mirror of
https://github.com/TotalFreedomMC/OpenInv.git
synced 2024-12-23 00:15:08 +00:00
General refactoring
This commit is contained in:
parent
f9ac6804b2
commit
b8f4589b87
7 changed files with 26 additions and 19 deletions
2
pom.xml
2
pom.xml
|
@ -4,7 +4,7 @@
|
||||||
<groupId>com.lishid</groupId>
|
<groupId>com.lishid</groupId>
|
||||||
<artifactId>openinv</artifactId>
|
<artifactId>openinv</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>2.3.6</version>
|
<version>2.3.7</version>
|
||||||
<name>OpenInv</name>
|
<name>OpenInv</name>
|
||||||
<url>http://dev.bukkit.org/bukkit-plugins/openinv/</url>
|
<url>http://dev.bukkit.org/bukkit-plugins/openinv/</url>
|
||||||
|
|
||||||
|
|
|
@ -46,13 +46,20 @@ public class Configuration {
|
||||||
notifyAnyChest = plugin.getConfig().getBoolean("notify.any-chest", true);
|
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.
|
* Saves a value to the plugin config at the specified path.
|
||||||
*
|
*
|
||||||
* @param path the path to set the value to
|
* @param path the path to set the value to
|
||||||
* @param value the value to set to the path
|
* @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.getConfig().set(path, value);
|
||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,9 @@ public class OpenInv extends JavaPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
// Save the default config.yml if it doesn't already exist
|
||||||
|
saveDefaultConfig();
|
||||||
|
|
||||||
// Config
|
// Config
|
||||||
configuration = new Configuration(this);
|
configuration = new Configuration(this);
|
||||||
|
|
||||||
|
@ -64,9 +67,6 @@ public class OpenInv extends JavaPlugin {
|
||||||
inventoryAccess = new InventoryAccess(this);
|
inventoryAccess = new InventoryAccess(this);
|
||||||
anySilentChest = new AnySilentChest(this);
|
anySilentChest = new AnySilentChest(this);
|
||||||
|
|
||||||
// Save the default config.yml if it doesn't already exist
|
|
||||||
saveDefaultConfig();
|
|
||||||
|
|
||||||
// Register the plugin's events
|
// Register the plugin's events
|
||||||
PluginManager pm = getServer().getPluginManager();
|
PluginManager pm = getServer().getPluginManager();
|
||||||
|
|
||||||
|
@ -155,27 +155,27 @@ public class OpenInv extends JavaPlugin {
|
||||||
* @param player the player to show help to
|
* @param player the player to show help to
|
||||||
*/
|
*/
|
||||||
public static void showHelp(Player player) {
|
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 + " (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 + " (aliases: oe)");
|
||||||
|
|
||||||
player.sendMessage(ChatColor.GREEN + "/searchinv <item> [minAmount] -");
|
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 + " (aliases: si)");
|
||||||
|
|
||||||
player.sendMessage(ChatColor.GREEN + "/searchender <item> [minAmount] -");
|
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 + " (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 + " (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 + " (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)");
|
player.sendMessage(ChatColor.GREEN + " (aliases: sc, silent)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class SilentChestCommand implements CommandExecutor {
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
if (args[0].equalsIgnoreCase("check")) {
|
if (args[0].equalsIgnoreCase("check")) {
|
||||||
String status = configuration.getPlayerSilentChestStatus(player) ? ChatColor.GREEN + "ON" : ChatColor.RED + "OFF";
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class SilentChestCommand implements CommandExecutor {
|
||||||
configuration.setPlayerSilentChestStatus(player, !configuration.getPlayerSilentChestStatus(player));
|
configuration.setPlayerSilentChestStatus(player, !configuration.getPlayerSilentChestStatus(player));
|
||||||
|
|
||||||
String status = configuration.getPlayerSilentChestStatus(player) ? ChatColor.GREEN + "ON" : ChatColor.RED + "OFF";
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class ToggleOpenInvCommand implements CommandExecutor {
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
if (args[0].equalsIgnoreCase("check")) {
|
if (args[0].equalsIgnoreCase("check")) {
|
||||||
String status = configuration.getPlayerItemOpenInvStatus(player) ? ChatColor.GREEN + "ON" : ChatColor.RED + "OFF";
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class ToggleOpenInvCommand implements CommandExecutor {
|
||||||
configuration.setPlayerItemOpenInvStatus(player, !configuration.getPlayerItemOpenInvStatus(player));
|
configuration.setPlayerItemOpenInvStatus(player, !configuration.getPlayerItemOpenInvStatus(player));
|
||||||
|
|
||||||
String status = configuration.getPlayerItemOpenInvStatus(player) ? ChatColor.GREEN + "ON" : ChatColor.RED + "OFF";
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,7 @@ public class AnySilentChest {
|
||||||
tileInventory = new SilentInventory(tileInventory);
|
tileInventory = new SilentInventory(tileInventory);
|
||||||
|
|
||||||
if (plugin.getConfiguration().notifySilentChest()) {
|
if (plugin.getConfiguration().notifySilentChest()) {
|
||||||
plugin.sendMessage(p, "You are opening a chest silently.");
|
OpenInv.sendMessage(p, "You are opening a chest silently.");
|
||||||
}
|
}
|
||||||
|
|
||||||
returnValue = false;
|
returnValue = false;
|
||||||
|
@ -161,7 +161,7 @@ public class AnySilentChest {
|
||||||
player.openContainer(tileInventory);
|
player.openContainer(tileInventory);
|
||||||
|
|
||||||
if (anyChest && plugin.getConfiguration().notifyAnyChest()) {
|
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;
|
return returnValue;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: OpenInv
|
name: OpenInv
|
||||||
main: com.lishid.openinv.OpenInv
|
main: com.lishid.openinv.OpenInv
|
||||||
version: 2.3.6
|
version: 2.3.7
|
||||||
author: lishid
|
author: lishid
|
||||||
authors: [ShadowRanger]
|
authors: [ShadowRanger]
|
||||||
description: >
|
description: >
|
||||||
|
|
Loading…
Reference in a new issue