Fix errors

This commit is contained in:
Telesphoreo 2022-05-19 16:32:31 -05:00
parent 4d77d514fd
commit f97649083a
2 changed files with 24 additions and 14 deletions

View File

@ -10,6 +10,7 @@ import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils; import dev.plex.util.PlexUtils;
import java.util.List; import java.util.List;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -24,26 +25,33 @@ public class ToggleCMD extends PlexCommand
{ {
if (isConsole(sender) || playerSender == null) if (isConsole(sender) || playerSender == null)
{ {
sender.sendMessage(PlexUtils.mmDeserialize("<gray>Available toggles:")); if (args.length == 0)
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Explosions " + status("explosions"))); {
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Fluidspread " + status("fluidspread"))); sender.sendMessage(PlexUtils.mmDeserialize("<gray>Available toggles:"));
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Drops " + status("drops"))); sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Explosions" + status("explosions")));
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Fluidspread" + status("fluidspread")));
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Drops" + status("drops")));
return null;
}
switch (args[0].toLowerCase()) switch (args[0].toLowerCase())
{ {
case "explosions": case "explosions" ->
{ {
toggle("explosions"); return toggle(sender, "explosions");
} }
case "fluidspread": case "fluidspread" ->
{ {
toggle("fluidspread"); return toggle(sender, "fluidspread");
} }
case "drops": case "drops" ->
{ {
toggle("drops"); return toggle(sender, "drops");
}
default ->
{
return messageComponent("invalidToggle");
} }
} }
return null;
} }
new ToggleMenu().openInv(playerSender, 0); new ToggleMenu().openInv(playerSender, 0);
return null; return null;
@ -57,11 +65,12 @@ public class ToggleCMD extends PlexCommand
private String status(String toggle) private String status(String toggle)
{ {
return plugin.toggles.getBoolean(toggle) ? "(enabled)" : "(disabled)"; return plugin.toggles.getBoolean(toggle) ? " (enabled)" : " (disabled)";
} }
private void toggle(String toggle) private Component toggle(CommandSender sender, String toggle)
{ {
plugin.toggles.set(toggle, !plugin.getToggles().getBoolean(toggle)); plugin.toggles.set(toggle, !plugin.getToggles().getBoolean(toggle));
return Component.text("Toggled " + toggle + status(toggle)).color(NamedTextColor.GRAY);
} }
} }

View File

@ -181,3 +181,4 @@ noteNotFound: "<red>A note with this ID could not be found."
removedNote: "<green>Removed note with ID: {0}" removedNote: "<green>Removed note with ID: {0}"
# 0 - The number of notes cleared # 0 - The number of notes cleared
clearedNotes: "<green>Cleared {0} notes." clearedNotes: "<green>Cleared {0} notes."
invalidToggle: "<red>That is not a valid toggle."