新增权限节点配置,允许通过权限节点控制玩家行为
This commit is contained in:
parent
3ffab50c9b
commit
b52fce2479
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>cn.lunadeer</groupId>
|
<groupId>cn.lunadeer</groupId>
|
||||||
<artifactId>MiniPlayerTitle</artifactId>
|
<artifactId>MiniPlayerTitle</artifactId>
|
||||||
<version>4.2.8</version>
|
<version>4.3.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>MiniPlayerTitle</name>
|
<name>MiniPlayerTitle</name>
|
||||||
|
@ -13,16 +13,6 @@ import static cn.lunadeer.miniplayertitle.MiniPlayerTitle.usingPapi;
|
|||||||
|
|
||||||
|
|
||||||
public class Apis {
|
public class Apis {
|
||||||
public static boolean notOpOrConsole(CommandSender sender) {
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
if (!player.isOp()) {
|
|
||||||
Notification.warn(player, "你没有权限使用此命令");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateName(Player player, @Nullable TitleDTO title) {
|
public static void updateName(Player player, @Nullable TitleDTO title) {
|
||||||
MiniPlayerTitle.instance.setPlayerUsingTitle(player.getUniqueId(), title);
|
MiniPlayerTitle.instance.setPlayerUsingTitle(player.getUniqueId(), title);
|
||||||
|
@ -8,7 +8,6 @@ import org.bukkit.command.CommandSender;
|
|||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
import static cn.lunadeer.miniplayertitle.commands.Apis.notOpOrConsole;
|
|
||||||
|
|
||||||
public class PlayerManage {
|
public class PlayerManage {
|
||||||
|
|
||||||
@ -20,7 +19,7 @@ public class PlayerManage {
|
|||||||
* @param args String[]
|
* @param args String[]
|
||||||
*/
|
*/
|
||||||
public static void addCoin(CommandSender sender, String[] args) {
|
public static void addCoin(CommandSender sender, String[] args) {
|
||||||
if (notOpOrConsole(sender)) return;
|
if (!sender.hasPermission("mplt.admin")) return;
|
||||||
try {
|
try {
|
||||||
PlayerInfoDTO playerInfo = PlayerInfoDTO.get(args[1]);
|
PlayerInfoDTO playerInfo = PlayerInfoDTO.get(args[1]);
|
||||||
if (playerInfo == null) {
|
if (playerInfo == null) {
|
||||||
@ -46,7 +45,7 @@ public class PlayerManage {
|
|||||||
* @param args String[]
|
* @param args String[]
|
||||||
*/
|
*/
|
||||||
public static void setCoin(CommandSender sender, String[] args) {
|
public static void setCoin(CommandSender sender, String[] args) {
|
||||||
if (notOpOrConsole(sender)) return;
|
if (!sender.hasPermission("mplt.admin")) return;
|
||||||
try {
|
try {
|
||||||
PlayerInfoDTO playerInfo = PlayerInfoDTO.get(args[1]);
|
PlayerInfoDTO playerInfo = PlayerInfoDTO.get(args[1]);
|
||||||
if (playerInfo == null) {
|
if (playerInfo == null) {
|
||||||
@ -72,7 +71,7 @@ public class PlayerManage {
|
|||||||
* @param args String[]
|
* @param args String[]
|
||||||
*/
|
*/
|
||||||
public static void grantTitle(CommandSender sender, String[] args) {
|
public static void grantTitle(CommandSender sender, String[] args) {
|
||||||
if (notOpOrConsole(sender)) return;
|
if (!sender.hasPermission("mplt.admin")) return;
|
||||||
try {
|
try {
|
||||||
PlayerInfoDTO playerInfo = PlayerInfoDTO.get(args[1]);
|
PlayerInfoDTO playerInfo = PlayerInfoDTO.get(args[1]);
|
||||||
if (playerInfo == null) {
|
if (playerInfo == null) {
|
||||||
|
@ -11,7 +11,6 @@ import net.kyori.adventure.text.Component;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import static cn.lunadeer.miniplayertitle.commands.Apis.notOpOrConsole;
|
|
||||||
import static cn.lunadeer.miniplayertitle.commands.Apis.updateName;
|
import static cn.lunadeer.miniplayertitle.commands.Apis.updateName;
|
||||||
|
|
||||||
public class TitleManage {
|
public class TitleManage {
|
||||||
@ -23,7 +22,7 @@ public class TitleManage {
|
|||||||
* @param args String[]
|
* @param args String[]
|
||||||
*/
|
*/
|
||||||
public static void createTitle(CommandSender sender, String[] args) {
|
public static void createTitle(CommandSender sender, String[] args) {
|
||||||
if (notOpOrConsole(sender)) return;
|
if (!sender.hasPermission("mplt.admin")) return;
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
Notification.warn(sender, "用法: /mplt create_title <称号名称> [称号描述]");
|
Notification.warn(sender, "用法: /mplt create_title <称号名称> [称号描述]");
|
||||||
return;
|
return;
|
||||||
@ -46,7 +45,7 @@ public class TitleManage {
|
|||||||
*/
|
*/
|
||||||
public static void deleteTitle(CommandSender sender, String[] args) {
|
public static void deleteTitle(CommandSender sender, String[] args) {
|
||||||
try {
|
try {
|
||||||
if (notOpOrConsole(sender)) return;
|
if (!sender.hasPermission("mplt.admin")) return;
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
Notification.warn(sender, "用法: /mplt delete_title <称号ID>");
|
Notification.warn(sender, "用法: /mplt delete_title <称号ID>");
|
||||||
return;
|
return;
|
||||||
@ -80,7 +79,7 @@ public class TitleManage {
|
|||||||
*/
|
*/
|
||||||
public static void editTitleName(CommandSender sender, String[] args) {
|
public static void editTitleName(CommandSender sender, String[] args) {
|
||||||
try {
|
try {
|
||||||
if (notOpOrConsole(sender)) return;
|
if (!sender.hasPermission("mplt.admin")) return;
|
||||||
if (args.length != 3) {
|
if (args.length != 3) {
|
||||||
Notification.warn(sender, "用法: /mplt set_title <称号ID> <称号名称>");
|
Notification.warn(sender, "用法: /mplt set_title <称号ID> <称号名称>");
|
||||||
return;
|
return;
|
||||||
@ -110,7 +109,7 @@ public class TitleManage {
|
|||||||
*/
|
*/
|
||||||
public static void editTitleDescription(CommandSender sender, String[] args) {
|
public static void editTitleDescription(CommandSender sender, String[] args) {
|
||||||
try {
|
try {
|
||||||
if (notOpOrConsole(sender)) return;
|
if (!sender.hasPermission("mplt.admin")) return;
|
||||||
if (args.length != 3) {
|
if (args.length != 3) {
|
||||||
Notification.warn(sender, "用法: /mplt set_desc <称号ID> <称号描述>");
|
Notification.warn(sender, "用法: /mplt set_desc <称号ID> <称号描述>");
|
||||||
return;
|
return;
|
||||||
@ -143,6 +142,7 @@ public class TitleManage {
|
|||||||
Notification.error(sender, "该命令只能由玩家执行");
|
Notification.error(sender, "该命令只能由玩家执行");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!sender.hasPermission("mplt.command")) return;
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
Notification.warn(sender, "用法: /mplt use_title <背包ID> [页码]");
|
Notification.warn(sender, "用法: /mplt use_title <背包ID> [页码]");
|
||||||
return;
|
return;
|
||||||
@ -201,6 +201,7 @@ public class TitleManage {
|
|||||||
Notification.error(sender, "该命令只能由玩家执行");
|
Notification.error(sender, "该命令只能由玩家执行");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!sender.hasPermission("mplt.custom")) return;
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
if (!MiniPlayerTitle.config.isEnableCustom()) {
|
if (!MiniPlayerTitle.config.isEnableCustom()) {
|
||||||
Notification.error(sender, "自定义称号功能已关闭");
|
Notification.error(sender, "自定义称号功能已关闭");
|
||||||
|
@ -16,7 +16,6 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static cn.lunadeer.miniplayertitle.commands.Apis.notOpOrConsole;
|
|
||||||
import static cn.lunadeer.miniplayertitle.tuis.Apis.getArgPage;
|
import static cn.lunadeer.miniplayertitle.tuis.Apis.getArgPage;
|
||||||
import static cn.lunadeer.miniplayertitle.tuis.Apis.getLastArgsPage;
|
import static cn.lunadeer.miniplayertitle.tuis.Apis.getLastArgsPage;
|
||||||
|
|
||||||
@ -30,7 +29,7 @@ public class TitleShopSale {
|
|||||||
* @param args String[]
|
* @param args String[]
|
||||||
*/
|
*/
|
||||||
public static void setSale(CommandSender sender, String[] args) {
|
public static void setSale(CommandSender sender, String[] args) {
|
||||||
if (notOpOrConsole(sender)) return;
|
if (!sender.hasPermission("mplt.admin")) return;
|
||||||
TitleShopDTO titleShop = TitleShopDTO.get(Integer.valueOf(args[2]));
|
TitleShopDTO titleShop = TitleShopDTO.get(Integer.valueOf(args[2]));
|
||||||
if (titleShop == null) {
|
if (titleShop == null) {
|
||||||
Notification.error(sender, "获取详情时出现错误,详情请查看控制台日志");
|
Notification.error(sender, "获取详情时出现错误,详情请查看控制台日志");
|
||||||
@ -83,7 +82,7 @@ public class TitleShopSale {
|
|||||||
* @param args String[]
|
* @param args String[]
|
||||||
*/
|
*/
|
||||||
public static void createSale(CommandSender sender, String[] args) {
|
public static void createSale(CommandSender sender, String[] args) {
|
||||||
if (notOpOrConsole(sender)) return;
|
if (!sender.hasPermission("mplt.admin")) return;
|
||||||
TitleDTO title = TitleDTO.get(Integer.parseInt(args[1]));
|
TitleDTO title = TitleDTO.get(Integer.parseInt(args[1]));
|
||||||
if (title == null) {
|
if (title == null) {
|
||||||
Notification.error(sender, "获取称号详情时出现错误,详情请查看控制台日志");
|
Notification.error(sender, "获取称号详情时出现错误,详情请查看控制台日志");
|
||||||
@ -108,7 +107,7 @@ public class TitleShopSale {
|
|||||||
* @param args String[]
|
* @param args String[]
|
||||||
*/
|
*/
|
||||||
public static void deleteSale(CommandSender sender, String[] args) {
|
public static void deleteSale(CommandSender sender, String[] args) {
|
||||||
if (notOpOrConsole(sender)) return;
|
if (!sender.hasPermission("mplt.admin")) return;
|
||||||
TitleShopDTO titleShop = TitleShopDTO.get(Integer.valueOf(args[1]));
|
TitleShopDTO titleShop = TitleShopDTO.get(Integer.valueOf(args[1]));
|
||||||
if (titleShop == null) {
|
if (titleShop == null) {
|
||||||
Notification.error(sender, "获取详情时出现错误");
|
Notification.error(sender, "获取详情时出现错误");
|
||||||
@ -138,6 +137,7 @@ public class TitleShopSale {
|
|||||||
Notification.error(sender, "该命令只能由玩家执行");
|
Notification.error(sender, "该命令只能由玩家执行");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!sender.hasPermission("mplt.command")) return;
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
PlayerInfoDTO playerInfo = PlayerInfoDTO.get(player.getUniqueId());
|
PlayerInfoDTO playerInfo = PlayerInfoDTO.get(player.getUniqueId());
|
||||||
if (playerInfo == null) {
|
if (playerInfo == null) {
|
||||||
|
@ -32,7 +32,7 @@ public class AllTitles {
|
|||||||
Line line = Line.create()
|
Line line = Line.create()
|
||||||
.append(title.getId().toString())
|
.append(title.getId().toString())
|
||||||
.append(title.getTitleColored());
|
.append(title.getTitleColored());
|
||||||
if (player.isOp()) {
|
if (player.hasPermission("mplt.admin")) {
|
||||||
line.append(Button.createRed("删除").setExecuteCommand("/mplt delete_title " + title.getId() + " " + page).build());
|
line.append(Button.createRed("删除").setExecuteCommand("/mplt delete_title " + title.getId() + " " + page).build());
|
||||||
line.append(Button.createGreen("创建商品").setExecuteCommand("/mplt create_sale " + title.getId()).build());
|
line.append(Button.createGreen("创建商品").setExecuteCommand("/mplt create_sale " + title.getId()).build());
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ public class Menu {
|
|||||||
Line all = Line.create()
|
Line all = Line.create()
|
||||||
.append(Button.create("所有称号").setExecuteCommand("/mplt all_titles").build()).append("查看所有称号");
|
.append(Button.create("所有称号").setExecuteCommand("/mplt all_titles").build()).append("查看所有称号");
|
||||||
|
|
||||||
if (player.isOp()) {
|
if (player.hasPermission("mplt.admin")) {
|
||||||
view.add(Line.create().append(""));
|
view.add(Line.create().append(""));
|
||||||
view.add(Line.create().append("---以下选项仅OP可见---"));
|
view.add(Line.create().append("---以下选项仅OP可见---"));
|
||||||
view.add(all);
|
view.add(all);
|
||||||
|
@ -46,11 +46,11 @@ public class SaleInfo {
|
|||||||
Line price = Line.create().append("价格: ");
|
Line price = Line.create().append("价格: ");
|
||||||
if (titleShop.getPrice() <= 0) {
|
if (titleShop.getPrice() <= 0) {
|
||||||
price.append("免费");
|
price.append("免费");
|
||||||
if (player.isOp()) {
|
if (player.hasPermission("mplt.admin")) {
|
||||||
price.append(Button.create("设置价格").setExecuteCommand("/mplt set_sale price " + titleShop.getId() + " 100 " + page).build());
|
price.append(Button.create("设置价格").setExecuteCommand("/mplt set_sale price " + titleShop.getId() + " 100 " + page).build());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (player.isOp()) {
|
if (player.hasPermission("mplt.admin")) {
|
||||||
price.append(NumChanger.create(titleShop.getPrice(), "/mplt set_sale price " + titleShop.getId()).setPageNumber(page).build());
|
price.append(NumChanger.create(titleShop.getPrice(), "/mplt set_sale price " + titleShop.getId()).setPageNumber(page).build());
|
||||||
price.append(Button.create("设置为免费").setExecuteCommand("/mplt set_sale price " + titleShop.getId() + " 0 " + page).build());
|
price.append(Button.create("设置为免费").setExecuteCommand("/mplt set_sale price " + titleShop.getId() + " 0 " + page).build());
|
||||||
} else {
|
} else {
|
||||||
@ -62,11 +62,11 @@ public class SaleInfo {
|
|||||||
Line day = Line.create().append("购买天数: ");
|
Line day = Line.create().append("购买天数: ");
|
||||||
if (titleShop.getDays() <= 0) {
|
if (titleShop.getDays() <= 0) {
|
||||||
day.append("永久");
|
day.append("永久");
|
||||||
if (player.isOp()) {
|
if (player.hasPermission("mplt.admin")) {
|
||||||
day.append(Button.create("转为限时").setExecuteCommand("/mplt set_sale days " + titleShop.getId() + " 7 " + page).build());
|
day.append(Button.create("转为限时").setExecuteCommand("/mplt set_sale days " + titleShop.getId() + " 7 " + page).build());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (player.isOp()) {
|
if (player.hasPermission("mplt.admin")) {
|
||||||
day.append(NumChanger.create(titleShop.getDays(), "/mplt set_sale days " + titleShop.getId()).setPageNumber(page).build());
|
day.append(NumChanger.create(titleShop.getDays(), "/mplt set_sale days " + titleShop.getId()).setPageNumber(page).build());
|
||||||
day.append(Button.create("转为永久").setExecuteCommand("/mplt set_sale days " + titleShop.getId() + " -1 " + page).build());
|
day.append(Button.create("转为永久").setExecuteCommand("/mplt set_sale days " + titleShop.getId() + " -1 " + page).build());
|
||||||
} else {
|
} else {
|
||||||
@ -78,12 +78,12 @@ public class SaleInfo {
|
|||||||
Line amount = Line.create().append("剩余数量: ");
|
Line amount = Line.create().append("剩余数量: ");
|
||||||
if (titleShop.getAmount() == -1) {
|
if (titleShop.getAmount() == -1) {
|
||||||
amount.append("无限");
|
amount.append("无限");
|
||||||
if (player.isOp()) {
|
if (player.hasPermission("mplt.admin")) {
|
||||||
amount.append(Button.create("转为限量").setExecuteCommand("/mplt set_sale amount " + titleShop.getId() + " 0 " + page).build());
|
amount.append(Button.create("转为限量").setExecuteCommand("/mplt set_sale amount " + titleShop.getId() + " 0 " + page).build());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (player.isOp()) {
|
if (player.hasPermission("mplt.admin")) {
|
||||||
amount.append(NumChanger.create(titleShop.getAmount(), "/mplt set_sale amount " + titleShop.getId()).setPageNumber(page).build());
|
amount.append(NumChanger.create(titleShop.getAmount(), "/mplt set_sale amount " + titleShop.getId()).setPageNumber(page).build());
|
||||||
amount.append(Button.create("转为无限").setExecuteCommand("/mplt set_sale amount " + titleShop.getId() + " -1 " + page).build());
|
amount.append(Button.create("转为无限").setExecuteCommand("/mplt set_sale amount " + titleShop.getId() + " -1 " + page).build());
|
||||||
} else {
|
} else {
|
||||||
@ -95,11 +95,11 @@ public class SaleInfo {
|
|||||||
Line end_at = Line.create().append("售卖结束时间: ");
|
Line end_at = Line.create().append("售卖结束时间: ");
|
||||||
if (titleShop.getSaleEndAt() == null) {
|
if (titleShop.getSaleEndAt() == null) {
|
||||||
end_at.append("常驻");
|
end_at.append("常驻");
|
||||||
if (player.isOp()) {
|
if (player.hasPermission("mplt.admin")) {
|
||||||
end_at.append(Button.create("转为限时").setExecuteCommand("/mplt set_sale end_at " + titleShop.getId() + " " + now_year + ":" + now_month + ":" + now_day + " " + page).build());
|
end_at.append(Button.create("转为限时").setExecuteCommand("/mplt set_sale end_at " + titleShop.getId() + " " + now_year + ":" + now_month + ":" + now_day + " " + page).build());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (player.isOp()) {
|
if (player.hasPermission("mplt.admin")) {
|
||||||
end_at.append(Button.create("<<").setPreSufIx("", "").setHoverText("提前10天").setExecuteCommand("/mplt set_sale less_end_at " + titleShop.getId() + " 10 " + page).build()
|
end_at.append(Button.create("<<").setPreSufIx("", "").setHoverText("提前10天").setExecuteCommand("/mplt set_sale less_end_at " + titleShop.getId() + " 10 " + page).build()
|
||||||
.append(Button.create("-").setPreSufIx("", "").setHoverText("提前1天").setExecuteCommand("/mplt set_sale less_end_at " + titleShop.getId() + " 1 " + page).build())
|
.append(Button.create("-").setPreSufIx("", "").setHoverText("提前1天").setExecuteCommand("/mplt set_sale less_end_at " + titleShop.getId() + " 1 " + page).build())
|
||||||
.append(Component.text(titleShop.getSaleEndAt().getYear() + "年" + titleShop.getSaleEndAt().getMonthValue() + "月" + titleShop.getSaleEndAt().getDayOfMonth() + "日"))
|
.append(Component.text(titleShop.getSaleEndAt().getYear() + "年" + titleShop.getSaleEndAt().getMonthValue() + "月" + titleShop.getSaleEndAt().getDayOfMonth() + "日"))
|
||||||
@ -120,7 +120,7 @@ public class SaleInfo {
|
|||||||
} else {
|
} else {
|
||||||
operate.append(Button.createGreen("购买").setExecuteCommand("/mplt buy_sale " + titleShop.getId()).build());
|
operate.append(Button.createGreen("购买").setExecuteCommand("/mplt buy_sale " + titleShop.getId()).build());
|
||||||
}
|
}
|
||||||
if (player.isOp()) {
|
if (player.hasPermission("mplt.admin")) {
|
||||||
operate.append(Button.create("删除").setExecuteCommand("/mplt delete_sale " + args[1] + " b").build());
|
operate.append(Button.create("删除").setExecuteCommand("/mplt delete_sale " + args[1] + " b").build());
|
||||||
}
|
}
|
||||||
view.add(Line.create().append("---------------------"));
|
view.add(Line.create().append("---------------------"));
|
||||||
|
@ -5,9 +5,20 @@ api-version: '1.20'
|
|||||||
description: 称号插件。
|
description: 称号插件。
|
||||||
website: https://lunadeer.cn
|
website: https://lunadeer.cn
|
||||||
folia-supported: true
|
folia-supported: true
|
||||||
softdepend: [PlaceholderAPI, Vault]
|
softdepend: [ PlaceholderAPI, Vault ]
|
||||||
commands:
|
commands:
|
||||||
MiniPlayerTitle:
|
MiniPlayerTitle:
|
||||||
description: 称号插件命令
|
description: 称号插件命令
|
||||||
usage: /mplt <cmd>
|
usage: /mplt <cmd>
|
||||||
aliases: [mplt]
|
aliases: [ mplt ]
|
||||||
|
permission: mplt.command
|
||||||
|
permissions:
|
||||||
|
mplt.command:
|
||||||
|
description: 普通命令
|
||||||
|
default: true
|
||||||
|
mplt.custom:
|
||||||
|
description: 是否可以自定义称号
|
||||||
|
default: true
|
||||||
|
mplt.admin:
|
||||||
|
description: 是否可以使用管理员命令
|
||||||
|
default: op
|
||||||
|
Loading…
Reference in New Issue
Block a user