aboutsummaryrefslogtreecommitdiff
path: root/bukkit/src
diff options
context:
space:
mode:
authorLuck <git@lucko.me>2018-06-06 15:39:16 +0100
committerLuck <git@lucko.me>2018-06-06 15:39:16 +0100
commit7d6808cbcfbb0f61f93e536d36968eeda5bd302c (patch)
tree3271db1ffa6e4d6c1fa5ea4ccc1335b1ac746f46 /bukkit/src
parent38f0c12483e6eda79ca36dc829ef678a736d2cef (diff)
downloadspark-7d6808cbcfbb0f61f93e536d36968eeda5bd302c.tar.gz
spark-7d6808cbcfbb0f61f93e536d36968eeda5bd302c.tar.bz2
spark-7d6808cbcfbb0f61f93e536d36968eeda5bd302c.zip
Convert to Gradle
Diffstat (limited to 'bukkit/src')
-rw-r--r--bukkit/src/main/java/me/lucko/spark/bukkit/BukkitTickCounter.java55
-rw-r--r--bukkit/src/main/java/me/lucko/spark/bukkit/SparkBukkitPlugin.java73
-rw-r--r--bukkit/src/main/resources/plugin.yml10
3 files changed, 0 insertions, 138 deletions
diff --git a/bukkit/src/main/java/me/lucko/spark/bukkit/BukkitTickCounter.java b/bukkit/src/main/java/me/lucko/spark/bukkit/BukkitTickCounter.java
deleted file mode 100644
index 61a7690..0000000
--- a/bukkit/src/main/java/me/lucko/spark/bukkit/BukkitTickCounter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package me.lucko.spark.bukkit;
-
-import me.lucko.spark.profiler.TickCounter;
-
-import org.bukkit.plugin.Plugin;
-import org.bukkit.scheduler.BukkitTask;
-
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.atomic.LongAdder;
-
-public class BukkitTickCounter implements TickCounter, Runnable {
- private final Plugin plugin;
- private BukkitTask task;
-
- private final Set<Runnable> tasks = new HashSet<>();
- private final LongAdder tick = new LongAdder();
-
- public BukkitTickCounter(Plugin plugin) {
- this.plugin = plugin;
- }
-
- @Override
- public void run() {
- this.tick.increment();
- for (Runnable r : this.tasks){
- r.run();
- }
- }
-
- @Override
- public void start() {
- this.task = this.plugin.getServer().getScheduler().runTaskTimer(this.plugin, this, 1, 1);
- }
-
- @Override
- public void close() {
- this.task.cancel();
- }
-
- @Override
- public long getCurrentTick() {
- return this.tick.longValue();
- }
-
- @Override
- public void addTickTask(Runnable runnable) {
- this.tasks.add(runnable);
- }
-
- @Override
- public void removeTickTask(Runnable runnable) {
- this.tasks.remove(runnable);
- }
-}
diff --git a/bukkit/src/main/java/me/lucko/spark/bukkit/SparkBukkitPlugin.java b/bukkit/src/main/java/me/lucko/spark/bukkit/SparkBukkitPlugin.java
deleted file mode 100644
index dc432c5..0000000
--- a/bukkit/src/main/java/me/lucko/spark/bukkit/SparkBukkitPlugin.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package me.lucko.spark.bukkit;
-
-import me.lucko.spark.common.CommandHandler;
-import me.lucko.spark.profiler.ThreadDumper;
-import me.lucko.spark.profiler.TickCounter;
-
-import org.bukkit.ChatColor;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.java.JavaPlugin;
-
-public class SparkBukkitPlugin extends JavaPlugin {
-
- private final CommandHandler<CommandSender> commandHandler = new CommandHandler<CommandSender>() {
-
- private String colorize(String message) {
- return ChatColor.translateAlternateColorCodes('&', message);
- }
-
- private void broadcast(String msg) {
- getServer().getConsoleSender().sendMessage(msg);
- for (Player player : getServer().getOnlinePlayers()) {
- if (player.hasPermission("spark.profiler")) {
- player.sendMessage(msg);
- }
- }
- }
-
- @Override
- protected void sendMessage(CommandSender sender, String message) {
- sender.sendMessage(colorize(message));
- }
-
- @Override
- protected void sendMessage(String message) {
- String msg = colorize(message);
- broadcast(msg);
- }
-
- @Override
- protected void sendLink(String url) {
- String msg = colorize("&7" + url);
- broadcast(msg);
- }
-
- @Override
- protected void runAsync(Runnable r) {
- getServer().getScheduler().runTaskAsynchronously(SparkBukkitPlugin.this, r);
- }
-
- @Override
- protected ThreadDumper getDefaultThreadDumper() {
- return new ThreadDumper.Specific(new long[]{Thread.currentThread().getId()});
- }
-
- @Override
- protected TickCounter newTickCounter() {
- return new BukkitTickCounter(SparkBukkitPlugin.this);
- }
- };
-
- @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;
- }
-}
diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml
deleted file mode 100644
index bd549b5..0000000
--- a/bukkit/src/main/resources/plugin.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-name: spark
-version: 1.0.4
-description: ${project.description}
-authors: [Luck, sk89q]
-main: me.lucko.spark.bukkit.SparkBukkitPlugin
-
-commands:
- spark:
- description: Main plugin command
- aliases: [profiler] \ No newline at end of file