测试版

This commit is contained in:
tianyu 2024-08-07 11:29:53 +08:00
parent ae15cae873
commit db103b9e35
7 changed files with 316 additions and 18 deletions

View File

@ -32,6 +32,11 @@
<artifactId>DemonAPI</artifactId> <artifactId>DemonAPI</artifactId>
<version>1.2.0</version> <version>1.2.0</version>
</dependency> </dependency>
<dependency>
<groupId>cn.hamster3.cdapi</groupId>
<artifactId>CDTimeAPI</artifactId>
<version>1.0</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -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<Player> 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);
}
}

View File

@ -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);
}
}

View File

@ -1,11 +1,13 @@
package me.Demon.AskyBlockWarps.Listener; package me.Demon.AskyBlockWarps.Listener;
import cn.hamster3.cdapi.CDTimeAPI;
import com.wasteofplastic.askyblock.ASkyBlockAPI; import com.wasteofplastic.askyblock.ASkyBlockAPI;
import me.Demon.AskyBlockWarps.Main; import me.Demon.AskyBlockWarps.Main;
import me.Demon.AskyBlockWarps.Util.itemUtil; import me.Demon.AskyBlockWarps.Util.itemUtil;
import me.Demon.DemonPlugin.DemonAPI; import me.Demon.DemonPlugin.DemonAPI;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -26,20 +28,69 @@ public class MainGui implements Listener {
e.setCancelled(true); e.setCancelled(true);
ItemStack item = e.getCurrentItem(); ItemStack item = e.getCurrentItem();
if (e.getRawSlot() >= 0 && e.getRawSlot() < e.getInventory().getSize() && !DemonAPI.itemIsNull(item) && !DemonAPI.itemIsLore(item)) { 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());
UUID islandOwner = ASkyBlockAPI.getInstance().getOwner(p.getLocation()); if (e.getRawSlot() == 1) {
System.out.println("LandOwner: " + Main.convertUUIDToName(islandOwner)); 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())) { if (islandOwner != null && islandOwner.equals(p.getUniqueId())) {
SetLocation("Stats." + p.getName(), p.getLocation()); if (CDTimeAPI.getCD(p.getUniqueId(), "islandsetwarp") < 0) {
p.sendMessage(Main.prefix + "设置空岛地标点成功."); SetLocation("Stats." + p.getName(), p.getLocation());
p.closeInventory(); 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 { } else {
p.sendMessage(Main.prefix + "您只能在您的岛屿设置传送点地标."); p.sendMessage(Main.prefix + "您只能在您的岛屿设置传送点地标.");
p.playSound(p.getLocation(), Sound.ENTITY_BLAZE_DEATH, 1.0F, 2.0F);
p.closeInventory(); p.closeInventory();
} }
} }
if (e.getRawSlot() == 15) {
if (e.getRawSlot() == 5) {
WarpGui.Opengui(p); 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) { public static void Opengui(Player p) {
Inventory inv = Bukkit.createInventory(null, 27, invtitle); Inventory inv = Bukkit.createInventory(null, 27, invtitle);
boolean butt = ASkyBlockAPI.getInstance().hasIsland(p.getUniqueId());
inv.setItem(11, itemUtil.resetLand()); inv.setItem(1, itemUtil.backisland(butt));
inv.setItem(3, itemUtil.setWarp());
inv.setItem(13, itemUtil.setWarp()); inv.setItem(5, itemUtil.warpList());
inv.setItem(7, itemUtil.resetLand());
inv.setItem(15, itemUtil.warpList()); 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); p.openInventory(inv);
} }

View File

