added scoreboard without complete multiversion support
Dieser Commit ist enthalten in:
Ursprung
ca5d074219
Commit
9418df66fe
15
SpigotCore_12/SpigotCore_12.iml
Normale Datei
15
SpigotCore_12/SpigotCore_12.iml
Normale Datei
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: steamwar:Spigot:1.12" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: steamwar:ProtocolLib:1.0" level="project" />
|
||||
</component>
|
||||
</module>
|
15
SpigotCore_14/SpigotCore_14.iml
Normale Datei
15
SpigotCore_14/SpigotCore_14.iml
Normale Datei
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: steamwar:Spigot:1.14" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: steamwar:ProtocolLib:1.0" level="project" />
|
||||
</component>
|
||||
</module>
|
15
SpigotCore_8/SpigotCore_8.iml
Normale Datei
15
SpigotCore_8/SpigotCore_8.iml
Normale Datei
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: steamwar:Spigot:1.8" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: steamwar:ProtocolLib:1.0" level="project" />
|
||||
</component>
|
||||
</module>
|
18
SpigotCore_Main/SpigotCore_Main.iml
Normale Datei
18
SpigotCore_Main/SpigotCore_Main.iml
Normale Datei
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: steamwar:Spigot:1.12" level="project" />
|
||||
<orderEntry type="module" module-name="SpigotCore_8" />
|
||||
<orderEntry type="module" module-name="SpigotCore_12" />
|
||||
<orderEntry type="module" module-name="SpigotCore_14" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: steamwar:ProtocolLib:1.0" level="project" />
|
||||
</component>
|
||||
</module>
|
89
SpigotCore_Main/src/de/steamwar/scoreboard/SWScoreboard.java
Normale Datei
89
SpigotCore_Main/src/de/steamwar/scoreboard/SWScoreboard.java
Normale Datei
@ -0,0 +1,89 @@
|
||||
package de.steamwar.scoreboard;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class SWScoreboard {
|
||||
|
||||
HashMap<String, Integer> data;
|
||||
private Player player;
|
||||
private String title;
|
||||
|
||||
public SWScoreboard(Player player, HashMap<String, Integer> data, String title) {
|
||||
this.data = data;
|
||||
this.player = player;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public void sendScoreboard() {
|
||||
PacketContainer remove = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SCOREBOARD_OBJECTIVE);
|
||||
remove.getStrings().write(0, "AAA");
|
||||
remove.getBytes().write(0, (byte) 1);
|
||||
|
||||
PacketContainer createpacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SCOREBOARD_OBJECTIVE);
|
||||
createpacket.getStrings().write(0, "AAA");
|
||||
createpacket.getBytes().write(0, (byte) 0);
|
||||
createpacket.getStrings().write(1, this.title);
|
||||
createpacket.getIntegers().write(0, 0);
|
||||
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, remove);
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, createpacket);
|
||||
} catch (InvocationTargetException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "COULD NOT SEND PACKAGE", ex);
|
||||
}
|
||||
|
||||
for(Map.Entry<String, Integer> entry : data.entrySet()) {
|
||||
PacketContainer update = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SCOREBOARD_SCORE);
|
||||
update.getStrings().write(0, entry.getKey());
|
||||
update.getBytes().write(0, (byte) 0);
|
||||
update.getStrings().write(1, "AAA");
|
||||
update.getIntegers().write(0, entry.getValue());
|
||||
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, update);
|
||||
} catch (InvocationTargetException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "COULD NOT SEND PACKAGE", ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void display() {
|
||||
PacketContainer display = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SCOREBOARD_DISPLAY_OBJECTIVE);
|
||||
display.getBytes().write(0, (byte) 1);
|
||||
display.getStrings().write(0, this.title);
|
||||
}
|
||||
|
||||
public HashMap<String, Integer> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(HashMap<String, Integer> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
}
|
12
SpigotCore_Main/src/de/steamwar/scoreboard/ScoreboardCallback.java
Normale Datei
12
SpigotCore_Main/src/de/steamwar/scoreboard/ScoreboardCallback.java
Normale Datei
@ -0,0 +1,12 @@
|
||||
package de.steamwar.scoreboard;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public interface ScoreboardCallback {
|
||||
|
||||
public HashMap<String, Integer> getData();
|
||||
|
||||
public String getTitle();
|
||||
|
||||
|
||||
}
|
57
SpigotCore_Main/src/de/steamwar/scoreboard/ScoreboardContainer.java
Normale Datei
57
SpigotCore_Main/src/de/steamwar/scoreboard/ScoreboardContainer.java
Normale Datei
@ -0,0 +1,57 @@
|
||||
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.UUID;
|
||||
|
||||
public class ScoreboardContainer {
|
||||
|
||||
private static HashMap<UUID, ScoreboardContainer> containers = new HashMap<>();
|
||||
|
||||
Player player;
|
||||
ScoreboardCallback callback;
|
||||
|
||||
public ScoreboardContainer(Player player, ScoreboardCallback callback) {
|
||||
this.player = player;
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public void update() {
|
||||
|
||||
//Update
|
||||
SWScoreboard update = new SWScoreboard(player, callback.getData(), callback.getTitle());
|
||||
update.sendScoreboard();
|
||||
Bukkit.getScheduler().runTaskLater(Core.getInstance(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
update.display();
|
||||
}
|
||||
}, 2);
|
||||
}
|
||||
|
||||
public void startScoreboard() {
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(Core.getInstance(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for(ScoreboardContainer container : ScoreboardContainer.getContainers().values()) {
|
||||
container.update();
|
||||
}
|
||||
}
|
||||
}, 10, 5);
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public static HashMap<UUID, ScoreboardContainer> getContainers() {
|
||||
return containers;
|
||||
}
|
||||
}
|
9
pom.xml
9
pom.xml
@ -42,4 +42,13 @@
|
||||
<module>SpigotCore_14</module>
|
||||
<module>SpigotCore_Main</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
In neuem Issue referenzieren
Einen Benutzer sperren