Add Bungee implementation

This commit is contained in:
Alexander Söderberg 2020-09-19 00:21:27 +02:00
parent 04a6919c6a
commit 1a85251fc6
No known key found for this signature in database
GPG key ID: C0207FF7EA146678
29 changed files with 420 additions and 57 deletions

View file

@ -21,8 +21,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
package com.intellectualsites.commands;
package com.intellectualsites.commands.bukkit;
import com.intellectualsites.commands.Command;
import com.intellectualsites.commands.arguments.CommandArgument;
import com.intellectualsites.commands.arguments.StaticArgument;
import com.intellectualsites.commands.exceptions.ArgumentParseException;
@ -36,9 +37,7 @@ import org.bukkit.command.PluginIdentifiableCommand;
import org.bukkit.plugin.Plugin;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import java.util.function.Consumer;
final class BukkitCommand<C> extends org.bukkit.command.Command implements PluginIdentifiableCommand {
@ -49,10 +48,10 @@ final class BukkitCommand<C> extends org.bukkit.command.Command implements Plugi
private final CommandArgument<C, ?> command;
private final BukkitCommandManager<C> bukkitCommandManager;
private final com.intellectualsites.commands.Command<C, BukkitCommandMeta> cloudCommand;
private final Command<C, BukkitCommandMeta> cloudCommand;
@SuppressWarnings("unchecked")
BukkitCommand(@Nonnull final com.intellectualsites.commands.Command<C, BukkitCommandMeta> cloudCommand,
BukkitCommand(@Nonnull final Command<C, BukkitCommandMeta> cloudCommand,
@Nonnull final CommandArgument<C, ?> command,
@Nonnull final BukkitCommandManager<C> bukkitCommandManager) {
super(command.getName(),
@ -88,7 +87,7 @@ final class BukkitCommand<C> extends org.bukkit.command.Command implements Plugi
commandSender.sendMessage(MESSAGE_UNKNOWN_COMMAND);
} else if (throwable instanceof ArgumentParseException) {
commandSender.sendMessage(ChatColor.RED + "Invalid Command Argument: "
+ ChatColor.GRAY + throwable.getCause().getMessage());
+ ChatColor.GRAY + throwable.getCause().getMessage());
} else {
commandSender.sendMessage(throwable.getMessage());
throwable.printStackTrace();
@ -124,25 +123,4 @@ final class BukkitCommand<C> extends org.bukkit.command.Command implements Plugi
return this.cloudCommand.getCommandPermission();
}
@Nullable
private <E extends Throwable> E captureException(@Nonnull final Class<E> clazz, @Nullable final Throwable throwable) {
if (throwable == null) {
return null;
}
if (clazz.equals(throwable.getClass())) {
//noinspection unchecked
return (E) throwable;
}
return captureException(clazz, throwable.getCause());
}
private <E extends Throwable> boolean handleException(@Nullable final E throwable,
@Nonnull final Consumer<E> consumer) {
if (throwable == null) {
return false;
}
consumer.accept(throwable);
return true;
}
}

View file

@ -21,12 +21,14 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
package com.intellectualsites.commands;
package com.intellectualsites.commands.bukkit;
import com.google.common.reflect.TypeToken;
import com.intellectualsites.commands.CommandManager;
import com.intellectualsites.commands.CommandTree;
import com.intellectualsites.commands.bukkit.parsers.MaterialArgument;
import com.intellectualsites.commands.bukkit.parsers.WorldArgument;
import com.intellectualsites.commands.execution.CommandExecutionCoordinator;
import com.intellectualsites.commands.parsers.MaterialArgument;
import com.intellectualsites.commands.parsers.WorldArgument;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
@ -97,8 +99,13 @@ public class BukkitCommandManager<C>
return BukkitCommandMetaBuilder.builder().withDescription("").build();
}
/**
* Get the command sender mapper
*
* @return Command sender mapper
*/
@Nonnull
final Function<CommandSender, C> getCommandSenderMapper() {
public final Function<CommandSender, C> getCommandSenderMapper() {
return this.commandSenderMapper;
}

View file

@ -21,7 +21,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
package com.intellectualsites.commands;
package com.intellectualsites.commands.bukkit;
import com.intellectualsites.commands.meta.SimpleCommandMeta;

View file

@ -21,7 +21,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
package com.intellectualsites.commands;
package com.intellectualsites.commands.bukkit;
import com.intellectualsites.commands.meta.CommandMeta;

View file

@ -21,7 +21,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
package com.intellectualsites.commands;
package com.intellectualsites.commands.bukkit;
import com.google.common.base.Objects;
import org.bukkit.entity.Player;

View file

@ -21,7 +21,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
package com.intellectualsites.commands;
package com.intellectualsites.commands.bukkit;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

View file

@ -21,7 +21,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
package com.intellectualsites.commands;
package com.intellectualsites.commands.bukkit;
import org.bukkit.entity.Player;

View file

@ -21,8 +21,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
package com.intellectualsites.commands;
package com.intellectualsites.commands.bukkit;
import com.intellectualsites.commands.Command;
import com.intellectualsites.commands.arguments.CommandArgument;
import com.intellectualsites.commands.internal.CommandRegistrationHandler;
import org.bukkit.Bukkit;

View file

@ -25,4 +25,4 @@
/**
* cloud implementation for Bukkit 1.8-1.16
*/
package com.intellectualsites.commands;
package com.intellectualsites.commands.bukkit;

View file

@ -21,7 +21,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
package com.intellectualsites.commands.parsers;
package com.intellectualsites.commands.bukkit.parsers;
import com.intellectualsites.commands.arguments.CommandArgument;
import com.intellectualsites.commands.arguments.parser.ArgumentParseResult;

View file

@ -21,7 +21,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
package com.intellectualsites.commands.parsers;
package com.intellectualsites.commands.bukkit.parsers;
import com.intellectualsites.commands.arguments.CommandArgument;
import com.intellectualsites.commands.arguments.parser.ArgumentParseResult;

View file

@ -25,4 +25,4 @@
/**
* Bukkit specific command arguments
*/
package com.intellectualsites.commands.parsers;
package com.intellectualsites.commands.bukkit.parsers;