From 2a03b547c7714a130b2bc1407b12a8abd58a9069 Mon Sep 17 00:00:00 2001 From: Luck Date: Sat, 3 Aug 2019 22:04:20 +0100 Subject: Some more reorganising --- .../spark/bungeecord/BungeeCordSparkPlugin.java | 95 ++++++++++++++++++ .../spark/bungeecord/SparkBungeeCordPlugin.java | 107 --------------------- spark-bungeecord/src/main/resources/bungee.yml | 2 +- 3 files changed, 96 insertions(+), 108 deletions(-) create mode 100644 spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordSparkPlugin.java delete mode 100644 spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/SparkBungeeCordPlugin.java (limited to 'spark-bungeecord/src/main') diff --git a/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordSparkPlugin.java b/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordSparkPlugin.java new file mode 100644 index 0000000..0fc85b7 --- /dev/null +++ b/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordSparkPlugin.java @@ -0,0 +1,95 @@ +/* + * This file is part of spark. + * + * Copyright (c) lucko (Luck) + * Copyright (c) contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package me.lucko.spark.bungeecord; + +import me.lucko.spark.common.SparkPlatform; +import me.lucko.spark.common.SparkPlugin; +import net.md_5.bungee.api.CommandSender; +import net.md_5.bungee.api.plugin.Command; +import net.md_5.bungee.api.plugin.Plugin; +import net.md_5.bungee.api.plugin.TabExecutor; + +import java.nio.file.Path; +import java.util.stream.Stream; + +public class BungeeCordSparkPlugin extends Plugin implements SparkPlugin { + + private SparkPlatform platform; + + @Override + public void onEnable() { + this.platform = new SparkPlatform(this); + this.platform.enable(); + getProxy().getPluginManager().registerCommand(this, new SparkCommand(this)); + } + + @Override + public void onDisable() { + this.platform.disable(); + } + + @Override + public String getVersion() { + return getDescription().getVersion(); + } + + @Override + public Path getPluginDirectory() { + return getDataFolder().toPath(); + } + + @Override + public String getCommandName() { + return "sparkb"; + } + + @Override + public Stream getSendersWithPermission(String permission) { + return Stream.concat( + getProxy().getPlayers().stream().filter(player -> player.hasPermission(permission)), + Stream.of(getProxy().getConsole()) + ).map(BungeeCordCommandSender::new); + } + + @Override + public void executeAsync(Runnable task) { + getProxy().getScheduler().runAsync(BungeeCordSparkPlugin.this, task); + } + + private static final class SparkCommand extends Command implements TabExecutor { + private final BungeeCordSparkPlugin plugin; + + SparkCommand(BungeeCordSparkPlugin plugin) { + super("sparkb", null, "sparkbungee"); + this.plugin = plugin; + } + + @Override + public void execute(CommandSender sender, String[] args) { + this.plugin.platform.executeCommand(new BungeeCordCommandSender(sender), args); + } + + @Override + public Iterable onTabComplete(CommandSender sender, String[] args) { + return this.plugin.platform.tabCompleteCommand(new BungeeCordCommandSender(sender), args); + } + } +} diff --git a/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/SparkBungeeCordPlugin.java b/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/SparkBungeeCordPlugin.java deleted file mode 100644 index 630035b..0000000 --- a/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/SparkBungeeCordPlugin.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * This file is part of spark. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package me.lucko.spark.bungeecord; - -import me.lucko.spark.common.SparkPlatform; -import me.lucko.spark.common.SparkPlugin; -import me.lucko.spark.common.sampler.ThreadDumper; -import me.lucko.spark.common.sampler.TickCounter; -import net.md_5.bungee.api.CommandSender; -import net.md_5.bungee.api.plugin.Command; -import net.md_5.bungee.api.plugin.Plugin; -import net.md_5.bungee.api.plugin.TabExecutor; - -import java.nio.file.Path; -import java.util.stream.Stream; - -public class SparkBungeeCordPlugin extends Plugin implements SparkPlugin { - - private SparkPlatform platform; - - @Override - public void onEnable() { - this.platform = new SparkPlatform(this); - this.platform.enable(); - getProxy().getPluginManager().registerCommand(this, new SparkCommand(this)); - } - - @Override - public void onDisable() { - this.platform.disable(); - } - - @Override - public String getVersion() { - return getDescription().getVersion(); - } - - @Override - public Path getPluginFolder() { - return getDataFolder().toPath(); - } - - @Override - public String getLabel() { - return "sparkb"; - } - - @Override - public Stream getSendersWithPermission(String permission) { - return Stream.concat( - getProxy().getPlayers().stream().filter(player -> player.hasPermission(permission)), - Stream.of(getProxy().getConsole()) - ).map(BungeeCordCommandSender::new); - } - - @Override - public void runAsync(Runnable r) { - getProxy().getScheduler().runAsync(SparkBungeeCordPlugin.this, r); - } - - @Override - public ThreadDumper getDefaultThreadDumper() { - return ThreadDumper.ALL; - } - - @Override - public TickCounter createTickCounter() { - return null; - } - - private static final class SparkCommand extends Command implements TabExecutor { - private final SparkBungeeCordPlugin plugin; - - SparkCommand(SparkBungeeCordPlugin plugin) { - super("sparkb", null, "sparkbungee"); - this.plugin = plugin; - } - - @Override - public void execute(CommandSender sender, String[] args) { - this.plugin.platform.executeCommand(new BungeeCordCommandSender(sender), args); - } - - @Override - public Iterable onTabComplete(CommandSender sender, String[] args) { - return this.plugin.platform.tabCompleteCommand(new BungeeCordCommandSender(sender), args); - } - } -} diff --git a/spark-bungeecord/src/main/resources/bungee.yml b/spark-bungeecord/src/main/resources/bungee.yml index 4485e11..ccf512e 100644 --- a/spark-bungeecord/src/main/resources/bungee.yml +++ b/spark-bungeecord/src/main/resources/bungee.yml @@ -2,4 +2,4 @@ name: spark version: ${pluginVersion} description: ${pluginDescription} author: Luck, sk89q -main: me.lucko.spark.bungeecord.SparkBungeeCordPlugin +main: me.lucko.spark.bungeecord.BungeeCordSparkPlugin -- cgit