General refactoring

This commit is contained in:
ShadowRanger 2016-03-10 13:47:17 +11:00
parent f9ac6804b2
commit b8f4589b87
7 changed files with 26 additions and 19 deletions

View file

@ -4,7 +4,7 @@
<groupId>com.lishid</groupId>
<artifactId>openinv</artifactId>
<packaging>jar</packaging>
<version>2.3.6</version>
<version>2.3.7</version>
<name>OpenInv</name>
<url>http://dev.bukkit.org/bukkit-plugins/openinv/</url>

View file

@ -46,13 +46,20 @@ public class Configuration {
notifyAnyChest = plugin.getConfig().getBoolean("notify.any-chest", true);
}
/**
* Reloads OpenInv's config settings.
*/
public void reload() {
load();
}
/**
* Saves a value to the plugin config at the specified path.
*
* @param path the path to set the value to
* @param value the value to set to the path
*/
public void saveToConfig(String path, Object value) {
private void saveToConfig(String path, Object value) {
plugin.getConfig().set(path, value);
plugin.saveConfig();
}

View file

@ -56,6 +56,9 @@ public class OpenInv extends JavaPlugin {
@Override
public void onEnable() {
// Save the default config.yml if it doesn't already exist
saveDefaultConfig();
// Config
configuration = new Configuration(this);
@ -64,9 +67,6 @@ public class OpenInv extends JavaPlugin {
inventoryAccess = new InventoryAccess(this);
anySilentChest = new AnySilentChest(this);
// Save the default config.yml if it doesn't already exist
saveDefaultConfig();
// Register the plugin's events
PluginManager pm = getServer().getPluginManager();
@ -155,27 +155,27 @@ public class OpenInv extends JavaPlugin {
* @param player the player to show help to
*/
public static void showHelp(Player player) {
player.sendMessage(ChatColor.GREEN + "/openinv <player> - Open a player's inventory.");
player.sendMessage(ChatColor.GREEN + "/openinv <player> - Opens a player's inventory.");
player.sendMessage(ChatColor.GREEN + " (aliases: oi, inv, open)");
player.sendMessage(ChatColor.GREEN + "/openender <player> - Open a player's ender chest.");
player.sendMessage(ChatColor.GREEN + "/openender <player> - Opens a player's ender chest.");
player.sendMessage(ChatColor.GREEN + " (aliases: oe)");
player.sendMessage(ChatColor.GREEN + "/searchinv <item> [minAmount] -");
player.sendMessage(ChatColor.GREEN + " Search and list players having a specific item.");
player.sendMessage(ChatColor.GREEN + " Searches and lists players that have a specific item in their inventory.");
player.sendMessage(ChatColor.GREEN + " (aliases: si)");
player.sendMessage(ChatColor.GREEN + "/searchender <item> [minAmount] -");
player.sendMessage(ChatColor.GREEN + " Search and list players having a specific item.");
player.sendMessage(ChatColor.GREEN + " Searches and lists players that have a specific item in their ender chest.");
player.sendMessage(ChatColor.GREEN + " (aliases: se)");
player.sendMessage(ChatColor.GREEN + "/toggleopeninv - Toggle the item openinv function.");
player.sendMessage(ChatColor.GREEN + "/toggleopeninv - Toggles the item openinv function.");
player.sendMessage(ChatColor.GREEN + " (aliases: toi, toggleoi, toggleinv)");
player.sendMessage(ChatColor.GREEN + "/anychest - Toggle the any chest function.");
player.sendMessage(ChatColor.GREEN + "/anychest - Toggles the any chest function.");
player.sendMessage(ChatColor.GREEN + " (aliases: ac)");
player.sendMessage(ChatColor.GREEN + "/silentchest - Toggle the silent chest function.");
player.sendMessage(ChatColor.GREEN + "/silentchest - Toggles the silent chest function.");
player.sendMessage(ChatColor.GREEN + " (aliases: sc, silent)");
}

View file

@ -54,7 +54,7 @@ public class SilentChestCommand implements CommandExecutor {
if (args.length > 0) {
if (args[0].equalsIgnoreCase("check")) {
String status = configuration.getPlayerSilentChestStatus(player) ? ChatColor.GREEN + "ON" : ChatColor.RED + "OFF";
plugin.sendMessage(player, "Silent Chest is " + status + ChatColor.RESET + ".");
OpenInv.sendMessage(player, "Silent Chest is " + status + ChatColor.RESET + ".");
return true;
}
}
@ -62,7 +62,7 @@ public class SilentChestCommand implements CommandExecutor {
configuration.setPlayerSilentChestStatus(player, !configuration.getPlayerSilentChestStatus(player));
String status = configuration.getPlayerSilentChestStatus(player) ? ChatColor.GREEN + "ON" : ChatColor.RED + "OFF";
plugin.sendMessage(player, "Silent Chest is now " + status + ChatColor.RESET + ".");
OpenInv.sendMessage(player, "Silent Chest is now " + status + ChatColor.RESET + ".");
return true;
}

View file

@ -54,7 +54,7 @@ public class ToggleOpenInvCommand implements CommandExecutor {
if (args.length > 0) {
if (args[0].equalsIgnoreCase("check")) {
String status = configuration.getPlayerItemOpenInvStatus(player) ? ChatColor.GREEN + "ON" : ChatColor.RED + "OFF";
plugin.sendMessage(player, "OpenInv with " + ChatColor.GRAY + configuration.getOpenInvItem() + ChatColor.RESET + status + ChatColor.RESET + ".");
OpenInv.sendMessage(player, "OpenInv with " + ChatColor.GRAY + configuration.getOpenInvItem() + ChatColor.RESET + status + ChatColor.RESET + ".");
return true;
}
}
@ -62,7 +62,7 @@ public class ToggleOpenInvCommand implements CommandExecutor {
configuration.setPlayerItemOpenInvStatus(player, !configuration.getPlayerItemOpenInvStatus(player));
String status = configuration.getPlayerItemOpenInvStatus(player) ? ChatColor.GREEN + "ON" : ChatColor.RED + "OFF";
plugin.sendMessage(player, "OpenInv with " + ChatColor.GRAY + configuration.getOpenInvItem() + ChatColor.RESET + " is now " + status + ChatColor.RESET + ".");
OpenInv.sendMessage(player, "OpenInv with " + ChatColor.GRAY + configuration.getOpenInvItem() + ChatColor.RESET + " is now " + status + ChatColor.RESET + ".");
return true;
}

View file

@ -152,7 +152,7 @@ public class AnySilentChest {
tileInventory = new SilentInventory(tileInventory);
if (plugin.getConfiguration().notifySilentChest()) {
plugin.sendMessage(p, "You are opening a chest silently.");
OpenInv.sendMessage(p, "You are opening a chest silently.");
}
returnValue = false;
@ -161,7 +161,7 @@ public class AnySilentChest {
player.openContainer(tileInventory);
if (anyChest && plugin.getConfiguration().notifyAnyChest()) {
plugin.sendMessage(p, "You are opening a blocked chest.");
OpenInv.sendMessage(p, "You are opening a blocked chest.");
}
return returnValue;

View file

@ -1,6 +1,6 @@
name: OpenInv
main: com.lishid.openinv.OpenInv
version: 2.3.6
version: 2.3.7
author: lishid
authors: [ShadowRanger]
description: >