Issue #135: Plugin doesnt work unless you delete the config and force reload and clearcache after startup
parent
ce1b92ad2d
commit
281497b4e8
|
@ -4,7 +4,7 @@
|
|||
|
||||
<groupId>com.lishid</groupId>
|
||||
<artifactId>orebfuscator</artifactId>
|
||||
<version>4.2.0-SNAPSHOT</version>
|
||||
<version>4.2.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Orebfuscator4</name>
|
||||
|
|
|
@ -18,10 +18,16 @@ package com.lishid.orebfuscator.commands;
|
|||
|
||||
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 @@ public class OrebfuscatorCommandExecutor {
|
|||
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 @@ public class OrebfuscatorCommandExecutor {
|
|||
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 @@ public class OrebfuscatorCommandExecutor {
|
|||
|
||||
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 @@ public class OrebfuscatorCommandExecutor {
|
|||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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 false;
|
||||
}
|
||||
}
|
|
@ -172,6 +172,10 @@ public class WorldConfig {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean[] getObfuscateAndProximityBlocks() {
|
||||
return this.obfuscateAndProximityBlocks;
|
||||
}
|
||||
|
||||
public boolean[] getDarknessBlocks() {
|
||||
return this.darknessBlocks;
|
||||
}
|
||||
|
|
|
@ -15,10 +15,12 @@ import java.util.WeakHashMap;
|
|||
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 @@ public class WorldReader {
|
|||
world.setDefaults();
|
||||
}
|
||||
|
||||
world = readWorld(worldPath, world, worldType == WorldType.Default);
|
||||
world = readWorld(worldPath, world, worldType, worldType == WorldType.Default);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +142,7 @@ public class WorldReader {
|
|||
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 @@ public class WorldReader {
|
|||
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 @@ public class WorldReader {
|
|||
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 @@ public class WorldReader {
|
|||
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 @@ public class WorldReader {
|
|||
|
||||
setBlockValues(obfuscateBlocks, obfuscateBlockIds, false);
|
||||
|
||||
obfuscateBlocks[1] = true;
|
||||
|
||||
WorldConfig cfg = new WorldConfig();
|
||||
cfg.setObfuscateBlocks(obfuscateBlocks);
|
||||
cfg.setRandomBlocks(randomBlocks);
|
||||
|
@ -318,8 +332,6 @@ public class WorldReader {
|
|||
|
||||
setBlockValues(obfuscateBlocks, obfuscateBlockIds, false);
|
||||
|
||||
obfuscateBlocks[121] = true;
|
||||
|
||||
WorldConfig cfg = new WorldConfig();
|
||||
cfg.setRandomBlocks(randomBlocks);
|
||||
cfg.setObfuscateBlocks(obfuscateBlocks);
|
||||
|
@ -342,8 +354,6 @@ public class WorldReader {
|
|||
|
||||
setBlockValues(obfuscateBlocks, obfuscateBlockIds, false);
|
||||
|
||||
obfuscateBlocks[87] = true;
|
||||
|
||||
WorldConfig cfg = new WorldConfig();
|
||||
cfg.setRandomBlocks(randomBlocks);
|
||||
cfg.setObfuscateBlocks(obfuscateBlocks);
|
||||
|
|
|
@ -158,7 +158,7 @@ public class Calculations {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check if the block should be obfuscated because of proximity check
|
||||
if (!obfuscate && proximityHider.isEnabled() && proximityHider.isProximityObfuscated(y, blockState.id)) {
|
||||
BlockCoord block = new BlockCoord(x, y, z);
|
||||
|
|
Loading…
Reference in New Issue