SteamWar/FightSystem
Archiviert
13
1

Not stable version

Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Yaruma3341 2019-02-23 21:58:26 +01:00
Ursprung 4dce49209c
Commit 7dc9546c72
13 geänderte Dateien mit 80 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -230,7 +230,7 @@ public class FightSystem extends JavaPlugin {
if(this.fightState != FightState.SETUP) if(this.fightState != FightState.SETUP)
return; return;
this.fightState = FightState.PRE_RUNNING; this.fightState = FightState.PRE_RUNNING;
Countdown.cancelAllTimers(plugin); Countdown.cancelAllTimers();
int time = fileManager.getIntegerFromConfig("Times.PreFightDuration"); int time = fileManager.getIntegerFromConfig("Times.PreFightDuration");
Countdown countdown = new Countdown(time, new FinishPreRunning()); Countdown countdown = new Countdown(time, new FinishPreRunning());
@ -259,7 +259,7 @@ public class FightSystem extends JavaPlugin {
if(this.fightState != FightState.PRE_RUNNING) if(this.fightState != FightState.PRE_RUNNING)
return; return;
this.fightState = FightState.RUNNING; this.fightState = FightState.RUNNING;
Countdown.cancelAllTimers(plugin); Countdown.cancelAllTimers();
setAllPlayersGM(GameMode.SURVIVAL); setAllPlayersGM(GameMode.SURVIVAL);
@ -275,7 +275,7 @@ public class FightSystem extends JavaPlugin {
if(this.fightState != FightState.RUNNING) if(this.fightState != FightState.RUNNING)
return; return;
this.fightState = FightState.SPECTATE; this.fightState = FightState.SPECTATE;
Countdown.cancelAllTimers(plugin); Countdown.cancelAllTimers();
setAllPlayersGM(GameMode.SPECTATOR); setAllPlayersGM(GameMode.SPECTATOR);
entern = true; entern = true;
@ -305,7 +305,7 @@ public class FightSystem extends JavaPlugin {
} }
Countdown cancelAllCountdowns = new Countdown(); Countdown cancelAllCountdowns = new Countdown();
cancelAllCountdowns.cancelAllTimers(FightSystem.getPlugin()); cancelAllCountdowns.cancelAllTimers();
Countdown countdown = new Countdown(20*60, new FinishSpectateOver()); Countdown countdown = new Countdown(20*60, new FinishSpectateOver());
countdown.startTimer(FightSystem.getPlugin()); countdown.startTimer(FightSystem.getPlugin());
} }

Datei anzeigen

@ -27,12 +27,12 @@ public class PlayerChatListener implements Listener {
String prefixColorCode = fightTeam.getPrefix(); String prefixColorCode = fightTeam.getPrefix();
String teamName = fightTeam.getName(); String teamName = fightTeam.getName();
if(message.startsWith(teamChatDetection)) { if(message.startsWith(teamChatDetection)) {
fightTeam.broadcast(prefixColorCode + player.getName() + "» " + prefixColorCode + message); fightTeam.broadcast(prefixColorCode + player.getName() + "» " + prefixColorCode + message.substring(1));
} else { } else {
Bukkit.broadcastMessage(prefixColorCode + teamName + " " + player.getName() + " §8» §7" + message); Bukkit.broadcastMessage(prefixColorCode + teamName + " " + player.getName() + " §8» §7" + message);
} }
}else{ }else{
Bukkit.broadcastMessage("§7" + player.getName() + " §8» §7" + message.substring(1)); Bukkit.broadcastMessage("§7" + player.getName() + " §8» §7" + message);
} }
event.setCancelled(true); event.setCancelled(true);

Datei anzeigen

@ -51,7 +51,7 @@ public class PlayerInteractListener implements Listener {
player.getInventory().clear(); player.getInventory().clear();
if(Fight.getOpposite(fightTeam).getLeader().getPlayer() != null) Fight.getOpposite(fightTeam).getLeader().getPlayer().getInventory().clear(); if(Fight.getOpposite(fightTeam).getLeader().getPlayer() != null) Fight.getOpposite(fightTeam).getLeader().getPlayer().getInventory().clear();
Countdown.cancelAllTimers(instance); Countdown.cancelAllTimers();
Countdown countdown = new Countdown(30, new FinishNoPlayersOnline()); Countdown countdown = new Countdown(30, new FinishNoPlayersOnline());
countdown.startTimer(instance); countdown.startTimer(instance);
break; break;

Datei anzeigen

@ -8,6 +8,8 @@ import java.util.ArrayList;
public class Countdown { public class Countdown {
private static ArrayList<Countdown> countdowns = new ArrayList<>();
private int time; private int time;
private CountdownCallback countdownCallback; private CountdownCallback countdownCallback;
private int taskID; private int taskID;
@ -19,6 +21,7 @@ public class Countdown {
public Countdown(int time, CountdownCallback countdownCallback) { public Countdown(int time, CountdownCallback countdownCallback) {
this.time = time; this.time = time;
this.countdownCallback = countdownCallback; this.countdownCallback = countdownCallback;
countdowns.add(this);
if(countdownCallback == new FinishTimeOver()) FightSystem.getPlugin().fightTime = time; if(countdownCallback == new FinishTimeOver()) FightSystem.getPlugin().fightTime = time;
} }
@ -49,11 +52,24 @@ public class Countdown {
}, 0, 20); }, 0, 20);
} }
public void cancelTimer(int taskID) { public void cancelTimer() {
Bukkit.getScheduler().cancelTask(taskID); Bukkit.getScheduler().cancelTask(this.taskID);
countdowns.remove(this);
} }
public static void cancelAllTimers(FightSystem plugin) { public static void cancelAllTimers() {
Bukkit.getScheduler().cancelTasks(plugin); for(Countdown countdown : countdowns) {
countdown.cancelTimer();
}
}
public static void cancelTimerType(CountdownType countdownType) {
for(Countdown countdown : countdowns) {
if(countdown.getType() == countdownType) countdown.cancelTimer();
}
}
public CountdownType getType() {
return countdownCallback.getType();
} }
} }

