This commit is contained in:
parent
7e540d1fe5
commit
eda8a8f22f
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>cn.lunadeer</groupId>
|
||||
<artifactId>MiniPlayerTitle</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.0.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>MiniPlayerTitle</name>
|
||||
|
@ -9,6 +9,8 @@ import org.bukkit.command.TabExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Commands implements TabExecutor {
|
||||
@ -20,52 +22,52 @@ public class Commands implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
switch (args[0]) {
|
||||
case "menu":
|
||||
case "menu": // mplt menu [页数]
|
||||
Menu.show(sender, args);
|
||||
break;
|
||||
case "all_titles":
|
||||
case "all_titles": // mplt all_titles [页数]
|
||||
AllTitles.show(sender, args);
|
||||
break;
|
||||
case "my_titles":
|
||||
case "my_titles": // mplt my_titles [页数]
|
||||
MyTitles.show(sender, args);
|
||||
break;
|
||||
case "shop":
|
||||
case "shop": // mplt shop [页数]
|
||||
Shop.show(sender, args);
|
||||
break;
|
||||
case "custom_info":
|
||||
case "custom_info": // mplt custom_info
|
||||
CustomInfo.show(sender, args);
|
||||
break;
|
||||
case "sale_info":
|
||||
case "sale_info": // mplt sale_info <商品ID>
|
||||
SaleInfo.show(sender, args);
|
||||
break;
|
||||
case "create_sale":
|
||||
case "create_sale": // mplt create_sale <称号ID>
|
||||
TitleShopSale.createSale(sender, args);
|
||||
break;
|
||||
case "set_sale":
|
||||
case "set_sale": // mplt set_sale <price|days|amount|end_at|more_end_at|less_end_at> <商品ID> <值> [页数]
|
||||
TitleShopSale.setSale(sender, args);
|
||||
break;
|
||||
case "delete_sale":
|
||||
case "delete_sale": // mplt delete_sale <商品ID> [页数]
|
||||
TitleShopSale.deleteSale(sender, args);
|
||||
break;
|
||||
case "buy_sale":
|
||||
case "buy_sale": // mplt buy_sale <商品ID>
|
||||
TitleShopSale.buySale(sender, args);
|
||||
break;
|
||||
case "use_title":
|
||||
case "use_title": // mplt use_title <背包ID> [页码]
|
||||
TitleManage.useTitle(sender, args);
|
||||
break;
|
||||
case "create_title":
|
||||
case "create_title": // mplt create_title <称号名称> <称号描述>
|
||||
TitleManage.createTitle(sender, args);
|
||||
break;
|
||||
case "delete_title":
|
||||
case "delete_title": // mplt delete_title <称号ID> [页码]
|
||||
TitleManage.deleteTitle(sender, args);
|
||||
break;
|
||||
case "set_title":
|
||||
TitleManage.setTitle(sender, args);
|
||||
case "edit_title_name": // mplt edit_title_name <称号ID> <称号名称>
|
||||
TitleManage.editTitleName(sender, args);
|
||||
break;
|
||||
case "set_desc":
|
||||
TitleManage.setTitleDescription(sender, args);
|
||||
case "edit_title_desc": // mplt set_title_desc <称号ID> <称号描述>
|
||||
TitleManage.editTitleDescription(sender, args);
|
||||
break;
|
||||
case "custom_title":
|
||||
case "custom_title": // mplt custom_title <称号>
|
||||
TitleManage.customTitle(sender, args);
|
||||
break;
|
||||
default:
|
||||
@ -76,6 +78,52 @@ public class Commands implements TabExecutor {
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (args.length == 1) {
|
||||
return Arrays.asList("menu", "all_titles", "my_titles", "shop", "custom_info", "sale_info",
|
||||
"create_sale", "set_sale", "delete_sale", "buy_sale", "use_title", "create_title",
|
||||
"delete_title", "edit_title_name", "edit_title_desc", "custom_title");
|
||||
}
|
||||
if (args.length == 2) {
|
||||
switch (args[0]) {
|
||||
case "sale_info":
|
||||
case "delete_sale":
|
||||
case "buy_sale":
|
||||
return Collections.singletonList("<商品ID>");
|
||||
case "create_sale":
|
||||
case "delete_title":
|
||||
case "edit_title_name":
|
||||
case "edit_title_desc":
|
||||
return Collections.singletonList("<称号ID>");
|
||||
case "use_title":
|
||||
return Collections.singletonList("<背包ID>");
|
||||
case "set_sale":
|
||||
return Arrays.asList("price", "days", "amount", "end_at", "more_end_at", "less_end_at");
|
||||
case "custom_title":
|
||||
return Collections.singletonList("<称号内容>");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (args.length == 3) {
|
||||
switch (args[0]) {
|
||||
case "set_sale":
|
||||
return Collections.singletonList("<商品ID>");
|
||||
case "edit_title_desc":
|
||||
return Collections.singletonList("<新的称号描述>");
|
||||
case "edit_title_name":
|
||||
return Collections.singletonList("<新的称号名称>");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (args.length == 4) {
|
||||
switch (args[0]) {
|
||||
case "set_sale":
|
||||
return Collections.singletonList("<值>");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ public class TitleManage {
|
||||
TitleDTO title = TitleDTO.create(args[1], args[2]);
|
||||
if (title != null) {
|
||||
MiniPlayerTitle.notification.info(sender, Component.text("成功创建称号: [" + title.getId() + "]").append(title.getTitleColored()));
|
||||
AllTitles.show(sender, new String[]{"all_titles"});
|
||||
} else {
|
||||
MiniPlayerTitle.notification.error(sender, "创建称号失败,具体请查看控制台日志");
|
||||
}
|
||||
@ -37,7 +38,7 @@ public class TitleManage {
|
||||
|
||||
/**
|
||||
* 删除称号
|
||||
* mplt delete_title <称号ID>
|
||||
* mplt delete_title <称号ID> [页码]
|
||||
*
|
||||
* @param sender CommandSender
|
||||
* @param args String[]
|
||||
@ -71,12 +72,12 @@ public class TitleManage {
|
||||
|
||||
/**
|
||||
* 设置称号名称
|
||||
* mplt set_title <称号ID> <称号名称>
|
||||
* mplt edit_title_name <称号ID> <称号名称>
|
||||
*
|
||||
* @param sender CommandSender
|
||||
* @param args String[]
|
||||
*/
|
||||
public static void setTitle(CommandSender sender, String[] args) {
|
||||
public static void editTitleName(CommandSender sender, String[] args) {
|
||||
try {
|
||||
if (notOpOrConsole(sender)) return;
|
||||
if (args.length != 3) {
|
||||
@ -101,12 +102,12 @@ public class TitleManage {
|
||||
|
||||
/**
|
||||
* 设置称号描述
|
||||
* mplt set_desc <称号ID> <称号描述>
|
||||
* mplt edit_title_desc <称号ID> <称号描述>
|
||||
*
|
||||
* @param sender CommandSender
|
||||
* @param args String[]
|
||||
*/
|
||||
public static void setTitleDescription(CommandSender sender, String[] args) {
|
||||
public static void editTitleDescription(CommandSender sender, String[] args) {
|
||||
try {
|
||||
if (notOpOrConsole(sender)) return;
|
||||
if (args.length != 3) {
|
||||
@ -131,7 +132,7 @@ public class TitleManage {
|
||||
|
||||
/**
|
||||
* 使用称号
|
||||
* mplt use_title <称号ID> [页码]
|
||||
* mplt use_title <背包ID> [页码]
|
||||
*
|
||||
* @param sender CommandSender
|
||||
* @param args String[]
|
||||
@ -139,22 +140,27 @@ public class TitleManage {
|
||||
public static void useTitle(CommandSender sender, String[] args) {
|
||||
if (notOpOrConsole(sender)) return;
|
||||
if (args.length < 2) {
|
||||
MiniPlayerTitle.notification.warn(sender, "用法: /mplt use_title <称号ID> [页码]");
|
||||
MiniPlayerTitle.notification.warn(sender, "用法: /mplt use_title <背包ID> [页码]");
|
||||
return;
|
||||
}
|
||||
TitleDTO title = TitleDTO.get(Integer.parseInt(args[1]));
|
||||
Player player = (Player) sender;
|
||||
PlayerTitleDTO title = PlayerTitleDTO.get(Integer.parseInt(args[1]));
|
||||
if (title == null) {
|
||||
MiniPlayerTitle.notification.error(sender, "称号不存在");
|
||||
return;
|
||||
}
|
||||
PlayerInfoDTO playerInfo = PlayerInfoDTO.get(((Player) sender).getUniqueId());
|
||||
if (!title.getPlayerUuid().equals(player.getUniqueId())) {
|
||||
MiniPlayerTitle.notification.error(sender, "该称号不属于你");
|
||||
return;
|
||||
}
|
||||
PlayerInfoDTO playerInfo = PlayerInfoDTO.get((player).getUniqueId());
|
||||
if (playerInfo == null) {
|
||||
MiniPlayerTitle.notification.error(sender, "获取玩家信息时出现错误");
|
||||
return;
|
||||
}
|
||||
boolean success = playerInfo.setUsingTitle(title);
|
||||
boolean success = playerInfo.setUsingTitle(title.getTitle());
|
||||
if (success) {
|
||||
updateName((Player) sender, title);
|
||||
updateName((Player) sender, title.getTitle());
|
||||
MiniPlayerTitle.notification.info(sender, "已使用称号");
|
||||
} else {
|
||||
MiniPlayerTitle.notification.error(sender, "使用称号失败,具体请查看控制台日志");
|
||||
@ -168,7 +174,7 @@ public class TitleManage {
|
||||
|
||||
/**
|
||||
* 创建自定义称号
|
||||
* mplt custom_title <称号>
|
||||
* mplt custom_title <称号内容>
|
||||
*
|
||||
* @param sender CommandSender
|
||||
* @param args String[]
|
||||
|
@ -24,7 +24,7 @@ public class TitleShopSale {
|
||||
|
||||
/**
|
||||
* 设置商品信息
|
||||
* mplt set_sale <price|days|amount|end_at|end_at_y|end_at_m|end_at_d> <商品ID> <值> [页数]
|
||||
* mplt set_sale <price|days|amount|end_at|more_end_at|less_end_at> <商品ID> <值> [页数]
|
||||
*
|
||||
* @param sender CommandSender
|
||||
* @param args String[]
|
||||
|
@ -24,7 +24,7 @@ public class PlayerTitleDTO {
|
||||
return title;
|
||||
}
|
||||
|
||||
public UUID getPlayer_uuid() {
|
||||
public UUID getPlayerUuid() {
|
||||
return player_uuid;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user