diff --git a/pom.xml b/pom.xml
index b856f78..2be4132 100644
--- a/pom.xml
+++ b/pom.xml
@@ -75,6 +75,10 @@
jitpack.io
https://jitpack.io/
+
+ vault-repo
+ http://nexus.hc.to/content/repositories/pub_releases
+
@@ -100,6 +104,12 @@
Towny
master-SNAPSHOT
+
+ com.github.milkbowl
+ VaultAPI
+ master-SNAPSHOT
+ provided
+
TBMCPlugins
diff --git a/src/main/java/buttondevteam/core/MainPlugin.java b/src/main/java/buttondevteam/core/MainPlugin.java
index b906966..5525da6 100644
--- a/src/main/java/buttondevteam/core/MainPlugin.java
+++ b/src/main/java/buttondevteam/core/MainPlugin.java
@@ -4,19 +4,17 @@ import java.util.Map.Entry;
import java.util.UUID;
import java.util.logging.Logger;
-import javax.persistence.PersistenceException;
-
import org.bukkit.plugin.PluginDescriptionFile;
+import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
-import buttondevteam.lib.CPlayer;
import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.TBMCPlayer;
-import buttondevteam.lib.db.CData;
-import buttondevteam.lib.db.DataManager;
+import net.milkbowl.vault.permission.Permission;
public class MainPlugin extends JavaPlugin {
public static MainPlugin Instance;
+ public static Permission permission;
private PluginDescriptionFile pdfFile;
private Logger logger;
@@ -27,29 +25,10 @@ public class MainPlugin extends JavaPlugin {
Instance = this;
pdfFile = getDescription();
logger = getLogger();
-
- /*setupDatabase();
- DataManager.setDatabase(getDatabase());
- final UUID cid = UUID.randomUUID();
- final UUID mcid = UUID.randomUUID();
- System.out.println(cid);
- System.out.println(mcid);
- System.out.println("----");
- DataManager.save(new CPlayer(cid, mcid));
- System.out.println("----");
- System.out.println(DataManager.load(CPlayer.class, cid).getMinecraftID());*/
+ setupPermissions();
logger.info(pdfFile.getName() + " has been Enabled (V." + pdfFile.getVersion() + ").");
TBMCCoreAPI.RegisterEventsForExceptions(new PlayerListener(), this);
}
-
- private void setupDatabase() {
- try {
- getDatabase().find(CPlayer.class).findRowCount();
- } catch (PersistenceException ex) {
- System.out.println("Installing database for ButtonCore due to first time usage");
- installDDL();
- }
- }
@Override
public void onDisable() {
@@ -59,4 +38,13 @@ public class MainPlugin extends JavaPlugin {
}
logger.info("Player data saved.");
}
+
+ private boolean setupPermissions() {
+ RegisteredServiceProvider permissionProvider = getServer().getServicesManager()
+ .getRegistration(Permission.class);
+ if (permissionProvider != null) {
+ permission = permissionProvider.getProvider();
+ }
+ return (permission != null);
+ }
}
diff --git a/src/main/java/buttondevteam/lib/CPlayer.java b/src/main/java/buttondevteam/lib/CPlayer.java
deleted file mode 100644
index a0efd60..0000000
--- a/src/main/java/buttondevteam/lib/CPlayer.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package buttondevteam.lib;
-
-import java.util.UUID;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import buttondevteam.lib.db.CData;
-
-@Entity
-public class CPlayer implements CData {
- public CPlayer() {
- }
-
- public CPlayer(UUID chromaid, UUID mcid) {
- id = chromaid;
- this.mcid = mcid;
- }
-
- @Id
- private UUID id;
- @Column(unique = true)
- private UUID mcid;
-
- @Override
- public UUID getChromaID() {
- return id;
- }
-
- public void setChromaID(UUID id) {
- this.id = id;
- }
-
- public UUID getMinecraftID() {
- return mcid;
- }
-
- public void setMinecraftID(UUID mcid) {
- this.mcid = mcid;
- }
-
-}
diff --git a/src/main/java/buttondevteam/lib/TBMCPlayerBase.java b/src/main/java/buttondevteam/lib/TBMCPlayerBase.java
new file mode 100644
index 0000000..cac3068
--- /dev/null
+++ b/src/main/java/buttondevteam/lib/TBMCPlayerBase.java
@@ -0,0 +1,15 @@
+package buttondevteam.lib;
+
+public abstract class TBMCPlayerBase {
+ /**
+ * This method returns the filename for this player data. For example, for Minecraft-related data, use MC UUIDs, for Discord data, use Discord IDs, etc.
+ */
+ public abstract String getFileName();
+
+ /**
+ * This method returns the folder the file is in. For example, for Minecraft data, this should be "minecraft", for Discord, "discord", etc.
+ */
+ public abstract String getFolder();
+
+
+}
diff --git a/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java b/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java
index 3a62ef6..0d81794 100644
--- a/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java
+++ b/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java
@@ -8,12 +8,14 @@ import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.reflections.Reflections;
import org.reflections.scanners.SubTypesScanner;
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;
+import buttondevteam.core.MainPlugin;
import buttondevteam.lib.TBMCChatEvent;
import buttondevteam.lib.TBMCCoreAPI;
@@ -30,10 +32,12 @@ public class TBMCChatAPI {
*
* @param command
* The command which we want the subcommands of
+ * @param sender
+ * The sender for permissions
* @return The subcommands
*/
- public static String[] GetSubCommands(TBMCCommandBase command) {
- return GetSubCommands(command.GetCommandPath());
+ public static String[] GetSubCommands(TBMCCommandBase command, CommandSender sender) {
+ return GetSubCommands(command.GetCommandPath(), sender);
}
/**
@@ -41,9 +45,11 @@ public class TBMCChatAPI {
*
* @param command
* The command which we want the subcommands of
+ * @param sender
+ * The sender for permissions
* @return The subcommands
*/
- public static String[] GetSubCommands(String command) {
+ public static String[] GetSubCommands(String command, CommandSender sender) {
ArrayList cmds = new ArrayList();
cmds.add("ยง6---- Subcommands ----");
for (TBMCCommandBase cmd : TBMCChatAPI.GetCommands().values()) {
@@ -51,6 +57,10 @@ public class TBMCChatAPI {
int ind = cmd.GetCommandPath().indexOf(' ', command.length() + 2);
if (ind >= 0)
continue;
+ if (cmd.GetPlayerOnly() && !(sender instanceof Player))
+ continue;
+ if (cmd.GetModOnly() && !MainPlugin.permission.has(sender, "tbmc.admin"))
+ continue;
cmds.add("/" + cmd.GetCommandPath());
}
}
diff --git a/src/main/java/buttondevteam/lib/db/CData.java b/src/main/java/buttondevteam/lib/db/CData.java
deleted file mode 100644
index 53f1c1e..0000000
--- a/src/main/java/buttondevteam/lib/db/CData.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package buttondevteam.lib.db;
-
-import java.util.UUID;
-
-public interface CData {
- public UUID getChromaID();
-}
diff --git a/src/main/java/buttondevteam/lib/db/DataManager.java b/src/main/java/buttondevteam/lib/db/DataManager.java
deleted file mode 100644
index e40b7ec..0000000
--- a/src/main/java/buttondevteam/lib/db/DataManager.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package buttondevteam.lib.db;
-
-import java.util.UUID;
-
-import javax.persistence.PersistenceException;
-
-import org.bukkit.plugin.java.JavaPlugin;
-
-import com.avaje.ebean.EbeanServer;
-
-import buttondevteam.core.MainPlugin;
-
-public final class DataManager {
- private static EbeanServer database;
-
- /**
- * Can be only used once and is used by {@link MainPlugin}
- *
- * @param database
- * The database to set
- */
- public static void setDatabase(EbeanServer database) {
- DataManager.database = database;
- }
-
- public static T load(Class cl, UUID id) {
- return database.find(cl, id);
- }
-
- public static void save(T obj) {
- database.save(obj);
- }
-
-}