1.4.1
This commit is contained in:
parent
cc538bb5c1
commit
a7f7060666
7 changed files with 69 additions and 38 deletions
2
pom.xml
2
pom.xml
|
|
@ -37,7 +37,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.20.1-R0.1-SNAPSHOT</version>
|
<version>1.20.2-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,13 @@ import pk.ajneb97.model.internal.UpdateCheckerResult;
|
||||||
import pk.ajneb97.tasks.InventoryUpdateTaskManager;
|
import pk.ajneb97.tasks.InventoryUpdateTaskManager;
|
||||||
import pk.ajneb97.tasks.PlayerDataSaveTask;
|
import pk.ajneb97.tasks.PlayerDataSaveTask;
|
||||||
import pk.ajneb97.versions.NMSManager;
|
import pk.ajneb97.versions.NMSManager;
|
||||||
|
import pk.ajneb97.utils.ServerVersion;
|
||||||
|
|
||||||
public class PlayerKits2 extends JavaPlugin {
|
public class PlayerKits2 extends JavaPlugin {
|
||||||
|
|
||||||
public String version = getDescription().getVersion();
|
public String version = getDescription().getVersion();
|
||||||
public static String prefix = MessagesManager.getColoredMessage("&8[&bPlayerKits&a²&8] ");
|
public static String prefix;
|
||||||
|
public static ServerVersion serverVersion;
|
||||||
|
|
||||||
private KitItemManager kitItemManager;
|
private KitItemManager kitItemManager;
|
||||||
private KitsManager kitsManager;
|
private KitsManager kitsManager;
|
||||||
|
|
@ -41,6 +43,8 @@ public class PlayerKits2 extends JavaPlugin {
|
||||||
private MySQLConnection mySQLConnection;
|
private MySQLConnection mySQLConnection;
|
||||||
|
|
||||||
public void onEnable(){
|
public void onEnable(){
|
||||||
|
setVersion();
|
||||||
|
setPrefix();
|
||||||
registerCommands();
|
registerCommands();
|
||||||
registerEvents();
|
registerEvents();
|
||||||
|
|
||||||
|
|
@ -105,6 +109,15 @@ public class PlayerKits2 extends JavaPlugin {
|
||||||
playerDataSaveTask.start(configsManager.getMainConfigManager().getConfig().getInt("player_data_save_time"));
|
playerDataSaveTask.start(configsManager.getMainConfigManager().getConfig().getInt("player_data_save_time"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPrefix(){
|
||||||
|
prefix = MessagesManager.getColoredMessage("&8[&bPlayerKits&a²&8] ");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVersion(){
|
||||||
|
String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
||||||
|
serverVersion = ServerVersion.valueOf(packageName.replace("org.bukkit.craftbukkit.", ""));
|
||||||
|
}
|
||||||
|
|
||||||
public KitItemManager getKitItemManager() {
|
public KitItemManager getKitItemManager() {
|
||||||
return kitItemManager;
|
return kitItemManager;
|
||||||
}
|
}
|
||||||
|
|
@ -157,6 +170,7 @@ public class PlayerKits2 extends JavaPlugin {
|
||||||
return verifyManager;
|
return verifyManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void updateMessage(UpdateCheckerResult result){
|
public void updateMessage(UpdateCheckerResult result){
|
||||||
if(!result.isError()){
|
if(!result.isError()){
|
||||||
String latestVersion = result.getLatestVersion();
|
String latestVersion = result.getLatestVersion();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package pk.ajneb97.utils;
|
package pk.ajneb97.utils;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -94,28 +95,35 @@ public class ItemUtils {
|
||||||
try {
|
try {
|
||||||
profileField = skullMeta.getClass().getDeclaredField("profile");
|
profileField = skullMeta.getClass().getDeclaredField("profile");
|
||||||
profileField.setAccessible(true);
|
profileField.setAccessible(true);
|
||||||
try {
|
|
||||||
GameProfile gameProfile = (GameProfile) profileField.get(skullMeta);
|
GameProfile gameProfile = (GameProfile) profileField.get(skullMeta);
|
||||||
if(gameProfile != null && gameProfile.getProperties() != null) {
|
if(gameProfile != null && gameProfile.getProperties() != null) {
|
||||||
PropertyMap propertyMap = gameProfile.getProperties();
|
PropertyMap propertyMap = gameProfile.getProperties();
|
||||||
owner = gameProfile.getName();
|
owner = gameProfile.getName();
|
||||||
if(gameProfile.getId() != null) {
|
if(gameProfile.getId() != null) {
|
||||||
id = gameProfile.getId().toString();
|
id = gameProfile.getId().toString();
|
||||||
}
|
}
|
||||||
for(Property p : propertyMap.values()) {
|
|
||||||
|
ServerVersion serverVersion = PlayerKits2.serverVersion;
|
||||||
|
for(Property p : propertyMap.values()) {
|
||||||
|
if(serverVersion.serverVersionGreaterEqualThan(serverVersion,ServerVersion.v1_20_R2)){
|
||||||
|
String pName = (String)p.getClass().getMethod("name").invoke(p);
|
||||||
|
if(pName.equals("textures")){
|
||||||
|
texture = (String)p.getClass().getMethod("value").invoke(p);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
if(p.getName().equals("textures")) {
|
if(p.getName().equals("textures")) {
|
||||||
texture = p.getValue();
|
texture = p.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
} catch (NoSuchFieldException | SecurityException e) {
|
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException
|
||||||
|
| InvocationTargetException | NoSuchMethodException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(texture != null || id != null || owner != null) {
|
if(texture != null || id != null || owner != null) {
|
||||||
kitItemSkullData = new KitItemSkullData(owner,texture,id);
|
kitItemSkullData = new KitItemSkullData(owner,texture,id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,9 +156,9 @@ public class ItemUtils {
|
||||||
|
|
||||||
GameProfile profile = null;
|
GameProfile profile = null;
|
||||||
if(id == null) {
|
if(id == null) {
|
||||||
profile = new GameProfile(UUID.randomUUID(), owner);
|
profile = new GameProfile(UUID.randomUUID(), owner != null ? owner : "");
|
||||||
}else {
|
}else {
|
||||||
profile = new GameProfile(UUID.fromString(id), owner);
|
profile = new GameProfile(UUID.fromString(id), owner != null ? owner : "");
|
||||||
}
|
}
|
||||||
profile.getProperties().put("textures", new Property("textures", texture));
|
profile.getProperties().put("textures", new Property("textures", texture));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import pk.ajneb97.PlayerKits2;
|
import pk.ajneb97.PlayerKits2;
|
||||||
|
import pk.ajneb97.api.PlayerKitsAPI;
|
||||||
import pk.ajneb97.managers.MessagesManager;
|
import pk.ajneb97.managers.MessagesManager;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -11,27 +12,25 @@ import java.util.ArrayList;
|
||||||
public class OtherUtils {
|
public class OtherUtils {
|
||||||
|
|
||||||
public static boolean isNew() {
|
public static boolean isNew() {
|
||||||
if(Bukkit.getVersion().contains("1.16") || Bukkit.getVersion().contains("1.17")
|
ServerVersion serverVersion = PlayerKits2.serverVersion;
|
||||||
|| Bukkit.getVersion().contains("1.18") || Bukkit.getVersion().contains("1.19")
|
if(serverVersion.serverVersionGreaterEqualThan(serverVersion,ServerVersion.v1_16_R1)){
|
||||||
|| Bukkit.getVersion().contains("1.20")) {
|
|
||||||
return true;
|
return true;
|
||||||
}else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLegacy() {
|
public static boolean isLegacy() {
|
||||||
if(Bukkit.getVersion().contains("1.13") || Bukkit.getVersion().contains("1.14") ||
|
ServerVersion serverVersion = PlayerKits2.serverVersion;
|
||||||
Bukkit.getVersion().contains("1.15") || isNew()) {
|
if(serverVersion.serverVersionGreaterEqualThan(serverVersion,ServerVersion.v1_13_R1)) {
|
||||||
return false;
|
return false;
|
||||||
}else {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1.20+
|
// 1.20+
|
||||||
public static boolean isTrimNew() {
|
public static boolean isTrimNew() {
|
||||||
if(Bukkit.getVersion().contains("1.20")) {
|
ServerVersion serverVersion = PlayerKits2.serverVersion;
|
||||||
|
if(serverVersion.serverVersionGreaterEqualThan(serverVersion,ServerVersion.v1_20_R1)) {
|
||||||
return true;
|
return true;
|
||||||
}else {
|
}else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package pk.ajneb97.versions;
|
package pk.ajneb97.utils;
|
||||||
|
|
||||||
public enum ServerVersion {
|
public enum ServerVersion {
|
||||||
v1_8_R1,
|
v1_8_R1,
|
||||||
|
|
@ -23,4 +23,9 @@ public enum ServerVersion {
|
||||||
v1_19_R2,
|
v1_19_R2,
|
||||||
v1_19_R3,
|
v1_19_R3,
|
||||||
v1_20_R1,
|
v1_20_R1,
|
||||||
|
v1_20_R2;
|
||||||
|
|
||||||
|
public boolean serverVersionGreaterEqualThan(ServerVersion version1,ServerVersion version2){
|
||||||
|
return version1.ordinal() >= version2.ordinal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
package pk.ajneb97.versions;
|
package pk.ajneb97.versions;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import pk.ajneb97.PlayerKits2;
|
||||||
|
import pk.ajneb97.utils.ServerVersion;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -9,13 +11,13 @@ import java.util.Set;
|
||||||
|
|
||||||
public class NMSManager {
|
public class NMSManager {
|
||||||
|
|
||||||
private ServerVersion serverVersion;
|
|
||||||
private Version version;
|
private Version version;
|
||||||
|
private ServerVersion serverVersion;
|
||||||
|
|
||||||
public NMSManager(){
|
public NMSManager(){
|
||||||
this.version = new Version();
|
this.version = new Version();
|
||||||
String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
this.serverVersion = PlayerKits2.serverVersion;
|
||||||
serverVersion = ServerVersion.valueOf(packageName.replace("org.bukkit.craftbukkit.", ""));
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//Classes
|
//Classes
|
||||||
|
|
@ -82,7 +84,8 @@ public class NMSManager {
|
||||||
case v1_19_R1:
|
case v1_19_R1:
|
||||||
case v1_19_R2:
|
case v1_19_R2:
|
||||||
case v1_19_R3: methodName = "t"; break;
|
case v1_19_R3: methodName = "t"; break;
|
||||||
case v1_20_R1: methodName = "u"; break;
|
case v1_20_R1:
|
||||||
|
case v1_20_R2: methodName = "u"; break;
|
||||||
}
|
}
|
||||||
version.addMethod("hasTag",version.getClassRef("ItemStackNMS").getMethod(methodName));
|
version.addMethod("hasTag",version.getClassRef("ItemStackNMS").getMethod(methodName));
|
||||||
|
|
||||||
|
|
@ -93,7 +96,8 @@ public class NMSManager {
|
||||||
case v1_19_R1:
|
case v1_19_R1:
|
||||||
case v1_19_R2:
|
case v1_19_R2:
|
||||||
case v1_19_R3: methodName = "u"; break;
|
case v1_19_R3: methodName = "u"; break;
|
||||||
case v1_20_R1: methodName = "v"; break;
|
case v1_20_R1:
|
||||||
|
case v1_20_R2: methodName = "v"; break;
|
||||||
}
|
}
|
||||||
version.addMethod("getTag",version.getClassRef("ItemStackNMS").getMethod(methodName));
|
version.addMethod("getTag",version.getClassRef("ItemStackNMS").getMethod(methodName));
|
||||||
|
|
||||||
|
|
@ -119,7 +123,8 @@ public class NMSManager {
|
||||||
case v1_19_R1: methodName = "d"; break;
|
case v1_19_R1: methodName = "d"; break;
|
||||||
case v1_19_R2:
|
case v1_19_R2:
|
||||||
case v1_19_R3:
|
case v1_19_R3:
|
||||||
case v1_20_R1: methodName = "e"; break;
|
case v1_20_R1:
|
||||||
|
case v1_20_R2: methodName = "e"; break;
|
||||||
}
|
}
|
||||||
version.addMethod("getKeys",version.getClassRef("NBTTagCompound").getMethod(methodName));
|
version.addMethod("getKeys",version.getClassRef("NBTTagCompound").getMethod(methodName));
|
||||||
version.addMethod("hasKeyOfType",version.getClassRef("NBTTagCompound").getMethod("b",String.class,int.class));
|
version.addMethod("hasKeyOfType",version.getClassRef("NBTTagCompound").getMethod("b",String.class,int.class));
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
main: pk.ajneb97.PlayerKits2
|
main: pk.ajneb97.PlayerKits2
|
||||||
version: 1.3.3
|
version: 1.4.1
|
||||||
name: PlayerKits2
|
name: PlayerKits2
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
softdepend: [Vault,PlaceholderAPI]
|
softdepend: [Vault,PlaceholderAPI]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue