SteamWar/FightSystem
Archiviert
13
1
Dieser Commit ist enthalten in:
Lixfel 2019-04-23 18:33:18 +02:00
Ursprung b9a26c768f
Commit d3adc79f0f
9 geänderte Dateien mit 41 neuen und 33 gelöschten Zeilen

Datei anzeigen

@ -21,5 +21,6 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: warking:SpigotCore:1.0" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: warking:SpigotCore:1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: warking:WorldEdit:1.0" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: warking:WorldEdit:1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: warking:FAWE:1.0" level="project" /> <orderEntry type="library" scope="PROVIDED" name="Maven: warking:FAWE:1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: warking:ProtocolLib:1.0" level="project" />
</component> </component>
</module> </module>

Datei anzeigen

@ -74,5 +74,11 @@
<version>1.0</version> <version>1.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>warking</groupId>
<artifactId>ProtocolLib</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

Datei anzeigen

@ -31,7 +31,7 @@ public class FightSystem extends JavaPlugin {
private Scoreboard scoreboard; private Scoreboard scoreboard;
private WaterRemover waterRemover; private WaterRemover waterRemover;
private FightState fightState; private static FightState fightState;
public int fightTime = 0; public int fightTime = 0;
@ -40,7 +40,7 @@ public class FightSystem extends JavaPlugin {
private final File kits = new File("plugins/" + this.getName(), "kits.data"); private final File kits = new File("plugins/" + this.getName(), "kits.data");
private final FileConfiguration getKitData = YamlConfiguration.loadConfiguration(kits); private final FileConfiguration getKitData = YamlConfiguration.loadConfiguration(kits);
public void saveKitData() { private void saveKitData() {
try { getKitData.save(kits); } catch (Exception ignored) { } try { getKitData.save(kits); } catch (Exception ignored) { }
} }
@ -65,6 +65,13 @@ public class FightSystem extends JavaPlugin {
fightState = FightState.SETUP; fightState = FightState.SETUP;
Countdown countdown = new Countdown(Config.NoPlayerOnlineDuration, new FinishNoPlayersOnline()); Countdown countdown = new Countdown(Config.NoPlayerOnlineDuration, new FinishNoPlayersOnline());
countdown.startTimer(getPlugin()); countdown.startTimer(getPlugin());
/*ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Server.MAP_CHUNK) {
@Override
public void onPacketSending(PacketEvent e) {
e.getPacket();
}
});*/
} }
public void onDisable() { public void onDisable() {
@ -109,11 +116,7 @@ public class FightSystem extends JavaPlugin {
return plugin; return plugin;
} }
public FightState getCurrentFightState() { public static FightState getFightState() {
return fightState;
}
public FightState getFightState() {
return fightState; return fightState;
} }
@ -126,9 +129,9 @@ public class FightSystem extends JavaPlugin {
} }
public void setPreRunningState() { public void setPreRunningState() {
if(this.fightState != FightState.SETUP) if(fightState != FightState.SETUP)
return; return;
this.fightState = FightState.PRE_RUNNING; fightState = FightState.PRE_RUNNING;
Countdown.cancelAllTimers(); Countdown.cancelAllTimers();
Countdown countdown = new Countdown(Config.PreFightDuration, new FinishPreRunning()); Countdown countdown = new Countdown(Config.PreFightDuration, new FinishPreRunning());
@ -169,9 +172,9 @@ public class FightSystem extends JavaPlugin {
} }
public void setRunningState() { public void setRunningState() {
if(this.fightState != FightState.PRE_RUNNING) if(fightState != FightState.PRE_RUNNING)
return; return;
this.fightState = FightState.RUNNING; fightState = FightState.RUNNING;
Countdown.cancelAllTimers(); Countdown.cancelAllTimers();
getWaterRemover().start(); getWaterRemover().start();
@ -185,18 +188,15 @@ public class FightSystem extends JavaPlugin {
} }
public void setSpectateState(FightTeam winFightTeam) { public void setSpectateState(FightTeam winFightTeam) {
if(this.fightState != FightState.RUNNING) if(fightState != FightState.RUNNING)
return; return;
this.fightState = FightState.SPECTATE; fightState = FightState.SPECTATE;
Countdown.cancelAllTimers(); Countdown.cancelAllTimers();
Bukkit.getScheduler().cancelTask(WinconditionTechKO.taskID); Bukkit.getScheduler().cancelTask(WinconditionTechKO.taskID);
setAllPlayersGM(GameMode.SPECTATOR); setAllPlayersGM(GameMode.SPECTATOR);
for(FightPlayer team1 : winFightTeam.getPlayers()) { for(Player p : Bukkit.getOnlinePlayers()){
team1.getPlayer().getInventory().clear(); p.getInventory().clear();
}
for(FightPlayer team2 : Fight.getOpposite(winFightTeam).getPlayers()) {
team2.getPlayer().getInventory().clear();
} }
Bukkit.broadcastMessage(" "); Bukkit.broadcastMessage(" ");

Datei anzeigen

@ -35,7 +35,7 @@ public class PlayerMoveListener implements Listener {
if(fightTeam == null){ if(fightTeam == null){
player.teleport(from); player.teleport(from);
player.sendMessage(FightSystem.PREFIX + "§cDu darfst die Arena nicht verlassen!"); player.sendMessage(FightSystem.PREFIX + "§cDu darfst die Arena nicht verlassen!");
}else if(instance.getCurrentFightState() == FightState.RUNNING) }else if(FightSystem.getFightState() == FightState.RUNNING)
player.damage(2); player.damage(2);
else if(fightTeam == Fight.redTeam) else if(fightTeam == Fight.redTeam)
player.teleport(Config.TeamRedSpawn); player.teleport(Config.TeamRedSpawn);

Datei anzeigen

@ -13,12 +13,14 @@ public class ProjectileLaunchListener implements Listener {
@EventHandler @EventHandler
public void handleProjectileLaunch(ProjectileLaunchEvent event) { public void handleProjectileLaunch(ProjectileLaunchEvent event) {
Player player = (Player) event.getEntity().getShooter();
if(instance.getFightState() != FightState.RUNNING) { if(instance.getFightState() != FightState.RUNNING) {
event.setCancelled(true); event.setCancelled(true);
if(event.getEntity().getShooter() instanceof Player){
Player player = (Player) event.getEntity().getShooter();
player.sendMessage(FightSystem.PREFIX + "§cDu kannst den Bogen erst nach Fightbeginn nutzen!"); player.sendMessage(FightSystem.PREFIX + "§cDu kannst den Bogen erst nach Fightbeginn nutzen!");
} }
} }
}
} }

Datei anzeigen

@ -19,7 +19,7 @@ public class WinconditionCaptainDead implements Listener {
@EventHandler @EventHandler
public void handlePlayerDeath(PlayerDeathEvent event) { public void handlePlayerDeath(PlayerDeathEvent event) {
if(!Config.CaptainDead) return; if(!Config.CaptainDead) return;
if(instance.getFightState() != FightState.PRE_RUNNING && instance.getFightState() != FightState.RUNNING) return; if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING) return;
Player player = event.getEntity().getPlayer(); Player player = event.getEntity().getPlayer();
if(Fight.getPlayerTeam(player) == null) return; if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player); FightTeam fightTeam = Fight.getPlayerTeam(player);
@ -35,7 +35,7 @@ public class WinconditionCaptainDead implements Listener {
@EventHandler @EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) { public void handlePlayerQuit(PlayerQuitEvent event) {
if(!Config.CaptainDead) return; if(!Config.CaptainDead) return;
if(instance.getFightState() != FightState.PRE_RUNNING && instance.getFightState() != FightState.RUNNING) return; if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING) return;
Player player = event.getPlayer(); Player player = event.getPlayer();
if(Fight.getPlayerTeam(player) == null) return; if(Fight.getPlayerTeam(player) == null) return;
FightTeam fightTeam = Fight.getPlayerTeam(player); FightTeam fightTeam = Fight.getPlayerTeam(player);
@ -44,7 +44,6 @@ public class WinconditionCaptainDead implements Listener {
if(fightTeam.isPlayerLeader(player)) { if(fightTeam.isPlayerLeader(player)) {
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von " + fightTeam.getPrefix() + fightTeam.getName() + " §chat den Kampf verlassen!"); Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von " + fightTeam.getPrefix() + fightTeam.getName() + " §chat den Kampf verlassen!");
instance.setSpectateState(Fight.getOpposite(fightTeam)); instance.setSpectateState(Fight.getOpposite(fightTeam));
return;
} }
} }

Datei anzeigen

@ -2,9 +2,9 @@ package me.yaruma.fightsystem.winconditions;
import me.yaruma.fightsystem.FightSystem; import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight; import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightState;
import me.yaruma.fightsystem.utils.Config; import me.yaruma.fightsystem.utils.Config;
import me.yaruma.fightsystem.utils.Region; import me.yaruma.fightsystem.utils.Region;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -27,6 +27,7 @@ public class WinconditionPercentSystem implements Listener {
@EventHandler @EventHandler
public void handleEntityExplode(EntityExplodeEvent event) { public void handleEntityExplode(EntityExplodeEvent event) {
if(!Config.PercentSystem) return; if(!Config.PercentSystem) return;
if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING) return;
Entity entity = event.getEntity(); Entity entity = event.getEntity();
//Team Blue //Team Blue

Datei anzeigen

@ -2,6 +2,7 @@ package me.yaruma.fightsystem.winconditions;
import me.yaruma.fightsystem.FightSystem; import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight; import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightState;
import me.yaruma.fightsystem.utils.Config; import me.yaruma.fightsystem.utils.Config;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -12,12 +13,13 @@ import java.util.Iterator;
public class WinconditionTechKO { public class WinconditionTechKO {
public static HashSet<Location> teamRedWater = new HashSet<>(); private static HashSet<Location> teamRedWater = new HashSet<>();
public static HashSet<Location> teamBlueWater = new HashSet<>(); private static HashSet<Location> teamBlueWater = new HashSet<>();
public static int taskID; public static int taskID;
public static void addWater() { public static void addWater() {
if(!Config.TechKO) return; if(!Config.TechKO) return;
if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING) return;
teamRedWater.clear(); teamRedWater.clear();
teamBlueWater.clear(); teamBlueWater.clear();
@ -71,12 +73,11 @@ public class WinconditionTechKO {
FightSystem.getPlugin().setSpectateState(Fight.getRedTeam()); FightSystem.getPlugin().setSpectateState(Fight.getRedTeam());
FightSystem.getPlugin().getWaterRemover().stop(); FightSystem.getPlugin().getWaterRemover().stop();
} }
System.out.println("RedList: " + teamRedWater.size());
System.out.println("BlueList: " + teamBlueWater.size());
} }
public static void removeWater() { public static void removeWater() {
if(!Config.TechKO) return; if(!Config.TechKO) return;
if(FightSystem.getFightState() != FightState.PRE_RUNNING && FightSystem.getFightState() != FightState.RUNNING) return;
//Team Red //Team Red
Iterator itrRed = teamRedWater.iterator(); Iterator itrRed = teamRedWater.iterator();
@ -84,7 +85,6 @@ public class WinconditionTechKO {
Location location = (Location) itrRed.next(); Location location = (Location) itrRed.next();
if(location.getBlock().getType() != Material.WATER && location.getBlock().getType() != Material.STATIONARY_WATER) { if(location.getBlock().getType() != Material.WATER && location.getBlock().getType() != Material.STATIONARY_WATER) {
itrRed.remove(); itrRed.remove();
System.out.println("red remove" + teamRedWater.size());
} }
} }
if(teamRedWater.isEmpty()) { if(teamRedWater.isEmpty()) {
@ -100,7 +100,6 @@ public class WinconditionTechKO {
Location location = (Location) itrBlue.next(); Location location = (Location) itrBlue.next();
if(location.getBlock().getType() != Material.WATER && location.getBlock().getType() != Material.STATIONARY_WATER) { if(location.getBlock().getType() != Material.WATER && location.getBlock().getType() != Material.STATIONARY_WATER) {
itrBlue.remove(); itrBlue.remove();
System.out.println("blue remove" + teamBlueWater.size());
} }
} }
if(teamBlueWater.isEmpty()) { if(teamBlueWater.isEmpty()) {
@ -113,7 +112,7 @@ public class WinconditionTechKO {
public static void startAutoChecker() { public static void startAutoChecker() {
if(!Config.TechKO) return; if(!Config.TechKO) return;
taskID = Bukkit.getScheduler().scheduleAsyncRepeatingTask(FightSystem.getPlugin(), () -> addWater(), 0, 20*20); taskID = Bukkit.getScheduler().scheduleAsyncRepeatingTask(FightSystem.getPlugin(), WinconditionTechKO::addWater, 0, 20*20);
} }
} }

Datei anzeigen

@ -2,7 +2,7 @@ name: FightSystem
version: 1.0 version: 1.0
author: [Yaruma3341, Lixfel] author: [Yaruma3341, Lixfel]
main: me.yaruma.fightsystem.FightSystem main: me.yaruma.fightsystem.FightSystem
depend: [CoreSystem, WorldEdit, FastAsyncWorldEdit] depend: [CoreSystem, WorldEdit, FastAsyncWorldEdit, ProtocolLib]
commands: commands:
ak: ak: