1
1
mirror of https://github.com/geekfrog/PermissionsTime.git synced 2024-11-21 23:08:48 +00:00

跨服与非跨服权限包同名兼容处理

This commit is contained in:
GeekFrog 2017-08-02 00:30:32 +08:00
parent a11adf481f
commit df53c5e651
6 changed files with 86 additions and 64 deletions

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>gg.frog.mc</groupId> <groupId>gg.frog.mc</groupId>
<artifactId>permissionstime</artifactId> <artifactId>permissionstime</artifactId>
<version>0.3.0-SNAPSHOT</version> <version>0.3.1-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>PermissionsTime</name> <name>PermissionsTime</name>
<description>支持跨服的权限限时插件</description> <description>支持跨服的权限限时插件</description>

View File

@ -16,45 +16,53 @@ import gg.frog.mc.permissionstime.utils.StrUtil;
public class GetCmd implements Runnable { public class GetCmd implements Runnable {
private PluginMain pm; private PluginMain pm;
private SqlManager sm; private SqlManager sm;
private String[] args; private String[] args;
private CommandSender sender; private CommandSender sender;
public GetCmd(PluginMain pm, CommandSender sender, String[] args) { public GetCmd(PluginMain pm, CommandSender sender, String[] args) {
this.pm = pm; this.pm = pm;
this.sm = pm.getSqlManager(); this.sm = pm.getSqlManager();
this.sender = sender; this.sender = sender;
this.args = args; this.args = args;
} }
@Override @Override
public void run() { public void run() {
if (args.length == 2) { if (args.length == 2) {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING)); sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
OfflinePlayer p = pm.getOfflinePlayer(args[1]); OfflinePlayer p = pm.getOfflinePlayer(args[1]);
if (p != null) { if (p != null) {
List<PlayerDataBean> ps = sm.getTime(p.getUniqueId().toString()); List<PlayerDataBean> ps = sm.getTime(p.getUniqueId().toString());
if (ps.size() > 0) { if (ps.size() > 0) {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NUM_OF_PACKAGES, args[1], ps.size())); sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NUM_OF_PACKAGES,
for (PlayerDataBean pdb : ps) { args[1], ps.size()));
String expireString = StrUtil.timestampToString(pdb.getExpire()); for (PlayerDataBean pdb : ps) {
PermissionPackageBean pc = PackagesCfg.PACKAGES.get(pdb.getPackageName()); String expireString = StrUtil.timestampToString(pdb.getExpire());
if (pc != null) { PermissionPackageBean pc = PackagesCfg.PACKAGES.get(pdb.getPackageName());
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_EXPIRATION_DATE, pdb.getGlobal() ? "*" : "", pc.getDisplayName(), pdb.getPackageName(), expireString, StrUtil.getLeftTime(pdb.getExpire()))); if (!pdb.getGlobal() || pc != null) {
} else { sender.sendMessage(StrUtil.messageFormat(
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_EXPIRATION_DATE, pdb.getGlobal() ? "*" : "", LangCfg.MSG_UNKNOWN_PACKAGE, pdb.getPackageName(), expireString, StrUtil.getLeftTime(pdb.getExpire()))); PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_EXPIRATION_DATE, pdb.getGlobal() ? "*" : "",
} pc != null ? pc.getDisplayName() : LangCfg.MSG_UNKNOWN_PACKAGE,
} pdb.getPackageName(), expireString, StrUtil.getLeftTime(pdb.getExpire())));
} else { } else {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_DATA)); sender.sendMessage(
} StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_EXPIRATION_DATE,
} else { pdb.getGlobal() ? "*" : "", LangCfg.MSG_UNKNOWN_PACKAGE,
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PLAYER, args[1])); pdb.getPackageName(), expireString, StrUtil.getLeftTime(pdb.getExpire())));
} }
} else { }
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH)); } else {
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_GET, pm.PLUGIN_NAME_LOWER_CASE)); sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_DATA));
} }
} } else {
sender.sendMessage(
StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PLAYER, args[1]));
}
} else {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_GET, pm.PLUGIN_NAME_LOWER_CASE));
}
}
} }

View File

