From db103b9e353a82294ecafdbe8ae218b9969d93a5 Mon Sep 17 00:00:00 2001
From: tianyu <32282861@qq.com>
Date: Wed, 7 Aug 2024 11:29:53 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 5 +
.../Listener/LandInviteGui.java | 59 +++++++++
.../AskyBlockWarps/Listener/LandTeamGui.java | 45 +++++++
.../AskyBlockWarps/Listener/MainGui.java | 80 ++++++++++--
.../AskyBlockWarps/Listener/WarpGui.java | 17 ++-
.../java/me/Demon/AskyBlockWarps/Main.java | 5 +-
.../Demon/AskyBlockWarps/Util/itemUtil.java | 123 +++++++++++++++++-
7 files changed, 316 insertions(+), 18 deletions(-)
create mode 100644 src/main/java/me/Demon/AskyBlockWarps/Listener/LandInviteGui.java
create mode 100644 src/main/java/me/Demon/AskyBlockWarps/Listener/LandTeamGui.java
diff --git a/pom.xml b/pom.xml
index a473000..1f56ed3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,6 +32,11 @@
DemonAPI
1.2.0
+
+ cn.hamster3.cdapi
+ CDTimeAPI
+ 1.0
+
\ No newline at end of file
diff --git a/src/main/java/me/Demon/AskyBlockWarps/Listener/LandInviteGui.java b/src/main/java/me/Demon/AskyBlockWarps/Listener/LandInviteGui.java
new file mode 100644
index 0000000..9489f8c
--- /dev/null
+++ b/src/main/java/me/Demon/AskyBlockWarps/Listener/LandInviteGui.java
@@ -0,0 +1,59 @@
+package me.Demon.AskyBlockWarps.Listener;
+
+import com.wasteofplastic.askyblock.ASkyBlockAPI;
+import me.Demon.AskyBlockWarps.Main;
+import me.Demon.AskyBlockWarps.Util.itemUtil;
+import me.Demon.DemonPlugin.DemonAPI;
+import org.bukkit.Bukkit;
+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 java.util.ArrayList;
+import java.util.List;
+
+public class LandInviteGui implements Listener {
+ public static String invtitle = "帝国战争 - 成员邀请";
+
+ @EventHandler
+ public void onclick(InventoryClickEvent e) {
+ 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();
+ }
+ }
+ }
+ }
+
+ public static void Opengui(Player p) {
+ 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) {
+ nearbyPlayers.add(nearbyPlayer);
+ }
+ }
+ }
+
+ for (Player nearbyPlayer : nearbyPlayers) {
+ if (!p.equals(nearbyPlayer)) { // 避免将玩家自己添加到GUI中
+ inv.addItem(itemUtil.addTeam(nearbyPlayer.getName()));
+ }
+ }
+
+ p.openInventory(inv);
+ }
+}
diff --git a/src/main/java/me/Demon/AskyBlockWarps/Listener/LandTeamGui.java b/src/main/java/me/Demon/AskyBlockWarps/Listener/LandTeamGui.java
new file mode 100644
index 0000000..1454cae
--- /dev/null
+++ b/src/main/java/me/Demon/AskyBlockWarps/Listener/LandTeamGui.java
@@ -0,0 +1,45 @@
+package me.Demon.AskyBlockWarps.Listener;
+
+import com.wasteofplastic.askyblock.ASkyBlockAPI;
+import me.Demon.AskyBlockWarps.Main;
+import me.Demon.AskyBlockWarps.Util.itemUtil;
+import me.Demon.DemonPlugin.DemonAPI;
+import org.bukkit.Bukkit;
+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 java.util.UUID;
+
+public class LandTeamGui implements Listener {
+ public static String invtitle = "帝国战争 - 空岛成员";
+
+ @EventHandler
+ public void onclick(InventoryClickEvent e) {
+ 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 expel " + playName);
+ }
+ } 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)));
+ }
+ p.openInventory(inv);
+ }
+}
diff --git a/src/main/java/me/Demon/AskyBlockWarps/Listener/MainGui.java b/src/main/java/me/Demon/AskyBlockWarps/Listener/MainGui.java
index 693e435..fc1c93a 100644
--- a/src/main/java/me/Demon/AskyBlockWarps/Listener/MainGui.java
+++ b/src/main/java/me/Demon/AskyBlockWarps/Listener/MainGui.java
@@ -1,11 +1,13 @@
package me.Demon.AskyBlockWarps.Listener;
+import cn.hamster3.cdapi.CDTimeAPI;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
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.Sound;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -26,20 +28,69 @@ public class MainGui implements Listener {
e.setCancelled(true);
ItemStack item = e.getCurrentItem();
if (e.getRawSlot() >= 0 && e.getRawSlot() < e.getInventory().getSize() && !DemonAPI.itemIsNull(item) && !DemonAPI.itemIsLore(item)) {
- if (e.getRawSlot() == 13) {
- UUID islandOwner = ASkyBlockAPI.getInstance().getOwner(p.getLocation());
- System.out.println("LandOwner: " + Main.convertUUIDToName(islandOwner));
+ UUID islandOwner = ASkyBlockAPI.getInstance().getOwner(p.getLocation());
+ if (e.getRawSlot() == 1) {
+ p.performCommand("is");
+ p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 2.0F);
+ p.closeInventory();
+ }
+
+ if (e.getRawSlot() == 3) {
if (islandOwner != null && islandOwner.equals(p.getUniqueId())) {
- SetLocation("Stats." + p.getName(), p.getLocation());
- p.sendMessage(Main.prefix + "设置空岛地标点成功.");
- p.closeInventory();
+ if (CDTimeAPI.getCD(p.getUniqueId(), "islandsetwarp") < 0) {
+ SetLocation("Stats." + p.getName(), 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() == 15) {
+
+ if (e.getRawSlot() == 5) {
WarpGui.Opengui(p);
+ p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 2.0F);
+ }
+
+ if (e.getRawSlot() == 7) {
+ 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();
+ }
+
+ if (e.getRawSlot() == 11) {
+ p.performCommand("is top");
+ p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 2.0F);
+ p.closeInventory();
+ }
+
+ if (e.getRawSlot() == 13) {
+ Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "asadmin lock " + p.getName());
+ p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 2.0F);
+ p.closeInventory();
+ }
+
+ if (e.getRawSlot() == 15) {
+ LandTeamGui.Opengui(p);
+ p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 2.0F);
+ }
+ if (e.getRawSlot() == 19) {
+ LandInviteGui.Opengui(p);
+ p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 2.0F);
+ }
+ if (e.getRawSlot() == 25) {
+ p.performCommand("challenge");
+ p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 2.0F);
}
}
}
@@ -47,12 +98,17 @@ public class MainGui implements Listener {
public static void Opengui(Player p) {
Inventory inv = Bukkit.createInventory(null, 27, invtitle);
+ boolean butt = ASkyBlockAPI.getInstance().hasIsland(p.getUniqueId());
- inv.setItem(11, itemUtil.resetLand());
-
- inv.setItem(13, itemUtil.setWarp());
-
- inv.setItem(15, itemUtil.warpList());
+ 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());
p.openInventory(inv);
}
diff --git a/src/main/java/me/Demon/AskyBlockWarps/Listener/WarpGui.java b/src/main/java/me/Demon/AskyBlockWarps/Listener/WarpGui.java
index 5c751a8..815abfb 100644
--- a/src/main/java/me/Demon/AskyBlockWarps/Listener/WarpGui.java
+++ b/src/main/java/me/Demon/AskyBlockWarps/Listener/WarpGui.java
@@ -1,10 +1,12 @@
package me.Demon.AskyBlockWarps.Listener;
+import cn.hamster3.cdapi.CDTimeAPI;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
import me.Demon.AskyBlockWarps.Main;
import me.Demon.AskyBlockWarps.Util.itemUtil;
import me.Demon.DemonPlugin.DemonAPI;
import org.bukkit.Bukkit;
+import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@@ -24,10 +26,17 @@ public class WarpGui implements Listener {
e.setCancelled(true);
ItemStack item = e.getCurrentItem();
if (e.getRawSlot() >= 0 && e.getRawSlot() < e.getInventory().getSize() && !DemonAPI.itemIsNull(item) && !DemonAPI.itemIsLore(item)) {
- UUID islandOwner = ASkyBlockAPI.getInstance().getOwner(p.getLocation());
- p.teleport(Main.LandWarpLoc(p.getName()));
- p.sendMessage(Main.prefix + "您已传送至 §e" + Main.convertUUIDToName(islandOwner) + "§f 的空岛地标旁.");
- p.closeInventory();
+ if (CDTimeAPI.getCD(p.getUniqueId(), "islandwarptp") < 0) {
+ UUID islandOwner = ASkyBlockAPI.getInstance().getOwner(p.getLocation());
+ p.teleport(Main.LandWarpLoc(p.getName()));
+ p.sendMessage(Main.prefix + "您已传送至 §e" + Main.convertUUIDToName(islandOwner) + "§f 的空岛地标旁.");
+ CDTimeAPI.setPlayerCD(p.getUniqueId(), "islandwarptp", 1000 * 3);
+ p.playSound(p.getLocation(), Sound.ENTITY_ENDEREYE_DEATH, 1.0F, 2.0F);
+ p.closeInventory();
+ } else {
+ p.sendMessage(Main.prefix + "空岛地标传送冷却中...");
+ p.closeInventory();
+ }
}
}
}
diff --git a/src/main/java/me/Demon/AskyBlockWarps/Main.java b/src/main/java/me/Demon/AskyBlockWarps/Main.java
index 6c7f94e..027dd68 100644
--- a/src/main/java/me/Demon/AskyBlockWarps/Main.java
+++ b/src/main/java/me/Demon/AskyBlockWarps/Main.java
@@ -1,13 +1,14 @@
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 org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.FileConfiguration;
-import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.UUID;
@@ -22,6 +23,8 @@ public class Main extends JavaPlugin {
saveDefaultConfig();
Bukkit.getServer().getPluginManager().registerEvents(new MainGui(), plugin);
Bukkit.getServer().getPluginManager().registerEvents(new WarpGui(), plugin);
+ Bukkit.getServer().getPluginManager().registerEvents(new LandTeamGui(), plugin);
+ Bukkit.getServer().getPluginManager().registerEvents(new LandInviteGui(), plugin);
getCommand("iswarps").setExecutor(new iswarpCommand());
getCommand("iswarps").setTabCompleter(new iswarpCommand());
}
diff --git a/src/main/java/me/Demon/AskyBlockWarps/Util/itemUtil.java b/src/main/java/me/Demon/AskyBlockWarps/Util/itemUtil.java
index 2943da2..bf70da3 100644
--- a/src/main/java/me/Demon/AskyBlockWarps/Util/itemUtil.java
+++ b/src/main/java/me/Demon/AskyBlockWarps/Util/itemUtil.java
@@ -1,6 +1,8 @@
package me.Demon.AskyBlockWarps.Util;
+import com.wasteofplastic.askyblock.ASkyBlockAPI;
import org.bukkit.Material;
+import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@@ -9,6 +11,38 @@ import java.util.List;
public class itemUtil {
+ public static ItemStack teamList(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▸ §c点击移除岛屿");
+ meta.setLore(lore);
+ 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();
@@ -21,8 +55,82 @@ public class itemUtil {
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.BOOK);
+ ItemStack item = new ItemStack(Material.LAVA_BUCKET);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§6§l重置空岛");
List lore = new ArrayList<>();
@@ -44,6 +152,7 @@ public class itemUtil {
item.setItemMeta(meta);
return item;
}
+
public static ItemStack warpList() {
ItemStack item = new ItemStack(Material.SIGN);
ItemMeta meta = item.getItemMeta();
@@ -55,4 +164,16 @@ public class itemUtil {
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;
+ }
}