Jump to content
  • 0

Question

Posted

1. ERROR in \PartyTeleporter.java <at line 74>

                For,L2Character character : zone.getCharactersInside<>.Values<>>

                                                                                                            ^^^^

The method values<> is undefined for the tybe L2tintObjectHashMap<L2Character>

----------

2. ERROR in \PartyTeleporter.java <at line 89>

                For,L2Character character : zone.getCharactersInside<>.Values<>>

----------

The method values<> is undefined for the tybe L2tintObjectHashMap<L2Character>

Recommended Posts

  • 0
Posted

  [javac] C:\Documents and Settings\Administrator\Desktop\WorckSpace\l2j-high-five\trunk\L2J_Server_High_Five\java\com\l2jserver\gameserver\model\zone\L2ZoneType.java:482: error: illegal start of expression

    [javac] public FastMap<Integer, L2Character> getCharactersInside()

    [javac] ^

    [javac] C:\Documents and Settings\Administrator\Desktop\WorckSpace\l2j-high-five\trunk\L2J_Server_High_Five\java\com\l2jserver\gameserver\model\zone\L2ZoneType.java:482: error: ';' expected

    [javac] public FastMap<Integer, L2Character> getCharactersInside()

    [javac]                                                         ^

    [javac] C:\Documents and Settings\Administrator\Desktop\WorckSpace\l2j-high-five\trunk\L2J_Server_High_Five\java\com\l2jserver\gameserver\model\zone\L2ZoneType.java:486: error: reached end of file while parsing

    [javac] }

    [javac] ^

    [javac] 3 errors

 

  • 0
Posted

Lock how i add the line.

 

 

public void visualizeZone(int z)

{

getZone().visualizeZone(z);

}

{

public FastMap<Integer, L2Character> getCharactersInside()

{

return _characterList;

}

}

  • 0
Posted
  public void visualizeZone(int z)

  {

      getZone().visualizeZone(z);

  }

 

      public FastMap<Integer, L2Character> getCharactersInside()

        {

            return _characterList;

        }

 

 

Try make it like that

  • 0
Posted

 

 

Try make it like that

 

javac] Compiling 1629 source files to C:\Documents and Settings\Administrator\Desktop\WorckSpace\l2j-high-five\trunk\L2J_Server_High_Five\build\classes

    [javac] C:\Documents and Settings\Administrator\Desktop\WorckSpace\l2j-high-five\trunk\L2J_Server_High_Five\java\com\l2jserver\gameserver\model\zone\L2ZoneType.java:485: error: reached end of file while parsing

    [javac]         }

    [javac]           ^

    [javac] 1 error

 

BUILD FAILED

C:\Documents and Settings\Administrator\Desktop\WorckSpace\l2j-high-five\trunk\L2J_Server_High_Five\build.xml:59: Compile failed; see the compiler error output for details.

 

 

If i put like this >>            public FastMap<Integer, L2Character> getCharactersInside()

        {

            return _characterList;

    }

    }

 

He give me the error

 

  [javac] Compiling 1629 source files to C:\Documents and Settings\Administrator\Desktop\WorckSpace\l2j-high-five\trunk\L2J_Server_High_Five\build\classes

    [javac] C:\Documents and Settings\Administrator\Desktop\WorckSpace\l2j-high-five\trunk\L2J_Server_High_Five\java\com\l2jserver\gameserver\model\zone\L2ZoneType.java:482: error: method getCharactersInside() is already defined in class L2ZoneType

    [javac]       public FastMap<Integer, L2Character> getCharactersInside()

    [javac]                                           ^

    [javac] C:\Documents and Settings\Administrator\Desktop\WorckSpace\l2j-high-five\trunk\L2J_Server_High_Five\java\com\l2jserver\gameserver\model\zone\L2ZoneType.java:484: error: incompatible types

    [javac]             return _characterList;

    [javac]                   ^

    [javac]  required: FastMap<Integer,L2Character>

    [javac]  found:    L2TIntObjectHashMap<L2Character>

    [javac] 2 errors

 

BUILD FAILED

C:\Documents and Settings\Administrator\Desktop\WorckSpace\l2j-high-five\trunk\L2J_Server_High_Five\build.xml:59: Compile failed; see the compiler error output for details.

  • 0
Posted

Show me the whole part of this code.

/*

* This program is free software: you can redistribute it and/or modify it under

* the terms of the GNU General Public License as published by the Free Software

* Foundation, either version 3 of the License, or (at your option) any later

* version.

*

* This program is distributed in the hope that it will be useful, but WITHOUT

* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more

* details.

*

* You should have received a copy of the GNU General Public License along with

* this program. If not, see <http://www.gnu.org/licenses/>.

*/

package com.l2jserver.gameserver.model.zone;

 

import gnu.trove.TObjectProcedure;

 

import java.util.Map;

