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

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 void onDisable() {
}
private void setupPermissions() {
Plugin permissionsPlugin = this.getServer().getPluginManager().getPlugin("Permissions");
@@ -63,7 +63,7 @@ public class OpenInv extends JavaPlugin {
getCommand("toggleopeninv").setExecutor(new OpenInvPluginCommand(this));
getCommand("silentchest").setExecutor(new SilentChestPluginCommand(this));
}
public static void ReplaceInv(CraftPlayer player)
{
try{
@@ -78,7 +78,7 @@ public class OpenInv extends JavaPlugin {
entityplayer.a(entityplayer.activeContainer, entityplayer.activeContainer.b());
entityplayer.activeContainer.a();
entityplayer.defaultContainer.a();
player.setHandle(entityplayer);
}
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());
}
}
public static boolean GetPlayerItemOpenInvStatus(String name)
{
return mainPlugin.getConfig().getBoolean("ItemOpenInv." + name.toLowerCase() + ".toggle", false);
}
public static void SetPlayerItemOpenInvStatus(String name, boolean 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);
}
public static void SetPlayerSilentChestStatus(String name, boolean status)
{
mainPlugin.getConfig().set("SilentChest." + name.toLowerCase() + ".toggle", status);
mainPlugin.saveConfig();
}
public static int GetItemOpenInvItem()
{
if(mainPlugin.getConfig().get("ItemOpenInvItemID") == null)
@@ -117,7 +117,7 @@ public class OpenInv extends JavaPlugin {
}
return mainPlugin.getConfig().getInt("ItemOpenInvItemID", 280);
}
public static Object GetFromConfig(String data, Object defaultValue)
{
Object val = mainPlugin.getConfig().get(data);
@@ -131,7 +131,7 @@ public class OpenInv extends JavaPlugin {
return val;
}
}
public static void SaveToConfig(String data, Object value)
{
mainPlugin.getConfig().set(data, value);

View File

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

View File

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