test
This commit is contained in:
parent
f5ce425677
commit
0d0a662ef8
|
@ -3,11 +3,13 @@ package me.Demon.AskyBlockWarps.Listener;
|
|||
import cn.hamster3.cdapi.CDTimeAPI;
|
||||
import com.wasteofplastic.askyblock.ASkyBlockAPI;
|
||||
import com.wasteofplastic.askyblock.Island;
|
||||
import de.tr7zw.itemnbtapi.NBTItem;
|
||||
import me.Demon.AskyBlockWarps.Data.WarpData;
|
||||
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.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -28,22 +30,24 @@ public class WarpGui implements Listener {
|
|||
|
||||
@EventHandler
|
||||
public void onclick(InventoryClickEvent e) {
|
||||
int rawSlot = e.getRawSlot();
|
||||
Inventory inv = e.getInventory();
|
||||
Player p = (Player) e.getWhoClicked();
|
||||
String name = p.getName();
|
||||
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 (CDTimeAPI.getCD(p.getUniqueId(), "islandwarptp") < 0) {
|
||||
String playName = item.getItemMeta().getDisplayName().replace("§6§l传送到 §e", "").replace(" §6§l的空岛","");
|
||||
UUID islandOwner = ASkyBlockAPI.getInstance().getOwner(p.getLocation());
|
||||
p.teleport(Main.LandWarpLoc(playName));
|
||||
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 + "空岛地标传送冷却中...");
|
||||
if (rawSlot >= 0 && rawSlot < inv.getSize()) {
|
||||
if(DemonAPI.itemIsNull(item)){return;}
|
||||
p.closeInventory();
|
||||
p.playSound(p.getLocation(),Sound.BLOCK_COMPARATOR_CLICK,1,1);
|
||||
NBTItem nbtItem = new NBTItem(item);
|
||||
if(nbtItem.hasKey("warpKey")){
|
||||
String warpKey = nbtItem.getString("warpKey");
|
||||
WarpData warpData = Main.gameManage.getWarpData(warpKey);
|
||||
Location location = warpData.getLocation().add(0,0.5,0);
|
||||
p.teleport(location);
|
||||
p.sendMessage(Main.prefix + "您已传送至 §e" + warpKey + "§f 的空岛地标旁.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +74,8 @@ public class WarpGui implements Listener {
|
|||
lore.add("§6▸ §e点击传送");
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
NBTItem nbtItem = new NBTItem(item);
|
||||
nbtItem.setString("warpKey",wData.getKey());
|
||||
return nbtItem.getItem();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user