Merge commit '2af8c8dbf2d5eb16d7492fd12b4b786d6205d0f9' as 'lib'

This commit is contained in:
Charlie
2014-07-31 11:37:54 -04:00
46 changed files with 3570 additions and 0 deletions

58
lib/bungee/pom.xml Normal file
View File

@@ -0,0 +1,58 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.sk89q</groupId>
<artifactId>command-framework-parent</artifactId>
<version>0.5-SNAPSHOT</version>
</parent>
<artifactId>command-framework-bungee</artifactId>
<packaging>jar</packaging>
<version>0.5-SNAPSHOT</version>
<name>Sk89q Command Framework for BungeeCord</name>
<description>Supporting classes for using the command framework on BungeeCord.</description>
<repositories>
<repository>
<id>sonatype-public</id>
<url>https://oss.sonatype.org/content/groups/public</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>command-framework-core</artifactId>
<version>0.5-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.5-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<configuration>
<artifactSet>
<includes>
<include>com.sk89q:command-framework-core</include>
</includes>
</artifactSet>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,12 @@
package com.sk89q.bungee.util;
import net.md_5.bungee.api.CommandSender;
import com.sk89q.minecraft.util.commands.CommandsManager;
public class BungeeCommandsManager extends CommandsManager<CommandSender> {
@Override
public boolean hasPermission(CommandSender player, String perm) {
return player.hasPermission(perm);
}
}

View File

@@ -0,0 +1,47 @@
package com.sk89q.bungee.util;
import net.md_5.bungee.api.CommandSender;
import com.sk89q.minecraft.util.commands.WrappedCommandSender;
public class BungeeWrappedCommandSender implements WrappedCommandSender {
public BungeeWrappedCommandSender(CommandSender wrapped) {
this.wrapped = wrapped;
}
@Override
public String getName() {
return this.wrapped.getName();
}
@Override
public void sendMessage(String message) {
this.wrapped.sendMessage(message);
}
@Override
public void sendMessage(String[] messages) {
this.wrapped.sendMessages(messages);
}
@Override
public boolean hasPermission(String permission) {
return this.wrapped.hasPermission(permission);
}
@Override
public Type getType() {
if (this.wrapped.getName().equals("CONSOLE")) { // hack because Bungee does not export ConsoleCommandSender
return Type.CONSOLE;
} else {
return Type.PLAYER;
}
}
@Override
public Object getCommandSender() {
return this.wrapped;
}
private final CommandSender wrapped;
}

View File

@@ -0,0 +1,6 @@
package com.sk89q.bungee.util;
public interface CommandExecutor<T> {
void onCommand(T sender, String commandName, String[] args);
}

View File

@@ -0,0 +1,36 @@
package com.sk89q.bungee.util;
import java.util.List;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.api.plugin.PluginManager;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandsManager;
public class CommandRegistration {
public CommandRegistration(Plugin plugin, PluginManager pluginManager, CommandsManager<?> commands, CommandExecutor<CommandSender> executor) {
this.plugin = plugin;
this.pluginManager = pluginManager;
this.commands = commands;
this.executor = executor;
}
public boolean register(Class<?> clazz) {
return this.registerAll(this.commands.registerAndReturn(clazz));
}
public boolean registerAll(List<Command> registered) {
for(Command command : registered) {
CommandWrapper wrapper = new CommandWrapper(this.executor, command.aliases()[0], command.aliases());
this.pluginManager.registerCommand(this.plugin, wrapper);
}
return true;
}
private final Plugin plugin;
private final PluginManager pluginManager;
private final CommandsManager<?> commands;
private final CommandExecutor<CommandSender> executor;
}

View File

@@ -0,0 +1,18 @@
package com.sk89q.bungee.util;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.plugin.Command;
public class CommandWrapper extends Command {
public CommandWrapper(CommandExecutor<CommandSender> executor, String commandName, String... aliases) {
super(commandName, null, aliases);
this.executor = executor;
}
@Override
public void execute(CommandSender sender, String[] args) {
this.executor.onCommand(sender, this.getName(), args);
}
private final CommandExecutor<CommandSender> executor;
}