diff --git a/pom.xml b/pom.xml
index a89ef51..8ede8b5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -18,10 +18,6 @@
papermc-repo
https://repo.papermc.io/repository/maven-public/
-
- sonatype
- https://oss.sonatype.org/content/groups/public/
-
public-rpg
https://repo.aurora-pixels.com/repository/public-rpg/
@@ -41,6 +37,16 @@
2.11.1
857
+
+ com.yaohun.live-api
+ McLiveAPI
+ 1.18.2
+
+
+ com.yaohun.nbtapi
+ NBT-API
+ 1.12.2
+
diff --git a/src/main/java/com/yaohun/enderdragonwars/Main.java b/src/main/java/com/yaohun/enderdragonwars/Main.java
index 3143e5c..77b5c0a 100644
--- a/src/main/java/com/yaohun/enderdragonwars/Main.java
+++ b/src/main/java/com/yaohun/enderdragonwars/Main.java
@@ -1,5 +1,6 @@
package com.yaohun.enderdragonwars;
+import com.yaohun.enderdragonwars.listener.RepairGiftGui;
import com.yaohun.enderdragonwars.effect.types.*;
import com.yaohun.enderdragonwars.game.Game;
import com.yaohun.enderdragonwars.listener.GameListener;
@@ -29,6 +30,7 @@ public class Main extends JavaPlugin {
Bukkit.getPluginManager().registerEvents(new PlayerListener(), this);
Bukkit.getPluginManager().registerEvents(new GameListener(), this);
Bukkit.getPluginManager().registerEvents(new LiveListener(), this);
+ Bukkit.getPluginManager().registerEvents(new RepairGiftGui(), this);
}
@Override
diff --git a/src/main/java/com/yaohun/enderdragonwars/listener/GameListener.java b/src/main/java/com/yaohun/enderdragonwars/listener/GameListener.java
index f4ec9e0..a6a4f9b 100644
--- a/src/main/java/com/yaohun/enderdragonwars/listener/GameListener.java
+++ b/src/main/java/com/yaohun/enderdragonwars/listener/GameListener.java
@@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
+import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
@@ -44,6 +45,17 @@ public class GameListener implements Listener {
Main.game.removePlayerDataBossBar( );
}
+ @EventHandler
+ public void onPick(PlayerDropItemEvent e){
+ Player p = e.getPlayer();
+ if (Main.game.isStartd()) {
+ if(p.isSneaking()){
+ e.setCancelled(true);
+ RepairGiftGui.OpenGui(p);
+ }
+ }
+ }
+
/*
* 死亡后游戏时间 +5分钟
* */
diff --git a/src/main/java/com/yaohun/enderdragonwars/listener/RepairGiftGui.java b/src/main/java/com/yaohun/enderdragonwars/listener/RepairGiftGui.java
new file mode 100644
index 0000000..2b0ac27
--- /dev/null
+++ b/src/main/java/com/yaohun/enderdragonwars/listener/RepairGiftGui.java
@@ -0,0 +1,186 @@
+package com.yaohun.enderdragonwars.listener;
+
+import com.yaohun.enderdragonwars.Main;
+import com.yaohun.enderdragonwars.data.GiftData;
+import com.yaohun.enderdragonwars.liveevent.GiftEventHandler;
+import com.yaohun.enderdragonwars.manager.GiftEffectManager;
+import com.yaohun.enderdragonwars.util.GameUtil;
+import com.yaohun.enderdragonwars.util.RandomUtil;
+import de.tr7zw.itemnbtapi.NBTItem;
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.ClickType;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class RepairGiftGui implements Listener {
+
+ public static String invTitle = "我的世界整蛊 - 礼物触发管理";
+
+ @EventHandler
+ public void onClick(InventoryClickEvent e){
+ int rawSlot = e.getRawSlot();
+ Player zhubo = (Player) e.getWhoClicked();
+ Inventory inv = e.getInventory();
+ if(e.getView().getTitle().equalsIgnoreCase(invTitle)){
+ if(rawSlot >= 0) {
+ e.setCancelled(true);
+ zhubo.closeInventory();
+ ItemStack stack = e.getCurrentItem();
+ if (stack != null && stack.getType() != Material.AIR) {
+ NBTItem nbti = new NBTItem(stack);
+ if (nbti.hasKey("giftName")) {
+ String giftName = nbti.getString("giftName");
+ String userName = "抖音"+ RandomUtil.getRandomInt(1,100);
+ int amount = 1;
+ if (e.getClick() == ClickType.RIGHT) {
+ amount = 10;
+ } else if (e.getClick() == ClickType.SHIFT_LEFT) {
+ amount = 66;
+ }else if (e.getClick() == ClickType.SHIFT_RIGHT) {
+ amount = 188;
+ }
+ if(Main.gameManager.getGiftData(giftName) == null){
+ zhubo.sendTitle("§r", "§c未设置效果",10, 30, 10);
+ return;
+ }
+ GiftData giftData = Main.gameManager.getGiftData(giftName);
+ String hide_userName = GameUtil.hideName(userName);
+ String eventName = giftData.getEvent();
+ String eventName_Show = eventName;
+ if(amount >= 2) {
+ String title = "§c" + eventName_Show + " x" + amount;
+ String subtitle = "§9" + hide_userName;
+ zhubo.sendTitle(title, subtitle,0, 30, 10);
+ }else{
+ String title = "§c" + eventName_Show;
+ String subtitle = "§9" + hide_userName;
+ zhubo.sendTitle(title, subtitle,0, 30, 10);
+ }
+ if (amount <= 1) {
+ giftData.playSoundEvent();
+ GiftEffectManager.addGiftEffect(hide_userName, eventName);
+ } else {
+ for (int i = 0; i < amount; i++) {
+ Bukkit.getScheduler().runTaskLater(Main.plugin, () -> {
+ giftData.playSoundEvent();
+ GiftEffectManager.addGiftEffect(hide_userName, eventName);
+ }, (long) i * 5);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public static void OpenGui(Player p){
+ Inventory inv = Bukkit.createInventory(null,27,invTitle);
+ HashMap hashMap = new HashMap<>();
+ hashMap.put("ONE礼挑一", stackGift("ONE礼挑一", 1));
+ hashMap.put("Thuglife", stackGift("Thuglife", 2));
+ hashMap.put("爱的纸鹤", stackGift("爱的纸鹤", 3));
+ hashMap.put("爱你哟", stackGift("爱你哟", 4));
+ hashMap.put("棒棒糖", stackGift("棒棒糖", 5));
+ hashMap.put("比心", stackGift("比心", 6));
+ hashMap.put("比心兔兔", stackGift("比心兔兔", 7));
+ hashMap.put("称心如意", stackGift("称心如意", 8));
+ hashMap.put("大啤酒", stackGift("大啤酒", 9));
+ hashMap.put("点亮孤单", stackGift("点亮孤单", 10));
+ hashMap.put("抖音", stackGift("抖音", 11));
+ hashMap.put("抖音1号", stackGift("抖音1号", 12));
+ hashMap.put("多喝热水", stackGift("多喝热水", 13));
+ hashMap.put("繁花秘语", stackGift("繁花秘语", 14));
+ hashMap.put("粉丝团灯牌", stackGift("粉丝团灯牌", 15));
+ hashMap.put("光之祝福", stackGift("光之祝福", 16));
+ hashMap.put("豪华邮轮", stackGift("豪华邮轮", 17));
+ hashMap.put("花开烂漫", stackGift("花开烂漫", 18));
+ hashMap.put("花落长亭", stackGift("花落长亭", 19));
+ hashMap.put("环球旅行车", stackGift("环球旅行车", 20));
+ hashMap.put("黄桃罐头", stackGift("黄桃罐头", 21));
+ hashMap.put("加油鸭", stackGift("加油鸭", 22));
+ hashMap.put("嘉年华", stackGift("嘉年华", 23));
+ hashMap.put("浪漫花火", stackGift("浪漫花火", 24));
+ hashMap.put("礼花筒", stackGift("礼花筒", 25));
+ hashMap.put("龙抬头", stackGift("龙抬头", 26));
+ hashMap.put("玫瑰", stackGift("玫瑰", 27));
+ hashMap.put("你最好看", stackGift("你最好看", 28));
+ hashMap.put("捏捏小脸", stackGift("捏捏小脸", 29));
+ hashMap.put("跑车", stackGift("跑车", 30));
+ hashMap.put("保时捷", stackGift("保时捷", 30));
+ hashMap.put("怦然心动", stackGift("怦然心动", 31));
+ hashMap.put("亲吻", stackGift("亲吻", 32));
+ hashMap.put("拳拳出击", stackGift("拳拳出击", 33));
+ hashMap.put("热气球", stackGift("热气球", 34));
+ hashMap.put("人气票", stackGift("人气票", 35));
+ hashMap.put("日出相伴", stackGift("日出相伴", 36));
+ hashMap.put("闪耀星辰", stackGift("闪耀星辰", 37));
+ hashMap.put("私人飞机", stackGift("私人飞机", 38));
+ hashMap.put("送你花花", stackGift("送你花花", 39));
+ hashMap.put("万象烟花", stackGift("万象烟花", 40));
+ hashMap.put("为你闪耀", stackGift("为你闪耀", 41));
+ hashMap.put("为你举牌", stackGift("为你举牌", 42));
+ hashMap.put("鲜花", stackGift("鲜花", 43));
+ hashMap.put("小心心", stackGift("小心心", 44));
+ hashMap.put("星星点灯", stackGift("星星点灯", 45));
+ hashMap.put("一点心意", stackGift("一点心意", 46));
+ hashMap.put("一束花开", stackGift("一束花开", 47));
+ hashMap.put("荧光棒", stackGift("荧光棒", 48));
+ hashMap.put("游戏手柄", stackGift("游戏手柄", 49));
+ hashMap.put("掌上明珠", stackGift("掌上明珠", 50));
+ hashMap.put("真爱玫瑰", stackGift("真爱玫瑰", 51));
+ hashMap.put("真的爱你", stackGift("真的爱你", 52));
+ hashMap.put("直升机", stackGift("直升机", 53));
+ hashMap.put("纸短情长", stackGift("纸短情长", 54));
+ hashMap.put("蝶 · 比翼鸟", stackGift("蝶 · 比翼鸟", 56));
+ hashMap.put("永生花", stackGift("永生花", 57));
+ Map giftData = Main.gameManager.getGiftDataMap();
+ for (String giftName : giftData.keySet()){
+ if(hashMap.get(giftName) != null){
+ inv.addItem(hashMap.get(giftName));
+ }else{
+ inv.addItem(stackGift(giftName,-1));
+ }
+ }
+ p.openInventory(inv);
+ }
+
+ public static ItemStack stackGift(String name,int model_id) {
+ ItemStack item = new ItemStack(Material.PAPER);
+ ItemMeta meta = item.getItemMeta();
+ meta.setDisplayName("§d§l★ §e礼物: " + name);
+ List lore = new ArrayList<>();
+ if (Main.gameManager.getGiftData(name) != null) {
+ GiftData giftData = Main.gameManager.getGiftData(name);
+ lore.add("§7触发效果: §a" + giftData.getEvent());
+ } else {
+ lore.add("§7触发效果: §c无");
+ }
+ lore.add(" ");
+ lore.add("§b§l★ §6左键点击 §7召唤1次");
+ lore.add("§b§l★ §6右键点击 §7召唤10次");
+ lore.add("§b§l★ §6SHIFT+左键 §7召唤66次");
+ lore.add("§b§l★ §6SHIFT+右键 §7召唤188次");
+ meta.setLore(lore);
+ if (model_id >= 1){
+ meta.setCustomModelData(model_id);
+ }else{
+ item.setType(Material.DIAMOND);
+ }
+ item.setItemMeta(meta);
+ NBTItem nbti = new NBTItem(item);
+ nbti.setString("giftName",name);
+ item = nbti.getItem();
+ return item;
+ }
+}