Fixed: warmup cancel on damage

Added: warmup cancel on move
This commit is contained in:
Boos 2011-12-28 16:11:26 +01:00
parent 183ad1bf19
commit f487ddf9ca
6 changed files with 37 additions and 8 deletions

View File

@ -33,12 +33,15 @@ public class boosConfigManager {
conf.setProperty("commands.warmup./give", 60);
conf.setProperty("commands.warmup./home", 20);
conf.setProperty("commands.options.cancel_warmup_on_damage", false);
conf.setProperty("commands.options.cancel_warmup_on_move", false);
conf.setProperty("commands.options.clear_on_restart", false);
conf.setProperty("commands.options.unit_seconds", "seconds");
conf.setProperty("commands.options.unit_minutes", "minutes");
conf.setProperty("commands.options.unit_hours", "hours");
conf.setProperty("commands.options.message_warmup_cancelled",
conf.setProperty("commands.options.message_warmup_cancelled_by_damage",
"&6Warm-ups have been cancelled due to receiving damage.&f");
conf.setProperty("commands.options.message_warmup_cancelled_by_move",
"&6Warm-ups have been cancelled due to moving.&f");
conf.setProperty("commands.options.message_cooldown",
"&6Wait&e &seconds& &unit&&6 before you can use command&e &command& &6again.&f");
conf.setProperty("commands.options.message_warmup",
@ -78,8 +81,13 @@ public class boosConfigManager {
"&6Wait&e &seconds& seconds&6 before you can use command&e &command& &6again.&f");
}
static String getWarmUpCancelledMessage() {
return conf.getString("commands.options.message_warmup_cancelled",
static String getWarmUpCancelledByMoveMessage() {
return conf.getString("commands.options.message_warmup_cancelled_by_move",
"&6Warm-ups have been cancelled due to moving.&f");
}
static String getWarmUpCancelledByDamageMessage() {
return conf.getString("commands.options.message_warmup_cancelled_by_damage",
"&6Warm-ups have been cancelled due to receiving damage.&f");
}
@ -115,4 +123,8 @@ public class boosConfigManager {
false);
}
public boolean getCancelWarmupOnMove() {
return conf.getBoolean("commands.options.cancel_warmup_on_move", false);
}
}

View File

@ -46,6 +46,9 @@ public class boosCoolDown extends JavaPlugin {
pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener,
Event.Priority.Normal, this);
}
if (boosConfigManager.getCancelWarmupOnMove()) {
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Event.Priority.Normal, this);
}
if (boosConfigManager.getClearOnRestart() == true) {
boosCoolDownManager.clear();
} else {

View File

@ -26,7 +26,7 @@ public class boosCoolDownEntityListener extends EntityListener {
if (player != null) {
if (boosWarmUpManager.hasWarmUps(player)) {
boosChat.sendMessageToPlayer(player,
boosConfigManager.getWarmUpCancelledMessage());
boosConfigManager.getWarmUpCancelledByDamageMessage());
boosWarmUpManager.cancelWarmUps(player);
}

View File

@ -1,10 +1,13 @@
package cz.boosik.boosCooldown;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerMoveEvent;
import util.boosChat;
//import org.bukkit.event.entity.EntityDamageEvent;
public class boosCoolDownPlayerListener extends PlayerListener {
@ -93,10 +96,18 @@ public class boosCoolDownPlayerListener extends PlayerListener {
return false;
}
public void onPlayerCommandMove(PlayerMoveEvent event) {
public void onPlayerMove(PlayerMoveEvent event) {
if (event.isCancelled()) {
return;
}
Player player = event.getPlayer();
boosWarmUpManager.cancelWarmUps(player);
boosCoolDownManager.cancelCoolDowns(player);
if (player != null) {
if (boosWarmUpManager.hasWarmUps(player)) {
boosChat.sendMessageToPlayer(player,
boosConfigManager.getWarmUpCancelledByMoveMessage());
boosWarmUpManager.cancelWarmUps(player);
}
}
}
}

View File

@ -48,6 +48,8 @@ public class boosWarmUpManager {
}
}
public static boolean isWarmUpProcess(Player player, String pre,
String message) {
pre = pre.toLowerCase();
@ -59,6 +61,7 @@ public class boosWarmUpManager {
public static void removeWarmUpProcess(String tag) {
boosWarmUpManager.playercommands.remove(tag);
scheduler.cancel();
}
public static void cancelWarmUps(Player player) {

View File

@ -25,7 +25,7 @@ public class boosWarmUpTimer extends TimerTask {
@Override
public void run() {
if (player.isOnline()) {
if (player.isOnline() && boosWarmUpManager.hasWarmUps(player)==true) {
boosCoolDownManager.setWarmUpOK(player, pre, message);
boosWarmUpManager.removeWarmUpProcess(this.player.getName() + "@"
+ pre);