commit fe2ce492dd65c6a2ecd62d6cebb977e6a2d6aaaf
Author: yuyu <124714592@qq.com>
Date: Tue Apr 23 11:15:11 2024 +0800
Initial commit
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..72cb0b7
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+# 项目排除路径
+/target/
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..35410ca
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/aws.xml b/.idea/aws.xml
new file mode 100644
index 0000000..b63b642
--- /dev/null
+++ b/.idea/aws.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..d65a0fb
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..aa00ffa
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..8632b0d
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_google_code_gson_gson_2_8_0.xml b/.idea/libraries/Maven__com_google_code_gson_gson_2_8_0.xml
new file mode 100644
index 0000000..6e5d5b7
--- /dev/null
+++ b/.idea/libraries/Maven__com_google_code_gson_gson_2_8_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_google_guava_guava_21_0.xml b/.idea/libraries/Maven__com_google_guava_guava_21_0.xml
new file mode 100644
index 0000000..a923456
--- /dev/null
+++ b/.idea/libraries/Maven__com_google_guava_guava_21_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_googlecode_json_simple_json_simple_1_1_1.xml b/.idea/libraries/Maven__com_googlecode_json_simple_json_simple_1_1_1.xml
new file mode 100644
index 0000000..f3f3738
--- /dev/null
+++ b/.idea/libraries/Maven__com_googlecode_json_simple_json_simple_1_1_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__commons_lang_commons_lang_2_6.xml b/.idea/libraries/Maven__commons_lang_commons_lang_2_6.xml
new file mode 100644
index 0000000..2ec8376
--- /dev/null
+++ b/.idea/libraries/Maven__commons_lang_commons_lang_2_6.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__junit_junit_4_10.xml b/.idea/libraries/Maven__junit_junit_4_10.xml
new file mode 100644
index 0000000..ed8bf5f
--- /dev/null
+++ b/.idea/libraries/Maven__junit_junit_4_10.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__net_md_5_bungeecord_chat_1_12_SNAPSHOT.xml b/.idea/libraries/Maven__net_md_5_bungeecord_chat_1_12_SNAPSHOT.xml
new file mode 100644
index 0000000..a472890
--- /dev/null
+++ b/.idea/libraries/Maven__net_md_5_bungeecord_chat_1_12_SNAPSHOT.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_1.xml b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_1.xml
new file mode 100644
index 0000000..acdf443
--- /dev/null
+++ b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_projectlombok_lombok_1_18_22.xml b/.idea/libraries/Maven__org_projectlombok_lombok_1_18_22.xml
new file mode 100644
index 0000000..72b596e
--- /dev/null
+++ b/.idea/libraries/Maven__org_projectlombok_lombok_1_18_22.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_spigotmc_spigot_api_1_12_2_R0_1_SNAPSHOT.xml b/.idea/libraries/Maven__org_spigotmc_spigot_api_1_12_2_R0_1_SNAPSHOT.xml
new file mode 100644
index 0000000..42f0d6f
--- /dev/null
+++ b/.idea/libraries/Maven__org_spigotmc_spigot_api_1_12_2_R0_1_SNAPSHOT.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_yaml_snakeyaml_1_19.xml b/.idea/libraries/Maven__org_yaml_snakeyaml_1_19.xml
new file mode 100644
index 0000000..33ccf19
--- /dev/null
+++ b/.idea/libraries/Maven__org_yaml_snakeyaml_1_19.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/lib__2_.xml b/.idea/libraries/lib__2_.xml
new file mode 100644
index 0000000..0ae6450
--- /dev/null
+++ b/.idea/libraries/lib__2_.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..2ca0d1f
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..b9ed519
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..2b63946
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/SrAppraise.iml b/SrAppraise.iml
new file mode 100644
index 0000000..cd35cdc
--- /dev/null
+++ b/SrAppraise.iml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+ SPIGOT
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/GermPlugin-Snapshot-4.3.9-8.jar b/lib/GermPlugin-Snapshot-4.3.9-8.jar
new file mode 100644
index 0000000..11e8bd2
Binary files /dev/null and b/lib/GermPlugin-Snapshot-4.3.9-8.jar differ
diff --git a/lib/SrItem-1.1.3-1.jar b/lib/SrItem-1.1.3-1.jar
new file mode 100644
index 0000000..0bc1c11
Binary files /dev/null and b/lib/SrItem-1.1.3-1.jar differ
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..c6be38f
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,80 @@
+
+
+ 4.0.0
+
+ com.yuyu
+ SrAppraise
+ 1.0-SNAPSHOT
+ jar
+
+ SrAppraise
+
+
+ 1.8
+ UTF-8
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
+ ${java.version}
+ ${java.version}
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.2.4
+
+
+ package
+
+ shade
+
+
+ false
+
+
+
+
+
+
+
+ src/main/resources
+ true
+
+
+
+
+
+
+ spigotmc-repo
+ https://hub.spigotmc.org/nexus/content/repositories/snapshots/
+
+
+ sonatype
+ https://oss.sonatype.org/content/groups/public/
+
+
+
+
+
+ org.projectlombok
+ lombok
+ 1.18.22
+ compile
+
+
+ org.spigotmc
+ spigot-api
+ 1.12.2-R0.1-SNAPSHOT
+ provided
+
+
+
diff --git a/src/main/java/com/yuyu/srappraise/SrAppraise.java b/src/main/java/com/yuyu/srappraise/SrAppraise.java
new file mode 100644
index 0000000..3b26908
--- /dev/null
+++ b/src/main/java/com/yuyu/srappraise/SrAppraise.java
@@ -0,0 +1,29 @@
+package com.yuyu.srappraise;
+
+import com.sakurarealm.sritem.bukkit.command.CommandBase;
+import com.yuyu.srappraise.command.OpenCommand;
+import lombok.Getter;
+import org.bukkit.ChatColor;
+import org.bukkit.plugin.java.JavaPlugin;
+
+public final class SrAppraise extends JavaPlugin {
+
+ @Getter
+ private static SrAppraise instance;//用于获取实例
+ @Override
+ public void onEnable() {
+
+ getLogger().info(ChatColor.MAGIC+"鉴定插件启动");
+
+ CommandBase commandBase = new CommandBase();
+ this.getCommand("srappraise").setExecutor(commandBase);
+ commandBase.registerSubCommand("open",new OpenCommand());
+ }
+
+ @Override
+ public void onDisable() {
+ // Plugin shutdown logic
+ }
+
+
+}
diff --git a/src/main/java/com/yuyu/srappraise/appraise/AppraiseManager.java b/src/main/java/com/yuyu/srappraise/appraise/AppraiseManager.java
new file mode 100644
index 0000000..319c8d9
--- /dev/null
+++ b/src/main/java/com/yuyu/srappraise/appraise/AppraiseManager.java
@@ -0,0 +1,47 @@
+package com.yuyu.srappraise.appraise;
+
+import com.germ.germplugin.api.dynamic.gui.GermGuiScreen;
+import com.sakurarealm.sritem.germ.GermGuiService;
+import lombok.Getter;
+import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.entity.Player;
+
+/**
+ * @BelongsProject: SrAppraise
+ * @BelongsPackage: com.yuyu.srappraise
+ * @FileName: AppraiseManager
+ * @Author: 峰。
+ * @Date: 2024/4/16-16:37
+ * @Version: 1.0
+ * @Description:提供鉴定服务相关
+ */
+public class AppraiseManager {
+
+ @Getter
+ private final static AppraiseManager instance = new AppraiseManager();
+
+ private AppraiseManager() {
+ }
+
+ public static ConfigurationSection getForgePlayerInventory() {
+ return GermGuiService.getGermGui("forge", "player_inventory-forge");
+ }
+ public static ConfigurationSection getAppraiseInventory() {
+ return GermGuiService.getGermGui("appraise", "appraise");
+ }
+
+
+
+ public void open(Player player,String guiName){
+ //获取鉴定的窗口
+ AppraiseScreen screen = new AppraiseScreen(getAppraiseInventory(),guiName);
+ //获取gui的配置,此处会把读取到的gui配置传到ForgeScreen的构造类中
+ GermGuiScreen packscreen = GermGuiScreen.getGermGuiScreen("player_inventory-forge", getForgePlayerInventory());
+
+// screen.btnRegister();
+ //为玩家打开鉴定窗口和背包窗口
+ packscreen.openGui(player);
+ screen.openChildGui(player);
+
+ }
+}
diff --git a/src/main/java/com/yuyu/srappraise/appraise/AppraiseScreen.java b/src/main/java/com/yuyu/srappraise/appraise/AppraiseScreen.java
new file mode 100644
index 0000000..2699f99
--- /dev/null
+++ b/src/main/java/com/yuyu/srappraise/appraise/AppraiseScreen.java
@@ -0,0 +1,111 @@
+package com.yuyu.srappraise.appraise;
+
+import com.germ.germplugin.api.dynamic.DynamicBase;
+import com.germ.germplugin.api.dynamic.gui.*;
+import com.sakurarealm.sritem.api.ItemStackHelper;
+import com.sakurarealm.sritem.api.SrItemAPI;
+import com.sakurarealm.sritem.api.SrItemManager;
+import com.sakurarealm.sritem.api.builder.SrItemHandler;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.entity.Item;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+
+import java.util.HashMap;
+
+/**
+ * @BelongsProject: SrAppraise
+ * @BelongsPackage: com.yuyu.srappraise.appraise
+ * @FileName: AppraiseScreen
+ * @Author: 峰。
+ * @Date: 2024/4/19-21:32
+ * @Version: 1.0
+ * @Description: 用于鉴定界面相关
+ */
+public class AppraiseScreen extends GermGuiScreen {
+
+ public AppraiseScreen(ConfigurationSection configurationSection,String guiName) {
+ super(guiName,configurationSection);
+ //TODO(此处绑定给 √ 按钮绑定一个监听事件,在监听事件中获取放入了物品槽位的物品,然后鉴定)
+ this.btnRegister();
+ this.setClosedHandler(((player, germGuiScreen) -> {
+ //窗口关闭事件
+ this.returnItemStacks(player);
+ this.close();
+ }));
+ }
+
+ /**
+ * 返回鉴定槽位内的物品给玩家
+ *
+ * @param player player
+ */
+ synchronized public void returnItemStacks(Player player) {
+ GermGuiCanvas canvas = (GermGuiCanvas) getGuiPart("utility");
+
+ GermGuiSlot slot_biomass = (GermGuiSlot) canvas.getGuiPart("slot_biomass");
+
+
+ ItemStack biomass_itemStack = slot_biomass.getItemStack();
+
+ if (biomass_itemStack != null && biomass_itemStack.getType() != Material.AIR) {
+ player.getInventory().addItem(biomass_itemStack);
+ }
+ slot_biomass.setItemStack(Material.AIR);
+
+ }
+
+// public ItemStack getSrItem(){
+// ItemStack item = SrItemAPI.getItem();
+// }
+
+ /**
+ * 此方法用于绑定鉴定事件的发生
+ */
+ public void btnRegister(){
+ //先获取canvas,再获取canvas中的按键
+ GermGuiCanvas canvas = (GermGuiCanvas) getGuiPart("utility");
+
+ GermGuiButton confrimBtn = (GermGuiButton) canvas.getGuiPart("b_confirm");
+ confrimBtn.registerCallbackHandler((clickPlayer, btn) -> {
+
+ GermGuiSlot slot_biomass = (GermGuiSlot) canvas.getGuiPart("slot_biomass");
+
+ ItemStack itemStack = slot_biomass.getItemStack();
+
+ SrItemHandler srItemHandler = ItemStackHelper.getSrItemHandler(itemStack);
+ String title = srItemHandler.getTitle();
+ String index = title.substring(title.indexOf('l') + 1);
+ String s = srItemHandler.getLore().get(0);
+
+ if (SrItemAPI.hasItem(index)) {
+ //TODO(此处hasItem的索引能通过,可以试试getItem能不能通过获取rpg物品)
+// SrItemManager.getInstance().getItem(index)
+ index = s.substring(s.indexOf('-') + 1);
+ itemStack = SrItemAPI.getItem(index,new HashMap<>(), Bukkit.getPlayer(clickPlayer.getName()),true,true);
+ if (itemStack == null){
+ clickPlayer.sendMessage(ChatColor.RED+title+"不存在");
+ return;
+ }
+
+ if (itemStack.getAmount() != 1) {
+ clickPlayer.sendMessage(ChatColor.RED + "每次只能鉴定一个物品!");
+ return;
+ }
+
+ if (itemStack != null && itemStack.getType() != Material.AIR) {
+ itemStack.setAmount(2);
+ clickPlayer.sendMessage(ChatColor.RED + "这是" + itemStack.getType().name());
+ SrItemAPI instance = SrItemAPI.INSTANCE;
+ slot_biomass.setItemStack(itemStack);
+ }
+ }else {
+ clickPlayer.sendMessage(ChatColor.GREEN+"这是一个"+itemStack.getType().name());
+ }
+ }, GermGuiButton.EventType.LEFT_CLICK);
+ }
+
+}
diff --git a/src/main/java/com/yuyu/srappraise/command/OpenCommand.java b/src/main/java/com/yuyu/srappraise/command/OpenCommand.java
new file mode 100644
index 0000000..d016d99
--- /dev/null
+++ b/src/main/java/com/yuyu/srappraise/command/OpenCommand.java
@@ -0,0 +1,45 @@
+package com.yuyu.srappraise.command;
+
+import com.sakurarealm.sritem.bukkit.command.SubCommand;
+import com.yuyu.srappraise.appraise.AppraiseManager;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+/**
+ * @BelongsProject: SrAppraise
+ * @BelongsPackage: com.yuyu.srappraise.command
+ * @FileName: OpenCommand
+ * @Author: 峰。
+ * @Date: 2024/4/19-21:14
+ * @Version: 1.0
+ * @Description: 用于打开gui窗口
+ */
+public class OpenCommand implements SubCommand {
+ @Override
+ public void onCommand(CommandSender commandSender, String[] strings) {
+
+ if (strings.length < 3){
+ commandSender.sendMessage(ChatColor.RED+"正确的格式为:/srappraise open 姓名 GUIname");
+ return;
+ }
+
+
+ Player player = Bukkit.getPlayer(strings[1]);
+ if (player == null){
+ commandSender.sendMessage(ChatColor.RED+"玩家"+strings[2]+"不存在!");
+ return;
+ }
+
+ String gui = strings[2];
+
+ if (gui.equalsIgnoreCase("appraise")){
+ //为玩家打开GUI列表
+ AppraiseManager.getInstance().open(player,gui);
+ }else {
+ commandSender.sendMessage(ChatColor.RED+"请输入正确的GUI名字");
+ }
+
+ }
+}
diff --git a/src/main/resources/AppraiseItem.yml b/src/main/resources/AppraiseItem.yml
new file mode 100644
index 0000000..6d64434
--- /dev/null
+++ b/src/main/resources/AppraiseItem.yml
@@ -0,0 +1,5 @@
+SrItem:
+ Appraise:
+ - 巴尔伐楼伽的怨牙 #这下面填上可以鉴定的物品的名称
+ - 环齿原胚
+
diff --git a/src/main/resources/ItemAppraiseProduct.yml b/src/main/resources/ItemAppraiseProduct.yml
new file mode 100644
index 0000000..f597a7b
--- /dev/null
+++ b/src/main/resources/ItemAppraiseProduct.yml
@@ -0,0 +1,6 @@
+SrItem:
+ 巴尔伐楼伽的怨牙: #这一行填可以鉴定的物品
+ 环齿原胚: #这下面填鉴定物品可以得到的结果
+ probability: 0.2 #概率,每个可以鉴定的物品下面的概率和要为1,不然可能出现没有鉴定无结果的可能
+ 保密试作品HC-03原胚: #这下面填鉴定物品可以得到的结果
+ probability: 0.8 #概率
\ No newline at end of file
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
new file mode 100644
index 0000000..a473d35
--- /dev/null
+++ b/src/main/resources/plugin.yml
@@ -0,0 +1,10 @@
+name: SrAppraise
+version: '${project.version}'
+main: com.yuyu.srappraise.SrAppraise
+depend:
+ - SrItem
+commands:
+ srappraise:
+ description: Appraise command
+ aliases: [ sra ]
+ permission: sritem.command