View difference between Paste ID: fR3fvLhP and Uc4DF0gT
SHOW: | | - or go back to the newest paste.
1
--- java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Report.java (revision 3)
2
+++ java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Report.java (working copy)
3
4
+package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
5
+
6
+import java.util.HashMap;
7
+import java.util.Map;
8
+import java.util.concurrent.TimeUnit;
9
+
10
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
11
+import net.sf.l2j.gameserver.instancemanager.BotsPreventionManager;
12
+import net.sf.l2j.gameserver.instancemanager.PetitionManager;
13
+import net.sf.l2j.gameserver.model.actor.instance.Player;
14
+import net.sf.l2j.gameserver.network.clientpackets.Say2;
15
+import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
16
+
17
+public class Report implements IVoicedCommandHandler
18
+{
19
+	
20
+	private static Map<Integer, Long> _holder = new HashMap<>();
21
+	
22
+	private static final String[] _voicedCommands =
23
+	{
24
+		"report"
25
+	};
26
+	
27
+	@Override
28
+	public boolean useVoicedCommand(String command, Player activeChar, String target)
29
+	{
30
+
31
+		final Player bot = activeChar.getTarget().getActingPlayer();
32
+		
33
+		final long action = getLastAction(activeChar.getObjectId());
34
+				
35
+		if (action >= System.currentTimeMillis())
36
+		{
37
+			activeChar.sendMessage("You have to wait " + TimeUnit.MILLISECONDS.toMinutes(action - System.currentTimeMillis()) + " minutes.");
38
+		}
39
+		else if (!(activeChar.getTarget() instanceof Player))
40
+		{
41
+			activeChar.sendPacket(new CreatureSay(0, Say2.PARTYROOM_COMMANDER, "System", "You need to target a player!"));
42
+		}
43
+		else  if ((bot == null) || (activeChar.getTarget().getObjectId() == activeChar.getObjectId()))
44
+		{
45
+			activeChar.sendPacket(new CreatureSay(0, Say2.PARTYROOM_COMMANDER, "System", "You can't report yourself!"));
46
+		}
47
+		else if (!bot.isInCombat() || bot.getPvpFlag() != 0 || bot.isInDuel())
48
+		{
49
+			activeChar.sendPacket(new CreatureSay(0, Say2.PARTYROOM_COMMANDER, "System", "This player is not botting!"));
50
+		}
51
+		else
52
+		{
53
+			activeChar.sendPacket(new CreatureSay(0, Say2.PARTYROOM_COMMANDER, "System", "Report has been sent!"));
54
+			activeChar.sendPacket(new CreatureSay(0, Say2.PARTYROOM_COMMANDER, "System", "Captcha has been sent!"));
55
+			
56
+			addAction(activeChar.getObjectId());
57
+			
58
+			/** Sent Capctha */
59
+			BotsPreventionManager.getInstance().validationtasks(bot);
60
+			
61
+			PetitionManager.getInstance().submitPetition(activeChar, "| User: "+bot.getName()+" |  might be botting! You need to check him!", 1);
62
+		}
63
+		return true;
64
+	}
65
+	
66
+	static long getLastAction(int objectId)
67
+	{
68
+		return _holder.containsKey(objectId) ? _holder.get(objectId) : 0;
69
+	}
70
+	
71
+	static void addAction(int objectId)
72
+	{
73
+		_holder.put(objectId, System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(15));
74
+	}
75
+	
76
+	@Override
77
+	public String[] getVoicedCommandList()
78
+	{
79
+		return _voicedCommands;
80
+	}
81
+}
82
83
84
--- java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (revision 3)
85
+++ java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (working copy)
86
87
	package net.sf.l2j.gameserver.handler;
88
89
	import java.util.HashMap;
90
	import java.util.Map;
91
92
+	import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Report;
93
94
	protected VoicedCommandHandler()
95
	{
96
+		registerHandler(new Report());
97
	}