优化gui

This commit is contained in:
yuyu 2024-07-05 10:50:14 +08:00
parent 7c180ba8cf
commit 90f2ee3cf5
3 changed files with 14 additions and 12 deletions

View File

@ -117,10 +117,12 @@ public class AppraiseGuiService extends GermGuiScreen {
GermGuiSlot slot_biomass = this.germGuiSlotHashMap.get("slotConsume"); GermGuiSlot slot_biomass = this.germGuiSlotHashMap.get("slotConsume");
GermGuiCanvas canvas = (GermGuiCanvas) getGuiPart("utility"); GermGuiCanvas canvas = (GermGuiCanvas) getGuiPart("utility");
GermGuiButton button_consume = (GermGuiButton) canvas.getGuiPart("button_consume"); GermGuiButton button_consume = (GermGuiButton) canvas.getGuiPart("button_consume");
// button_consume.setDefaultPath("local<->textures/gui/appraise/touming.gif");
// button_consume.setHoverPath("local<->textures/gui/appraise/touming.gif");
button_consume.registerCallbackHandler((player, germGuiSlot) -> { button_consume.registerCallbackHandler((player, germGuiSlot) -> {
//验证产物槽上面是否存在没拿走的产物
for (int i = 1;i<=5;i++){ for (int i = 1;i<=5;i++){
String slot = "slot_product_"+i; String slot = "slot_product_"+i;
GermGuiSlot Germslot = this.germGuiSlotHashMap.get(slot); GermGuiSlot Germslot = this.germGuiSlotHashMap.get(slot);
@ -149,6 +151,7 @@ public class AppraiseGuiService extends GermGuiScreen {
//这个是item的名字 //这个是item的名字
String itemName = title.substring(title.indexOf('l') + 1); String itemName = title.substring(title.indexOf('l') + 1);
//此处通过表示存在可鉴定的产物
if (SrAppraise.getConfigManager().getAppraiseItemMap().containsKey(itemName)){ if (SrAppraise.getConfigManager().getAppraiseItemMap().containsKey(itemName)){
itemStackHashMap.clear(); itemStackHashMap.clear();
@ -375,6 +378,7 @@ public class AppraiseGuiService extends GermGuiScreen {
} }
int timeRun = 9 / itemStacks.size(); int timeRun = 9 / itemStacks.size();
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
AtomicInteger j = new AtomicInteger(0); AtomicInteger j = new AtomicInteger(0);

View File

@ -53,9 +53,9 @@ public class AppraiseManager {
public void open(Player player,String guiName){ public void open(Player player){
//获取鉴定的窗口 //获取鉴定的窗口
AppraiseGuiService screen = new AppraiseGuiService(getAppraiseInventory(),guiName); AppraiseGuiService screen = new AppraiseGuiService(getAppraiseInventory(),"appraise");
//获取gui的配置,此处会把读取到的gui配置传到ForgeScreen的构造类中 //获取gui的配置,此处会把读取到的gui配置传到ForgeScreen的构造类中
GermGuiScreen packscreen = GermGuiScreen.getGermGuiScreen("player_inventory-forge", getForgePlayerInventory()); GermGuiScreen packscreen = GermGuiScreen.getGermGuiScreen("player_inventory-forge", getForgePlayerInventory());

View File

@ -28,26 +28,24 @@ public class OpenCommand implements SubCommand {
} }
} }
if (strings.length < 3){ if (strings.length < 2){
commandSender.sendMessage(ChatColor.RED+"正确的格式为:/srappraise open 姓名 GUIname"); commandSender.sendMessage(ChatColor.RED+"正确的格式为:/srappraise open 姓名 ");
return; return;
} }
Player player = Bukkit.getPlayer(strings[1]); Player player = Bukkit.getPlayer(strings[1]);
if (player == null){ if (player == null){
commandSender.sendMessage(ChatColor.RED+"玩家"+strings[2]+"不存在!"); commandSender.sendMessage(ChatColor.RED+"玩家"+strings[1]+"不存在!");
return; return;
} }
String gui = strings[2];
if (gui.equalsIgnoreCase("appraise")){
//为玩家打开GUI列表 //为玩家打开GUI列表
AppraiseManager.getInstance().open(player,gui); AppraiseManager.getInstance().open(player);
}else {
commandSender.sendMessage(ChatColor.RED+"请输入正确的GUI名字");
}
} }
} }