going on an adventure

This commit is contained in:
2022-06-16 23:52:30 +02:00
parent 6fd3e4b671
commit b99c14b631
7 changed files with 135 additions and 69 deletions
@@ -3,24 +3,27 @@ package me.youhavetrouble.preventstabby.commands;
import me.youhavetrouble.preventstabby.PreventStabby;
import me.youhavetrouble.preventstabby.config.PreventStabbyPermission;
import me.youhavetrouble.preventstabby.util.PluginMessages;
import net.kyori.adventure.audience.MessageType;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import java.util.ArrayList;
import java.util.List;
public class HelpCommand {
// TODO change this to be 1 component when transitioning to adventure
public static void help(CommandSender sender, String[] args) {
Bukkit.getScheduler().runTaskAsynchronously(PreventStabby.getPlugin(), () -> {
List<String> helpPage = new ArrayList<>();
helpPage.add(PluginMessages.parseMessage("&b&m &bPreventStabby Help&b&m "));
helpPage.add(PluginMessages.parseMessage("&9/pvp &b&lhelp &f- shows this message"));
Component helpComponent = PluginMessages.MINIMESSAGE
.deserialize("<aqua><strikethrough> </strikethrough> PreventStabby Help <strikethrough> </strikethrough>")
.append(Component.newline())
.append(PluginMessages.MINIMESSAGE.deserialize("<blue>/pvp <aqua><bold>help</bold> <white>- shows this message"));
if (PreventStabbyPermission.COMMAND_TOGGLE.doesCommandSenderHave(sender)) {
helpPage.add(PluginMessages.parseMessage("&9/pvp &b&l[on/off] &f- enables or disables PvP"));
helpPage.add(PluginMessages.parseMessage("&9/pvp &b&ltoggle &f- toggles PvP status"));
helpComponent = helpComponent.append(Component.newline());
helpComponent = helpComponent
.append(PluginMessages.MINIMESSAGE.deserialize("<blue>/pvp <aqua><bold>[on/off]</bold> <white>- enables or disables PvP"))
.append(Component.newline())
.append(PluginMessages.MINIMESSAGE.deserialize("<blue>/pvp <aqua><bold>toggle</bold> <white>- toggles PvP status"));
}
String[] helpReady = helpPage.toArray(new String[0]);
sender.sendMessage(helpReady);
PreventStabby.getAudiences().sender(sender).sendMessage(helpComponent, MessageType.SYSTEM);
});
}
@@ -26,13 +26,11 @@ public class PvpToggleCommand {
}
boolean currentState = PreventStabby.getPlugin().getPlayerManager().togglePlayerPvpState(player.getUniqueId());
String message;
if (currentState) {
message = PluginMessages.parseMessage(sender, PreventStabby.getPlugin().getConfigCache().getPvp_enabled());
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().getPvp_enabled());
} else {
message = PluginMessages.parseMessage(sender, PreventStabby.getPlugin().getConfigCache().getPvp_disabled());
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().getPvp_disabled());
}
PluginMessages.sendMessage(sender, message);
} else {
PluginMessages.sendMessage(sender, "Try /pvp toggle <player>");
}
@@ -51,7 +49,7 @@ public class PvpToggleCommand {
Player player = Bukkit.getPlayer(args[1]);
if (player == null) {
PluginMessages.sendMessage(sender, "&cPlayer offline.");
PluginMessages.sendMessage(sender, "<red>Player offline.");
return;
}
boolean currentState = PreventStabby.getPlugin().getPlayerManager().togglePlayerPvpState(player.getUniqueId());
@@ -103,7 +101,7 @@ public class PvpToggleCommand {
}
Player player = Bukkit.getPlayer(args[1]);
if (player == null) {
PluginMessages.sendMessage(sender, PluginMessages.parseMessage("&cPlayer offline."));
PluginMessages.sendMessage(sender, "<red>Player offline.");
return;
}
String message = PreventStabby.getPlugin().getConfigCache().getPvp_enabled_other();
@@ -149,7 +147,7 @@ public class PvpToggleCommand {
}
Player player = Bukkit.getPlayer(args[1]);
if (player == null) {
PluginMessages.sendMessage(sender, PluginMessages.parseMessage("&cPlayer offline."));
PluginMessages.sendMessage(sender, "<red>Player offline.");
return;
}
String message = PreventStabby.getPlugin().getConfigCache().getPvp_disabled_other();