mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-01 23:13:48 +01:00
Lets disable scoreboard top list until further updates
This commit is contained in:
parent
d31d60f4d8
commit
f72c3b37e6
@ -889,8 +889,13 @@ public class GeneralConfigManager {
|
|||||||
"This is update for same job signs, to avoid huge lag if you have bunch of same type signs. Keep it from 1 to as many sec you want");
|
"This is update for same job signs, to avoid huge lag if you have bunch of same type signs. Keep it from 1 to as many sec you want");
|
||||||
InfoUpdateInterval = c.get("Signs.InfoUpdateInterval", 5);
|
InfoUpdateInterval = c.get("Signs.InfoUpdateInterval", 5);
|
||||||
|
|
||||||
c.getW().addComment("Scoreboard.ShowToplist", "This will enables to show top list in scoreboard instead of chat");
|
if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
|
||||||
ShowToplistInScoreboard = c.get("Scoreboard.ShowToplist", true);
|
ShowToplistInScoreboard = false;
|
||||||
|
} else {
|
||||||
|
c.getW().addComment("Scoreboard.ShowToplist", "This will enables to show top list in scoreboard instead of chat");
|
||||||
|
ShowToplistInScoreboard = c.get("Scoreboard.ShowToplist", true);
|
||||||
|
}
|
||||||
|
|
||||||
c.getW().addComment("Scoreboard.interval", "For how long to show scoreboard");
|
c.getW().addComment("Scoreboard.interval", "For how long to show scoreboard");
|
||||||
ToplistInScoreboardInterval = c.get("Scoreboard.interval", 10);
|
ToplistInScoreboardInterval = c.get("Scoreboard.interval", 10);
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -19,6 +19,7 @@ import org.bukkit.scoreboard.Scoreboard;
|
|||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
import com.gamingmesh.jobs.container.ScoreboardInfo;
|
import com.gamingmesh.jobs.container.ScoreboardInfo;
|
||||||
|
import com.gamingmesh.jobs.stuff.VersionChecker.Version;
|
||||||
|
|
||||||
public class CMIScoreboardManager {
|
public class CMIScoreboardManager {
|
||||||
|
|
||||||
@ -74,17 +75,37 @@ public class CMIScoreboardManager {
|
|||||||
Class<?> boardClass = getNMSClass("Scoreboard");
|
Class<?> boardClass = getNMSClass("Scoreboard");
|
||||||
Object boards = boardClass.getConstructor().newInstance();
|
Object boards = boardClass.getConstructor().newInstance();
|
||||||
|
|
||||||
Method m = boards.getClass().getMethod("registerObjective", String.class, getNMSClass("IScoreboardCriteria"));
|
if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
|
||||||
|
|
||||||
Class<?> IScoreboardCriterias = getNMSClass("ScoreboardBaseCriteria");
|
// Class<?> enums = getNMSClass("IScoreboardCriteria$EnumScoreboardHealthDisplay");
|
||||||
Constructor<?> IScoreboardCriteriasConst = IScoreboardCriterias.getConstructor(String.class);
|
// Class<?> chatbase = getNMSClass("IChatBaseComponent$ChatSerializer");
|
||||||
Object IScoreboardCriteria = IScoreboardCriteriasConst.newInstance("JobsDummy");
|
//// Class<?> ser = getNMSClass("IChatBaseComponent$ChatSerializer");
|
||||||
|
// Method mm = chatbase.getMethod("a", String.class);
|
||||||
|
// Object serealized = mm.invoke(chatbase, "{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', "JobsDummy") + "\"}");
|
||||||
|
// Object e = enums.getEnumConstants()[0];
|
||||||
|
// Class<?> IScoreboardCriterias = getNMSClass("ScoreboardBaseCriteria");
|
||||||
|
// Constructor<?> IScoreboardCriteriasConst = IScoreboardCriterias.getConstructor(String.class);
|
||||||
|
// Object IScoreboardCriteria = IScoreboardCriteriasConst.newInstance("JobsDummy");
|
||||||
|
// Method m = boards.getClass().getMethod("registerNewObjective", String.class, getNMSClass("IScoreboardCriteria"), chatbase, enums);
|
||||||
|
// Object obj = m.invoke(boards, objName, "JobsDummy", IScoreboardCriteria, serealized, e);
|
||||||
|
//
|
||||||
|
// Class<?> p1 = getNMSClass("PacketPlayOutScoreboardObjective");
|
||||||
|
// Constructor<?> p11 = p1.getConstructor(obj.getClass(), int.class);
|
||||||
|
// Object pp1 = p11.newInstance(obj, 1);
|
||||||
|
// sendPacket(player, pp1);
|
||||||
|
} else {
|
||||||
|
Method m = boards.getClass().getMethod("registerObjective", String.class, getNMSClass("IScoreboardCriteria"));
|
||||||
|
|
||||||
Object obj = m.invoke(boards, objName, IScoreboardCriteria);
|
Class<?> IScoreboardCriterias = getNMSClass("ScoreboardBaseCriteria");
|
||||||
Class<?> p1 = getNMSClass("PacketPlayOutScoreboardObjective");
|
Constructor<?> IScoreboardCriteriasConst = IScoreboardCriterias.getConstructor(String.class);
|
||||||
Constructor<?> p11 = p1.getConstructor(obj.getClass(), int.class);
|
Object IScoreboardCriteria = IScoreboardCriteriasConst.newInstance("JobsDummy");
|
||||||
Object pp1 = p11.newInstance(obj, 1);
|
|
||||||
sendPacket(player, pp1);
|
Object obj = m.invoke(boards, objName, IScoreboardCriteria);
|
||||||
|
Class<?> p1 = getNMSClass("PacketPlayOutScoreboardObjective");
|
||||||
|
Constructor<?> p11 = p1.getConstructor(obj.getClass(), int.class);
|
||||||
|
Object pp1 = p11.newInstance(obj, 1);
|
||||||
|
sendPacket(player, pp1);
|
||||||
|
}
|
||||||
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -95,50 +116,105 @@ public class CMIScoreboardManager {
|
|||||||
try {
|
try {
|
||||||
Class<?> boardClass = getNMSClass("Scoreboard");
|
Class<?> boardClass = getNMSClass("Scoreboard");
|
||||||
Object boards = boardClass.getConstructor().newInstance();
|
Object boards = boardClass.getConstructor().newInstance();
|
||||||
|
if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) {
|
||||||
|
//
|
||||||
|
// Class<?> enums = getNMSClass("IScoreboardCriteria$EnumScoreboardHealthDisplay");
|
||||||
|
//
|
||||||
|
// Class<?> chatbase = getNMSClass("IChatBaseComponent$ChatSerializer");
|
||||||
|
//// Class<?> ser = getNMSClass("IChatBaseComponent$ChatSerializer");
|
||||||
|
// Method mm2 = chatbase.getMethod("a", String.class);
|
||||||
|
// Object serealized = mm2.invoke(chatbase, "{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', "JobsDummy") + "\"}");
|
||||||
|
// Object e = enums.getEnumConstants()[0];
|
||||||
|
// Class<?> IScoreboardCriterias = getNMSClass("ScoreboardBaseCriteria");
|
||||||
|
// Constructor<?> IScoreboardCriteriasConst = IScoreboardCriterias.getConstructor(String.class);
|
||||||
|
// Object IScoreboardCriteria = IScoreboardCriteriasConst.newInstance("JobsDummy");
|
||||||
|
// Method m = boards.getClass().getMethod("registerNewObjective", String.class, getNMSClass("IScoreboardCriteria"), chatbase, enums);
|
||||||
|
// Object obj = m.invoke(boards, objName, "JobsDummy", IScoreboardCriteria, serealized, e);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Method mm = obj.getClass().getMethod("setDisplayName", String.class);
|
||||||
|
// mm.invoke(obj, ChatColor.translateAlternateColorCodes('&', displayName));
|
||||||
|
//
|
||||||
|
// Class<?> p1 = getNMSClass("PacketPlayOutScoreboardObjective");
|
||||||
|
// Constructor<?> p11 = p1.getConstructor(obj.getClass(), int.class);
|
||||||
|
// Object pp1 = p11.newInstance(obj, 1);
|
||||||
|
// sendPacket(player, pp1);
|
||||||
|
//
|
||||||
|
// Class<?> p2 = getNMSClass("PacketPlayOutScoreboardObjective");
|
||||||
|
// Constructor<?> p12 = p2.getConstructor(obj.getClass(), int.class);
|
||||||
|
// Object pp2 = p12.newInstance(obj, 0);
|
||||||
|
// sendPacket(player, pp2);
|
||||||
|
//
|
||||||
|
// Class<?> packetClass = getNMSClass("PacketPlayOutScoreboardDisplayObjective");
|
||||||
|
// Constructor<?> packetConstructor = packetClass.getConstructor(int.class, getNMSClass("ScoreboardObjective"));
|
||||||
|
// Object packet = packetConstructor.newInstance(1, obj);
|
||||||
|
// sendPacket(player, packet);
|
||||||
|
//
|
||||||
|
// for (int i = 0; i < 15; i++) {
|
||||||
|
// if (i >= lines.size())
|
||||||
|
// break;
|
||||||
|
//
|
||||||
|
// String ln = ChatColor.translateAlternateColorCodes('&', lines.get(i));
|
||||||
|
// Class<?> ScoreboardScoreClass = getNMSClass("ScoreboardScore");
|
||||||
|
// Constructor<?> packetConstructor2 = ScoreboardScoreClass.getConstructor(getNMSClass("Scoreboard"), getNMSClass("ScoreboardObjective"), String.class);
|
||||||
|
// Object packet2 = packetConstructor2.newInstance(boards, obj, ln);
|
||||||
|
// Method mc = packet2.getClass().getMethod("setScore", int.class);
|
||||||
|
// mc.invoke(packet2, 15 - i);
|
||||||
|
//
|
||||||
|
// Class<?> PacketPlayOutScoreboardScoreClass = getNMSClass("PacketPlayOutScoreboardScore");
|
||||||
|
// Constructor<?> PacketPlayOutScoreboardScoreConstructor = PacketPlayOutScoreboardScoreClass.getConstructor(getNMSClass("ScoreboardScore"));
|
||||||
|
// Object PacketPlayOutScoreboardScore = PacketPlayOutScoreboardScoreConstructor.newInstance(packet2);
|
||||||
|
//
|
||||||
|
// sendPacket(player, PacketPlayOutScoreboardScore);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
Method m = boards.getClass().getMethod("registerObjective", String.class, getNMSClass("IScoreboardCriteria"));
|
} else {
|
||||||
|
|
||||||
Class<?> IScoreboardCriterias = getNMSClass("ScoreboardBaseCriteria");
|
Method m = boards.getClass().getMethod("registerObjective", String.class, getNMSClass("IScoreboardCriteria"));
|
||||||
Constructor<?> IScoreboardCriteriasConst = IScoreboardCriterias.getConstructor(String.class);
|
|
||||||
Object IScoreboardCriteria = IScoreboardCriteriasConst.newInstance("JobsDummy");
|
|
||||||
|
|
||||||
Object obj = m.invoke(boards, objName, IScoreboardCriteria);
|
Class<?> IScoreboardCriterias = getNMSClass("ScoreboardBaseCriteria");
|
||||||
|
Constructor<?> IScoreboardCriteriasConst = IScoreboardCriterias.getConstructor(String.class);
|
||||||
|
Object IScoreboardCriteria = IScoreboardCriteriasConst.newInstance("JobsDummy");
|
||||||
|
|
||||||
Method mm = obj.getClass().getMethod("setDisplayName", String.class);
|
Object obj = m.invoke(boards, objName, IScoreboardCriteria);
|
||||||
mm.invoke(obj, ChatColor.translateAlternateColorCodes('&', displayName));
|
|
||||||
|
|
||||||
Class<?> p1 = getNMSClass("PacketPlayOutScoreboardObjective");
|
Method mm = obj.getClass().getMethod("setDisplayName", String.class);
|
||||||
Constructor<?> p11 = p1.getConstructor(obj.getClass(), int.class);
|
mm.invoke(obj, ChatColor.translateAlternateColorCodes('&', displayName));
|
||||||
Object pp1 = p11.newInstance(obj, 1);
|
|
||||||
sendPacket(player, pp1);
|
|
||||||
|
|
||||||
Class<?> p2 = getNMSClass("PacketPlayOutScoreboardObjective");
|
Class<?> p1 = getNMSClass("PacketPlayOutScoreboardObjective");
|
||||||
Constructor<?> p12 = p2.getConstructor(obj.getClass(), int.class);
|
Constructor<?> p11 = p1.getConstructor(obj.getClass(), int.class);
|
||||||
Object pp2 = p12.newInstance(obj, 0);
|
Object pp1 = p11.newInstance(obj, 1);
|
||||||
sendPacket(player, pp2);
|
sendPacket(player, pp1);
|
||||||
|
|
||||||
Class<?> packetClass = getNMSClass("PacketPlayOutScoreboardDisplayObjective");
|
Class<?> p2 = getNMSClass("PacketPlayOutScoreboardObjective");
|
||||||
Constructor<?> packetConstructor = packetClass.getConstructor(int.class, getNMSClass("ScoreboardObjective"));
|
Constructor<?> p12 = p2.getConstructor(obj.getClass(), int.class);
|
||||||
Object packet = packetConstructor.newInstance(1, obj);
|
Object pp2 = p12.newInstance(obj, 0);
|
||||||
sendPacket(player, packet);
|
sendPacket(player, pp2);
|
||||||
|
|
||||||
for (int i = 0; i < 15; i++) {
|
Class<?> packetClass = getNMSClass("PacketPlayOutScoreboardDisplayObjective");
|
||||||
if (i >= lines.size())
|
Constructor<?> packetConstructor = packetClass.getConstructor(int.class, getNMSClass("ScoreboardObjective"));
|
||||||
break;
|
Object packet = packetConstructor.newInstance(1, obj);
|
||||||
|
sendPacket(player, packet);
|
||||||
|
|
||||||
String ln = ChatColor.translateAlternateColorCodes('&', lines.get(i));
|
for (int i = 0; i < 15; i++) {
|
||||||
Class<?> ScoreboardScoreClass = getNMSClass("ScoreboardScore");
|
if (i >= lines.size())
|
||||||
Constructor<?> packetConstructor2 = ScoreboardScoreClass.getConstructor(getNMSClass("Scoreboard"), getNMSClass("ScoreboardObjective"), String.class);
|
break;
|
||||||
Object packet2 = packetConstructor2.newInstance(boards, obj, ln);
|
|
||||||
Method mc = packet2.getClass().getMethod("setScore", int.class);
|
|
||||||
mc.invoke(packet2, 15 - i);
|
|
||||||
|
|
||||||
Class<?> PacketPlayOutScoreboardScoreClass = getNMSClass("PacketPlayOutScoreboardScore");
|
String ln = ChatColor.translateAlternateColorCodes('&', lines.get(i));
|
||||||
Constructor<?> PacketPlayOutScoreboardScoreConstructor = PacketPlayOutScoreboardScoreClass.getConstructor(getNMSClass("ScoreboardScore"));
|
Class<?> ScoreboardScoreClass = getNMSClass("ScoreboardScore");
|
||||||
Object PacketPlayOutScoreboardScore = PacketPlayOutScoreboardScoreConstructor.newInstance(packet2);
|
Constructor<?> packetConstructor2 = ScoreboardScoreClass.getConstructor(getNMSClass("Scoreboard"), getNMSClass("ScoreboardObjective"), String.class);
|
||||||
|
Object packet2 = packetConstructor2.newInstance(boards, obj, ln);
|
||||||
|
Method mc = packet2.getClass().getMethod("setScore", int.class);
|
||||||
|
mc.invoke(packet2, 15 - i);
|
||||||
|
|
||||||
sendPacket(player, PacketPlayOutScoreboardScore);
|
Class<?> PacketPlayOutScoreboardScoreClass = getNMSClass("PacketPlayOutScoreboardScore");
|
||||||
|
Constructor<?> PacketPlayOutScoreboardScoreConstructor = PacketPlayOutScoreboardScoreClass.getConstructor(getNMSClass("ScoreboardScore"));
|
||||||
|
Object PacketPlayOutScoreboardScore = PacketPlayOutScoreboardScoreConstructor.newInstance(packet2);
|
||||||
|
|
||||||
|
sendPacket(player, PacketPlayOutScoreboardScore);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -22,7 +22,7 @@ public class VersionChecker {
|
|||||||
version = getCurrent();
|
version = getCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Version version = Version.v1_11_R1;
|
private static Version version = Version.v1_11_R1;
|
||||||
|
|
||||||
public Version getVersion() {
|
public Version getVersion() {
|
||||||
return version;
|
return version;
|
||||||
@ -91,6 +91,10 @@ public class VersionChecker {
|
|||||||
public boolean isEqualOrHigher(Version version) {
|
public boolean isEqualOrHigher(Version version) {
|
||||||
return getValue() >= version.getValue();
|
return getValue() >= version.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isCurrentEqualOrHigher(Version version) {
|
||||||
|
return version.getValue() >= version.getValue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Version getCurrent() {
|
public static Version getCurrent() {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: Jobs
|
name: Jobs
|
||||||
description: Jobs Plugin for the BukkitAPI
|
description: Jobs Plugin for the BukkitAPI
|
||||||
main: com.gamingmesh.jobs.Jobs
|
main: com.gamingmesh.jobs.Jobs
|
||||||
version: 4.6.1
|
version: 4.6.2
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
website: https://www.spigotmc.org/resources/jobs-reborn.4216/
|
website: https://www.spigotmc.org/resources/jobs-reborn.4216/
|
||||||
author: phrstbrn
|
author: phrstbrn
|
||||||
|
Loading…
Reference in New Issue
Block a user