-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2dbcfb4
commit 1dc0697
Showing
37 changed files
with
2,567 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package de.buddelbubi.commands; | ||
|
||
import cn.nukkit.Server; | ||
import cn.nukkit.command.Command; | ||
import cn.nukkit.command.CommandSender; | ||
import cn.nukkit.command.data.CommandParamType; | ||
import cn.nukkit.command.data.CommandParameter; | ||
|
||
public class AliasManager extends Command { | ||
|
||
public AliasManager(String name) { | ||
super(name); | ||
} | ||
|
||
@Override | ||
public boolean execute(CommandSender arg0, String arg1, String[] arg2) { | ||
|
||
String args = ""; | ||
for(String s : arg2) args = args + " " + s; | ||
|
||
if(arg1.toLowerCase().matches("world|mvtp|unitp|wmtp|lmtp")) { | ||
Server.getInstance().dispatchCommand(arg0, "wm tp" + args); | ||
} else if(arg1.toLowerCase().matches("mvimport|mvload|uniload|mvimport")) { | ||
Server.getInstance().dispatchCommand(arg0, "wm load" + args); | ||
} else if(arg1.equalsIgnoreCase("mvedit")){ | ||
Server.getInstance().dispatchCommand(arg0, "wm gamerule" + args); | ||
} else if(arg1.equalsIgnoreCase("worlds")) { | ||
Server.getInstance().dispatchCommand(arg0, "wm list"); | ||
} | ||
return true; | ||
} | ||
|
||
public static void registerAliases() { | ||
|
||
Command world = new AliasManager("world"); | ||
world.setDescription("Teleport to a different world."); | ||
world.addCommandParameters("world", new CommandParameter[] {CommandParameter.newType("world", true, CommandParamType.STRING)}); | ||
Command worlds = new AliasManager("worlds"); | ||
worlds.setDescription("Shows you a list of all worlds."); | ||
Command load = new AliasManager("mvimport"); | ||
load.setDescription("Lets you load a unloaded world."); | ||
load.addCommandParameters("world", new CommandParameter[] {CommandParameter.newType("world", false, CommandParamType.STRING)}); | ||
Command edit = new AliasManager("mvedit"); | ||
edit.setDescription("Opens the WorldManager Settings Menu"); | ||
edit.addCommandParameters("world", new CommandParameter[] {CommandParameter.newType("world", true, CommandParamType.STRING)}); | ||
|
||
load.setAliases(new String[] { | ||
"mvload", "uniload", "mvimport" | ||
}); | ||
world.setAliases(new String[] { | ||
"mvtp", "unitp", "wmtp", "mwtp", "lmtp" | ||
}); | ||
|
||
for(Command c : new Command[] {world, worlds, load, edit}) { | ||
Server.getInstance().getCommandMap().register(c.getName(), c); | ||
} | ||
|
||
} | ||
|
||
} |
107 changes: 107 additions & 0 deletions
107
Sourcecode/src/de/buddelbubi/commands/CommandMapping.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package de.buddelbubi.commands; | ||
|
||
import java.util.ArrayList; | ||
|
||
import java.util.Arrays; | ||
import cn.nukkit.Server; | ||
import cn.nukkit.command.Command; | ||
import cn.nukkit.command.CommandSender; | ||
import de.buddelbubi.WorldManager; | ||
import de.buddelbubi.commands.subcommand.AddonCommand; | ||
import de.buddelbubi.commands.subcommand.ClearlagCommand; | ||
import de.buddelbubi.commands.subcommand.CopyCommand; | ||
import de.buddelbubi.commands.subcommand.DeleteCommand; | ||
import de.buddelbubi.commands.subcommand.GameruleCommand; | ||
import de.buddelbubi.commands.subcommand.GenerateCommand; | ||
import de.buddelbubi.commands.subcommand.HelpCommand; | ||
import de.buddelbubi.commands.subcommand.InfoCommand; | ||
import de.buddelbubi.commands.subcommand.LoadCommand; | ||
import de.buddelbubi.commands.subcommand.ListCommand; | ||
import de.buddelbubi.commands.subcommand.RegenerateCommand; | ||
import de.buddelbubi.commands.subcommand.ReloadCommand; | ||
import de.buddelbubi.commands.subcommand.RenameCommand; | ||
import de.buddelbubi.commands.subcommand.SaveCommand; | ||
import de.buddelbubi.commands.subcommand.SetdefaultCommand; | ||
import de.buddelbubi.commands.subcommand.SetseedCommand; | ||
import de.buddelbubi.commands.subcommand.SetspawnCommand; | ||
import de.buddelbubi.commands.subcommand.SettingsCommand; | ||
import de.buddelbubi.commands.subcommand.SpawnCommand; | ||
import de.buddelbubi.commands.subcommand.StatusCommand; | ||
import de.buddelbubi.commands.subcommand.SubCommand; | ||
import de.buddelbubi.commands.subcommand.SyncCommand; | ||
import de.buddelbubi.commands.subcommand.TeleportCommand; | ||
import de.buddelbubi.commands.subcommand.UnloadCommand; | ||
import de.buddelbubi.commands.subcommand.VersionCommand; | ||
|
||
public class CommandMapping extends Command { | ||
|
||
private ArrayList<SubCommand> subcommands = new ArrayList<>(); | ||
|
||
public CommandMapping() { | ||
super("worldmanager"); | ||
this.setAliases(new String[] {"wm", "mw", "mv", "levelmanager", "lm"}); | ||
this.setDescription("The main WorldManager Command"); | ||
this.commandParameters.clear(); | ||
} | ||
|
||
@Override | ||
public boolean execute(CommandSender sender, String arg1, String[] args) { | ||
|
||
if(args.length > 0) { | ||
|
||
String name = args[0].toLowerCase(); | ||
|
||
for(SubCommand command : subcommands) { | ||
|
||
if(Arrays.asList(command.getAliases()).contains(name)) { | ||
command.execute(sender, arg1, args); | ||
return true; | ||
} | ||
|
||
} | ||
|
||
} | ||
sender.sendMessage(WorldManager.prefix + "§cUnknown Command. Use '/worldmanager help' to get a list of commands."); | ||
|
||
return true; | ||
} | ||
|
||
public void registerSubCommand(SubCommand subcommand) { | ||
subcommands.add(subcommand); | ||
addCommandParameters(subcommand.getName(), subcommand.getParameters()); | ||
} | ||
|
||
public void register() { | ||
|
||
SubCommand[] subcommands = new SubCommand[] { | ||
new TeleportCommand(), | ||
new GenerateCommand(), | ||
new DeleteCommand(), | ||
new LoadCommand(), | ||
new UnloadCommand(), | ||
new ReloadCommand(), | ||
new ListCommand(), | ||
new SetspawnCommand(), | ||
new SettingsCommand(), | ||
new InfoCommand(), | ||
new SetseedCommand(), | ||
new RenameCommand(), | ||
new CopyCommand(), | ||
new RegenerateCommand(), | ||
new ClearlagCommand(), | ||
new GameruleCommand(), | ||
new SetdefaultCommand(), | ||
new SaveCommand(), | ||
new VersionCommand(), | ||
new SyncCommand(), | ||
new AddonCommand(), | ||
new SpawnCommand(), | ||
new StatusCommand(), | ||
new HelpCommand() | ||
}; | ||
for(SubCommand subcommand : subcommands) registerSubCommand(subcommand); | ||
|
||
Server.getInstance().getCommandMap().register(this.getName(), this); | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
Sourcecode/src/de/buddelbubi/commands/subcommand/AddonCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package de.buddelbubi.commands.subcommand; | ||
|
||
import java.util.LinkedList; | ||
|
||
import cn.nukkit.Player; | ||
import cn.nukkit.command.CommandSender; | ||
import cn.nukkit.command.data.CommandParameter; | ||
import de.buddelbubi.WorldManager; | ||
import de.buddelbubi.listener.Addons; | ||
|
||
public class AddonCommand extends SubCommand { | ||
|
||
public AddonCommand() { | ||
super("addon"); | ||
this.setAliases(new String[] { | ||
"addon", | ||
"addons" | ||
}); | ||
} | ||
|
||
@Override | ||
public CommandParameter[] getParameters() { | ||
|
||
LinkedList < CommandParameter > parameters = new LinkedList < > (); | ||
parameters.add(CommandParameter.newEnum(this.getName(), this.getAliases())); | ||
return parameters.toArray(new CommandParameter[parameters.size()]); | ||
|
||
} | ||
|
||
@Override | ||
public boolean execute(CommandSender sender, String arg1, String[] args) { | ||
|
||
if (sender instanceof Player && sender.hasPermission("worldmanager.addon")) { | ||
|
||
Addons.showAddonUI((Player) sender); | ||
|
||
} else sender.sendMessage(WorldManager.prefix + "§cYou are lacking the permission 'worldmanager.addon'."); | ||
|
||
return false; | ||
} | ||
|
||
} |
Oops, something went wrong.