测试版1.0.3
This commit is contained in:
parent
6f4263d815
commit
5b76ef37c9
|
@ -1,9 +1,10 @@
|
||||||
package com.yaohun.enderdragonwars.listener;
|
package com.yaohun.enderdragonwars.listener;
|
||||||
|
|
||||||
|
import com.io.yutian.mclive.event.ZhuboAPI;
|
||||||
import com.yaohun.enderdragonwars.Main;
|
import com.yaohun.enderdragonwars.Main;
|
||||||
import com.yaohun.enderdragonwars.data.GiftData;
|
import com.yaohun.enderdragonwars.data.GiftData;
|
||||||
|
import com.yaohun.enderdragonwars.manager.GameManager;
|
||||||
import com.yaohun.enderdragonwars.manager.GiftEffectManager;
|
import com.yaohun.enderdragonwars.manager.GiftEffectManager;
|
||||||
import com.yaohun.enderdragonwars.util.GameUtil;
|
|
||||||
import com.yaohun.enderdragonwars.util.RandomUtil;
|
import com.yaohun.enderdragonwars.util.RandomUtil;
|
||||||
import de.tr7zw.nbtapi.NBTItem;
|
import de.tr7zw.nbtapi.NBTItem;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -26,9 +27,74 @@ public class RepairGiftGui implements Listener {
|
||||||
|
|
||||||
public static String invTitle = "我的世界整蛊 - 礼物触发管理";
|
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 eventName = giftData.getEvent();
|
||||||
|
if (amount <= 1) {
|
||||||
|
GiftEffectManager.addGiftEffect(userName, eventName);
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < amount; i++) {
|
||||||
|
Bukkit.getScheduler().runTaskLater(Main.plugin, () -> {
|
||||||
|
GiftEffectManager.addGiftEffect(userName, eventName);
|
||||||
|
}, (long) i * 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void OpenGui(Player p) {
|
public static void OpenGui(Player p) {
|
||||||
Inventory inv = Bukkit.createInventory(null, 27, invTitle);
|
Inventory inv = Bukkit.createInventory(null, 27, invTitle);
|
||||||
HashMap<String, ItemStack> hashMap = new HashMap<>();
|
HashMap<String, ItemStack> 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("ONE礼挑一", stackGift("ONE礼挑一", 1));
|
||||||
hashMap.put("Thuglife", stackGift("Thuglife", 2));
|
hashMap.put("Thuglife", stackGift("Thuglife", 2));
|
||||||
hashMap.put("爱的纸鹤", stackGift("爱的纸鹤", 3));
|
hashMap.put("爱的纸鹤", stackGift("爱的纸鹤", 3));
|
||||||
|
@ -86,6 +152,7 @@ public class RepairGiftGui implements Listener {
|
||||||
hashMap.put("纸短情长", stackGift("纸短情长", 54));
|
hashMap.put("纸短情长", stackGift("纸短情长", 54));
|
||||||
hashMap.put("蝶 · 比翼鸟", stackGift("蝶 · 比翼鸟", 56));
|
hashMap.put("蝶 · 比翼鸟", stackGift("蝶 · 比翼鸟", 56));
|
||||||
hashMap.put("永生花", stackGift("永生花", 57));
|
hashMap.put("永生花", stackGift("永生花", 57));
|
||||||
|
}
|
||||||
Map<String, GiftData> giftData = Main.gameManager.getGiftDataMap();
|
Map<String, GiftData> giftData = Main.gameManager.getGiftDataMap();
|
||||||
for (String giftName : giftData.keySet()) {
|
for (String giftName : giftData.keySet()) {
|
||||||
if (hashMap.get(giftName) != null) {
|
if (hashMap.get(giftName) != null) {
|
||||||
|
@ -98,6 +165,7 @@ public class RepairGiftGui implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack stackGift(String name, int model_id) {
|
public static ItemStack stackGift(String name, int model_id) {
|
||||||
|
boolean hdError = true;
|
||||||
ItemStack item = new ItemStack(Material.PAPER);
|
ItemStack item = new ItemStack(Material.PAPER);
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
meta.setDisplayName("§d§l★ §e礼物: " + name);
|
meta.setDisplayName("§d§l★ §e礼物: " + name);
|
||||||
|
@ -115,10 +183,15 @@ public class RepairGiftGui implements Listener {
|
||||||
lore.add("§b§l★ §6SHIFT+右键 §7召唤188次");
|
lore.add("§b§l★ §6SHIFT+右键 §7召唤188次");
|
||||||
meta.setLore(lore);
|
meta.setLore(lore);
|
||||||
if (model_id >= 1) {
|
if (model_id >= 1) {
|
||||||
|
if (!hdError) {
|
||||||
meta.setCustomModelData(model_id);
|
meta.setCustomModelData(model_id);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
item.setType(Material.DIAMOND);
|
item.setType(Material.DIAMOND);
|
||||||
}
|
}
|
||||||
|
if (hdError) {
|
||||||
|
item.setType(getMaterial(name));
|
||||||
|
}
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
NBTItem nbti = new NBTItem(item);
|
NBTItem nbti = new NBTItem(item);
|
||||||
nbti.setString("giftName", name);
|
nbti.setString("giftName", name);
|
||||||
|
@ -126,60 +199,62 @@ public class RepairGiftGui implements Listener {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
public static Material getMaterial(String giftName) {
|
||||||
public void onClick(InventoryClickEvent e) {
|
if (giftName.equalsIgnoreCase("抖音")) {
|
||||||
int rawSlot = e.getRawSlot();
|
return Material.YELLOW_DYE;
|
||||||
Player zhubo = (Player) e.getWhoClicked();
|
} else if (giftName.equalsIgnoreCase("人气票")) {
|
||||||
Inventory inv = e.getInventory();
|
return Material.MUSIC_DISC_WAIT;
|
||||||
if (e.getView().getTitle().equalsIgnoreCase(invTitle)) {
|
} else if (giftName.equalsIgnoreCase("小心心")) {
|
||||||
if (rawSlot >= 0) {
|
return Material.LIME_DYE;
|
||||||
e.setCancelled(true);
|
} else if (giftName.equalsIgnoreCase("粉丝团灯牌")) {
|
||||||
zhubo.closeInventory();
|
return Material.MAGENTA_DYE;
|
||||||
ItemStack stack = e.getCurrentItem();
|
} else if (giftName.equalsIgnoreCase("你最好看")) {
|
||||||
if (stack != null && stack.getType() != Material.AIR) {
|
return Material.MUSIC_DISC_BLOCKS;
|
||||||
NBTItem nbti = new NBTItem(stack);
|
} else if (giftName.equalsIgnoreCase("闪耀星辰")) {
|
||||||
if (nbti.hasKey("giftName")) {
|
return Material.MUSIC_DISC_WARD;
|
||||||
String giftName = nbti.getString("giftName");
|
} else if (giftName.equalsIgnoreCase("黄桃罐头")) {
|
||||||
String userName = "抖音" + RandomUtil.getRandomInt(1, 100);
|
return Material.MUSIC_DISC_PIGSTEP;
|
||||||
int amount = 1;
|
} else if (giftName.equalsIgnoreCase("多喝热水")) {
|
||||||
if (e.getClick() == ClickType.RIGHT) {
|
return Material.MUSIC_DISC_CAT;
|
||||||
amount = 10;
|
} else if (giftName.equalsIgnoreCase("比心兔兔")) {
|
||||||
} else if (e.getClick() == ClickType.SHIFT_LEFT) {
|
return Material.MUSIC_DISC_13;
|
||||||
amount = 66;
|
} else if (giftName.equalsIgnoreCase("捏捏小脸")) {
|
||||||
} else if (e.getClick() == ClickType.SHIFT_RIGHT) {
|
return Material.MUSIC_DISC_11;
|
||||||
amount = 188;
|
} else if (giftName.equalsIgnoreCase("礼花筒")) {
|
||||||
}
|
return Material.MUSIC_DISC_STRAD;
|
||||||
if (Main.gameManager.getGiftData(giftName) == null) {
|
} else if (giftName.equalsIgnoreCase("真爱玫瑰")) {
|
||||||
zhubo.sendTitle("§r", "§c未设置效果", 10, 30, 10);
|
return Material.MUSIC_DISC_FAR;
|
||||||
return;
|
} else if (giftName.equalsIgnoreCase("Thuglife")) {
|
||||||
}
|
return Material.PINK_DYE;
|
||||||
GiftData giftData = Main.gameManager.getGiftData(giftName);
|
} else if (giftName.equalsIgnoreCase("助力票")) {
|
||||||
String hide_userName = GameUtil.hideName(userName);
|
return Material.MUSIC_DISC_MALL;
|
||||||
String eventName = giftData.getEvent();
|
} else if (giftName.equalsIgnoreCase("抖音1号")) {
|
||||||
String eventName_Show = eventName;
|
return Material.MUSIC_DISC_STAL;
|
||||||
if (amount >= 2) {
|
} else if (giftName.equalsIgnoreCase("大啤酒")) {
|
||||||
String title = "§c" + eventName_Show + " x" + amount;
|
return Material.GREEN_DYE;
|
||||||
String subtitle = "§9" + hide_userName;
|
} else if (giftName.equalsIgnoreCase("玫瑰")) {
|
||||||
zhubo.sendTitle(title, subtitle, 0, 30, 10);
|
return Material.ORANGE_DYE;
|
||||||
} else {
|
} else if (giftName.equalsIgnoreCase("棒棒糖")) {
|
||||||
String title = "§c" + eventName_Show;
|
return Material.BROWN_DYE;
|
||||||
String subtitle = "§9" + hide_userName;
|
} else if (giftName.equalsIgnoreCase("鲜花")) {
|
||||||
zhubo.sendTitle(title, subtitle, 0, 30, 10);
|
return Material.GRAY_DYE;
|
||||||
}
|
} else if (giftName.equalsIgnoreCase("加油鸭")) {
|
||||||
if (amount <= 1) {
|
return Material.CYAN_DYE;
|
||||||
giftData.playSoundEvent();
|
} else if (giftName.equalsIgnoreCase("爱你哟")) {
|
||||||
GiftEffectManager.addGiftEffect(hide_userName, eventName);
|
return Material.BLUE_DYE;
|
||||||
} else {
|
} else if (giftName.equalsIgnoreCase("送你花花")) {
|
||||||
for (int i = 0; i < amount; i++) {
|
return Material.MUSIC_DISC_MELLOHI;
|
||||||
Bukkit.getScheduler().runTaskLater(Main.plugin, () -> {
|
} else if (giftName.equalsIgnoreCase("爱的纸鹤")) {
|
||||||
giftData.playSoundEvent();
|
return Material.BLACK_DYE;
|
||||||
GiftEffectManager.addGiftEffect(hide_userName, eventName);
|
} else if (giftName.equalsIgnoreCase("亲吻")) {
|
||||||
}, (long) i * 5);
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -58,6 +58,7 @@ public class GiftEffectManager {
|
||||||
registerGiftEffect("螺旋升天", ToHeavenEffect::new);
|
registerGiftEffect("螺旋升天", ToHeavenEffect::new);
|
||||||
registerGiftEffect("怪物军团", SummonMobs::new);
|
registerGiftEffect("怪物军团", SummonMobs::new);
|
||||||
registerGiftEffect("芜湖起飞", WuHuJump::new);
|
registerGiftEffect("芜湖起飞", WuHuJump::new);
|
||||||
|
registerGiftEffect("随机盲盒", RandomBox::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerGiftEffect(String id, Function<String, GiftEffect> giftEffectGetter) {
|
private static void registerGiftEffect(String id, Function<String, GiftEffect> giftEffectGetter) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user