Added Scoreboard
Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
c3d48cce73
Commit
abd1ea3616
@ -9,6 +9,7 @@ import me.yaruma.fightsystem.manager.FileManager;
|
|||||||
import me.yaruma.fightsystem.utils.countdown.Countdown;
|
import me.yaruma.fightsystem.utils.countdown.Countdown;
|
||||||
import me.yaruma.fightsystem.utils.countdown.FinishSetupOver;
|
import me.yaruma.fightsystem.utils.countdown.FinishSetupOver;
|
||||||
import me.yaruma.fightsystem.utils.countdown.FinishSpectateOver;
|
import me.yaruma.fightsystem.utils.countdown.FinishSpectateOver;
|
||||||
|
import me.yaruma.fightsystem.utils.scoreboard.Scoreboard;
|
||||||
import me.yaruma.fightsystem.winconditions.WinconditionAllDead;
|
import me.yaruma.fightsystem.winconditions.WinconditionAllDead;
|
||||||
import me.yaruma.fightsystem.winconditions.WinconditionCaptainDead;
|
import me.yaruma.fightsystem.winconditions.WinconditionCaptainDead;
|
||||||
import me.yaruma.fightsystem.winconditions.WinconditionPercentSystem;
|
import me.yaruma.fightsystem.winconditions.WinconditionPercentSystem;
|
||||||
@ -28,6 +29,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
private static FightSystem plugin;
|
private static FightSystem plugin;
|
||||||
private FileManager fileManager;
|
private FileManager fileManager;
|
||||||
private FightManager fightManager;
|
private FightManager fightManager;
|
||||||
|
private Scoreboard scoreboard;
|
||||||
|
|
||||||
private FightState fightState;
|
private FightState fightState;
|
||||||
|
|
||||||
@ -56,6 +58,11 @@ public class FightSystem extends JavaPlugin {
|
|||||||
public int team2cornerZ;
|
public int team2cornerZ;
|
||||||
|
|
||||||
|
|
||||||
|
public int fightTime = 0;
|
||||||
|
public double damageRed = 0D;
|
||||||
|
public double getDamageBlue = 0D;
|
||||||
|
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
||||||
plugin = this;
|
plugin = this;
|
||||||
@ -197,6 +204,10 @@ public class FightSystem extends JavaPlugin {
|
|||||||
return fightState;
|
return fightState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Scoreboard getScoreboard() {
|
||||||
|
return scoreboard;
|
||||||
|
}
|
||||||
|
|
||||||
public void setSetupState() {
|
public void setSetupState() {
|
||||||
if(this.fightState == null) {
|
if(this.fightState == null) {
|
||||||
this.fightState = FightState.SETUP;
|
this.fightState = FightState.SETUP;
|
||||||
@ -332,4 +343,15 @@ public class FightSystem extends JavaPlugin {
|
|||||||
return team2cornerZ;
|
return team2cornerZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getFightTime() {
|
||||||
|
return fightTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getDamageRed() {
|
||||||
|
return damageRed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getGetDamageBlue() {
|
||||||
|
return getDamageBlue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,8 @@ public class PlayerJoinListener implements Listener {
|
|||||||
player.teleport(FightSystem.getPlugin().getTeam1SpawnLoc());
|
player.teleport(FightSystem.getPlugin().getTeam1SpawnLoc());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FightSystem.getPlugin().getScoreboard().setAutoScoreboard(20*10, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@ 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;
|
||||||
|
|
||||||
|
if(countdownCallback == new FinishTimeOver()) FightSystem.getPlugin().fightTime = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
91
src/me/yaruma/fightsystem/utils/scoreboard/Scoreboard.java
Normale Datei
91
src/me/yaruma/fightsystem/utils/scoreboard/Scoreboard.java
Normale Datei
@ -0,0 +1,91 @@
|
|||||||
|
package me.yaruma.fightsystem.utils.scoreboard;
|
||||||
|
|
||||||
|
import me.yaruma.fightsystem.FightSystem;
|
||||||
|
import me.yaruma.fightsystem.fight.Fight;
|
||||||
|
import me.yaruma.fightsystem.fight.FightTeam;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scoreboard.DisplaySlot;
|
||||||
|
import org.bukkit.scoreboard.Objective;
|
||||||
|
import org.bukkit.scoreboard.ScoreboardManager;
|
||||||
|
|
||||||
|
public class Scoreboard {
|
||||||
|
|
||||||
|
private ScoreboardManager scoreboardManager;
|
||||||
|
private org.bukkit.scoreboard.Scoreboard scoreboard;
|
||||||
|
private Objective objective;
|
||||||
|
private int taskID;
|
||||||
|
|
||||||
|
public Scoreboard(FightSystem instance) {
|
||||||
|
this.scoreboardManager = Bukkit.getScoreboardManager();
|
||||||
|
this.scoreboard = this.scoreboardManager.getNewScoreboard();
|
||||||
|
this.objective = scoreboard.registerNewObjective("AAA", "BBB");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAutoScoreboard(int delay, Player player) {
|
||||||
|
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(FightSystem.getPlugin(), new Runnable() {
|
||||||
|
|
||||||
|
private int index;
|
||||||
|
|
||||||
|
private String PREFIX;
|
||||||
|
private String NAME;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if(getIndexDisplay(index) != null) {
|
||||||
|
|
||||||
|
if(getIndexDisplay(index) == Fight.redTeam) {
|
||||||
|
this.PREFIX = FightSystem.getPlugin().getFileManager().getStringFromConfig("Output.TeamRedColor");
|
||||||
|
this.NAME = FightSystem.getPlugin().getFileManager().getStringFromConfig("Output.TeamRedName");
|
||||||
|
}
|
||||||
|
if(getIndexDisplay(index) == Fight.redTeam) {
|
||||||
|
this.PREFIX = FightSystem.getPlugin().getFileManager().getStringFromConfig("Output.TeamRedColor");
|
||||||
|
this.NAME = FightSystem.getPlugin().getFileManager().getStringFromConfig("Output.TeamRedName");
|
||||||
|
}
|
||||||
|
|
||||||
|
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
|
objective.setDisplayName("§6Info " + PREFIX + NAME);
|
||||||
|
|
||||||
|
for(int i = 0; i < getIndexDisplay(index).getPlayers().size(); i++) {
|
||||||
|
objective.getScore(PREFIX + getIndexDisplay(index).getPlayers().get(i).getPlayer().getDisplayName() + " §8: " + "§6" + getIndexDisplay(index).getPlayers().get(i).getPlayer().getHealth()).setScore(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
index = 0;
|
||||||
|
|
||||||
|
String gameName = FightSystem.getPlugin().getFileManager().getStringFromConfig("Output.GameName");
|
||||||
|
|
||||||
|
objective.setDisplayName("§6Fight Info");
|
||||||
|
if(gameName == "AirWargear" || gameName == "WarShip") {
|
||||||
|
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
|
objective.getScore("§7Zeit: §a" + FightSystem.getPlugin().getFightTime()).setScore(0);
|
||||||
|
objective.getScore("§7Entern: " + (FightSystem.getPlugin().getFileManager().getBooleanFromConfig("Fight.Entern") ? "§aja" : "§cnein")).setScore(1);
|
||||||
|
objective.getScore("§7Spieltyp: §e" + gameName).setScore(2);
|
||||||
|
objective.getScore("§eSchaden ROT: " + FightSystem.getPlugin().getDamageRed()).setScore(3);
|
||||||
|
objective.getScore("§eSchaden BLAU: " + FightSystem.getPlugin().getGetDamageBlue()).setScore(4);
|
||||||
|
} else {
|
||||||
|
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
|
objective.getScore("§7Zeit: §a" + FightSystem.getPlugin().getFightTime()).setScore(0);
|
||||||
|
objective.getScore("§7Spieltyp: §e" + gameName).setScore(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
player.setScoreboard(scoreboard);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}, 0, delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
private FightTeam getIndexDisplay(int index) {
|
||||||
|
if(index == 0) {
|
||||||
|
return Fight.redTeam;
|
||||||
|
}
|
||||||
|
if(index == 1) {
|
||||||
|
return Fight.blueTeam;
|
||||||
|
}
|
||||||
|
if(index == 2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren