diff --git a/pom.xml b/pom.xml index 123a918..268d2ea 100644 --- a/pom.xml +++ b/pom.xml @@ -47,6 +47,16 @@ NBT-API 1.12.2 + + com.yaohun.playermanage + PlayerManage + 1.0.3 + + + com.vexview.api + vexview + 1.12.2 + \ No newline at end of file diff --git a/src/main/java/me/Demon/AskyBlockWarps/Data/WarpData.java b/src/main/java/me/Demon/AskyBlockWarps/Data/WarpData.java index 7fc366c..118a158 100644 --- a/src/main/java/me/Demon/AskyBlockWarps/Data/WarpData.java +++ b/src/main/java/me/Demon/AskyBlockWarps/Data/WarpData.java @@ -14,8 +14,6 @@ public class WarpData { private String key; private Location location; - private boolean locSwitch; - private Island island; public WarpData(String key){ FileConfiguration yml = Main.plugin.getConfig(); @@ -33,19 +31,15 @@ public class WarpData { float yaw = (float) yml.getDouble(string+"yaw"); float pitch = (float) yml.getDouble(string+"pitch"); this.location = new Location(world,x,y,z,yaw,pitch); - this.island = ASkyBlockAPI.getInstance().getIslandAt(location); - this.locSwitch = yml.getBoolean(string+"switch"); } public WarpData(String key,Location location){ this.key = key; this.location = location; - this.locSwitch = true; } public void SaveData(){ FileConfiguration yml = Main.plugin.getConfig(); String string = "Stats."+key+"."; - yml.set(string+"switch",this.locSwitch); yml.set(string+"world",location.getWorld().getName()); yml.set(string+"x",location.getX()); yml.set(string+"y",location.getY()); @@ -66,12 +60,4 @@ public class WarpData { public void setLocation(Location location) { this.location = location; } - - public boolean isLocSwitch() { - return locSwitch; - } - - public Island getIsland() { - return island; - } } diff --git a/src/main/java/me/Demon/AskyBlockWarps/Listener/AcceptGui.java b/src/main/java/me/Demon/AskyBlockWarps/Listener/AcceptGui.java new file mode 100644 index 0000000..8a71fad --- /dev/null +++ b/src/main/java/me/Demon/AskyBlockWarps/Listener/AcceptGui.java @@ -0,0 +1,93 @@ +package me.Demon.AskyBlockWarps.Listener; + +import com.wasteofplastic.askyblock.ASkyBlockAPI; +import de.tr7zw.itemnbtapi.NBTItem; +import me.Demon.AskyBlockWarps.Main; +import me.Demon.DemonPlugin.DemonAPI; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +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.scheduler.BukkitRunnable; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +public class AcceptGui implements Listener { + public static String invtitle = "帝国战争 - 岛屿邀请"; + public static List playerList = new ArrayList<>(); + @EventHandler + public void onclick(InventoryClickEvent e) { + int rawSlot = e.getRawSlot(); + Player p = (Player) e.getWhoClicked(); + if (e.getInventory() != null && e.getInventory().getTitle().contains(invtitle)) { + e.setCancelled(true); + if (rawSlot >= 0 && rawSlot < e.getInventory().getSize()) { + if(rawSlot == 2){ + playerList.add(p); + p.closeInventory(); + p.performCommand("is accept"); + new BukkitRunnable() { + @Override + public void run() { + playerList.remove(p); + } + }.runTaskLater(Main.plugin,60L); + } + if(rawSlot == 6){ + p.performCommand("is reject"); + } + } + } + } + + + @EventHandler + public void onclick(InventoryCloseEvent e) { + Player p = (Player) e.getPlayer(); + if (e.getInventory() != null && e.getInventory().getTitle().contains(invtitle)) { + if (!playerList.contains(p)) { + p.performCommand("is reject"); + } + } + } + + public static void Opengui(Player p) { + Inventory inv = Bukkit.createInventory(null, 9, invtitle); + inv.setItem(2,Accept()); + inv.setItem(6,Deny()); + p.openInventory(inv); + } + + public static ItemStack Accept() { + ItemStack item = new ItemStack(Material.SLIME_BALL); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName("§6§l接受邀请"); + List lore = new ArrayList<>(); + lore.add("§r"); + lore.add("§6▸ §e点击操作"); + meta.setLore(lore); + item.setItemMeta(meta); + return item; + } + public static ItemStack Deny() { + ItemStack item = new ItemStack(Material.MAGMA_CREAM); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName("§c§l拒绝邀请"); + List lore = new ArrayList<>(); + lore.add("§r"); + lore.add("§6▸ §e点击操作"); + meta.setLore(lore); + item.setItemMeta(meta); + return item; + } +} diff --git a/src/main/java/me/Demon/AskyBlockWarps/Listener/LandInviteGui.java b/src/main/java/me/Demon/AskyBlockWarps/Listener/LandInviteGui.java index 9489f8c..6026a50 100644 --- a/src/main/java/me/Demon/AskyBlockWarps/Listener/LandInviteGui.java +++ b/src/main/java/me/Demon/AskyBlockWarps/Listener/LandInviteGui.java @@ -1,19 +1,26 @@ package me.Demon.AskyBlockWarps.Listener; +import cn.hamster3.cdapi.CDTimeAPI; import com.wasteofplastic.askyblock.ASkyBlockAPI; +import de.tr7zw.itemnbtapi.NBTItem; import me.Demon.AskyBlockWarps.Main; import me.Demon.AskyBlockWarps.Util.itemUtil; import me.Demon.DemonPlugin.DemonAPI; import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.World; 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.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import java.util.ArrayList; import java.util.List; +import java.util.UUID; public class LandInviteGui implements Listener { public static String invtitle = "帝国战争 - 成员邀请"; @@ -23,14 +30,23 @@ public class LandInviteGui implements Listener { Player p = (Player) e.getWhoClicked(); if (e.getInventory() != null && e.getInventory().getTitle().contains(invtitle)) { e.setCancelled(true); - ItemStack item = e.getCurrentItem(); - if (e.getRawSlot() >= 0 && e.getRawSlot() < e.getInventory().getSize() && !DemonAPI.itemIsNull(item) && !DemonAPI.itemIsLore(item)) { - if (ASkyBlockAPI.getInstance().getOwner(p.getLocation()).equals(p.getUniqueId())) { - String playName = item.getItemMeta().getDisplayName().replace("§6§l玩家 §e", ""); - p.performCommand("is invite " + playName); - } else { - p.sendMessage(Main.prefix + "您不是岛主,没权限邀请玩家加入岛屿."); - p.closeInventory(); + if (e.getRawSlot() >= 0 && e.getRawSlot() < e.getInventory().getSize()) { + ItemStack item = e.getCurrentItem(); + if(!DemonAPI.itemIsNull(item) && !DemonAPI.itemIsLore(item)) { + NBTItem nbtItem = new NBTItem(item); + if (nbtItem.hasKey("inviteName")) { + p.closeInventory(); + String name = nbtItem.getString("inviteName"); + p.performCommand("is invite " + name); + Player toPlayer = Bukkit.getPlayer(name); + if(CDTimeAPI.getCD(p.getUniqueId(),"inviteCd") > 0){ + return; + } + if(toPlayer != null){ + AcceptGui.Opengui(toPlayer); + CDTimeAPI.setPlayerCD(p.getUniqueId(),"inviteCd",1000 * 10); + } + } } } } @@ -40,20 +56,44 @@ public class LandInviteGui implements Listener { Inventory inv = Bukkit.createInventory(null, 54, invtitle); // 获取玩家附近20格内的所有玩家 List nearbyPlayers = new ArrayList<>(); - for (Player nearbyPlayer : Bukkit.getServer().getOnlinePlayers()) { - if (p.getWorld().equals(nearbyPlayer.getWorld())) { // 确保玩家在同一世界 - if (p.getLocation().distance(nearbyPlayer.getLocation()) <= 20) { + World world = p.getWorld(); + for (Player nearbyPlayer : world.getPlayers()) { + if (p.getLocation().distance(nearbyPlayer.getLocation()) <= 50) { + // 判断这个玩家是否已加入岛屿 + if(!ASkyBlockAPI.getInstance().hasIsland(nearbyPlayer.getUniqueId())) { nearbyPlayers.add(nearbyPlayer); } } } - + if(nearbyPlayers.size() < 1){ + p.sendMessage(Main.prefix + "您周围没有玩家可邀请加入岛屿."); + p.playSound(p.getLocation(), Sound.ENTITY_BLAZE_DEATH, 1.6F, 1.8F); + return; + } for (Player nearbyPlayer : nearbyPlayers) { if (!p.equals(nearbyPlayer)) { // 避免将玩家自己添加到GUI中 - inv.addItem(itemUtil.addTeam(nearbyPlayer.getName())); + inv.addItem(addTeam(nearbyPlayer.getName())); } } p.openInventory(inv); } + + public static ItemStack addTeam(String name) { + ItemStack item = new ItemStack(Material.SIGN); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName("§6§l玩家 §e" + name); + List lore = new ArrayList<>(); + lore.add("§r"); + lore.add("§c 请勿随意点击"); + lore.add("§c 请勿随意点击"); + lore.add("§c 请勿随意点击"); + lore.add("§r"); + lore.add("§6▸ §e点击邀请加入岛屿"); + meta.setLore(lore); + item.setItemMeta(meta); + NBTItem nbtItem = new NBTItem(item); + nbtItem.setString("inviteName",name); + return nbtItem.getItem(); + } } diff --git a/src/main/java/me/Demon/AskyBlockWarps/Listener/LandTeamGui.java b/src/main/java/me/Demon/AskyBlockWarps/Listener/LandTeamGui.java index 94b6eac..5ed7aad 100644 --- a/src/main/java/me/Demon/AskyBlockWarps/Listener/LandTeamGui.java +++ b/src/main/java/me/Demon/AskyBlockWarps/Listener/LandTeamGui.java @@ -1,17 +1,26 @@ package me.Demon.AskyBlockWarps.Listener; import com.wasteofplastic.askyblock.ASkyBlockAPI; +import com.wasteofplastic.askyblock.Island; +import com.yaohun.playermanage.PlayerManage; +import de.tr7zw.itemnbtapi.NBTItem; import me.Demon.AskyBlockWarps.Main; import me.Demon.AskyBlockWarps.Util.itemUtil; import me.Demon.DemonPlugin.DemonAPI; import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; 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.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import java.util.ArrayList; +import java.util.List; import java.util.UUID; public class LandTeamGui implements Listener { @@ -19,27 +28,89 @@ public class LandTeamGui implements Listener { @EventHandler public void onclick(InventoryClickEvent e) { + int rawSlot = e.getRawSlot(); + Inventory inv = e.getInventory(); Player p = (Player) e.getWhoClicked(); - if (e.getInventory() != null && e.getInventory().getTitle().contains(invtitle)) { + Location location = p.getLocation(); + String name = p.getName(); + if (inv != null && inv.getTitle().contains(invtitle)) { e.setCancelled(true); ItemStack item = e.getCurrentItem(); - if (e.getRawSlot() >= 0 && e.getRawSlot() < e.getInventory().getSize() && !DemonAPI.itemIsNull(item) && !DemonAPI.itemIsLore(item)) { - if (ASkyBlockAPI.getInstance().getIslandAt(p.getLocation()).equals(p.getUniqueId())) { - String playName = item.getItemMeta().getDisplayName().replace("§6§l成员 §e", ""); - p.performCommand("is expel " + playName); + if (rawSlot >= 0 && rawSlot < inv.getSize()) { + if(!DemonAPI.itemIsNull(item) && !DemonAPI.itemIsLore(item)) { + NBTItem nbtItem = new NBTItem(item); + if(nbtItem.hasKey("uuid")) { + String uuid = nbtItem.getString("uuid"); + // 获取当前岛屿数据 + Island island = ASkyBlockAPI.getInstance().getIslandAt(location); + UUID ownerUuid = island.getOwner(); + // 判断操作目标是否是岛屿主人 + if(ownerUuid.toString().equalsIgnoreCase(uuid)){ + p.sendMessage(Main.prefix + "无法对岛屿主人进行移除操作."); + p.playSound(p.getLocation(), Sound.ENTITY_BLAZE_DEATH,1.6F,1.8F); + return; + } + // 判断操作移除的人是否是岛屿主人 + if(!ownerUuid.equals(p.getUniqueId())){ + p.sendMessage(Main.prefix + "只有岛屿主人才能进行移除操作."); + p.playSound(p.getLocation(), Sound.ENTITY_BLAZE_DEATH,1.6F,1.8F); + return; + } + String kickName = PlayerManage.getUuidToName(uuid); + if(kickName == null){ + p.sendMessage(Main.prefix + "移除失败,无法获取该目标昵称."); + p.playSound(p.getLocation(), Sound.ENTITY_BLAZE_DEATH,1.6F,1.8F); + return; + } + p.performCommand("is expel " + kickName); + } } - } else { - p.sendMessage(Main.prefix + "您不是岛主,没权限将玩家移出岛屿."); - p.closeInventory(); } } } public static void Opengui(Player p) { Inventory inv = Bukkit.createInventory(null, 27, invtitle); - for (UUID uid : ASkyBlockAPI.getInstance().getTeamMembers(p.getUniqueId())) { - inv.addItem(itemUtil.teamList(Main.convertUUIDToName(uid))); + Island island = ASkyBlockAPI.getInstance().getIslandAt(p.getLocation()); + int slot = 0; + List uuidList = island.getMembers(); + uuidList.remove(0); + for (UUID uuid : uuidList){ + String name = PlayerManage.getUuidToName(uuid.toString()); + if (name != null) { + if (!uuid.equals(island.getOwner())) { + inv.setItem(slot,teamList(uuid,false)); + }else{ + inv.setItem(slot,teamList(uuid,true)); + } + slot++; + } } p.openInventory(inv); } + + public static ItemStack teamList(UUID uuid,boolean owner) { + ItemStack item = new ItemStack(Material.SIGN); + ItemMeta meta = item.getItemMeta(); + String name = PlayerManage.getUuidToName(uuid.toString()); + if(name == null){ + meta.setDisplayName("§6§l成员 §c无法获取"); + }else { + meta.setDisplayName("§6§l成员 §e" + name); + } + List lore = new ArrayList<>(); + lore.add("§r"); + if(owner){ + lore.add("§7 身份: §f岛主"); + }else { + lore.add("§7 身份: §f岛员"); + } + lore.add("§r"); + lore.add("§6▸ §c点击移除岛屿"); + meta.setLore(lore); + item.setItemMeta(meta); + NBTItem nbtItem = new NBTItem(item); + nbtItem.setString("uuid",uuid.toString()); + return nbtItem.getItem(); + } } diff --git a/src/main/java/me/Demon/AskyBlockWarps/Listener/MainGui.java b/src/main/java/me/Demon/AskyBlockWarps/Listener/MainGui.java index 8900bb3..a59770b 100644 --- a/src/main/java/me/Demon/AskyBlockWarps/Listener/MainGui.java +++ b/src/main/java/me/Demon/AskyBlockWarps/Listener/MainGui.java @@ -2,21 +2,30 @@ package me.Demon.AskyBlockWarps.Listener; import cn.hamster3.cdapi.CDTimeAPI; import com.wasteofplastic.askyblock.ASkyBlockAPI; +import com.wasteofplastic.askyblock.Island; +import com.yaohun.playermanage.PlayerManage; +import lk.vexview.api.VexViewAPI; import me.Demon.AskyBlockWarps.Main; import me.Demon.AskyBlockWarps.Manage.GameManage; import me.Demon.AskyBlockWarps.Util.itemUtil; import me.Demon.DemonPlugin.DemonAPI; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; +import org.bukkit.entity.Vex; 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; import java.util.UUID; public class MainGui implements Listener { @@ -27,103 +36,278 @@ public class MainGui implements Listener { int rawSlot = e.getRawSlot(); Inventory inv = e.getInventory(); Player p = (Player) e.getWhoClicked(); + Location location = p.getLocation(); String name = p.getName(); if (inv != null && inv.getTitle().contains(invtitle)) { e.setCancelled(true); if (rawSlot >= 0 && rawSlot < inv.getSize()) { - UUID islandOwner = ASkyBlockAPI.getInstance().getOwner(p.getLocation()); - if (e.getRawSlot() == 1) { + ItemStack item = e.getCurrentItem(); + if(DemonAPI.itemIsNull(item) || DemonAPI.itemIsName(item)){return;} + ItemMeta meta = item.getItemMeta(); + String itemName = meta.getDisplayName(); + if(itemName.contains("返回主页")){ + VexViewAPI.openGui(p,"主菜单"); + p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK, 1.6F, 1.8F); + return; + } + if(itemName.contains("返回空岛")){ p.performCommand("is"); p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 2.0F); p.closeInventory(); + return; } - - if (e.getRawSlot() == 3) { - if (islandOwner != null && islandOwner.equals(p.getUniqueId())) { - if (CDTimeAPI.getCD(p.getUniqueId(), "islandsetwarp") < 0) { - Main.gameManage.setWarpLoc(name,p.getLocation()); - p.sendMessage(Main.prefix + "设置空岛地标点成功."); - CDTimeAPI.setPlayerCD(p.getUniqueId(), "islandsetwarp", 1000 * 3); - p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 2.0F); - p.closeInventory(); - } else { - p.sendMessage(Main.prefix + "功能冷却中..."); - p.closeInventory(); - } - } else { - p.sendMessage(Main.prefix + "您只能在您的岛屿设置传送点地标."); - p.playSound(p.getLocation(), Sound.ENTITY_BLAZE_DEATH, 1.0F, 2.0F); - p.closeInventory(); - } - } - - if (e.getRawSlot() == 5) { + if(itemName.contains("空岛地标列表")){ WarpGui.Opengui(p); - p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 2.0F); + p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK, 1.6F, 1.8F); + return; } - - if (e.getRawSlot() == 7) { + if(itemName.contains("邀请加入空岛")){ + // 判断玩家是否拥有岛屿并且是岛主 + boolean isOwner = false; + Island island = ASkyBlockAPI.getInstance().getIslandOwnedBy(p.getUniqueId()); + if(island != null){ + UUID ownerUuid = island.getOwner(); + if(ownerUuid.equals(p.getUniqueId())){ + LandInviteGui.Opengui(p); + p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK, 1.6F, 1.8F); + isOwner = true; + } + } + if(!isOwner){ + p.sendMessage(Main.prefix + "您需要创建岛屿成为岛主后才能邀请玩家."); + p.playSound(p.getLocation(), Sound.ENTITY_BLAZE_DEATH, 1.6F, 1.8F); + } + return; + } + if(itemName.contains("设置空岛地标")){ + p.closeInventory(); + // 获取当前岛屿岛主UUID + Island island = ASkyBlockAPI.getInstance().getIslandAt(location); + if(island != null && !island.getOwner().equals(p.getUniqueId())){ + p.sendMessage(Main.prefix + "您只能在自己的岛屿设置传送点坐标."); + p.playSound(p.getLocation(), Sound.ENTITY_BLAZE_DEATH, 1.6F, 1.8F); + return; + } + if (CDTimeAPI.getCD(p.getUniqueId(), "islandsetwarp") > 0) { + p.sendMessage(Main.prefix + "请稍后再次尝试设置坐标."); + p.playSound(p.getLocation(), Sound.ENTITY_BLAZE_DEATH, 1.6F, 1.8F); + return; + } + if(!p.hasPermission("warps.create")){ + p.sendMessage(Main.prefix + "你需要成为 盫 §r才能设置坐标."); + p.playSound(p.getLocation(), Sound.ENTITY_BLAZE_DEATH, 1.6F, 1.8F); + return; + } + Main.gameManage.setWarpLoc(name,p.getLocation()); + p.sendMessage(Main.prefix + "设置空岛地标点成功."); + CDTimeAPI.setPlayerCD(p.getUniqueId(), "islandsetwarp", 1000 * 5); + p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.6F, 1.8F); + return; + } + if(itemName.contains("重置空岛")){ + p.closeInventory(); DemonAPI.sendTitle(p, 10, 20, 10, "§c§l空岛重置", "§6请联系群客服进行重置"); - p.sendMessage(Main.prefix + "请联系客服进行空岛重置报备!!!"); - p.sendMessage(Main.prefix + "请联系客服进行空岛重置报备!!!"); - p.sendMessage(Main.prefix + "请联系客服进行空岛重置报备!!!"); - p.playSound(p.getLocation(), Sound.ENTITY_BLAZE_DEATH, 1.0F, 2.0F); - p.closeInventory(); + p.sendMessage(Main.prefix + "需要重置岛屿,请联系群内客服申请报备!!!"); + p.sendMessage(Main.prefix + "需要重置岛屿,请联系群内客服申请报备!!!"); + p.sendMessage(Main.prefix + "需要重置岛屿,请联系群内客服申请报备!!!"); + p.playSound(p.getLocation(), Sound.ENTITY_BLAZE_DEATH, 1.6F, 1.8F); + return; } - - if (e.getRawSlot() == 11) { - p.performCommand("is top"); - p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 2.0F); + if(itemName.contains("岛屿等级")){ p.closeInventory(); + p.performCommand("is level"); + p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.6F, 1.8F); + return; } - - if (e.getRawSlot() == 13) { + if(itemName.contains("岛屿保护")){ + p.closeInventory(); + // 获取当前岛屿岛主UUID + Island island = ASkyBlockAPI.getInstance().getIslandAt(location); + if(island != null && !island.getOwner().equals(p.getUniqueId())){ + p.sendMessage(Main.prefix + "您只能在自己岛屿上才能设置岛屿保护."); + p.playSound(p.getLocation(), Sound.ENTITY_BLAZE_DEATH, 1.6F, 1.8F); + return; + } Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "asadmin lock " + p.getName()); - p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 2.0F); - p.closeInventory(); + p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.6F, 1.8F); + return; } - - if (e.getRawSlot() == 15) { + if(itemName.contains("查看空岛成员")){ LandTeamGui.Opengui(p); - p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 2.0F); + p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK, 1.6F, 1.8F); + return; } - if (e.getRawSlot() == 19) { - LandInviteGui.Opengui(p); - p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 2.0F); - } - if (e.getRawSlot() == 25) { + if(itemName.contains("挑战任务")){ p.performCommand("challenge"); - p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 2.0F); + p.playSound(p.getLocation(), Sound.BLOCK_COMPARATOR_CLICK, 1.6F, 1.8F); + return; } } } } public static void Opengui(Player p) { - Inventory inv = Bukkit.createInventory(null, 27, invtitle); - boolean butt = ASkyBlockAPI.getInstance().hasIsland(p.getUniqueId()); - - inv.setItem(1, itemUtil.backisland(butt)); - inv.setItem(3, itemUtil.setWarp()); - inv.setItem(5, itemUtil.warpList()); - inv.setItem(7, itemUtil.resetLand()); - inv.setItem(11, itemUtil.looklandlevel(p, butt)); - inv.setItem(13, itemUtil.islandlock()); - inv.setItem(15, itemUtil.islandlook(butt)); - inv.setItem(19, itemUtil.isLandinvite()); - inv.setItem(25, itemUtil.islandQuest()); - + Inventory inv = Bukkit.createInventory(null, 36, invtitle); + Island island = ASkyBlockAPI.getInstance().getIslandAt(p.getLocation()); + if (island == null) { + inv = Bukkit.createInventory(null, 9, invtitle); + inv.setItem(1, islandBack()); + inv.setItem(3, checkWarpList()); + inv.setItem(5, islandInvite()); + inv.setItem(8,backMenu()); + } else { + inv.setItem(1, islandBack()); + inv.setItem(3, setWarp()); + inv.setItem(5, checkWarpList()); + inv.setItem(7, resetIsland()); + inv.setItem(11, islandLevel(island)); + inv.setItem(13, islandlock(island)); + inv.setItem(15, islandlook(island)); + inv.setItem(19, islandInvite()); + inv.setItem(25, islandChallenge()); + inv.setItem(31,backMenu()); + } p.openInventory(inv); } - public void SetLocation(String key, Location loc) { - FileConfiguration yml = Main.plugin.getConfig(); - yml.set(key + ".world", loc.getWorld().getName()); - yml.set(key + ".x", loc.getX()); - yml.set(key + ".y", loc.getY()); - yml.set(key + ".z", loc.getZ()); - yml.set(key + ".yaw", loc.getYaw()); - yml.set(key + ".pitch", loc.getPitch()); - Main.plugin.saveConfig(); + public static ItemStack backMenu() { + ItemStack item = new ItemStack(Material.BOOK); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName("§a§l返回主页"); + item.setItemMeta(meta); + return item; } + + public static ItemStack islandInvite() { + ItemStack item = new ItemStack(Material.SLIME_BALL); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName("§6§l邀请加入空岛"); + List lore = new ArrayList<>(); + lore.add("§r"); + lore.add("§7 自动搜索周围玩家"); + lore.add("§r"); + lore.add("§6▸ §c点击邀请"); + meta.setLore(lore); + item.setItemMeta(meta); + return item; + } + + public static ItemStack islandBack() { + ItemStack item = new ItemStack(Material.GRASS); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName("§6§l返回空岛"); + List lore = new ArrayList<>(); + lore.add("§r"); + lore.add("§6▸ §e点击返回空岛"); + meta.setLore(lore); + item.setItemMeta(meta); + return item; + } + + public static ItemStack islandChallenge() { + ItemStack item = new ItemStack(Material.DIAMOND_CHESTPLATE); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName("§6§l挑战任务"); + List lore = new ArrayList<>(); + lore.add("§r"); + lore.add("§6▸ §e点击查看"); + meta.setLore(lore); + meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); + item.setItemMeta(meta); + return item; + } + + public static ItemStack islandLevel(Island island) { + ItemStack item = new ItemStack(Material.BEACON); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName("§6§l岛屿等级"); + List lore = new ArrayList<>(); + lore.add("§r"); + UUID islandOwner = island.getOwner(); + lore.add("§7 岛屿主人: §f" + PlayerManage.getUuidToName(islandOwner.toString())); + lore.add("§7 岛屿等级: §f" + ASkyBlockAPI.getInstance().getLongIslandLevel(islandOwner)); + lore.add("§r"); + lore.add("§6▸ §e点击刷新岛屿等级"); + meta.setLore(lore); + item.setItemMeta(meta); + return item; + } + + public static ItemStack islandlook(Island island) { + ItemStack item = new ItemStack(Material.EMPTY_MAP); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName("§6§l查看空岛成员"); + List lore = new ArrayList<>(); + lore.add("§r"); + lore.add(" §7岛屿成员:"); + List uuidList = island.getMembers(); + uuidList.remove(0); + for (UUID uuid : uuidList) { + String name = PlayerManage.getUuidToName(uuid.toString()); + lore.add(" §f - " + name); + } + lore.add("§r"); + lore.add("§6▸ §e点击查看"); + meta.setLore(lore); + item.setItemMeta(meta); + return item; + } + + public static ItemStack islandlock(Island island) { + ItemStack item = new ItemStack(Material.EYE_OF_ENDER); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName("§6§l岛屿保护"); + List lore = new ArrayList<>(); + lore.add("§r"); + if(!island.isLocked()){ + lore.add(" §7当前模式: §c封锁中"); + }else { + lore.add(" §7当前模式: §f开放中"); + item.setType(Material.ENDER_PEARL); + } + lore.add("§r"); + lore.add("§6▸ §c点击设置"); + meta.setLore(lore); + item.setItemMeta(meta); + return item; + } + + public static ItemStack resetIsland() { + ItemStack item = new ItemStack(Material.LAVA_BUCKET); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName("§6§l重置空岛"); + List lore = new ArrayList<>(); + lore.add("§r"); + lore.add("§6▸ §c点击重置"); + meta.setLore(lore); + item.setItemMeta(meta); + return item; + } + + public static ItemStack setWarp() { + ItemStack item = new ItemStack(Material.ANVIL); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName("§6§l设置空岛地标"); + List lore = new ArrayList<>(); + lore.add("§r"); + lore.add("§6▸ §e点击设置"); + meta.setLore(lore); + item.setItemMeta(meta); + return item; + } + + public static ItemStack checkWarpList() { + ItemStack item = new ItemStack(Material.SIGN); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName("§6§l空岛地标列表"); + List lore = new ArrayList<>(); + lore.add("§r"); + lore.add(" §7数量: §f"+Main.gameManage.getWarpDataMap().size()+"个"); + lore.add("§r"); + lore.add("§6▸ §e点击查看"); + meta.setLore(lore); + item.setItemMeta(meta); + return item; + } + } diff --git a/src/main/java/me/Demon/AskyBlockWarps/Listener/WarpGui.java b/src/main/java/me/Demon/AskyBlockWarps/Listener/WarpGui.java index 9e6fa82..2829d6e 100644 --- a/src/main/java/me/Demon/AskyBlockWarps/Listener/WarpGui.java +++ b/src/main/java/me/Demon/AskyBlockWarps/Listener/WarpGui.java @@ -3,6 +3,7 @@ package me.Demon.AskyBlockWarps.Listener; import cn.hamster3.cdapi.CDTimeAPI; import com.wasteofplastic.askyblock.ASkyBlockAPI; import com.wasteofplastic.askyblock.Island; +import com.yaohun.playermanage.PlayerManage; import de.tr7zw.itemnbtapi.NBTItem; import me.Demon.AskyBlockWarps.Data.WarpData; import me.Demon.AskyBlockWarps.Main; @@ -43,7 +44,12 @@ public class WarpGui implements Listener { p.playSound(p.getLocation(),Sound.BLOCK_COMPARATOR_CLICK,1,1); NBTItem nbtItem = new NBTItem(item); if(nbtItem.hasKey("warpKey")){ + boolean butt = nbtItem.getBoolean("warpLock"); String warpKey = nbtItem.getString("warpKey"); + if(butt){ + p.sendMessage(Main.prefix + "您想访问的目标岛屿处于封锁状态,无法访问."); + return; + } WarpData warpData = Main.gameManage.getWarpData(warpKey); Location location = warpData.getLocation().add(0,0.5,0); p.teleport(location); @@ -58,7 +64,10 @@ public class WarpGui implements Listener { HashMap warpDataHashMap = Main.gameManage.getWarpDataMap(); for (String key : warpDataHashMap.keySet()){ WarpData warpData = warpDataHashMap.get(key); - inv.addItem(warpShow(warpData)); + ItemStack item = warpShow(warpData); + if(item != null) { + inv.addItem(item); + } } p.openInventory(inv); } @@ -68,14 +77,30 @@ public class WarpGui implements Listener { ItemMeta meta = item.getItemMeta(); meta.setDisplayName("§6§l传送到 §e" + wData.getKey() + " §6§l的空岛"); List lore = new ArrayList<>(); - Island island = wData.getIsland(); - lore.add(" §7岛屿等级: §f"+island.getLevelHandicap()); - lore.add("§r"); - lore.add("§6▸ §e点击传送"); - meta.setLore(lore); - item.setItemMeta(meta); - NBTItem nbtItem = new NBTItem(item); - nbtItem.setString("warpKey",wData.getKey()); - return nbtItem.getItem(); + Island island = ASkyBlockAPI.getInstance().getIslandAt(wData.getLocation()); + if(island != null) { + lore.add(" §7岛屿等级: §f" + ASkyBlockAPI.getInstance().getLongIslandLevel(island.getOwner())); + boolean isBlockade = island.isLocked(); + if (isBlockade) { + lore.add(" §7岛屿状态: §c封锁"); + } else { + lore.add(" §7岛屿状态: §a开放"); + } + lore.add(" §7岛屿成员:"); + List uuidList = island.getMembers(); + for (UUID uuid : uuidList) { + String name = PlayerManage.getUuidToName(uuid.toString()); + lore.add(" §f - " + name); + } + lore.add("§r"); + lore.add("§6▸ §e点击传送"); + meta.setLore(lore); + item.setItemMeta(meta); + NBTItem nbtItem = new NBTItem(item); + nbtItem.setString("warpKey", wData.getKey()); + nbtItem.setBoolean("warpLock", isBlockade); + return nbtItem.getItem(); + } + return null; } } diff --git a/src/main/java/me/Demon/AskyBlockWarps/Main.java b/src/main/java/me/Demon/AskyBlockWarps/Main.java index f21099c..29383d1 100644 --- a/src/main/java/me/Demon/AskyBlockWarps/Main.java +++ b/src/main/java/me/Demon/AskyBlockWarps/Main.java @@ -1,10 +1,7 @@ package me.Demon.AskyBlockWarps; import me.Demon.AskyBlockWarps.Command.iswarpCommand; -import me.Demon.AskyBlockWarps.Listener.LandInviteGui; -import me.Demon.AskyBlockWarps.Listener.LandTeamGui; -import me.Demon.AskyBlockWarps.Listener.MainGui; -import me.Demon.AskyBlockWarps.Listener.WarpGui; +import me.Demon.AskyBlockWarps.Listener.*; import me.Demon.AskyBlockWarps.Manage.GameManage; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -28,28 +25,8 @@ public class Main extends JavaPlugin { Bukkit.getServer().getPluginManager().registerEvents(new WarpGui(), plugin); Bukkit.getServer().getPluginManager().registerEvents(new LandTeamGui(), plugin); Bukkit.getServer().getPluginManager().registerEvents(new LandInviteGui(), plugin); + Bukkit.getServer().getPluginManager().registerEvents(new AcceptGui(), plugin); getCommand("iswarps").setExecutor(new iswarpCommand()); getCommand("iswarps").setTabCompleter(new iswarpCommand()); } - - @Override - public void onDisable() { - - } - - public static String convertUUIDToName(UUID uuid) { - OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid); - return offlinePlayer.getName(); - } - - public static Location LandWarpLoc(String playName) { - FileConfiguration yml = Main.plugin.getConfig(); - String w = yml.getString("Stats." + playName + ".world"); - double x = yml.getDouble("Stats." + playName + ".x"); - double y = yml.getDouble("Stats." + playName + ".y"); - double z = yml.getDouble("Stats." + playName + ".z"); - float pi = (float) yml.getDouble("Stats." + playName + ".pitch"); - float ya = (float) yml.getDouble("Stats." + playName + ".yaw"); - return new Location(Bukkit.getWorld(w), x, y, z, ya, pi); - } } diff --git a/src/main/java/me/Demon/AskyBlockWarps/Manage/GameManage.java b/src/main/java/me/Demon/AskyBlockWarps/Manage/GameManage.java index 195e93a..df0e600 100644 --- a/src/main/java/me/Demon/AskyBlockWarps/Manage/GameManage.java +++ b/src/main/java/me/Demon/AskyBlockWarps/Manage/GameManage.java @@ -54,14 +54,6 @@ public class GameManage { Main.plugin.saveConfig(); } - // 获取这个传送点是否开启 - public boolean getWarpSwitch(String key){ - if(warpDataMap.get(key) == null){ - return false; - } - return warpDataMap.get(key).isLocSwitch(); - } - // 获取这个坐标点的坐标 public Location getWarpLoc(String key){ if(warpDataMap.get(key) == null){ diff --git a/src/main/java/me/Demon/AskyBlockWarps/Util/itemUtil.java b/src/main/java/me/Demon/AskyBlockWarps/Util/itemUtil.java index bf70da3..7796ceb 100644 --- a/src/main/java/me/Demon/AskyBlockWarps/Util/itemUtil.java +++ b/src/main/java/me/Demon/AskyBlockWarps/Util/itemUtil.java @@ -26,154 +26,4 @@ public class itemUtil { item.setItemMeta(meta); return item; } - - public static ItemStack addTeam(String name) { - ItemStack item = new ItemStack(Material.SIGN); - ItemMeta meta = item.getItemMeta(); - meta.setDisplayName("§6§l玩家 §e" + name); - List lore = new ArrayList<>(); - lore.add("§r"); - lore.add("§c 请勿随意点击"); - lore.add("§c 请勿随意点击"); - lore.add("§c 请勿随意点击"); - lore.add("§r"); - lore.add("§6▸ §e点击邀请加入岛屿"); - meta.setLore(lore); - item.setItemMeta(meta); - return item; - } - - public static ItemStack warpShow(String name) { - ItemStack item = new ItemStack(Material.SIGN); - ItemMeta meta = item.getItemMeta(); - meta.setDisplayName("§6§l传送到 §e" + name + " §6§l的空岛"); - List lore = new ArrayList<>(); - lore.add("§r"); - lore.add("§6▸ §e点击传送"); - meta.setLore(lore); - item.setItemMeta(meta); - return item; - } - - public static ItemStack looklandlevel(Player p,boolean butt) { - ItemStack item = new ItemStack(Material.BEACON); - ItemMeta meta = item.getItemMeta(); - meta.setDisplayName("§6§l岛屿等级"); - List lore = new ArrayList<>(); - lore.add("§r"); - if (butt) { - lore.add("§7 您的岛屿等级: §f" + ASkyBlockAPI.getInstance().getLongIslandLevel(p.getUniqueId())); - } else { - lore.add("§7 没有属于您的岛屿"); - } - lore.add("§r"); - lore.add("§6▸ §e点击查看空岛排行"); - meta.setLore(lore); - item.setItemMeta(meta); - return item; - } - - public static ItemStack backisland(boolean butt) { - ItemStack item = new ItemStack(Material.ENDER_PORTAL_FRAME); - ItemMeta meta = item.getItemMeta(); - meta.setDisplayName("§6§l返回空岛"); - List lore = new ArrayList<>(); - lore.add("§r"); - if (butt) { - lore.add("§6▸ §e点击返回空岛"); - } else { - lore.add("§6▸ §c点击创建空岛"); - } - meta.setLore(lore); - item.setItemMeta(meta); - return item; - } - - public static ItemStack isLandinvite() { - ItemStack item = new ItemStack(Material.SLIME_BALL); - ItemMeta meta = item.getItemMeta(); - meta.setDisplayName("§6§l邀请加入空岛"); - List lore = new ArrayList<>(); - lore.add("§r"); - lore.add("§6▸ §c点击邀请"); - meta.setLore(lore); - item.setItemMeta(meta); - return item; - } - - public static ItemStack islandlook(boolean butt) { - ItemStack item = new ItemStack(Material.EMPTY_MAP); - ItemMeta meta = item.getItemMeta(); - meta.setDisplayName("§6§l查看空岛成员"); - List lore = new ArrayList<>(); - lore.add("§r"); - if (butt) { - lore.add("§6▸ §e点击查看"); - } else { - lore.add("§6▸ §e没有属于您的岛屿"); - } - meta.setLore(lore); - item.setItemMeta(meta); - return item; - } - - public static ItemStack islandlock() { - ItemStack item = new ItemStack(Material.WATCH); - ItemMeta meta = item.getItemMeta(); - meta.setDisplayName("§c§l锁定岛屿"); - List lore = new ArrayList<>(); - lore.add("§r"); - lore.add("§6▸ §c点击锁定"); - meta.setLore(lore); - item.setItemMeta(meta); - return item; - } - - public static ItemStack resetLand() { - ItemStack item = new ItemStack(Material.LAVA_BUCKET); - ItemMeta meta = item.getItemMeta(); - meta.setDisplayName("§6§l重置空岛"); - List lore = new ArrayList<>(); - lore.add("§r"); - lore.add("§6▸ §c点击重置"); - meta.setLore(lore); - item.setItemMeta(meta); - return item; - } - - public static ItemStack setWarp() { - ItemStack item = new ItemStack(Material.ANVIL); - ItemMeta meta = item.getItemMeta(); - meta.setDisplayName("§6§l设置空岛地标"); - List lore = new ArrayList<>(); - lore.add("§r"); - lore.add("§6▸ §e点击设置"); - meta.setLore(lore); - item.setItemMeta(meta); - return item; - } - - public static ItemStack warpList() { - ItemStack item = new ItemStack(Material.SIGN); - ItemMeta meta = item.getItemMeta(); - meta.setDisplayName("§6§l空岛地标列表"); - List lore = new ArrayList<>(); - lore.add("§r"); - lore.add("§6▸ §e点击查看"); - meta.setLore(lore); - item.setItemMeta(meta); - return item; - } - - public static ItemStack islandQuest() { - ItemStack item = new ItemStack(Material.BOOK); - ItemMeta meta = item.getItemMeta(); - meta.setDisplayName("§6§l挑战任务"); - List lore = new ArrayList<>(); - lore.add("§r"); - lore.add("§6▸ §e点击查看"); - meta.setLore(lore); - item.setItemMeta(meta); - return item; - } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 3949240..4c3993e 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: AskyBlockWarps main: me.Demon.AskyBlockWarps.Main -version: 1.0 +version: 1.1.0 commands: iswarps: \ No newline at end of file