Tópico: [Interlude] Game Guard
Ver um Único Post
Antigo 10-04-2011, 05:51 PM   #4 (permalink)
Mazokista
Membro - Veterano
 
Avatar de Mazokista
 
Registrado em: Dec 2009
Posts: 1,335
Agradeceu: 490
Agradecido 803 Vezes em 427 Posts
Achei Ruim:
Acharam ruim Vezes em Posts
Meu Sistema
Rate Designer: Iniciante
Meu Estado:
Enviar mensagem via Windows Live Messenger para Mazokista
Nome Real: Roberto

Inventório de Mazokista

Padrão

Código: [Somente Usuários Registrados Podem Visualizar os Links Desta PáginaClique aqui para se Registrar]
Index: ProjetoL2J_CORE/java/com/it/roberto/gameserver/clientpackets/EnterWorld.java
===================================================================
--- ProjetoL2J_CORE/java/com/it/roberto/gameserver/clientpackets/EnterWorld.java	(revision 57)
+++ ProjetoL2J_CORE/java/com/it/roberto/gameserver/clientpackets/EnterWorld.java	(working copy)
@@ -1,7 +1,5 @@
 package com.it.roberto.gameserver.clientpackets;
 
+import static com.it.roberto.guard.ActionType.ENTER_WORLD;
+
 import java.sql.Connection;
 import java.io.UnsupportedEncodingException;
 import java.sql.PreparedStatement;
@@ -455,9 +453,6 @@
 
         if(activeChar.isAio())
         	onEnterAio(activeChar);
+
+		if(Config.GAMEGUARD_ENFORCE)
+			activeChar.getGuard().tryPerformAction(ENTER_WORLD);
 		
 		if (CTF._savePlayers.contains(activeChar.getName()))
     	    CTF.addDisconnectedPlayer(activeChar);
Index: ProjetoL2J_CORE/java/com/it/roberto/gameserver/GmListTable.java
===================================================================
--- ProjetoL2J_CORE/java/com/it/roberto/gameserver/GmListTable.java	(revision 53)
+++ ProjetoL2J_CORE/java/com/it/roberto/gameserver/GmListTable.java	(working copy)
@@ -163,9 +163,4 @@
 		}
 	}
 
+	public static void broadcastGuardToGMs(String message) 
+	{ 
+ 	   for (L2PcInstance gm : GmListTable.getInstance().getAllGms(true)) 
+	   gm.getGuard().sayToPc(message); 
+	}
 }
Index: ProjetoL2J_CORE/java/com/it/roberto/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- ProjetoL2J_CORE/java/com/it/roberto/gameserver/model/actor/instance/L2PcInstance.java	(revision 57)
+++ ProjetoL2J_CORE/java/com/it/roberto/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -197,7 +197,6 @@
 import com.it.roberto.gameserver.util.Broadcast;
 import com.it.roberto.gameserver.util.FloodProtector;
 import com.it.roberto.util.Point3D;
+import com.it.roberto.guard.CheatGuard;
 import com.it.roberto.util.Rnd;
 
 import com.it.roberto.gameserver.instancemanager.AntharasManager;
@@ -314,9 +313,6 @@
 	protected int _baseClass;
 	protected int _activeClass;
 	protected int _classIndex = 0;
+	
+	/** Cheat Guard **/ 
+	public CheatGuard _guard;
 
     private Map<Integer, SubClass> _subClasses;
 
@@ -5711,8 +5707,6 @@
 			if(player.getPet() != null) player.getPet().setOwner(player);
 			player.refreshOverloaded();
 			