import java.util.logging.Logger;

 

import javolution.util.FastList;

import javolution.util.FastMap;

 

import com.l2jserver.gameserver.model.L2Object;

import com.l2jserver.gameserver.model.L2Object.InstanceType;

import com.l2jserver.gameserver.model.actor.L2Character;

import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;

import com.l2jserver.gameserver.model.quest.Quest;

import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;

import com.l2jserver.gameserver.util.L2TIntObjectHashMap;

 

/**

* Abstract base class for any zone type

* Handles basic operations

*

* @author  durgus

*/

public abstract class L2ZoneType

{

protected static final Logger _log = Logger.getLogger(L2ZoneType.class.getName());

 

private final int _id;

protected L2ZoneForm _zone;

protected L2TIntObjectHashMap<L2Character> _characterList;

 

/** Parameters to affect specific characters */

private boolean _checkAffected = false;

 

private String _name = null;

private int _minLvl;

private int _maxLvl;

private int[] _race;

private int[] _class;

private char _classType;

private Map<Quest.QuestEventType, FastList<Quest>> _questEvents;

private InstanceType _target = InstanceType.L2Character; // default all chars

 

protected L2ZoneType(int id)

{

_id = id;

_characterList = new L2TIntObjectHashMap<L2Character>();

 

_minLvl = 0;

_maxLvl = 0xFF;

 

_classType = 0;

 

_race = null;

_class = null;

}

 

/**

* @return Returns the id.

*/

public int getId()

{

return _id;

}

 

/**

* Setup new parameters for this zone

* @param type

* @param value

*/

public void setParameter(String name, String value)

{

_checkAffected = true;

 

// Zone name

if (name.equals("name"))

{

_name = value;

}

// Minimum level

else if (name.equals("affectedLvlMin"))

{

_minLvl = Integer.parseInt(value);

}

// Maximum level

else if (name.equals("affectedLvlMax"))

{

_maxLvl = Integer.parseInt(value);

}

// Affected Races

else if (name.equals("affectedRace"))

{

// Create a new array holding the affected race

if (_race == null)

{

_race = new int[1];

_race[0] = Integer.parseInt(value);

}

else

{

int[] temp = new int[_race.length + 1];

 

int i = 0;

for (; i < _race.length; i++)

temp = _race;

 

temp = Integer.parseInt(value);

 

_race = temp;

}

}

// Affected classes

else if (name.equals("affectedClassId"))

{

// Create a new array holding the affected classIds

if (_class == null)

{

_class = new int[1];

_class[0] = Integer.parseInt(value);

}

else

{

int[] temp = new int[_class.length + 1];

 

int i = 0;

for (; i < _class.length; i++)

temp = _class;

 

temp = Integer.parseInt(value);

 

_class = temp;

}

}

// Affected class type

else if (name.equals("affectedClassType"))

{

if (value.equals("Fighter"))

{

_classType = 1;

}

else

{

_classType = 2;

}

}

else if (name.equals("targetClass"))

{

_target = Enum.valueOf(InstanceType.class, value);

}

else

_log.info(getClass().getSimpleName()+": Unknown parameter - "+name+" in zone: "+getId());

}

 

/**

* Checks if the given character is affected by this zone

* @param character

* @return

*/

private boolean isAffected(L2Character character)

{

// Check lvl

if (character.getLevel() < _minLvl || character.getLevel() > _maxLvl)

return false;

 

// check obj class

if (!character.isInstanceType(_target))

return false;

 

if (character instanceof L2PcInstance)

{

// Check class type

if (_classType != 0)

{

if (((L2PcInstance) character).isMageClass())

{

if (_classType == 1)

return false;

}

else if (_classType == 2)

return false;

}

 

// Check race

if (_race != null)

{

boolean ok = false;

 

for (int i = 0; i < _race.length; i++)

{

if (((L2PcInstance) character).getRace().ordinal() == _race)

{

ok = true;

break;

}

}

 

if (!ok)

return false;

}

 

// Check class

if (_class != null)

{

boolean ok = false;

 

for (int i = 0; i < _class.length; i++)

{

if (((L2PcInstance) character).getClassId().ordinal() == _class)

{

ok = true;

break;

}

}

 

if (!ok)

return false;

}

}

return true;

}

 

/**

* Set the zone for this L2ZoneType Instance

* @param zone

*/

public void setZone(L2ZoneForm zone)

{

if (_zone != null)

throw new IllegalStateException("Zone already set");

_zone = zone;

}

 

/**

* Returns this zones zone form

* @param zone

* @return

*/

public L2ZoneForm getZone()

{

return _zone;

}

 

/**

* Set the zone name.

* @param name

*/

public void setName(String name)

{

_name = name;

}

 

/**

* Returns zone name

* @return

*/

public String getName()

{

return _name;

}

 

/**

* Checks if the given coordinates are within zone's plane

* @param x

* @param y

*/

public boolean isInsideZone(int x, int y)

{

return _zone.isInsideZone(x, y, _zone.getHighZ());

}

 

/**

* Checks if the given coordinates are within the zone

* @param x

* @param y

* @param z

*/

public boolean isInsideZone(int x, int y, int z)

{

return _zone.isInsideZone(x, y, z);

}

 

/**

* Checks if the given object is inside the zone.

*

* @param object

*/

public boolean isInsideZone(L2Object object)

{

return isInsideZone(object.getX(), object.getY(), object.getZ());

}

 

public double getDistanceToZone(int x, int y)

{

return getZone().getDistanceToZone(x, y);

}

 

public double getDistanceToZone(L2Object object)

{

return getZone().getDistanceToZone(object.getX(), object.getY());

}

 

public void revalidateInZone(L2Character character)

{

// If the character can't be affected by this zone return

if (_checkAffected)

{

if (!isAffected(character))

return;

}

 

// If the object is inside the zone...

if (isInsideZone(character.getX(), character.getY(), character.getZ()))

{

// Was the character not yet inside this zone?

if (!_characterList.containsKey(character.getObjectId()))

{

FastList<Quest> quests = this.getQuestByEvent(Quest.QuestEventType.ON_ENTER_ZONE);

if (quests != null)

{

for (Quest quest : quests)

{

quest.notifyEnterZone(character, this);

}

}

_characterList.put(character.getObjectId(), character);

onEnter(character);

}

}

else

{

// Was the character inside this zone?

if (_characterList.containsKey(character.getObjectId()))

{

FastList<Quest> quests = this.getQuestByEvent(Quest.QuestEventType.ON_EXIT_ZONE);

if (quests != null)

{

for (Quest quest : quests)

{

quest.notifyExitZone(character, this);

}

}

_characterList.remove(character.getObjectId());

onExit(character);

}

}

}

 

/**

* Force fully removes a character from the zone

* Should use during teleport / logoff

* @param character

*/

public void removeCharacter(L2Character character)

{

if (_characterList.containsKey(character.getObjectId()))

{

FastList<Quest> quests = this.getQuestByEvent(Quest.QuestEventType.ON_EXIT_ZONE);

if (quests != null)

{

for (Quest quest : quests)

{

quest.notifyExitZone(character, this);

}

}

_characterList.remove(character.getObjectId());

onExit(character);

}

}

 

/**

* Will scan the zones char list for the character

* @param character

* @return

*/

public boolean isCharacterInZone(L2Character character)

{

return _characterList.containsKey(character.getObjectId());

}

 

protected abstract void onEnter(L2Character character);

 

protected abstract void onExit(L2Character character);

 

public abstract void onDieInside(L2Character character);

 

public abstract void onReviveInside(L2Character character);

 

public L2TIntObjectHashMap<L2Character> getCharactersInside()

{

return _characterList;

}

 

public L2Character[] getCharactersInsideArray()

{

return _characterList.getValues(new L2Character[_characterList.size()]);

}

 

public void addQuestEvent(Quest.QuestEventType EventType, Quest q)

{

if (_questEvents == null)

_questEvents = new FastMap<Quest.QuestEventType, FastList<Quest>>();

FastList<Quest> questByEvents = _questEvents.get(EventType);

if (questByEvents == null)

questByEvents = new FastList<Quest>();

if (!questByEvents.contains(q))

questByEvents.add(q);

_questEvents.put(EventType, questByEvents);

}

 

public FastList<Quest> getQuestByEvent(Quest.QuestEventType EventType)

{

if (_questEvents == null)

return null;

return _questEvents.get(EventType);

}

 

/**

* Broadcasts packet to all players inside the zone

*/

public void broadcastPacket(L2GameServerPacket packet)

{

if (_characterList.isEmpty())

return;

 

_characterList.forEachValue(new BroadcastPacket(packet));

}

 

private final class BroadcastPacket implements TObjectProcedure<L2Character>

{

final L2GameServerPacket _packet;

private BroadcastPacket(L2GameServerPacket packet)

{

_packet = packet;

}

 

@Override

public final boolean execute(final L2Character character)

{

if (character != null && character instanceof L2PcInstance)

character.sendPacket(_packet);

return true;

}

}

 

public InstanceType getTargetType()

{

return _target;

}

 

public void setTargetType(InstanceType type)

{

_target = type;

_checkAffected = true;

}

 

@Override

public String toString()

{

return getClass().getSimpleName()+"["+ _id + "]";

}

 

