diff --git a/src/main/java/com/onarandombox/multiverseinventories/InventoriesListener.java b/src/main/java/com/onarandombox/multiverseinventories/InventoriesListener.java index 8e1d8e4d..992df2a3 100644 --- a/src/main/java/com/onarandombox/multiverseinventories/InventoriesListener.java +++ b/src/main/java/com/onarandombox/multiverseinventories/InventoriesListener.java @@ -1,7 +1,7 @@ package com.onarandombox.multiverseinventories; import com.dumptruckman.minecraft.util.Logging; -import com.onarandombox.MultiverseCore.api.MultiverseWorld; +import com.onarandombox.MultiverseCore.api.MVWorld; import com.onarandombox.MultiverseCore.event.MVConfigReloadEvent; import com.onarandombox.MultiverseCore.event.MVVersionEvent; import com.onarandombox.multiverseinventories.profile.GlobalProfile; @@ -389,7 +389,7 @@ private void handleRespawn(PlayerRespawnEvent event, EventPriority priority) { if (group.getSpawnPriority().equals(priority)) { String spawnWorldName = group.getSpawnWorld(); if (spawnWorldName != null) { - MultiverseWorld mvWorld = this.inventories.getCore() + MVWorld mvWorld = this.inventories.getCore() .getMVWorldManager().getMVWorld(spawnWorldName); if (mvWorld != null) { this.spawnLoc = mvWorld.getSpawnLocation(); diff --git a/src/main/java/com/onarandombox/multiverseinventories/MultiverseInventories.java b/src/main/java/com/onarandombox/multiverseinventories/MultiverseInventories.java index d3d37d1c..9e860235 100644 --- a/src/main/java/com/onarandombox/multiverseinventories/MultiverseInventories.java +++ b/src/main/java/com/onarandombox/multiverseinventories/MultiverseInventories.java @@ -1,38 +1,25 @@ package com.onarandombox.multiverseinventories; +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.Locale; + import com.dumptruckman.minecraft.util.Logging; -import com.onarandombox.MultiverseCore.MultiverseCore; +import com.onarandombox.MultiverseCore.api.MVCore; import com.onarandombox.MultiverseCore.api.MVPlugin; -import com.onarandombox.MultiverseCore.commands.HelpCommand; -import com.onarandombox.commandhandler.CommandHandler; +import com.onarandombox.multiverseinventories.locale.Message; +import com.onarandombox.multiverseinventories.locale.Messager; +import com.onarandombox.multiverseinventories.locale.Messaging; +import com.onarandombox.multiverseinventories.migration.ImportManager; import com.onarandombox.multiverseinventories.profile.ProfileDataSource; import com.onarandombox.multiverseinventories.profile.WorldGroupManager; import com.onarandombox.multiverseinventories.profile.container.ContainerType; import com.onarandombox.multiverseinventories.profile.container.ProfileContainerStore; import com.onarandombox.multiverseinventories.share.Sharables; -import com.onarandombox.multiverseinventories.command.AddSharesCommand; -import com.onarandombox.multiverseinventories.command.AddWorldCommand; -import com.onarandombox.multiverseinventories.command.CreateGroupCommand; -import com.onarandombox.multiverseinventories.command.DeleteGroupCommand; -import com.onarandombox.multiverseinventories.command.GroupCommand; -import com.onarandombox.multiverseinventories.command.ImportCommand; -import com.onarandombox.multiverseinventories.command.InfoCommand; -import com.onarandombox.multiverseinventories.command.ListCommand; -import com.onarandombox.multiverseinventories.command.MigrateCommand; -import com.onarandombox.multiverseinventories.command.ReloadCommand; -import com.onarandombox.multiverseinventories.command.RemoveSharesCommand; -import com.onarandombox.multiverseinventories.command.RemoveWorldCommand; -import com.onarandombox.multiverseinventories.command.SpawnCommand; -import com.onarandombox.multiverseinventories.command.ToggleCommand; -import com.onarandombox.multiverseinventories.locale.Message; -import com.onarandombox.multiverseinventories.locale.Messager; -import com.onarandombox.multiverseinventories.locale.Messaging; -import com.onarandombox.multiverseinventories.migration.ImportManager; import com.onarandombox.multiverseinventories.util.Perm; import me.drayshak.WorldInventories.WorldInventories; import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; @@ -41,25 +28,19 @@ import org.bukkit.plugin.java.JavaPluginLoader; import uk.co.tggl.pluckerpluck.multiinv.MultiInv; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Locale; -import java.util.logging.Level; - /** * Multiverse-Inventories plugin main class. */ public class MultiverseInventories extends JavaPlugin implements MVPlugin, Messaging { + private static final int PROTOCOL = 50; + private static MultiverseInventories inventoriesPlugin; public static MultiverseInventories getPlugin() { return inventoriesPlugin; } - private final int requiresProtocol = 22; private final InventoriesListener inventoriesListener = new InventoriesListener(this); private final AdventureListener adventureListener = new AdventureListener(this); @@ -69,8 +50,7 @@ public static MultiverseInventories getPlugin() { private ProfileContainerStore groupProfileContainerStore = null; private ImportManager importManager = new ImportManager(this); - private CommandHandler commandHandler = null; - private MultiverseCore core = null; + private MVCore core = null; private InventoriesConfig config = null; private FlatFileProfileDataSource data = null; @@ -101,49 +81,43 @@ public MultiverseInventories(JavaPluginLoader loader, PluginDescriptionFile desc * {@inheritDoc} */ @Override - public void onDisable() { - for (final Player player : getServer().getOnlinePlayers()) { - final String world = player.getWorld().getName(); - //getData().updateLastWorld(player.getName(), world); - if (getMVIConfig().usingLoggingSaveLoad()) { - ShareHandlingUpdater.updateProfile(this, player, new DefaultPersistingProfile(Sharables.allOf(), - getWorldProfileContainerStore().getContainer(world).getPlayerData(player))); - getData().setLoadOnLogin(player.getName(), true); - } - } - - this.dupingPatch.disable(); - - Logging.shutdown(); + public void onLoad() { + Logging.init(this); + this.getDataFolder().mkdirs(); } /** * {@inheritDoc} */ @Override - public void onEnable() { - Logging.init(this); - Perm.register(this); - - MultiverseCore mvCore; - mvCore = (MultiverseCore) this.getServer().getPluginManager().getPlugin("Multiverse-Core"); - // Test if the Core was found, if not we'll disable this plugin. - if (mvCore == null) { - Logging.severe("Multiverse-Core not found, disabling..."); + public final void onEnable() { + this.core = (MVCore) this.getServer().getPluginManager().getPlugin("Multiverse-Core"); + if (this.core == null) { + Logging.severe("Core not found! You must have Multiverse-Core installed to use this plugin!"); + Logging.severe("Grab a copy at: "); + Logging.severe("https://dev.bukkit.org/projects/multiverse-core"); + Logging.severe("Disabling!"); this.getServer().getPluginManager().disablePlugin(this); return; } - this.setCore(mvCore); - - if (this.getCore().getProtocolVersion() < this.getRequiredProtocol()) { + if (this.core.getProtocolVersion() < this.getProtocolVersion()) { Logging.severe("Your Multiverse-Core is OUT OF DATE"); - Logging.severe("This version of Multiverse-Inventories requires Protocol Level: " + this.getRequiredProtocol()); - Logging.severe("Your of Core Protocol Level is: " + this.getCore().getProtocolVersion()); + Logging.severe("This version of " + this.getDescription().getName() + " requires Protocol Level: " + this.getProtocolVersion()); + Logging.severe("Your of Core Protocol Level is: " + this.core.getProtocolVersion()); Logging.severe("Grab an updated copy at: "); - Logging.severe("http://bukkit.onarandombox.com/?dir=multiverse-core"); + Logging.severe("https://dev.bukkit.org/projects/multiverse-core"); + Logging.severe("Disabling!"); this.getServer().getPluginManager().disablePlugin(this); return; } + Logging.setDebugLevel(core.getMVConfig().getGlobalDebug()); + this.core.incrementPluginCount(); + this.onMVPluginEnable(); + Logging.config("Version %s (API v%s) Enabled - By %s", this.getDescription().getVersion(), getProtocolVersion(), getAuthors()); + } + + private void onMVPluginEnable() { + Perm.register(this); this.reloadConfig(); @@ -158,15 +132,12 @@ public void onEnable() { // Initialize data class //this.getWorldProfileContainerStore().setWorldProfiles(this.getData().getWorldProfiles()); - Logging.setDebugLevel(getCore().getMVConfig().getGlobalDebug()); - - this.getCore().incrementPluginCount(); - // Register Events Bukkit.getPluginManager().registerEvents(inventoriesListener, this); if (Bukkit.getPluginManager().getPlugin("Multiverse-Adventure") != null) { Bukkit.getPluginManager().registerEvents(adventureListener, this); } + if (getCore().getProtocolVersion() >= 24) { new CoreDebugListener(this); } @@ -180,32 +151,31 @@ public void onEnable() { Sharables.init(this); this.dupingPatch = InventoriesDupingPatch.enableDupingPatch(this); - - // Display enable message/version info - Logging.log(true, Level.INFO, "enabled."); } - private void registerCommands() { - this.commandHandler = this.getCore().getCommandHandler(); - this.getCommandHandler().registerCommand(new InfoCommand(this)); - this.getCommandHandler().registerCommand(new ImportCommand(this)); - this.getCommandHandler().registerCommand(new ListCommand(this)); - this.getCommandHandler().registerCommand(new ReloadCommand(this)); - this.getCommandHandler().registerCommand(new AddWorldCommand(this)); - this.getCommandHandler().registerCommand(new RemoveWorldCommand(this)); - this.getCommandHandler().registerCommand(new AddSharesCommand(this)); - this.getCommandHandler().registerCommand(new RemoveSharesCommand(this)); - this.getCommandHandler().registerCommand(new CreateGroupCommand(this)); - this.getCommandHandler().registerCommand(new DeleteGroupCommand(this)); - this.getCommandHandler().registerCommand(new SpawnCommand(this)); - this.getCommandHandler().registerCommand(new GroupCommand(this)); - this.getCommandHandler().registerCommand(new ToggleCommand(this)); - this.getCommandHandler().registerCommand(new MigrateCommand(this)); - for (com.onarandombox.commandhandler.Command c : this.commandHandler.getAllCommands()) { - if (c instanceof HelpCommand) { - c.addKey("mvinv"); + /** + * {@inheritDoc} + */ + @Override + public void onDisable() { + for (final Player player : getServer().getOnlinePlayers()) { + final String world = player.getWorld().getName(); + //getData().updateLastWorld(player.getName(), world); + if (getMVIConfig().usingLoggingSaveLoad()) { + ShareHandlingUpdater.updateProfile(this, player, new DefaultPersistingProfile(Sharables.allOf(), + getWorldProfileContainerStore().getContainer(world).getPlayerData(player))); + getData().setLoadOnLogin(player.getName(), true); } } + + this.dupingPatch.disable(); + + this.core.decrementPluginCount(); + Logging.shutdown(); + } + + private void registerCommands() { + } private void hookImportables() { @@ -231,71 +201,40 @@ public ImportManager getImportManager() { * {@inheritDoc} */ @Override - public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) { - if (!this.isEnabled()) { - sender.sendMessage("This plugin is Disabled!"); - return true; - } - ArrayList allArgs = new ArrayList(Arrays.asList(args)); - allArgs.add(0, command.getName()); - return this.getCommandHandler().locateAndRunCommand(sender, allArgs); - } - - private CommandHandler getCommandHandler() { - return this.commandHandler; - } - - /** - * {@inheritDoc} - */ - @Override - public void log(Level level, String msg) { - Logging.log(level, msg); - } - - /** - * {@inheritDoc} - */ - @Override - public MultiverseCore getCore() { + public MVCore getCore() { return this.core; } - /** - * {@inheritDoc} - */ - @Override - public void setCore(MultiverseCore core) { - this.core = core; - } - /** * {@inheritDoc} */ @Override public int getProtocolVersion() { - return 1; + return PROTOCOL; } /** * {@inheritDoc} */ @Override - public String dumpVersionInfo(String buffer) { - buffer += logAndAddToPasteBinBuffer("=== Settings ==="); - buffer += logAndAddToPasteBinBuffer("First Run: " + this.getMVIConfig().isFirstRun()); - buffer += logAndAddToPasteBinBuffer("Using Bypass: " + this.getMVIConfig().isUsingBypass()); - buffer += logAndAddToPasteBinBuffer("Default Ungrouped Worlds: " + this.getMVIConfig().isDefaultingUngroupedWorlds()); - buffer += logAndAddToPasteBinBuffer("Save and Load on Log In and Out: " + this.getMVIConfig().usingLoggingSaveLoad()); - buffer += logAndAddToPasteBinBuffer("Using GameMode Profiles: " + this.getMVIConfig().isUsingGameModeProfiles()); - buffer += logAndAddToPasteBinBuffer("=== Shares ==="); - buffer += logAndAddToPasteBinBuffer("Optionals for Ungrouped Worlds: " + this.getMVIConfig().usingOptionalsForUngrouped()); - buffer += logAndAddToPasteBinBuffer("Enabled Optionals: " + this.getMVIConfig().getOptionalShares()); - buffer += logAndAddToPasteBinBuffer("=== Groups ==="); - for (WorldGroup group : this.getGroupManager().getGroups()) { - buffer += logAndAddToPasteBinBuffer(group.toString()); + public String getAuthors() { + List authorsList = this.getDescription().getAuthors(); + if (authorsList.size() == 0) { + return ""; + } + + StringBuilder authors = new StringBuilder(); + authors.append(authorsList.get(0)); + + for (int i = 1; i < authorsList.size(); i++) { + if (i == authorsList.size() - 1) { + authors.append(" and ").append(authorsList.get(i)); + } else { + authors.append(", ").append(authorsList.get(i)); + } } - return buffer; + + return authors.toString(); } /** @@ -413,13 +352,6 @@ public void setMessager(Messager messager) { this.messager = messager; } - /** - * @return The required protocol version of core. - */ - public int getRequiredProtocol() { - return this.requiresProtocol; - } - /** * @return The World Group manager for this plugin. */ diff --git a/src/main/java/com/onarandombox/multiverseinventories/command/AddSharesCommand.java b/src/main/java/com/onarandombox/multiverseinventories/command/AddSharesCommand.java deleted file mode 100644 index e3e98458..00000000 --- a/src/main/java/com/onarandombox/multiverseinventories/command/AddSharesCommand.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.onarandombox.multiverseinventories.command; - -import com.onarandombox.multiverseinventories.MultiverseInventories; -import com.onarandombox.multiverseinventories.WorldGroup; -import com.onarandombox.multiverseinventories.share.Sharables; -import com.onarandombox.multiverseinventories.share.Shares; -import com.onarandombox.multiverseinventories.locale.Message; -import com.onarandombox.multiverseinventories.util.Perm; -import org.bukkit.command.CommandSender; - -import java.util.List; - -/** - * The /mvinv addshares Command. - * @deprecated Deprecated in favor of /mvinv group. - */ -@Deprecated -public class AddSharesCommand extends InventoriesCommand { - - public AddSharesCommand(MultiverseInventories plugin) { - super(plugin); - this.setName("Adds share(s) to a World Group."); - this.setCommandUsage("/mvinv addshares {SHARE[,EXTRA]} {GROUP}"); - this.setArgRange(2, 2); - this.addKey("mvinv addshares"); - this.addKey("mvinv addshare"); - this.addKey("mvinv adds"); - this.addKey("mvinvas"); - this.addKey("mvinvadds"); - this.addKey("mvinvaddshares"); - this.addKey("mvinvaddshare"); - this.setPermission(Perm.COMMAND_ADDSHARES.getPermission()); - } - - @Override - public void runCommand(CommandSender sender, List args) { - Shares newShares; - Shares negativeShares; - if (args.get(0).contains("all") || args.get(0).contains("everything") || args.get(0).contains("*")) { - newShares = Sharables.allOf(); - negativeShares = Sharables.noneOf(); - } else if (args.get(0).contains("-all") || args.get(0).contains("-everything") || args.get(0).contains("-*")) { - negativeShares = Sharables.allOf(); - newShares = Sharables.noneOf(); - } else { - negativeShares = Sharables.noneOf(); - newShares = Sharables.noneOf(); - String[] sharesString = args.get(0).split(","); - for (String shareString : sharesString) { - if (shareString.startsWith("-") && shareString.length() > 1) { - Shares shares = Sharables.lookup(shareString.substring(1)); - if (shares == null) { - continue; - } - negativeShares.setSharing(shares, true); - } else { - Shares shares = Sharables.lookup(shareString); - if (shares == null) { - continue; - } - newShares.setSharing(shares, true); - } - } - } - if (newShares.isEmpty() && negativeShares.isEmpty()) { - this.messager.normal(Message.ERROR_NO_SHARES_SPECIFIED, sender, args.get(0)); - return; - } - WorldGroup worldGroup = this.plugin.getGroupManager().getGroup(args.get(1)); - if (worldGroup == null) { - this.messager.normal(Message.ERROR_NO_GROUP, sender, args.get(1)); - return; - } - worldGroup.getShares().mergeShares(newShares); - worldGroup.getShares().removeAll(negativeShares); - this.plugin.getGroupManager().updateGroup(worldGroup); - this.plugin.getMVIConfig().save(); - this.messager.normal(Message.NOW_SHARING, sender, worldGroup.getName(), - worldGroup.getShares().toString()); - } -} - diff --git a/src/main/java/com/onarandombox/multiverseinventories/command/AddWorldCommand.java b/src/main/java/com/onarandombox/multiverseinventories/command/AddWorldCommand.java deleted file mode 100644 index e4812a0a..00000000 --- a/src/main/java/com/onarandombox/multiverseinventories/command/AddWorldCommand.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.onarandombox.multiverseinventories.command; - -import com.onarandombox.multiverseinventories.MultiverseInventories; -import com.onarandombox.multiverseinventories.WorldGroup; -import com.onarandombox.multiverseinventories.locale.Message; -import com.onarandombox.multiverseinventories.util.Perm; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.command.CommandSender; - -import java.util.List; - -/** - * The /mvinv addworld Command. - * @deprecated Deprecated in favor of /mvinv group. - */ -@Deprecated -public class AddWorldCommand extends InventoriesCommand { - - public AddWorldCommand(MultiverseInventories plugin) { - super(plugin); - this.setName("Adds a World to a World Group."); - this.setCommandUsage("/mvinv addworld {WORLD} {GROUP}"); - this.setArgRange(2, 2); - this.addKey("mvinv addworld"); - this.addKey("mvinv addw"); - this.addKey("mvinvaw"); - this.addKey("mvinvaddw"); - this.addKey("mvinvaddworld"); - this.setPermission(Perm.COMMAND_ADDWORLD.getPermission()); - } - - @Override - public void runCommand(CommandSender sender, List args) { - World world = Bukkit.getWorld(args.get(0)); - if (world == null) { - this.messager.normal(Message.ERROR_NO_WORLD, sender, args.get(0)); - return; - } - WorldGroup worldGroup = this.plugin.getGroupManager().getGroup(args.get(1)); - if (worldGroup == null) { - this.messager.normal(Message.ERROR_NO_GROUP, sender, args.get(1)); - return; - } - if (worldGroup.containsWorld(world.getName())) { - this.messager.normal(Message.WORLD_ALREADY_EXISTS, sender, world.getName(), - worldGroup.getName()); - return; - } - worldGroup.addWorld(world); - this.plugin.getGroupManager().updateGroup(worldGroup); - this.plugin.getMVIConfig().save(); - this.messager.normal(Message.WORLD_ADDED, sender, world.getName(), - worldGroup.getName()); - } -} - diff --git a/src/main/java/com/onarandombox/multiverseinventories/command/CreateGroupCommand.java b/src/main/java/com/onarandombox/multiverseinventories/command/CreateGroupCommand.java deleted file mode 100644 index d9da3a99..00000000 --- a/src/main/java/com/onarandombox/multiverseinventories/command/CreateGroupCommand.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.onarandombox.multiverseinventories.command; - -import com.onarandombox.multiverseinventories.MultiverseInventories; -import com.onarandombox.multiverseinventories.WorldGroup; -import com.onarandombox.multiverseinventories.locale.Message; -import com.onarandombox.multiverseinventories.util.Perm; -import org.bukkit.command.CommandSender; - -import java.util.List; - -/** - * The /mvinv creategroup Command. - */ -public class CreateGroupCommand extends InventoriesCommand { - - public CreateGroupCommand(MultiverseInventories plugin) { - super(plugin); - this.setName("Creates a new World Group with no worlds and no shares."); - this.setCommandUsage("/mvinv creategroup {NAME}"); - this.setArgRange(1, 1); - this.addKey("mvinv creategroup"); - this.addKey("mvinv createg"); - this.addKey("mvinv cg"); - this.addKey("mvinvcreategroup"); - this.addKey("mvinvcreateg"); - this.addKey("mvinvcg"); - this.setPermission(Perm.COMMAND_CREATEGROUP.getPermission()); - } - - @Override - public void runCommand(CommandSender sender, List args) { - WorldGroup worldGroup = this.plugin.getGroupManager().getGroup(args.get(0)); - if (worldGroup != null) { - this.messager.normal(Message.GROUP_EXISTS, sender, args.get(0)); - return; - } - - worldGroup = this.plugin.getGroupManager().newEmptyGroup(args.get(0)); - this.plugin.getGroupManager().updateGroup(worldGroup); - this.messager.normal(Message.GROUP_CREATION_COMPLETE, sender); - } -} - diff --git a/src/main/java/com/onarandombox/multiverseinventories/command/DeleteGroupCommand.java b/src/main/java/com/onarandombox/multiverseinventories/command/DeleteGroupCommand.java deleted file mode 100644 index dd8c903a..00000000 --- a/src/main/java/com/onarandombox/multiverseinventories/command/DeleteGroupCommand.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.onarandombox.multiverseinventories.command; - -import com.onarandombox.multiverseinventories.MultiverseInventories; -import com.onarandombox.multiverseinventories.WorldGroup; -import com.onarandombox.multiverseinventories.locale.Message; -import com.onarandombox.multiverseinventories.util.Perm; -import org.bukkit.command.CommandSender; - -import java.util.List; - -/** - * The /mvinv deletegroup Command. - */ -public class DeleteGroupCommand extends InventoriesCommand { - - public DeleteGroupCommand(MultiverseInventories plugin) { - super(plugin); - this.setName("Deletes a World Group."); - this.setCommandUsage("/mvinv deletegroup {NAME}"); - this.setArgRange(1, 1); - this.addKey("mvinv deletegroup"); - this.addKey("mvinv deleteg"); - this.addKey("mvinv dg"); - this.addKey("mvinvdeletegroup"); - this.addKey("mvinvdeleteg"); - this.addKey("mvinvdg"); - this.setPermission(Perm.COMMAND_DELETEGROUP.getPermission()); - } - - @Override - public void runCommand(CommandSender sender, List args) { - WorldGroup worldGroup = this.plugin.getGroupManager().getGroup(args.get(0)); - if (worldGroup == null) { - this.messager.normal(Message.ERROR_NO_GROUP, sender, args.get(0)); - return; - } - - this.plugin.getGroupManager().removeGroup(worldGroup); - this.messager.normal(Message.GROUP_REMOVED, sender, args.get(0)); - } -} - diff --git a/src/main/java/com/onarandombox/multiverseinventories/command/GroupCommand.java b/src/main/java/com/onarandombox/multiverseinventories/command/GroupCommand.java deleted file mode 100644 index e4baefc6..00000000 --- a/src/main/java/com/onarandombox/multiverseinventories/command/GroupCommand.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.onarandombox.multiverseinventories.command; - -import com.onarandombox.multiverseinventories.MultiverseInventories; -import com.onarandombox.multiverseinventories.command.prompts.GroupControlPrompt; -import com.onarandombox.multiverseinventories.locale.Message; -import com.onarandombox.multiverseinventories.util.Perm; -import org.bukkit.command.CommandSender; -import org.bukkit.conversations.Conversable; -import org.bukkit.conversations.Conversation; -import org.bukkit.conversations.ConversationFactory; - -import java.util.List; - -/** - * The /mvi info Command. - */ -public class GroupCommand extends InventoriesCommand { - - public GroupCommand(MultiverseInventories plugin) { - super(plugin); - this.setName("Creates a world group."); - this.setCommandUsage("/mvinv group"); - this.setArgRange(0, 0); - this.addKey("mvinv group"); - this.addKey("mvinv g"); - this.addKey("mvinvgroup"); - this.addKey("mvinvg"); - this.setPermission(Perm.COMMAND_GROUP.getPermission()); - } - - @Override - public void runCommand(CommandSender sender, List args) { - if (!(sender instanceof Conversable)) { - this.messager.normal(Message.NON_CONVERSABLE, sender); - return; - } - - Conversable conversable = (Conversable) sender; - Conversation conversation = new ConversationFactory(this.plugin) - .withFirstPrompt(new GroupControlPrompt(plugin, sender)) - .withEscapeSequence("##") - .withModality(false).buildConversation(conversable); - conversation.begin(); - } -} - diff --git a/src/main/java/com/onarandombox/multiverseinventories/command/ImportCommand.java b/src/main/java/com/onarandombox/multiverseinventories/command/ImportCommand.java deleted file mode 100644 index 1831351b..00000000 --- a/src/main/java/com/onarandombox/multiverseinventories/command/ImportCommand.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.onarandombox.multiverseinventories.command; - -import com.dumptruckman.minecraft.util.Logging; -import com.onarandombox.multiverseinventories.MultiverseInventories; -import com.onarandombox.multiverseinventories.locale.Message; -import com.onarandombox.multiverseinventories.migration.DataImporter; -import com.onarandombox.multiverseinventories.migration.MigrationException; -import com.onarandombox.multiverseinventories.util.Perm; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; - -import java.util.List; - -/** - * The /mvi info Command. - */ -public class ImportCommand extends InventoriesCommand { - - public ImportCommand(MultiverseInventories plugin) { - super(plugin); - this.setName("Import from MultiInv/WorldInventories"); - this.setCommandUsage("/mvinv import " + ChatColor.GREEN + "{MultiInv|WorldInventories}"); - this.setArgRange(1, 1); - this.addKey("mvinv import"); - this.addKey("mvinvim"); - this.addKey("mvinvimport"); - this.setPermission(Perm.COMMAND_IMPORT.getPermission()); - } - - @Override - public void runCommand(CommandSender sender, List args) { - DataImporter importer = null; - if (args.get(0).equalsIgnoreCase("MultiInv")) { - importer = this.plugin.getImportManager().getMultiInvImporter(); - } else if (args.get(0).equalsIgnoreCase("WorldInventories")) { - importer = this.plugin.getImportManager().getWorldInventoriesImporter(); - } else { - this.messager.bad(Message.ERROR_PLUGIN_NOT_ENABLED, - sender, args.get(0)); - return; - } - if (importer == null) { - this.messager.bad(Message.ERROR_PLUGIN_NOT_ENABLED, - sender, args.get(0)); - } else { - try { - importer.importData(); - } catch (MigrationException e) { - Logging.severe(e.getMessage()); - Logging.severe("Cause: " + e.getCauseException().getMessage()); - } - } - } -} - diff --git a/src/main/java/com/onarandombox/multiverseinventories/command/InfoCommand.java b/src/main/java/com/onarandombox/multiverseinventories/command/InfoCommand.java deleted file mode 100644 index 8567b3a6..00000000 --- a/src/main/java/com/onarandombox/multiverseinventories/command/InfoCommand.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.onarandombox.multiverseinventories.command; - -import com.onarandombox.multiverseinventories.MultiverseInventories; -import com.onarandombox.multiverseinventories.WorldGroup; -import com.onarandombox.multiverseinventories.profile.container.ProfileContainer; -import com.onarandombox.multiverseinventories.locale.Message; -import com.onarandombox.multiverseinventories.util.Perm; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.List; -import java.util.Set; - -/** - * The /mvi info Command. - */ -public class InfoCommand extends InventoriesCommand { - - public InfoCommand(MultiverseInventories plugin) { - super(plugin); - this.setName("World and Group Information"); - this.setCommandUsage("/mvinv info " + ChatColor.GREEN + "[WORLD|GROUP]"); - this.setArgRange(0, 1); - this.addKey("mvinv info"); - this.addKey("mvinvi"); - this.addKey("mvinvinfo"); - this.setPermission(Perm.COMMAND_INFO.getPermission()); - } - - @Override - public void runCommand(CommandSender sender, List args) { - String name; - if (args.isEmpty()) { - if (!(sender instanceof Player)) { - this.messager.normal(Message.INFO_ZERO_ARG, sender); - return; - } - name = ((Player) sender).getWorld().getName(); - } else { - name = args.get(0); - } - - ProfileContainer worldProfileContainer = this.plugin.getWorldProfileContainerStore().getContainer(name); - messager.normal(Message.INFO_WORLD, sender, name); - if (worldProfileContainer != null && Bukkit.getWorld(worldProfileContainer.getContainerName()) != null) { - worldInfo(sender, worldProfileContainer); - } else { - messager.normal(Message.ERROR_NO_WORLD_PROFILE, sender, name); - } - WorldGroup worldGroup = this.plugin.getGroupManager().getGroup(name); - this.messager.normal(Message.INFO_GROUP, sender, name); - if (worldGroup != null) { - this.groupInfo(sender, worldGroup); - } else { - this.messager.normal(Message.ERROR_NO_GROUP, sender, name); - } - } - - private void groupInfo(CommandSender sender, WorldGroup worldGroup) { - StringBuilder worldsString = new StringBuilder(); - Set worlds = worldGroup.getWorlds(); - if (worlds.isEmpty()) { - worldsString.append("N/A"); - } else { - for (String world : worlds) { - if (!worldsString.toString().isEmpty()) { - worldsString.append(", "); - } - worldsString.append(world); - } - } - this.messager.normal(Message.INFO_GROUPS_INFO, - sender, worldsString, worldGroup.getShares().toString()); - } - - private void worldInfo(CommandSender sender, ProfileContainer worldProfileContainer) { - StringBuilder groupsString = new StringBuilder(); - List worldGroups = this.plugin.getGroupManager() - .getGroupsForWorld(worldProfileContainer.getContainerName()); - - if (worldGroups.isEmpty()) { - groupsString.append("N/A"); - } else { - for (WorldGroup worldGroup : worldGroups) { - if (!groupsString.toString().isEmpty()) { - groupsString.append(", "); - } - groupsString.append(worldGroup.getName()); - } - } - - this.messager.normal(Message.INFO_WORLD_INFO, - sender, groupsString.toString()); - } -} - diff --git a/src/main/java/com/onarandombox/multiverseinventories/command/InventoriesCommand.java b/src/main/java/com/onarandombox/multiverseinventories/command/InventoriesCommand.java deleted file mode 100644 index c06378d7..00000000 --- a/src/main/java/com/onarandombox/multiverseinventories/command/InventoriesCommand.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.onarandombox.multiverseinventories.command; - -import com.onarandombox.commandhandler.Command; -import com.onarandombox.multiverseinventories.MultiverseInventories; -import com.onarandombox.multiverseinventories.locale.Messager; -import org.bukkit.command.CommandSender; - -import java.util.List; - -/** - * A base command class to easily retrieve the plugin associated. - */ -public abstract class InventoriesCommand extends Command { - - /** - * Instance of MultiverseInventories. - */ - protected MultiverseInventories plugin; - /** - * Instance of messager used for Inventories. - */ - protected Messager messager; - - public InventoriesCommand(MultiverseInventories plugin) { - super(plugin); - this.plugin = plugin; - this.messager = plugin.getMessager(); - } - - @Override - public abstract void runCommand(CommandSender sender, List args); -} - - diff --git a/src/main/java/com/onarandombox/multiverseinventories/command/ListCommand.java b/src/main/java/com/onarandombox/multiverseinventories/command/ListCommand.java deleted file mode 100644 index aacb289e..00000000 --- a/src/main/java/com/onarandombox/multiverseinventories/command/ListCommand.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.onarandombox.multiverseinventories.command; - -import com.onarandombox.multiverseinventories.MultiverseInventories; -import com.onarandombox.multiverseinventories.WorldGroup; -import com.onarandombox.multiverseinventories.locale.Message; -import com.onarandombox.multiverseinventories.util.Perm; -import org.bukkit.command.CommandSender; - -import java.util.Collection; -import java.util.List; - -/** - * The /mvi info Command. - */ -public class ListCommand extends InventoriesCommand { - - public ListCommand(MultiverseInventories plugin) { - super(plugin); - this.setName("World and Group Information"); - this.setCommandUsage("/mvinv list"); - this.setArgRange(0, 0); - this.addKey("mvinv list"); - this.addKey("mvinvl"); - this.addKey("mvinvlist"); - this.setPermission(Perm.COMMAND_LIST.getPermission()); - } - - @Override - public void runCommand(CommandSender sender, List args) { - Collection groups = this.plugin.getGroupManager().getGroups(); - String groupsString = "N/A"; - if (!groups.isEmpty()) { - StringBuilder builder = new StringBuilder(); - for (WorldGroup group : groups) { - if (!builder.toString().isEmpty()) { - builder.append(", "); - } - builder.append(group.getName()); - } - groupsString = builder.toString(); - } - this.messager.normal(Message.LIST_GROUPS, sender, groupsString); - } -} - diff --git a/src/main/java/com/onarandombox/multiverseinventories/command/MigrateCommand.java b/src/main/java/com/onarandombox/multiverseinventories/command/MigrateCommand.java deleted file mode 100644 index 70feb105..00000000 --- a/src/main/java/com/onarandombox/multiverseinventories/command/MigrateCommand.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.onarandombox.multiverseinventories.command; - -import com.dumptruckman.minecraft.util.Logging; -import com.onarandombox.multiverseinventories.MultiverseInventories; -import com.onarandombox.multiverseinventories.WorldGroup; -import com.onarandombox.multiverseinventories.locale.Message; -import com.onarandombox.multiverseinventories.profile.container.ProfileContainer; -import com.onarandombox.multiverseinventories.util.Perm; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.io.IOException; -import java.util.List; -import java.util.Set; - -/** - * The /mvi info Command. - */ -public class MigrateCommand extends InventoriesCommand { - - public MigrateCommand(MultiverseInventories plugin) { - super(plugin); - this.setName("Migrate player data from one name to another"); - this.setCommandUsage("/mvinv migrate " + ChatColor.GREEN + "{OLDNAME} {NEWNAME} [saveold]"); - this.setArgRange(2, 3); - this.addKey("mvinv migrate"); - this.addKey("mvinvmigrate"); - this.setPermission(Perm.COMMAND_INFO.getPermission()); - } - - @Override - public void runCommand(CommandSender sender, List args) { - String oldName = args.get(0); - String newName = args.get(1); - boolean deleteOld = true; - if (args.size() > 2) { - if (args.get(2).equalsIgnoreCase("saveold")) { - deleteOld = false; - } - } - try { - plugin.getData().migratePlayerData(oldName, newName, Bukkit.getOfflinePlayer(newName).getUniqueId(), deleteOld); - messager.good(Message.MIGRATE_SUCCESSFUL, sender, oldName, newName); - } catch (IOException e) { - Logging.severe("Could not migrate data from name " + oldName + " to " + newName); - e.printStackTrace(); - messager.bad(Message.MIGRATE_FAILED, sender, oldName, newName); - } - } -} - diff --git a/src/main/java/com/onarandombox/multiverseinventories/command/ReloadCommand.java b/src/main/java/com/onarandombox/multiverseinventories/command/ReloadCommand.java deleted file mode 100644 index 45596191..00000000 --- a/src/main/java/com/onarandombox/multiverseinventories/command/ReloadCommand.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.onarandombox.multiverseinventories.command; - -import com.onarandombox.multiverseinventories.util.Perm; -import com.onarandombox.multiverseinventories.MultiverseInventories; -import com.onarandombox.multiverseinventories.locale.Message; -import org.bukkit.command.CommandSender; - -import java.util.List; - -/** - * The /mvi info Command. - */ -public class ReloadCommand extends InventoriesCommand { - - public ReloadCommand(MultiverseInventories plugin) { - super(plugin); - this.setName("Reloads config file"); - this.setCommandUsage("/mvinv reload"); - this.setArgRange(0, 0); - this.addKey("mvinv reload"); - this.addKey("mvinvreload"); - this.setPermission(Perm.COMMAND_RELOAD.getPermission()); - } - - @Override - public void runCommand(CommandSender sender, List args) { - this.plugin.reloadConfig(); - this.messager.normal(Message.RELOAD_COMPLETE, sender); - } -} - diff --git a/src/main/java/com/onarandombox/multiverseinventories/command/RemoveSharesCommand.java b/src/main/java/com/onarandombox/multiverseinventories/command/RemoveSharesCommand.java deleted file mode 100644 index 72c08ea1..00000000 --- a/src/main/java/com/onarandombox/multiverseinventories/command/RemoveSharesCommand.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.onarandombox.multiverseinventories.command; - -import com.onarandombox.multiverseinventories.MultiverseInventories; -import com.onarandombox.multiverseinventories.WorldGroup; -import com.onarandombox.multiverseinventories.share.Sharable; -import com.onarandombox.multiverseinventories.share.Sharables; -import com.onarandombox.multiverseinventories.share.Shares; -import com.onarandombox.multiverseinventories.locale.Message; -import com.onarandombox.multiverseinventories.util.Perm; -import org.bukkit.command.CommandSender; - -import java.util.List; - -/** - * The /mvinv rmshares Command. - * @deprecated Deprecated in favor of /mvinv group. - */ -@Deprecated -public class RemoveSharesCommand extends InventoriesCommand { - - public RemoveSharesCommand(MultiverseInventories plugin) { - super(plugin); - this.setName("Removes share(s) from a World Group."); - this.setCommandUsage("/mvinv removeshares {SHARE[,EXTRA]} {GROUP}"); - this.setArgRange(2, 2); - this.addKey("mvinv removeshares"); - this.addKey("mvinv rmshares"); - this.addKey("mvinv removeshare"); - this.addKey("mvinv rmshare"); - this.addKey("mvinv removes"); - this.addKey("mvinv rms"); - this.addKey("mvinvrs"); - this.addKey("mvinvrms"); - this.addKey("mvinvremoves"); - this.addKey("mvinvremoveshares"); - this.addKey("mvinvrmshares"); - this.addKey("mvinvremoveshare"); - this.addKey("mvinvrmshare"); - this.setPermission(Perm.COMMAND_RMSHARES.getPermission()); - } - - @Override - public void runCommand(CommandSender sender, List args) { - Shares newShares; - if (args.get(0).contains("all") || args.get(0).contains("everything") || args.get(0).contains("*")) { - newShares = Sharables.allOf(); - } else { - newShares = Sharables.noneOf(); - String[] sharesString = args.get(0).split(","); - for (String shareString : sharesString) { - Shares shares = Sharables.lookup(shareString); - if (shares == null) { - continue; - } - newShares.setSharing(shares, true); - } - } - if (newShares.isEmpty()) { - this.messager.normal(Message.ERROR_NO_SHARES_SPECIFIED, sender, args.get(0)); - return; - } - WorldGroup worldGroup = this.plugin.getGroupManager().getGroup(args.get(1)); - if (worldGroup == null) { - this.messager.normal(Message.ERROR_NO_GROUP, sender, args.get(1)); - return; - } - for (Sharable sharable : newShares) { - worldGroup.getShares().setSharing(sharable, false); - } - this.plugin.getGroupManager().updateGroup(worldGroup); - this.plugin.getMVIConfig().save(); - this.messager.normal(Message.NOW_SHARING, sender, worldGroup.getName(), - worldGroup.getShares().toString()); - } -} - diff --git a/src/main/java/com/onarandombox/multiverseinventories/command/RemoveWorldCommand.java b/src/main/java/com/onarandombox/multiverseinventories/command/RemoveWorldCommand.java deleted file mode 100644 index f715295a..00000000 --- a/src/main/java/com/onarandombox/multiverseinventories/command/RemoveWorldCommand.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.onarandombox.multiverseinventories.command; - -import com.onarandombox.multiverseinventories.MultiverseInventories; -import com.onarandombox.multiverseinventories.WorldGroup; -import com.onarandombox.multiverseinventories.locale.Message; -import com.onarandombox.multiverseinventories.util.Perm; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.command.CommandSender; - -import java.util.List; - -/** - * The /mvinv rmworld Command. - * @deprecated Deprecated in favor of /mvinv group. - */ -@Deprecated -public class RemoveWorldCommand extends InventoriesCommand { - - public RemoveWorldCommand(MultiverseInventories plugin) { - super(plugin); - this.setName("Removes a World from a World Group."); - this.setCommandUsage("/mvinv removeworld {WORLD} {GROUP}"); - this.setArgRange(2, 2); - this.addKey("mvinv removeworld"); - this.addKey("mvinv rmworld"); - this.addKey("mvinv removew"); - this.addKey("mvinv rmw"); - this.addKey("mvinvrw"); - this.addKey("mvinvrmw"); - this.addKey("mvinvremovew"); - this.addKey("mvinvremoveworld"); - this.addKey("mvinvrmworld"); - this.setPermission(Perm.COMMAND_RMWORLD.getPermission()); - } - - @Override - public void runCommand(CommandSender sender, List args) { - World world = Bukkit.getWorld(args.get(0)); - if (world == null) { - this.messager.normal(Message.ERROR_NO_WORLD, sender, args.get(0)); - return; - } - WorldGroup worldGroup = this.plugin.getGroupManager().getGroup(args.get(1)); - if (worldGroup == null) { - this.messager.normal(Message.ERROR_NO_GROUP, sender, args.get(1)); - return; - } - if (!worldGroup.containsWorld(world.getName())) { - this.messager.normal(Message.WORLD_NOT_IN_GROUP, sender, world.getName(), - worldGroup.getName()); - return; - } - worldGroup.removeWorld(world); - this.plugin.getGroupManager().updateGroup(worldGroup); - this.plugin.getMVIConfig().save(); - this.messager.normal(Message.WORLD_REMOVED, sender, world.getName(), - worldGroup.getName()); - } -} - diff --git a/src/main/java/com/onarandombox/multiverseinventories/command/SpawnCommand.java b/src/main/java/com/onarandombox/multiverseinventories/command/SpawnCommand.java deleted file mode 100644 index c7869ae1..00000000 --- a/src/main/java/com/onarandombox/multiverseinventories/command/SpawnCommand.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.onarandombox.multiverseinventories.command; - -import com.onarandombox.MultiverseCore.api.MultiverseWorld; -import com.onarandombox.multiverseinventories.WorldGroup; -import com.onarandombox.multiverseinventories.util.Perm; -import com.onarandombox.multiverseinventories.MultiverseInventories; -import com.onarandombox.multiverseinventories.locale.Message; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.List; - -/** - * The /mvi info Command. - */ -public class SpawnCommand extends InventoriesCommand { - - public SpawnCommand(MultiverseInventories plugin) { - super(plugin); - this.setName("Spawn"); - this.setCommandUsage("/mvinv spawn" + ChatColor.GOLD + " [PLAYER]"); - this.setArgRange(0, 1); - this.addKey("mvinv spawn"); - this.addKey("mvinvspawn"); - this.addKey("mvinvs"); - this.addKey("gspawn"); - this.addKey("ispawn"); - this.setPermission(Perm.COMMAND_SPAWN.getPermission()); - this.addAdditonalPermission(Perm.COMMAND_SPAWN_OTHER.getPermission()); - - } - - @Override - public void runCommand(CommandSender sender, List args) { - Player player = null; - if (sender instanceof Player) { - player = (Player) sender; - } - // If a persons name was passed in, you must be A. the console, or B have permissions - if (args.size() == 1) { - Perm perm = Perm.COMMAND_SPAWN_OTHER; - if (player != null && !perm.has(player)) { - this.messager.normal(Message.GENERIC_COMMAND_NO_PERMISSION, player, - perm.getPermission().getDescription(), perm.getPermission().getName()); - return; - } - Player target = Bukkit.getPlayerExact(args.get(0)); - if (target != null) { - this.messager.normal(Message.TELEPORTING, target); - spawnAccurately(target); - - if (player != null) { - this.messager.normal(Message.TELEPORTED_BY, target, - ChatColor.YELLOW + player.getName()); - } else { - this.messager.normal(Message.TELEPORTED_BY, target, - ChatColor.LIGHT_PURPLE + this.messager - .getMessage(Message.GENERIC_THE_CONSOLE)); - } - } else { - this.messager.normal(Message.GENERIC_NOT_LOGGED_IN, sender, args.get(0)); - } - } else { - Perm perm = Perm.COMMAND_SPAWN; - if (player != null && !perm.has(player)) { - this.messager.normal(Message.GENERIC_COMMAND_NO_PERMISSION, player, - perm.getPermission().getDescription(), perm.getPermission().getName()); - return; - } - if (player != null) { - this.messager.normal(Message.TELEPORTING, player); - spawnAccurately(player); - } else { - this.messager.normal(Message.TELEPORT_CONSOLE_ERROR, sender); - } - } - } - - private void spawnAccurately(Player player) { - World world = null; - for (WorldGroup group : this.plugin.getGroupManager().getGroupsForWorld(player.getWorld().getName())) { - if (group.getSpawnWorld() != null) { - world = Bukkit.getWorld(group.getSpawnWorld()); - if (world != null) { - break; - } - } - } - if (world == null) { - world = player.getWorld(); - } - MultiverseWorld mvWorld = this.plugin.getCore() - .getMVWorldManager().getMVWorld(world); - Location spawnLocation; - if (mvWorld != null) { - spawnLocation = mvWorld.getSpawnLocation(); - } else { - spawnLocation = world.getSpawnLocation(); - } - this.plugin.getCore().getSafeTTeleporter().safelyTeleport(player, player, spawnLocation, false); - } -} - diff --git a/src/main/java/com/onarandombox/multiverseinventories/command/ToggleCommand.java b/src/main/java/com/onarandombox/multiverseinventories/command/ToggleCommand.java deleted file mode 100644 index f30e9401..00000000 --- a/src/main/java/com/onarandombox/multiverseinventories/command/ToggleCommand.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.onarandombox.multiverseinventories.command; - -import com.onarandombox.multiverseinventories.MultiverseInventories; -import com.onarandombox.multiverseinventories.share.Sharable; -import com.onarandombox.multiverseinventories.share.Sharables; -import com.onarandombox.multiverseinventories.share.Shares; -import com.onarandombox.multiverseinventories.locale.Message; -import com.onarandombox.multiverseinventories.util.Perm; -import org.bukkit.command.CommandSender; - -import java.util.List; - -/** - * The /mvi info Command. - */ -public class ToggleCommand extends InventoriesCommand { - - public ToggleCommand(MultiverseInventories plugin) { - super(plugin); - this.setName("Toggles the usage of optional sharables"); - this.setCommandUsage("/mvinv toggle {SHARE}"); - this.setArgRange(1, 1); - this.addKey("mvinv toggle"); - this.addKey("mvinv t"); - this.setPermission(Perm.COMMAND_ADDSHARES.getPermission()); - } - - @Override - public void runCommand(CommandSender sender, List args) { - Shares shares = Sharables.lookup(args.get(0).toLowerCase()); - if (shares == null) { - this.messager.normal(Message.ERROR_NO_SHARES_SPECIFIED, sender); - return; - } - boolean foundOpt = false; - for (Sharable sharable : shares) { - if (sharable.isOptional()) { - foundOpt = true; - if (this.plugin.getMVIConfig().getOptionalShares().contains(sharable)) { - this.plugin.getMVIConfig().getOptionalShares().remove(sharable); - this.messager.normal(Message.NOW_NOT_USING_OPTIONAL, sender, sharable.getNames()[0]); - } else { - this.plugin.getMVIConfig().getOptionalShares().add(sharable); - this.messager.normal(Message.NOW_USING_OPTIONAL, sender, sharable.getNames()[0]); - } - } - } - if (foundOpt) { - this.plugin.getMVIConfig().save(); - } else { - this.messager.normal(Message.NO_OPTIONAL_SHARES, sender, args.get(0)); - } - } -} - diff --git a/src/main/java/com/onarandombox/multiverseinventories/event/ShareHandlingEvent.java b/src/main/java/com/onarandombox/multiverseinventories/event/ShareHandlingEvent.java index d65b1bca..9bc81d2f 100644 --- a/src/main/java/com/onarandombox/multiverseinventories/event/ShareHandlingEvent.java +++ b/src/main/java/com/onarandombox/multiverseinventories/event/ShareHandlingEvent.java @@ -6,8 +6,6 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.Event; -import java.util.Collection; -import java.util.LinkedList; import java.util.List; /** diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 07ebb670..f49dcf43 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,7 +2,7 @@ name: Multiverse-Inventories main: com.onarandombox.multiverseinventories.MultiverseInventories version: ${version} api-version: 1.13 -author: dumptruckman +authors: ['dumptruckman'] depend: ['Multiverse-Core'] softdepend: [MultiInv, WorldInventories, Multiverse-Adventure] diff --git a/src/test/java/com/onarandombox/multiverseinventories/util/TestInstanceCreator.java b/src/test/java/com/onarandombox/multiverseinventories/util/TestInstanceCreator.java index 82fb2bc5..7552c09b 100644 --- a/src/test/java/com/onarandombox/multiverseinventories/util/TestInstanceCreator.java +++ b/src/test/java/com/onarandombox/multiverseinventories/util/TestInstanceCreator.java @@ -8,12 +8,13 @@ package com.onarandombox.multiverseinventories.util; import com.onarandombox.MultiverseCore.MultiverseCore; +import com.onarandombox.MultiverseCore.api.MVWorldManager; import com.onarandombox.MultiverseCore.listeners.MVEntityListener; import com.onarandombox.MultiverseCore.listeners.MVPlayerListener; import com.onarandombox.MultiverseCore.listeners.MVWeatherListener; import com.onarandombox.MultiverseCore.utils.FileUtils; import com.onarandombox.MultiverseCore.utils.TestingMode; -import com.onarandombox.MultiverseCore.utils.WorldManager; +import com.onarandombox.MultiverseCore.world.SimpleMVWorldManager; import com.onarandombox.multiverseinventories.InventoriesListener; import com.onarandombox.multiverseinventories.MultiverseInventories; import org.bukkit.Bukkit; @@ -297,7 +298,7 @@ public Integer answer(InvocationOnMock invocation) throws Throwable { serverfield.set(plugin, mockServer); // Set worldManager - WorldManager wm = spy(new WorldManager(core)); + MVWorldManager wm = spy(new SimpleMVWorldManager(core)); Field worldmanagerfield = MultiverseCore.class.getDeclaredField("worldManager"); worldmanagerfield.setAccessible(true); worldmanagerfield.set(core, wm);