added scoreboard; tested; added *.iml
Dieser Commit ist enthalten in:
Ursprung
6e7c05b4f0
Commit
6883b7efc2
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
.idea
|
||||
target
|
||||
dependency-reduced-pom.xml
|
||||
dependency-reduced-pom.xml
|
||||
*.iml
|
54
SpigotCore_10/src/de/steamwar/scoreboard/SWScoreboard_10.java
Normale Datei
54
SpigotCore_10/src/de/steamwar/scoreboard/SWScoreboard_10.java
Normale Datei
@ -0,0 +1,54 @@
|
||||
package de.steamwar.scoreboard;
|
||||
|
||||
import net.minecraft.server.v1_10_R1.*;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class SWScoreboard_10 {
|
||||
|
||||
ScoreboardCallback callback;
|
||||
private Scoreboard scoreboard;
|
||||
private ScoreboardObjective obj;
|
||||
private int switcher = 0; //switch zwischen 0 und 1
|
||||
|
||||
public SWScoreboard_10(ScoreboardCallback callback) {
|
||||
this.callback = callback;
|
||||
this.scoreboard = new Scoreboard();
|
||||
this.obj = this.scoreboard.registerObjective("MainBord" + switcher, IScoreboardCriteria.b);
|
||||
obj.setDisplayName(this.callback.getTitle());
|
||||
}
|
||||
|
||||
public void sendScoreboard(Player player) {
|
||||
PacketPlayOutScoreboardObjective removePacket = new PacketPlayOutScoreboardObjective(obj, 1);
|
||||
PacketPlayOutScoreboardObjective createpacket = new PacketPlayOutScoreboardObjective(obj, 0);
|
||||
|
||||
sendPacket(player, removePacket);
|
||||
sendPacket(player, createpacket);
|
||||
|
||||
for(Map.Entry<String, Integer> currentEntry : this.callback.getData().entrySet()) {
|
||||
ScoreboardScore score = new ScoreboardScore(this.scoreboard, this.obj, currentEntry.getKey());
|
||||
score.setScore(currentEntry.getValue());
|
||||
PacketPlayOutScoreboardScore scorePacket = new PacketPlayOutScoreboardScore(score);
|
||||
sendPacket(player, scorePacket);
|
||||
}
|
||||
|
||||
switcher();
|
||||
|
||||
PacketPlayOutScoreboardDisplayObjective displayPacket = new PacketPlayOutScoreboardDisplayObjective(1, this.obj);
|
||||
sendPacket(player, displayPacket);
|
||||
}
|
||||
|
||||
private void sendPacket(Player p, Packet<?> packet) {
|
||||
((CraftPlayer)p).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
private void switcher() {
|
||||
switcher++;
|
||||
if(switcher == 1)
|
||||
switcher = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
53
SpigotCore_12/src/de/steamwar/scoreboard/SWScoreboard_12.java
Normale Datei
53
SpigotCore_12/src/de/steamwar/scoreboard/SWScoreboard_12.java
Normale Datei
@ -0,0 +1,53 @@
|
||||
package de.steamwar.scoreboard;
|
||||
|
||||
import net.minecraft.server.v1_12_R1.*;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class SWScoreboard_12 {
|
||||
|
||||
ScoreboardCallback callback;
|
||||
private Scoreboard scoreboard;
|
||||
private ScoreboardObjective obj;
|
||||
private int switcher = 0; //switch zwischen 0 und 1
|
||||
|
||||
public SWScoreboard_12(ScoreboardCallback callback) {
|
||||
this.callback = callback;
|
||||
this.scoreboard = new Scoreboard();
|
||||
this.obj = this.scoreboard.registerObjective("MainBord" + switcher, IScoreboardCriteria.b);
|
||||
obj.setDisplayName(this.callback.getTitle());
|
||||
}
|
||||
|
||||
public void sendScoreboard(Player player) {
|
||||
PacketPlayOutScoreboardObjective removePacket = new PacketPlayOutScoreboardObjective(obj, 1);
|
||||
PacketPlayOutScoreboardObjective createpacket = new PacketPlayOutScoreboardObjective(obj, 0);
|
||||
|
||||
sendPacket(player, removePacket);
|
||||
sendPacket(player, createpacket);
|
||||
|
||||
for(Map.Entry<String, Integer> currentEntry : this.callback.getData().entrySet()) {
|
||||
ScoreboardScore score = new ScoreboardScore(this.scoreboard, this.obj, currentEntry.getKey());
|
||||
score.setScore(currentEntry.getValue());
|
||||
PacketPlayOutScoreboardScore scorePacket = new PacketPlayOutScoreboardScore(score);
|
||||
sendPacket(player, scorePacket);
|
||||
}
|
||||
|
||||
switcher();
|
||||
|
||||
PacketPlayOutScoreboardDisplayObjective displayPacket = new PacketPlayOutScoreboardDisplayObjective(1, this.obj);
|
||||
sendPacket(player, displayPacket);
|
||||
}
|
||||
|
||||
private void sendPacket(Player p, Packet<?> packet) {
|
||||
((CraftPlayer)p).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
private void switcher() {
|
||||
switcher++;
|
||||
if(switcher == 1)
|
||||
switcher = 0;
|
||||
}
|
||||
|
||||
}
|
53
SpigotCore_14/src/de/steamwar/scoreboard/SWScoreboard_14.java
Normale Datei
53
SpigotCore_14/src/de/steamwar/scoreboard/SWScoreboard_14.java
Normale Datei
@ -0,0 +1,53 @@
|
||||
package de.steamwar.scoreboard;
|
||||
|
||||
import net.minecraft.server.v1_14_R1.*;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class SWScoreboard_14 {
|
||||
|
||||
ScoreboardCallback callback;
|
||||
private Scoreboard scoreboard;
|
||||
private ScoreboardObjective obj;
|
||||
private int switcher = 0; //switch zwischen 0 und 1
|
||||
|
||||
public SWScoreboard_14(ScoreboardCallback callback) {
|
||||
this.callback = callback;
|
||||
this.scoreboard = new Scoreboard();
|
||||
this.obj = this.scoreboard.registerObjective("MainBord" + switcher, IScoreboardCriteria.DUMMY, new ChatMessage("USELESS"), IScoreboardCriteria.EnumScoreboardHealthDisplay.HEARTS);
|
||||
obj.setDisplayName(new ChatMessage(this.callback.getTitle()));
|
||||
}
|
||||
|
||||
public void sendScoreboard(Player player) {
|
||||
PacketPlayOutScoreboardObjective removePacket = new PacketPlayOutScoreboardObjective(obj, 1);
|
||||
PacketPlayOutScoreboardObjective createpacket = new PacketPlayOutScoreboardObjective(obj, 0);
|
||||
|
||||
sendPacket(player, removePacket);
|
||||
sendPacket(player, createpacket);
|
||||
|
||||
for(Map.Entry<String, Integer> currentEntry : this.callback.getData().entrySet()) {
|
||||
ScoreboardScore score = new ScoreboardScore(this.scoreboard, this.obj, currentEntry.getKey());
|
||||
score.setScore(currentEntry.getValue());
|
||||
PacketPlayOutScoreboardScore scorePacket = new PacketPlayOutScoreboardScore(ScoreboardServer.Action.CHANGE, this.obj.getName(), score.getPlayerName(), score.getScore());
|
||||
sendPacket(player, scorePacket);
|
||||
}
|
||||
|
||||
switcher();
|
||||
|
||||
PacketPlayOutScoreboardDisplayObjective displayPacket = new PacketPlayOutScoreboardDisplayObjective(1, this.obj);
|
||||
sendPacket(player, displayPacket);
|
||||
}
|
||||
|
||||
private void sendPacket(Player p, Packet<?> packet) {
|
||||
((CraftPlayer)p).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
private void switcher() {
|
||||
switcher++;
|
||||
if(switcher == 1)
|
||||
switcher = 0;
|
||||
}
|
||||
|
||||
}
|
53
SpigotCore_15/src/de/steamwar/scoreboard/SWScoreboard_15.java
Normale Datei
53
SpigotCore_15/src/de/steamwar/scoreboard/SWScoreboard_15.java
Normale Datei
@ -0,0 +1,53 @@
|
||||
package de.steamwar.scoreboard;
|
||||
|
||||
import net.minecraft.server.v1_15_R1.*;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class SWScoreboard_15 {
|
||||
|
||||
ScoreboardCallback callback;
|
||||
private Scoreboard scoreboard;
|
||||
private ScoreboardObjective obj;
|
||||
private int switcher = 0; //switch zwischen 0 und 1
|
||||
|
||||
public SWScoreboard_15(ScoreboardCallback callback) {
|
||||
this.callback = callback;
|
||||
this.scoreboard = new Scoreboard();
|
||||
this.obj = this.scoreboard.registerObjective("MainBord" + switcher, IScoreboardCriteria.DUMMY, new ChatMessage("USELESS"), IScoreboardCriteria.EnumScoreboardHealthDisplay.HEARTS);
|
||||
obj.setDisplayName(new ChatMessage(this.callback.getTitle()));
|
||||
}
|
||||
|
||||
public void sendScoreboard(Player player) {
|
||||
PacketPlayOutScoreboardObjective removePacket = new PacketPlayOutScoreboardObjective(obj, 1);
|
||||
PacketPlayOutScoreboardObjective createpacket = new PacketPlayOutScoreboardObjective(obj, 0);
|
||||
|
||||
sendPacket(player, removePacket);
|
||||
sendPacket(player, createpacket);
|
||||
|
||||
for(Map.Entry<String, Integer> currentEntry : this.callback.getData().entrySet()) {
|
||||
ScoreboardScore score = new ScoreboardScore(this.scoreboard, this.obj, currentEntry.getKey());
|
||||
score.setScore(currentEntry.getValue());
|
||||
PacketPlayOutScoreboardScore scorePacket = new PacketPlayOutScoreboardScore(ScoreboardServer.Action.CHANGE, this.obj.getName(), score.getPlayerName(), score.getScore());
|
||||
sendPacket(player, scorePacket);
|
||||
}
|
||||
|
||||
switcher();
|
||||
|
||||
PacketPlayOutScoreboardDisplayObjective displayPacket = new PacketPlayOutScoreboardDisplayObjective(1, this.obj);
|
||||
sendPacket(player, displayPacket);
|
||||
}
|
||||
|
||||
private void sendPacket(Player p, Packet<?> packet) {
|
||||
((CraftPlayer)p).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
private void switcher() {
|
||||
switcher++;
|
||||
if(switcher == 1)
|
||||
switcher = 0;
|
||||
}
|
||||
|
||||
}
|
53
SpigotCore_8/src/de/steamwar/scoreboard/SWScoreboard_8.java
Normale Datei
53
SpigotCore_8/src/de/steamwar/scoreboard/SWScoreboard_8.java
Normale Datei
@ -0,0 +1,53 @@
|
||||
package de.steamwar.scoreboard;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.*;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class SWScoreboard_8 {
|
||||
|
||||
ScoreboardCallback callback;
|
||||
private Scoreboard scoreboard;
|
||||
private ScoreboardObjective obj;
|
||||
private int switcher = 0; //switch zwischen 0 und 1
|
||||
|
||||
public SWScoreboard_8(ScoreboardCallback callback) {
|
||||
this.callback = callback;
|
||||
this.scoreboard = new Scoreboard();
|
||||
this.obj = this.scoreboard.registerObjective("MainBord" + switcher, IScoreboardCriteria.b);
|
||||
obj.setDisplayName(this.callback.getTitle());
|
||||
}
|
||||
|
||||
public void sendScoreboard(Player player) {
|
||||
PacketPlayOutScoreboardObjective removePacket = new PacketPlayOutScoreboardObjective(obj, 1);
|
||||
PacketPlayOutScoreboardObjective createpacket = new PacketPlayOutScoreboardObjective(obj, 0);
|
||||
|
||||
sendPacket(player, removePacket);
|
||||
sendPacket(player, createpacket);
|
||||
|
||||
for(Map.Entry<String, Integer> currentEntry : this.callback.getData().entrySet()) {
|
||||
ScoreboardScore score = new ScoreboardScore(this.scoreboard, this.obj, currentEntry.getKey());
|
||||
score.setScore(currentEntry.getValue());
|
||||
PacketPlayOutScoreboardScore scorePacket = new PacketPlayOutScoreboardScore(score);
|
||||
sendPacket(player, scorePacket);
|
||||
}
|
||||
|
||||
switcher();
|
||||
|
||||
PacketPlayOutScoreboardDisplayObjective displayPacket = new PacketPlayOutScoreboardDisplayObjective(1, this.obj);
|
||||
sendPacket(player, displayPacket);
|
||||
}
|
||||
|
||||
private void sendPacket(Player p, Packet<?> packet) {
|
||||
((CraftPlayer)p).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
private void switcher() {
|
||||
switcher++;
|
||||
if(switcher == 1)
|
||||
switcher = 0;
|
||||
}
|
||||
|
||||
}
|
53
SpigotCore_9/src/de/steamwar/scoreboard/SWScoreboard_9.java
Normale Datei
53
SpigotCore_9/src/de/steamwar/scoreboard/SWScoreboard_9.java
Normale Datei
@ -0,0 +1,53 @@
|
||||
package de.steamwar.scoreboard;
|
||||
|
||||
import net.minecraft.server.v1_9_R2.*;
|
||||
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class SWScoreboard_9 {
|
||||
|
||||
ScoreboardCallback callback;
|
||||
private Scoreboard scoreboard;
|
||||
private ScoreboardObjective obj;
|
||||
private int switcher = 0; //switch zwischen 0 und 1
|
||||
|
||||
public SWScoreboard_9(ScoreboardCallback callback) {
|
||||
this.callback = callback;
|
||||
this.scoreboard = new Scoreboard();
|
||||
this.obj = this.scoreboard.registerObjective("MainBord" + switcher, IScoreboardCriteria.b);
|
||||
obj.setDisplayName(this.callback.getTitle());
|
||||
}
|
||||
|
||||
public void sendScoreboard(Player player) {
|
||||
PacketPlayOutScoreboardObjective removePacket = new PacketPlayOutScoreboardObjective(obj, 1);
|
||||
PacketPlayOutScoreboardObjective createpacket = new PacketPlayOutScoreboardObjective(obj, 0);
|
||||
|
||||
sendPacket(player, removePacket);
|
||||
sendPacket(player, createpacket);
|
||||
|
||||
for(Map.Entry<String, Integer> currentEntry : this.callback.getData().entrySet()) {
|
||||
ScoreboardScore score = new ScoreboardScore(this.scoreboard, this.obj, currentEntry.getKey());
|
||||
score.setScore(currentEntry.getValue());
|
||||
PacketPlayOutScoreboardScore scorePacket = new PacketPlayOutScoreboardScore(score);
|
||||
sendPacket(player, scorePacket);
|
||||
}
|
||||
|
||||
switcher();
|
||||
|
||||
PacketPlayOutScoreboardDisplayObjective displayPacket = new PacketPlayOutScoreboardDisplayObjective(1, this.obj);
|
||||
sendPacket(player, displayPacket);
|
||||
}
|
||||
|
||||
private void sendPacket(Player p, Packet<?> packet) {
|
||||
((CraftPlayer)p).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
private void switcher() {
|
||||
switcher++;
|
||||
if(switcher == 1)
|
||||
switcher = 0;
|
||||
}
|
||||
|
||||
}
|
12
SpigotCore_API/src/de/steamwar/scoreboard/ScoreboardCallback.java
Normale Datei
12
SpigotCore_API/src/de/steamwar/scoreboard/ScoreboardCallback.java
Normale Datei
@ -0,0 +1,12 @@
|
||||
package de.steamwar.scoreboard;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public interface ScoreboardCallback {
|
||||
|
||||
HashMap<String, Integer> getData();
|
||||
|
||||
String getTitle();
|
||||
|
||||
|
||||
}
|
77
SpigotCore_Main/src/de/steamwar/scoreboard/SWScoreboard.java
Normale Datei
77
SpigotCore_Main/src/de/steamwar/scoreboard/SWScoreboard.java
Normale Datei
@ -0,0 +1,77 @@
|
||||
package de.steamwar.scoreboard;
|
||||
|
||||
import de.steamwar.core.Core;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SWScoreboard {
|
||||
|
||||
private static HashMap<Player, Object> playerBoards = new HashMap<>(); //Object -> Scoreboard | Alle Versionen in der Map!
|
||||
|
||||
public static boolean createScoreboard(Player player, ScoreboardCallback callback) {
|
||||
Object swScoreboardObject;
|
||||
switch (Core.getVersion()) {
|
||||
case 8:
|
||||
swScoreboardObject = new SWScoreboard_8(callback);
|
||||
break;
|
||||
case 9:
|
||||
swScoreboardObject = new SWScoreboard_9(callback);
|
||||
break;
|
||||
case 10:
|
||||
swScoreboardObject = new SWScoreboard_10(callback);
|
||||
break;
|
||||
case 12:
|
||||
swScoreboardObject = new SWScoreboard_12(callback);
|
||||
break;
|
||||
case 14:
|
||||
swScoreboardObject = new SWScoreboard_14(callback);
|
||||
break;
|
||||
case 15:
|
||||
swScoreboardObject = new SWScoreboard_15(callback);
|
||||
break;
|
||||
default:
|
||||
return false; //Kein Scoreboard senden
|
||||
}
|
||||
playerBoards.put(player, swScoreboardObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void removeScoreboard(Player player) {
|
||||
if(playerBoards.containsKey(player))
|
||||
playerBoards.remove(player);
|
||||
}
|
||||
|
||||
//Scoreboard Updater
|
||||
static {
|
||||
Bukkit.getScheduler().scheduleAsyncRepeatingTask(Core.getInstance(), () -> {
|
||||
synchronized (playerBoards) {
|
||||
for(Map.Entry<Player, Object> entry : playerBoards.entrySet()) {
|
||||
switch (Core.getVersion()) {
|
||||
case 8:
|
||||
((SWScoreboard_8) entry.getValue()).sendScoreboard(entry.getKey());
|
||||
break;
|
||||
case 9:
|
||||
((SWScoreboard_9) entry.getValue()).sendScoreboard(entry.getKey());
|
||||
break;
|
||||
case 10:
|
||||
((SWScoreboard_10) entry.getValue()).sendScoreboard(entry.getKey());
|
||||
break;
|
||||
case 12:
|
||||
((SWScoreboard_12) entry.getValue()).sendScoreboard(entry.getKey());
|
||||
break;
|
||||
case 14:
|
||||
((SWScoreboard_14) entry.getValue()).sendScoreboard(entry.getKey());
|
||||
break;
|
||||
case 15:
|
||||
((SWScoreboard_15) entry.getValue()).sendScoreboard(entry.getKey());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 10, 5);
|
||||
}
|
||||
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren