Add Tablist support #30
@ -54,6 +54,8 @@ public class Config {
|
||||
public static final UUID BlueLeader;
|
||||
public static final UUID RedLeader;
|
||||
|
||||
private static final int EventKampfID;
|
||||
|
||||
static {
|
||||
File configfile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "config.yml");
|
||||
if (!configfile.exists()) {
|
||||
@ -98,10 +100,16 @@ public class Config {
|
||||
RedLeader = UUID.fromString(redLeader);
|
||||
else
|
||||
RedLeader = null;
|
||||
|
||||
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
|
||||
}
|
||||
|
||||
public static boolean isChallenge() {
|
||||
return BlueLeader != null && RedLeader != null;
|
||||
}
|
||||
|
||||
public static boolean test(){
|
||||
return EventKampfID == -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,10 +19,9 @@
|
||||
|
||||
package de.steamwar.misslewars;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import de.steamwar.comms.packets.TablistNamePacket;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
@ -57,7 +56,7 @@ public class MWTeam {
|
||||
|
||||
private final LinkedList<Player> players = new LinkedList<>();
|
||||
private final Set<Player> openInvitations = new HashSet<>();
|
||||
|
||||
|
||||
MWTeam(ChatColor color, Location spawn, String teamName, int portalZ) {
|
||||
this.teamName = teamName;
|
||||
this.color = color;
|
||||
@ -122,8 +121,11 @@ public class MWTeam {
|
||||
p.setDisplayName(color + p.getName());
|
||||
if (MissileWars.getFightState() == FightState.WAITING && !enemy().players.isEmpty())
|
||||
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) {
|
||||
if (!players.contains(p)) return;
|
||||
|
||||
@ -132,6 +134,9 @@ public class MWTeam {
|
||||
sbteam.removePlayer(p);
|
||||
if (players.isEmpty() && MissileWars.getFightState() == FightState.FIGHTING)
|
||||
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) {
|
||||
@ -143,18 +148,18 @@ public class MWTeam {
|
||||
removeInvitations(p);
|
||||
join(p);
|
||||
}
|
||||
|
||||
|
||||
private MWTeam enemy() {
|
||||
if (this == MissileWars.getRedTeam())
|
||||
return MissileWars.getBlueTeam();
|
||||
|
||||
return MissileWars.getRedTeam();
|
||||
}
|
||||
|
||||
|
||||
public String getColorCode(){
|
||||
return "§" + color.getChar();
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPlayer(Player p) {
|
||||
return players.contains(p);
|
||||
}
|
||||
|
@ -19,9 +19,11 @@
|
||||
|
||||
package de.steamwar.misslewars.listener;
|
||||
|
||||
import de.steamwar.comms.packets.TablistNamePacket;
|
||||
import de.steamwar.misslewars.Config;
|
||||
import de.steamwar.misslewars.FightState;
|
||||
import de.steamwar.misslewars.MissileWars;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
@ -37,6 +39,8 @@ public class JoinListener extends BasicListener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onJoin(PlayerJoinEvent e){
|
||||
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.RedLeader.equals(e.getPlayer().getUniqueId())) {
|
||||
MissileWars.getRedTeam().join(e.getPlayer());
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren