SHOW:
|
|
- or go back to the newest paste.
1 | package com.l2jfrozen.gameserver.model.actor.instance; | |
2 | ||
3 | import java.util.concurrent.ScheduledFuture; | |
4 | ||
5 | import com.l2jfrozen.gameserver.model.L2Character; | |
6 | import com.l2jfrozen.gameserver.templates.L2NpcTemplate; | |
7 | import com.l2jfrozen.gameserver.thread.ThreadPoolManager; | |
8 | /** | |
9 | * | |
10 | * | |
11 | * @author Token | |
12 | */ | |
13 | public class L2NoobProtectionInstance extends L2FolkInstance | |
14 | { | |
15 | private ScheduledFuture<?> _aiTask; | |
16 | ||
17 | public class ProtectorAI implements Runnable | |
18 | { | |
19 | @Override | |
20 | public void run() | |
21 | { | |
22 | for(L2PcInstance player : getKnownList().getKnownPlayers().values()) | |
23 | ||
24 | { | |
25 | if(player.getKarma() > 0) | |
26 | { | |
27 | sendToJail(player); | |
28 | } | |
29 | } | |
30 | } | |
31 | ||
32 | private void sendToJail(L2PcInstance player) | |
33 | { | |
34 | if(player.isGM() || player.isDead() || !isInsideRadius(player, 5000, false, false)) | |
35 | return ; | |
36 | ||
37 | if (player != null) | |
38 | { | |
39 | player.setPunishLevel(L2PcInstance.PunishLevel.JAIL, 5); | |
40 | player.sendMessage("Voce vai ficar na jail por 5 minutos, por dar pk em iniciantes."); | |
41 | ||
42 | if (player.getParty() != null) | |
43 | player.getParty().removePartyMember(player); | |
44 | } | |
45 | } | |
46 | } | |
47 | ||
48 | public L2NoobProtectionInstance(int objectId, L2NpcTemplate template) | |
49 | { | |
50 | super(objectId, template); | |
51 | ||
52 | if(_aiTask != null) | |
53 | { | |
54 | _aiTask.cancel(true); | |
55 | } | |
56 | ||
57 | _aiTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new ProtectorAI(), 3000, 3000); | |
58 | } | |
59 | ||
60 | @Override | |
61 | public void deleteMe() | |
62 | { | |
63 | if(_aiTask != null) | |
64 | { | |
65 | _aiTask.cancel(true); | |
66 | _aiTask = null; | |
67 | } | |
68 | ||
69 | super.deleteMe(); | |
70 | } | |
71 | ||
72 | @Override | |
73 | public boolean isAutoAttackable(L2Character attacker) | |
74 | { | |
75 | return false; | |
76 | } | |
77 | } |