@ -10,6 +10,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import gg.frog.mc.permissionstime.config.LangCfg; import gg.frog.mc.permissionstime.config.LangCfg;
import gg.frog.mc.permissionstime.config.PackagesCfg; import gg.frog.mc.permissionstime.config.PackagesCfg;
import gg.frog.mc.permissionstime.model.cfg.PermissionPackageBean;
import gg.frog.mc.permissionstime.model.db.PlayerDataBean; import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
import gg.frog.mc.permissionstime.utils.StrUtil; import gg.frog.mc.permissionstime.utils.StrUtil;
@ -18,8 +19,9 @@ public class PlayerPermissionShow {
public static void show(Player p, List<PlayerDataBean> pdbList) { public static void show(Player p, List<PlayerDataBean> pdbList) {
Inventory inventory = Bukkit.createInventory(null, (pdbList.size() % 9 == 0 ? pdbList.size() : (pdbList.size() / 9 + 1) * 9), StrUtil.messageFormat(LangCfg.INVENTORY_NAME + "&r&5&9&2&0&r")); Inventory inventory = Bukkit.createInventory(null, (pdbList.size() % 9 == 0 ? pdbList.size() : (pdbList.size() / 9 + 1) * 9), StrUtil.messageFormat(LangCfg.INVENTORY_NAME + "&r&5&9&2&0&r"));
for (PlayerDataBean pdb : pdbList) { for (PlayerDataBean pdb : pdbList) {
ItemStack item = PackagesCfg.PACKAGE_ITEMS.get(pdb.getPackageName()); PermissionPackageBean ppb = PackagesCfg.PACKAGES.get(pdb.getPackageName());
if (item != null) { if (ppb != null && pdb.getGlobal() == ppb.getGlobal()) {
ItemStack item = PackagesCfg.PACKAGE_ITEMS.get(pdb.getPackageName());
ItemStack tItem = item.clone(); ItemStack tItem = item.clone();
ItemMeta meta = tItem.getItemMeta(); ItemMeta meta = tItem.getItemMeta();
List<String> lores = meta.getLore(); List<String> lores = meta.getLore();

View File

@ -246,7 +246,7 @@ public class PermissionPackageBean implements IConfigBean {
} }
} }
PermissionPackageBean p = PackagesCfg.PACKAGES.get(pdb.getPackageName()); PermissionPackageBean p = PackagesCfg.PACKAGES.get(pdb.getPackageName());
if (p != null) { if (p != null && pdb.getGlobal() == p.getGlobal()) {
addPpb.getPermissions().addAll(p.getPermissions()); addPpb.getPermissions().addAll(p.getPermissions());
subPpb.getPermissions().removeAll(p.getPermissions()); subPpb.getPermissions().removeAll(p.getPermissions());
addPpb.getGroups().addAll(p.getGroups()); addPpb.getGroups().addAll(p.getGroups());
@ -308,27 +308,32 @@ public class PermissionPackageBean implements IConfigBean {
for (PlayerDataBean playerData : playerDataList) { for (PlayerDataBean playerData : playerDataList) {
if (playerData.getExpire() < now) { if (playerData.getExpire() < now) {
PermissionPackageBean packageBean = PackagesCfg.PACKAGES.get(playerData.getPackageName()); PermissionPackageBean packageBean = PackagesCfg.PACKAGES.get(playerData.getPackageName());
plugin.getServer().getScheduler().runTask(plugin, new Runnable() { if ((packageBean == null && !playerData.getGlobal())
@Override || (packageBean != null && playerData.getGlobal() == packageBean.getGlobal())) {
public void run() { plugin.getServer().getScheduler().runTask(plugin, new Runnable() {
Player p = player.getPlayer(); @Override
if (p != null) { public void run() {
p.sendMessage(StrUtil.messageFormat( Player p = player.getPlayer();
PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_IS_EXPIRATION_DATE, if (p != null) {
packageBean != null ? packageBean.getDisplayName() : LangCfg.MSG_UNKNOWN_PACKAGE, p.sendMessage(
playerData.getPackageName())); StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_IS_EXPIRATION_DATE,
for (String commands : packageBean.getExpireCommands()) { packageBean != null ? packageBean.getDisplayName()
try { : LangCfg.MSG_UNKNOWN_PACKAGE,
commands = StrUtil.messageFormat(player.getPlayer(), commands); playerData.getPackageName()));
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), commands); for (String commands : packageBean.getExpireCommands()) {
} catch (Exception e) { try {
e.printStackTrace(); commands = StrUtil.messageFormat(player.getPlayer(), commands);
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(),
commands);
} catch (Exception e) {
e.printStackTrace();
}
} }
} }
} }
} });
}); plugin.getSqlManager().delById(playerData.getId());
plugin.getSqlManager().delById(playerData.getId()); }
} }
} }
} }

View File

@ -1,5 +1,5 @@
name: PermissionsTime name: PermissionsTime
version: 0.3.0-SNAPSHOT version: 0.3.1-SNAPSHOT
main: gg.frog.mc.permissionstime.PluginMain main: gg.frog.mc.permissionstime.PluginMain
author: GeekFrog author: GeekFrog
softdepend: softdepend:

View File

@ -3,7 +3,7 @@
[align=center][table=98%,#4169e1] [align=center][table=98%,#4169e1]
[tr][td][align=center][size=6][color=#ffffff][b]唠叨[/b][/color][/size][/align][/td][/tr] [tr][td][align=center][size=6][color=#ffffff][b]唠叨[/b][/color][/size][/align][/td][/tr]
[/table][/align][align=center][table=98%,gray] [/table][/align][align=center][table=98%,gray]
[tr][td][align=center][size=4][color=#ffa500][b]这是本人第一个发布的插件, 希望能让大家满意![/b][/color][/size][/align][align=center][size=4][color=#dda0dd][b]本插件需要JAVA8[/b][/color][/size][/align][align=center][size=4][color=#98fb98][b]下载地址在最下面![/b][/color][/size][/align][align=center][size=4][color=#c0c0c0][b]最新版本: [/b][/color][b][color=#8b0000]0.3.0[/color][color=#c0c0c0]推荐大家使用新版本只需替换插件的jar包和语言文件即可[/color][/b][/size][/align][/td][/tr] [tr][td][align=center][size=4][color=#ffa500][b]这是本人第一个发布的插件, 希望能让大家满意![/b][/color][/size][/align][align=center][size=4][color=#dda0dd][b]本插件需要JAVA8[/b][/color][/size][/align][align=center][size=4][color=#98fb98][b]下载地址在最下面![/b][/color][/size][/align][align=center][size=4][color=#c0c0c0][b]最新版本: [/b][/color][b][color=#8b0000]0.3.1[/color][color=#c0c0c0]推荐大家使用新版本只需替换插件的jar包和语言文件即可[/color][/b][/size][/align][/td][/tr]
[/table][/align][align=center][table=98%,#4169e1] [/table][/align][align=center][table=98%,#4169e1]
[tr][td][align=center][size=6][color=#ffffff][b]前言[/b][/color][/size][/align][/td][/tr] [tr][td][align=center][size=6][color=#ffffff][b]前言[/b][/color][/size][/align][/td][/tr]
[/table][/align][align=center][table=98%,gray] [/table][/align][align=center][table=98%,gray]
@ -136,6 +136,11 @@ packages:
groups: groups:
- group1 - group1
- group2:world1 - group2:world1
# 权限包过期后执行的控制台命令
# Package expire console commands.
expireCommands:
- 'say %player% 的权限包到期了.'
- 'say 请及时续期.'
[/code] [/code]
[font=-apple-system, BlinkMacSystemFont,][color=#000000]简体中文 zh-cn.yml[/color][/font][code] [font=-apple-system, BlinkMacSystemFont,][color=#000000]简体中文 zh-cn.yml[/color][/font][code]
@ -198,6 +203,8 @@ cmd:
[tr][td][align=center][size=6][color=#ffffff][b]更新日志[/b][/color][/size][/align][/td][/tr] [tr][td][align=center][size=6][color=#ffffff][b]更新日志[/b][/color][/size][/align][/td][/tr]
[/table][/align][align=center][table=98%,gray] [/table][/align][align=center][table=98%,gray]
[tr][td][spoiler][size=4][b][url=http://ci.frog.gg/jenkins/job/PermissionsTime/changes]详细的更新记录[/url] [tr][td][spoiler][size=4][b][url=http://ci.frog.gg/jenkins/job/PermissionsTime/changes]详细的更新记录[/url]
[color=#ffffff]2017年8月2日 V0.3.1[/color][quote][color=#000000]
1.跨服与非跨服权限包同名兼容处理[/color][/quote]
[color=#ffffff]2017年8月1日 V0.3.0[/color][quote][color=#000000] [color=#ffffff]2017年8月1日 V0.3.0[/color][quote][color=#000000]
1.权限包到期可执行自定义命令[/color][/quote] 1.权限包到期可执行自定义命令[/color][/quote]
[color=#ffffff]2017年7月31日 V0.2.4[/color][quote][color=#000000] [color=#ffffff]2017年7月31日 V0.2.4[/color][quote][color=#000000]
@ -227,7 +234,7 @@ cmd:
[/table][/align][align=center][table=98%,#4169e1] [/table][/align][align=center][table=98%,#4169e1]
[tr][td][align=center][size=6][color=#ffffff][b]下载地址[/b][/color][/size][/align][/td][/tr] [tr][td][align=center][size=6][color=#ffffff][b]下载地址[/b][/color][/size][/align][/td][/tr]
[/table][/align][align=center][table=98%,gray] [/table][/align][align=center][table=98%,gray]
[tr][td][size=4][b][align=center][color=#000] [url=http://ci.frog.gg/jenkins/job/PermissionsTime/64/]V0.3.0版下载地址[/url][/color][/align][align=center][color=#ffffff]前置插件:[/color][color=#000][url=https://dev.bukkit.org/projects/vault/files]vault[/url][/color][color=#000000] , [/color][color=#000][url=https://dev.bukkit.org/projects/sqlibrary/files]sqlibrary[/url][/color][/align][align=center][color=#ffffff]前置插件最好去原站下载适合的版本, 如果无法下载可以在帖内下载。[/color][/align] [tr][td][size=4][b][align=center][color=#000] [url=http://ci.frog.gg/jenkins/job/PermissionsTime/65/]V0.3.1版下载地址[/url][/color][/align][align=center][color=#ffffff]前置插件:[/color][color=#000][url=https://dev.bukkit.org/projects/vault/files]vault[/url][/color][color=#000000] , [/color][color=#000][url=https://dev.bukkit.org/projects/sqlibrary/files]sqlibrary[/url][/color][/align][align=center][color=#ffffff]前置插件最好去原站下载适合的版本, 如果无法下载可以在帖内下载。[/color][/align]
[align=center][b][color=#ffffff]帖内下载:[/color][/b][/align][align=center][color=#000][attach]1101088[/attach][/color][/align][align=center][color=#000][b][color=#ff0000]前置插件必须安装[/color][/b][/color][/align][align=center][color=#000][attach]1101089[/attach][/color][/align][align=center][color=#000][attach]1101090[/attach][/color][/align][align=center][color=#000][attach]1101110[/attach][/color][/align] [align=center][b][color=#ffffff]帖内下载:[/color][/b][/align][align=center][color=#000][attach]1101088[/attach][/color][/align][align=center][color=#000][b][color=#ff0000]前置插件必须安装[/color][/b][/color][/align][align=center][color=#000][attach]1101089[/attach][/color][/align][align=center][color=#000][attach]1101090[/attach][/color][/align][align=center][color=#000][attach]1101110[/attach][/color][/align]
[align=center][color=#000][color=#ff0000][b]如果大家觉得好用就给点金粒吧,如果不好请告诉我,帮助我改进。[/b][/color][/color][/align][align=center][color=#000][b]BUG可以在帖内回复我。[/b][/color][/align][/b][/size][/td][/tr] [align=center][color=#000][color=#ff0000][b]如果大家觉得好用就给点金粒吧,如果不好请告诉我,帮助我改进。[/b][/color][/color][/align][align=center][color=#000][b]BUG可以在帖内回复我。[/b][/color][/align][/b][/size][/td][/tr]
[/table][/align][align=center][table=98%,#4169e1] [/table][/align][align=center][table=98%,#4169e1]