mirror of
https://github.com/geekfrog/PermissionsTime.git
synced 2024-11-21 23:08:48 +00:00
提示剩余时间
This commit is contained in:
parent
de87f66f06
commit
2523df87e1
@ -50,6 +50,7 @@
|
||||
- **检测是否有新版本**
|
||||
- **提示权限包到期**
|
||||
- **玩家登录时删除过期的或无效数据**
|
||||
- **提示剩余时间**
|
||||
- 取消前置插件
|
||||
|
||||
|
||||
|
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>gg.frog.mc</groupId>
|
||||
<artifactId>permissionstime</artifactId>
|
||||
<version>0.2.1-SNAPSHOT</version>
|
||||
<version>0.2.2-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>PermissionsTime</name>
|
||||
<description>支持跨服的权限限时插件</description>
|
||||
|
@ -41,9 +41,9 @@ public class GetCmd implements Runnable {
|
||||
String expireString = StrUtil.timestampToString(pdb.getExpire());
|
||||
PermissionPackageBean pc = PackagesCfg.PACKAGES.get(pdb.getPackageName());
|
||||
if (pc != null) {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_EXPIRATION_DATE, pdb.getGlobal() ? "*" : "", pc.getDisplayName(), pdb.getPackageName(), expireString));
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_EXPIRATION_DATE, pdb.getGlobal() ? "*" : "", pc.getDisplayName(), pdb.getPackageName(), expireString, StrUtil.getLeftTime(pdb.getExpire())));
|
||||
} else {
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_EXPIRATION_DATE, pdb.getGlobal() ? "*" : "", LangCfg.MSG_UNKNOWN_PACKAGE, pdb.getPackageName(), expireString));
|
||||
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_EXPIRATION_DATE, pdb.getGlobal() ? "*" : "", LangCfg.MSG_UNKNOWN_PACKAGE, pdb.getPackageName(), expireString, StrUtil.getLeftTime(pdb.getExpire())));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -12,7 +12,8 @@ import gg.frog.mc.permissionstime.utils.config.PluginConfig;
|
||||
public class LangCfg extends PluginConfig {
|
||||
|
||||
public static String INVENTORY_NAME = null;
|
||||
public static String EXPIRATION_DATE = null;
|
||||
public static String EXPIRATION_TIME = null;
|
||||
public static String LEFT_TIME = null;
|
||||
public static String TIME_UNIT_D = null;
|
||||
public static String TIME_UNIT_H = null;
|
||||
public static String TIME_UNIT_M = null;
|
||||
@ -67,7 +68,8 @@ public class LangCfg extends PluginConfig {
|
||||
@Override
|
||||
protected void loadToDo() {
|
||||
INVENTORY_NAME = getConfig().getString("inventoryName", "&4===Permissions Packages===");
|
||||
EXPIRATION_DATE = getConfig().getString("expirationDate", "&4Expiration date: {0}");
|
||||
EXPIRATION_TIME = getConfig().getString("expirationTime", "&4Expiration time: {0}");
|
||||
LEFT_TIME = getConfig().getString("leftTime", "&4Left time: About {0}{1} {2}{3} {4}{5}");
|
||||
TIME_UNIT_D = getConfig().getString("timeUnitD", "day(s)");
|
||||
TIME_UNIT_H = getConfig().getString("timeUnitH", "hour(s)");
|
||||
TIME_UNIT_M = getConfig().getString("timeUnitM", "minute(s)");
|
||||
@ -98,7 +100,7 @@ public class LangCfg extends PluginConfig {
|
||||
MSG_DEL_ALL = getConfig().getString("msg.delAll", "&2Remove all packages for player {0}");
|
||||
MSG_DEL_ALL_FAIL = getConfig().getString("msg.delAllFail", "&4Failed to remove all packages for player {0}");
|
||||
MSG_NUM_OF_PACKAGES = getConfig().getString("msg.numOfPackages", "====={0} has {1} packages=====");
|
||||
MSG_EXPIRATION_DATE = getConfig().getString("msg.expirationDate", "{0}packages: {1}({2}), Expiration date: {3}");
|
||||
MSG_EXPIRATION_DATE = getConfig().getString("msg.expirationDate", "{0}packages: {1}({2}), Expiration date: {3}, {4}");
|
||||
MSG_UNKNOWN_PACKAGE = getConfig().getString("msg.unknownPackage", "Unknown Packages");
|
||||
MSG_IS_EXPIRATION_DATE = getConfig().getString("msg.isExpirationDate", "Your package: {0}({1})&r has expired.");
|
||||
|
||||
|
@ -23,7 +23,8 @@ public class PlayerPermissionShow {
|
||||
ItemStack tItem = item.clone();
|
||||
ItemMeta meta = tItem.getItemMeta();
|
||||
List<String> lores = meta.getLore();
|
||||
lores.add(StrUtil.messageFormat(LangCfg.EXPIRATION_DATE, StrUtil.timestampToString(pdb.getExpire())));
|
||||
lores.add(StrUtil.messageFormat(LangCfg.EXPIRATION_TIME, StrUtil.timestampToString(pdb.getExpire())));
|
||||
lores.add(StrUtil.getLeftTime(pdb.getExpire()));
|
||||
meta.setLore(lores);
|
||||
tItem.setItemMeta(meta);
|
||||
inventory.addItem(tItem);
|
||||
|
@ -298,7 +298,7 @@ public class PermissionPackageBean implements IConfigBean {
|
||||
public void run() {
|
||||
Player p = player.getPlayer();
|
||||
if (p != null) {
|
||||
p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4你的权限包: &r{0}({1}), 已到期.", packageBean != null ? packageBean.getDisplayName() : LangCfg.MSG_UNKNOWN_PACKAGE, playerData.getPackageName()));
|
||||
p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_IS_EXPIRATION_DATE, packageBean != null ? packageBean.getDisplayName() : LangCfg.MSG_UNKNOWN_PACKAGE, playerData.getPackageName()));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -5,9 +5,15 @@ import java.util.Date;
|
||||
|
||||
import org.apache.commons.lang.time.DateFormatUtils;
|
||||
|
||||
import gg.frog.mc.permissionstime.config.LangCfg;
|
||||
import gg.frog.mc.permissionstime.database.IPlayerDataDao;
|
||||
|
||||
public class StrUtil {
|
||||
|
||||
private static String dfs = "yyyy/MM/dd HH:mm:ss";
|
||||
private static long dt = 24 * 60 * IPlayerDataDao.TIME_UNIT;
|
||||
private static long ht = 60 * IPlayerDataDao.TIME_UNIT;
|
||||
private static long mt = IPlayerDataDao.TIME_UNIT;
|
||||
|
||||
public static String messageFormat(String src, Object... args) {
|
||||
return MessageFormat.format(src, args).replace("&", "§").replace("\\n", "\n");
|
||||
@ -24,4 +30,13 @@ public class StrUtil {
|
||||
public static String nowTimeString() {
|
||||
return DateFormatUtils.format(new Date(), dfs);
|
||||
}
|
||||
|
||||
public static String getLeftTime(long time) {
|
||||
long leftTime = time - new Date().getTime();
|
||||
long d = leftTime / dt;
|
||||
long h = (leftTime % dt) / ht;
|
||||
long m = (leftTime % ht) / mt;
|
||||
return messageFormat(LangCfg.LEFT_TIME, d, LangCfg.TIME_UNIT_D, h, LangCfg.TIME_UNIT_H, m, LangCfg.TIME_UNIT_M);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
inventoryName: '&4===Permissions Packages==='
|
||||
expirationDate: '&4Expiration date: {0}'
|
||||
expirationTime: '&4Expiration date: {0}'
|
||||
leftTime: '&4Left time: About {0}{1} {2}{3} {4}{5}'
|
||||
timeUnitD: 'day(s)'
|
||||
timeUnitH: 'hour(s)'
|
||||
timeUnitM: 'minute(s)'
|
||||
@ -30,7 +31,7 @@ msg:
|
||||
delAll: '&2Remove all packages for player {0}'
|
||||
delAllFail: '&4Failed to remove all packages for player {0}'
|
||||
numOfPackages: '====={0} has {1} packages====='
|
||||
expirationDate: '{0}packages: {1}({2}), Expiration date: {3}'
|
||||
expirationDate: '{0}packages: {1}({2}), Expiration date: {3}, {4}'
|
||||
unknownPackage: 'Unknown Packages'
|
||||
isExpirationDate: 'Your package: {0}({1})&r has expired.'
|
||||
cmd:
|
||||
|
@ -1,5 +1,6 @@
|
||||
inventoryName: '&4===权限仓库==='
|
||||
expirationDate: '&4到期时间: {0}.'
|
||||
expirationTime: '&4到期时间: {0}.'
|
||||
leftTime: '&4剩余时间: 大约 {0}{1} {2}{3} {4}{5}'
|
||||
timeUnitD: '天'
|
||||
timeUnitH: '小时'
|
||||
timeUnitM: '分钟'
|
||||
@ -30,7 +31,7 @@ msg:
|
||||
delAll: '&2删除玩家 {0} 的所有权限包.'
|
||||
delAllFail: '&4未删除玩家 {0} 的 所有权限包.'
|
||||
numOfPackages: '====={0}有{1}个权限包====='
|
||||
expirationDate: '{0}权限包: {1}({2}), 到期时间: {3}'
|
||||
expirationDate: '{0}权限包: {1}({2}), 到期时间: {3}, {4}'
|
||||
unknownPackage: '未知权限包'
|
||||
isExpirationDate: '你的权限包: {0}({1})&r, 已到期.'
|
||||
cmd:
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: PermissionsTime
|
||||
version: 0.2.1-SNAPSHOT
|
||||
version: 0.2.2-SNAPSHOT
|
||||
main: gg.frog.mc.permissionstime.PluginMain
|
||||
author: GeekFrog
|
||||
softdepend:
|
||||
|
Loading…
Reference in New Issue
Block a user