From 429eeb35876576d861404cd199b6e9763fc4e5b0 Mon Sep 17 00:00:00 2001 From: Luck Date: Sat, 26 May 2018 22:52:58 +0100 Subject: Initial commit for spark --- .../me/lucko/spark/bukkit/SparkBukkitPlugin.java | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 bukkit/src/main/java/me/lucko/spark/bukkit/SparkBukkitPlugin.java (limited to 'bukkit/src/main/java/me/lucko/spark') diff --git a/bukkit/src/main/java/me/lucko/spark/bukkit/SparkBukkitPlugin.java b/bukkit/src/main/java/me/lucko/spark/bukkit/SparkBukkitPlugin.java new file mode 100644 index 0000000..0ddbce0 --- /dev/null +++ b/bukkit/src/main/java/me/lucko/spark/bukkit/SparkBukkitPlugin.java @@ -0,0 +1,34 @@ +package me.lucko.spark.bukkit; + +import me.lucko.spark.common.CommandHandler; + +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.plugin.java.JavaPlugin; + +public class SparkBukkitPlugin extends JavaPlugin { + + private final CommandHandler commandHandler = new CommandHandler() { + @Override + protected void sendMessage(CommandSender sender, String message) { + sender.sendMessage(ChatColor.translateAlternateColorCodes('&', message)); + } + + @Override + protected void runAsync(Runnable r) { + getServer().getScheduler().runTaskAsynchronously(SparkBukkitPlugin.this, r); + } + }; + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!sender.hasPermission("spark.profiler")) { + sender.sendMessage(ChatColor.RED + "You do not have permission to use this command."); + return true; + } + + this.commandHandler.handleCommand(sender, args); + return true; + } +} -- cgit