commit ae15cae8734f0506dbb7fd3c7f73a5c6260e8356
Author: tianyu <32282861@qq.com>
Date: Tue Aug 6 15:53:05 2024 +0800
测试版
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c037f46
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,40 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
+/.idea/
+/out/
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..a473000
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,37 @@
+
+
+ 4.0.0
+
+ org.example
+ AskyBlockWarps
+ 1.0-SNAPSHOT
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+ public-rpg
+ https://repo.aurora-pixels.com/repository/public-rpg/
+
+
+
+
+
+ org.spigotmc
+ spigot-api
+ 1.12.2
+
+
+ me.Demon.DemonPlugin
+ DemonAPI
+ 1.2.0
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/me/Demon/AskyBlockWarps/Command/iswarpCommand.java b/src/main/java/me/Demon/AskyBlockWarps/Command/iswarpCommand.java
new file mode 100644
index 0000000..69af808
--- /dev/null
+++ b/src/main/java/me/Demon/AskyBlockWarps/Command/iswarpCommand.java
@@ -0,0 +1,34 @@
+package me.Demon.AskyBlockWarps.Command;
+
+import me.Demon.AskyBlockWarps.Listener.MainGui;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.command.TabExecutor;
+import org.bukkit.entity.Player;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class iswarpCommand implements CommandExecutor, TabExecutor {
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ if (args.length == 1 && args[0].equalsIgnoreCase("open")) {
+ Player p = (Player) sender;
+ MainGui.Opengui(p);
+ }
+ return false;
+ }
+
+ public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
+ List list = new ArrayList<>();
+ if (args.length == 1) {
+ if (sender.isOp()) {
+ list.add("open");
+ }
+ return list;
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/me/Demon/AskyBlockWarps/Listener/MainGui.java b/src/main/java/me/Demon/AskyBlockWarps/Listener/MainGui.java
new file mode 100644
index 0000000..693e435
--- /dev/null
+++ b/src/main/java/me/Demon/AskyBlockWarps/Listener/MainGui.java
@@ -0,0 +1,70 @@
+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.Location;
+import org.bukkit.configuration.file.FileConfiguration;
+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 MainGui 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 (e.getRawSlot() == 13) {
+ UUID islandOwner = ASkyBlockAPI.getInstance().getOwner(p.getLocation());
+ System.out.println("LandOwner: " + Main.convertUUIDToName(islandOwner));
+ if (islandOwner != null && islandOwner.equals(p.getUniqueId())) {
+ SetLocation("Stats." + p.getName(), p.getLocation());
+ p.sendMessage(Main.prefix + "设置空岛地标点成功.");
+ p.closeInventory();
+ } else {
+ p.sendMessage(Main.prefix + "您只能在您的岛屿设置传送点地标.");
+ p.closeInventory();
+ }
+ }
+ if (e.getRawSlot() == 15) {
+ WarpGui.Opengui(p);
+ }
+ }
+ }
+ }
+
+ public static void Opengui(Player p) {
+ Inventory inv = Bukkit.createInventory(null, 27, invtitle);
+
+ inv.setItem(11, itemUtil.resetLand());
+
+ inv.setItem(13, itemUtil.setWarp());
+
+ inv.setItem(15, itemUtil.warpList());
+
+ 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();
+ }
+}
diff --git a/src/main/java/me/Demon/AskyBlockWarps/Listener/WarpGui.java b/src/main/java/me/Demon/AskyBlockWarps/Listener/WarpGui.java
new file mode 100644
index 0000000..5c751a8
--- /dev/null
+++ b/src/main/java/me/Demon/AskyBlockWarps/Listener/WarpGui.java
@@ -0,0 +1,43 @@
+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 WarpGui 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)) {
+ UUID islandOwner = ASkyBlockAPI.getInstance().getOwner(p.getLocation());
+ p.teleport(Main.LandWarpLoc(p.getName()));
+ p.sendMessage(Main.prefix + "您已传送至 §e" + Main.convertUUIDToName(islandOwner) + "§f 的空岛地标旁.");
+ p.closeInventory();
+ }
+ }
+ }
+
+ public static void Opengui(Player p) {
+ Inventory inv = Bukkit.createInventory(null, 54, invtitle);
+ for (String warpName : Main.plugin.getConfig().getConfigurationSection("Stats").getKeys(false)) {
+ inv.addItem(itemUtil.warpShow(warpName));
+ }
+
+ p.openInventory(inv);
+ }
+}
diff --git a/src/main/java/me/Demon/AskyBlockWarps/Main.java b/src/main/java/me/Demon/AskyBlockWarps/Main.java
new file mode 100644
index 0000000..6c7f94e
--- /dev/null
+++ b/src/main/java/me/Demon/AskyBlockWarps/Main.java
@@ -0,0 +1,49 @@
+package me.Demon.AskyBlockWarps;
+
+import me.Demon.AskyBlockWarps.Command.iswarpCommand;
+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;
+
+public class Main extends JavaPlugin {
+ public static Main plugin;
+ public static String prefix = "§7[§6帝国战争§7] §f";
+
+ @Override
+ public void onEnable() {
+ plugin = this;
+ saveDefaultConfig();
+ Bukkit.getServer().getPluginManager().registerEvents(new MainGui(), plugin);
+ Bukkit.getServer().getPluginManager().registerEvents(new WarpGui(), 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/Util/itemUtil.java b/src/main/java/me/Demon/AskyBlockWarps/Util/itemUtil.java
new file mode 100644
index 0000000..2943da2
--- /dev/null
+++ b/src/main/java/me/Demon/AskyBlockWarps/Util/itemUtil.java
@@ -0,0 +1,58 @@
+package me.Demon.AskyBlockWarps.Util;
+
+import org.bukkit.Material;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class itemUtil {
+
+ 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 resetLand() {
+ ItemStack item = new ItemStack(Material.BOOK);
+ 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;
+ }
+}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
new file mode 100644
index 0000000..47e6f1d
--- /dev/null
+++ b/src/main/resources/config.yml
@@ -0,0 +1,8 @@
+Stats:
+ Mc_Tianyu:
+ world: ASkyBlock
+ x: -4001.171424947261
+ y: 92.0
+ z: -4791.300628270689
+ yaw: -166.64987
+ pitch: 10.050012
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
new file mode 100644
index 0000000..3949240
--- /dev/null
+++ b/src/main/resources/plugin.yml
@@ -0,0 +1,5 @@
+name: AskyBlockWarps
+main: me.Demon.AskyBlockWarps.Main
+version: 1.0
+commands:
+ iswarps:
\ No newline at end of file