修复了因为输入非数字导致报错的问题
All checks were successful
Java CI-CD with Maven / build (push) Successful in 11m53s

This commit is contained in:
zhangyuheng 2024-04-20 21:49:08 +08:00
parent 6d983cd055
commit 125b53c259
2 changed files with 219 additions and 175 deletions

View File

@ -6,7 +6,7 @@
<groupId>cn.lunadeer</groupId>
<artifactId>MiniPlayerTitle</artifactId>
<version>2.11.0</version>
<version>2.11.1</version>
<packaging>jar</packaging>
<name>MiniPlayerTitle</name>

View File

@ -31,6 +31,7 @@ public class AdminCommands {
}
public static void deleteTitle(CommandSender sender, String[] args) {
try {
if (sender instanceof org.bukkit.entity.Player) {
Player player = (org.bukkit.entity.Player) sender;
if (!player.isOp()) {
@ -44,9 +45,13 @@ public class AdminCommands {
}
Title.delete(Integer.parseInt(args[1]));
Notification.info(sender, "已删除称号");
} catch (Exception e) {
Notification.error(sender, e.getMessage());
}
}
public static void listAllTitle(CommandSender sender, String[] args) {
try {
if (sender instanceof Player) {
Player player = (Player) sender;
if (!player.isOp()) {
@ -64,9 +69,13 @@ public class AdminCommands {
}
}
Title.listAllTitle(sender, page);
} catch (Exception e) {
Notification.error(sender, e.getMessage());
}
}
public static void setTitleDescription(CommandSender sender, String[] args) {
try {
if (sender instanceof org.bukkit.entity.Player) {
Player player = (org.bukkit.entity.Player) sender;
if (!player.isOp()) {
@ -81,9 +90,13 @@ public class AdminCommands {
Title title = new Title(Integer.parseInt(args[1]));
title.setDescription(args[2]);
Notification.info(sender, "已设置称号描述");
} catch (Exception e) {
Notification.error(sender, e.getMessage());
}
}
public static void setTitleName(CommandSender sender, String[] args) {
try {
if (sender instanceof org.bukkit.entity.Player) {
Player player = (org.bukkit.entity.Player) sender;
if (!player.isOp()) {
@ -98,9 +111,13 @@ public class AdminCommands {
Title title = new Title(Integer.parseInt(args[1]));
title.setTitle(args[2]);
Notification.info(sender, "已设置称号名称");
} catch (Exception e) {
Notification.error(sender, e.getMessage());
}
}
public static void addShop(CommandSender sender, String[] args) {
try {
if (sender instanceof org.bukkit.entity.Player) {
Player player = (org.bukkit.entity.Player) sender;
if (!player.isOp()) {
@ -119,9 +136,13 @@ public class AdminCommands {
Notification.info(sender, "已添加称号到商店, 商品ID: " + title.getSaleId());
Notification.info(sender, title.getTitle());
}
} catch (Exception e) {
Notification.error(sender, e.getMessage());
}
}
public static void removeShop(CommandSender sender, String[] args) {
try {
if (sender instanceof org.bukkit.entity.Player) {
Player player = (org.bukkit.entity.Player) sender;
if (!player.isOp()) {
@ -135,9 +156,13 @@ public class AdminCommands {
}
SaleTitle.delete(Integer.parseInt(args[1]));
Notification.info(sender, "已从商店移除商品");
} catch (Exception e) {
Notification.error(sender, e.getMessage());
}
}
public static void setPrice(CommandSender sender, String[] args) {
try {
if (sender instanceof org.bukkit.entity.Player) {
Player player = (org.bukkit.entity.Player) sender;
if (!player.isOp()) {
@ -167,9 +192,13 @@ public class AdminCommands {
SaleTitle.setPrice(id, price);
SaleTitle.setDays(id, days);
Notification.info(sender, "已设置商品价格");
} catch (Exception e) {
Notification.error(sender, e.getMessage());
}
}
public static void setAmount(CommandSender sender, String[] args) {
try {
if (sender instanceof org.bukkit.entity.Player) {
Player player = (org.bukkit.entity.Player) sender;
if (!player.isOp()) {
@ -192,9 +221,13 @@ public class AdminCommands {
}
SaleTitle.setAmount(id, amount);
Notification.info(sender, "已设置商品数量");
} catch (Exception e) {
Notification.error(sender, e.getMessage());
}
}
public static void setSaleEndAt(CommandSender sender, String[] args) {
try {
if (sender instanceof org.bukkit.entity.Player) {
Player player = (org.bukkit.entity.Player) sender;
if (!player.isOp()) {
@ -216,9 +249,13 @@ public class AdminCommands {
SaleTitle.setSaleEndAt(Integer.parseInt(args[1]), time_stamp);
Notification.info(sender, "已设置商品结束时间");
} catch (Exception e) {
Notification.error(sender, e.getMessage());
}
}
public static void addCoin(CommandSender sender, String[] args) {
try {
if (sender instanceof Player) {
Player player = (Player) sender;
if (!player.isOp()) {
@ -244,9 +281,13 @@ public class AdminCommands {
}
new XPlayer(target).add_coin(amount);
Notification.info(sender, "已给予玩家 " + target.getName() + " " + amount + " 称号币");
} catch (Exception e) {
Notification.error(sender, e.getMessage());
}
}
public static void setCoin(CommandSender sender, String[] args) {
try {
if (sender instanceof Player) {
Player player = (Player) sender;
if (!player.isOp()) {
@ -272,5 +313,8 @@ public class AdminCommands {
}
new XPlayer(target).set_coin(amount);
Notification.info(sender, "已设置玩家 " + target.getName() + " 称号币为 " + amount);
} catch (Exception e) {
Notification.error(sender, e.getMessage());
}
}
}