diff --git a/src/main/java/com/yaohun/enderdragonwars/listener/RepairGiftGui.java b/src/main/java/com/yaohun/enderdragonwars/listener/RepairGiftGui.java index 23f3cc8..7a4cc7f 100644 --- a/src/main/java/com/yaohun/enderdragonwars/listener/RepairGiftGui.java +++ b/src/main/java/com/yaohun/enderdragonwars/listener/RepairGiftGui.java @@ -1,9 +1,10 @@ package com.yaohun.enderdragonwars.listener; +import com.io.yutian.mclive.event.ZhuboAPI; import com.yaohun.enderdragonwars.Main; import com.yaohun.enderdragonwars.data.GiftData; +import com.yaohun.enderdragonwars.manager.GameManager; import com.yaohun.enderdragonwars.manager.GiftEffectManager; -import com.yaohun.enderdragonwars.util.GameUtil; import com.yaohun.enderdragonwars.util.RandomUtil; import de.tr7zw.nbtapi.NBTItem; import org.bukkit.Bukkit; @@ -26,106 +27,6 @@ public class RepairGiftGui implements Listener { public static String invTitle = "我的世界整蛊 - 礼物触发管理"; - 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; - } - @EventHandler public void onClick(InventoryClickEvent e) { int rawSlot = e.getRawSlot(); @@ -154,26 +55,13 @@ public class RepairGiftGui implements Listener { 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); + GiftEffectManager.addGiftEffect(userName, eventName); } else { for (int i = 0; i < amount; i++) { Bukkit.getScheduler().runTaskLater(Main.plugin, () -> { - giftData.playSoundEvent(); - GiftEffectManager.addGiftEffect(hide_userName, eventName); + GiftEffectManager.addGiftEffect(userName, eventName); }, (long) i * 5); } } @@ -182,4 +70,191 @@ public class RepairGiftGui implements Listener { } } } -} + + public static void OpenGui(Player p) { + Inventory inv = Bukkit.createInventory(null, 27, invTitle); + HashMap hashMap = new HashMap<>(); + if (ZhuboAPI.getRoomLiveName().equalsIgnoreCase("KuaiShou")) { + hashMap.put("棒棒糖", stackGift("棒棒糖", 101)); + hashMap.put("比心", stackGift("比心", 102)); + hashMap.put("粉丝团灯牌", stackGift("粉丝团灯牌", 103)); + hashMap.put("集结票", stackGift("集结票", 104)); + hashMap.put("浪漫风铃", stackGift("浪漫风铃", 105)); + hashMap.put("玫瑰", stackGift("玫瑰", 106)); + hashMap.put("玫瑰花园", stackGift("玫瑰花园", 107)); + hashMap.put("魔法箱子", stackGift("魔法箱子", 108)); + hashMap.put("摸摸头", stackGift("摸摸头", 109)); + hashMap.put("陪伴你", stackGift("陪伴你", 110)); + hashMap.put("啤酒", stackGift("啤酒", 111)); + hashMap.put("人气卡", stackGift("人气卡", 112)); + hashMap.put("人气票", stackGift("人气票", 113)); + hashMap.put("送你花环", stackGift("送你花环", 114)); + hashMap.put("童话日记", stackGift("童话日记", 115)); + hashMap.put("小白菜", stackGift("小白菜", 116)); + hashMap.put("钻戒", stackGift("钻戒", 117)); + hashMap.put("荧光棒", stackGift("荧光棒", 118)); + hashMap.put("小可爱", stackGift("小可爱", 119)); + } else { + 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) { + boolean hdError = true; + 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) { + if (!hdError) { + meta.setCustomModelData(model_id); + } + } else { + item.setType(Material.DIAMOND); + } + if (hdError) { + item.setType(getMaterial(name)); + } + item.setItemMeta(meta); + NBTItem nbti = new NBTItem(item); + nbti.setString("giftName", name); + item = nbti.getItem(); + return item; + } + + public static Material getMaterial(String giftName) { + if (giftName.equalsIgnoreCase("抖音")) { + return Material.YELLOW_DYE; + } else if (giftName.equalsIgnoreCase("人气票")) { + return Material.MUSIC_DISC_WAIT; + } else if (giftName.equalsIgnoreCase("小心心")) { + return Material.LIME_DYE; + } else if (giftName.equalsIgnoreCase("粉丝团灯牌")) { + return Material.MAGENTA_DYE; + } else if (giftName.equalsIgnoreCase("你最好看")) { + return Material.MUSIC_DISC_BLOCKS; + } else if (giftName.equalsIgnoreCase("闪耀星辰")) { + return Material.MUSIC_DISC_WARD; + } else if (giftName.equalsIgnoreCase("黄桃罐头")) { + return Material.MUSIC_DISC_PIGSTEP; + } else if (giftName.equalsIgnoreCase("多喝热水")) { + return Material.MUSIC_DISC_CAT; + } else if (giftName.equalsIgnoreCase("比心兔兔")) { + return Material.MUSIC_DISC_13; + } else if (giftName.equalsIgnoreCase("捏捏小脸")) { + return Material.MUSIC_DISC_11; + } else if (giftName.equalsIgnoreCase("礼花筒")) { + return Material.MUSIC_DISC_STRAD; + } else if (giftName.equalsIgnoreCase("真爱玫瑰")) { + return Material.MUSIC_DISC_FAR; + } else if (giftName.equalsIgnoreCase("Thuglife")) { + return Material.PINK_DYE; + } else if (giftName.equalsIgnoreCase("助力票")) { + return Material.MUSIC_DISC_MALL; + } else if (giftName.equalsIgnoreCase("抖音1号")) { + return Material.MUSIC_DISC_STAL; + } else if (giftName.equalsIgnoreCase("大啤酒")) { + return Material.GREEN_DYE; + } else if (giftName.equalsIgnoreCase("玫瑰")) { + return Material.ORANGE_DYE; + } else if (giftName.equalsIgnoreCase("棒棒糖")) { + return Material.BROWN_DYE; + } else if (giftName.equalsIgnoreCase("鲜花")) { + return Material.GRAY_DYE; + } else if (giftName.equalsIgnoreCase("加油鸭")) { + return Material.CYAN_DYE; + } else if (giftName.equalsIgnoreCase("爱你哟")) { + return Material.BLUE_DYE; + } else if (giftName.equalsIgnoreCase("送你花花")) { + return Material.MUSIC_DISC_MELLOHI; + } else if (giftName.equalsIgnoreCase("爱的纸鹤")) { + return Material.BLACK_DYE; + } else if (giftName.equalsIgnoreCase("亲吻")) { + return Material.LIGHT_BLUE_DYE; + } else if (giftName.equalsIgnoreCase("真的爱你")) { + return Material.RED_DYE; + } else if (giftName.equalsIgnoreCase("热气球")) { + return Material.LIGHT_GRAY_DYE; + } else if (giftName.equalsIgnoreCase("跑车")) { + return Material.PURPLE_DYE; + } + return Material.GOLD_INGOT; + } +} \ No newline at end of file diff --git a/src/main/java/com/yaohun/enderdragonwars/manager/GiftEffectManager.java b/src/main/java/com/yaohun/enderdragonwars/manager/GiftEffectManager.java index 25cff5b..8c337b7 100644 --- a/src/main/java/com/yaohun/enderdragonwars/manager/GiftEffectManager.java +++ b/src/main/java/com/yaohun/enderdragonwars/manager/GiftEffectManager.java @@ -58,6 +58,7 @@ public class GiftEffectManager { registerGiftEffect("螺旋升天", ToHeavenEffect::new); registerGiftEffect("怪物军团", SummonMobs::new); registerGiftEffect("芜湖起飞", WuHuJump::new); + registerGiftEffect("随机盲盒", RandomBox::new); } private static void registerGiftEffect(String id, Function giftEffectGetter) {