diff --git a/ontime-velocity/src/main/java/org/anvilpowered/ontime/velocity/command/VelocityOnTimeAddCommand.java b/ontime-api/src/main/java/org/anvilpowered/ontime/api/plugin/PluginMessages.java
similarity index 62%
rename from ontime-velocity/src/main/java/org/anvilpowered/ontime/velocity/command/VelocityOnTimeAddCommand.java
rename to ontime-api/src/main/java/org/anvilpowered/ontime/api/plugin/PluginMessages.java
index 8ffc5a0..7222463 100644
--- a/ontime-velocity/src/main/java/org/anvilpowered/ontime/velocity/command/VelocityOnTimeAddCommand.java
+++ b/ontime-api/src/main/java/org/anvilpowered/ontime/api/plugin/PluginMessages.java
@@ -16,15 +16,9 @@
* along with this program. If not, see .
*/
-package org.anvilpowered.ontime.velocity.command;
+package org.anvilpowered.ontime.api.plugin;
-import com.velocitypowered.api.command.Command;
-import com.velocitypowered.api.command.CommandSource;
-import com.velocitypowered.api.proxy.Player;
-import net.kyori.adventure.text.TextComponent;
-import org.anvilpowered.ontime.common.command.CommonOnTimeAddCommand;
+public interface PluginMessages {
-public class VelocityOnTimeAddCommand
- extends CommonOnTimeAddCommand
- implements Command {
+ TString getNoPermission();
}
diff --git a/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonOnTimeAddCommand.java b/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonAddCommand.kt
similarity index 74%
rename from ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonOnTimeAddCommand.java
rename to ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonAddCommand.kt
index a4c4989..38174b5 100644
--- a/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonOnTimeAddCommand.java
+++ b/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonAddCommand.kt
@@ -15,13 +15,11 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
+package org.anvilpowered.ontime.common.command
-package org.anvilpowered.ontime.common.command;
-
-public class CommonOnTimeAddCommand
- extends CommonOnTimeTwoArgCommand {
-
- public void execute(TCommandSource source, String[] context) {
- execute(source, context, "add", memberManager::addBonusTime);
+open class CommonAddCommand :
+ CommonTwoArgCommand() {
+ open fun execute(source: TCommandSource, context: Array) {
+ execute(source, context, "add", memberManager::addBonusTime)
}
}
diff --git a/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonCheckCommand.kt b/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonCheckCommand.kt
new file mode 100644
index 0000000..a5a250d
--- /dev/null
+++ b/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonCheckCommand.kt
@@ -0,0 +1,115 @@
+/*
+ * OnTime - AnvilPowered
+ * Copyright (C) 2020
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+package org.anvilpowered.ontime.common.command
+
+import com.google.inject.Inject
+import org.anvilpowered.anvil.api.plugin.PluginInfo
+import org.anvilpowered.anvil.api.registry.Registry
+import org.anvilpowered.anvil.api.util.PermissionService
+import org.anvilpowered.anvil.api.util.TextService
+import org.anvilpowered.anvil.api.util.UserService
+import org.anvilpowered.ontime.api.member.MemberManager
+import org.anvilpowered.ontime.api.plugin.PluginMessages
+import org.anvilpowered.ontime.api.registry.OnTimeKeys
+import java.util.Optional
+import java.util.UUID
+import java.util.concurrent.CompletableFuture
+
+open class CommonCheckCommand<
+ TUser : Any,
+ TPlayer : Any,
+ TString : Any,
+ TCommandSource : Any
+ >(
+ private val playerClass: Class
+) {
+
+ @Inject
+ protected lateinit var memberManager: MemberManager
+
+ @Inject
+ private lateinit var permissionService: PermissionService
+
+ @Inject
+ private lateinit var pluginInfo: PluginInfo
+
+ @Inject
+ private lateinit var pluginMessages: PluginMessages
+
+ @Inject
+ protected lateinit var registry: Registry
+
+ @Inject
+ protected lateinit var textService: TextService
+
+ @Inject
+ private lateinit var userService: UserService
+
+ private val error: TString by lazy {
+ textService.builder()
+ .append(pluginInfo.prefix)
+ .red().append("Specify user or run as player!")
+ .build()
+ }
+
+ private fun testPermission(source: Any?): Boolean {
+ return permissionService.hasPermission(source ?: return false, registry.getOrDefault(OnTimeKeys.CHECK_PERMISSION))
+ }
+
+ private fun hasNoPerms(source: TCommandSource): Boolean {
+ if (!testPermission(source)) {
+ textService.send(pluginMessages.noPermission, source)
+ return true
+ }
+ return false
+ }
+
+ open fun execute(
+ source: TCommandSource,
+ context: Array
+ ) {
+ if (hasNoPerms(source)) return
+ val isPlayer = playerClass.isAssignableFrom(source.javaClass)
+ val hasExtended = permissionService.hasPermission(source, registry.getOrDefault(OnTimeKeys.CHECK_EXTENDED_PERMISSION))
+ val futureUUID = if (context.size == 1 && hasExtended) {
+ userService.getUUID(context[0])
+ } else {
+ CompletableFuture.completedFuture(Optional.empty())
+ }
+ futureUUID.thenAcceptAsync { optionalUserUUID: Optional ->
+ if (optionalUserUUID.isPresent) {
+ memberManager.infoExtended(optionalUserUUID.get())
+ .thenAcceptAsync { textService.send(it, source) }
+ } else if (isPlayer) {
+ val userUUID = userService.getUUID(source as TUser)
+ if (hasExtended) {
+ memberManager.infoExtended(userUUID)
+ } else {
+ memberManager.info(userUUID)
+ }.thenAcceptAsync { textService.send(it, source) }
+ } else {
+ textService.send(error, source)
+ }
+ }
+ }
+
+ open fun suggest(source: TCommandSource, context: Array): List {
+ if (!testPermission(source)) return listOf()
+ return userService.matchPlayerNames(context, 0, 1)
+ }
+}
diff --git a/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonOnTimeCheckCommand.java b/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonOnTimeCheckCommand.java
deleted file mode 100644
index eb8ab6a..0000000
--- a/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonOnTimeCheckCommand.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * OnTime - AnvilPowered
- * Copyright (C) 2020
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package org.anvilpowered.ontime.common.command;
-
-import com.google.inject.Inject;
-import org.anvilpowered.anvil.api.plugin.PluginInfo;
-import org.anvilpowered.anvil.api.registry.Registry;
-import org.anvilpowered.anvil.api.util.PermissionService;
-import org.anvilpowered.anvil.api.util.TextService;
-import org.anvilpowered.anvil.api.util.UserService;
-import org.anvilpowered.ontime.api.member.MemberManager;
-import org.anvilpowered.ontime.api.registry.OnTimeKeys;
-
-import java.util.Optional;
-import java.util.UUID;
-import java.util.concurrent.CompletableFuture;
-
-@SuppressWarnings("unchecked")
-public class CommonOnTimeCheckCommand {
-
- @Inject
- protected MemberManager memberManager;
-
- @Inject
- private PermissionService permissionService;
-
- @Inject
- private PluginInfo pluginInfo;
-
- @Inject
- protected Registry registry;
-
- @Inject
- private TextService textService;
-
- @Inject
- private UserService userService;
-
- public void sendError(TCommandSource source) {
- textService.builder()
- .append(pluginInfo.getPrefix())
- .red().append("Specify user or run as player!")
- .sendTo(source);
- }
-
- public void execute(TCommandSource source, String[] context,
- Class playerClass) {
- final boolean isPlayer = playerClass.isAssignableFrom(source.getClass());
- if (!permissionService.hasPermission(source,
- registry.getOrDefault(OnTimeKeys.CHECK_PERMISSION))) {
- textService.builder()
- .append(pluginInfo.getPrefix())
- .red().append("You do not have permission for this command!")
- .sendTo(source);
- return;
- }
- final boolean hasExtended = permissionService.hasPermission(source,
- registry.getOrDefault(OnTimeKeys.CHECK_EXTENDED_PERMISSION));
-
- CompletableFuture> futureUUID;
- if (context.length == 1 && hasExtended) {
- futureUUID = userService.getUUID(context[0]);
- } else {
- futureUUID = CompletableFuture.completedFuture(Optional.empty());
- }
- futureUUID.thenAcceptAsync(optionalUserUUID -> {
- if (optionalUserUUID.isPresent()) {
- memberManager.infoExtended(optionalUserUUID.get())
- .thenAcceptAsync(result -> textService.send(result, source));
- } else if (isPlayer) {
- UUID userUUID = userService.getUUID((TUser) source);
- if (hasExtended) {
- memberManager.infoExtended(userUUID)
- .thenAcceptAsync(result -> textService.send(result, source));
- } else {
- memberManager.info(userUUID)
- .thenAcceptAsync(result -> textService.send(result, source));
- }
- } else {
- sendError(source);
- }
- });
- }
-}
diff --git a/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonOnTimeCommandNode.java b/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonOnTimeCommandNode.java
deleted file mode 100644
index b90eee7..0000000
--- a/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonOnTimeCommandNode.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * OnTime - AnvilPowered
- * Copyright (C) 2020
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package org.anvilpowered.ontime.common.command;
-
-import org.anvilpowered.anvil.api.Environment;
-import org.anvilpowered.anvil.api.command.CommandNode;
-import org.anvilpowered.anvil.api.command.CommandService;
-import org.anvilpowered.anvil.api.registry.Registry;
-import org.anvilpowered.ontime.common.plugin.OnTimePluginInfo;
-
-import javax.inject.Inject;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.function.Function;
-import java.util.function.Predicate;
-
-public abstract class CommonOnTimeCommandNode
- implements CommandNode {
-
- protected static final List ADD_ALIAS = Arrays.asList("add", "a");
- protected static final List CHECK_ALIAS = Arrays.asList("check", "c", "info", "i");
- protected static final List IMPORT_ALIAS = Collections.singletonList("import");
- protected static final List SET_BONUS_ALIAS = Arrays.asList("setbonus", "sb");
- protected static final List SET_TOTAL_ALIAS = Arrays.asList("set", "s", "settotal", "st");
- protected static final List HELP_ALIAS = Arrays.asList("help", "h");
- protected static final List VERSION_ALIAS = Arrays.asList("version", "v");
-
- protected static final String ADD_DESCRIPTION = "Add bonus time to a player";
- protected static final String CHECK_DESCRIPTION = "Check playtime";
- protected static final String IMPORT_DESCRIPTION = "Import data from rankupper";
- protected static final String SET_BONUS_DESCRIPTION = "Set bonus playtime";
- protected static final String SET_TOTAL_DESCRIPTION = "Set total playtime";
- protected static final String HELP_DESCRIPTION = "Shows this help page.";
- protected static final String VERSION_DESCRIPTION = "Shows the plugin version";
- protected static final String ROOT_DESCRIPTION = String.format("%s root command", OnTimePluginInfo.name);
-
- protected static final String ADD_USAGE = " ";
- protected static final String CHECK_USAGE = "[]";
- protected static final String IMPORT_USAGE = "";
- protected static final String SET_BONUS_USAGE = " ";
- protected static final String SET_TOTAL_USAGE = " ";
-
- protected static final String HELP_COMMAND = "/ontime help";
-
- private boolean alreadyLoaded;
- protected Map, Function> descriptions;
- protected Map, Predicate> permissions;
- protected Map, Function> usages;
-
- @Inject
- protected CommandService commandService;
-
- @Inject
- protected Environment environment;
-
- protected Registry registry;
-
- protected CommonOnTimeCommandNode(Registry registry) {
- this.registry = registry;
- registry.whenLoaded(() -> {
- if (alreadyLoaded) return;
- loadCommands();
- alreadyLoaded = true;
- }).register();
- alreadyLoaded = false;
- descriptions = new HashMap<>();
- permissions = new HashMap<>();
- usages = new HashMap<>();
- descriptions.put(ADD_ALIAS, c -> ADD_DESCRIPTION);
- descriptions.put(CHECK_ALIAS, c -> CHECK_DESCRIPTION);
- descriptions.put(IMPORT_ALIAS, c -> IMPORT_DESCRIPTION);
- descriptions.put(SET_BONUS_ALIAS, c -> SET_BONUS_DESCRIPTION);
- descriptions.put(SET_TOTAL_ALIAS, c -> SET_TOTAL_DESCRIPTION);
- descriptions.put(HELP_ALIAS, c -> HELP_DESCRIPTION);
- descriptions.put(VERSION_ALIAS, c -> VERSION_DESCRIPTION);
- usages.put(ADD_ALIAS, c -> ADD_USAGE);
- usages.put(CHECK_ALIAS, c -> CHECK_USAGE);
- usages.put(IMPORT_ALIAS, c -> IMPORT_USAGE);
- usages.put(SET_BONUS_ALIAS, c -> SET_BONUS_USAGE);
- usages.put(SET_TOTAL_ALIAS, c -> SET_TOTAL_USAGE);
- }
-
- protected abstract void loadCommands();
-
- private static final String ERROR_MESSAGE = "OnTime command has not been loaded yet";
-
- @Override
- public Map, Function> getDescriptions() {
- return Objects.requireNonNull(descriptions, ERROR_MESSAGE);
- }
-
- @Override
- public Map, Predicate> getPermissions() {
- return Objects.requireNonNull(permissions, ERROR_MESSAGE);
- }
-
- @Override
- public Map, Function> getUsages() {
- return Objects.requireNonNull(usages, ERROR_MESSAGE);
- }
-
- @Override
- public String getName() {
- return OnTimePluginInfo.id;
- }
-}
diff --git a/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonOnTimeCommandNode.kt b/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonOnTimeCommandNode.kt
new file mode 100644
index 0000000..b0c5951
--- /dev/null
+++ b/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonOnTimeCommandNode.kt
@@ -0,0 +1,99 @@
+/*
+ * OnTime - AnvilPowered
+ * Copyright (C) 2020
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+package org.anvilpowered.ontime.common.command
+
+import org.anvilpowered.anvil.api.Environment
+import org.anvilpowered.anvil.api.command.CommandNode
+import org.anvilpowered.anvil.api.command.CommandService
+import org.anvilpowered.anvil.api.registry.Registry
+import org.anvilpowered.ontime.common.plugin.OnTimePluginInfo
+import java.util.function.Function
+import java.util.function.Predicate
+import javax.inject.Inject
+
+abstract class CommonOnTimeCommandNode protected constructor(
+ protected var registry: Registry
+) : CommandNode {
+ companion object {
+ val ADD_ALIAS = listOf("add", "a")
+ val CHECK_ALIAS = listOf("check", "c", "info", "i")
+ val IMPORT_ALIAS = listOf("import")
+ val SET_BONUS_ALIAS = listOf("setbonus", "sb")
+ val SET_TOTAL_ALIAS = listOf("set", "s", "settotal", "st")
+ val HELP_ALIAS = listOf("help", "h")
+ val VERSION_ALIAS = listOf("version", "v")
+
+ const val ADD_DESCRIPTION = "Add bonus time to a player"
+ const val CHECK_DESCRIPTION = "Check playtime"
+ const val IMPORT_DESCRIPTION = "Import data from rankupper"
+ const val SET_BONUS_DESCRIPTION = "Set bonus playtime"
+ const val SET_TOTAL_DESCRIPTION = "Set total playtime"
+ const val HELP_DESCRIPTION = "Shows this help page."
+ const val VERSION_DESCRIPTION = "Shows the plugin version"
+
+ const val ROOT_DESCRIPTION = "${OnTimePluginInfo.name} root command"
+ const val ADD_USAGE = " "
+ const val CHECK_USAGE = "[]"
+ const val IMPORT_USAGE = ""
+ const val SET_BONUS_USAGE = " "
+ const val SET_TOTAL_USAGE = " "
+ const val HELP_COMMAND = "/ontime help"
+ }
+
+ private var alreadyLoaded: Boolean
+ private var descriptions: MutableMap, Function>
+ private var permissions: Map, Predicate>
+
+ private var usages: MutableMap, Function>
+
+ @Inject
+ protected lateinit var commandService: CommandService
+
+ @Inject
+ protected lateinit var environment: Environment
+
+ init {
+ alreadyLoaded = false
+ registry.whenLoaded {
+ if (alreadyLoaded) return@whenLoaded
+ loadCommands()
+ alreadyLoaded = true
+ }.register()
+ descriptions = mutableMapOf()
+ permissions = mutableMapOf()
+ usages = mutableMapOf()
+ descriptions.put(ADD_ALIAS) { ADD_DESCRIPTION }
+ descriptions.put(CHECK_ALIAS) { CHECK_DESCRIPTION }
+ descriptions.put(IMPORT_ALIAS) { IMPORT_DESCRIPTION }
+ descriptions.put(SET_BONUS_ALIAS) { SET_BONUS_DESCRIPTION }
+ descriptions.put(SET_TOTAL_ALIAS) { SET_TOTAL_DESCRIPTION }
+ descriptions.put(HELP_ALIAS) { HELP_DESCRIPTION }
+ descriptions.put(VERSION_ALIAS) { VERSION_DESCRIPTION }
+ usages.put(ADD_ALIAS) { ADD_USAGE }
+ usages.put(CHECK_ALIAS) { CHECK_USAGE }
+ usages.put(IMPORT_ALIAS) { IMPORT_USAGE }
+ usages.put(SET_BONUS_ALIAS) { SET_BONUS_USAGE }
+ usages.put(SET_TOTAL_ALIAS) { SET_TOTAL_USAGE }
+ }
+
+ protected abstract fun loadCommands()
+ override fun getDescriptions(): Map, Function> = descriptions
+ override fun getPermissions(): Map, Predicate> = permissions
+ override fun getUsages(): Map, Function> = usages
+ override fun getName(): String = OnTimePluginInfo.id
+}
diff --git a/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonOnTimeTwoArgCommand.java b/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonOnTimeTwoArgCommand.java
deleted file mode 100644
index 547c8dc..0000000
--- a/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonOnTimeTwoArgCommand.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * OnTime - AnvilPowered
- * Copyright (C) 2020
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package org.anvilpowered.ontime.common.command;
-
-import com.google.inject.Inject;
-import org.anvilpowered.anvil.api.plugin.PluginInfo;
-import org.anvilpowered.anvil.api.registry.Registry;
-import org.anvilpowered.anvil.api.util.PermissionService;
-import org.anvilpowered.anvil.api.util.TextService;
-import org.anvilpowered.anvil.api.util.UserService;
-import org.anvilpowered.ontime.api.member.MemberManager;
-import org.anvilpowered.ontime.api.registry.OnTimeKeys;
-
-import java.util.UUID;
-import java.util.concurrent.CompletableFuture;
-import java.util.function.BiFunction;
-
-public class CommonOnTimeTwoArgCommand {
-
- @Inject
- protected MemberManager memberManager;
-
- @Inject
- protected PermissionService permissionService;
-
- @Inject
- private PluginInfo pluginInfo;
-
- @Inject
- protected Registry registry;
-
- @Inject
- private TextService textService;
-
- @Inject
- private UserService userService;
-
- public void execute(TCommandSource source, String[] context, String command,
- BiFunction> function) {
- if (!permissionService.hasPermission(source,
- registry.getOrDefault(OnTimeKeys.EDIT_PERMISSION))) {
- textService.builder()
- .append(pluginInfo.getPrefix())
- .red().append("You do not have permission for this command!")
- .sendTo(source);
- return;
- }
- if (context.length != 2) {
- textService.builder()
- .append(pluginInfo.getPrefix())
- .red().append("Not enough arguments!")
- .append("\n", command, " ").appendJoining(" ", context)
- .append("\n^\nUsage: /ontime ", command, " ")
- .sendTo(source);
- return;
- }
- userService.getUUID(context[0]).thenAcceptAsync(userUUID -> {
- if (!userUUID.isPresent()) {
- textService.builder()
- .append(pluginInfo.getPrefix())
- .red().append("No values matching pattern '", context[0], "' present for user!")
- .append("\n", command, " ").appendJoining(" ", context)
- .append("\n").appendCount(command.length() + 1, " ")
- .append("^\nUsage: /ontime ", command, " ")
- .sendTo(source);
- return;
- }
- function.apply(userUUID.get(), context[1])
- .thenAcceptAsync(result -> textService.send(result, source));
- });
- }
-}
diff --git a/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonOnTimeSetBonusCommand.java b/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonSetBonusCommand.kt
similarity index 74%
rename from ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonOnTimeSetBonusCommand.java
rename to ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonSetBonusCommand.kt
index a3d46b9..e6a9545 100644
--- a/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonOnTimeSetBonusCommand.java
+++ b/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonSetBonusCommand.kt
@@ -15,13 +15,11 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
+package org.anvilpowered.ontime.common.command
-package org.anvilpowered.ontime.common.command;
-
-public class CommonOnTimeSetBonusCommand
- extends CommonOnTimeTwoArgCommand {
-
- public void execute(TCommandSource source, String[] context) {
- execute(source, context, "setbonus", memberManager::setBonusTime);
+open class CommonSetBonusCommand
+ : CommonTwoArgCommand() {
+ open fun execute(source: TCommandSource, context: Array) {
+ execute(source, context, "setbonus", memberManager::setBonusTime)
}
}
diff --git a/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonOnTimeSetTotalCommand.java b/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonSetTotalCommand.kt
similarity index 74%
rename from ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonOnTimeSetTotalCommand.java
rename to ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonSetTotalCommand.kt
index 94ac9b5..1bafd4a 100644
--- a/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonOnTimeSetTotalCommand.java
+++ b/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonSetTotalCommand.kt
@@ -15,13 +15,11 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
+package org.anvilpowered.ontime.common.command
-package org.anvilpowered.ontime.common.command;
-
-public class CommonOnTimeSetTotalCommand
- extends CommonOnTimeTwoArgCommand {
-
- public void execute(TCommandSource source, String[] context) {
- execute(source, context, "set", memberManager::setTotalTime);
+open class CommonSetTotalCommand
+ : CommonTwoArgCommand() {
+ open fun execute(source: TCommandSource, context: Array) {
+ execute(source, context, "set", memberManager::setTotalTime)
}
}
diff --git a/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonTwoArgCommand.kt b/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonTwoArgCommand.kt
new file mode 100644
index 0000000..ae8b299
--- /dev/null
+++ b/ontime-common/src/main/java/org/anvilpowered/ontime/common/command/CommonTwoArgCommand.kt
@@ -0,0 +1,110 @@
+/*
+ * OnTime - AnvilPowered
+ * Copyright (C) 2020
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+package org.anvilpowered.ontime.common.command
+
+import com.google.inject.Inject
+import org.anvilpowered.anvil.api.asNullable
+import org.anvilpowered.anvil.api.plugin.PluginInfo
+import org.anvilpowered.anvil.api.registry.Registry
+import org.anvilpowered.anvil.api.util.PermissionService
+import org.anvilpowered.anvil.api.util.TextService
+import org.anvilpowered.anvil.api.util.UserService
+import org.anvilpowered.ontime.api.member.MemberManager
+import org.anvilpowered.ontime.api.plugin.PluginMessages
+import org.anvilpowered.ontime.api.registry.OnTimeKeys
+import java.util.UUID
+import java.util.concurrent.CompletableFuture
+
+open class CommonTwoArgCommand {
+
+ @Inject
+ protected lateinit var memberManager: MemberManager
+
+ @Inject
+ protected lateinit var permissionService: PermissionService
+
+ @Inject
+ private lateinit var pluginInfo: PluginInfo
+
+ @Inject
+ private lateinit var pluginMessages: PluginMessages
+
+ @Inject
+ protected lateinit var registry: Registry
+
+ @Inject
+ private lateinit var textService: TextService
+
+ @Inject
+ private lateinit var userService: UserService
+
+ private fun testPermission(source: Any?): Boolean {
+ return permissionService.hasPermission(source ?: return false, registry.getOrDefault(OnTimeKeys.EDIT_PERMISSION))
+ }
+
+ private fun hasNoPerms(source: TCommandSource): Boolean {
+ if (!testPermission(source)) {
+ textService.send(pluginMessages.noPermission, source)
+ return true
+ }
+ return false
+ }
+
+ fun execute(
+ source: TCommandSource,
+ context: Array,
+ command: String,
+ function: (UUID, String) -> CompletableFuture
+ ) {
+ if (hasNoPerms(source)) return
+ if (context.size < 2) {
+ textService.builder()
+ .append(pluginInfo.prefix)
+ .red().append("Not enough arguments!")
+ .append("\n", command, " ").appendJoining(" ", *context)
+ .append("\n^\nUsage: /ontime ", command, " ")
+ .sendTo(source)
+ return
+ }
+
+ userService.getUUID(context[0]).asNullable().thenAcceptAsync { userUUID: UUID? ->
+ if (userUUID != null) {
+ val sb = StringBuilder()
+ sb.append(context[1])
+ for (i in 2 until context.size) {
+ sb.append(" ").append(context[i])
+ }
+ function(userUUID, sb.toString()).thenAcceptAsync { textService.send(it, source) }
+ return@thenAcceptAsync
+ }
+ textService.builder()
+ .append(pluginInfo.prefix)
+ .red().append("No values matching pattern '", context[0], "' present for user!")
+ .append("\n", command, " ").appendJoining(" ", *context)
+ .append("\n").appendCount(command.length + 1, " ")
+ .append("^\nUsage: /ontime ", command, " ")
+ .sendTo(source)
+ return@thenAcceptAsync
+ }
+ }
+
+ open fun suggest(source: TCommandSource, context: Array): List {
+ if (!testPermission(source)) return listOf()
+ return userService.matchPlayerNames(context, 0, 1)
+ }
+}
diff --git a/ontime-common/src/main/java/org/anvilpowered/ontime/common/module/CommonModule.java b/ontime-common/src/main/java/org/anvilpowered/ontime/common/module/CommonModule.java
index e78b487..4f98771 100644
--- a/ontime-common/src/main/java/org/anvilpowered/ontime/common/module/CommonModule.java
+++ b/ontime-common/src/main/java/org/anvilpowered/ontime/common/module/CommonModule.java
@@ -32,12 +32,14 @@
import org.anvilpowered.anvil.api.registry.Registry;
import org.anvilpowered.ontime.api.member.MemberManager;
import org.anvilpowered.ontime.api.member.MemberRepository;
+import org.anvilpowered.ontime.api.plugin.PluginMessages;
import org.anvilpowered.ontime.api.util.DataImportService;
import org.anvilpowered.ontime.api.util.RankCommandService;
import org.anvilpowered.ontime.common.member.CommonMemberManager;
import org.anvilpowered.ontime.common.member.CommonMongoMemberRepository;
import org.anvilpowered.ontime.common.member.CommonXodusMemberRepository;
import org.anvilpowered.ontime.common.plugin.OnTimePluginInfo;
+import org.anvilpowered.ontime.common.plugin.OnTimePluginMessages;
import org.anvilpowered.ontime.common.registry.CommonConfigurationService;
import org.anvilpowered.ontime.common.registry.CommonRegistry;
import org.anvilpowered.ontime.common.util.CommonDataImportService;
@@ -57,6 +59,10 @@ protected void configure() {
BindingExtensions be = Anvil.getBindingExtensions(binder());
+ be.bind(new TypeToken>(getClass()) {
+ }, new TypeToken>(getClass()) {
+ });
+
be.bind(
new TypeToken>(getClass()) {
},
diff --git a/ontime-spigot/src/main/java/org/anvilpowered/ontime/spigot/command/SpigotOnTimeSetBonusCommand.java b/ontime-common/src/main/java/org/anvilpowered/ontime/common/plugin/OnTimePluginMessages.kt
similarity index 50%
rename from ontime-spigot/src/main/java/org/anvilpowered/ontime/spigot/command/SpigotOnTimeSetBonusCommand.java
rename to ontime-common/src/main/java/org/anvilpowered/ontime/common/plugin/OnTimePluginMessages.kt
index 30d6be3..1695590 100644
--- a/ontime-spigot/src/main/java/org/anvilpowered/ontime/spigot/command/SpigotOnTimeSetBonusCommand.java
+++ b/ontime-common/src/main/java/org/anvilpowered/ontime/common/plugin/OnTimePluginMessages.kt
@@ -16,27 +16,27 @@
* along with this program. If not, see .
*/
-package org.anvilpowered.ontime.spigot.command;
+package org.anvilpowered.ontime.common.plugin
-import net.md_5.bungee.api.chat.TextComponent;
-import org.anvilpowered.ontime.common.command.CommonOnTimeSetBonusCommand;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandExecutor;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
+import com.google.inject.Inject
+import org.anvilpowered.anvil.api.plugin.PluginInfo
+import org.anvilpowered.anvil.api.util.TextService
+import org.anvilpowered.ontime.api.plugin.PluginMessages
-public class SpigotOnTimeSetBonusCommand
- extends CommonOnTimeSetBonusCommand
- implements CommandExecutor {
+class OnTimePluginMessages : PluginMessages {
- @Override
- public boolean onCommand(
- CommandSender source,
- Command command,
- String alias,
- String[] context
- ) {
- execute(source, context);
- return true;
+ @Inject
+ private lateinit var pluginInfo: PluginInfo
+
+ @Inject
+ private lateinit var textService: TextService
+
+ private val noPermissionText: TString by lazy {
+ textService.builder()
+ .append(pluginInfo.prefix)
+ .red().append("You do not have permission for this command!")
+ .build()
}
+
+ override fun getNoPermission(): TString = noPermissionText
}
diff --git a/ontime-spigot/src/main/java/org/anvilpowered/ontime/spigot/command/SpigotOnTimeCommandNode.java b/ontime-spigot/src/main/java/org/anvilpowered/ontime/spigot/command/SpigotOnTimeCommandNode.java
deleted file mode 100644
index 840c18d..0000000
--- a/ontime-spigot/src/main/java/org/anvilpowered/ontime/spigot/command/SpigotOnTimeCommandNode.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * OnTime - AnvilPowered
- * Copyright (C) 2020
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package org.anvilpowered.ontime.spigot.command;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.anvilpowered.anvil.api.registry.Registry;
-import org.anvilpowered.ontime.common.command.CommonOnTimeCommandNode;
-import org.anvilpowered.ontime.common.plugin.OnTimePluginInfo;
-import org.anvilpowered.ontime.spigot.OnTimeSpigot;
-import org.bukkit.command.CommandExecutor;
-import org.bukkit.command.CommandSender;
-import org.bukkit.command.PluginCommand;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-@Singleton
-public class SpigotOnTimeCommandNode
- extends CommonOnTimeCommandNode {
-
- @Inject
- private SpigotOnTimeAddCommand onTimeAddCommand;
-
- @Inject
- private SpigotOnTimeCheckCommand onTimeCheckCommand;
-
- @Inject
- private SpigotOnTimeSetBonusCommand onTimeSetBonusCommand;
-
- @Inject
- private SpigotOnTimeSetTotalCommand onTimeSetTotalCommand;
-
- @Inject
- private OnTimeSpigot plugin;
-
- @Inject
- public SpigotOnTimeCommandNode(Registry registry) {
- super(registry);
- }
-
- @Override
- protected void loadCommands() {
- Map, CommandExecutor> subCommands = new HashMap<>();
-
- subCommands.put(ADD_ALIAS, onTimeAddCommand);
- subCommands.put(CHECK_ALIAS, onTimeCheckCommand);
- subCommands.put(SET_BONUS_ALIAS, onTimeSetBonusCommand);
- subCommands.put(SET_TOTAL_ALIAS, onTimeSetTotalCommand);
- subCommands.put(HELP_ALIAS, commandService.generateHelpCommand(this));
- subCommands.put(VERSION_ALIAS, commandService.generateVersionCommand(HELP_COMMAND));
-
- PluginCommand root = plugin.getCommand(OnTimePluginInfo.id);
- Objects.requireNonNull(root, "OnTime command not registered");
- root.setExecutor(commandService.generateRoutingCommand(
- commandService.generateRootCommand(HELP_COMMAND), subCommands, false));
- }
-}
diff --git a/ontime-spigot/src/main/java/org/anvilpowered/ontime/spigot/command/SpigotOnTimeSetTotalCommand.java b/ontime-spigot/src/main/java/org/anvilpowered/ontime/spigot/command/SpigotOnTimeSetTotalCommand.java
deleted file mode 100644
index 471f09c..0000000
--- a/ontime-spigot/src/main/java/org/anvilpowered/ontime/spigot/command/SpigotOnTimeSetTotalCommand.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * OnTime - AnvilPowered
- * Copyright (C) 2020
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package org.anvilpowered.ontime.spigot.command;
-
-import net.md_5.bungee.api.chat.TextComponent;
-import org.anvilpowered.ontime.common.command.CommonOnTimeSetTotalCommand;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandExecutor;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-public class SpigotOnTimeSetTotalCommand
- extends CommonOnTimeSetTotalCommand
- implements CommandExecutor {
-
- @Override
- public boolean onCommand(
- CommandSender source,
- Command command,
- String alias,
- String[] context
- ) {
- execute(source, context);
- return true;
- }
-}
diff --git a/ontime-spigot/src/main/kotlin/org/anvilpowered/ontime/spigot/command/SpigotAddCommand.kt b/ontime-spigot/src/main/kotlin/org/anvilpowered/ontime/spigot/command/SpigotAddCommand.kt
new file mode 100644
index 0000000..2933cd7
--- /dev/null
+++ b/ontime-spigot/src/main/kotlin/org/anvilpowered/ontime/spigot/command/SpigotAddCommand.kt
@@ -0,0 +1,39 @@
+/*
+ * OnTime - AnvilPowered
+ * Copyright (C) 2020
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+package org.anvilpowered.ontime.spigot.command
+
+import net.md_5.bungee.api.chat.TextComponent
+import org.anvilpowered.ontime.common.command.CommonAddCommand
+import org.bukkit.command.Command
+import org.bukkit.command.CommandSender
+import org.bukkit.command.TabExecutor
+import org.bukkit.entity.Player
+
+class SpigotAddCommand : CommonAddCommand(), TabExecutor {
+ override fun onCommand(source: CommandSender, command: Command, alias: String, context: Array): Boolean {
+ execute(source, context)
+ return true
+ }
+
+ override fun onTabComplete(
+ source: CommandSender,
+ command: Command,
+ alias: String,
+ context: Array
+ ): List = suggest(source, context)
+}
diff --git a/ontime-spigot/src/main/kotlin/org/anvilpowered/ontime/spigot/command/SpigotCheckCommand.kt b/ontime-spigot/src/main/kotlin/org/anvilpowered/ontime/spigot/command/SpigotCheckCommand.kt
new file mode 100644
index 0000000..7b393d5
--- /dev/null
+++ b/ontime-spigot/src/main/kotlin/org/anvilpowered/ontime/spigot/command/SpigotCheckCommand.kt
@@ -0,0 +1,39 @@
+/*
+ * OnTime - AnvilPowered
+ * Copyright (C) 2020
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+package org.anvilpowered.ontime.spigot.command
+
+import net.md_5.bungee.api.chat.TextComponent
+import org.anvilpowered.ontime.common.command.CommonCheckCommand
+import org.bukkit.command.Command
+import org.bukkit.command.CommandSender
+import org.bukkit.command.TabExecutor
+import org.bukkit.entity.Player
+
+class SpigotCheckCommand : CommonCheckCommand(Player::class.java), TabExecutor {
+ override fun onCommand(source: CommandSender, command: Command, alias: String, context: Array): Boolean {
+ execute(source, context)
+ return true
+ }
+
+ override fun onTabComplete(
+ source: CommandSender,
+ command: Command,
+ label: String,
+ context: Array
+ ): List = suggest(source, context)
+}
diff --git a/ontime-spigot/src/main/kotlin/org/anvilpowered/ontime/spigot/command/SpigotOnTimeCommandNode.kt b/ontime-spigot/src/main/kotlin/org/anvilpowered/ontime/spigot/command/SpigotOnTimeCommandNode.kt
new file mode 100644
index 0000000..a22f976
--- /dev/null
+++ b/ontime-spigot/src/main/kotlin/org/anvilpowered/ontime/spigot/command/SpigotOnTimeCommandNode.kt
@@ -0,0 +1,63 @@
+/*
+ * OnTime - AnvilPowered
+ * Copyright (C) 2020
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+package org.anvilpowered.ontime.spigot.command
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.anvilpowered.anvil.api.registry.Registry
+import org.anvilpowered.ontime.common.command.CommonOnTimeCommandNode
+import org.anvilpowered.ontime.common.plugin.OnTimePluginInfo
+import org.anvilpowered.ontime.spigot.OnTimeSpigot
+import org.bukkit.command.CommandExecutor
+import org.bukkit.command.CommandSender
+import java.util.HashMap
+
+@Singleton
+class SpigotOnTimeCommandNode @Inject constructor(
+ registry: Registry
+) : CommonOnTimeCommandNode(registry) {
+ @Inject
+ private lateinit var onTimeAddCommand: SpigotAddCommand
+
+ @Inject
+ private lateinit var onTimeCheckCommand: SpigotCheckCommand
+
+ @Inject
+ private lateinit var onTimeSetBonusCommand: SpigotSetBonusCommand
+
+ @Inject
+ private lateinit var onTimeSetTotalCommand: SpigotSetTotalCommand
+
+ @Inject
+ private lateinit var plugin: OnTimeSpigot
+
+ override fun loadCommands() {
+ val subCommands: MutableMap, CommandExecutor> = HashMap()
+ subCommands[ADD_ALIAS] = onTimeAddCommand
+ subCommands[CHECK_ALIAS] = onTimeCheckCommand
+ subCommands[SET_BONUS_ALIAS] = onTimeSetBonusCommand
+ subCommands[SET_TOTAL_ALIAS] = onTimeSetTotalCommand
+ subCommands[HELP_ALIAS] = commandService.generateHelpCommand(this)
+ subCommands[VERSION_ALIAS] = commandService.generateVersionCommand(HELP_COMMAND)
+ plugin.getCommand(OnTimePluginInfo.id)!!.setExecutor(
+ commandService.generateRoutingCommand(
+ commandService.generateRootCommand(HELP_COMMAND), subCommands, false
+ )
+ )
+ }
+}
diff --git a/ontime-spigot/src/main/kotlin/org/anvilpowered/ontime/spigot/command/SpigotSetBonusCommand.kt b/ontime-spigot/src/main/kotlin/org/anvilpowered/ontime/spigot/command/SpigotSetBonusCommand.kt
new file mode 100644
index 0000000..051f8f0
--- /dev/null
+++ b/ontime-spigot/src/main/kotlin/org/anvilpowered/ontime/spigot/command/SpigotSetBonusCommand.kt
@@ -0,0 +1,39 @@
+/*
+ * OnTime - AnvilPowered
+ * Copyright (C) 2020
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+package org.anvilpowered.ontime.spigot.command
+
+import net.md_5.bungee.api.chat.TextComponent
+import org.anvilpowered.ontime.common.command.CommonSetBonusCommand
+import org.bukkit.command.Command
+import org.bukkit.command.CommandSender
+import org.bukkit.command.TabExecutor
+import org.bukkit.entity.Player
+
+class SpigotSetBonusCommand : CommonSetBonusCommand(), TabExecutor {
+ override fun onCommand(source: CommandSender, command: Command, alias: String, context: Array): Boolean {
+ execute(source, context)
+ return true
+ }
+
+ override fun onTabComplete(
+ source: CommandSender,
+ command: Command,
+ alias: String,
+ context: Array
+ ): List = suggest(source, context)
+}
diff --git a/ontime-spigot/src/main/kotlin/org/anvilpowered/ontime/spigot/command/SpigotSetTotalCommand.kt b/ontime-spigot/src/main/kotlin/org/anvilpowered/ontime/spigot/command/SpigotSetTotalCommand.kt
new file mode 100644
index 0000000..5a50952
--- /dev/null
+++ b/ontime-spigot/src/main/kotlin/org/anvilpowered/ontime/spigot/command/SpigotSetTotalCommand.kt
@@ -0,0 +1,39 @@
+/*
+ * OnTime - AnvilPowered
+ * Copyright (C) 2020
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+package org.anvilpowered.ontime.spigot.command
+
+import net.md_5.bungee.api.chat.TextComponent
+import org.anvilpowered.ontime.common.command.CommonSetTotalCommand
+import org.bukkit.command.Command
+import org.bukkit.command.CommandSender
+import org.bukkit.command.TabExecutor
+import org.bukkit.entity.Player
+
+class SpigotSetTotalCommand : CommonSetTotalCommand(), TabExecutor {
+ override fun onCommand(source: CommandSender, command: Command, alias: String, context: Array): Boolean {
+ execute(source, context)
+ return true
+ }
+
+ override fun onTabComplete(
+ source: CommandSender,
+ command: Command,
+ alias: String,
+ context: Array
+ ): List = suggest(source, context)
+}
diff --git a/ontime-spigot/src/main/resources/plugin.yml b/ontime-spigot/src/main/resources/plugin.yml
index 02a0ecb..c9a34f6 100644
--- a/ontime-spigot/src/main/resources/plugin.yml
+++ b/ontime-spigot/src/main/resources/plugin.yml
@@ -7,4 +7,4 @@ description: Playtime tracker
depend: [Anvil, LuckPerms]
commands:
ontime:
- description: OnTime root command
+ description: OnTime root org.anvilpowered.ontime.spigot.command
diff --git a/ontime-sponge/src/main/java/org/anvilpowered/ontime/sponge/command/SpongeOnTimeAddBonusCommand.java b/ontime-sponge/src/main/java/org/anvilpowered/ontime/sponge/command/SpongeOnTimeAddBonusCommand.java
deleted file mode 100644
index b7fe20b..0000000
--- a/ontime-sponge/src/main/java/org/anvilpowered/ontime/sponge/command/SpongeOnTimeAddBonusCommand.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * OnTime - AnvilPowered
- * Copyright (C) 2020
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package org.anvilpowered.ontime.sponge.command;
-
-import com.google.inject.Inject;
-import org.anvilpowered.ontime.api.member.MemberManager;
-import org.spongepowered.api.command.CommandResult;
-import org.spongepowered.api.command.CommandSource;
-import org.spongepowered.api.command.args.CommandContext;
-import org.spongepowered.api.command.spec.CommandExecutor;
-import org.spongepowered.api.entity.living.player.User;
-import org.spongepowered.api.text.Text;
-
-public class SpongeOnTimeAddBonusCommand implements CommandExecutor {
-
- @Inject
- private MemberManager memberManager;
-
- @Override
- public CommandResult execute(CommandSource source, CommandContext context) {
- memberManager.addBonusTime(
- context.requireOne(Text.of("user")).getUniqueId(),
- context.requireOne(Text.of("time"))
- ).thenAcceptAsync(source::sendMessage);
- return CommandResult.success();
- }
-}
diff --git a/ontime-sponge/src/main/java/org/anvilpowered/ontime/sponge/command/SpongeOnTimeCheckCommand.java b/ontime-sponge/src/main/java/org/anvilpowered/ontime/sponge/command/SpongeOnTimeCheckCommand.java
deleted file mode 100644
index 688e6ba..0000000
--- a/ontime-sponge/src/main/java/org/anvilpowered/ontime/sponge/command/SpongeOnTimeCheckCommand.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * OnTime - AnvilPowered
- * Copyright (C) 2020
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package org.anvilpowered.ontime.sponge.command;
-
-import com.google.inject.Inject;
-import org.anvilpowered.anvil.api.registry.Registry;
-import org.anvilpowered.ontime.api.member.MemberManager;
-import org.anvilpowered.ontime.api.registry.OnTimeKeys;
-import org.anvilpowered.ontime.common.command.CommonOnTimeCheckCommand;
-import org.spongepowered.api.command.CommandResult;
-import org.spongepowered.api.command.CommandSource;
-import org.spongepowered.api.command.args.CommandContext;
-import org.spongepowered.api.command.spec.CommandExecutor;
-import org.spongepowered.api.entity.living.player.Player;
-import org.spongepowered.api.entity.living.player.User;
-import org.spongepowered.api.text.Text;
-
-import java.util.Optional;
-
-public class SpongeOnTimeCheckCommand
- extends CommonOnTimeCheckCommand
- implements CommandExecutor {
-
- @Inject
- private MemberManager memberManager;
-
- @Inject
- private Registry registry;
-
- @Override
- public CommandResult execute(CommandSource source, CommandContext context) {
- Optional optionalUser = context.getOne(Text.of("user"));
- if (optionalUser.isPresent()) {
- memberManager.infoExtended(optionalUser.get().getUniqueId()).thenAcceptAsync(source::sendMessage);
- } else if (source instanceof Player) {
- if (source.hasPermission(registry.getOrDefault(OnTimeKeys.CHECK_EXTENDED_PERMISSION))) {
- memberManager.infoExtended(((Player) source).getUniqueId()).thenAcceptAsync(source::sendMessage);
- } else {
- memberManager.info(((Player) source).getUniqueId()).thenAcceptAsync(source::sendMessage);
- }
- } else {
- sendError(source);
- }
- return CommandResult.success();
- }
-}
diff --git a/ontime-sponge/src/main/java/org/anvilpowered/ontime/sponge/command/SpongeOnTimeCommandNode.java b/ontime-sponge/src/main/java/org/anvilpowered/ontime/sponge/command/SpongeOnTimeCommandNode.java
deleted file mode 100644
index 226e372..0000000
--- a/ontime-sponge/src/main/java/org/anvilpowered/ontime/sponge/command/SpongeOnTimeCommandNode.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * OnTime - AnvilPowered
- * Copyright (C) 2020
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package org.anvilpowered.ontime.sponge.command;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.anvilpowered.anvil.api.registry.Registry;
-import org.anvilpowered.ontime.api.registry.OnTimeKeys;
-import org.anvilpowered.ontime.common.command.CommonOnTimeCommandNode;
-import org.anvilpowered.ontime.common.plugin.OnTimePluginInfo;
-import org.spongepowered.api.Sponge;
-import org.spongepowered.api.command.CommandSource;
-import org.spongepowered.api.command.args.GenericArguments;
-import org.spongepowered.api.command.spec.CommandExecutor;
-import org.spongepowered.api.command.spec.CommandSpec;
-import org.spongepowered.api.text.Text;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-@Singleton
-public class SpongeOnTimeCommandNode
- extends CommonOnTimeCommandNode {
-
- @Inject
- private SpongeOnTimeAddBonusCommand onTimeAddCommand;
-
- @Inject
- private SpongeOnTimeCheckCommand onTimeCheckCommand;
-
- @Inject
- private SpongeOnTimeImportCommand onTimeImportCommand;
-
- @Inject
- private SpongeOnTimeSetBonusCommand onTimeSetBonusCommand;
-
- @Inject
- private SpongeOnTimeSetTotalCommand onTimeSetTotalCommand;
-
- @Inject
- public SpongeOnTimeCommandNode(Registry registry) {
- super(registry);
- }
-
- @Override
- protected void loadCommands() {
- Map, CommandSpec> subCommands = new HashMap<>();
-
- subCommands.put(ADD_ALIAS, CommandSpec.builder()
- .description(Text.of(ADD_DESCRIPTION))
- .permission(registry.getOrDefault(OnTimeKeys.EDIT_PERMISSION))
- .arguments(
- GenericArguments.onlyOne(GenericArguments.user(Text.of("user"))),
- GenericArguments.remainingJoinedStrings(Text.of("time"))
- )
- .executor(onTimeAddCommand)
- .build()
- );
-
- subCommands.put(CHECK_ALIAS, CommandSpec.builder()
- .description(Text.of(CHECK_DESCRIPTION))
- .permission(registry.getOrDefault(OnTimeKeys.CHECK_PERMISSION))
- .arguments(
- GenericArguments.optional(
- GenericArguments.requiringPermission(
- GenericArguments.onlyOne(GenericArguments.user(Text.of("user"))),
- registry.getOrDefault(OnTimeKeys.CHECK_EXTENDED_PERMISSION)
- )
- )
- )
- .executor(onTimeCheckCommand)
- .build()
- );
-
- subCommands.put(IMPORT_ALIAS, CommandSpec.builder()
- .description(Text.of(IMPORT_DESCRIPTION))
- .permission(registry.getOrDefault(OnTimeKeys.IMPORT_PERMISSION))
- .arguments(GenericArguments.remainingJoinedStrings(Text.of("path")))
- .executor(onTimeImportCommand)
- .build());
-
- subCommands.put(SET_BONUS_ALIAS, CommandSpec.builder()
- .description(Text.of(SET_BONUS_DESCRIPTION))
- .permission(registry.getOrDefault(OnTimeKeys.EDIT_PERMISSION))
- .arguments(
- GenericArguments.onlyOne(GenericArguments.user(Text.of("user"))),
- GenericArguments.remainingJoinedStrings(Text.of("time"))
- )
- .executor(onTimeSetBonusCommand)
- .build()
- );
-
- subCommands.put(SET_TOTAL_ALIAS, CommandSpec.builder()
- .description(Text.of(SET_TOTAL_DESCRIPTION))
- .permission(registry.getOrDefault(OnTimeKeys.EDIT_PERMISSION))
- .arguments(
- GenericArguments.onlyOne(GenericArguments.user(Text.of("user"))),
- GenericArguments.remainingJoinedStrings(Text.of("time"))
- )
- .executor(onTimeSetTotalCommand)
- .build()
- );
-
- subCommands.put(HELP_ALIAS, CommandSpec.builder()
- .description(Text.of(HELP_COMMAND))
- .executor(commandService.generateHelpCommand(this))
- .build()
- );
-
- subCommands.put(VERSION_ALIAS, CommandSpec.builder()
- .description(Text.of(VERSION_DESCRIPTION))
- .executor(commandService.generateVersionCommand(HELP_COMMAND))
- .build()
- );
-
- CommandSpec command = CommandSpec.builder()
- .description(Text.of(ROOT_DESCRIPTION))
- .executor(commandService.generateRootCommand(HELP_COMMAND))
- .children(subCommands)
- .build();
-
- Sponge.getCommandManager()
- .register(environment.getPlugin(), command, OnTimePluginInfo.id, "ot");
- }
-}
diff --git a/ontime-sponge/src/main/java/org/anvilpowered/ontime/sponge/command/SpongeOnTimeImportCommand.java b/ontime-sponge/src/main/java/org/anvilpowered/ontime/sponge/command/SpongeOnTimeImportCommand.java
deleted file mode 100644
index babca60..0000000
--- a/ontime-sponge/src/main/java/org/anvilpowered/ontime/sponge/command/SpongeOnTimeImportCommand.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * OnTime - AnvilPowered
- * Copyright (C) 2020
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package org.anvilpowered.ontime.sponge.command;
-
-import com.google.inject.Inject;
-import org.anvilpowered.anvil.api.plugin.PluginInfo;
-import org.anvilpowered.ontime.api.util.DataImportService;
-import org.spongepowered.api.command.CommandException;
-import org.spongepowered.api.command.CommandResult;
-import org.spongepowered.api.command.CommandSource;
-import org.spongepowered.api.command.args.CommandContext;
-import org.spongepowered.api.command.spec.CommandExecutor;
-import org.spongepowered.api.text.Text;
-import org.spongepowered.api.text.format.TextColors;
-
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Optional;
-
-public class SpongeOnTimeImportCommand implements CommandExecutor {
-
- @Inject
- private DataImportService importService;
-
- @Inject
- private PluginInfo pluginInfo;
-
- @Override
- public CommandResult execute(CommandSource source, CommandContext context) throws CommandException {
- Optional optionalPath = context.getOne(Text.of("path"));
- if (optionalPath.isPresent()) {
- String inputPath = optionalPath.get();
- Path path = Paths.get(inputPath);
-
- if (path.toFile().exists()) {
- source.sendMessage(Text.of(pluginInfo.getPrefix(), TextColors.GREEN, "Starting Rankup import!"));
- importService.importData(path);
- } else {
- source.sendMessage(Text.of(pluginInfo.getPrefix(), TextColors.YELLOW, "Could not find the specified file." +
- "\nDid you mean:", TextColors.GOLD, "\"config/rankup/playerstats.conf\" ?"));
- }
- } else {
- throw new CommandException(Text.of("Please specify a path!"));
- }
- return CommandResult.success();
- }
-}
diff --git a/ontime-sponge/src/main/java/org/anvilpowered/ontime/sponge/command/SpongeOnTimeSetBonusCommand.java b/ontime-sponge/src/main/java/org/anvilpowered/ontime/sponge/command/SpongeOnTimeSetBonusCommand.java
deleted file mode 100644
index 8083b18..0000000
--- a/ontime-sponge/src/main/java/org/anvilpowered/ontime/sponge/command/SpongeOnTimeSetBonusCommand.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * OnTime - AnvilPowered
- * Copyright (C) 2020
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package org.anvilpowered.ontime.sponge.command;
-
-import com.google.inject.Inject;
-import org.anvilpowered.ontime.api.member.MemberManager;
-import org.spongepowered.api.command.CommandResult;
-import org.spongepowered.api.command.CommandSource;
-import org.spongepowered.api.command.args.CommandContext;
-import org.spongepowered.api.command.spec.CommandExecutor;
-import org.spongepowered.api.entity.living.player.User;
-import org.spongepowered.api.text.Text;
-
-public class SpongeOnTimeSetBonusCommand implements CommandExecutor {
-
- @Inject
- private MemberManager memberManager;
-
- @Override
- public CommandResult execute(CommandSource source, CommandContext context) {
- memberManager.setBonusTime(
- context.requireOne(Text.of("user")).getUniqueId(),
- context.requireOne(Text.of("time"))
- ).thenAcceptAsync(source::sendMessage);
- return CommandResult.success();
- }
-}
diff --git a/ontime-sponge/src/main/java/org/anvilpowered/ontime/sponge/command/SpongeOnTimeSetTotalCommand.java b/ontime-sponge/src/main/java/org/anvilpowered/ontime/sponge/command/SpongeOnTimeSetTotalCommand.java
deleted file mode 100644
index 1d8d982..0000000
--- a/ontime-sponge/src/main/java/org/anvilpowered/ontime/sponge/command/SpongeOnTimeSetTotalCommand.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * OnTime - AnvilPowered
- * Copyright (C) 2020
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package org.anvilpowered.ontime.sponge.command;
-
-import com.google.inject.Inject;
-import org.anvilpowered.ontime.api.member.MemberManager;
-import org.spongepowered.api.command.CommandResult;
-import org.spongepowered.api.command.CommandSource;
-import org.spongepowered.api.command.args.CommandContext;
-import org.spongepowered.api.command.spec.CommandExecutor;
-import org.spongepowered.api.entity.living.player.User;
-import org.spongepowered.api.text.Text;
-
-public class SpongeOnTimeSetTotalCommand implements CommandExecutor {
-
- @Inject
- private MemberManager memberManager;
-
- @Override
- public CommandResult execute(CommandSource source, CommandContext context) {
- memberManager.setTotalTime(
- context.requireOne(Text.of("user")).getUniqueId(),
- context.requireOne(Text.of("time"))
- ).thenAcceptAsync(source::sendMessage);
- return CommandResult.success();
- }
-}
diff --git a/ontime-sponge/src/main/kotlin/org/anvilpowered/ontime/sponge/command/SpongeAddCommand.kt b/ontime-sponge/src/main/kotlin/org/anvilpowered/ontime/sponge/command/SpongeAddCommand.kt
new file mode 100644
index 0000000..28b7ba9
--- /dev/null
+++ b/ontime-sponge/src/main/kotlin/org/anvilpowered/ontime/sponge/command/SpongeAddCommand.kt
@@ -0,0 +1,57 @@
+/*
+ * OnTime - AnvilPowered
+ * Copyright (C) 2020
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+package org.anvilpowered.ontime.sponge.command
+
+import org.anvilpowered.anvil.api.splitContext
+import org.anvilpowered.ontime.api.registry.OnTimeKeys
+import org.anvilpowered.ontime.common.command.CommonAddCommand
+import org.anvilpowered.ontime.common.command.CommonOnTimeCommandNode
+import org.spongepowered.api.command.CommandCallable
+import org.spongepowered.api.command.CommandResult
+import org.spongepowered.api.command.CommandSource
+import org.spongepowered.api.entity.living.player.Player
+import org.spongepowered.api.entity.living.player.User
+import org.spongepowered.api.text.Text
+import org.spongepowered.api.world.Location
+import org.spongepowered.api.world.World
+import java.util.Optional
+
+class SpongeAddCommand : CommonAddCommand(), CommandCallable {
+
+ companion object {
+ val DESCRIPTION: Optional = Optional.of(Text.of(CommonOnTimeCommandNode.ADD_DESCRIPTION))
+ val USAGE: Text = Text.of(CommonOnTimeCommandNode.ADD_USAGE)
+ }
+
+ override fun process(source: CommandSource, context: String): CommandResult {
+ execute(source, context.splitContext())
+ return CommandResult.success()
+ }
+
+ override fun getSuggestions(source: CommandSource, context: String, targetPosition: Location?): List {
+ return suggest(source, context.splitContext())
+ }
+
+ override fun testPermission(source: CommandSource): Boolean {
+ return source.hasPermission(registry.getOrDefault(OnTimeKeys.EDIT_PERMISSION))
+ }
+
+ override fun getShortDescription(source: CommandSource): Optional = DESCRIPTION
+ override fun getHelp(source: CommandSource): Optional = DESCRIPTION
+ override fun getUsage(source: CommandSource): Text = USAGE
+}
diff --git a/ontime-sponge/src/main/kotlin/org/anvilpowered/ontime/sponge/command/SpongeCheckCommand.kt b/ontime-sponge/src/main/kotlin/org/anvilpowered/ontime/sponge/command/SpongeCheckCommand.kt
new file mode 100644
index 0000000..915ec87
--- /dev/null
+++ b/ontime-sponge/src/main/kotlin/org/anvilpowered/ontime/sponge/command/SpongeCheckCommand.kt
@@ -0,0 +1,57 @@
+/*
+ * OnTime - AnvilPowered
+ * Copyright (C) 2020
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+package org.anvilpowered.ontime.sponge.command
+
+import org.anvilpowered.anvil.api.splitContext
+import org.anvilpowered.ontime.api.registry.OnTimeKeys
+import org.anvilpowered.ontime.common.command.CommonCheckCommand
+import org.anvilpowered.ontime.common.command.CommonOnTimeCommandNode
+import org.spongepowered.api.command.CommandCallable
+import org.spongepowered.api.command.CommandResult
+import org.spongepowered.api.command.CommandSource
+import org.spongepowered.api.entity.living.player.Player
+import org.spongepowered.api.entity.living.player.User
+import org.spongepowered.api.text.Text
+import org.spongepowered.api.world.Location
+import org.spongepowered.api.world.World
+import java.util.Optional
+
+class SpongeCheckCommand : CommonCheckCommand(Player::class.java), CommandCallable {
+
+ companion object {
+ val DESCRIPTION: Optional = Optional.of(Text.of(CommonOnTimeCommandNode.CHECK_DESCRIPTION))
+ val USAGE: Text = Text.of(CommonOnTimeCommandNode.CHECK_USAGE)
+ }
+
+ override fun process(source: CommandSource, context: String): CommandResult {
+ execute(source, context.splitContext())
+ return CommandResult.success()
+ }
+
+ override fun getSuggestions(source: CommandSource, context: String, targetPosition: Location?): List {
+ return suggest(source, context.splitContext())
+ }
+
+ override fun testPermission(source: CommandSource): Boolean {
+ return source.hasPermission(registry.getOrDefault(OnTimeKeys.CHECK_PERMISSION))
+ }
+
+ override fun getShortDescription(source: CommandSource): Optional = DESCRIPTION
+ override fun getHelp(source: CommandSource): Optional = DESCRIPTION
+ override fun getUsage(source: CommandSource): Text = USAGE
+}
diff --git a/ontime-sponge/src/main/kotlin/org/anvilpowered/ontime/sponge/command/SpongeImportCommand.kt b/ontime-sponge/src/main/kotlin/org/anvilpowered/ontime/sponge/command/SpongeImportCommand.kt
new file mode 100644
index 0000000..73eafef
--- /dev/null
+++ b/ontime-sponge/src/main/kotlin/org/anvilpowered/ontime/sponge/command/SpongeImportCommand.kt
@@ -0,0 +1,55 @@
+/*
+ * OnTime - AnvilPowered
+ * Copyright (C) 2020
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+package org.anvilpowered.ontime.sponge.command
+
+import com.google.inject.Inject
+import org.anvilpowered.anvil.api.plugin.PluginInfo
+import org.anvilpowered.ontime.api.util.DataImportService
+import org.spongepowered.api.command.CommandResult
+import org.spongepowered.api.command.CommandSource
+import org.spongepowered.api.command.args.CommandContext
+import org.spongepowered.api.command.spec.CommandExecutor
+import org.spongepowered.api.text.Text
+import org.spongepowered.api.text.format.TextColors
+import java.nio.file.Paths
+
+class SpongeImportCommand : CommandExecutor {
+
+ @Inject
+ private lateinit var importService: DataImportService
+
+ @Inject
+ private lateinit var pluginInfo: PluginInfo
+
+ override fun execute(source: CommandSource, context: CommandContext): CommandResult {
+ val path = Paths.get(context.requireOne(Text.of("path")))
+ if (path.toFile().exists()) {
+ source.sendMessage(Text.of(pluginInfo.prefix, TextColors.GREEN, "Starting Rankup import!"))
+ importService.importData(path)
+ } else {
+ source.sendMessage(
+ Text.of(
+ pluginInfo.prefix, TextColors.YELLOW,
+ "Could not find the specified file.\nDid you mean:", TextColors.GOLD,
+ "\"config/rankup/playerstats.conf\" ?"
+ )
+ )
+ }
+ return CommandResult.success()
+ }
+}
diff --git a/ontime-sponge/src/main/kotlin/org/anvilpowered/ontime/sponge/command/SpongeOnTimeCommandNode.kt b/ontime-sponge/src/main/kotlin/org/anvilpowered/ontime/sponge/command/SpongeOnTimeCommandNode.kt
new file mode 100644
index 0000000..1b4502d
--- /dev/null
+++ b/ontime-sponge/src/main/kotlin/org/anvilpowered/ontime/sponge/command/SpongeOnTimeCommandNode.kt
@@ -0,0 +1,83 @@
+/*
+ * OnTime - AnvilPowered
+ * Copyright (C) 2020
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+package org.anvilpowered.ontime.sponge.command
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.anvilpowered.anvil.api.registry.Registry
+import org.anvilpowered.ontime.api.registry.OnTimeKeys
+import org.anvilpowered.ontime.common.command.CommonOnTimeCommandNode
+import org.anvilpowered.ontime.common.plugin.OnTimePluginInfo
+import org.spongepowered.api.Sponge
+import org.spongepowered.api.command.CommandCallable
+import org.spongepowered.api.command.CommandSource
+import org.spongepowered.api.command.args.GenericArguments
+import org.spongepowered.api.command.spec.CommandExecutor
+import org.spongepowered.api.command.spec.CommandSpec
+import org.spongepowered.api.text.Text
+import java.util.HashMap
+
+@Singleton
+class SpongeOnTimeCommandNode @Inject constructor(
+ registry: Registry
+) : CommonOnTimeCommandNode(registry) {
+
+ @Inject
+ private lateinit var addCommand: SpongeAddCommand
+
+ @Inject
+ private lateinit var onTimeCheckCommand: SpongeCheckCommand
+
+ @Inject
+ private lateinit var importCommand: SpongeImportCommand
+
+ @Inject
+ private lateinit var setBonusCommand: SpongeSetBonusCommand
+
+ @Inject
+ private lateinit var setTotalCommand: SpongeSetTotalCommand
+
+ override fun loadCommands() {
+ val subCommands: MutableMap, CommandCallable> = HashMap()
+ subCommands[ADD_ALIAS] = addCommand
+ subCommands[CHECK_ALIAS] = onTimeCheckCommand
+ subCommands[IMPORT_ALIAS] = CommandSpec.builder()
+ .description(Text.of(IMPORT_DESCRIPTION))
+ .permission(registry.getOrDefault(OnTimeKeys.IMPORT_PERMISSION))
+ .arguments(GenericArguments.remainingJoinedStrings(Text.of("path")))
+ .executor(importCommand)
+ .build()
+ subCommands[SET_BONUS_ALIAS] = setBonusCommand
+ subCommands[SET_TOTAL_ALIAS] = setTotalCommand
+ subCommands[HELP_ALIAS] = CommandSpec.builder()
+ .description(Text.of(HELP_COMMAND))
+ .executor(commandService.generateHelpCommand(this))
+ .build()
+ subCommands[VERSION_ALIAS] = CommandSpec.builder()
+ .description(Text.of(VERSION_DESCRIPTION))
+ .executor(commandService.generateVersionCommand(HELP_COMMAND))
+ .build()
+ val command = CommandSpec.builder()
+ .description(Text.of(ROOT_DESCRIPTION))
+ .executor(commandService.generateRootCommand(HELP_COMMAND))
+ .children(subCommands)
+ .build()
+ Sponge.getCommandManager()
+ .register(environment.plugin, command, OnTimePluginInfo.id, "ot")
+ }
+}
diff --git a/ontime-sponge/src/main/kotlin/org/anvilpowered/ontime/sponge/command/SpongeSetBonusCommand.kt b/ontime-sponge/src/main/kotlin/org/anvilpowered/ontime/sponge/command/SpongeSetBonusCommand.kt
new file mode 100644
index 0000000..8ecb5db
--- /dev/null
+++ b/ontime-sponge/src/main/kotlin/org/anvilpowered/ontime/sponge/command/SpongeSetBonusCommand.kt
@@ -0,0 +1,57 @@
+/*
+ * OnTime - AnvilPowered
+ * Copyright (C) 2020
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+package org.anvilpowered.ontime.sponge.command
+
+import org.anvilpowered.anvil.api.splitContext
+import org.anvilpowered.ontime.api.registry.OnTimeKeys
+import org.anvilpowered.ontime.common.command.CommonOnTimeCommandNode
+import org.anvilpowered.ontime.common.command.CommonSetBonusCommand
+import org.spongepowered.api.command.CommandCallable
+import org.spongepowered.api.command.CommandResult
+import org.spongepowered.api.command.CommandSource
+import org.spongepowered.api.entity.living.player.Player
+import org.spongepowered.api.entity.living.player.User
+import org.spongepowered.api.text.Text
+import org.spongepowered.api.world.Location
+import org.spongepowered.api.world.World
+import java.util.Optional
+
+class SpongeSetBonusCommand : CommonSetBonusCommand(), CommandCallable {
+
+ companion object {
+ val DESCRIPTION: Optional = Optional.of(Text.of(CommonOnTimeCommandNode.ADD_DESCRIPTION))
+ val USAGE: Text = Text.of(CommonOnTimeCommandNode.ADD_USAGE)
+ }
+
+ override fun process(source: CommandSource, context: String): CommandResult {
+ execute(source, context.splitContext())
+ return CommandResult.success()
+ }
+
+ override fun getSuggestions(source: CommandSource, context: String, targetPosition: Location?): List {
+ return suggest(source, context.splitContext())
+ }
+
+ override fun testPermission(source: CommandSource): Boolean {
+ return source.hasPermission(registry.getOrDefault(OnTimeKeys.EDIT_PERMISSION))
+ }
+
+ override fun getShortDescription(source: CommandSource): Optional = DESCRIPTION
+ override fun getHelp(source: CommandSource): Optional = DESCRIPTION
+ override fun getUsage(source: CommandSource): Text = USAGE
+}
diff --git a/ontime-sponge/src/main/kotlin/org/anvilpowered/ontime/sponge/command/SpongeSetTotalCommand.kt b/ontime-sponge/src/main/kotlin/org/anvilpowered/ontime/sponge/command/SpongeSetTotalCommand.kt
new file mode 100644
index 0000000..ffa421b
--- /dev/null
+++ b/ontime-sponge/src/main/kotlin/org/anvilpowered/ontime/sponge/command/SpongeSetTotalCommand.kt
@@ -0,0 +1,57 @@
+/*
+ * OnTime - AnvilPowered
+ * Copyright (C) 2020
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+package org.anvilpowered.ontime.sponge.command
+
+import org.anvilpowered.anvil.api.splitContext
+import org.anvilpowered.ontime.api.registry.OnTimeKeys
+import org.anvilpowered.ontime.common.command.CommonOnTimeCommandNode
+import org.anvilpowered.ontime.common.command.CommonSetTotalCommand
+import org.spongepowered.api.command.CommandCallable
+import org.spongepowered.api.command.CommandResult
+import org.spongepowered.api.command.CommandSource
+import org.spongepowered.api.entity.living.player.Player
+import org.spongepowered.api.entity.living.player.User
+import org.spongepowered.api.text.Text
+import org.spongepowered.api.world.Location
+import org.spongepowered.api.world.World
+import java.util.Optional
+
+class SpongeSetTotalCommand : CommonSetTotalCommand(), CommandCallable {
+
+ companion object {
+ val DESCRIPTION: Optional = Optional.of(Text.of(CommonOnTimeCommandNode.SET_TOTAL_DESCRIPTION))
+ val USAGE: Text = Text.of(CommonOnTimeCommandNode.SET_TOTAL_USAGE)
+ }
+
+ override fun process(source: CommandSource, context: String): CommandResult {
+ execute(source, context.splitContext())
+ return CommandResult.success()
+ }
+
+ override fun getSuggestions(source: CommandSource, context: String, targetPosition: Location?): List {
+ return suggest(source, context.splitContext())
+ }
+
+ override fun testPermission(source: CommandSource): Boolean {
+ return source.hasPermission(registry.getOrDefault(OnTimeKeys.EDIT_PERMISSION))
+ }
+
+ override fun getShortDescription(source: CommandSource): Optional = DESCRIPTION
+ override fun getHelp(source: CommandSource): Optional = DESCRIPTION
+ override fun getUsage(source: CommandSource): Text = USAGE
+}
diff --git a/ontime-velocity/src/main/java/org/anvilpowered/ontime/velocity/command/VelocityOnTimeCheckCommand.java b/ontime-velocity/src/main/java/org/anvilpowered/ontime/velocity/command/VelocityOnTimeCheckCommand.java
deleted file mode 100644
index c938f52..0000000
--- a/ontime-velocity/src/main/java/org/anvilpowered/ontime/velocity/command/VelocityOnTimeCheckCommand.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * OnTime - AnvilPowered
- * Copyright (C) 2020
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package org.anvilpowered.ontime.velocity.command;
-
-import com.velocitypowered.api.command.Command;
-import com.velocitypowered.api.command.CommandSource;
-import com.velocitypowered.api.proxy.Player;
-import net.kyori.adventure.text.TextComponent;
-import org.anvilpowered.ontime.common.command.CommonOnTimeCheckCommand;
-
-public class VelocityOnTimeCheckCommand
- extends CommonOnTimeCheckCommand
- implements Command {
-
- @Override
- public void execute(CommandSource source, String[] context) {
- execute(source, context, Player.class);
- }
-}
diff --git a/ontime-velocity/src/main/java/org/anvilpowered/ontime/velocity/command/VelocityOnTimeCommandNode.java b/ontime-velocity/src/main/java/org/anvilpowered/ontime/velocity/command/VelocityOnTimeCommandNode.java
deleted file mode 100644
index ca023e2..0000000
--- a/ontime-velocity/src/main/java/org/anvilpowered/ontime/velocity/command/VelocityOnTimeCommandNode.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * OnTime - AnvilPowered
- * Copyright (C) 2020
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package org.anvilpowered.ontime.velocity.command;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.velocitypowered.api.command.Command;
-import com.velocitypowered.api.command.CommandSource;
-import com.velocitypowered.api.proxy.ProxyServer;
-import org.anvilpowered.anvil.api.registry.Registry;
-import org.anvilpowered.ontime.common.command.CommonOnTimeCommandNode;
-import org.anvilpowered.ontime.common.plugin.OnTimePluginInfo;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-@Singleton
-public class VelocityOnTimeCommandNode
- extends CommonOnTimeCommandNode {
-
- @Inject
- private ProxyServer proxyServer;
-
- @Inject
- private VelocityOnTimeAddCommand onTimeAddCommand;
-
- @Inject
- private VelocityOnTimeCheckCommand onTimeCheckCommand;
-
- @Inject
- private VelocityOnTimeSetBonusCommand onTimeSetBonusCommand;
-
- @Inject
- private VelocityOnTimeSetTotalCommand onTimeSetTotalCommand;
-
- @Inject
- public VelocityOnTimeCommandNode(Registry registry) {
- super(registry);
- }
-
- @Override
- protected void loadCommands() {
- Map, Command> subCommands = new HashMap<>();
-
- subCommands.put(ADD_ALIAS, onTimeAddCommand);
- subCommands.put(CHECK_ALIAS, onTimeCheckCommand);
- subCommands.put(SET_BONUS_ALIAS, onTimeSetBonusCommand);
- subCommands.put(SET_TOTAL_ALIAS, onTimeSetTotalCommand);
- subCommands.put(HELP_ALIAS, commandService.generateHelpCommand(this));
- subCommands.put(VERSION_ALIAS, commandService.generateVersionCommand(HELP_COMMAND));
-
- proxyServer.getCommandManager().register(OnTimePluginInfo.id,
- commandService.generateRoutingCommand(
- commandService.generateRootCommand(HELP_COMMAND), subCommands, false),
- "ot");
- }
-}
diff --git a/ontime-velocity/src/main/java/org/anvilpowered/ontime/velocity/command/VelocityOnTimeSetBonusCommand.java b/ontime-velocity/src/main/java/org/anvilpowered/ontime/velocity/command/VelocityOnTimeSetBonusCommand.java
deleted file mode 100644
index 2e61ee6..0000000
--- a/ontime-velocity/src/main/java/org/anvilpowered/ontime/velocity/command/VelocityOnTimeSetBonusCommand.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * OnTime - AnvilPowered
- * Copyright (C) 2020
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package org.anvilpowered.ontime.velocity.command;
-
-import com.velocitypowered.api.command.Command;
-import com.velocitypowered.api.command.CommandSource;
-import com.velocitypowered.api.proxy.Player;
-import net.kyori.adventure.text.TextComponent;
-import org.anvilpowered.ontime.common.command.CommonOnTimeSetBonusCommand;
-
-public class VelocityOnTimeSetBonusCommand
- extends CommonOnTimeSetBonusCommand
- implements Command {
-}
diff --git a/ontime-velocity/src/main/java/org/anvilpowered/ontime/velocity/command/VelocityOnTimeSetTotalCommand.java b/ontime-velocity/src/main/java/org/anvilpowered/ontime/velocity/command/VelocityOnTimeSetTotalCommand.java
deleted file mode 100644
index 952a5f6..0000000
--- a/ontime-velocity/src/main/java/org/anvilpowered/ontime/velocity/command/VelocityOnTimeSetTotalCommand.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * OnTime - AnvilPowered
- * Copyright (C) 2020
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package org.anvilpowered.ontime.velocity.command;
-
-import com.velocitypowered.api.command.Command;
-import com.velocitypowered.api.command.CommandSource;
-import com.velocitypowered.api.proxy.Player;
-import net.kyori.adventure.text.TextComponent;
-import org.anvilpowered.ontime.common.command.CommonOnTimeSetTotalCommand;
-
-public class VelocityOnTimeSetTotalCommand
- extends CommonOnTimeSetTotalCommand
- implements Command {
-}
diff --git a/ontime-velocity/src/main/kotlin/org/anvilpowered/ontime/velocity/command/VelocityAddCommand.kt b/ontime-velocity/src/main/kotlin/org/anvilpowered/ontime/velocity/command/VelocityAddCommand.kt
new file mode 100644
index 0000000..5f95ea0
--- /dev/null
+++ b/ontime-velocity/src/main/kotlin/org/anvilpowered/ontime/velocity/command/VelocityAddCommand.kt
@@ -0,0 +1,32 @@
+/*
+ * OnTime - AnvilPowered
+ * Copyright (C) 2020
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+package org.anvilpowered.ontime.velocity.command
+
+import com.velocitypowered.api.command.Command
+import com.velocitypowered.api.command.CommandSource
+import com.velocitypowered.api.proxy.Player
+import net.kyori.adventure.text.TextComponent
+import org.anvilpowered.ontime.common.command.CommonAddCommand
+
+class VelocityAddCommand : CommonAddCommand(), Command {
+ override fun execute(source: CommandSource, context: Array) =
+ super.execute(source, context)
+
+ override fun suggest(source: CommandSource, context: Array): List =
+ super.suggest(source, context)
+}
diff --git a/ontime-spigot/src/main/java/org/anvilpowered/ontime/spigot/command/SpigotOnTimeCheckCommand.java b/ontime-velocity/src/main/kotlin/org/anvilpowered/ontime/velocity/command/VelocityCheckCommand.kt
similarity index 52%
rename from ontime-spigot/src/main/java/org/anvilpowered/ontime/spigot/command/SpigotOnTimeCheckCommand.java
rename to ontime-velocity/src/main/kotlin/org/anvilpowered/ontime/velocity/command/VelocityCheckCommand.kt
index ac213c2..3b423d8 100644
--- a/ontime-spigot/src/main/java/org/anvilpowered/ontime/spigot/command/SpigotOnTimeCheckCommand.java
+++ b/ontime-velocity/src/main/kotlin/org/anvilpowered/ontime/velocity/command/VelocityCheckCommand.kt
@@ -15,28 +15,18 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
+package org.anvilpowered.ontime.velocity.command
-package org.anvilpowered.ontime.spigot.command;
+import com.velocitypowered.api.command.Command
+import com.velocitypowered.api.command.CommandSource
+import com.velocitypowered.api.proxy.Player
+import net.kyori.adventure.text.TextComponent
+import org.anvilpowered.ontime.common.command.CommonCheckCommand
-import net.md_5.bungee.api.chat.TextComponent;
-import org.anvilpowered.ontime.common.command.CommonOnTimeCheckCommand;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandExecutor;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
+class VelocityCheckCommand : CommonCheckCommand(Player::class.java), Command {
+ override fun execute(source: CommandSource, context: Array) =
+ super.execute(source, context)
-public class SpigotOnTimeCheckCommand
- extends CommonOnTimeCheckCommand
- implements CommandExecutor {
-
- @Override
- public boolean onCommand(
- CommandSender source,
- Command command,
- String alias,
- String[] context
- ) {
- execute(source, context, Player.class);
- return true;
- }
+ override fun suggest(source: CommandSource, context: Array): List =
+ super.suggest(source, context)
}
diff --git a/ontime-velocity/src/main/kotlin/org/anvilpowered/ontime/velocity/command/VelocityOnTimeCommandNode.kt b/ontime-velocity/src/main/kotlin/org/anvilpowered/ontime/velocity/command/VelocityOnTimeCommandNode.kt
new file mode 100644
index 0000000..3eedfc2
--- /dev/null
+++ b/ontime-velocity/src/main/kotlin/org/anvilpowered/ontime/velocity/command/VelocityOnTimeCommandNode.kt
@@ -0,0 +1,63 @@
+/*
+ * OnTime - AnvilPowered
+ * Copyright (C) 2020
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+package org.anvilpowered.ontime.velocity.command
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import com.velocitypowered.api.command.Command
+import com.velocitypowered.api.command.CommandSource
+import com.velocitypowered.api.proxy.ProxyServer
+import org.anvilpowered.anvil.api.registry.Registry
+import org.anvilpowered.ontime.common.command.CommonOnTimeCommandNode
+import org.anvilpowered.ontime.common.plugin.OnTimePluginInfo
+
+@Singleton
+class VelocityOnTimeCommandNode @Inject constructor(
+ registry: Registry
+) : CommonOnTimeCommandNode(registry) {
+ @Inject
+ private lateinit var proxyServer: ProxyServer
+
+ @Inject
+ private lateinit var onTimeAddCommand: VelocityAddCommand
+
+ @Inject
+ private lateinit var onTimeCheckCommand: VelocityCheckCommand
+
+ @Inject
+ private lateinit var onTimeSetBonusCommand: VelocitySetBonusCommand
+
+ @Inject
+ private lateinit var onTimeSetTotalCommand: VelocitySetTotalCommand
+
+ override fun loadCommands() {
+ val subCommands: MutableMap, Command> = mutableMapOf()
+ subCommands[ADD_ALIAS] = onTimeAddCommand
+ subCommands[CHECK_ALIAS] = onTimeCheckCommand
+ subCommands[SET_BONUS_ALIAS] = onTimeSetBonusCommand
+ subCommands[SET_TOTAL_ALIAS] = onTimeSetTotalCommand
+ subCommands[HELP_ALIAS] = commandService.generateHelpCommand(this)
+ subCommands[VERSION_ALIAS] = commandService.generateVersionCommand(HELP_COMMAND)
+ proxyServer.commandManager.register(
+ proxyServer.commandManager.metaBuilder(OnTimePluginInfo.id).aliases("ot").build(),
+ commandService.generateRoutingCommand(
+ commandService.generateRootCommand(HELP_COMMAND), subCommands, false
+ )
+ )
+ }
+}
diff --git a/ontime-spigot/src/main/java/org/anvilpowered/ontime/spigot/command/SpigotOnTimeAddCommand.java b/ontime-velocity/src/main/kotlin/org/anvilpowered/ontime/velocity/command/VelocitySetBonusCommand.kt
similarity index 52%
rename from ontime-spigot/src/main/java/org/anvilpowered/ontime/spigot/command/SpigotOnTimeAddCommand.java
rename to ontime-velocity/src/main/kotlin/org/anvilpowered/ontime/velocity/command/VelocitySetBonusCommand.kt
index ef7bcac..a5ddac6 100644
--- a/ontime-spigot/src/main/java/org/anvilpowered/ontime/spigot/command/SpigotOnTimeAddCommand.java
+++ b/ontime-velocity/src/main/kotlin/org/anvilpowered/ontime/velocity/command/VelocitySetBonusCommand.kt
@@ -15,28 +15,18 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
+package org.anvilpowered.ontime.velocity.command
-package org.anvilpowered.ontime.spigot.command;
+import com.velocitypowered.api.command.Command
+import com.velocitypowered.api.command.CommandSource
+import com.velocitypowered.api.proxy.Player
+import net.kyori.adventure.text.TextComponent
+import org.anvilpowered.ontime.common.command.CommonSetBonusCommand
-import net.md_5.bungee.api.chat.TextComponent;
-import org.anvilpowered.ontime.common.command.CommonOnTimeAddCommand;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandExecutor;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
+class VelocitySetBonusCommand : CommonSetBonusCommand(), Command {
+ override fun execute(source: CommandSource, context: Array) =
+ super.execute(source, context)
-public class SpigotOnTimeAddCommand
- extends CommonOnTimeAddCommand
- implements CommandExecutor {
-
- @Override
- public boolean onCommand(
- CommandSender source,
- Command command,
- String alias,
- String[] context
- ) {
- execute(source, context);
- return true;
- }
+ override fun suggest(source: CommandSource, context: Array): List =
+ super.suggest(source, context)
}
diff --git a/ontime-velocity/src/main/kotlin/org/anvilpowered/ontime/velocity/command/VelocitySetTotalCommand.kt b/ontime-velocity/src/main/kotlin/org/anvilpowered/ontime/velocity/command/VelocitySetTotalCommand.kt
new file mode 100644
index 0000000..71fd453
--- /dev/null
+++ b/ontime-velocity/src/main/kotlin/org/anvilpowered/ontime/velocity/command/VelocitySetTotalCommand.kt
@@ -0,0 +1,32 @@
+/*
+ * OnTime - AnvilPowered
+ * Copyright (C) 2020
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see .
+ */
+package org.anvilpowered.ontime.velocity.command
+
+import com.velocitypowered.api.command.Command
+import com.velocitypowered.api.command.CommandSource
+import com.velocitypowered.api.proxy.Player
+import net.kyori.adventure.text.TextComponent
+import org.anvilpowered.ontime.common.command.CommonSetTotalCommand
+
+class VelocitySetTotalCommand : CommonSetTotalCommand(), Command {
+ override fun execute(source: CommandSource, context: Array) =
+ super.execute(source, context)
+
+ override fun suggest(source: CommandSource, context: Array): List =
+ super.suggest(source, context)
+}