Not stable version
Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
4dce49209c
Commit
7dc9546c72
@ -230,7 +230,7 @@ public class FightSystem extends JavaPlugin {
|
||||
if(this.fightState != FightState.SETUP)
|
||||
return;
|
||||
this.fightState = FightState.PRE_RUNNING;
|
||||
Countdown.cancelAllTimers(plugin);
|
||||
Countdown.cancelAllTimers();
|
||||
|
||||
int time = fileManager.getIntegerFromConfig("Times.PreFightDuration");
|
||||
Countdown countdown = new Countdown(time, new FinishPreRunning());
|
||||
@ -259,7 +259,7 @@ public class FightSystem extends JavaPlugin {
|
||||
if(this.fightState != FightState.PRE_RUNNING)
|
||||
return;
|
||||
this.fightState = FightState.RUNNING;
|
||||
Countdown.cancelAllTimers(plugin);
|
||||
Countdown.cancelAllTimers();
|
||||
|
||||
setAllPlayersGM(GameMode.SURVIVAL);
|
||||
|
||||
@ -275,7 +275,7 @@ public class FightSystem extends JavaPlugin {
|
||||
if(this.fightState != FightState.RUNNING)
|
||||
return;
|
||||
this.fightState = FightState.SPECTATE;
|
||||
Countdown.cancelAllTimers(plugin);
|
||||
Countdown.cancelAllTimers();
|
||||
|
||||
setAllPlayersGM(GameMode.SPECTATOR);
|
||||
entern = true;
|
||||
@ -305,7 +305,7 @@ public class FightSystem extends JavaPlugin {
|
||||
}
|
||||
|
||||
Countdown cancelAllCountdowns = new Countdown();
|
||||
cancelAllCountdowns.cancelAllTimers(FightSystem.getPlugin());
|
||||
cancelAllCountdowns.cancelAllTimers();
|
||||
Countdown countdown = new Countdown(20*60, new FinishSpectateOver());
|
||||
countdown.startTimer(FightSystem.getPlugin());
|
||||
}
|
||||
|
@ -27,12 +27,12 @@ public class PlayerChatListener implements Listener {
|
||||
String prefixColorCode = fightTeam.getPrefix();
|
||||
String teamName = fightTeam.getName();
|
||||
if(message.startsWith(teamChatDetection)) {
|
||||
fightTeam.broadcast(prefixColorCode + player.getName() + "» " + prefixColorCode + message);
|
||||
fightTeam.broadcast(prefixColorCode + player.getName() + "» " + prefixColorCode + message.substring(1));
|
||||
} else {
|
||||
Bukkit.broadcastMessage(prefixColorCode + teamName + " " + player.getName() + " §8» §7" + message);
|
||||
}
|
||||
}else{
|
||||
Bukkit.broadcastMessage("§7" + player.getName() + " §8» §7" + message.substring(1));
|
||||
Bukkit.broadcastMessage("§7" + player.getName() + " §8» §7" + message);
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
@ -51,7 +51,7 @@ public class PlayerInteractListener implements Listener {
|
||||
player.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.startTimer(instance);
|
||||
break;
|
||||
|
@ -8,6 +8,8 @@ import java.util.ArrayList;
|
||||
|
||||
public class Countdown {
|
||||
|
||||
private static ArrayList<Countdown> countdowns = new ArrayList<>();
|
||||
|
||||
private int time;
|
||||
private CountdownCallback countdownCallback;
|
||||
private int taskID;
|
||||
@ -19,6 +21,7 @@ public class Countdown {
|
||||
public Countdown(int time, CountdownCallback countdownCallback) {
|
||||
this.time = time;
|
||||
this.countdownCallback = countdownCallback;
|
||||
countdowns.add(this);
|
||||
|
||||
if(countdownCallback == new FinishTimeOver()) FightSystem.getPlugin().fightTime = time;
|
||||
}
|
||||
@ -49,11 +52,24 @@ public class Countdown {
|
||||
}, 0, 20);
|
||||
}
|
||||
|
||||
public void cancelTimer(int taskID) {
|
||||
Bukkit.getScheduler().cancelTask(taskID);
|
||||
public void cancelTimer() {
|
||||
Bukkit.getScheduler().cancelTask(this.taskID);
|
||||
countdowns.remove(this);
|
||||
}
|
||||
|
||||
public static void cancelAllTimers(FightSystem plugin) {
|
||||
Bukkit.getScheduler().cancelTasks(plugin);
|
||||
public static void cancelAllTimers() {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ public interface CountdownCallback {
|
||||
|
||||
String countdownCounting();
|
||||
void countdownFinished();
|
||||
CountdownType getType();
|
||||
|
||||
|
||||
}
|
||||
|
13
src/me/yaruma/fightsystem/utils/countdown/CountdownType.java
Normale Datei
13
src/me/yaruma/fightsystem/utils/countdown/CountdownType.java
Normale Datei
@ -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;
|
||||
|
||||
|
||||
}
|
@ -14,4 +14,9 @@ public class FinishNoPlayersOnline implements CountdownCallback {
|
||||
Bukkit.broadcastMessage("§aStoppe Server...");
|
||||
Bukkit.getServer().shutdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CountdownType getType() {
|
||||
return CountdownType.NO_PLAYERS_ONLINE;
|
||||
}
|
||||
}
|
||||
|
@ -15,4 +15,9 @@ public class FinishNoneEntern implements CountdownCallback {
|
||||
FightSystem.getPlugin().entern = true;
|
||||
Bukkit.broadcastMessage("§aEntern ist nun erlaubt!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CountdownType getType() {
|
||||
return CountdownType.NO_ENTERN;
|
||||
}
|
||||
}
|
||||
|
@ -17,4 +17,9 @@ public class FinishPreRunning implements CountdownCallback {
|
||||
public void countdownFinished() {
|
||||
FightSystem.getPlugin().setRunningState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CountdownType getType() {
|
||||
return CountdownType.PRE_RUNNING;
|
||||
}
|
||||
}
|
||||
|
@ -14,4 +14,9 @@ public class FinishSetupOver implements CountdownCallback {
|
||||
Bukkit.broadcastMessage("Fight wird abgebrochen! \n Stoppe Server...");
|
||||
Bukkit.getServer().shutdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CountdownType getType() {
|
||||
return CountdownType.SETUP_OVER;
|
||||
}
|
||||
}
|
||||
|
@ -14,4 +14,9 @@ public class FinishSpectateOver implements CountdownCallback {
|
||||
Bukkit.broadcastMessage("§aStoppe Server...");
|
||||
Bukkit.getServer().shutdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CountdownType getType() {
|
||||
return CountdownType.SPECTATE_OVER;
|
||||
}
|
||||
}
|
||||
|
@ -15,4 +15,9 @@ public class FinishTimeOver implements CountdownCallback {
|
||||
Bukkit.broadcastMessage("§aZeit abgelaufen!");
|
||||
FightSystem.getPlugin().setSpectateState(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CountdownType getType() {
|
||||
return CountdownType.TIME_OVER;
|
||||
}
|
||||
}
|
||||
|
@ -33,18 +33,22 @@ public class Scoreboard {
|
||||
public void run() {
|
||||
FightTeam fightTeam = getIndexDisplay(index);
|
||||
if(fightTeam != null) {
|
||||
objective.unregister();
|
||||
scoreboard.registerNewObjective("AAA", "BBB");
|
||||
|
||||
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
objective.setDisplayName("§6Info " + fightTeam.getPrefix() + fightTeam.getName());
|
||||
|
||||
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 = 0;
|
||||
index++;
|
||||
|
||||
String gameName = FightSystem.getPlugin().getFileManager().getStringFromConfig("Output.GameName");
|
||||
} else {
|
||||
|
||||
objective.unregister();
|
||||
scoreboard.registerNewObjective("AAA", "BBB");
|
||||
|
||||
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
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);
|
||||
}
|
||||
player.setScoreboard(scoreboard);
|
||||
index++;
|
||||
index = 0;
|
||||
}
|
||||
}, 0, delay);
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren