From 948d472f406edb448a16db4148413fcc91af83c3 Mon Sep 17 00:00:00 2001 From: jojo Date: Fri, 4 Dec 2020 21:47:14 +0100 Subject: [PATCH] Add DeathListener Add Config.test Add MWTeam color to tablist --- pom.xml | 7 +++++++ src/de/steamwar/misslewars/Config.java | 9 +++++++++ src/de/steamwar/misslewars/MWTeam.java | 13 +++++++------ .../steamwar/misslewars/listener/DeathListener.java | 4 ++++ 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 226acf5..d6ed03e 100644 --- a/pom.xml +++ b/pom.xml @@ -53,5 +53,12 @@ system ${main.basedir}/lib/WorldEdit-1.15.jar + + steamwar + SpigotCore + 1.0 + system + ${main.basedir}/lib/SpigotCore.jar + \ No newline at end of file diff --git a/src/de/steamwar/misslewars/Config.java b/src/de/steamwar/misslewars/Config.java index 4e4ed04..27073cc 100644 --- a/src/de/steamwar/misslewars/Config.java +++ b/src/de/steamwar/misslewars/Config.java @@ -50,6 +50,8 @@ public class Config { public static final double MissileChance; + private static final int EventKampfID; + static { File configfile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "config.yml"); if (!configfile.exists()) { @@ -83,5 +85,12 @@ public class Config { assert blue != null; BluePortalZ = blue.getInt("PortalZ"); BlueSpawn = new Location(Bukkit.getWorlds().get(0), blue.getDouble("SpawnX"), blue.getDouble("SpawnY"), blue.getDouble("SpawnZ"), (float)blue.getDouble("SpawnYaw"), (float)blue.getDouble("SpawnPitch")); + + EventKampfID = Integer.parseInt(System.getProperty("fightID", "0")); } + + public static boolean test() { + return EventKampfID == -1; + } + } diff --git a/src/de/steamwar/misslewars/MWTeam.java b/src/de/steamwar/misslewars/MWTeam.java index 72ba713..906adc4 100644 --- a/src/de/steamwar/misslewars/MWTeam.java +++ b/src/de/steamwar/misslewars/MWTeam.java @@ -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; @@ -95,7 +94,7 @@ public class MWTeam { } public void teamScoreboard(Objective objective) { - players.forEach(p -> objective.getScore(getPrefix() + p.getName()).setScore(1)); + players.forEach(p -> objective.getScore(getColorCode() + p.getName()).setScore(1)); } public int size() { @@ -119,6 +118,8 @@ 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) { @@ -137,7 +138,7 @@ public class MWTeam { return MissileWars.getRedTeam(); } - public String getPrefix(){ + public String getColorCode(){ return "ยง" + color.getChar(); } diff --git a/src/de/steamwar/misslewars/listener/DeathListener.java b/src/de/steamwar/misslewars/listener/DeathListener.java index 4c12226..735dcc4 100644 --- a/src/de/steamwar/misslewars/listener/DeathListener.java +++ b/src/de/steamwar/misslewars/listener/DeathListener.java @@ -28,11 +28,14 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.util.Vector; import java.util.EnumSet; public class DeathListener extends BasicListener { + private static Vector ZERO = new Vector(0, 0, 0); + public DeathListener() { super(EnumSet.allOf(FightState.class)); } @@ -52,6 +55,7 @@ public class DeathListener extends BasicListener { return; e.setRespawnLocation(team.getSpawn()); + e.getPlayer().setVelocity(ZERO); new SpawnPlatformCreator(p); } }