@ -1,10 +1,12 @@
package me.Demon.AskyBlockWarps.Listener; package me.Demon.AskyBlockWarps.Listener;
import cn.hamster3.cdapi.CDTimeAPI;
import com.wasteofplastic.askyblock.ASkyBlockAPI; import com.wasteofplastic.askyblock.ASkyBlockAPI;
import me.Demon.AskyBlockWarps.Main; import me.Demon.AskyBlockWarps.Main;
import me.Demon.AskyBlockWarps.Util.itemUtil; import me.Demon.AskyBlockWarps.Util.itemUtil;
import me.Demon.DemonPlugin.DemonAPI; import me.Demon.DemonPlugin.DemonAPI;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -24,10 +26,17 @@ public class WarpGui implements Listener {
e.setCancelled(true); e.setCancelled(true);
ItemStack item = e.getCurrentItem(); ItemStack item = e.getCurrentItem();
if (e.getRawSlot() >= 0 && e.getRawSlot() < e.getInventory().getSize() && !DemonAPI.itemIsNull(item) && !DemonAPI.itemIsLore(item)) { if (e.getRawSlot() >= 0 && e.getRawSlot() < e.getInventory().getSize() && !DemonAPI.itemIsNull(item) && !DemonAPI.itemIsLore(item)) {
UUID islandOwner = ASkyBlockAPI.getInstance().getOwner(p.getLocation()); if (CDTimeAPI.getCD(p.getUniqueId(), "islandwarptp") < 0) {
p.teleport(Main.LandWarpLoc(p.getName())); UUID islandOwner = ASkyBlockAPI.getInstance().getOwner(p.getLocation());
p.sendMessage(Main.prefix + "您已传送至 §e" + Main.convertUUIDToName(islandOwner) + "§f 的空岛地标旁."); p.teleport(Main.LandWarpLoc(p.getName()));
p.closeInventory(); 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();
}
} }
} }
} }

View File

@ -1,13 +1,14 @@
package me.Demon.AskyBlockWarps; package me.Demon.AskyBlockWarps;
import me.Demon.AskyBlockWarps.Command.iswarpCommand; 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.MainGui;
import me.Demon.AskyBlockWarps.Listener.WarpGui; import me.Demon.AskyBlockWarps.Listener.WarpGui;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import java.util.UUID; import java.util.UUID;
@ -22,6 +23,8 @@ public class Main extends JavaPlugin {
saveDefaultConfig(); saveDefaultConfig();
Bukkit.getServer().getPluginManager().registerEvents(new MainGui(), plugin); Bukkit.getServer().getPluginManager().registerEvents(new MainGui(), plugin);
Bukkit.getServer().getPluginManager().registerEvents(new WarpGui(), 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").setExecutor(new iswarpCommand());
getCommand("iswarps").setTabCompleter(new iswarpCommand()); getCommand("iswarps").setTabCompleter(new iswarpCommand());
} }

View File

@ -1,6 +1,8 @@
package me.Demon.AskyBlockWarps.Util; package me.Demon.AskyBlockWarps.Util;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
@ -9,6 +11,38 @@ import java.util.List;
public class itemUtil { 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<String> 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<String> 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) { public static ItemStack warpShow(String name) {
ItemStack item = new ItemStack(Material.SIGN); ItemStack item = new ItemStack(Material.SIGN);
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
@ -21,8 +55,82 @@ public class itemUtil {
return item; 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<String> 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<String> 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<String> 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<String> 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<String> lore = new ArrayList<>();
lore.add("§r");
lore.add("§6▸ §c点击锁定");
meta.setLore(lore);
item.setItemMeta(meta);
return item;
}
public static ItemStack resetLand() { public static ItemStack resetLand() {
ItemStack item = new ItemStack(Material.BOOK); ItemStack item = new ItemStack(Material.LAVA_BUCKET);
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§6§l重置空岛"); meta.setDisplayName("§6§l重置空岛");
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
@ -44,6 +152,7 @@ public class itemUtil {
item.setItemMeta(meta); item.setItemMeta(meta);
return item; return item;
} }
public static ItemStack warpList() { public static ItemStack warpList() {
ItemStack item = new ItemStack(Material.SIGN); ItemStack item = new ItemStack(Material.SIGN);
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
@ -55,4 +164,16 @@ public class itemUtil {
item.setItemMeta(meta); item.setItemMeta(meta);
return item; return item;
} }
public static ItemStack islandQuest() {
ItemStack item = new ItemStack(Material.BOOK);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§6§l挑战任务");
List<String> lore = new ArrayList<>();
lore.add("§r");
lore.add("§6▸ §e点击查看");
meta.setLore(lore);
item.setItemMeta(meta);
return item;
}
} }