Hi! I cleaned up your code for you! #2

Closed
GunioRobot wants to merge 1 commits from clean into master
4 changed files with 81 additions and 31 deletions
Showing only changes of commit 3ec34a8794 - Show all commits

50
.gitignore vendored Normal file
View File

@@ -0,0 +1,50 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.pyc
# Numerous always-ignore extensions
###################
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.vi
*~
*.sass-cache
# Folders to ignore
###################
.hg
.svn
.CVS
# OS or Editor folders
###################
.DS_Store
Icon?
Thumbs.db
ehthumbs.db
nbproject
.cache
.project
.settings
.tmproj
*.esproj
*.sublime-project
*.sublime-workspace
# Dreamweaver added files
###################
_notes
dwsync.xml
# Komodo
###################
*.komodoproject
.komodotools

View File

@@ -29,7 +29,7 @@ public class OpenInv extends JavaPlugin {
public static OpenInv mainPlugin; public static OpenInv mainPlugin;
public void onDisable() { public void onDisable() {
} }
private void setupPermissions() { private void setupPermissions() {
Plugin permissionsPlugin = this.getServer().getPluginManager().getPlugin("Permissions"); Plugin permissionsPlugin = this.getServer().getPluginManager().getPlugin("Permissions");
@@ -63,7 +63,7 @@ public class OpenInv extends JavaPlugin {
getCommand("toggleopeninv").setExecutor(new OpenInvPluginCommand(this)); getCommand("toggleopeninv").setExecutor(new OpenInvPluginCommand(this));
getCommand("silentchest").setExecutor(new SilentChestPluginCommand(this)); getCommand("silentchest").setExecutor(new SilentChestPluginCommand(this));
} }
public static void ReplaceInv(CraftPlayer player) public static void ReplaceInv(CraftPlayer player)
{ {
try{ try{
@@ -78,7 +78,7 @@ public class OpenInv extends JavaPlugin {
entityplayer.a(entityplayer.activeContainer, entityplayer.activeContainer.b()); entityplayer.a(entityplayer.activeContainer, entityplayer.activeContainer.b());
entityplayer.activeContainer.a(); entityplayer.activeContainer.a();
entityplayer.defaultContainer.a(); entityplayer.defaultContainer.a();
player.setHandle(entityplayer); player.setHandle(entityplayer);
} }
catch(Exception e) catch(Exception e)
@@ -86,12 +86,12 @@ public class OpenInv extends JavaPlugin {
System.out.println("[OpenInv] Error while trying to override player inventory, error: " + e.getMessage()); System.out.println("[OpenInv] Error while trying to override player inventory, error: " + e.getMessage());
} }
} }
public static boolean GetPlayerItemOpenInvStatus(String name) public static boolean GetPlayerItemOpenInvStatus(String name)
{ {
return mainPlugin.getConfig().getBoolean("ItemOpenInv." + name.toLowerCase() + ".toggle", false); return mainPlugin.getConfig().getBoolean("ItemOpenInv." + name.toLowerCase() + ".toggle", false);
} }
public static void SetPlayerItemOpenInvStatus(String name, boolean status) public static void SetPlayerItemOpenInvStatus(String name, boolean status)
{ {
mainPlugin.getConfig().set("ItemOpenInv." + name.toLowerCase() + ".toggle", status); mainPlugin.getConfig().set("ItemOpenInv." + name.toLowerCase() + ".toggle", status);
@@ -102,13 +102,13 @@ public class OpenInv extends JavaPlugin {
{ {
return mainPlugin.getConfig().getBoolean("SilentChest." + name.toLowerCase() + ".toggle", false); return mainPlugin.getConfig().getBoolean("SilentChest." + name.toLowerCase() + ".toggle", false);
} }
public static void SetPlayerSilentChestStatus(String name, boolean status) public static void SetPlayerSilentChestStatus(String name, boolean status)
{ {
mainPlugin.getConfig().set("SilentChest." + name.toLowerCase() + ".toggle", status); mainPlugin.getConfig().set("SilentChest." + name.toLowerCase() + ".toggle", status);
mainPlugin.saveConfig(); mainPlugin.saveConfig();
} }
public static int GetItemOpenInvItem() public static int GetItemOpenInvItem()
{ {
if(mainPlugin.getConfig().get("ItemOpenInvItemID") == null) if(mainPlugin.getConfig().get("ItemOpenInvItemID") == null)
@@ -117,7 +117,7 @@ public class OpenInv extends JavaPlugin {
} }
return mainPlugin.getConfig().getInt("ItemOpenInvItemID", 280); return mainPlugin.getConfig().getInt("ItemOpenInvItemID", 280);
} }
public static Object GetFromConfig(String data, Object defaultValue) public static Object GetFromConfig(String data, Object defaultValue)
{ {
Object val = mainPlugin.getConfig().get(data); Object val = mainPlugin.getConfig().get(data);
@@ -131,7 +131,7 @@ public class OpenInv extends JavaPlugin {
return val; return val;
} }
} }
public static void SaveToConfig(String data, Object value) public static void SaveToConfig(String data, Object value)
{ {
mainPlugin.getConfig().set(data, value); mainPlugin.getConfig().set(data, value);

View File

@@ -27,25 +27,25 @@ public class OpenInvPluginCommand implements CommandExecutor {
public OpenInvPluginCommand(OpenInv plugin) { public OpenInvPluginCommand(OpenInv plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!PermissionRelay.hasPermission((Player) sender, "OpenInv.openinv")) { if (!PermissionRelay.hasPermission((Player) sender, "OpenInv.openinv")) {
sender.sendMessage(ChatColor.RED + "You do not have permission to access player inventories"); sender.sendMessage(ChatColor.RED + "You do not have permission to access player inventories");
return true; return true;
} }
boolean Offline = false; boolean Offline = false;
Player player = (Player)sender; Player player = (Player)sender;
//History management //History management
OpenInvHistory history = theOpenInvHistory.get(player); OpenInvHistory history = theOpenInvHistory.get(player);
if(history == null) if(history == null)
{ {
history = new OpenInvHistory(player); history = new OpenInvHistory(player);
theOpenInvHistory.put(player, history); theOpenInvHistory.put(player, history);
} }
//Toggleopeninv command //Toggleopeninv command
if(command.getName().equalsIgnoreCase("toggleopeninv")) if(command.getName().equalsIgnoreCase("toggleopeninv"))
{ {
@@ -74,9 +74,9 @@ public class OpenInvPluginCommand implements CommandExecutor {
//Target selecting //Target selecting
Player target; Player target;
String name = ""; String name = "";
if (args.length < 1) { if (args.length < 1) {
if(history.lastPlayer != null) if(history.lastPlayer != null)
{ {
@@ -92,7 +92,7 @@ public class OpenInvPluginCommand implements CommandExecutor {
{ {
name = args[0]; name = args[0];
} }
target = this.plugin.getServer().getPlayer(name); target = this.plugin.getServer().getPlayer(name);
@@ -129,21 +129,21 @@ public class OpenInvPluginCommand implements CommandExecutor {
return true; return true;
} }
} }
//Check if target is the player him/her self //Check if target is the player him/her self
if(target == player) if(target == player)
{ {
sender.sendMessage(ChatColor.RED + "Cannot OpenInv yourself!"); sender.sendMessage(ChatColor.RED + "Cannot OpenInv yourself!");
return true; return true;
} }
//Permissions checks //Permissions checks
if (!PermissionRelay.hasPermission(player, "OpenInv.override") && PermissionRelay.hasPermission(target, "OpenInv.exempt")) { if (!PermissionRelay.hasPermission(player, "OpenInv.override") && PermissionRelay.hasPermission(target, "OpenInv.exempt")) {
sender.sendMessage(ChatColor.RED + target.getDisplayName() + "'s inventory is protected!"); sender.sendMessage(ChatColor.RED + target.getDisplayName() + "'s inventory is protected!");
return true; return true;
} }
if((!PermissionRelay.hasPermission(player, "OpenInv.crossworld") && !PermissionRelay.hasPermission(player, "OpenInv.override")) && if((!PermissionRelay.hasPermission(player, "OpenInv.crossworld") && !PermissionRelay.hasPermission(player, "OpenInv.override")) &&
target.getWorld() != player.getWorld()){ target.getWorld() != player.getWorld()){
sender.sendMessage(ChatColor.RED + target.getDisplayName() + " is not in your world!"); sender.sendMessage(ChatColor.RED + target.getDisplayName() + " is not in your world!");
return true; return true;
@@ -151,30 +151,30 @@ public class OpenInvPluginCommand implements CommandExecutor {
//The actual openinv //The actual openinv
history.lastPlayer = target.getName(); history.lastPlayer = target.getName();
// Get the EntityPlayer handle from the sender // Get the EntityPlayer handle from the sender
EntityPlayer entityplayer = ((CraftPlayer) player).getHandle(); EntityPlayer entityplayer = ((CraftPlayer) player).getHandle();
// Get the EntityPlayer from the Target // Get the EntityPlayer from the Target
EntityPlayer entitytarget = ((CraftPlayer) target).getHandle(); EntityPlayer entitytarget = ((CraftPlayer) target).getHandle();
if(!(entitytarget.inventory instanceof PlayerInventoryChest)) if(!(entitytarget.inventory instanceof PlayerInventoryChest))
{ {
OpenInv.ReplaceInv((CraftPlayer) target); OpenInv.ReplaceInv((CraftPlayer) target);
} }
if(entitytarget.inventory instanceof PlayerInventoryChest) if(entitytarget.inventory instanceof PlayerInventoryChest)
{ {
((PlayerInventoryChest)entitytarget.inventory).Opener = player; ((PlayerInventoryChest)entitytarget.inventory).Opener = player;
((PlayerInventoryChest)entitytarget.inventory).Target = target; ((PlayerInventoryChest)entitytarget.inventory).Target = target;
if(Offline) if(Offline)
{ {
((PlayerInventoryChest)entitytarget.inventory).Offline = true; ((PlayerInventoryChest)entitytarget.inventory).Offline = true;
offlineInv.put((PlayerInventoryChest) entitytarget.inventory, target); offlineInv.put((PlayerInventoryChest) entitytarget.inventory, target);
} }
} }
entityplayer.a(entitytarget.inventory); entityplayer.a(entitytarget.inventory);
return true; return true;

View File

@@ -15,15 +15,15 @@ public class SearchInvPluginCommand implements CommandExecutor {
public SearchInvPluginCommand(OpenInv plugin) { public SearchInvPluginCommand(OpenInv plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!PermissionRelay.hasPermission((Player) sender, "OpenInv.search")) { if (!PermissionRelay.hasPermission((Player) sender, "OpenInv.search")) {
sender.sendMessage(ChatColor.RED + "You do not have permission to access player inventories"); sender.sendMessage(ChatColor.RED + "You do not have permission to access player inventories");
return true; return true;
} }
String PlayerList = ""; String PlayerList = "";
Material material = null; Material material = null;
int count = 1; int count = 1;
@@ -40,7 +40,7 @@ public class SearchInvPluginCommand implements CommandExecutor {
return false; return false;
} }
} }
if (material == null) { if (material == null) {
sender.sendMessage(ChatColor.RED + "Unknown item"); sender.sendMessage(ChatColor.RED + "Unknown item");
return false; return false;
@@ -53,7 +53,7 @@ public class SearchInvPluginCommand implements CommandExecutor {
PlayerList += templayer.getName() + " "; PlayerList += templayer.getName() + " ";
} }
} }
sender.sendMessage("Players with the item " + material.toString() + ": " + PlayerList); sender.sendMessage("Players with the item " + material.toString() + ": " + PlayerList);
return true; return true;
} }