+			// Init CheatGuard
+			CheatGuard.registerPlayer(player);
 		}
 		catch (Exception e)
 		{
@@ -10396,18 +10390,6 @@
 	{
 		_forceBuff = fb;
 	}
+	
+	/** 
+	* @return Returns the guard. 
+	*/ 
+	public CheatGuard getGuard() 
+	{ 
+	    return _guard; 
+	}
+	public void setGuard(CheatGuard acg)
+	{
+	    _guard = acg;
+	} 
 
 	private String addZerosToColor(String color)
     {
	 
	 
Index: ProjetoL2J_CORE/java/com/it/roberto/gameserver/instancemanager/GuardManager.java
===================================================================
--- ProjetoL2J_CORE/java/com/it/roberto/gameserver/instancemanager/GuardManager.java	(revision 57)
+++ ProjetoL2J_CORE/java/com/it/roberto/gameserver/instancemanager/GuardManager.java	(working copy)
@@ -0,0 +1,64 @@
+/*
+ * 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.it.roberto.gameserver.instancemanager;
+
+import javolution.util.FastMap;
+
+import com.it.roberto.gameserver.model.actor.instance.L2PcInstance;
+import com.it.roberto.guard.ActionBase;
+import com.it.roberto.guard.ActionEnterWorld;
+import com.it.roberto.guard.ActionType;
+import com.it.roberto.guard.ActionUseItem;
+import com.it.roberto.guard.CheatGuard;
+
+/**
+ * @author  Setekh
+ */
+public class GuardManager
+{
+	public FastMap<ActionType, ActionBase> _actions;
+	private static GuardManager _instance;
+	
+	public static GuardManager getInstance()
+	{
+		if(_instance == null)
+		_instance = new GuardManager();
+		
+		return _instance;
+	}
+	
+	public GuardManager()
+	{
+		_actions = new FastMap<ActionType, ActionBase>();
+	}
+	
+	/**
+	 * Registers the action on the map.  
+	 * @param type
+	 * @param temp
+	 */
+	public void registerInstanceAction(ActionType type, ActionBase temp)
+	{
+		_actions.put(type, temp);
+	}
+
+	public static void initPlayer(L2PcInstance player)
+	{
+		player._guard = new CheatGuard(player);
+		getInstance().registerInstanceAction(ActionType.ENTER_WORLD, new ActionEnterWorld(player));
+		getInstance().registerInstanceAction(ActionType.USE_ITEM, new ActionUseItem(player));
+	}
+}

Index: ProjetoL2J_CORE/java/com/it/roberto/guard/ActionBase.java
===================================================================
--- ProjetoL2J_CORE/java/com/it/roberto/guard/ActionBase.java	(revision 57)
+++ ProjetoL2J_CORE/java/com/it/roberto/guard/ActionBase.java	(working copy)
@@ -0,0 +1,60 @@
+/*
+ * 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 2, 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * <http://www.gnu.org/copyleft/gpl.html>
+ */
+package com.it.roberto.guard;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.it.roberto.gameserver.model.L2ItemInstance;
+import com.it.roberto.gameserver.model.actor.instance.L2PcInstance;
+import com.it.roberto.guard.CheatGuard;
+
+/**
+ * @author  Setekh
+ */
+public abstract class ActionBase 
+{
+	protected Log _log = LogFactory.getLog(ActionBase.class);
+
+	protected L2PcInstance _actor;
+	protected CheatGuard _guard;
+	protected L2ItemInstance _item;
+	
+	public ActionBase(L2PcInstance actor)
+	{
+		_actor = actor;
+		_guard = actor.getGuard();
+	}
+
+	/**
+	 * Instance handler interface ^^
+	 * @return boolean
+	 */
+	public abstract boolean handleInstanceAction();
+
+	/**
+	 * Sets the item instance item if its one :P 
+	 * @param item
+	 */
+	public void setItem(L2ItemInstance item)
+	{
+		_item = item;
+	}
+}
+
Index: ProjetoL2J_CORE/java/com/it/roberto/guard/ActionEnchantItem.java
===================================================================
--- ProjetoL2J_CORE/java/com/it/roberto/guard/ActionEnchantItem.java	(revision 57)
+++ ProjetoL2J_CORE/java/com/it/roberto/guard/ActionEnchantItem.java	(working copy)
@@ -0,0 +1,68 @@
+/*
+ * 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.it.roberto.guard;
+
+import com.it.roberto.Config;
+import com.it.roberto.gameserver.model.L2ItemInstance;
+import com.it.roberto.gameserver.model.actor.instance.L2PcInstance;
+import com.it.roberto.gameserver.templates.L2Item;
+import com.it.roberto.gameserver.serverpackets.CreatureSay;
+
+/**
+ * @author  Setekh
+ */
+public final class ActionEnchantItem extends ActionBase
+{
+	/**
+	 * @param actor
+	 */
+	public ActionEnchantItem(L2PcInstance actor)
+	{
+		super(actor);
+	}
+
+	/**
+	 * @see com.jenova.shield.actions.ActionBase#handleInstanceAction()
+	 */
+	public boolean handleInstanceAction()
+	{
+		if(Config.ENCHANT_MAX_ALLOWED_ARMOR <= 0 || Config.ENCHANT_MAX_ALLOWED_JEWELRY <= 0 || Config.ENCHANT_MAX_ALLOWED_WEAPON <= 0
+				|| _actor.isGM())
+			return false;
+		
+		boolean cheater = false;
+		
+        if(_actor.getActiveTradeList() != null)
+        	cheater = true;
+        else if(_actor.getActiveWarehouse() != null)
+			cheater = true;
+        else if(_item.isWear())
+			cheater = true;
+        else if(_item.getItem().getType2() == L2Item.TYPE2_SHIELD_ARMOR && _item.isEquipable() && _item.getEnchantLevel() > Config.ENCHANT_MAX_ALLOWED_ARMOR)
+			cheater = true;
+		else if(_item.getItem().getType2() == L2Item.TYPE2_WEAPON && _item.isEquipable() && _item.getEnchantLevel() > Config.ENCHANT_MAX_ALLOWED_WEAPON)
+			cheater = true;
+		else if(_item.getItem().getType2() == L2Item.TYPE2_ACCESSORY && _item.isEquipable() && _item.getEnchantLevel() > Config.ENCHANT_MAX_ALLOWED_JEWELRY)
+			cheater = true;
+        
+		if(cheater)
+		{
+			_log.warn(_actor+" tryed to hack an item useing ReqEnchantitem packet!");
+			_guard.sayToPc(_guard.cants());
+		}
+		return cheater;
+	}
+}
+
Index: ProjetoL2J_CORE/java/com/it/roberto/guard/ActionEnterWorld.java
===================================================================
--- ProjetoL2J_CORE/java/com/it/roberto/guard/ActionEnterWorld.java	(revision 57)
+++ ProjetoL2J_CORE/java/com/it/roberto/guard/ActionEnterWorld.java	(working copy)
@@ -0,0 +1,102 @@
+/*
+ * 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.it.roberto.guard;
+
+import com.it.roberto.Config;
+import com.it.roberto.gameserver.model.L2ItemInstance;
+import com.it.roberto.gameserver.model.actor.instance.L2PcInstance;
+import com.it.roberto.gameserver.templates.L2Item;
+
+/**
+ * @author  Setekh
+ */
+public final class ActionEnterWorld extends ActionBase
+{
+	/** 
+ 	* @param actor 
+ 	*/ 
+	
+	public ActionEnterWorld(L2PcInstance actor)
+	{
+		super(actor);		
+	}
+	
+	/**
+	 * @see com.it.roberto.guard.ActionBase#handleInstanceAction()
+	 */
+	public boolean handleInstanceAction()
+	{
+		boolean cheater = false;
+		int destroyedCount = 0;
+		_guard.sayToPc("Custom Protection Engine Anti-Exploit Enabled!");
+		
+		if(Config.ENCHANT_MAX_ALLOWED_ARMOR <= 0 || Config.ENCHANT_MAX_ALLOWED_JEWELRY <= 0 || Config.ENCHANT_MAX_ALLOWED_WEAPON <= 0
+				|| _actor.isGM())
+			return false;
+						
+		for(L2ItemInstance item : _actor.getWarehouse().getItems())
+		{
+			if(item.getItem().getType2() == L2Item.TYPE2_SHIELD_ARMOR && item.isEquipable() && item.getEnchantLevel() > Config.ENCHANT_MAX_ALLOWED_ARMOR)
+			{
+				_actor.getWarehouse().destroyItem("CheatGuard", item, _actor, _actor);
+				cheater = true;
+				destroyedCount++;
+			}
+			else if(item.getItem().getType2() == L2Item.TYPE2_WEAPON && item.isEquipable() && item.getEnchantLevel() > Config.ENCHANT_MAX_ALLOWED_WEAPON)
+			{
+				_actor.getWarehouse().destroyItem("CheatGuard", item, _actor, _actor);
+				cheater = true;
+				destroyedCount++;
+			}
+			else if(item.getItem().getType2() == L2Item.TYPE2_ACCESSORY && item.isEquipable() && item.getEnchantLevel() > Config.ENCHANT_MAX_ALLOWED_JEWELRY)
+			{
+				_actor.getWarehouse().destroyItem("CheatGuard", item, _actor, _actor);
+				cheater = true;
+				destroyedCount++;
+			}
+		}
+		for(L2ItemInstance item : _actor.getInventory().getItems())
+		{
+			if(item.getItem().getType2() == L2Item.TYPE2_SHIELD_ARMOR && item.isEquipable() && item.getEnchantLevel() > Config.ENCHANT_MAX_ALLOWED_ARMOR)
+			{
+				_actor.destroyItem("CheatGuard", item, _actor, true);
+				cheater = true;
+				destroyedCount++;
+			}
+			else if(item.getItem().getType2() == L2Item.TYPE2_WEAPON && item.isEquipable() && item.getEnchantLevel() > Config.ENCHANT_MAX_ALLOWED_WEAPON)
+			{
+				_actor.destroyItem("CheatGuard", item, _actor, true);
+				cheater = true;
+				destroyedCount++;
+			}
+			else if(item.getItem().getType2() == L2Item.TYPE2_ACCESSORY && item.isEquipable() && item.getEnchantLevel() > Config.ENCHANT_MAX_ALLOWED_JEWELRY)
+			{
+				_actor.destroyItem("CheatGuard", item, _actor, true);
+				cheater = true;
+				destroyedCount++;
+			}
+		}
+		
+		if(cheater)
+		{
+			_log.warn("Player: "+_actor.getName()+" loged in with over enchanted items! Items destroyed: "+destroyedCount+"!");
+			_guard.sayToPc("Nice try, but, you need more then that! Items destroyed: "+destroyedCount+"!");
+		}
+		return cheater;
+	}
+	
+}
+
Index: ProjetoL2J_CORE/java/com/it/roberto/guard/ActionType.java
===================================================================
--- ProjetoL2J_CORE/java/com/it/roberto/guard/ActionType.java	(revision 57)
+++ ProjetoL2J_CORE/java/com/it/roberto/guard/ActionType.java	(working copy)
@@ -0,0 +1,23 @@
+/*
+ * 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.it.roberto.guard;
+
+public enum ActionType
+{
+	ENTER_WORLD,
+	USE_ITEM,
+	ENCHANT_ITEM;
+}
+
Index: ProjetoL2J_CORE/java/com/it/roberto/guard/ActionUseItem.java
===================================================================
--- ProjetoL2J_CORE/java/com/it/roberto/guard/ActionUseItem.java	(revision 57)
+++ ProjetoL2J_CORE/java/com/it/roberto/guard/ActionUseItem.java	(working copy)
@@ -0,0 +1,82 @@
+/*
+ * 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.it.roberto.guard;
+
+import com.it.roberto.Config;
+import com.it.roberto.gameserver.model.actor.instance.L2PcInstance;
+import com.it.roberto.gameserver.templates.L2Item;
+
+/**
+ * @author  Setekh
+ */
+public final class ActionUseItem extends ActionBase
+{
+	/** 
+ 	* @param actor 
+ 	*/ 
+	
+	public ActionUseItem(L2PcInstance actor)
+	{
+		super(actor);		
+	}
+	
+	/**
+	 * @see com.it.roberto.guard.ActionBase#handleInstanceAction()
+	 */
+	public boolean handleInstanceAction()
+	{
+		if(Config.ENCHANT_MAX_ALLOWED_ARMOR <= 0 || Config.ENCHANT_MAX_ALLOWED_JEWELRY <= 0 || Config.ENCHANT_MAX_ALLOWED_WEAPON <= 0
+				|| _actor.isGM())
+			return false;
+		boolean cheater = false;
+		
+		if(_actor.getActiveTradeList() != null)
+		{
+			_guard.sayToPc(_guard.cants());
+			_guard.sayToPc("When your on active trade!");
+			return true;
+		}
+		else if(_actor.getActiveTradeList() != null)
+		{
+			_guard.sayToPc(_guard.cants());
+			return true;
+		}
+		
+		
+		else if(_item.getItem().getType2() == L2Item.TYPE2_SHIELD_ARMOR && _item.isEquipable() && _item.getEnchantLevel() > Config.ENCHANT_MAX_ALLOWED_ARMOR)
+		{
+			_actor.destroyItem("CheatGuard", _item, _actor, true);
+			cheater = true;
+		}
+		else if(_item.getItem().getType2() == L2Item.TYPE2_WEAPON && _item.isEquipable() && _item.getEnchantLevel() > Config.ENCHANT_MAX_ALLOWED_WEAPON)
+		{
+			_actor.destroyItem("CheatGuard", _item, _actor, true);
+			cheater = true;
+		}
+		else if(_item.getItem().getType2() == L2Item.TYPE2_ACCESSORY && _item.isEquipable() && _item.getEnchantLevel() > Config.ENCHANT_MAX_ALLOWED_JEWELRY)
+		{
+			_actor.destroyItem("CheatGuard", _item, _actor, true);
+			cheater = true;
+		}
+
+		if(cheater)
+		{
+			_log.warn("Player: "+_actor.getName()+" tryed equiping an over enchanted item!");
+			_guard.sayToPc("Nice try, but to brake an Wars server, you need more then that!");
+		}
+		return cheater;
+	}
+}
+
Index: ProjetoL2J_CORE/java/com/it/roberto/guard/CheatGuard.java
===================================================================
--- ProjetoL2J_CORE/java/com/it/roberto/guard/CheatGuard.java	(revision 57)
+++ ProjetoL2J_CORE/java/com/it/roberto/guard/CheatGuard.java	(working copy)
@@ -0,0 +1,152 @@
+/*
+ * 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.it.roberto.guard;
+
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javolution.util.FastMap;
+
+import com.it.roberto.gameserver.ThreadPoolManager;
+import com.it.roberto.gameserver.model.actor.instance.L2PcInstance;
+import com.it.roberto.gameserver.clientpackets.Say2;
+import com.it.roberto.gameserver.serverpackets.CreatureSay;
+import com.it.roberto.guard.ActionBase;
+import com.it.roberto.guard.ActionEnchantItem;
+import com.it.roberto.guard.ActionEnterWorld;
+import com.it.roberto.guard.ActionUseItem;
+
+import com.it.roberto.util.Rnd;
+
+/**
+ * @author  Setekh
+ * @version 1.1.0
+ */
+public class CheatGuard
+{
+	protected Log _log = LogFactory.getLog(CheatGuard.class);
+	protected String _myName = "[CheatGuard]";
+	protected int _myDefaultChat = Say2.PARTY; // Green is smexay ^_~
+	protected L2PcInstance _actor;
+	protected final ReentrantLock _lock;
+	public ActionBase _actionBase;
+	
+	public FastMap<ActionType, ActionBase> _actions;
+		
+	/**
+	 * Instance Constructor
+	 */
+	public CheatGuard(L2PcInstance player)
+	{
+		_actor = player;
+		_lock = new ReentrantLock();
+		_actions = new FastMap<ActionType, ActionBase>();		
+	}
+
+	public boolean tryPerformAction(ActionType on)
+	{
+		if(_actions.containsKey(on))
+			return _actions.get(on).handleInstanceAction();
+		
+		return true;
+	}
+	
+	public void handleIllegalPlayerAction(L2PcInstance actor, String message, int punishment)
+	{
+		sayToPc("Action Blocked!");
+		ThreadPoolManager.getInstance().executeTask(new IllegalPlayerAction(actor, message, punishment));
+	}
+	
+	public void handleIllegalPlayerAction(String message, int punishment)
+	{
+		sayToPc("Action Blocked!");
+		ThreadPoolManager.getInstance().executeTask(new IllegalPlayerAction(_actor, message, punishment));
+	}
+
+	public void handleIllegalPlayerAction(int punishment)
+	{
+		sayToPc("Action Blocked!");
+		ThreadPoolManager.getInstance().executeTask(new IllegalPlayerAction(_actor, null, punishment));
+	}	
+
+	public void sayToPc(String msg)
+	{
+		_actor.sendPacket(new CreatureSay(0, _myDefaultChat, _myName, msg));
+	}
+		
+	public void lockAction()
+	{
+		if(_lock.tryLock())
+			_log.warn("["+_myName+"]: Blocked player's: "+_actor.getName()+" action.");
+		else
+		{
+			_lock.lock();
+			_log.warn("["+_myName+"]: Forced Blocked player's: "+_actor.getName()+" action.");
+		}
+	}
+	
+	public String cants()
+	{
+		switch(Rnd.get(4))
+		{
+			case 0: return "I can't allow you to do that!";
+			case 1: return "You can't do that!";
+			case 2: return "You are not able to do that action.";
+			case 3: return "Action is blocked.";
+		}
+		return null;
+	}
+	
+	public boolean isLocked()
+	{
+		return _lock.isLocked();
+	}
+	
+	public void unLock()
+	{
+		_lock.unlock();
+	}
+	
+	public L2PcInstance getInstanceOwner()
+	{
+		return _actor;
+	}
+	
+	public ActionBase getAction(ActionType type)
+	{
+			return _actions.get(type);
+	}
+	
+	/**
+	 * Registers the action on the map.  
+	 * @param type
+	 * @param temp
+	 */
+	public void registerInstanceAction(ActionType type, ActionBase temp)
+	{
+		_actions.put(type, temp);
+	}
+
+	public static void registerPlayer(L2PcInstance player)
+	{
+		player.setGuard(new CheatGuard(player));
+		player.getGuard().registerInstanceAction(ActionType.ENTER_WORLD, new ActionEnterWorld(player));
+		player.getGuard().registerInstanceAction(ActionType.USE_ITEM, new ActionUseItem(player));
+		player.getGuard().registerInstanceAction(ActionType.ENCHANT_ITEM, new ActionEnchantItem(player));
+	}
+}
+
Index: ProjetoL2J_CORE/java/com/it/roberto/guard/IllegalPlayerAction.java
===================================================================
--- ProjetoL2J_CORE/java/com/it/roberto/guard/IllegalPlayerAction.java	(revision 57)
+++ ProjetoL2J_CORE/java/com/it/roberto/guard/IllegalPlayerAction.java	(working copy)
@@ -0,0 +1,102 @@
+/*
+ * 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.it.roberto.guard;
+
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+import com.it.roberto.Config;
+import com.it.roberto.gameserver.GmListTable;
+import com.it.roberto.gameserver.model.actor.instance.L2PcInstance;
+
+
+/**
+ * This class ...
+ *
+ * @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
+ */
+public final class IllegalPlayerAction implements Runnable
+{
+	private static Logger _logAudit = Logger.getLogger("audit");
+
+    String _message;
+    int _punishment;
+    L2PcInstance _actor;
+    CheatGuard _guard;
+
+    public static final int PUNISH_BROADCAST = 1;
+    public static final int PUNISH_KICK = 2;
+    public static final int PUNISH_KICKBAN = 3;
+    public static final int PUNISH_JAIL = 4;
+    
+    public IllegalPlayerAction(L2PcInstance actor, String message, int punishment)
+    {
+        _message        = message;
+        _punishment     = punishment;
+        _actor          = actor;
+        _guard          = actor.getGuard();
+        
+        if(_message == null || _message == "")
+        		_message = _actor+" tried to cheat, and got punished.";
+        
+        if(punishment > 0) 
+        	_guard.lockAction(); // lock player, prevents him from moveing
+        						//or loging out (or anything else :D)
+        switch(punishment)
+        {
+            case PUNISH_KICK:
+            	_guard.sayToPc("You will be kicked for illegal action, GM informed.");
+                break;
+            case PUNISH_KICKBAN:
+            	_guard.sayToPc("You are banned for illegal action, GM informed.");
+                break;
+            case PUNISH_JAIL:
+            	_guard.sayToPc("You will be teleported to GM Consultation Service area and jailed.");
+            	break;
+        }
+    }
+
+    public void run()
+    {
+		LogRecord record = new LogRecord(Level.INFO, "AUDIT:" + _message);
+		record.setLoggerName("audit");
+		record.setParameters(new Object[]{_actor, _punishment});
+		_logAudit.log(record);
+
+        GmListTable.broadcastGuardToGMs(_message);
+        
+        try{Thread.sleep(5000);}catch(Exception e){}
+
+        switch(_punishment)
+        {
+            case PUNISH_BROADCAST:
+                return;
+            case PUNISH_KICK:
+                _actor.closeNetConnection();
+                break;
+            case PUNISH_KICKBAN:
+                _actor.setAccessLevel(-100);
+                _actor.setAccountAccesslevel(-100);
+                _actor.closeNetConnection();
+                break;
+            case PUNISH_JAIL:
+                _actor.setInJail(true, Config.DEFAULT_PUNISH_PARAM);
+            	_guard.unLock();;
+                break;
+        }
+    }
+}
+

Mazokista está offline   Responder com Citação
 

Search Engine Optimization by vBSEO 3.3.0