SteamWar/MissileWars
Archiviert
13
0

Merge pull request 'Add Tablist support' (#30) from Tablist into master

Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
YoyoNow 2021-01-28 19:40:36 +01:00
Commit 5e16aaffcd
3 geänderte Dateien mit 26 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -54,6 +54,8 @@ public class Config {
public static final UUID BlueLeader; public static final UUID BlueLeader;
public static final UUID RedLeader; public static final UUID RedLeader;
private static final int EventKampfID;
static { static {
File configfile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "config.yml"); File configfile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "config.yml");
if (!configfile.exists()) { if (!configfile.exists()) {
@ -98,10 +100,16 @@ public class Config {
RedLeader = UUID.fromString(redLeader); RedLeader = UUID.fromString(redLeader);
else else
RedLeader = null; RedLeader = null;
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
} }
public static boolean isChallenge() { public static boolean isChallenge() {
return BlueLeader != null && RedLeader != null; return BlueLeader != null && RedLeader != null;
} }
public static boolean test(){
return EventKampfID == -1;
}
} }

Datei anzeigen

@ -19,10 +19,9 @@
package de.steamwar.misslewars; package de.steamwar.misslewars;
import org.bukkit.ChatColor; import de.steamwar.comms.packets.TablistNamePacket;
import org.bukkit.GameMode; import de.steamwar.sql.SteamwarUser;
import org.bukkit.Location; import org.bukkit.*;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
@ -57,7 +56,7 @@ public class MWTeam {
private final LinkedList<Player> players = new LinkedList<>(); private final LinkedList<Player> players = new LinkedList<>();
private final Set<Player> openInvitations = new HashSet<>(); private final Set<Player> openInvitations = new HashSet<>();
MWTeam(ChatColor color, Location spawn, String teamName, int portalZ) { MWTeam(ChatColor color, Location spawn, String teamName, int portalZ) {
this.teamName = teamName; this.teamName = teamName;
this.color = color; this.color = color;
@ -122,8 +121,11 @@ public class MWTeam {
p.setDisplayName(color + p.getName()); p.setDisplayName(color + p.getName());
if (MissileWars.getFightState() == FightState.WAITING && !enemy().players.isEmpty()) if (MissileWars.getFightState() == FightState.WAITING && !enemy().players.isEmpty())
MissileWars.startRound(); MissileWars.startRound();
if (!Config.test())
Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), () -> new TablistNamePacket(SteamwarUser.get(p.getUniqueId()).getId(), color + p.getName()).send(p), 5);
} }
public void leave(Player p) { public void leave(Player p) {
if (!players.contains(p)) return; if (!players.contains(p)) return;
@ -132,6 +134,9 @@ public class MWTeam {
sbteam.removePlayer(p); sbteam.removePlayer(p);
if (players.isEmpty() && MissileWars.getFightState() == FightState.FIGHTING) if (players.isEmpty() && MissileWars.getFightState() == FightState.FIGHTING)
MissileWars.end(WinReasons.NO_ENEMY, enemy()); MissileWars.end(WinReasons.NO_ENEMY, enemy());
if (!Config.test())
new TablistNamePacket(SteamwarUser.get(p.getUniqueId()).getId(), "§7§o" + p.getName()).send(p);
} }
public void invitePlayer(Player p) { public void invitePlayer(Player p) {
@ -143,18 +148,18 @@ public class MWTeam {
removeInvitations(p); removeInvitations(p);
join(p); join(p);
} }
private MWTeam enemy() { private MWTeam enemy() {
if (this == MissileWars.getRedTeam()) if (this == MissileWars.getRedTeam())
return MissileWars.getBlueTeam(); return MissileWars.getBlueTeam();
return MissileWars.getRedTeam(); return MissileWars.getRedTeam();
} }
public String getColorCode(){ public String getColorCode(){
return "§" + color.getChar(); return "§" + color.getChar();
} }
public boolean hasPlayer(Player p) { public boolean hasPlayer(Player p) {
return players.contains(p); return players.contains(p);
} }

Datei anzeigen

@ -19,9 +19,11 @@
package de.steamwar.misslewars.listener; package de.steamwar.misslewars.listener;
import de.steamwar.comms.packets.TablistNamePacket;
import de.steamwar.misslewars.Config; import de.steamwar.misslewars.Config;
import de.steamwar.misslewars.FightState; import de.steamwar.misslewars.FightState;
import de.steamwar.misslewars.MissileWars; import de.steamwar.misslewars.MissileWars;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
@ -37,6 +39,8 @@ public class JoinListener extends BasicListener {
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onJoin(PlayerJoinEvent e){ public void onJoin(PlayerJoinEvent e){
e.setJoinMessage("§a» " + e.getPlayer().getDisplayName()); e.setJoinMessage("§a» " + e.getPlayer().getDisplayName());
if (!Config.test())
new TablistNamePacket(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), "§7" + e.getPlayer().getName()).send(e.getPlayer());
if (Config.isChallenge()) { if (Config.isChallenge()) {
if (Config.RedLeader.equals(e.getPlayer().getUniqueId())) { if (Config.RedLeader.equals(e.getPlayer().getUniqueId())) {
MissileWars.getRedTeam().join(e.getPlayer()); MissileWars.getRedTeam().join(e.getPlayer());