aboutsummaryrefslogtreecommitdiff
path: root/spark-nukkit/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'spark-nukkit/src/main/java')
-rw-r--r--spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitClassSourceLookup.java38
-rw-r--r--spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitCommandSender.java59
-rw-r--r--spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitPlatformInfo.java57
-rw-r--r--spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitPlayerPingProvider.java45
-rw-r--r--spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitSparkPlugin.java118
5 files changed, 0 insertions, 317 deletions
diff --git a/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitClassSourceLookup.java b/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitClassSourceLookup.java
deleted file mode 100644
index e815b6c..0000000
--- a/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitClassSourceLookup.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * 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 <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.nukkit;
-
-import cn.nukkit.plugin.PluginClassLoader;
-import me.lucko.spark.common.sampler.source.ClassSourceLookup;
-
-import java.io.IOException;
-import java.net.URISyntaxException;
-
-public class NukkitClassSourceLookup extends ClassSourceLookup.ByFirstUrlSource {
-
- @Override
- public String identify(ClassLoader loader) throws IOException, URISyntaxException {
- if (loader instanceof PluginClassLoader) {
- return super.identify(loader);
- }
- return null;
- }
-}
diff --git a/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitCommandSender.java b/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitCommandSender.java
deleted file mode 100644
index 3d6de22..0000000
--- a/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitCommandSender.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * 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 <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.nukkit;
-
-import cn.nukkit.Player;
-import cn.nukkit.command.CommandSender;
-import me.lucko.spark.common.command.sender.AbstractCommandSender;
-import net.kyori.adventure.text.Component;
-import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
-
-import java.util.UUID;
-
-public class NukkitCommandSender extends AbstractCommandSender<CommandSender> {
-
- public NukkitCommandSender(CommandSender delegate) {
- super(delegate);
- }
-
- @Override
- public String getName() {
- return this.delegate.getName();
- }
-
- @Override
- public UUID getUniqueId() {
- if (this.delegate instanceof Player) {
- return ((Player) this.delegate).getUniqueId();
- }
- return null;
- }
-
- @Override
- public void sendMessage(Component message) {
- this.delegate.sendMessage(LegacyComponentSerializer.legacySection().serialize(message));
- }
-
- @Override
- public boolean hasPermission(String permission) {
- return this.delegate.hasPermission(permission);
- }
-}
diff --git a/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitPlatformInfo.java b/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitPlatformInfo.java
deleted file mode 100644
index a1c9c5b..0000000
--- a/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitPlatformInfo.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * 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 <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.nukkit;
-
-import cn.nukkit.Server;
-import me.lucko.spark.common.platform.PlatformInfo;
-
-public class NukkitPlatformInfo implements PlatformInfo {
- private final Server server;
-
- public NukkitPlatformInfo(Server server) {
- this.server = server;
- }
-
- @Override
- public Type getType() {
- return Type.SERVER;
- }
-
- @Override
- public String getName() {
- return "Nukkit";
- }
-
- @Override
- public String getBrand() {
- return this.server.getName();
- }
-
- @Override
- public String getVersion() {
- return this.server.getNukkitVersion();
- }
-
- @Override
- public String getMinecraftVersion() {
- return this.server.getVersion();
- }
-}
diff --git a/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitPlayerPingProvider.java b/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitPlayerPingProvider.java
deleted file mode 100644
index b2e5100..0000000
--- a/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitPlayerPingProvider.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * 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 <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.nukkit;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import com.google.common.collect.ImmutableMap;
-import me.lucko.spark.common.monitor.ping.PlayerPingProvider;
-
-import java.util.Map;
-
-public class NukkitPlayerPingProvider implements PlayerPingProvider {
- private final Server server;
-
- public NukkitPlayerPingProvider(Server server) {
- this.server = server;
- }
-
- @Override
- public Map<String, Integer> poll() {
- ImmutableMap.Builder<String, Integer> builder = ImmutableMap.builder();
- for (Player player : this.server.getOnlinePlayers().values()) {
- builder.put(player.getName(), player.getPing());
- }
- return builder.build();
- }
-}
diff --git a/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitSparkPlugin.java b/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitSparkPlugin.java
deleted file mode 100644
index 39be28d..0000000
--- a/spark-nukkit/src/main/java/me/lucko/spark/nukkit/NukkitSparkPlugin.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * This file is part of spark.
- *
- * Copyright (c) lucko (Luck) <luck@lucko.me>
- * 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 <http://www.gnu.org/licenses/>.
- */
-
-package me.lucko.spark.nukkit;
-
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.plugin.PluginBase;
-import cn.nukkit.plugin.service.ServicePriority;
-import me.lucko.spark.api.Spark;
-import me.lucko.spark.common.SparkPlatform;
-import me.lucko.spark.common.SparkPlugin;
-import me.lucko.spark.common.monitor.ping.PlayerPingProvider;
-import me.lucko.spark.common.platform.PlatformInfo;
-import me.lucko.spark.common.sampler.source.ClassSourceLookup;
-
-import java.nio.file.Path;
-import java.util.logging.Level;
-import java.util.stream.Stream;
-
-public class NukkitSparkPlugin extends PluginBase implements SparkPlugin {
- private SparkPlatform platform;
-
- @Override
- public void onEnable() {
- this.platform = new SparkPlatform(this);
- this.platform.enable();
- }
-
- @Override
- public void onDisable() {
- this.platform.disable();
- }
-
- @Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- this.platform.executeCommand(new NukkitCommandSender(sender), args);
- return true;
- }
-
- @Override
- public String getVersion() {
- return getDescription().getVersion();
- }
-
- @Override
- public Path getPluginDirectory() {
- return getDataFolder().toPath();
- }
-
- @Override
- public String getCommandName() {
- return "spark";
- }
-
- @Override
- public Stream<NukkitCommandSender> getCommandSenders() {
- return Stream.concat(
- getServer().getOnlinePlayers().values().stream(),
- Stream.of(getServer().getConsoleSender())
- ).map(NukkitCommandSender::new);
- }
-
- @Override
- public void executeAsync(Runnable task) {
- getServer().getScheduler().scheduleTask(this, task, true);
- }
-
- @Override
- public void log(Level level, String msg) {
- if (level == Level.INFO) {
- getLogger().info(msg);
- } else if (level == Level.WARNING) {
- getLogger().warning(msg);
- } else if (level == Level.SEVERE) {
- getLogger().error(msg);
- } else {
- throw new IllegalArgumentException(level.getName());
- }
- }
-
- @Override
- public ClassSourceLookup createClassSourceLookup() {
- return new NukkitClassSourceLookup();
- }
-
- @Override
- public PlayerPingProvider createPlayerPingProvider() {
- return new NukkitPlayerPingProvider(getServer());
- }
-
- @Override
- public PlatformInfo getPlatformInfo() {
- return new NukkitPlatformInfo(getServer());
- }
-
- @Override
- public void registerApi(Spark api) {
- getServer().getServiceManager().register(Spark.class, api, this, ServicePriority.NORMAL);
- }
-}