Jump to content

Question

3 answers to this question

Recommended Posts

  • 0
Posted

adapt this it's not hard just some small changes on the imports

### Eclipse Workspace Patch 1.0
#P L2jxCine_GameServer
Index: head-src/net/xcine/Config.java
===================================================================
--- head-src/net/xcine/Config.java      (revision 59)
+++ head-src/net/xcine/Config.java      (working copy)
@@ -305,6 +305,7 @@
        public static String CHAT_FILTER_PUNISHMENT;
        public static ArrayList<String> FILTER_LIST = new ArrayList<>();

+       public static boolean NOXPGAIN_ENABLED;
        public static int FS_TIME_ATTACK;
        public static int FS_TIME_COOLDOWN;
        public static int FS_TIME_ENTRY;

        //Rates
@@ -2115,6 +2123,7 @@
                        CHAT_FILTER_PUNISHMENT = otherSettings.getProperty("ChatFilterPunishment", "off");
                        CHAT_FILTER_PUNISHMENT_PARAM1 = Integer.parseInt(otherSettings.getProperty("ChatFilterPunishmentParam1", "1"));
                        CHAT_FILTER_PUNISHMENT_PARAM2 = Integer.parseInt(otherSettings.getProperty("ChatFilterPunishmentParam2", "1000"));
+                       NOXPGAIN_ENABLED = Boolean.parseBoolean(otherSettings.getProperty("NoXPGainEnable", "false"));
                        FS_TIME_ATTACK = Integer.parseInt(otherSettings.getProperty("TimeOfAttack", "50"));
                        FS_TIME_COOLDOWN = Integer.parseInt(otherSettings.getProperty("TimeOfCoolDown", "5"));
                        FS_TIME_ENTRY = Integer.parseInt(otherSettings.getProperty("TimeOfEntry", "3"));
Index: head-src/net/xcine/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- head-src/net/xcine/gameserver/model/actor/instance/L2PcInstance.java        (revision 59)
+++ head-src/net/xcine/gameserver/model/actor/instance/L2PcInstance.java        (working copy)
@@ -1362,6 +1362,17 @@

        private long timerToAttack;

+       private boolean _cantGainXP;
+      
+       public void cantGainXP(boolean b)
+       {
+               _cantGainXP = b;
+       }      
+          
+       public boolean cantGainXP()
+       {
+               return _cantGainXP;
+       }      
        //private boolean isInDangerArea;
        ////////////////////////////////////////////////////////////////////
        //START CHAT BAN SYSTEM
Index: head-src/net/xcine/gameserver/handler/VoicedCommandHandler.java
===================================================================
--- head-src/net/xcine/gameserver/handler/VoicedCommandHandler.java     (revision 54)
+++ head-src/net/xcine/gameserver/handler/VoicedCommandHandler.java     (working copy)
@@ -27,6 +27,7 @@
 import net.xcine.gameserver.handler.voicedcommandhandlers.BankingCmd;
 import net.xcine.gameserver.handler.voicedcommandhandlers.CTFCmd;
 import net.xcine.gameserver.handler.voicedcommandhandlers.DMCmd;
+import net.xcine.gameserver.handler.voicedcommandhandlers.NoExp;
 import net.xcine.gameserver.handler.voicedcommandhandlers.OfflineShop;
 import net.xcine.gameserver.handler.voicedcommandhandlers.Online;
 import net.xcine.gameserver.handler.voicedcommandhandlers.StatsCmd;
@@ -98,7 +99,8 @@
                {
                        registerVoicedCommandHandler(new OfflineShop());
                }
-              
+        if (Config.NOXPGAIN_ENABLED)
+            VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new NoExp());
                _log.config("VoicedCommandHandler: Loaded " + _datatable.size() + " handlers.");

        }
Index: head-src/net/xcine/gameserver/handler/voicedcommandhandlers/NoExp.java
===================================================================
--- head-src/net/xcine/gameserver/handler/voicedcommandhandlers/NoExp.java      (revision 0)
+++ head-src/net/xcine/gameserver/handler/voicedcommandhandlers/NoExp.java      (working copy)
@@ -0,0 +1,62 @@
+/*
+ * 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 net.xcine.gameserver.handler.voicedcommandhandlers;
+
+import net.xcine.gameserver.handler.IVoicedCommandHandler;
+import net.xcine.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * This class allows user to turn XP-gain off and on.
+ *
+ * @author Notorious
+ */
+public class NoExp implements IVoicedCommandHandler
+{
+   private static final String[] _voicedCommands =
+   {
+      "xpoff",
+      "xpon"
+   };
+
+   /**
+    *
+    * @see net.xcine.gameserver.handler.IVoicedCommandHandler#useVoicedCommand(java.lang.String, net.xcine.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
+    */
+   @Override
+   public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
+   {
+      if (command.equalsIgnoreCase("xpoff"))
+      {
+         activeChar.cantGainXP(true);
+         activeChar.sendMessage("You have turned XP-gain OFF!");
+      }
+      else if (command.equalsIgnoreCase("xpon"))
+      {
+         activeChar.cantGainXP(false);
+         activeChar.sendMessage("You have turned XP-gain ON!");
+      }
+      return true;
+   }
+
+   /**
+    *
+    * @see net.xcine.gameserver.handler.IVoicedCommandHandler#getVoicedCommandList()
+    */
+   @Override
+   public String[] getVoicedCommandList()
+   {
+      return _voicedCommands;
+   }
+}
\ No newline at end of file
Index: head-src/net/xcine/gameserver/model/actor/stat/PcStat.java
===================================================================
--- head-src/net/xcine/gameserver/model/actor/stat/PcStat.java  (revision 54)
+++ head-src/net/xcine/gameserver/model/actor/stat/PcStat.java  (working copy)
@@ -55,8 +55,8 @@
        {
                L2PcInstance activeChar = getActiveChar();

-               //Player is Gm and access level is below or equal to canGainExp and is in party, don't give Xp
-               if(!getActiveChar().getAccessLevel().canGainExp() && getActiveChar().isInParty())
+               // Allowed to gain exp?
+               if (!getActiveChar().getAccessLevel().canGainExp() && getActiveChar().isInParty() || (Config.NOXPGAIN_ENABLED && getActiveChar().cantGainXP()))
                        return false;

                if(!super.addExp(value))
@@ -109,7 +109,7 @@

                //Player is Gm and acces level is below or equal to GM_DONT_TAKE_EXPSP and is in party, don't give Xp/Sp
                L2PcInstance activeChar = getActiveChar();
-               if(!activeChar.getAccessLevel().canGainExp() && activeChar.isInParty())
+               if (!activeChar.getAccessLevel().canGainExp() && activeChar.isInParty() || (Config.NOXPGAIN_ENABLED && getActiveChar().cantGainXP()))
                        return false;

                // if this player has a pet that takes from the owner's Exp, give the pet Exp now
Index: config/main/other.properties
===================================================================
--- config/main/other.properties        (revision 54)
+++ config/main/other.properties        (working copy)
@@ -232,3 +232,10 @@
 # Enable Messages to GMs on 4-5 consecutive pvp of a player
 # Why? to see if a char are farming!
 EnableAntiPvpFarmMsg = true
+
+#==============================================================#
+#       Voice-command for turning off XP-gain                  #                                                        
+#==============================================================#
+# Player can use .xpoff to disable XP-gain, and .xpon to enable again.
+# Default: False
+NoXPGainEnable = False
Guest
This topic is now closed to further replies.
×
×
  • Create New...