made players who ran /nopvp glow
This commit is contained in:
parent
1048c6ec57
commit
089b2a9368
2 changed files with 20 additions and 0 deletions
|
|
@ -7,6 +7,8 @@ import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
|
||||||
public final class NoPvPListener implements Listener {
|
public final class NoPvPListener implements Listener {
|
||||||
|
|
||||||
|
|
@ -16,6 +18,16 @@ public final class NoPvPListener implements Listener {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
manager.applyGlow(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||||
|
manager.applyGlow(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||||
if (!(event.getEntity() instanceof Player victim)) {
|
if (!(event.getEntity() instanceof Player victim)) {
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ public final class NoPvPManager {
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
enabled.put(uuid, true);
|
enabled.put(uuid, true);
|
||||||
cooldownUntil.put(uuid, 0L);
|
cooldownUntil.put(uuid, 0L);
|
||||||
|
player.setGlowing(true);
|
||||||
scheduleSave();
|
scheduleSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -46,9 +47,16 @@ public final class NoPvPManager {
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
enabled.put(uuid, false);
|
enabled.put(uuid, false);
|
||||||
cooldownUntil.put(uuid, System.currentTimeMillis() + COOLDOWN_MILLIS);
|
cooldownUntil.put(uuid, System.currentTimeMillis() + COOLDOWN_MILLIS);
|
||||||
|
player.setGlowing(false);
|
||||||
scheduleSave();
|
scheduleSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void applyGlow(Player player) {
|
||||||
|
if (isEnabled(player)) {
|
||||||
|
player.setGlowing(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void load() {
|
private void load() {
|
||||||
if (!dataFile.exists()) {
|
if (!dataFile.exists()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue