mirror of
https://github.com/geekfrog/PermissionsTime.git
synced 2024-11-21 14:58:48 +00:00
新特性
可以定义物品的种类, 特殊的如头颅可以指定哪个玩家的头颅.(1.8+) 附魔发光的特效.
This commit is contained in:
parent
d0dd089d23
commit
e166cd5456
@ -43,6 +43,9 @@
|
||||
- **支持跨服**
|
||||
- **gui显示自己的权限包**
|
||||
- **语言支持整理**
|
||||
- **支持自定义哪个玩家的头颅**
|
||||
- **支持物品发光(附魔效果)**
|
||||
- **玩家进入游戏时赋予权限更早**
|
||||
- 手动删除过期的或无效数据
|
||||
- 取消前置插件
|
||||
|
||||
|
@ -12,8 +12,17 @@ packages:
|
||||
# Permission package display name.
|
||||
displayName: '&4Test Package'
|
||||
# 显示的物品类型.
|
||||
# 可以使用id, 但不可与type同时使用.
|
||||
# 可以定义物品的种类, 特殊的如头颅可以指定哪个玩家的头颅.
|
||||
# Show the type of item.
|
||||
# You can use 'id', but you can't use 'type' at the same time.
|
||||
# You can define the type of item, such as skull can set which player's head.
|
||||
#id: 397
|
||||
#type: SKULL_ITEM:5
|
||||
#type: SKULL_ITEM:MHF_Present1
|
||||
type: NETHER_STAR
|
||||
# 是否有附魔发光的特效
|
||||
glowing: false
|
||||
# 标签.
|
||||
# Lores.
|
||||
lores:
|
||||
|
4
pom.xml
4
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>gg.frog.mc</groupId>
|
||||
<artifactId>permissionstime</artifactId>
|
||||
<version>0.1.1-SNAPSHOT</version>
|
||||
<version>0.1.2-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>PermissionsTime</name>
|
||||
<description>支持跨服的权限限时插件</description>
|
||||
@ -38,7 +38,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.12-pre6-SNAPSHOT</version>
|
||||
<version>1.8-R0.1-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
@ -19,6 +19,7 @@ import gg.frog.mc.permissionstime.PluginMain;
|
||||
import gg.frog.mc.permissionstime.model.cfg.PermissionPackageBean;
|
||||
import gg.frog.mc.permissionstime.utils.StrUtil;
|
||||
import gg.frog.mc.permissionstime.utils.config.PluginConfig;
|
||||
import gg.frog.mc.permissionstime.utils.nms.ItemUtil;
|
||||
|
||||
public class PackagesCfg extends PluginConfig {
|
||||
|
||||
@ -66,35 +67,42 @@ public class PackagesCfg extends PluginConfig {
|
||||
if (ppb != null) {
|
||||
Material type = null;
|
||||
int exid = 0;
|
||||
String skullOwner = null;
|
||||
if (ppb.getType() != null) {
|
||||
String[] args = ppb.getType().split(":");
|
||||
try {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
exid = Integer.parseInt(args[1]);
|
||||
case 1:
|
||||
type = Material.getMaterial(args[0].toUpperCase(Locale.ENGLISH));
|
||||
type = Material.getMaterial(args[0].toUpperCase(Locale.ENGLISH));
|
||||
if (args.length == 2) {
|
||||
try {
|
||||
exid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
if (Material.SKULL_ITEM.equals(type)) {
|
||||
exid = 3;
|
||||
skullOwner = args[1];
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (ppb.getId() != null) {
|
||||
String[] args = ppb.getId().split(":");
|
||||
try {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
exid = Integer.parseInt(args[1]);
|
||||
case 1:
|
||||
int id = Integer.parseInt(args[0]);
|
||||
type = Material.getMaterial(id);
|
||||
int id = Integer.parseInt(args[0]);
|
||||
type = Material.getMaterial(id);
|
||||
if (args.length == 2) {
|
||||
try {
|
||||
exid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
if (Material.SKULL_ITEM.equals(type)) {
|
||||
exid = 3;
|
||||
skullOwner = args[1];
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (type != null) {
|
||||
ItemStack items = new ItemStack(type, 1, (short) 0, (byte) exid);
|
||||
ItemMeta meta = items.getItemMeta();
|
||||
ItemStack item = new ItemStack(type, 1, (short) 0, (byte) exid);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(StrUtil.messageFormat(ppb.getDisplayName() + "&r(" + name + ")"));
|
||||
List<String> lores = new ArrayList<String>();
|
||||
for (String lore : ppb.getLores()) {
|
||||
@ -102,8 +110,14 @@ public class PackagesCfg extends PluginConfig {
|
||||
}
|
||||
lores.add("");
|
||||
meta.setLore(lores);
|
||||
items.setItemMeta(meta);
|
||||
return items;
|
||||
item.setItemMeta(meta);
|
||||
if (ppb.getGlowing() && !meta.hasEnchants()) {
|
||||
item = ItemUtil.addEnchantLight(item);
|
||||
}
|
||||
if (skullOwner != null) {
|
||||
item = ItemUtil.addSkullOwner(item, skullOwner);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -8,7 +8,6 @@ import gg.frog.mc.permissionstime.config.PluginCfg;
|
||||
import gg.frog.mc.permissionstime.database.impl.MySQLPlayerDataDao;
|
||||
import gg.frog.mc.permissionstime.database.impl.SqlitePlayerDataDao;
|
||||
import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
|
||||
import gg.frog.mc.permissionstime.utils.StrUtil;
|
||||
import lib.PatPeter.SQLibrary.Database;
|
||||
import lib.PatPeter.SQLibrary.MySQL;
|
||||
import lib.PatPeter.SQLibrary.SQLite;
|
||||
|
@ -3,10 +3,11 @@ package gg.frog.mc.permissionstime.listener;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import gg.frog.mc.permissionstime.PluginMain;
|
||||
@ -24,28 +25,17 @@ public class MainListener implements Listener {
|
||||
this.pm = pm;
|
||||
}
|
||||
|
||||
/**
|
||||
* 一个监听器例子
|
||||
*
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
List<PlayerDataBean> pdbList = pm.getSqlManager().getTime(event.getPlayer().getUniqueId().toString());
|
||||
PermissionPackageBean.reloadPlayerPermissions(event.getPlayer(), pdbList, pm);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
event.getPlayer().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_FAIL_SET_PERMISSION));
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onJoin(PlayerLoginEvent event) {
|
||||
try {
|
||||
List<PlayerDataBean> pdbList = pm.getSqlManager().getTime(event.getPlayer().getUniqueId().toString());
|
||||
PermissionPackageBean.reloadPlayerPermissions(event.getPlayer(), pdbList, pm, false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
event.getPlayer().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_FAIL_SET_PERMISSION));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
@ -59,7 +49,6 @@ public class MainListener implements Listener {
|
||||
}).start();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onKick(PlayerKickEvent event) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
|
@ -14,8 +14,11 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import gg.frog.mc.permissionstime.PluginMain;
|
||||
import gg.frog.mc.permissionstime.config.LangCfg;
|
||||
import gg.frog.mc.permissionstime.config.PackagesCfg;
|
||||
import gg.frog.mc.permissionstime.config.PluginCfg;
|
||||
import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
|
||||
import gg.frog.mc.permissionstime.utils.StrUtil;
|
||||
import gg.frog.mc.permissionstime.utils.config.IConfigBean;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
@ -30,8 +33,9 @@ public class PermissionPackageBean implements IConfigBean {
|
||||
private String displayName = null;
|
||||
private String id;
|
||||
private String type;
|
||||
private Boolean glowing;
|
||||
private List<String> lores = new ArrayList<>();
|
||||
private Boolean global = null;
|
||||
private Boolean global;
|
||||
private List<String> permissions = new ArrayList<>();
|
||||
private List<String> groups = new ArrayList<>();
|
||||
private static Map<String, BukkitTask> taskMap = new ConcurrentHashMap<>();
|
||||
@ -60,6 +64,14 @@ public class PermissionPackageBean implements IConfigBean {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Boolean getGlowing() {
|
||||
return glowing;
|
||||
}
|
||||
|
||||
public void setGlowing(Boolean glowing) {
|
||||
this.glowing = glowing;
|
||||
}
|
||||
|
||||
public List<String> getLores() {
|
||||
return lores;
|
||||
}
|
||||
@ -98,6 +110,7 @@ public class PermissionPackageBean implements IConfigBean {
|
||||
config.set("displayName", displayName);
|
||||
config.set("id", id);
|
||||
config.set("type", type);
|
||||
config.set("glowing", glowing);
|
||||
config.set("lores", lores);
|
||||
config.set("global", global);
|
||||
config.set("permissions", permissions);
|
||||
@ -116,6 +129,7 @@ public class PermissionPackageBean implements IConfigBean {
|
||||
if (id == null && type == null) {
|
||||
type = "NETHER_STAR";
|
||||
}
|
||||
glowing = config.getBoolean("glowing");
|
||||
lores = config.getStringList("lores");
|
||||
global = config.getBoolean("global");
|
||||
permissions = config.getStringList("permissions");
|
||||
@ -124,7 +138,7 @@ public class PermissionPackageBean implements IConfigBean {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PermissionPackageBean [displayName=" + displayName + ", id=" + id + ", type=" + type + ", lores=" + lores + ", global=" + global + ", permissions=" + permissions + ", groups=" + groups + "]";
|
||||
return "PermissionPackageBean [displayName=" + displayName + ", id=" + id + ", type=" + type + ", glowing=" + glowing + ", lores=" + lores + ", global=" + global + ", permissions=" + permissions + ", groups=" + groups + "]";
|
||||
}
|
||||
|
||||
private void givePlayer(OfflinePlayer player, Server server, Permission permission) {
|
||||
@ -196,6 +210,10 @@ public class PermissionPackageBean implements IConfigBean {
|
||||
}
|
||||
|
||||
public static void reloadPlayerPermissions(OfflinePlayer player, List<PlayerDataBean> pdbList, PluginMain plugin) {
|
||||
reloadPlayerPermissions(player, pdbList, plugin, true);
|
||||
}
|
||||
|
||||
public static void reloadPlayerPermissions(OfflinePlayer player, List<PlayerDataBean> pdbList, PluginMain plugin, boolean async) {
|
||||
long delay = -1;
|
||||
long now = new Date().getTime();
|
||||
PermissionPackageBean addPpb = new PermissionPackageBean();
|
||||
@ -219,13 +237,23 @@ public class PermissionPackageBean implements IConfigBean {
|
||||
subPpb.getGroups().removeAll(p.getGroups());
|
||||
}
|
||||
}
|
||||
plugin.getServer().getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
subPpb.clearPlayer(player, plugin.getServer(), plugin.getPermission());
|
||||
addPpb.givePlayer(player, plugin.getServer(), plugin.getPermission());
|
||||
}
|
||||
});
|
||||
if (async) {
|
||||
plugin.getServer().getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
subPpb.clearPlayer(player, plugin.getServer(), plugin.getPermission());
|
||||
addPpb.givePlayer(player, plugin.getServer(), plugin.getPermission());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
player.getPlayer().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_FAIL_SET_PERMISSION));
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
subPpb.clearPlayer(player, plugin.getServer(), plugin.getPermission());
|
||||
addPpb.givePlayer(player, plugin.getServer(), plugin.getPermission());
|
||||
}
|
||||
BukkitTask task = taskMap.get(player.getUniqueId().toString());
|
||||
if (task != null) {
|
||||
plugin.getServer().getScheduler().cancelTask(task.getTaskId());
|
||||
|
@ -18,6 +18,8 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import gg.frog.mc.permissionstime.PluginMain;
|
||||
import gg.frog.mc.permissionstime.config.PluginCfg;
|
||||
import gg.frog.mc.permissionstime.utils.StrUtil;
|
||||
|
||||
/**
|
||||
* 配置操作
|
||||
@ -105,7 +107,7 @@ public abstract class PluginConfig {
|
||||
try {
|
||||
getConfig().save(configFile);
|
||||
} catch (IOException ex) {
|
||||
PluginMain.LOG.log(Level.SEVERE, "Could not save config to " + configFile, ex);
|
||||
PluginMain.LOG.log(Level.SEVERE, StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "Could not save config to " + configFile), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,7 +116,7 @@ public abstract class PluginConfig {
|
||||
getConfig().save(configFile);
|
||||
reloadConfig();
|
||||
} catch (IOException ex) {
|
||||
PluginMain.LOG.log(Level.SEVERE, "Could not save config to " + configFile, ex);
|
||||
PluginMain.LOG.log(Level.SEVERE, StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "Could not save config to " + configFile), ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
124
src/main/gg/frog/mc/permissionstime/utils/nms/ItemUtil.java
Normal file
124
src/main/gg/frog/mc/permissionstime/utils/nms/ItemUtil.java
Normal file
@ -0,0 +1,124 @@
|
||||
package gg.frog.mc.permissionstime.utils.nms;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import gg.frog.mc.permissionstime.PluginMain;
|
||||
import gg.frog.mc.permissionstime.config.PluginCfg;
|
||||
import gg.frog.mc.permissionstime.utils.StrUtil;
|
||||
|
||||
public class ItemUtil {
|
||||
|
||||
private static Class<?> nbtBaseClass;
|
||||
private static Class<?> nbtTagCompoundClass;
|
||||
private static Class<?> nbtTagStringClass;
|
||||
private static Class<?> nbtTagIntClass;
|
||||
// private static Class<?> nbtTagShortClass;
|
||||
// private static Class<?> nbtTagListClass;
|
||||
private static Class<?> nmsItemstackClass;
|
||||
private static Method asNmsCopyMethod;
|
||||
private static Method asCraftMirrorMethod;
|
||||
private static Method hasTagMethod;
|
||||
private static Method getTagMethod;
|
||||
private static Method setTagMethod;
|
||||
private static Method nbtSetMethod;
|
||||
// private static Method nbtListAddSetMethod;
|
||||
private static boolean setupOk;
|
||||
|
||||
static {
|
||||
try {
|
||||
nmsItemstackClass = NMSUtil.getNmsClass("ItemStack");// add
|
||||
nbtBaseClass = NMSUtil.getNmsClass("NBTBase");// dy
|
||||
nbtTagStringClass = NMSUtil.getNmsClass("NBTTagString");// dx
|
||||
nbtTagIntClass = NMSUtil.getNmsClass("NBTTagInt");// dp
|
||||
nbtTagCompoundClass = NMSUtil.getNmsClass("NBTTagCompound");// dh
|
||||
// nbtTagShortClass = NMSUtil.getNmsClass("NBTTagShort");
|
||||
// nbtTagListClass = NMSUtil.getNmsClass("NBTTagList");
|
||||
asNmsCopyMethod = NMSUtil.getObcClass("inventory.CraftItemStack").getMethod("asNMSCopy", new Class[] { ItemStack.class });
|
||||
asCraftMirrorMethod = NMSUtil.getObcClass("inventory.CraftItemStack").getMethod("asCraftMirror", new Class[] { nmsItemstackClass });
|
||||
hasTagMethod = nmsItemstackClass.getMethod("hasTag", new Class[0]);// p
|
||||
getTagMethod = nmsItemstackClass.getMethod("getTag", new Class[0]);// q
|
||||
setTagMethod = nmsItemstackClass.getMethod("setTag", new Class[] { nbtTagCompoundClass });// d
|
||||
nbtSetMethod = nbtTagCompoundClass.getMethod("set", new Class[] { String.class, nbtBaseClass });// a
|
||||
// nbtListAddSetMethod = nbtTagListClass.getMethod("add", new Class[] { nbtBaseClass });
|
||||
setupOk = true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// try {
|
||||
// nmsItemstackClass = Class.forName("add");
|
||||
// nbtBaseClass = Class.forName("dy");
|
||||
// nbtTagStringClass = Class.forName("dx");
|
||||
// nbtTagIntClass = Class.forName("dp");
|
||||
// nbtTagCompoundClass = Class.forName("dh");
|
||||
// asNmsCopyMethod = NMSUtil.getObcClass("inventory.CraftItemStack").getMethod("asNMSCopy", new Class[] { ItemStack.class });
|
||||
// asCraftMirrorMethod = NMSUtil.getObcClass("inventory.CraftItemStack").getMethod("asCraftMirror", new Class[] { nmsItemstackClass });
|
||||
// hasTagMethod = nmsItemstackClass.getMethod("func_77942_o", new Class[0]);
|
||||
// getTagMethod = nmsItemstackClass.getMethod("func_77978_p", new Class[0]);
|
||||
// setTagMethod = nmsItemstackClass.getMethod("func_77982_d", new Class[] { nbtTagCompoundClass });
|
||||
// nbtSetMethod = nbtTagCompoundClass.getMethod("func_74782_a", new Class[] { String.class, nbtBaseClass });
|
||||
// setupOk = true;
|
||||
// } catch (Exception ex) {
|
||||
// ex.printStackTrace();
|
||||
// PluginMain.LOG.warning(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "ItemUtil setup fail. Some functions are unavailable."));
|
||||
// }
|
||||
PluginMain.LOG.warning(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "ItemUtil setup fail. Some functions are unavailable."));
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack addEnchantLight(ItemStack item) {
|
||||
item.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 0);
|
||||
if (!NMSUtil.getServerVersion().startsWith("v1_7_") && setupOk) {
|
||||
try {
|
||||
Object nmsItemstack = asNmsCopyMethod.invoke(null, new Object[] { item });
|
||||
if (nmsItemstack == null) {
|
||||
return item;
|
||||
}
|
||||
Object nbtCompound = null;
|
||||
if (((Boolean) hasTagMethod.invoke(nmsItemstack, new Object[0])).booleanValue()) {
|
||||
nbtCompound = getTagMethod.invoke(nmsItemstack, new Object[0]);
|
||||
} else {
|
||||
nbtCompound = nbtTagCompoundClass.newInstance();
|
||||
setTagMethod.invoke(nmsItemstack, new Object[] { nbtCompound });
|
||||
}
|
||||
if (nbtCompound == null) {
|
||||
return item;
|
||||
}
|
||||
Object nbtHideFlags = nbtTagIntClass.getConstructor(int.class).newInstance(1);
|
||||
nbtSetMethod.invoke(nbtCompound, new Object[] { "HideFlags", nbtHideFlags });
|
||||
return (ItemStack) asCraftMirrorMethod.invoke(null, new Object[] { nmsItemstack });
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack addSkullOwner(ItemStack item, String name) {
|
||||
if (setupOk) {
|
||||
try {
|
||||
Object nmsItemstack = asNmsCopyMethod.invoke(null, new Object[] { item });
|
||||
if (nmsItemstack == null) {
|
||||
return item;
|
||||
}
|
||||
Object nbtCompound = null;
|
||||
if (((Boolean) hasTagMethod.invoke(nmsItemstack, new Object[0])).booleanValue()) {
|
||||
nbtCompound = getTagMethod.invoke(nmsItemstack, new Object[0]);
|
||||
} else {
|
||||
nbtCompound = nbtTagCompoundClass.newInstance();
|
||||
setTagMethod.invoke(nmsItemstack, new Object[] { nbtCompound });
|
||||
}
|
||||
if (nbtCompound == null) {
|
||||
return item;
|
||||
}
|
||||
Object nbtString = nbtTagStringClass.getConstructor(String.class).newInstance(name);
|
||||
nbtSetMethod.invoke(nbtCompound, new Object[] { "SkullOwner", nbtString });
|
||||
return (ItemStack) asCraftMirrorMethod.invoke(null, new Object[] { nmsItemstack });
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
26
src/main/gg/frog/mc/permissionstime/utils/nms/NMSUtil.java
Normal file
26
src/main/gg/frog/mc/permissionstime/utils/nms/NMSUtil.java
Normal file
@ -0,0 +1,26 @@
|
||||
package gg.frog.mc.permissionstime.utils.nms;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class NMSUtil {
|
||||
|
||||
private static String serverVersion;
|
||||
|
||||
static {
|
||||
String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
||||
serverVersion = packageName.substring(packageName.lastIndexOf('.') + 1);
|
||||
}
|
||||
|
||||
public static String getServerVersion() {
|
||||
return serverVersion;
|
||||
}
|
||||
|
||||
public static Class<?> getNmsClass(String name) throws ClassNotFoundException {
|
||||
return Class.forName("net.minecraft.server." + getServerVersion() + "." + name);
|
||||
}
|
||||
|
||||
public static Class<?> getObcClass(String name) throws ClassNotFoundException {
|
||||
return Class.forName("org.bukkit.craftbukkit." + getServerVersion() + "." + name);
|
||||
}
|
||||
|
||||
}
|
@ -12,8 +12,17 @@ packages:
|
||||
# Permission package display name.
|
||||
displayName: '&4Test Package'
|
||||
# 显示的物品类型.
|
||||
# 可以使用id, 但不可与type同时使用.
|
||||
# 可以定义物品的种类, 特殊的如头颅可以指定哪个玩家的头颅.
|
||||
# Show the type of item.
|
||||
# You can use 'id', but you can't use 'type' at the same time.
|
||||
# You can define the type of item, such as skull can set which player's head.
|
||||
#id: 397
|
||||
#type: SKULL_ITEM:5
|
||||
#type: SKULL_ITEM:MHF_Present1
|
||||
type: NETHER_STAR
|
||||
# 是否有附魔发光的特效
|
||||
glowing: false
|
||||
# 标签.
|
||||
# Lores.
|
||||
lores:
|
||||
|
Loading…
Reference in New Issue
Block a user