diff options
Diffstat (limited to 'bukkit')
-rw-r--r-- | bukkit/pom.xml | 62 | ||||
-rw-r--r-- | bukkit/src/main/java/me/lucko/spark/bukkit/BukkitTickCounter.java | 55 | ||||
-rw-r--r-- | bukkit/src/main/java/me/lucko/spark/bukkit/SparkBukkitPlugin.java | 73 | ||||
-rw-r--r-- | bukkit/src/main/resources/plugin.yml | 10 |
4 files changed, 0 insertions, 200 deletions
diff --git a/bukkit/pom.xml b/bukkit/pom.xml deleted file mode 100644 index 3e24269..0000000 --- a/bukkit/pom.xml +++ /dev/null @@ -1,62 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="http://maven.apache.org/POM/4.0.0" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <artifactId>spark-parent</artifactId> - <groupId>me.lucko</groupId> - <version>1.0-SNAPSHOT</version> - </parent> - <modelVersion>4.0.0</modelVersion> - - <artifactId>spark-bukkit</artifactId> - <packaging>jar</packaging> - - <build> - <defaultGoal>clean package</defaultGoal> - <finalName>spark-bukkit</finalName> - <resources> - <resource> - <directory>src/main/resources</directory> - <filtering>true</filtering> - </resource> - </resources> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>${compiler.version}</version> - <configuration> - <source>1.8</source> - <target>1.8</target> - </configuration> - </plugin> - </plugins> - </build> - - <dependencies> - <!-- common --> - <dependency> - <groupId>me.lucko</groupId> - <artifactId>spark-common</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - - <!-- Spigot --> - <dependency> - <groupId>org.spigotmc</groupId> - <artifactId>spigot-api</artifactId> - <version>1.12.2-R0.1-SNAPSHOT</version> - <scope>provided</scope> - </dependency> - </dependencies> - - <repositories> - <repository> - <id>spigot-repo</id> - <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> - </repository> - </repositories> - -</project> 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 |