chore: use predifined helper colors

This commit is contained in:
Janik Heß
2025-03-06 12:57:57 +01:00
parent 8fce93b346
commit 6a8aa6283f

View File

@@ -4,7 +4,6 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -20,7 +19,6 @@ import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import de.hessj.helper.Helper.Type;
import net.md_5.bungee.api.ChatColor;
public class EnvironmentExCommands implements CommandExecutor, Listener {
public de.hessj.helper.Helper helper = new de.hessj.helper.Helper();
@@ -55,7 +53,8 @@ public class EnvironmentExCommands implements CommandExecutor, Listener {
UUID playerId = p.getUniqueId();
playerPins.putIfAbsent(playerId, new HashMap<>());
if (args.length < 1) {
p.sendMessage(ChatColor.RED + "Benutzung: /pin <set | list | remove | follow | unfollow> [name]");
p.sendMessage(helper.R3SMessage(Type.ERROR,
"Benutzung: /pin <set | list | remove | follow | unfollow> [name]"));
return true;
}
@@ -65,7 +64,7 @@ public class EnvironmentExCommands implements CommandExecutor, Listener {
switch (subCommand) {
case "set":
if (args.length < 2) {
p.sendMessage(ChatColor.RED + "Benutzung: /pin set <name>");
p.sendMessage(helper.R3SMessage(Type.ERROR, "Benutzung: /pin set <name>"));
return true;
}
String pinName = args[1];
@@ -78,16 +77,16 @@ public class EnvironmentExCommands implements CommandExecutor, Listener {
+ playerLocation.getBlockY() + ", " + playerLocation.getBlockZ());
savePins();
p.sendMessage(ChatColor.GREEN + "Pin '" + pinName + "' wurde hinzugefügt.");
p.sendMessage(helper.R3SMessage(Type.SUCCESS, "Pin '" + pinName + "' wurde hinzugefügt."));
break;
case "list":
loadPinsFromConfig(playerId);
if (pins.isEmpty()) {
p.sendMessage(ChatColor.RED + "Du hast keine Pins.");
p.sendMessage(helper.R3SMessage(Type.ERROR, "Du hast keine Pins."));
return true;
}
p.sendMessage(ChatColor.BLUE + "Deine Pins:");
p.sendMessage(helper.R3SMessage(Type.OK, "Deine Pins:"));
for (String name : pins.keySet()) {
Location location = pins.get(name);
String w = "Overworld: ";
@@ -105,72 +104,65 @@ public class EnvironmentExCommands implements CommandExecutor, Listener {
break;
case "remove":
if (args.length < 2) {
p.sendMessage(ChatColor.RED + "Benutzung: /pin remove <name>");
p.sendMessage(helper.R3SMessage(Type.ERROR, "Benutzung: /pin remove <name>"));
return true;
}
pinName = args[1];
if (pins.remove(pinName) != null) {
PinFeature.pinConfig.set(playerId + "." + pinName, null);
savePins();
p.sendMessage(ChatColor.GREEN + "Pin '" + pinName + "' wurde entfernt.");
p.sendMessage(helper.R3SMessage(Type.SUCCESS, "Pin '" + pinName + "' wurde entfernt."));
} else {
p.sendMessage(ChatColor.RED + "Kein Pin mit diesem Namen gefunden.");
p.sendMessage(helper.R3SMessage(Type.ERROR, "Kein Pin mit diesem Namen gefunden."));
}
break;
case "follow":
if (args.length < 2) {
p.sendMessage(ChatColor.RED + "Benutzung: /pin follow <name>");
return true;
}
pinName = args[1];
if (PinFeature.pinConfig.contains(playerId + "." + pinName)) {
String locationString = PinFeature.pinConfig.getString(playerId + "." + pinName + ".loc");
if (locationString != null) {
String[] locParts = locationString.split(", ");
String worldName = locParts[0];
int x = Integer.parseInt(locParts[1]);
int y = Integer.parseInt(locParts[2]);
int z = Integer.parseInt(locParts[3]);
Location pinLocation = new Location(Bukkit.getWorld(worldName), x, y, z);
String w = "Overworld: ";
if (pinLocation.getWorld().getName().endsWith("_nether")) {
w = "Nether: ";
} else if (pinLocation.getWorld().getName().endsWith("_end")) {
w = "End: ";
}
BossBar bossBar = Bukkit.createBossBar(w + x + " " + y + " " + z, BarColor.WHITE, BarStyle.SOLID);
bossBar.setProgress(0.0);
if (!bossBars.containsKey(p.getUniqueId())) {
bossBar.addPlayer(p);
bossBars.put(p.getUniqueId(), bossBar);
} else {
bossBars.get(p.getUniqueId()).removeAll();
bossBars.remove(p.getUniqueId());
bossBar.addPlayer(p);
bossBars.put(p.getUniqueId(), bossBar);
if (args.length < 2) {
p.sendMessage(helper.R3SMessage(Type.ERROR, "Benutzung: /pin follow <name>"));
return true;
}
p.sendMessage(ChatColor.GREEN + "Du folgst nun dem Pin '" + pinName + "'.");
}
}
else {
p.sendMessage(ChatColor.RED + "Kein Pin mit diesem Namen gefunden.");
}
pinName = args[1];
if (PinFeature.pinConfig.contains(playerId + "." + pinName)) {
String locationString = PinFeature.pinConfig.getString(playerId + "." + pinName + ".loc");
if (locationString != null) {
String[] locParts = locationString.split(", ");
String worldName = locParts[0];
int x = Integer.parseInt(locParts[1]);
int y = Integer.parseInt(locParts[2]);
int z = Integer.parseInt(locParts[3]);
Location pinLocation = new Location(Bukkit.getWorld(worldName), x, y, z);
String w = "Overworld: ";
if (pinLocation.getWorld().getName().endsWith("_nether")) {
w = "Nether: ";
} else if (pinLocation.getWorld().getName().endsWith("_end")) {
w = "End: ";
}
BossBar bossBar = Bukkit.createBossBar(w + x + " " + y + " " + z, BarColor.WHITE,
BarStyle.SOLID);
bossBar.setProgress(0.0);
if (!bossBars.containsKey(p.getUniqueId())) {
bossBar.addPlayer(p);
bossBars.put(p.getUniqueId(), bossBar);
} else {
bossBars.get(p.getUniqueId()).removeAll();
bossBars.remove(p.getUniqueId());
bossBar.addPlayer(p);
bossBars.put(p.getUniqueId(), bossBar);
}
p.sendMessage(
helper.R3SMessage(Type.SUCCESS, "Du folgst nun dem Pin '" + pinName + "'."));
}
} else {
p.sendMessage(helper.R3SMessage(Type.ERROR, "Kein Pin mit diesem Namen gefunden."));
}
break;
@@ -178,12 +170,13 @@ public class EnvironmentExCommands implements CommandExecutor, Listener {
if (bossBars.containsKey(p.getUniqueId())) {
bossBars.get(p.getUniqueId()).removeAll();
bossBars.remove(p.getUniqueId());
p.sendMessage(ChatColor.RED + "Du folgst nun keinem Pin mehr.");
p.sendMessage(helper.R3SMessage(Type.ERROR, "Du folgst nun keinem Pin mehr."));
}
break;
default:
p.sendMessage(ChatColor.RED + "Benutzung: /pin <set | list | remove | follow | unfollow> [name]");
p.sendMessage(helper.R3SMessage(Type.ERROR,
"Benutzung: /pin <set | list | remove | follow | unfollow> [name]"));
}
}