Datei anzeigen

@ -4,6 +4,7 @@ public interface CountdownCallback {
String countdownCounting(); String countdownCounting();
void countdownFinished(); void countdownFinished();
CountdownType getType();
} }

Datei anzeigen

@ -0,0 +1,13 @@
package me.yaruma.fightsystem.utils.countdown;
public enum CountdownType {
NO_ENTERN,
NO_PLAYERS_ONLINE,
PRE_RUNNING,
SETUP_OVER,
SPECTATE_OVER,
TIME_OVER;
}

Datei anzeigen

@ -14,4 +14,9 @@ public class FinishNoPlayersOnline implements CountdownCallback {
Bukkit.broadcastMessage("§aStoppe Server..."); Bukkit.broadcastMessage("§aStoppe Server...");
Bukkit.getServer().shutdown(); Bukkit.getServer().shutdown();
} }
@Override
public CountdownType getType() {
return CountdownType.NO_PLAYERS_ONLINE;
}
} }

Datei anzeigen

@ -15,4 +15,9 @@ public class FinishNoneEntern implements CountdownCallback {
FightSystem.getPlugin().entern = true; FightSystem.getPlugin().entern = true;
Bukkit.broadcastMessage("§aEntern ist nun erlaubt!"); Bukkit.broadcastMessage("§aEntern ist nun erlaubt!");
} }
@Override
public CountdownType getType() {
return CountdownType.NO_ENTERN;
}
} }

Datei anzeigen

@ -17,4 +17,9 @@ public class FinishPreRunning implements CountdownCallback {
public void countdownFinished() { public void countdownFinished() {
FightSystem.getPlugin().setRunningState(); FightSystem.getPlugin().setRunningState();
} }
@Override
public CountdownType getType() {
return CountdownType.PRE_RUNNING;
}
} }

Datei anzeigen

@ -14,4 +14,9 @@ public class FinishSetupOver implements CountdownCallback {
Bukkit.broadcastMessage("Fight wird abgebrochen! \n Stoppe Server..."); Bukkit.broadcastMessage("Fight wird abgebrochen! \n Stoppe Server...");
Bukkit.getServer().shutdown(); Bukkit.getServer().shutdown();
} }
@Override
public CountdownType getType() {
return CountdownType.SETUP_OVER;
}
} }

Datei anzeigen

@ -14,4 +14,9 @@ public class FinishSpectateOver implements CountdownCallback {
Bukkit.broadcastMessage("§aStoppe Server..."); Bukkit.broadcastMessage("§aStoppe Server...");
Bukkit.getServer().shutdown(); Bukkit.getServer().shutdown();
} }
@Override
public CountdownType getType() {
return CountdownType.SPECTATE_OVER;
}
} }

Datei anzeigen

@ -15,4 +15,9 @@ public class FinishTimeOver implements CountdownCallback {
Bukkit.broadcastMessage("§aZeit abgelaufen!"); Bukkit.broadcastMessage("§aZeit abgelaufen!");
FightSystem.getPlugin().setSpectateState(null); FightSystem.getPlugin().setSpectateState(null);
} }
@Override
public CountdownType getType() {
return CountdownType.TIME_OVER;
}
} }

Datei anzeigen

@ -33,18 +33,22 @@ public class Scoreboard {
public void run() { public void run() {
FightTeam fightTeam = getIndexDisplay(index); FightTeam fightTeam = getIndexDisplay(index);
if(fightTeam != null) { if(fightTeam != null) {
objective.unregister();
scoreboard.registerNewObjective("AAA", "BBB");
objective.setDisplaySlot(DisplaySlot.SIDEBAR); objective.setDisplaySlot(DisplaySlot.SIDEBAR);
objective.setDisplayName("§6Info " + fightTeam.getPrefix() + fightTeam.getName()); objective.setDisplayName("§6Info " + fightTeam.getPrefix() + fightTeam.getName());
for(FightPlayer fp : fightTeam.getPlayers()) { for(FightPlayer fp : fightTeam.getPlayers()) {
objective.getScore(fightTeam.getPrefix() + fp.getPlayer().getDisplayName()).setScore(fp.getPlayer().getHealth()); objective.getScore(fightTeam.getPrefix() + fp.getPlayer().getName()).setScore((int) fp.getPlayer().getHealth());
} }
} else { index++;
index = 0;
String gameName = FightSystem.getPlugin().getFileManager().getStringFromConfig("Output.GameName"); } else {
objective.unregister();
scoreboard.registerNewObjective("AAA", "BBB");
objective.setDisplaySlot(DisplaySlot.SIDEBAR); objective.setDisplaySlot(DisplaySlot.SIDEBAR);
objective.setDisplayName("§6Fight Info"); objective.setDisplayName("§6Fight Info");
@ -54,7 +58,7 @@ public class Scoreboard {
if(Methods.isEnabled("WinConditions.PercentSystem")) objective.getScore("§eSchaden BLAU: §c" + FightSystem.getPlugin().getGetDamageBlue() + "%").setScore(3); if(Methods.isEnabled("WinConditions.PercentSystem")) objective.getScore("§eSchaden BLAU: §c" + FightSystem.getPlugin().getGetDamageBlue() + "%").setScore(3);
} }
player.setScoreboard(scoreboard); player.setScoreboard(scoreboard);
index++; index = 0;
} }
}, 0, delay); }, 0, delay);
} }