  public void visualizeZone(int z)

  {

      getZone().visualizeZone(z);

  }

 

      public FastMap<Integer, L2Character> getCharactersInside()

        {

            return _characterList;

    }

    }

  • 0
Posted

-public L2TIntObjectHashMap<L2Character> getCharactersInside()
-        {
-		return _characterList;
-	}
+	public FastMap<Integer, L2Character> getCharactersInside()
+  {
+      return _characterList;
+	}

 

 

Press a lot of times Ctrl+Z till code gets to retail. Then try to change this

Guest
This topic is now closed to further replies.


  • Posts

    • DISCORD : utchiha_market telegram : https://t.me/utchiha_market SELLIX STORE : https://utchiha.sellpass.io/ Join our server for more products : https://discord.gg/uthciha-services https://campsite.bio/utchihaamkt  
    • DISCORD : utchiha_market telegram : https://t.me/utchiha_market SELLIX STORE : https://utchiha.sellpass.io/ Join our server for more products : https://discord.gg/uthciha-services https://campsite.bio/utchihaamkt  
    • DISCORD : utchiha_market telegram : https://t.me/utchiha_market SELLIX STORE : https://utchiha.sellpass.io/ Join our server for more products : https://discord.gg/uthciha-services https://campsite.bio/utchihaamkt  
    • DISCORD : utchiha_market telegram : https://t.me/utchiha_market SELLIX STORE : https://utchiha.sellpass.io/ Join our server for more products : https://discord.gg/uthciha-services https://campsite.bio/utchihaamkt  
    • Hello everyone, I would like some help adapting this file for a custom community board l2jFrozen:   package com.l2jfrozen.gameserver.communitybbs; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Map; import java.util.StringTokenizer; import javolution.util.FastMap; import com.l2jfrozen.Config; import com.l2jfrozen.gameserver.cache.HtmCache; import com.l2jfrozen.gameserver.communitybbs.Manager.BaseBBSManager; import com.l2jfrozen.gameserver.communitybbs.Manager.ClanBBSManager; import com.l2jfrozen.gameserver.communitybbs.Manager.PostBBSManager; import com.l2jfrozen.gameserver.communitybbs.Manager.RegionBBSManager; import com.l2jfrozen.gameserver.communitybbs.Manager.TeleBBSManager; import com.l2jfrozen.gameserver.communitybbs.Manager.TopicBBSManager; import com.l2jfrozen.gameserver.communitybbs.Manager.shopBBSManager; import com.l2jfrozen.gameserver.handler.IBBSHandler; import com.l2jfrozen.gameserver.model.L2Clan; import com.l2jfrozen.gameserver.model.L2World; import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; import com.l2jfrozen.gameserver.model.multisell.L2Multisell; import com.l2jfrozen.gameserver.network.L2GameClient; import com.l2jfrozen.gameserver.network.SystemMessageId; import com.l2jfrozen.gameserver.network.serverpackets.ShowBoard; import com.l2jfrozen.gameserver.network.serverpackets.SystemMessage; public class CommunityBoard { private static CommunityBoard _instance; private final Map<String, IBBSHandler> _handlers; protected final SimpleDateFormat fmt = new SimpleDateFormat("H:mm."); public CommunityBoard() { _handlers = new FastMap<>(); // null; } public boolean checkPlayerConditions(L2PcInstance activeChar, String command) { if (activeChar.isInOlympiadMode()) { activeChar.sendMessage("CommunityBoard use is prohibited at the Olympiad"); return false; } if (activeChar.isFlying() || activeChar.isMounted()) { activeChar.sendMessage("CommunityBoard use is prohibited at while flying or mounted!"); return false; } if (activeChar.inObserverMode()) { activeChar.sendMessage("CommunityBoard use is prohibited in ObserveMode!"); return false; } if (activeChar.isAlikeDead() || activeChar.isDead()) { activeChar.sendMessage("CommunityBoard use is prohibited While Dead"); return false; } if (activeChar.isInCombat()) { activeChar.sendMessage("CommunityBoard use is prohibited in Combat!"); return false; } if (activeChar.isCastingNow()) { activeChar.sendMessage("CommunityBoard use is prohibited while Casting!"); return false; } if (activeChar.isAttackingNow()) { activeChar.sendMessage("CommunityBoard use is prohibited while Attacking!"); return false; } if (activeChar.isInDuel()) { activeChar.sendMessage("CommunityBoard use is prohibited while Playing Duel!"); return false; } if (activeChar.isFishing()) { activeChar.sendMessage("CommunityBoard use is prohibited while Fishing!"); return false; } if (activeChar.isInStoreMode()) { activeChar.sendMessage("CommunityBoard use is prohibited in StoreMode!"); return false; } if (activeChar.isInJail() || activeChar.isCursedWeaponEquipped() || activeChar.isFlying() || activeChar.isInBoat() || activeChar.isProcessingTransaction() || activeChar.isStunned()) { activeChar.sendMessage("CommunityBoard use is prohibited right now!"); return false; } return true; } public static CommunityBoard getInstance() { if (_instance == null) { _instance = new CommunityBoard(); } return _instance; } /** * by Azagthtot * @param handler as IBBSHandler */ public void registerBBSHandler(final IBBSHandler handler) { for (final String s : handler.getBBSCommands()) { _handlers.put(s, handler); } } /** * by Azagthtot * @param client * @param command */ public void handleCommands(final L2GameClient client, final String command) { L2PcInstance activeChar = client.getActiveChar(); if (activeChar == null) return; if(!checkPlayerConditions(activeChar, command)) return; if (Config.COMMUNITY_TYPE.equals("full")) { String cmd = command.substring(4); String params = ""; final int iPos = cmd.indexOf(" "); if (iPos != -1) { params = cmd.substring(iPos + 1); cmd = cmd.substring(0, iPos); } final IBBSHandler bbsh = _handlers.get(cmd); if (bbsh != null) { bbsh.handleCommand(cmd, activeChar, params); } else { if (command.startsWith("_bbsclan")) { String text = HtmCache.getInstance().getHtm("data/html/CommunityBoard/index.htm"); //Custom Community Board text = text.replace("%CharName%", String.valueOf(activeChar.getName())); text = text.replace("%CharClass%", String.valueOf(activeChar.getClassId().name())); text = text.replace("%CharLevel%", String.valueOf(activeChar.getLevel())); if (activeChar.isNoble()) { text = text.replace("%nobless%", "Yes"); } else { text = text.replace("%nobless%", "No"); } L2Clan clan = activeChar.getClan(); if (clan != null) { text = text.replace("%CharClan%", String.valueOf(activeChar.getClan().getName())); } else { text = text.replace("%CharClan%", "No Clan"); } text = text.replace("%CharIP%", String.valueOf(activeChar.getClient().getConnection().getInetAddress().getHostAddress())); text = text.replace("%PlayerOnline%", String.valueOf(L2World.getInstance().getAllPlayers().size()* 1)); text = text.replace("%ServerTime%", fmt.format(new Date(System.currentTimeMillis()))); //Custom Community Board BaseBBSManager.separateAndSend(text, activeChar); } else if (command.startsWith("_bbsmemo")) { String text = HtmCache.getInstance().getHtm("data/html/CommunityBoard/index.htm"); //Custom Community Board text = text.replace("%CharName%", String.valueOf(activeChar.getName())); text = text.replace("%CharClass%", String.valueOf(activeChar.getClassId().name())); text = text.replace("%CharLevel%", String.valueOf(activeChar.getLevel())); if (activeChar.isNoble()) { text = text.replace("%nobless%", "Yes"); } else { text = text.replace("%nobless%", "No"); } L2Clan clan = activeChar.getClan(); if (clan != null) { text = text.replace("%CharClan%", String.valueOf(activeChar.getClan().getName())); } else { text = text.replace("%CharClan%", "No Clan"); } text = text.replace("%CharIP%", String.valueOf(activeChar.getClient().getConnection().getInetAddress().getHostAddress())); text = text.replace("%PlayerOnline%", String.valueOf(L2World.getInstance().getAllPlayers().size()* 1)); text = text.replace("%ServerTime%", fmt.format(new Date(System.currentTimeMillis()))); //Custom Community Board BaseBBSManager.separateAndSend(text, activeChar); } else if (command.startsWith("_bbsgetfav")) { String text = HtmCache.getInstance().getHtm("data/html/CommunityBoard/index.htm"); //Custom Community Board text = text.replace("%CharName%", String.valueOf(activeChar.getName())); text = text.replace("%CharClass%", String.valueOf(activeChar.getClassId().name())); text = text.replace("%CharLevel%", String.valueOf(activeChar.getLevel())); if (activeChar.isNoble()) { text = text.replace("%nobless%", "Yes"); } else { text = text.replace("%nobless%", "No"); } L2Clan clan = activeChar.getClan(); if (clan != null) { text = text.replace("%CharClan%", String.valueOf(activeChar.getClan().getName())); } else { text = text.replace("%CharClan%", "No Clan"); } text = text.replace("%CharIP%", String.valueOf(activeChar.getClient().getConnection().getInetAddress().getHostAddress())); text = text.replace("%PlayerOnline%", String.valueOf(L2World.getInstance().getAllPlayers().size()* 1)); text = text.replace("%ServerTime%", fmt.format(new Date(System.currentTimeMillis()))); //Custom Community Board BaseBBSManager.separateAndSend(text, activeChar); } else if (command.startsWith("_bbstopics")) { String text = HtmCache.getInstance().getHtm("data/html/CommunityBoard/index.htm"); //Custom Community Board text = text.replace("%CharName%", String.valueOf(activeChar.getName())); text = text.replace("%CharClass%", String.valueOf(activeChar.getClassId().name())); text = text.replace("%CharLevel%", String.valueOf(activeChar.getLevel())); if (activeChar.isNoble()) { text = text.replace("%nobless%", "Yes"); } else { text = text.replace("%nobless%", "No"); } L2Clan clan = activeChar.getClan(); if (clan != null) { text = text.replace("%CharClan%", String.valueOf(activeChar.getClan().getName())); } else { text = text.replace("%CharClan%", "No Clan"); } text = text.replace("%CharIP%", String.valueOf(activeChar.getClient().getConnection().getInetAddress().getHostAddress())); text = text.replace("%PlayerOnline%", String.valueOf(L2World.getInstance().getAllPlayers().size()* 1)); text = text.replace("%ServerTime%", fmt.format(new Date(System.currentTimeMillis()))); //Custom Community Board BaseBBSManager.separateAndSend(text, activeChar); } else if (command.startsWith("_bbsposts")) { String text = HtmCache.getInstance().getHtm("data/html/CommunityBoard/index.htm"); //Custom Community Board text = text.replace("%CharName%", String.valueOf(activeChar.getName())); text = text.replace("%CharClass%", String.valueOf(activeChar.getClassId().name())); text = text.replace("%CharLevel%", String.valueOf(activeChar.getLevel())); if (activeChar.isNoble()) { text = text.replace("%nobless%", "Yes"); } else { text = text.replace("%nobless%", "No"); } L2Clan clan = activeChar.getClan(); if (clan != null) { text = text.replace("%CharClan%", String.valueOf(activeChar.getClan().getName())); } else { text = text.replace("%CharClan%", "No Clan"); } text = text.replace("%CharIP%", String.valueOf(activeChar.getClient().getConnection().getInetAddress().getHostAddress())); text = text.replace("%PlayerOnline%", String.valueOf(L2World.getInstance().getAllPlayers().size()* 1)); text = text.replace("%ServerTime%", fmt.format(new Date(System.currentTimeMillis()))); //Custom Community Board BaseBBSManager.separateAndSend(text, activeChar); } else if (command.startsWith("_bbstop")) { String text = HtmCache.getInstance().getHtm("data/html/CommunityBoard/index.htm"); //Custom Community Board text = text.replace("%CharName%", String.valueOf(activeChar.getName())); text = text.replace("%CharClass%", String.valueOf(activeChar.getClassId().name())); text = text.replace("%CharLevel%", String.valueOf(activeChar.getLevel())); if (activeChar.isNoble()) { text = text.replace("%nobless%", "Yes"); } else { text = text.replace("%nobless%", "No"); } L2Clan clan = activeChar.getClan(); if (clan != null) { text = text.replace("%CharClan%", String.valueOf(activeChar.getClan().getName())); } else { text = text.replace("%CharClan%", "No Clan"); } text = text.replace("%CharIP%", String.valueOf(activeChar.getClient().getConnection().getInetAddress().getHostAddress())); text = text.replace("%PlayerOnline%", String.valueOf(L2World.getInstance().getAllPlayers().size()* 1)); text = text.replace("%ServerTime%", fmt.format(new Date(System.currentTimeMillis()))); //Custom Community Board BaseBBSManager.separateAndSend(text, activeChar); } else if (command.startsWith("_bbshome")) { String text = HtmCache.getInstance().getHtm("data/html/CommunityBoard/index.htm"); //Custom Community Board text = text.replace("%CharName%", String.valueOf(activeChar.getName())); text = text.replace("%CharClass%", String.valueOf(activeChar.getClassId().name())); text = text.replace("%CharLevel%", String.valueOf(activeChar.getLevel())); if (activeChar.isNoble()) { text = text.replace("%nobless%", "Yes"); } else { text = text.replace("%nobless%", "No"); } L2Clan clan = activeChar.getClan(); if (clan != null) { text = text.replace("%CharClan%", String.valueOf(activeChar.getClan().getName())); } else { text = text.replace("%CharClan%", "No Clan"); } text = text.replace("%CharIP%", String.valueOf(activeChar.getClient().getConnection().getInetAddress().getHostAddress())); text = text.replace("%PlayerOnline%", String.valueOf(L2World.getInstance().getAllPlayers().size()* 1)); text = text.replace("%ServerTime%", fmt.format(new Date(System.currentTimeMillis()))); //Custom Community Board BaseBBSManager.separateAndSend(text, activeChar); } else if (command.startsWith("_bbsloc")) { String text = HtmCache.getInstance().getHtm("data/html/CommunityBoard/index.htm"); //Custom Community Board text = text.replace("%CharName%", String.valueOf(activeChar.getName())); text = text.replace("%CharClass%", String.valueOf(activeChar.getClassId().name())); text = text.replace("%CharLevel%", String.valueOf(activeChar.getLevel())); if (activeChar.isNoble()) { text = text.replace("%nobless%", "Yes"); } else { text = text.replace("%nobless%", "No"); } L2Clan clan = activeChar.getClan(); if (clan != null) { text = text.replace("%CharClan%", String.valueOf(activeChar.getClan().getName())); } else { text = text.replace("%CharClan%", "No Clan"); } text = text.replace("%CharIP%", String.valueOf(activeChar.getClient().getConnection().getInetAddress().getHostAddress())); text = text.replace("%PlayerOnline%", String.valueOf(L2World.getInstance().getAllPlayers().size()* 1)); text = text.replace("%ServerTime%", fmt.format(new Date(System.currentTimeMillis()))); //Custom Community Board BaseBBSManager.separateAndSend(text, activeChar); } else if (command.startsWith("_bbstele")) { TeleBBSManager.getInstance().parsecmd(command, activeChar); } else if (command.startsWith("_bbsShop")) { shopBBSManager.getInstance().parsecmd(command, activeChar); } else if(command.startsWith("_bbsmultisell;")) { StringTokenizer st = new StringTokenizer(command, ";"); st.nextToken(); shopBBSManager.getInstance().parsecmd("_bbsShop;" + st.nextToken(), activeChar); L2Multisell.getInstance().SeparateAndSend(Integer.parseInt(st.nextToken()), activeChar, false, 0); } else { ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + command + " is not implemented yet</center><br><br></body></html>", "101"); activeChar.sendPacket(sb); sb = null; activeChar.sendPacket(new ShowBoard(null, "102")); activeChar.sendPacket(new ShowBoard(null, "103")); } } } else if (Config.COMMUNITY_TYPE.equals("old")) { RegionBBSManager.getInstance().parsecmd(command, activeChar); } else { activeChar.sendPacket(new SystemMessage(SystemMessageId.CB_OFFLINE)); } activeChar = null; } /** * @param client * @param url * @param arg1 * @param arg2 * @param arg3 * @param arg4 * @param arg5 */ public void handleWriteCommands(final L2GameClient client, final String url, final String arg1, final String arg2, final String arg3, final String arg4, final String arg5) { L2PcInstance activeChar = client.getActiveChar(); if (activeChar == null) return; if (Config.COMMUNITY_TYPE.equals("full")) { if (url.equals("Topic")) { TopicBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar); } else if (url.equals("Post")) { PostBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar); } else if (url.equals("Region")) { RegionBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar); } else if (url.equals("Notice")) { ClanBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar); } else { ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + url + " is not implemented yet</center><br><br></body></html>", "101"); activeChar.sendPacket(sb); sb = null; activeChar.sendPacket(new ShowBoard(null, "102")); activeChar.sendPacket(new ShowBoard(null, "103")); } } else if (Config.COMMUNITY_TYPE.equals("old")) { RegionBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar); } else { ShowBoard sb = new ShowBoard("<html><body><br><br><center>The Community board is currently disable</center><br><br></body></html>", "101"); activeChar.sendPacket(sb); sb = null; activeChar.sendPacket(new ShowBoard(null, "102")); activeChar.sendPacket(new ShowBoard(null, "103")); } activeChar = null; } }   And making it work in another l2jOrion project:   package l2jorion.game.community; import java.util.HashMap; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import l2jorion.Config; import l2jorion.game.community.manager.BaseBBSManager; import l2jorion.game.community.manager.ClanBBSManager; import l2jorion.game.community.manager.FavoriteBBSManager; import l2jorion.game.community.manager.FriendsBBSManager; import l2jorion.game.community.manager.MailBBSManager; import l2jorion.game.community.manager.PostBBSManager; import l2jorion.game.community.manager.RankBBSManager; import l2jorion.game.community.manager.RegionBBSManager; import l2jorion.game.community.manager.TopBBSManager; import l2jorion.game.community.manager.TopicBBSManager; import l2jorion.game.handler.ICommunityBoardHandler; import l2jorion.game.model.actor.instance.L2PcInstance; import l2jorion.game.network.L2GameClient; import l2jorion.game.network.SystemMessageId; import l2jorion.logger.Logger; import l2jorion.logger.LoggerFactory; public class CommunityBoardManager { protected static Logger LOG = LoggerFactory.getLogger(CommunityBoardManager.class); private Map<String, ICommunityBoardHandler> _handlers = new HashMap<>(); private final Map<Integer, String> _bypasses = new ConcurrentHashMap<>(); private static CommunityBoardManager _instance; public static CommunityBoardManager getInstance() { if (_instance == null) { _instance = new CommunityBoardManager(); } return _instance; } private CommunityBoardManager() { registerBBSHandler(new TopBBSManager()); registerBBSHandler(new FavoriteBBSManager()); registerBBSHandler(new RegionBBSManager()); registerBBSHandler(new ClanBBSManager()); registerBBSHandler(new TopicBBSManager()); registerBBSHandler(new MailBBSManager()); registerBBSHandler(new FriendsBBSManager()); registerBBSHandler(new TopicBBSManager()); registerBBSHandler(new PostBBSManager()); registerBBSHandler(new RankBBSManager()); LOG.info("CommunityBoardHandlers: Loaded " + _handlers.size() + " handlers"); } public void registerBBSHandler(ICommunityBoardHandler handler) { for (String bypass : handler.getBypassBbsCommands()) { if (_handlers.containsKey(bypass)) { continue; } _handlers.put(bypass, handler); } } public void onBypassCommand(L2GameClient client, String command) { final L2PcInstance player = client.getActiveChar(); if (player == null) { return; } if (Config.COMMUNITY_TYPE.equals("off")) { player.sendPacket(SystemMessageId.CB_OFFLINE); return; } /* * if (!AutoImageSenderManager.wereAllImagesSent(player)) { player.sendMessage("Community wasn't loaded yet, try again in few seconds."); player.sendPacket(new ExShowScreenMessage("Community wasn't loaded yet, try again in few seconds.", 2000, 2, false)); return; } */ String cmd = command.substring(4); String params = ""; final int iPos = cmd.indexOf(" "); if (iPos != -1) { params = cmd.substring(iPos + 1); cmd = cmd.substring(0, iPos); } ICommunityBoardHandler bypass = _handlers.get(cmd); if (bypass != null) { bypass.handleCommand(cmd, player, params); } else { if (command.startsWith("_bbshome")) { TopBBSManager.getInstance().parseCmd(command, player); } else if (command.startsWith("_bbsgetfav") || command.startsWith("bbs_add_fav") || command.startsWith("_bbsdelfav_")) { FavoriteBBSManager.getInstance().parseCmd(command, player); } else if (command.startsWith("_bbsloc")) { RegionBBSManager.getInstance().parseCmd(command, player); } else if (command.startsWith("_bbsclan")) { ClanBBSManager.getInstance().parseCmd(command, player); } else if (command.startsWith("_bbsmemo")) { TopicBBSManager.getInstance().parseCmd(command, player); } else if (command.startsWith("_bbsmail") || command.equals("_maillist_0_1_0_")) { MailBBSManager.getInstance().parseCmd(command, player); } else if (command.startsWith("_friend") || command.startsWith("_block")) { FriendsBBSManager.getInstance().parseCmd(command, player); } else if (command.startsWith("_bbstopics")) { TopicBBSManager.getInstance().parseCmd(command, player); } else if (command.startsWith("_bbsposts")) { PostBBSManager.getInstance().parseCmd(command, player); } else if (command.startsWith("_bbsshowrank")) { RankBBSManager.getInstance().parseCmd(command, player); } else { BaseBBSManager.separateAndSend("<html><body><br><br><center>The command: " + command + " isn't implemented.</center></body></html>", player); } } } public void handleWriteCommands(L2GameClient client, String url, String arg1, String arg2, String arg3, String arg4, String arg5) { final L2PcInstance player = client.getActiveChar(); if (player == null) { return; } if (Config.COMMUNITY_TYPE.equals("off")) { player.sendPacket(SystemMessageId.CB_OFFLINE); return; } if (url.equals("Topic")) { TopicBBSManager.getInstance().parseWrite(arg1, arg2, arg3, arg4, arg5, player); } else if (url.equals("Post")) { PostBBSManager.getInstance().parseWrite(arg1, arg2, arg3, arg4, arg5, player); } else if (url.equals("_bbsloc")) { RegionBBSManager.getInstance().parseWrite(arg1, arg2, arg3, arg4, arg5, player); } else if (url.equals("_bbsclan")) { ClanBBSManager.getInstance().parseWrite(arg1, arg2, arg3, arg4, arg5, player); } else if (url.equals("Mail")) { MailBBSManager.getInstance().parseWrite(arg1, arg2, arg3, arg4, arg5, player); } else if (url.equals("Clan")) { ClanBBSManager.getInstance().parseWrite(arg1, arg2, arg3, arg4, arg5, player); } else if (url.equals("_friend")) { FriendsBBSManager.getInstance().parseWrite(arg1, arg2, arg3, arg4, arg5, player); } else { BaseBBSManager.separateAndSend("<html><body><br><br><center>The command: " + url + " isn't implemented.</center></body></html>", player); } } public ICommunityBoardHandler getCommunityHandler(String bypass) { if (_handlers.isEmpty()) { return null; } for (Map.Entry<String, ICommunityBoardHandler> entry : _handlers.entrySet()) { if (bypass.contains(entry.getKey())) { return entry.getValue(); } } return null; } public void addBypass(L2PcInstance player, String title, String bypass) { _bypasses.put(player.getObjectId(), title + "&" + bypass); } public String removeBypass(L2PcInstance player) { return _bypasses.remove(player.getObjectId()); } public Map<Integer, String> getAllBypass() { return _bypasses; } }  
  • Topics

×
×
  • Create New...