Added Listener - modified others

This commit is contained in:
Neptune Whitebear 2011-10-03 00:48:13 +02:00
parent af812e0f83
commit 4e6133f802
3 changed files with 39 additions and 4 deletions

View File

@ -28,7 +28,6 @@ public class boosCoolDown extends JavaPlugin {
public static boolean permissions = false; public static boolean permissions = false;
@SuppressWarnings("static-access") @SuppressWarnings("static-access")
@Override
public void onEnable() { public void onEnable() {
pdfFile = this.getDescription(); pdfFile = this.getDescription();
@ -57,7 +56,6 @@ public class boosCoolDown extends JavaPlugin {
} }
@Override
public void onDisable() { public void onDisable() {
if (boosConfigManager.getClearOnRestart() == true) { if (boosConfigManager.getClearOnRestart() == true) {
boosCoolDownManager.clear(); boosCoolDownManager.clear();

View File

@ -0,0 +1,34 @@
package cz.boosik.boosCooldown;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityListener;
import util.boosChat;
public class boosCoolDownEntityListener extends EntityListener {
private final boosCoolDown plugin;
public boosCoolDownEntityListener(boosCoolDown instance) {
plugin = instance;
}
public void onEntityDamage(EntityDamageEvent event) {
if (event.isCancelled()) {
return;
}
Entity entity = event.getEntity();
if(entity != null && entity instanceof Player) {
Player player = (Player)entity;
if(player != null) {
if(boosWarmUpManager.hasWarmUps(player)) {
boosChat.sendMessageToPlayer(player,boosConfigManager.getWarmUpCancelledMessage());
boosWarmUpManager.cancelWarmUps(player);
}
}
}
}
}

View File

@ -57,11 +57,14 @@ public class boosWarmUpManager {
} }
public static void cancelWarmUps(Player player) { public static void cancelWarmUps(Player player) {
removeWarmUpProcess(player.getName()); for(String key: playercommands.keySet()) {
if(key.startsWith(player.getName())) {
removeWarmUpProcess(key);
}
}
} }
public static boolean hasWarmUps(Player player) { public static boolean hasWarmUps(Player player) {
boosChat.sendMessageToServer( "haswarmup" );
for(String key: playercommands.keySet()) { for(String key: playercommands.keySet()) {
if(key.startsWith(player.getName())) { if(key.startsWith(player.getName())) {
return true; return true;