SteamWar/BauSystem
Archiviert
13
0

Merge branch 'scoreboard' of SteamWar/BauSystem into master

Dieser Commit ist enthalten in:
Lixfel 2020-01-12 16:42:09 +01:00 committet von Gitea
Commit 2a212e30f5
4 geänderte Dateien mit 68 neuen und 8 gelöschten Zeilen

1
.gitignore vendored
Datei anzeigen

@ -1,3 +1,4 @@
.idea
target
dependency-reduced-pom.xml
*.iml

Datei anzeigen

@ -2,9 +2,11 @@ package de.steamwar.bausystem;
import de.steamwar.bausystem.commands.*;
import de.steamwar.bausystem.world.ArenaSection;
import de.steamwar.bausystem.world.BauScoreboard;
import de.steamwar.bausystem.world.RegionListener;
import de.steamwar.bausystem.world.TNTListener;
import de.steamwar.core.CommandRemover;
import de.steamwar.scoreboard.SWScoreboard;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException;
@ -84,6 +86,7 @@ public class BauSystem extends JavaPlugin implements Listener {
Bukkit.getPluginManager().registerEvents(this, this);
Bukkit.getPluginManager().registerEvents(new RegionListener(), this);
Bukkit.getPluginManager().registerEvents(new TNTListener(), this);
Bukkit.getPluginManager().registerEvents(new BauScoreboard(), this);
}
public static BauSystem getPlugin(){
@ -241,6 +244,7 @@ public class BauSystem extends JavaPlugin implements Listener {
@EventHandler
public void onLeave(PlayerQuitEvent e) {
SWScoreboard.removeScoreboard(e.getPlayer());
if(Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(e.getPlayer())))
Bukkit.shutdown();
}

Datei anzeigen

@ -31,7 +31,17 @@ public class CommandInfo implements CommandExecutor {
}
sender.sendMessage(membermessage.toString());
StringBuilder tpsmessage = new StringBuilder().append(BauSystem.PREFIX).append("TPS:§e");
for(float tps : getTps()){
tpsmessage.append(" " + tps);
}
sender.sendMessage(tpsmessage.toString());
return false;
}
public static float[] getTps() {
double[] tps;
switch (Core.getVersion()) {
case 15:
tps = CommandInfo_15.getTps();
@ -39,11 +49,11 @@ public class CommandInfo implements CommandExecutor {
default:
tps = CommandInfo_12.getTps();
}
StringBuilder tpsmessage = new StringBuilder().append(BauSystem.PREFIX).append("TPS:§e");
for(double t : tps){
tpsmessage.append(String.format(" %.1f", t));
float[] roundedTps = new float[3];
for(int i = 0; i < tps.length; i++) {
roundedTps[i] = Math.round(tps[0]);
}
sender.sendMessage(tpsmessage.toString());
return false;
return roundedTps;
}
}

Datei anzeigen

@ -0,0 +1,45 @@
package de.steamwar.bausystem.world;
import de.steamwar.bausystem.commands.CommandFreeze;
import de.steamwar.bausystem.commands.CommandInfo;
import de.steamwar.bausystem.commands.CommandTNT;
import de.steamwar.scoreboard.SWScoreboard;
import de.steamwar.scoreboard.ScoreboardCallback;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
public class BauScoreboard implements Listener {
@EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
SWScoreboard.createScoreboard(player, new ScoreboardCallback() {
@Override
public HashMap<String, Integer> getData() {
HashMap<String, Integer> data = new HashMap<>();
data.put("§1 ", 7);
data.put("§eUhrzeit§8: §7" + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()), 6);
data.put("§2 ", 5);
data.put("§eTNT§8: " + (!CommandTNT.getInstance().isOn() ? "§aan" : "§caus"), 4);
data.put("§eFreeze§8: " + (!CommandFreeze.getInstance().isOn() ? "§aan" : "§caus"), 3);
data.put("§3 ", 2);
data.put("§eTPS§8: §7" + CommandInfo.getTps()[0], 1);
return data;
}
@Override
public String getTitle() {
return "§eSteam§8War";
}
});
}
}