13
0

Hologram nice text formatting
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Lixfel 2022-03-11 17:10:05 +01:00
Ursprung e02edf3cca
Commit ce74b70a94
2 geänderte Dateien mit 46 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -31,7 +31,8 @@ public class InventoryInteraction extends BasicListener {
@EventHandler
public void handlePlayerInteract(PlayerInteractEvent event) {
if(event.getItem() == null)
ItemStack item = event.getItem();
if(item == null || item.getType() == Material.FIREWORK_ROCKET)
return;
if(!ModifyCommand.modifying(event.getPlayer()))

Datei anzeigen

@ -29,7 +29,9 @@ import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import java.text.MessageFormat;
import java.util.*;
import java.util.logging.Level;
public class FightserverPortal implements PortalHandler, Comparable<FightserverPortal> {
@ -78,12 +80,6 @@ public class FightserverPortal implements PortalHandler, Comparable<FightserverP
this.redPlayers = redPlayers;
hologram = new Hologram(null, portal.denormalize(new Vector(0.5, 0.5, 0.5)).toLocation(portal.getPos1().getWorld()), "", false);
if(portal.getId().equals("Lixfel")) {
System.out.println(portal.getPos1());
System.out.println(portal.getPos2());
System.out.println(portal.denormalize(new Vector(0.5, 0.5, 0.5)).toLocation(portal.getPos1().getWorld()));
}
setServer(null);
List<FightserverPortal> list = portals.computeIfAbsent(gamemode, mode -> new ArrayList<>());
@ -105,12 +101,16 @@ public class FightserverPortal implements PortalHandler, Comparable<FightserverP
public void updateText() {
if(server == null) {
hologram.updateText("Neuen Kampf starten");
hologram.updateText("§7Neuen Kampf starten");
return;
}
FightInfoPacket info = server.current();
hologram.updateText(server.getServerName() + " " + info.getFightState() + " " + (info.getCountdown() / 60) + ":" + (info.getCountdown() % 60));
if (fightStateCountdown(info.getFightState()))
hologram.updateText(MessageFormat.format("§7{0} §e{1} §7{2}§8:§7{3}", server.getServerName(), fightStateMapper(info.getFightState()), info.getCountdown() / 60, info.getCountdown() % 60));
else
hologram.updateText(MessageFormat.format("§7{0} §e{1}", server.getServerName(), fightStateMapper(info.getFightState())));
}
public void updateBluePlayers() {
@ -189,4 +189,40 @@ public class FightserverPortal implements PortalHandler, Comparable<FightserverP
public int compareTo(FightserverPortal other) {
return order - other.order;
}
private boolean fightStateCountdown(String state) {
switch (state) {
case "waiting":
case "PRE_LEADER_SETUP":
case "end":
case "SPECTATE":
return false;
default:
return true;
}
}
private String fightStateMapper(String state) {
switch (state) {
case "waiting":
case "PRE_LEADER_SETUP":
return "Warten auf Spieler";
case "fighting":
return "Kampf läuft seit";
case "PRE_SCHEM_SETUP":
return "Schemauswahl";
case "POST_SCHEM_SETUP":
return "Vorbereitung";
case "PRE_RUNNING":
return "Kampfbeginn in";
case "RUNNING":
return "Kampf läuft noch";
case "end":
case "SPECTATE":
return "Zuschauerphase";
default:
LobbySystem.getPlugin().getLogger().log(Level.SEVERE, "Unknown FightState " + state + " encountered");
return "Programmierfehler";
}
}
}