test
This commit is contained in:
parent
db103b9e35
commit
4e303031f8
10
pom.xml
10
pom.xml
|
@ -37,6 +37,16 @@
|
||||||
<artifactId>CDTimeAPI</artifactId>
|
<artifactId>CDTimeAPI</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.wasteofplastic.askyblock</groupId>
|
||||||
|
<artifactId>AskyBlockAPI</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.yaohun.nbtapi</groupId>
|
||||||
|
<artifactId>NBT-API</artifactId>
|
||||||
|
<version>1.12.2</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
77
src/main/java/me/Demon/AskyBlockWarps/Data/WarpData.java
Normal file
77
src/main/java/me/Demon/AskyBlockWarps/Data/WarpData.java
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
package me.Demon.AskyBlockWarps.Data;
|
||||||
|
|
||||||
|
import com.wasteofplastic.askyblock.ASkyBlockAPI;
|
||||||
|
import com.wasteofplastic.askyblock.Island;
|
||||||
|
import me.Demon.AskyBlockWarps.Main;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class WarpData {
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
private Location location;
|
||||||
|
private boolean locSwitch;
|
||||||
|
private Island island;
|
||||||
|
|
||||||
|
public WarpData(String key){
|
||||||
|
FileConfiguration yml = Main.plugin.getConfig();
|
||||||
|
this.key = key;
|
||||||
|
String string = "Stats."+key+".";
|
||||||
|
String worldName = yml.getString(string+"world");
|
||||||
|
World world = Bukkit.getWorld(worldName);
|
||||||
|
if(world==null){
|
||||||
|
System.out.println("[错误 - Sky坐标] "+key+"无法检测该世界.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
double x = yml.getDouble(string+"x");
|
||||||
|
double y = yml.getDouble(string+"y");
|
||||||
|
double z = yml.getDouble(string+"z");
|
||||||
|
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());
|
||||||
|
yml.set(string+"z",location.getZ());
|
||||||
|
yml.set(string+"yaw",location.getYaw());
|
||||||
|
yml.set(string+"pitch",location.getPitch());
|
||||||
|
Main.plugin.saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocation(Location location) {
|
||||||
|
this.location = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLocSwitch() {
|
||||||
|
return locSwitch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Island getIsland() {
|
||||||
|
return island;
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,7 +24,7 @@ public class LandTeamGui 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 (ASkyBlockAPI.getInstance().getOwner(p.getLocation()).equals(p.getUniqueId())) {
|
if (ASkyBlockAPI.getInstance().getIslandAt(p.getLocation()).equals(p.getUniqueId())) {
|
||||||
String playName = item.getItemMeta().getDisplayName().replace("§6§l成员 §e", "");
|
String playName = item.getItemMeta().getDisplayName().replace("§6§l成员 §e", "");
|
||||||
p.performCommand("is expel " + playName);
|
p.performCommand("is expel " + playName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package me.Demon.AskyBlockWarps.Listener;
|
||||||
import cn.hamster3.cdapi.CDTimeAPI;
|
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.Manage.GameManage;
|
||||||
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;
|
||||||
|
@ -23,11 +24,13 @@ public class MainGui implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onclick(InventoryClickEvent e) {
|
public void onclick(InventoryClickEvent e) {
|
||||||
|
int rawSlot = e.getRawSlot();
|
||||||
|
Inventory inv = e.getInventory();
|
||||||
Player p = (Player) e.getWhoClicked();
|
Player p = (Player) e.getWhoClicked();
|
||||||
if (e.getInventory() != null && e.getInventory().getTitle().contains(invtitle)) {
|
String name = p.getName();
|
||||||
|
if (inv != null && inv.getTitle().contains(invtitle)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
ItemStack item = e.getCurrentItem();
|
if (rawSlot >= 0 && rawSlot < inv.getSize()) {
|
||||||
if (e.getRawSlot() >= 0 && e.getRawSlot() < e.getInventory().getSize() && !DemonAPI.itemIsNull(item) && !DemonAPI.itemIsLore(item)) {
|
|
||||||
UUID islandOwner = ASkyBlockAPI.getInstance().getOwner(p.getLocation());
|
UUID islandOwner = ASkyBlockAPI.getInstance().getOwner(p.getLocation());
|
||||||
if (e.getRawSlot() == 1) {
|
if (e.getRawSlot() == 1) {
|
||||||
p.performCommand("is");
|
p.performCommand("is");
|
||||||
|
@ -38,7 +41,7 @@ public class MainGui implements Listener {
|
||||||
if (e.getRawSlot() == 3) {
|
if (e.getRawSlot() == 3) {
|
||||||
if (islandOwner != null && islandOwner.equals(p.getUniqueId())) {
|
if (islandOwner != null && islandOwner.equals(p.getUniqueId())) {
|
||||||
if (CDTimeAPI.getCD(p.getUniqueId(), "islandsetwarp") < 0) {
|
if (CDTimeAPI.getCD(p.getUniqueId(), "islandsetwarp") < 0) {
|
||||||
SetLocation("Stats." + p.getName(), p.getLocation());
|
Main.gameManage.setWarpLoc(name,p.getLocation());
|
||||||
p.sendMessage(Main.prefix + "设置空岛地标点成功.");
|
p.sendMessage(Main.prefix + "设置空岛地标点成功.");
|
||||||
CDTimeAPI.setPlayerCD(p.getUniqueId(), "islandsetwarp", 1000 * 3);
|
CDTimeAPI.setPlayerCD(p.getUniqueId(), "islandsetwarp", 1000 * 3);
|
||||||
p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 2.0F);
|
p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 2.0F);
|
||||||
|
|
|
@ -2,10 +2,13 @@ package me.Demon.AskyBlockWarps.Listener;
|
||||||
|
|
||||||
import cn.hamster3.cdapi.CDTimeAPI;
|
import cn.hamster3.cdapi.CDTimeAPI;
|
||||||
import com.wasteofplastic.askyblock.ASkyBlockAPI;
|
import com.wasteofplastic.askyblock.ASkyBlockAPI;
|
||||||
|
import com.wasteofplastic.askyblock.Island;
|
||||||
|
import me.Demon.AskyBlockWarps.Data.WarpData;
|
||||||
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.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
@ -13,7 +16,11 @@ import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class WarpGui implements Listener {
|
public class WarpGui implements Listener {
|
||||||
|
@ -43,10 +50,25 @@ public class WarpGui implements Listener {
|
||||||
|
|
||||||
public static void Opengui(Player p) {
|
public static void Opengui(Player p) {
|
||||||
Inventory inv = Bukkit.createInventory(null, 54, invtitle);
|
Inventory inv = Bukkit.createInventory(null, 54, invtitle);
|
||||||
for (String warpName : Main.plugin.getConfig().getConfigurationSection("Stats").getKeys(false)) {
|
HashMap<String, WarpData> warpDataHashMap = Main.gameManage.getWarpDataMap();
|
||||||
inv.addItem(itemUtil.warpShow(warpName));
|
for (String key : warpDataHashMap.keySet()){
|
||||||
|
WarpData warpData = warpDataHashMap.get(key);
|
||||||
|
inv.addItem(warpShow(warpData));
|
||||||
}
|
}
|
||||||
|
|
||||||
p.openInventory(inv);
|
p.openInventory(inv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ItemStack warpShow(WarpData wData) {
|
||||||
|
ItemStack item = new ItemStack(Material.SIGN);
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
meta.setDisplayName("§6§l传送到 §e" + wData.getKey() + " §6§l的空岛");
|
||||||
|
List<String> 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);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import me.Demon.AskyBlockWarps.Listener.LandInviteGui;
|
||||||
import me.Demon.AskyBlockWarps.Listener.LandTeamGui;
|
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 me.Demon.AskyBlockWarps.Manage.GameManage;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
@ -16,10 +17,12 @@ import java.util.UUID;
|
||||||
public class Main extends JavaPlugin {
|
public class Main extends JavaPlugin {
|
||||||
public static Main plugin;
|
public static Main plugin;
|
||||||
public static String prefix = "§7[§6帝国战争§7] §f";
|
public static String prefix = "§7[§6帝国战争§7] §f";
|
||||||
|
public static GameManage gameManage;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
plugin = this;
|
plugin = this;
|
||||||
|
gameManage = new GameManage(getConfig());
|
||||||
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);
|
||||||
|
|
72
src/main/java/me/Demon/AskyBlockWarps/Manage/GameManage.java
Normal file
72
src/main/java/me/Demon/AskyBlockWarps/Manage/GameManage.java
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
package me.Demon.AskyBlockWarps.Manage;
|
||||||
|
|
||||||
|
import me.Demon.AskyBlockWarps.Data.WarpData;
|
||||||
|
import me.Demon.AskyBlockWarps.Main;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class GameManage {
|
||||||
|
|
||||||
|
private FileConfiguration yml;
|
||||||
|
private HashMap<String, WarpData> warpDataMap = new HashMap<>();
|
||||||
|
|
||||||
|
public GameManage(FileConfiguration yml){
|
||||||
|
this.yml = yml;
|
||||||
|
if(yml.getConfigurationSection("Stats") == null){
|
||||||
|
yml.createSection("Stats");
|
||||||
|
}
|
||||||
|
for (String key : yml.getConfigurationSection("Stats").getKeys(false)){
|
||||||
|
warpDataMap.put(key,new WarpData(key));
|
||||||
|
}
|
||||||
|
Bukkit.getConsoleSender().sendMessage("[载入岛屿地标] "+warpDataMap.size()+"个");
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String, WarpData> getWarpDataMap() {
|
||||||
|
return warpDataMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WarpData getWarpData(String key){
|
||||||
|
if(warpDataMap.get(key) == null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return warpDataMap.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWarpLoc(String key,Location location){
|
||||||
|
if(warpDataMap.get(key) == null){
|
||||||
|
warpDataMap.put(key,new WarpData(key,location));
|
||||||
|
warpDataMap.get(key).SaveData();
|
||||||
|
}else{
|
||||||
|
warpDataMap.get(key).setLocation(location);
|
||||||
|
warpDataMap.get(key).SaveData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeWarpLoc(String key){
|
||||||
|
if(warpDataMap.get(key) == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
warpDataMap.remove(key);
|
||||||
|
yml.set("Stats."+key,null);
|
||||||
|
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){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return warpDataMap.get(key).getLocation();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user