测试版
This commit is contained in:
commit
ae15cae873
40
.gitignore
vendored
Normal file
40
.gitignore
vendored
Normal file
|
@ -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/
|
37
pom.xml
Normal file
37
pom.xml
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>AskyBlockWarps</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>public-rpg</id>
|
||||
<url>https://repo.aurora-pixels.com/repository/public-rpg/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.Demon.DemonPlugin</groupId>
|
||||
<artifactId>DemonAPI</artifactId>
|
||||
<version>1.2.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -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<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||
List<String> list = new ArrayList<>();
|
||||
if (args.length == 1) {
|
||||
if (sender.isOp()) {
|
||||
list.add("open");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
70
src/main/java/me/Demon/AskyBlockWarps/Listener/MainGui.java
Normal file
70
src/main/java/me/Demon/AskyBlockWarps/Listener/MainGui.java
Normal file
|
@ -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();
|
||||
}
|
||||
}
|
43
src/main/java/me/Demon/AskyBlockWarps/Listener/WarpGui.java
Normal file
43
src/main/java/me/Demon/AskyBlockWarps/Listener/WarpGui.java
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
49
src/main/java/me/Demon/AskyBlockWarps/Main.java
Normal file
49
src/main/java/me/Demon/AskyBlockWarps/Main.java
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
58
src/main/java/me/Demon/AskyBlockWarps/Util/itemUtil.java
Normal file
58
src/main/java/me/Demon/AskyBlockWarps/Util/itemUtil.java
Normal file
|
@ -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<String> 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<String> 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<String> 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<String> lore = new ArrayList<>();
|
||||
lore.add("§r");
|
||||
lore.add("§6▸ §e点击查看");
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
}
|
8
src/main/resources/config.yml
Normal file
8
src/main/resources/config.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
Stats:
|
||||
Mc_Tianyu:
|
||||
world: ASkyBlock
|
||||
x: -4001.171424947261
|
||||
y: 92.0
|
||||
z: -4791.300628270689
|
||||
yaw: -166.64987
|
||||
pitch: 10.050012
|
5
src/main/resources/plugin.yml
Normal file
5
src/main/resources/plugin.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
name: AskyBlockWarps
|
||||
main: me.Demon.AskyBlockWarps.Main
|
||||
version: 1.0
|
||||
commands:
|
||||
iswarps:
|
Loading…
Reference in New Issue
Block a user