mirror of
https://github.com/YouHaveTrouble/PreventStabby.git
synced 2026-05-12 05:16:55 +00:00
Remove several game listeners and utility files
The commit includes the deletion of several listeners and utility files. These were mainly related to handling specific game events such as interactions with lava and fireworks, combat commands, and actions related to player pets and mounts. The removal is due to refactoring damage source check system
This commit is contained in:
@@ -3,7 +3,7 @@ package me.youhavetrouble.preventstabby.commands;
|
||||
import me.youhavetrouble.preventstabby.PreventStabby;
|
||||
import me.youhavetrouble.preventstabby.api.event.PlayerTogglePvpEvent;
|
||||
import me.youhavetrouble.preventstabby.config.PreventStabbyPermission;
|
||||
import me.youhavetrouble.preventstabby.util.CombatTimer;
|
||||
import me.youhavetrouble.preventstabby.players.PlayerManager;
|
||||
import me.youhavetrouble.preventstabby.util.PluginMessages;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -11,46 +11,47 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class PvpToggleCommand {
|
||||
|
||||
private static final PlayerManager playerManager = PreventStabby.getPlugin().getPlayerManager();
|
||||
|
||||
public static void toggle(CommandSender sender, String[] args) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(PreventStabby.getPlugin(), () -> {
|
||||
if (!PreventStabbyPermission.COMMAND_TOGGLE.doesCommandSenderHave(sender)) {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().getNo_permission());
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().no_permission);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length <= 1) {
|
||||
if (!(sender instanceof Player)) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
PluginMessages.sendMessage(sender, "Try /pvp toggle <player>");
|
||||
return;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
if (CombatTimer.isInCombat(player.getUniqueId())) {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().getCant_do_that_during_combat());
|
||||
if (playerManager.getPlayer(player.getUniqueId()).isInCombat()) {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().cant_do_that_during_combat);
|
||||
return;
|
||||
}
|
||||
boolean currentState = PreventStabby.getPlugin().getPlayerManager().togglePlayerPvpState(player.getUniqueId());
|
||||
PlayerTogglePvpEvent toggleEvent = new PlayerTogglePvpEvent(player, currentState, true);
|
||||
Bukkit.getScheduler().runTask(PreventStabby.getPlugin(), () -> {
|
||||
if (PlayerTogglePvpEvent.getHandlerList().getRegisteredListeners().length > 0) {
|
||||
Bukkit.getPluginManager().callEvent(toggleEvent);
|
||||
}
|
||||
if (!toggleEvent.isSendMessage()) return;
|
||||
if (currentState) {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().getPvp_enabled());
|
||||
} else {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().getPvp_disabled());
|
||||
}
|
||||
|
||||
playerManager.togglePlayerPvpState(player.getUniqueId()).thenAccept(newState -> {
|
||||
PlayerTogglePvpEvent toggleEvent = new PlayerTogglePvpEvent(player, newState, true);
|
||||
Bukkit.getScheduler().runTask(PreventStabby.getPlugin(), () -> {
|
||||
if (PlayerTogglePvpEvent.getHandlerList().getRegisteredListeners().length > 0) {
|
||||
Bukkit.getPluginManager().callEvent(toggleEvent);
|
||||
}
|
||||
if (!toggleEvent.isSendMessage()) return;
|
||||
if (newState) {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().pvp_enabled);
|
||||
} else {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().pvp_disabled);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
} else if (args.length == 2) {
|
||||
if (!PreventStabbyPermission.COMMAND_TOGGLE_OTHERS.doesCommandSenderHave(sender)) {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().getNo_permission());
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().no_permission);
|
||||
return;
|
||||
}
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if (CombatTimer.isInCombat(player.getUniqueId())) {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().getCant_do_that_during_combat());
|
||||
if (sender instanceof Player player) {
|
||||
if (playerManager.getPlayer(player.getUniqueId()).isInCombat()) {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().cant_do_that_during_combat);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -60,67 +61,65 @@ public class PvpToggleCommand {
|
||||
PluginMessages.sendMessage(sender, "<red>Player offline.");
|
||||
return;
|
||||
}
|
||||
boolean currentState = PreventStabby.getPlugin().getPlayerManager().togglePlayerPvpState(player.getUniqueId());
|
||||
PlayerTogglePvpEvent toggleEvent = new PlayerTogglePvpEvent(player, currentState, false);
|
||||
Bukkit.getScheduler().runTask(PreventStabby.getPlugin(), () -> {
|
||||
if (PlayerTogglePvpEvent.getHandlerList().getRegisteredListeners().length > 0) {
|
||||
Bukkit.getPluginManager().callEvent(toggleEvent);
|
||||
}
|
||||
if (toggleEvent.isSendMessage()) {
|
||||
if (currentState) {
|
||||
PluginMessages.sendMessage(player, PreventStabby.getPlugin().getConfigCache().getPvp_enabled());
|
||||
} else {
|
||||
PluginMessages.sendMessage(player, PreventStabby.getPlugin().getConfigCache().getPvp_disabled());
|
||||
playerManager.togglePlayerPvpState(player.getUniqueId()).thenAccept(newState -> {
|
||||
PlayerTogglePvpEvent toggleEvent = new PlayerTogglePvpEvent(player, newState, false);
|
||||
Bukkit.getScheduler().runTask(PreventStabby.getPlugin(), () -> {
|
||||
if (PlayerTogglePvpEvent.getHandlerList().getRegisteredListeners().length > 0) {
|
||||
Bukkit.getPluginManager().callEvent(toggleEvent);
|
||||
}
|
||||
}
|
||||
if (toggleEvent.isSendMessage()) {
|
||||
if (newState) {
|
||||
PluginMessages.sendMessage(player, PreventStabby.getPlugin().getConfigCache().pvp_enabled);
|
||||
} else {
|
||||
PluginMessages.sendMessage(player, PreventStabby.getPlugin().getConfigCache().pvp_disabled);
|
||||
}
|
||||
}
|
||||
String message;
|
||||
if (newState) {
|
||||
message = PreventStabby.getPlugin().getConfigCache().pvp_enabled_other;
|
||||
} else {
|
||||
message = PreventStabby.getPlugin().getConfigCache().pvp_disabled_other;
|
||||
}
|
||||
PluginMessages.sendMessage(sender, PluginMessages.parsePlayerName(player, message));
|
||||
});
|
||||
});
|
||||
|
||||
String message;
|
||||
if (currentState) {
|
||||
message = PreventStabby.getPlugin().getConfigCache().getPvp_enabled_other();
|
||||
} else {
|
||||
message = PreventStabby.getPlugin().getConfigCache().getPvp_disabled_other();
|
||||
}
|
||||
PluginMessages.sendMessage(sender, PluginMessages.parsePlayerName(player, message));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void enable(CommandSender sender, String[] args) {
|
||||
if (!PreventStabbyPermission.COMMAND_TOGGLE.doesCommandSenderHave(sender)) {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().getNo_permission());
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().no_permission);
|
||||
return;
|
||||
}
|
||||
if (args.length == 1) {
|
||||
if (!(sender instanceof Player)) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
PluginMessages.sendMessage(sender, "Try /pvp enable <player>");
|
||||
return;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
if (CombatTimer.isInCombat(player.getUniqueId())) {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().getCant_do_that_during_combat());
|
||||
if (playerManager.getPlayer(player.getUniqueId()).isInCombat()) {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().cant_do_that_during_combat);
|
||||
return;
|
||||
}
|
||||
PreventStabby.getPlugin().getPlayerManager().setPlayerPvpState(player.getUniqueId(), true);
|
||||
playerManager.setPlayerPvpState(player.getUniqueId(), true);
|
||||
PlayerTogglePvpEvent toggleEvent = new PlayerTogglePvpEvent(player, true, true);
|
||||
Bukkit.getScheduler().runTask(PreventStabby.getPlugin(), () -> {
|
||||
if (PlayerTogglePvpEvent.getHandlerList().getRegisteredListeners().length > 0) {
|
||||
Bukkit.getPluginManager().callEvent(toggleEvent);
|
||||
}
|
||||
if (toggleEvent.isSendMessage()) {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().getPvp_enabled());
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().pvp_enabled);
|
||||
}
|
||||
});
|
||||
|
||||
} else if (args.length == 2) {
|
||||
if (!PreventStabbyPermission.COMMAND_TOGGLE_OTHERS.doesCommandSenderHave(sender)) {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().getNo_permission());
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().no_permission);
|
||||
return;
|
||||
}
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if (CombatTimer.isInCombat(player.getUniqueId())) {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().getCant_do_that_during_combat());
|
||||
if (sender instanceof Player player) {
|
||||
if (playerManager.getPlayer(player.getUniqueId()).isInCombat()) {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().cant_do_that_during_combat);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -129,16 +128,16 @@ public class PvpToggleCommand {
|
||||
PluginMessages.sendMessage(sender, "<red>Player offline.");
|
||||
return;
|
||||
}
|
||||
String message = PreventStabby.getPlugin().getConfigCache().getPvp_enabled_other();
|
||||
String message = PreventStabby.getPlugin().getConfigCache().pvp_enabled_other;
|
||||
PluginMessages.sendMessage(sender, PluginMessages.parsePlayerName(player, message));
|
||||
PreventStabby.getPlugin().getPlayerManager().setPlayerPvpState(player.getUniqueId(), true);
|
||||
playerManager.setPlayerPvpState(player.getUniqueId(), true);
|
||||
PlayerTogglePvpEvent toggleEvent = new PlayerTogglePvpEvent(player, true, false);
|
||||
Bukkit.getScheduler().runTask(PreventStabby.getPlugin(), () -> {
|
||||
if (PlayerTogglePvpEvent.getHandlerList().getRegisteredListeners().length > 0) {
|
||||
Bukkit.getPluginManager().callEvent(toggleEvent);
|
||||
}
|
||||
if (toggleEvent.isSendMessage()) {
|
||||
PluginMessages.sendMessage(player, PreventStabby.getPlugin().getConfigCache().getPvp_enabled());
|
||||
PluginMessages.sendMessage(player, PreventStabby.getPlugin().getConfigCache().pvp_enabled);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -152,24 +151,23 @@ public class PvpToggleCommand {
|
||||
|
||||
public static void disable(CommandSender sender, String[] args) {
|
||||
if (!PreventStabbyPermission.COMMAND_TOGGLE.doesCommandSenderHave(sender)) {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().getNo_permission());
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().no_permission);
|
||||
return;
|
||||
}
|
||||
if (args.length == 1) {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if (CombatTimer.isInCombat(player.getUniqueId())) {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().getCant_do_that_during_combat());
|
||||
if (sender instanceof Player player) {
|
||||
if (playerManager.getPlayer(player.getUniqueId()).isInCombat()) {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().cant_do_that_during_combat);
|
||||
return;
|
||||
}
|
||||
PreventStabby.getPlugin().getPlayerManager().setPlayerPvpState(player.getUniqueId(), false);
|
||||
playerManager.setPlayerPvpState(player.getUniqueId(), false);
|
||||
PlayerTogglePvpEvent toggleEvent = new PlayerTogglePvpEvent(player, false, true);
|
||||
Bukkit.getScheduler().runTask(PreventStabby.getPlugin(), () -> {
|
||||
if (PlayerTogglePvpEvent.getHandlerList().getRegisteredListeners().length > 0) {
|
||||
Bukkit.getPluginManager().callEvent(toggleEvent);
|
||||
}
|
||||
if (toggleEvent.isSendMessage()) {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().getPvp_disabled());
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().pvp_disabled);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -177,13 +175,12 @@ public class PvpToggleCommand {
|
||||
}
|
||||
} else if (args.length == 2) {
|
||||
if (!PreventStabbyPermission.COMMAND_TOGGLE_OTHERS.doesCommandSenderHave(sender)) {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().getNo_permission());
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().no_permission);
|
||||
return;
|
||||
}
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if (CombatTimer.isInCombat(player.getUniqueId())) {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().getCant_do_that_during_combat());
|
||||
if (sender instanceof Player player) {
|
||||
if (playerManager.getPlayer(player.getUniqueId()).isInCombat()) {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().cant_do_that_during_combat);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -192,16 +189,16 @@ public class PvpToggleCommand {
|
||||
PluginMessages.sendMessage(sender, "<red>Player offline.");
|
||||
return;
|
||||
}
|
||||
String message = PreventStabby.getPlugin().getConfigCache().getPvp_disabled_other();
|
||||
String message = PreventStabby.getPlugin().getConfigCache().pvp_disabled_other;
|
||||
PluginMessages.sendMessage(sender, PluginMessages.parsePlayerName(player, message));
|
||||
PreventStabby.getPlugin().getPlayerManager().setPlayerPvpState(player.getUniqueId(), false);
|
||||
playerManager.setPlayerPvpState(player.getUniqueId(), false);
|
||||
PlayerTogglePvpEvent toggleEvent = new PlayerTogglePvpEvent(player, false, false);
|
||||
Bukkit.getScheduler().runTask(PreventStabby.getPlugin(), () -> {
|
||||
if (PlayerTogglePvpEvent.getHandlerList().getRegisteredListeners().length > 0) {
|
||||
Bukkit.getPluginManager().callEvent(toggleEvent);
|
||||
}
|
||||
if (toggleEvent.isSendMessage()) {
|
||||
PluginMessages.sendMessage(player, PreventStabby.getPlugin().getConfigCache().getPvp_disabled());
|
||||
PluginMessages.sendMessage(player, PreventStabby.getPlugin().getConfigCache().pvp_disabled);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user