mirror of
https://github.com/LordBoos/boosCooldowns.git
synced 2024-11-01 08:20:32 +01:00
Added Listener - modified others
This commit is contained in:
parent
af812e0f83
commit
4e6133f802
@ -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();
|
||||||
|
34
src/cz/boosik/boosCooldown/boosCoolDownEntityListener.java
Normal file
34
src/cz/boosik/boosCooldown/boosCoolDownEntityListener.java
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user