diff --git a/pom.xml b/pom.xml
index f9f303f..47b32a3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,6 +13,13 @@
themepark
1.2.2
+
+
+ placeholderapi
+ http://repo.extendedclip.com/content/repositories/placeholderapi/
+
+
+
org.spigotmc
@@ -20,5 +27,11 @@
1.8.8-R0.1-SNAPSHOT
provided
+
+ me.clip
+ placeholderapi
+ 2.0.6
+ provided
+
\ No newline at end of file
diff --git a/src/main/java/me/paradoxpixel/themepark/ThemeParkPlugin.java b/src/main/java/me/paradoxpixel/themepark/ThemeParkPlugin.java
index 142b5d0..325183d 100644
--- a/src/main/java/me/paradoxpixel/themepark/ThemeParkPlugin.java
+++ b/src/main/java/me/paradoxpixel/themepark/ThemeParkPlugin.java
@@ -12,6 +12,7 @@ import me.paradoxpixel.themepark.listener.ClickListener;
import me.paradoxpixel.themepark.listener.ChangeListener;
import me.paradoxpixel.themepark.listener.PlayerListener;
import me.paradoxpixel.themepark.listener.SignListener;
+import me.paradoxpixel.themepark.placeholder.ThemeParkPlaceholder;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandMap;
import org.bukkit.plugin.PluginManager;
@@ -45,6 +46,9 @@ public class ThemeParkPlugin extends JavaPlugin {
private void loadData() {
StatusManager.load();
AttractionMenu.load();
+ if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
+ new ThemeParkPlaceholder(this).hook();
+ }
}
private void loadDatabase() {
diff --git a/src/main/java/me/paradoxpixel/themepark/api/attraction/Attraction.java b/src/main/java/me/paradoxpixel/themepark/api/attraction/Attraction.java
index 8fe6340..85ef631 100644
--- a/src/main/java/me/paradoxpixel/themepark/api/attraction/Attraction.java
+++ b/src/main/java/me/paradoxpixel/themepark/api/attraction/Attraction.java
@@ -64,10 +64,16 @@ public class Attraction {
if(location == this.location)
return;
- if(LocationUtils.toString(location) != null && LocationUtils.toString(location) != null)
- if(LocationUtils.toString(this.location).equals(LocationUtils.toString(location)))
+ if(location == null)
return;
+ if(LocationUtils.toString(location) == null)
+ return;
+
+ if(LocationUtils.toString(this.location) != null && LocationUtils.toString(location) != null)
+ if(LocationUtils.toString(this.location).equals(LocationUtils.toString(location)))
+ return;
+
ChangeAttractionEvent event = new ChangeAttractionEvent(this, name, name, region_id, region_id, this.location, location, type, type);
this.location = location;
Bukkit.getPluginManager().callEvent(event);
diff --git a/src/main/java/me/paradoxpixel/themepark/gui/GUIListener.java b/src/main/java/me/paradoxpixel/themepark/gui/GUIListener.java
index 6c4a3d8..0d8ab0d 100644
--- a/src/main/java/me/paradoxpixel/themepark/gui/GUIListener.java
+++ b/src/main/java/me/paradoxpixel/themepark/gui/GUIListener.java
@@ -5,6 +5,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.inventory.Inventory;
public class GUIListener implements Listener {
@@ -26,4 +27,16 @@ public class GUIListener implements Listener {
e.setCancelled(gui.execute(player, slot, type));
}
+ @EventHandler
+ public void onMove(InventoryMoveItemEvent e) {
+ if(e.getDestination() == null)
+ return;
+
+ Inventory inventory = e.getDestination();
+ if(!(inventory.getHolder() instanceof GUIHolder))
+ return;
+
+ e.setCancelled(true);
+ }
+
}
diff --git a/src/main/java/me/paradoxpixel/themepark/placeholder/ThemeParkPlaceholder.java b/src/main/java/me/paradoxpixel/themepark/placeholder/ThemeParkPlaceholder.java
new file mode 100644
index 0000000..24cfe02
--- /dev/null
+++ b/src/main/java/me/paradoxpixel/themepark/placeholder/ThemeParkPlaceholder.java
@@ -0,0 +1,51 @@
+package me.paradoxpixel.themepark.placeholder;
+
+import me.paradoxpixel.themepark.ThemeParkPlugin;
+import me.paradoxpixel.themepark.api.API;
+import me.paradoxpixel.themepark.api.attraction.component.Status;
+import me.paradoxpixel.themepark.attraction.status.StatusManager;
+import me.paradoxpixel.themepark.utils.Utils;
+import org.bukkit.entity.Player;
+import me.clip.placeholderapi.external.EZPlaceholderHook;
+
+public class ThemeParkPlaceholder extends EZPlaceholderHook {
+
+ public ThemeParkPlaceholder(ThemeParkPlugin plugin) {
+ super(plugin, "tp");
+ }
+
+ @Override
+ public String onPlaceholderRequest(Player player, String identifier) {
+ if(identifier == null)
+ return null;
+
+ if(identifier.startsWith("status")) {
+ String[] args = identifier.split(":");
+ if(args.length < 2)
+ return null;
+
+ String id = args[1];
+ if(!API.isAttraction(id))
+ return null;
+
+ Status status = API.getAttraction(id).getStatus();
+ return Utils.color(StatusManager.getName(status));
+ }
+
+ if(identifier.startsWith("name")) {
+ String[] args = identifier.split(":");
+ if(args.length < 2)
+ return null;
+
+ String id = args[1];
+ if(!API.isAttraction(id))
+ return null;
+
+ String name = API.getAttraction(id).getName();
+ return Utils.color(name);
+ }
+
+ return null;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 684224f..7ee7d06 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -2,5 +2,6 @@ name: ThemePark
version: 1.2.2
main: me.paradoxpixel.themepark.ThemeParkPlugin
author: ParadoxPixel
+softdepend: [PlaceholderAPI]
commands:
status:
\ No newline at end of file