commit 628c7560b8c5983104dae80d0091edfe019b781b
Author: tianyu <32282861@qq.com>
Date: Thu Jul 25 00:22:12 2024 +0800
测试版
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..6ff7bfc
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,37 @@
+
+
+ 4.0.0
+
+ org.example
+ DemonBuildShop
+ 1.0-SNAPSHOT
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+ public-rpg
+ https://repo.aurora-pixels.com/repository/public-rpg/
+
+
+
+
+
+ org.spigotmc
+ spigot-api
+ 1.12.2
+
+
+ me.Demon.DemonPlugin
+ DemonAPI
+ 1.2.0
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/me/Demon/DemonBuildShop/Main.java b/src/main/java/me/Demon/DemonBuildShop/Main.java
new file mode 100644
index 0000000..f5197df
--- /dev/null
+++ b/src/main/java/me/Demon/DemonBuildShop/Main.java
@@ -0,0 +1,112 @@
+package me.Demon.DemonBuildShop;
+
+import me.Demon.DemonPlugin.DemonAPI;
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryCloseEvent;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+import org.bukkit.plugin.java.JavaPlugin;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+public class Main extends JavaPlugin implements Listener {
+
+ public static Main plugin;
+ public static String prefix = "§7[§建筑商店§7] §f";
+ public static List LockAccount = new ArrayList<>();
+
+ public void onEnable() {
+ plugin = this;
+ saveDefaultConfig();
+ Bukkit.getPluginManager().registerEvents(this, this);
+ Bukkit.getServer().getPluginManager().registerEvents(new gui_1(), plugin);
+ Bukkit.getServer().getPluginManager().registerEvents(new gui_2(), plugin);
+ Bukkit.getServer().getPluginManager().registerEvents(new gui_3(), plugin);
+ Bukkit.getServer().getPluginManager().registerEvents(new gui_4(), plugin);
+ Bukkit.getServer().getPluginManager().registerEvents(new gui_5(), plugin);
+ Bukkit.getServer().getPluginManager().registerEvents(new gui_6(), plugin);
+ Bukkit.getConsoleSender().sendMessage("§a[建材商城] §f插件成功载入服务器.");
+ }
+
+ public void onDisable() {
+ Bukkit.getConsoleSender().sendMessage("§c[建材商城] §f插件已经从服务器中卸载.");
+ }
+
+ public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel, String[] args) {
+ if (CommandLabel.equalsIgnoreCase("buildshop")) {
+ if (args.length == 0) {
+ gui_1.OpenGui((Player) sender);
+ } else if (args.length == 1 && sender.isOp()) {
+ if (args[0].equalsIgnoreCase("reload")) {
+ reloadConfig();
+ sender.sendMessage(prefix + "配置文件重载完成。");
+ } else {
+ OpenGui((Player) sender, Integer.parseInt(args[0]));
+ }
+ }
+ }
+ return false;
+ }
+
+ @EventHandler
+ public void onclose(InventoryCloseEvent e) {
+ Player p = (Player) e.getPlayer();
+ if (e.getView().getTitle().contains("创建配置文件#")) {
+ int amount = 0;
+ String key = e.getView().getTitle().replace("创建配置文件#", "");
+ getConfig().set("ItemShop_" + key, null);
+ for (int i = 0; i < e.getInventory().getSize(); i++) {
+ ItemStack items = e.getInventory().getItem(i);
+ if (!DemonAPI.itemIsNull(items)) {
+ getConfig().set("ItemShop_" + key + "." + i + ".price", 4);
+ items.setAmount(64);
+ getConfig().set("ItemShop_" + key + "." + i + ".items", items);
+ saveConfig();
+ amount++;
+ }
+ }
+ p.sendMessage("创建配置物品总计: §a" + amount + "个");
+ }
+ }
+
+ public static void OpenGui(Player p, int key) {
+ Inventory inv = Bukkit.createInventory(null, 54, "创建配置文件#" + key);
+ String str = "ItemShop_" + key;
+ FileConfiguration yml = Main.plugin.getConfig();
+ if (yml.getString(str) != null) {
+ for (String slot_key : yml.getConfigurationSection(str).getKeys(false)) {
+ ItemStack item = yml.getItemStack(str + "." + slot_key + ".items");
+ int slot = Integer.parseInt(slot_key);
+ inv.setItem(slot, item);
+ }
+ }
+ p.openInventory(inv);
+ }
+
+ public static String getTime(String format) {
+ Date date = Calendar.getInstance().getTime();
+ SimpleDateFormat datatime = new SimpleDateFormat(format);
+ return datatime.format(date);
+ }
+
+ public static ItemStack BackBook(String name) {
+ ItemStack item = new ItemStack(Material.BOOK);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(name);
+ item.setItemMeta(meta);
+ return item;
+ }
+
+}
diff --git a/src/main/java/me/Demon/DemonBuildShop/gui_1.java b/src/main/java/me/Demon/DemonBuildShop/gui_1.java
new file mode 100644
index 0000000..da34b64
--- /dev/null
+++ b/src/main/java/me/Demon/DemonBuildShop/gui_1.java
@@ -0,0 +1,98 @@
+package me.Demon.DemonBuildShop;
+
+import me.Demon.DemonPlugin.DemonAPI;
+import me.skymc.taboomenu.TabooMenuAPI;
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.Sound;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemFlag;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class gui_1 implements Listener {
+
+ public static String inv_title = "建材商店(第一页)";
+ public static String Next_String = "ItemShop_1";
+ public static FileConfiguration yml = Main.plugin.getConfig();
+
+ public static void OpenGui(Player p){
+ Inventory inv = Bukkit.createInventory(null,54,inv_title);
+ if(yml.getConfigurationSection(Next_String) != null) {
+ for (String slot : yml.getConfigurationSection(Next_String).getKeys(false)) {
+ double price = yml.getDouble(Next_String+"." + slot + ".price");
+ ItemStack items = yml.getItemStack(Next_String+"." + slot + ".items").clone();
+ inv.setItem(Integer.parseInt(slot), shopItems(items, price));
+ }
+ }
+ inv.setItem(45,arrow(Material.BARRIER,"§c无法进行翻页!"));
+ inv.setItem(49, Main.BackBook("§a返回菜单"));
+ inv.setItem(53,arrow(Material.ARROW,"§a下一页"));
+ p.openInventory(inv);
+ }
+
+ public static ItemStack shopItems(ItemStack items,double price){
+ ItemStack item = items.clone();
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(DemonAPI.getItemName(item));
+ List lore = new ArrayList<>();
+ lore.add("§7价格: "+(int) price+"点券");
+ lore.add("§7数量: "+item.getAmount()+"个");
+ lore.add("§a§l✔§7点击购买");
+ meta.setLore(lore);
+ meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
+ item.setItemMeta(meta);
+ return item;
+ }
+
+ public static ItemStack arrow(Material material, String name){
+ ItemStack item = new ItemStack(material);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(name);
+ item.setItemMeta(meta);
+ return item;
+ }
+
+ @EventHandler
+ public void onclick(InventoryClickEvent e){
+ Player p = (Player) e.getWhoClicked();
+ if(inv_title.equalsIgnoreCase(e.getView().getTitle())){
+ e.setCancelled(true);
+ if(e.getRawSlot() == 45){
+ p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK,1,2);
+ return;
+ }
+ if(e.getRawSlot() == 53){
+ gui_2.OpenGui(p);
+ p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK,1,2);
+ return;
+ }
+ if(e.getRawSlot() == 49){
+ TabooMenuAPI.openMenu(p,"商城菜单",true);
+ }
+ if(e.getRawSlot() >= 0 && e.getRawSlot() < 45){
+ ItemStack item = e.getCurrentItem();
+ if(!DemonAPI.itemIsNull(item) && !DemonAPI.itemIsLore(item)){
+ String str = Next_String+"."+e.getRawSlot()+".";
+ p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK,1,2);
+ //获取这个物品多少钱
+ int price = yml.getInt(str+"price");
+ if(!DemonAPI.hasPoints(p,price)){
+ p.sendMessage(Main.prefix + "你需要§d" + price + "§f点券才能操作.");
+ return;
+ }
+ DemonAPI.takePoints(p,price);
+ p.getInventory().addItem(yml.getItemStack(str+"items").clone());
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/me/Demon/DemonBuildShop/gui_2.java b/src/main/java/me/Demon/DemonBuildShop/gui_2.java
new file mode 100644
index 0000000..3289e49
--- /dev/null
+++ b/src/main/java/me/Demon/DemonBuildShop/gui_2.java
@@ -0,0 +1,99 @@
+package me.Demon.DemonBuildShop;
+
+import me.Demon.DemonPlugin.DemonAPI;
+import me.skymc.taboomenu.TabooMenuAPI;
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.Sound;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemFlag;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class gui_2 implements Listener {
+
+ public static String inv_title = "建材商店(第二页)";
+ public static String Next_String = "ItemShop_2";
+ public static FileConfiguration yml = Main.plugin.getConfig();
+
+ public static void OpenGui(Player p) {
+ Inventory inv = Bukkit.createInventory(null, 54, inv_title);
+ if (yml.getConfigurationSection(Next_String) != null) {
+ for (String slot : yml.getConfigurationSection(Next_String).getKeys(false)) {
+ double price = yml.getDouble(Next_String + "." + slot + ".price");
+ ItemStack items = yml.getItemStack(Next_String + "." + slot + ".items").clone();
+ inv.setItem(Integer.parseInt(slot), shopItems(items, price));
+ }
+ }
+ inv.setItem(45, arrow(Material.ARROW, "§a上一页"));
+ inv.setItem(49, Main.BackBook("§a返回菜单"));
+ inv.setItem(53, arrow(Material.ARROW, "§a下一页"));
+ p.openInventory(inv);
+ }
+
+ public static ItemStack shopItems(ItemStack items, double price) {
+ ItemStack item = items.clone();
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(DemonAPI.getItemName(item));
+ List lore = new ArrayList<>();
+ lore.add("§7价格: " + (int) price + "点券");
+ lore.add("§7数量: " + item.getAmount() + "个");
+ lore.add("§a§l✔§7点击购买");
+ meta.setLore(lore);
+ meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
+ item.setItemMeta(meta);
+ return item;
+ }
+
+ public static ItemStack arrow(Material material, String name) {
+ ItemStack item = new ItemStack(material);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(name);
+ item.setItemMeta(meta);
+ return item;
+ }
+
+ @EventHandler
+ public void onclick(InventoryClickEvent e) {
+ Player p = (Player) e.getWhoClicked();
+ if (inv_title.equalsIgnoreCase(e.getView().getTitle())) {
+ e.setCancelled(true);
+ if (e.getRawSlot() == 45) {
+ gui_1.OpenGui(p);
+ p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK, 1, 2);
+ return;
+ }
+ if (e.getRawSlot() == 53) {
+ gui_3.OpenGui(p);
+ p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK, 1, 2);
+ return;
+ }
+ if (e.getRawSlot() == 49) {
+ TabooMenuAPI.openMenu(p, "商城菜单", true);
+ }
+ if (e.getRawSlot() >= 0 && e.getRawSlot() < 45) {
+ ItemStack item = e.getCurrentItem();
+ if (!DemonAPI.itemIsNull(item) && !DemonAPI.itemIsLore(item)) {
+ String str = "ItemShop_" + 2 + "." + e.getRawSlot() + ".";
+ p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK, 1, 2);
+ //获取这个物品多少钱
+ int price = yml.getInt(str + "price");
+ if (!DemonAPI.hasPoints(p, price)) {
+ p.sendMessage(Main.prefix + "你需要§d" + price + "§f点券才能操作.");
+ return;
+ }
+ DemonAPI.takePoints(p, price);
+ p.getInventory().addItem(yml.getItemStack(str + "items").clone());
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/me/Demon/DemonBuildShop/gui_3.java b/src/main/java/me/Demon/DemonBuildShop/gui_3.java
new file mode 100644
index 0000000..3aa23d0
--- /dev/null
+++ b/src/main/java/me/Demon/DemonBuildShop/gui_3.java
@@ -0,0 +1,99 @@
+package me.Demon.DemonBuildShop;
+
+import me.Demon.DemonPlugin.DemonAPI;
+import me.skymc.taboomenu.TabooMenuAPI;
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.Sound;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemFlag;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class gui_3 implements Listener {
+
+ public static String inv_title = "建材商店(第三页)";
+ public static String Next_String = "ItemShop_3";
+ public static FileConfiguration yml = Main.plugin.getConfig();
+
+ public static void OpenGui(Player p) {
+ //获取玩家点券余额
+ Inventory inv = Bukkit.createInventory(null, 54, inv_title);
+ if (yml.getConfigurationSection(Next_String) != null) {
+ for (String slot : yml.getConfigurationSection(Next_String).getKeys(false)) {
+ double price = yml.getDouble(Next_String + "." + slot + ".price");
+ ItemStack items = yml.getItemStack(Next_String + "." + slot + ".items").clone();
+ inv.setItem(Integer.parseInt(slot), shopItems(items, price));
+ }
+ }
+ inv.setItem(45, arrow(Material.ARROW, "§a上一页"));
+ inv.setItem(49, Main.BackBook("§a返回菜单"));
+ inv.setItem(53, arrow(Material.BARRIER, "§c最后一页了!"));
+ p.openInventory(inv);
+ }
+
+ public static ItemStack shopItems(ItemStack items, double price) {
+ ItemStack item = items.clone();
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(DemonAPI.getItemName(item));
+ List lore = new ArrayList<>();
+ lore.add("§7价格: " + (int) price + "点券");
+ lore.add("§7数量: " + item.getAmount() + "个");
+ lore.add("§a§l✔§7点击购买");
+ meta.setLore(lore);
+ meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
+ item.setItemMeta(meta);
+ return item;
+ }
+
+ public static ItemStack arrow(Material material, String name) {
+ ItemStack item = new ItemStack(material);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(name);
+ item.setItemMeta(meta);
+ return item;
+ }
+
+ @EventHandler
+ public void onclick(InventoryClickEvent e) {
+ Player p = (Player) e.getWhoClicked();
+ if (inv_title.equalsIgnoreCase(e.getView().getTitle())) {
+ e.setCancelled(true);
+ if (e.getRawSlot() == 45) {
+ gui_2.OpenGui(p);
+ p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK, 1, 2);
+ return;
+ }
+ if (e.getRawSlot() == 53) {
+ p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK, 1, 2);
+ return;
+ }
+ if (e.getRawSlot() == 49) {
+ TabooMenuAPI.openMenu(p, "商城菜单", true);
+ }
+ if (e.getRawSlot() >= 0 && e.getRawSlot() < 45) {
+ ItemStack item = e.getCurrentItem();
+ if (!DemonAPI.itemIsNull(item) && !DemonAPI.itemIsLore(item)) {
+ String str = Next_String + "." + e.getRawSlot() + ".";
+ p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK, 1, 2);
+ //获取这个物品多少钱
+ int price = yml.getInt(str + "price");
+ if (!DemonAPI.hasPoints(p, price)) {
+ p.sendMessage(Main.prefix + "你需要§d" + price + "§f点券才能操作.");
+ return;
+ }
+ DemonAPI.takePoints(p, price);
+ p.getInventory().addItem(yml.getItemStack(str + "items").clone());
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/me/Demon/DemonBuildShop/gui_4.java b/src/main/java/me/Demon/DemonBuildShop/gui_4.java
new file mode 100644
index 0000000..d584821
--- /dev/null
+++ b/src/main/java/me/Demon/DemonBuildShop/gui_4.java
@@ -0,0 +1,100 @@
+package me.Demon.DemonBuildShop;
+
+import me.Demon.DemonPlugin.DemonAPI;
+import me.skymc.taboomenu.TabooMenuAPI;
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.Sound;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemFlag;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class gui_4 implements Listener {
+
+ public static String inv_title = "建材商店(第四页)";
+ public static String Next_String = "ItemShop_4";
+ public static FileConfiguration yml = Main.plugin.getConfig();
+
+ public static void OpenGui(Player p) {
+ Inventory inv = Bukkit.createInventory(null, 54, inv_title);
+ if (yml.getConfigurationSection(Next_String) != null) {
+ for (String slot : yml.getConfigurationSection(Next_String).getKeys(false)) {
+ double price = yml.getDouble(Next_String + "." + slot + ".price");
+ ItemStack items = yml.getItemStack(Next_String + "." + slot + ".items").clone();
+ inv.setItem(Integer.parseInt(slot), shopItems(items, price));
+ }
+ }
+ inv.setItem(45, arrow(Material.ARROW, "§a上一页"));
+ inv.setItem(49, Main.BackBook("§a返回菜单"));
+ inv.setItem(53, arrow(Material.ARROW, "§a下一页"));
+ p.openInventory(inv);
+ }
+
+ public static ItemStack shopItems(ItemStack items, double price) {
+ ItemStack item = items.clone();
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(DemonAPI.getItemName(item));
+ List lore = new ArrayList<>();
+ lore.add("§7价格: " + (int) price + "点券");
+ lore.add("§7数量: " + item.getAmount() + "个");
+ lore.add("§a§l✔§7点击购买");
+ meta.setLore(lore);
+ meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
+ item.setItemMeta(meta);
+ return item;
+ }
+
+ public static ItemStack arrow(Material material, String name) {
+ ItemStack item = new ItemStack(material);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(name);
+ item.setItemMeta(meta);
+ return item;
+ }
+
+ @EventHandler
+ public void onclick(InventoryClickEvent e) {
+ Player p = (Player) e.getWhoClicked();
+ if (inv_title.equalsIgnoreCase(e.getView().getTitle())) {
+ e.setCancelled(true);
+ if (e.getRawSlot() == 45) {
+ gui_3.OpenGui(p);
+ p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK, 1, 2);
+ return;
+ }
+ if (e.getRawSlot() == 53) {
+ gui_5.OpenGui(p);
+ p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK, 1, 2);
+ return;
+ }
+ if (e.getRawSlot() == 49) {
+ TabooMenuAPI.openMenu(p, "商城菜单", true);
+ }
+ if (e.getRawSlot() >= 0 && e.getRawSlot() < 45) {
+ ItemStack item = e.getCurrentItem();
+ if (!DemonAPI.itemIsNull(item) && !DemonAPI.itemIsLore(item)) {
+ String str = Next_String + "." + e.getRawSlot() + ".";
+ p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK, 1, 2);
+ //获取这个物品多少钱
+ int price = yml.getInt(str + "price");
+ if (!DemonAPI.hasPoints(p, price)) {
+ p.sendMessage(Main.prefix + "你需要§d" + price + "§f点券才能操作.");
+ p.closeInventory();
+ return;
+ }
+ DemonAPI.takePoints(p, price);
+ p.getInventory().addItem(yml.getItemStack(str + "items").clone());
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/me/Demon/DemonBuildShop/gui_5.java b/src/main/java/me/Demon/DemonBuildShop/gui_5.java
new file mode 100644
index 0000000..8bbcc64
--- /dev/null
+++ b/src/main/java/me/Demon/DemonBuildShop/gui_5.java
@@ -0,0 +1,100 @@
+package me.Demon.DemonBuildShop;
+
+import me.Demon.DemonPlugin.DemonAPI;
+import me.skymc.taboomenu.TabooMenuAPI;
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.Sound;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemFlag;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class gui_5 implements Listener {
+
+ public static String inv_title = "建材商店(第五页)";
+ public static String Next_String = "ItemShop_5";
+ public static FileConfiguration yml = Main.plugin.getConfig();
+
+ public static void OpenGui(Player p){
+ Inventory inv = Bukkit.createInventory(null,54,inv_title);
+ if(yml.getConfigurationSection(Next_String) != null) {
+ for (String slot : yml.getConfigurationSection(Next_String).getKeys(false)) {
+ double price = yml.getDouble(Next_String+"." + slot + ".price");
+ ItemStack items = yml.getItemStack(Next_String+"." + slot + ".items").clone();
+ inv.setItem(Integer.parseInt(slot), shopItems(items, price));
+ }
+ }
+ inv.setItem(45,arrow(Material.ARROW,"§a上一页"));
+ inv.setItem(49, Main.BackBook("§a返回菜单"));
+ inv.setItem(53,arrow(Material.ARROW,"§a下一页"));
+ p.openInventory(inv);
+ }
+
+ public static ItemStack shopItems(ItemStack items,double price){
+ ItemStack item = items.clone();
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(DemonAPI.getItemName(item));
+ List lore = new ArrayList<>();
+ lore.add("§7价格: "+(int) price+"点券");
+ lore.add("§7数量: "+item.getAmount()+"个");
+ lore.add("§a§l✔§7点击购买");
+ meta.setLore(lore);
+ meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
+ item.setItemMeta(meta);
+ return item;
+ }
+
+ public static ItemStack arrow(Material material, String name){
+ ItemStack item = new ItemStack(material);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(name);
+ item.setItemMeta(meta);
+ return item;
+ }
+
+ @EventHandler
+ public void onclick(InventoryClickEvent e){
+ Player p = (Player) e.getWhoClicked();
+ if(inv_title.equalsIgnoreCase(e.getView().getTitle())){
+ e.setCancelled(true);
+ if(e.getRawSlot() == 45){
+ gui_4.OpenGui(p);
+ p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK,1,2);
+ return;
+ }
+ if(e.getRawSlot() == 53){
+ gui_6.OpenGui(p);
+ p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK,1,2);
+ return;
+ }
+ if(e.getRawSlot() == 49){
+ TabooMenuAPI.openMenu(p,"商城菜单",true);
+ }
+ if(e.getRawSlot() >= 0 && e.getRawSlot() < 45){
+ ItemStack item = e.getCurrentItem();
+ if(!DemonAPI.itemIsNull(item) && !DemonAPI.itemIsLore(item)){
+ String str = Next_String+"."+e.getRawSlot()+".";
+ p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK,1,2);
+ //获取这个物品多少钱
+ int price = yml.getInt(str+"price");
+ if(!DemonAPI.hasPoints(p,price)){
+ p.sendMessage(Main.prefix + "你需要§d" + price + "§f点券才能操作.");
+ p.closeInventory();
+ return;
+ }
+ DemonAPI.takePoints(p,price);
+ p.getInventory().addItem(yml.getItemStack(str+"items").clone());
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/me/Demon/DemonBuildShop/gui_6.java b/src/main/java/me/Demon/DemonBuildShop/gui_6.java
new file mode 100644
index 0000000..004b0d4
--- /dev/null
+++ b/src/main/java/me/Demon/DemonBuildShop/gui_6.java
@@ -0,0 +1,100 @@
+package me.Demon.DemonBuildShop;
+
+import cn.hamster3.api.HamsterAPI;
+import me.Demon.DemonPlugin.DemonAPI;
+import me.skymc.taboomenu.TabooMenuAPI;
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.Sound;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemFlag;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class gui_6 implements Listener {
+
+ public static String inv_title = "建材商店(第六页)";
+ public static String Next_String = "ItemShop_6";
+ public static FileConfiguration yml = Main.plugin.getConfig();
+
+ public static void OpenGui(Player p){
+ Inventory inv = Bukkit.createInventory(null,54,inv_title);
+ if(yml.getConfigurationSection(Next_String) != null) {
+ for (String slot : yml.getConfigurationSection(Next_String).getKeys(false)) {
+ double price = yml.getDouble(Next_String+"." + slot + ".price");
+ ItemStack items = yml.getItemStack(Next_String+"." + slot + ".items").clone();
+ inv.setItem(Integer.parseInt(slot), shopItems(items, price));
+ }
+ }
+ inv.setItem(45,arrow(Material.ARROW,"§a上一页"));
+ inv.setItem(49, Main.BackBook("§a返回菜单"));
+ inv.setItem(53,arrow(Material.BARRIER,"§c最后一页了!"));
+ p.openInventory(inv);
+ }
+
+ public static ItemStack shopItems(ItemStack items,double price){
+ ItemStack item = items.clone();
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(DemonAPI.getItemName(item));
+ List lore = new ArrayList<>();
+ lore.add("§7价格: "+(int) price+"点券");
+ lore.add("§7数量: "+item.getAmount()+"个");
+ lore.add("§a§l✔§7点击购买");
+ meta.setLore(lore);
+ meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
+ item.setItemMeta(meta);
+ return item;
+ }
+
+ public static ItemStack arrow(Material material, String name){
+ ItemStack item = new ItemStack(material);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName(name);
+ item.setItemMeta(meta);
+ return item;
+ }
+
+ @EventHandler
+ public void onclick(InventoryClickEvent e){
+ Player p = (Player) e.getWhoClicked();
+ if(inv_title.equalsIgnoreCase(e.getView().getTitle())){
+ e.setCancelled(true);
+ if(e.getRawSlot() == 45){
+ gui_5.OpenGui(p);
+ p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK,1,2);
+ return;
+ }
+ if(e.getRawSlot() == 53){
+ p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK,1,2);
+ return;
+ }
+ if(e.getRawSlot() == 49){
+ TabooMenuAPI.openMenu(p,"商城菜单",true);
+ }
+ if(e.getRawSlot() >= 0 && e.getRawSlot() < 45){
+ ItemStack item = e.getCurrentItem();
+ if(!DemonAPI.itemIsNull(item) && !DemonAPI.itemIsLore(item)){
+ String str = Next_String+"."+e.getRawSlot()+".";
+ p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK,1,2);
+ //获取这个物品多少钱
+ int price = yml.getInt(str+"price");
+ if(!DemonAPI.hasPoints(p,price)){
+ p.sendMessage(Main.prefix + "你需要§d" + price + "§f点券才能操作.");
+ p.closeInventory();
+ return;
+ }
+ DemonAPI.takePoints(p,price);
+ p.getInventory().addItem(yml.getItemStack(str+"items").clone());
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
new file mode 100644
index 0000000..e69de29
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
new file mode 100644
index 0000000..97233e4
--- /dev/null
+++ b/src/main/resources/plugin.yml
@@ -0,0 +1,7 @@
+name: DemonBuildShop
+main: me.Demon.DemonBuildShop.Main
+version: 1.0
+depend:
+ - DemonAPI
+commands:
+ buildshop:
\ No newline at end of file