diff --git a/Plugin/pom.xml b/Plugin/pom.xml index 3fe72f07..c905e57c 100644 --- a/Plugin/pom.xml +++ b/Plugin/pom.xml @@ -4,7 +4,7 @@ com.lishid orebfuscator - 4.2.0-SNAPSHOT + 4.2.1-SNAPSHOT jar Orebfuscator4 diff --git a/Plugin/src/main/java/com/lishid/orebfuscator/commands/OrebfuscatorCommandExecutor.java b/Plugin/src/main/java/com/lishid/orebfuscator/commands/OrebfuscatorCommandExecutor.java index 449941cd..fcacbe45 100644 --- a/Plugin/src/main/java/com/lishid/orebfuscator/commands/OrebfuscatorCommandExecutor.java +++ b/Plugin/src/main/java/com/lishid/orebfuscator/commands/OrebfuscatorCommandExecutor.java @@ -18,10 +18,16 @@ import java.io.IOException; +import net.md_5.bungee.api.ChatColor; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.World; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import com.lishid.orebfuscator.DeprecatedMethods; import com.lishid.orebfuscator.Orebfuscator; import com.lishid.orebfuscator.cache.ObfuscatedDataCache; @@ -91,29 +97,35 @@ else if (args[0].equalsIgnoreCase("enable") || args[0].equalsIgnoreCase("disable if (args[0].equalsIgnoreCase("enable") && args.length == 1) { Orebfuscator.configManager.setEnabled(true); Orebfuscator.message(sender, "Enabled."); + return true; } else if (args[0].equalsIgnoreCase("disable") && args.length == 1) { Orebfuscator.configManager.setEnabled(false); Orebfuscator.message(sender, "Disabled."); + return true; } else if (args.length > 1) { if (args[1].equalsIgnoreCase("op")) { Orebfuscator.configManager.setNoObfuscationForOps(data); Orebfuscator.message(sender, "Ops No-Obfuscation " + (data ? "enabled" : "disabled") + "."); + return true; } else if (args[1].equalsIgnoreCase("perms") || args[1].equalsIgnoreCase("permissions")) { Orebfuscator.configManager.setNoObfuscationForPermission(data); Orebfuscator.message(sender, "Permissions No-Obfuscation " + (data ? "enabled" : "disabled") + "."); + return true; } else if (args[1].equalsIgnoreCase("cache")) { Orebfuscator.configManager.setUseCache(data); Orebfuscator.message(sender, "Cache " + (data ? "enabled" : "disabled") + "."); + return true; } else if (args[1].equalsIgnoreCase("notification")) { Orebfuscator.configManager.setLoginNotification(data); Orebfuscator.message(sender, "Login Notification " + (data ? "enabled" : "disabled") + "."); + return true; } } } @@ -121,6 +133,7 @@ else if (args[1].equalsIgnoreCase("notification")) { else if (args[0].equalsIgnoreCase("reload")) { Orebfuscator.instance.reloadOrebfuscatorConfig(); Orebfuscator.message(sender, "Reload complete."); + return true; } else if (args[0].equalsIgnoreCase("status")) { @@ -150,6 +163,8 @@ else if (args[0].equalsIgnoreCase("status")) { Orebfuscator.message(sender, "Worlds: " + (worlds.equals("") ? "None" : worlds)); Orebfuscator.message(sender, "Use worlds as: " + (Orebfuscator.config.getDefaultWorld().isEnabled() ? "Blacklist" : "Whitelist")); + + return true; } else if (args[0].equalsIgnoreCase("clearcache")) { @@ -159,8 +174,50 @@ else if (args[0].equalsIgnoreCase("clearcache")) { } catch (IOException e) { e.printStackTrace(); } + + return true; + } + + else if (args[0].equalsIgnoreCase("obfuscateblocks")) { + if(args.length == 1) { + Orebfuscator.message(sender, ChatColor.RED + "World is required parameter."); + } else { + String worldName = args[1]; + World world = Bukkit.getWorld(worldName); + + if(world == null) { + Orebfuscator.message(sender, ChatColor.RED + "Specified world is not found."); + } else { + if(args.length > 2) { + Material material = Material.getMaterial(args[2]); + + if(material == null) { + Orebfuscator.message(sender, ChatColor.RED + "Specified material is not found."); + } else { + int materialId = DeprecatedMethods.getMaterialId(material); + + if(Orebfuscator.configManager.getWorld(world).isObfuscated(materialId)) + Orebfuscator.message(sender, material.name() + ": " + ChatColor.GREEN + "obfuscate"); + else + Orebfuscator.message(sender, material.name() + ": " + ChatColor.RED + "not obfuscate"); + } + } else { + boolean[] blocks = Orebfuscator.configManager.getWorld(world).getObfuscateAndProximityBlocks(); + + Orebfuscator.message(sender, ChatColor.GREEN + "Obfuscate blocks:"); + + for(int i = 0; i < blocks.length; i++) { + if(blocks[i]) { + Orebfuscator.message(sender, " - " + DeprecatedMethods.getMaterial(i).name()); + } + } + } + } + } + + return true; } - return true; + return false; } } \ No newline at end of file diff --git a/Plugin/src/main/java/com/lishid/orebfuscator/config/WorldConfig.java b/Plugin/src/main/java/com/lishid/orebfuscator/config/WorldConfig.java index 6b02a4f1..b8b84b35 100644 --- a/Plugin/src/main/java/com/lishid/orebfuscator/config/WorldConfig.java +++ b/Plugin/src/main/java/com/lishid/orebfuscator/config/WorldConfig.java @@ -172,6 +172,10 @@ private void setObfuscateAndProximityBlocks() { } } + public boolean[] getObfuscateAndProximityBlocks() { + return this.obfuscateAndProximityBlocks; + } + public boolean[] getDarknessBlocks() { return this.darknessBlocks; } diff --git a/Plugin/src/main/java/com/lishid/orebfuscator/config/WorldReader.java b/Plugin/src/main/java/com/lishid/orebfuscator/config/WorldReader.java index 6ca66a35..77ef2a64 100644 --- a/Plugin/src/main/java/com/lishid/orebfuscator/config/WorldReader.java +++ b/Plugin/src/main/java/com/lishid/orebfuscator/config/WorldReader.java @@ -15,10 +15,12 @@ import java.util.logging.Level; import java.util.logging.Logger; +import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.plugin.java.JavaPlugin; +import com.lishid.orebfuscator.DeprecatedMethods; import com.lishid.orebfuscator.utils.Globals; public class WorldReader { @@ -102,7 +104,7 @@ private WorldConfig readWorldByType(Set keys, WorldType worldType, World world.setDefaults(); } - world = readWorld(worldPath, world, worldType == WorldType.Default); + world = readWorld(worldPath, world, worldType, worldType == WorldType.Default); break; } } @@ -140,7 +142,7 @@ private void readWorldsByName(String worldPath) { String key = name.toLowerCase(); if(!this.worlds.containsKey(key)) { - this.worlds.put(key, readWorld(worldPath, null, false)); + this.worlds.put(key, readWorld(worldPath, null, WorldType.Default, false)); } } } @@ -170,7 +172,7 @@ private List parseWorldTypes(List types) { return parsedTypes; } - private WorldConfig readWorld(String worldPath, WorldConfig cfg, boolean withSave) { + private WorldConfig readWorld(String worldPath, WorldConfig cfg, WorldType worldType, boolean withSave) { if(cfg == null) { cfg = new WorldConfig(); } @@ -183,6 +185,20 @@ private WorldConfig readWorld(String worldPath, WorldConfig cfg, boolean withSav Integer mode1Block = this.materialReader.getMaterialIdByPath(worldPath + ".Mode1Block", cfg.getMode1BlockId(), withSave); Integer[] randomBlocks = this.materialReader.getMaterialIdsByPath(worldPath + ".RandomBlocks", cfg.getRandomBlocks(), withSave); boolean[] obfuscateBlocks = readBlockMatrix(cfg.getObfuscateBlocks(), cfg.getObfuscateBlockIds(), worldPath + ".ObfuscateBlocks", withSave); + + switch(worldType) { + case Normal: + obfuscateBlocks[DeprecatedMethods.getMaterialId(Material.STONE)] = true; + break; + case TheEnd: + obfuscateBlocks[DeprecatedMethods.getMaterialId(Material.ENDER_STONE)] = true; + break; + case Nether: + obfuscateBlocks[DeprecatedMethods.getMaterialId(Material.NETHERRACK)] = true; + break; + default: + break; + } readProximityHider(worldPath, cfg, withSave); @@ -277,7 +293,7 @@ private WorldConfig createDefaultWorld(String worldPath) { WorldConfig world = new WorldConfig(); world.setDefaults(); - return readWorld(worldPath, world, true); + return readWorld(worldPath, world, WorldType.Default, true); } private WorldConfig createNormalWorld(String worldPath) { @@ -294,8 +310,6 @@ private WorldConfig createNormalWorld(String worldPath) { setBlockValues(obfuscateBlocks, obfuscateBlockIds, false); - obfuscateBlocks[1] = true; - WorldConfig cfg = new WorldConfig(); cfg.setObfuscateBlocks(obfuscateBlocks); cfg.setRandomBlocks(randomBlocks); @@ -318,8 +332,6 @@ private WorldConfig createEndWorld(String worldPath) { setBlockValues(obfuscateBlocks, obfuscateBlockIds, false); - obfuscateBlocks[121] = true; - WorldConfig cfg = new WorldConfig(); cfg.setRandomBlocks(randomBlocks); cfg.setObfuscateBlocks(obfuscateBlocks); @@ -342,8 +354,6 @@ private WorldConfig createNetherWorld(String worldPath) { setBlockValues(obfuscateBlocks, obfuscateBlockIds, false); - obfuscateBlocks[87] = true; - WorldConfig cfg = new WorldConfig(); cfg.setRandomBlocks(randomBlocks); cfg.setObfuscateBlocks(obfuscateBlocks); diff --git a/Plugin/src/main/java/com/lishid/orebfuscator/obfuscation/Calculations.java b/Plugin/src/main/java/com/lishid/orebfuscator/obfuscation/Calculations.java index 99583975..195973fc 100644 --- a/Plugin/src/main/java/com/lishid/orebfuscator/obfuscation/Calculations.java +++ b/Plugin/src/main/java/com/lishid/orebfuscator/obfuscation/Calculations.java @@ -158,7 +158,7 @@ private static byte[] obfuscate(ChunkData chunkData, Player player, ArrayList