Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Buddelbubi authored Mar 11, 2023
1 parent 2dbcfb4 commit 1dc0697
Show file tree
Hide file tree
Showing 37 changed files with 2,567 additions and 44 deletions.
2 changes: 1 addition & 1 deletion Sourcecode/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: WorldManager
version: 1.1.11
version: 1.1.14
api: [1.0.11, 1.0.13, 1.0.14]
author: Buddelbubi
description: WorldManager is the most powerful world management system.
Expand Down
29 changes: 18 additions & 11 deletions Sourcecode/src/de/buddelbubi/WorldManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
import java.io.File;

import cn.nukkit.Server;
import cn.nukkit.command.Command;
import cn.nukkit.plugin.Plugin;
import cn.nukkit.plugin.PluginBase;
import cn.nukkit.utils.Config;
import de.buddelbubi.Commands.AliasManager;
import de.buddelbubi.Commands.WorldManagerCommand;
import de.buddelbubi.Events.Addons;
import de.buddelbubi.Events.Events;
import de.buddelbubi.Events.WorldManagerUI;
import de.buddelbubi.commands.AliasManager;
import de.buddelbubi.commands.CommandMapping;
import de.buddelbubi.listener.Addons;
import de.buddelbubi.listener.Events;
import de.buddelbubi.listener.WorldManagerUI;
import de.buddelbubi.utils.Cache;
import de.buddelbubi.utils.CustomMetricsManager;
import de.buddelbubi.utils.LoadWorlds;
Expand All @@ -22,18 +21,19 @@ public class WorldManager extends PluginBase {

protected static Plugin plugin;

public static final String prefix = "§3WorldManager §8» §7";

public void onEnable() {

plugin = this;

Command command = new WorldManagerCommand("WorldManager");
command.setAliases(new String[] {"wm", "mw", "mv", "levelmanager", "lm"});
command.setDescription("The main WorldManager Command");
getServer().getCommandMap().register(command.getName(), command);
registerCommands();

getServer().getPluginManager().registerEvents(new Events(), plugin);
getServer().getPluginManager().registerEvents(new WorldManagerUI(), plugin);
getServer().getPluginManager().registerEvents(new Addons(), plugin);
getServer().getPluginManager().registerEvents(new Cache(), plugin);

LoadWorlds.loadWorlds();
AliasManager.registerAliases();
Addons.initJson();
Expand All @@ -49,7 +49,14 @@ public void onEnable() {

Updater.checkAndDoUpdateIfAvailable();

Server.getInstance().getLogger().info("§bWorldManager v" + plugin.getDescription().getVersion() + " loaded successfully.");
get().getLogger().info("§bWorldManager v" + plugin.getDescription().getVersion() + " loaded successfully.");

}

private void registerCommands() {

CommandMapping command = new CommandMapping();
command.register();

}

Expand Down
27 changes: 7 additions & 20 deletions Sourcecode/src/de/buddelbubi/api/World.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.buddelbubi.api;

import java.io.File;

import cn.nukkit.Server;
import cn.nukkit.level.Level;
import cn.nukkit.utils.Config;
Expand All @@ -9,7 +10,6 @@ public class World {
private String level;
private Config config;
private boolean loadonstart;
private boolean useowngamemode;
private int gamemode;
private String respawnworld;
private String thumbnail;
Expand Down Expand Up @@ -43,10 +43,6 @@ public boolean doesLoadOnStart() {
return this.loadonstart;
}

public boolean isUsingOwnGamemode() {
return this.useowngamemode;
}

public int getOwnGamemode() {
return this.gamemode;
}
Expand Down Expand Up @@ -90,26 +86,16 @@ public void disableLoadOnStart() {
this.config.save();
}

public void setUsingOwnGamemode(boolean usingOwnGamemode) {
this.useowngamemode = usingOwnGamemode;
this.config.set("UseOwnGamemode", usingOwnGamemode);
this.config.save();
}

public void enableOwnGamemode() {
this.useowngamemode = true;
this.config.set("UseOwnGamemode", true);
this.config.save();
setGamemode(4);
}

public void disableOwnGamemode() {
this.useowngamemode = false;
this.config.set("UseOwnGamemode", false);
this.config.save();
public boolean isUsingOwnGamemode() {
return (this.gamemode == 4);
}

public void setGamemode(int gamemode) {
if(gamemode < 0 || gamemode > 3) throw new IndexOutOfBoundsException("Unknown Gamemode");
if(gamemode < 0 || gamemode > 4) throw new IndexOutOfBoundsException("Unknown Gamemode");
this.gamemode = gamemode;
this.config.set("Gamemode", gamemode);
this.config.save();
Expand Down Expand Up @@ -189,13 +175,14 @@ public void setNote(String note) {
this.config.save();
}



public void refreshData() {

// If you are using the api, execute this to refresh the data. It may be changed by UI changes or manual config overwrites.

this.config = new Config(new File(Server.getInstance().getDataPath() + "/worlds/" + this.getAsLevel().getFolderName(), "config.yml"));
this.loadonstart = this.config.getBoolean("LoadOnStart");
this.useowngamemode = this.config.getBoolean("UseOwnGamemode");
this.gamemode = this.config.getInt("Gamemode");
this.protect = this.config.getBoolean("protected");
this.fly = this.config.getBoolean("fly");
Expand Down
60 changes: 60 additions & 0 deletions Sourcecode/src/de/buddelbubi/commands/AliasManager.java
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 Sourcecode/src/de/buddelbubi/commands/CommandMapping.java
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 Sourcecode/src/de/buddelbubi/commands/subcommand/AddonCommand.java
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;
}

}
Loading

0 comments on commit 1dc0697

Please sign in to comment.