Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P gameserver
- Index: java/com/l2jpes/gameserver/model/actor/knownlist/PlayerKnownList.java
- ===================================================================
- --- java/com/l2jpes/gameserver/model/actor/knownlist/PlayerKnownList.java (revision 17)
- +++ java/com/l2jpes/gameserver/model/actor/knownlist/PlayerKnownList.java (working copy)
- @@ -35,6 +35,9 @@
- if (object instanceof L2PlayerInstance && ((L2PlayerInstance) object).inObserverMode())
- continue;
- + if (object.getDimensionId() != getActiveChar().getDimensionId())
- + continue;
- +
- sendInfoFrom(object);
- }
- }
- Index: java/com/l2jpes/gameserver/handler/voicedcommandhandlers/DimensionCmd.java
- ===================================================================
- --- java/com/l2jpes/gameserver/handler/voicedcommandhandlers/DimensionCmd.java (revision 0)
- +++ java/com/l2jpes/gameserver/handler/voicedcommandhandlers/DimensionCmd.java (working copy)
- @@ -0,0 +1,104 @@
- +/*
- + * 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.l2jpes.gameserver.handler.voicedcommandhandlers;
- +
- +import com.l2jpes.Config;
- +import com.l2jpes.gameserver.handler.impl.IVoicedCommandHandler;
- +import com.l2jpes.gameserver.model.L2Object;
- +import com.l2jpes.gameserver.model.L2World;
- +import com.l2jpes.gameserver.model.actor.instance.L2PlayerInstance;
- +import com.l2jpes.gameserver.network.serverpackets.NpcHtmlMessage;
- +
- +/**
- + * @author Pauler
- + */
- +public class DimensionCmd implements IVoicedCommandHandler
- +{
- +
- + private String[] commands = {
- + "dimension"
- + };
- +
- + @Override
- + public boolean useVoicedCommand(String command, L2PlayerInstance player, String[] commandParams)
- + {
- + if (Config.ENABLE_DIMENSION_COMMAND) {
- + if ((Config.DIMENSION_COMMAND_ADMIN_ONLY && player.isGM()) || !Config.DIMENSION_COMMAND_ADMIN_ONLY) {
- + if (commandParams != null) {
- + int dimensionId;
- +
- + try {
- + dimensionId = Integer.parseInt(commandParams[0]);
- + }catch(NumberFormatException e) {
- + player.sendMessage("You have to type a valid id.");
- + return false;
- + }
- +
- + if (dimensionId <= Config.MAX_DIMENSIONS) {
- + if (player.getDimensionId() != dimensionId) {
- + changeDimension(player, dimensionId);
- + player.sendMessage("You are transfered to dimension " + dimensionId + ".");
- + }else{
- + player.sendMessage("You already are in this dimension.");
- + }
- + }else
- + player.sendMessage("There are only " + Config.MAX_DIMENSIONS + " dimensions.");
- + }else{
- + NpcHtmlMessage msg = new NpcHtmlMessage(20);
- + msg.setHtml(showWindow(player));
- + msg.replace("%objectId%", String.valueOf(20));
- + player.sendPacket(msg);
- + }
- + }
- + }
- +
- + return true;
- + }
- +
- + private static void changeDimension(L2PlayerInstance player, int dimensionId) {
- + player.setDimensionId(dimensionId);
- + player.teleToLocation(player.getX(), player.getY(), player.getZ(), 0);
- + }
- +
- + private static String showWindow(L2PlayerInstance player) {
- + StringBuilder st = new StringBuilder();
- +
- + st.append("<html><head><title>L2JPes Open Source - Dimensions</title></head><body>");
- + for (int i = 1; i < Config.MAX_DIMENSIONS + 1; i++) {
- + st.append("<a action=\"bypass -h dimension " + i + "\" width=204 height=20>Dimension(" + i + ")-> " + getObjectCount(i) + " Objects.</a><br>");
- + }
- + st.append("</body></html>");
- +
- + return st.toString();
- + }
- +
- + private static int getObjectCount(int dimensionId) {
- + int objectCount = 0;
- +
- + for (L2Object obj:L2World.getInstance().getAllVisibleObjects().values()) {
- + if (obj.getDimensionId() == dimensionId)
- + objectCount++;
- + }
- +
- + return objectCount;
- + }
- +
- + @Override
- + public String[] getVoicedCommandList()
- + {
- + return commands;
- + }
- +
- +}
- Index: java/com/l2jpes/gameserver/network/clientpackets/Action.java
- ===================================================================
- --- java/com/l2jpes/gameserver/network/clientpackets/Action.java (revision 13)
- +++ java/com/l2jpes/gameserver/network/clientpackets/Action.java (working copy)
- @@ -72,6 +72,11 @@
- return;
- }
- + if (obj.getDimensionId() != activeChar.getDimensionId()) {
- + activeChar.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- +
- if (!activeChar.isGM() && activeChar.isOutOfControl())
- {
- activeChar.sendPacket(ActionFailed.STATIC_PACKET);
- Index: java/com/l2jpes/gameserver/handler/admincommandhandlers/AdminSpawn.java
- ===================================================================
- --- java/com/l2jpes/gameserver/handler/admincommandhandlers/AdminSpawn.java (revision 14)
- +++ java/com/l2jpes/gameserver/handler/admincommandhandlers/AdminSpawn.java (working copy)
- @@ -267,6 +267,7 @@
- spawn.setLocz(target.getZ());
- spawn.setHeading(activeChar.getHeading());
- spawn.setRespawnDelay(respawnTime);
- + spawn.setDimensionId(activeChar.getDimensionId());
- if (RaidBossSpawnManager.getInstance().getValidTemplate(spawn.getNpcId()) != null)
- {
- Index: java/com/l2jpes/gameserver/datatables/SpawnTable.java
- ===================================================================
- --- java/com/l2jpes/gameserver/datatables/SpawnTable.java (revision 5)
- +++ java/com/l2jpes/gameserver/datatables/SpawnTable.java (working copy)
- @@ -94,6 +94,11 @@
- spawnDat.setHeading(rset.getInt("heading"));
- spawnDat.setRespawnDelay(rset.getInt("respawn_delay"));
- + if (rset.getInt("dimensionid") == 0)
- + spawnDat.setDimensionId(1);
- + else
- + spawnDat.setDimensionId(rset.getInt("dimensionid"));
- +
- switch (rset.getInt("periodOfDay"))
- {
- case 0: // default
- @@ -141,13 +146,14 @@
- {
- try (Connection con = L2DatabaseFactory.getInstance().getConnection())
- {
- - PreparedStatement statement = con.prepareStatement("INSERT INTO spawnlist (npc_templateid,locx,locy,locz,heading,respawn_delay) values(?,?,?,?,?,?)");
- + PreparedStatement statement = con.prepareStatement("INSERT INTO spawnlist (npc_templateid,locx,locy,locz,heading,respawn_delay,dimensionid) values(?,?,?,?,?,?,?)");
- statement.setInt(1, spawn.getNpcId());
- statement.setInt(2, spawn.getLocx());
- statement.setInt(3, spawn.getLocy());
- statement.setInt(4, spawn.getLocz());
- statement.setInt(5, spawn.getHeading());
- statement.setInt(6, spawn.getRespawnDelay() / 1000);
- + statement.setInt(7, spawn.getDimensionId());
- statement.execute();
- statement.close();
- }
- Index: java/com/l2jpes/gameserver/handler/skillhandlers/Continuous.java
- ===================================================================
- --- java/com/l2jpes/gameserver/handler/skillhandlers/Continuous.java (revision 14)
- +++ java/com/l2jpes/gameserver/handler/skillhandlers/Continuous.java (working copy)
- @@ -78,6 +78,10 @@
- if (!(obj instanceof L2Character))
- continue;
- + if (obj.getDimensionId() != activeChar.getDimensionId()) {
- + continue;
- + }
- +
- L2Character target = ((L2Character) obj);
- if (Formulas.calcSkillReflect(target, skill) == Formulas.SKILL_REFLECT_SUCCEED)
- target = activeChar;
- Index: java/com/l2jpes/gameserver/network/clientpackets/RequestBypassToServer.java
- ===================================================================
- --- java/com/l2jpes/gameserver/network/clientpackets/RequestBypassToServer.java (revision 14)
- +++ java/com/l2jpes/gameserver/network/clientpackets/RequestBypassToServer.java (working copy)
- @@ -186,6 +186,17 @@
- return;
- }
- }
- + else if (_command.startsWith("dimension")) {
- + StringTokenizer st = new StringTokenizer(_command);
- +
- + st.nextToken();
- +
- + int dimensionId = Integer.parseInt(st.nextToken());
- +
- + activeChar.sendMessage("You are transfered to dimension " + dimensionId + ".");
- + activeChar.setDimensionId(dimensionId);
- + activeChar.teleToLocation(activeChar.getX(), activeChar.getY(), activeChar.getZ(), 0);
- + }
- }
- catch (Exception e)
- {
- Index: java/com/l2jpes/Config.java
- ===================================================================
- --- java/com/l2jpes/Config.java (revision 16)
- +++ java/com/l2jpes/Config.java (working copy)
- @@ -644,6 +644,10 @@
- public static boolean ENABLE_ONLINE_COMMAND;
- public static boolean ENABLE_ONLINE_PARAM;
- + public static boolean ENABLE_DIMENSION_COMMAND;
- + public static boolean DIMENSION_COMMAND_ADMIN_ONLY;
- + public static int MAX_DIMENSIONS;
- +
- // --------------------------------------------------
- // Those "hidden" settings haven't configs to avoid admins to fuck their server
- // You still can experiment changing values here. But don't say I didn't warn you.
- @@ -1323,6 +1327,10 @@
- ENABLE_ONLINE_COMMAND = general.getProperty("EnableOnlineCmd", false);
- ENABLE_ONLINE_PARAM = general.getProperty("EnableOnlineParam", false);
- +
- + ENABLE_DIMENSION_COMMAND = general.getProperty("EnableDimensionCmd", false);
- + DIMENSION_COMMAND_ADMIN_ONLY = general.getProperty("AdminOnlyDimensionCommand", false);
- + MAX_DIMENSIONS = general.getProperty("MaxDimensions", 20);
- }
- else if (Server.serverMode == Server.MODE_LOGINSERVER)
- {
- Index: java/com/l2jpes/gameserver/model/L2Object.java
- ===================================================================
- --- java/com/l2jpes/gameserver/model/L2Object.java (revision 13)
- +++ java/com/l2jpes/gameserver/model/L2Object.java (working copy)
- @@ -33,6 +33,7 @@
- private int _objectId; // Object identifier
- private ObjectPoly _poly;
- private ObjectPosition _position;
- + private int dimensionId = 1;
- public L2Object(int objectId)
- {
- @@ -344,4 +345,12 @@
- {
- return (getClass().getSimpleName() + ":" + getName() + "[" + getObjectId() + "]");
- }
- +
- + public int getDimensionId() {
- + return dimensionId;
- + }
- +
- + public void setDimensionId(int dimensionId) {
- + this.dimensionId = dimensionId;
- + }
- }
- \ No newline at end of file
- Index: java/com/l2jpes/gameserver/handler/VoicedCommandHandler.java
- ===================================================================
- --- java/com/l2jpes/gameserver/handler/VoicedCommandHandler.java (revision 16)
- +++ java/com/l2jpes/gameserver/handler/VoicedCommandHandler.java (working copy)
- @@ -20,6 +20,7 @@
- import com.l2jpes.Config;
- import com.l2jpes.gameserver.handler.impl.IVoicedCommandHandler;
- +import com.l2jpes.gameserver.handler.voicedcommandhandlers.DimensionCmd;
- import com.l2jpes.gameserver.handler.voicedcommandhandlers.L2JPesCmd;
- import com.l2jpes.gameserver.handler.voicedcommandhandlers.OnlineCmd;
- @@ -38,6 +39,7 @@
- _datatable = new TIntObjectHashMap<>();
- registerVoicedCommandHandler(new L2JPesCmd());
- registerVoicedCommandHandler(new OnlineCmd());
- + registerVoicedCommandHandler(new DimensionCmd());
- }
- private void registerVoicedCommandHandler(IVoicedCommandHandler handler)
- Index: java/com/l2jpes/gameserver/model/actor/knownlist/ObjectKnownList.java
- ===================================================================
- --- java/com/l2jpes/gameserver/model/actor/knownlist/ObjectKnownList.java (revision 5)
- +++ java/com/l2jpes/gameserver/model/actor/knownlist/ObjectKnownList.java (working copy)
- @@ -48,6 +48,10 @@
- if (!Util.checkIfInShortRadius(getDistanceToWatchObject(object), _activeObject, object, true))
- return false;
- + // Check if they are at different dimensions
- + if (object.getDimensionId() != getActiveObject().getDimensionId())
- + return false;
- +
- return _knownObjects.put(object.getObjectId(), object) == null;
- }
- Index: java/com/l2jpes/gameserver/model/L2Spawn.java
- ===================================================================
- --- java/com/l2jpes/gameserver/model/L2Spawn.java (revision 5)
- +++ java/com/l2jpes/gameserver/model/L2Spawn.java (working copy)
- @@ -75,6 +75,8 @@
- private L2Npc _lastSpawn;
- private static List<SpawnListener> _spawnListeners = new ArrayList<>();
- + private int _dimensionid = 1;
- +
- /** The task launching the function doSpawn() */
- class SpawnTask implements Runnable
- {
- @@ -276,11 +278,11 @@
- }
- /**
- - * Create the initial spawning and set _doRespawn to True.
- + * Create the initial spawning and set _doRespawn to True.
- */
- public void init()
- {
- - doSpawn();
- + doSpawn().setDimensionId(getDimensionId());
- _doRespawn = true;
- }
- @@ -489,6 +491,14 @@
- return _template;
- }
- + public int getDimensionId() {
- + return _dimensionid;
- + }
- +
- + public void setDimensionId(int dimensionId) {
- + _dimensionid = dimensionId;
- + }
- +
- @Override
- public String toString()
- {
- Index: config/general.properties
- ===================================================================
- --- config/general.properties (revision 16)
- +++ config/general.properties (working copy)
- @@ -308,4 +308,16 @@
- # By enabling this a player can check if someone is online by
- # writing the another player's name after the command
- # EnableOnlineCmd must be set to true
- -EnableOnlineParam = False
- \ No newline at end of file
- +EnableOnlineParam = False
- +
- +# Enable .dimension command.
- +# Default: False
- +EnableDimensionCmd = False
- +
- +# By enabling this you allow only GMs to use the .dimension command
- +# EnableDimensionCmd must be set to true
- +AdminOnlyDimensionCommand = False
- +
- +# Max number of available dimensions
- +# Default: 20
- +MaxDimensions = 20
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement