commit
e22ffbfb2f
|
@ -4,7 +4,7 @@
|
|||
|
||||
<groupId>com.lishid</groupId>
|
||||
<artifactId>orebfuscator</artifactId>
|
||||
<version>4.1.10-SNAPSHOT</version>
|
||||
<version>4.1.14-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Orebfuscator4</name>
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package com.lishid.orebfuscator;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -27,6 +28,8 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||
import com.lishid.orebfuscator.cache.CacheCleaner;
|
||||
import com.lishid.orebfuscator.cache.ObfuscatedDataCache;
|
||||
import com.lishid.orebfuscator.commands.OrebfuscatorCommandExecutor;
|
||||
import com.lishid.orebfuscator.config.ConfigManager;
|
||||
import com.lishid.orebfuscator.config.OrebfuscatorConfig;
|
||||
import com.lishid.orebfuscator.hithack.BlockHitManager;
|
||||
import com.lishid.orebfuscator.hook.ProtocolLibHook;
|
||||
import com.lishid.orebfuscator.listeners.OrebfuscatorBlockListener;
|
||||
|
@ -34,6 +37,7 @@ import com.lishid.orebfuscator.listeners.OrebfuscatorChunkListener;
|
|||
import com.lishid.orebfuscator.listeners.OrebfuscatorEntityListener;
|
||||
import com.lishid.orebfuscator.listeners.OrebfuscatorPlayerListener;
|
||||
import com.lishid.orebfuscator.nms.INmsManager;
|
||||
import com.lishid.orebfuscator.utils.Globals;
|
||||
|
||||
/**
|
||||
* Orebfuscator Anti X-RAY
|
||||
|
@ -44,6 +48,8 @@ public class Orebfuscator extends JavaPlugin {
|
|||
|
||||
public static final Logger logger = Logger.getLogger("Minecraft.OFC");
|
||||
public static Orebfuscator instance;
|
||||
public static OrebfuscatorConfig config;
|
||||
public static ConfigManager configManager;
|
||||
|
||||
public static INmsManager nms;
|
||||
|
||||
|
@ -62,7 +68,7 @@ public class Orebfuscator extends JavaPlugin {
|
|||
nms = createNmsManager();
|
||||
|
||||
// Load configurations
|
||||
OrebfuscatorConfig.load();
|
||||
loadOrebfuscatorConfig();
|
||||
|
||||
this.isProtocolLibFound = pm.getPlugin("ProtocolLib") != null;
|
||||
|
||||
|
@ -76,13 +82,38 @@ public class Orebfuscator extends JavaPlugin {
|
|||
pm.registerEvents(new OrebfuscatorEntityListener(), this);
|
||||
pm.registerEvents(new OrebfuscatorBlockListener(), this);
|
||||
pm.registerEvents(new OrebfuscatorChunkListener(), this);
|
||||
|
||||
|
||||
(new ProtocolLibHook()).register(this);
|
||||
|
||||
// Run CacheCleaner
|
||||
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new CacheCleaner(), 0, OrebfuscatorConfig.CacheCleanRate);
|
||||
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new CacheCleaner(), 0, config.getCacheCleanRate());
|
||||
}
|
||||
|
||||
public void loadOrebfuscatorConfig() {
|
||||
if(config == null) {
|
||||
config = new OrebfuscatorConfig();
|
||||
configManager = new ConfigManager(this, logger, config);
|
||||
}
|
||||
|
||||
configManager.load();
|
||||
|
||||
ObfuscatedDataCache.resetCacheFolder();
|
||||
|
||||
nms.setMaxLoadedCacheFiles(config.getMaxLoadedCacheFiles());
|
||||
|
||||
//Make sure cache is cleared if config was changed since last start
|
||||
try {
|
||||
ObfuscatedDataCache.checkCacheAndConfigSynchronized();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void reloadOrebfuscatorConfig() {
|
||||
reloadConfig();
|
||||
loadOrebfuscatorConfig();
|
||||
}
|
||||
|
||||
private static INmsManager createNmsManager() {
|
||||
|
||||
String serverVersion = org.bukkit.Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
|
@ -121,14 +152,14 @@ public class Orebfuscator extends JavaPlugin {
|
|||
* Log an information
|
||||
*/
|
||||
public static void log(String text) {
|
||||
logger.info("[OFC] " + text);
|
||||
logger.info(Globals.LogPrefix + text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an error
|
||||
*/
|
||||
public static void log(Throwable e) {
|
||||
logger.severe("[OFC] " + e.toString());
|
||||
logger.severe(Globals.LogPrefix + e.toString());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -136,6 +167,6 @@ public class Orebfuscator extends JavaPlugin {
|
|||
* Send a message to a player
|
||||
*/
|
||||
public static void message(CommandSender target, String message) {
|
||||
target.sendMessage(ChatColor.AQUA + "[OFC] " + message);
|
||||
target.sendMessage(ChatColor.AQUA + Globals.LogPrefix + message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,704 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2011-2014 lishid. All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.lishid.orebfuscator;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.lishid.orebfuscator.cache.ObfuscatedDataCache;
|
||||
|
||||
public class OrebfuscatorConfig {
|
||||
private static class MaterialResult {
|
||||
public int id;
|
||||
public String name;
|
||||
|
||||
public MaterialResult(int id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
// Constant/persistent data
|
||||
private static final int CONFIG_VERSION = 12;
|
||||
private static Random random = new Random();
|
||||
|
||||
// Main engine config
|
||||
public static boolean Enabled = true;
|
||||
public static boolean UpdateOnDamage = true;
|
||||
public static int EngineMode = 2;
|
||||
public static int InitialRadius = 1;
|
||||
public static int UpdateRadius = 2;
|
||||
public static boolean UseWorldsAsBlacklist = true;
|
||||
public static boolean NoObfuscationForMetadata = true;
|
||||
public static String NoObfuscationForMetadataTagName = "NPC";
|
||||
|
||||
// Darkness
|
||||
public static boolean DarknessHideBlocks = false;
|
||||
|
||||
// Caching
|
||||
public static boolean UseCache = true;
|
||||
public static int MaxLoadedCacheFiles = 64;
|
||||
public static String CacheLocation = "orebfuscator_cache";
|
||||
public static File CacheFolder = new File(Bukkit.getServer().getWorldContainer(), CacheLocation);
|
||||
public static int DeleteCacheFilesAfterDays = 0;
|
||||
|
||||
// ProximityHider
|
||||
public static int ProximityHiderRate = 500;
|
||||
public static int ProximityHiderDistance = 8;
|
||||
public static int ProximityHiderID = 1;
|
||||
public static int ProximityHiderEnd = 255;
|
||||
public static boolean UseProximityHider = true;
|
||||
public static boolean UseSpecialBlockForProximityHider = true;
|
||||
public static boolean UseYLocationProximity = false;
|
||||
|
||||
// AntiTexturePackAndFreecam
|
||||
public static boolean AntiTexturePackAndFreecam = true;
|
||||
public static int AirGeneratorMaxChance = 43;
|
||||
|
||||
// Misc
|
||||
public static boolean NoObfuscationForOps = false;
|
||||
public static boolean NoObfuscationForPermission = false;
|
||||
public static boolean LoginNotification = true;
|
||||
|
||||
// Anti Hit Hack
|
||||
public static int AntiHitHackDecrementFactor = 1000;
|
||||
public static int AntiHitHackMaxViolation = 15;
|
||||
|
||||
// Utilities
|
||||
private static boolean[] ObfuscateBlocks = new boolean[256];
|
||||
private static boolean[] NetherObfuscateBlocks = new boolean[256];
|
||||
private static boolean[] DarknessBlocks = new boolean[256];
|
||||
private static boolean[] ProximityHiderBlocks = new boolean[256];
|
||||
private static Integer[] RandomBlocks = new Integer[]{1, 4, 5, 14, 15, 16, 21, 46, 48, 49, 56, 73, 82, 129};
|
||||
private static Integer[] NetherRandomBlocks = new Integer[]{13, 87, 88, 112, 153};
|
||||
private static Integer[] RandomBlocks2 = RandomBlocks;
|
||||
private static List<String> Worlds = new ArrayList<String>();
|
||||
|
||||
// Palette
|
||||
public static int[] NetherPaletteBlocks;
|
||||
public static int[] NormalPaletteBlocks;
|
||||
|
||||
// ChunkReloader
|
||||
public static int ChunkReloaderRate = 500;
|
||||
public static boolean UseChunkReloader = false;
|
||||
|
||||
// CacheCleaner
|
||||
public static long CacheCleanRate = 60 * 60 * 20;//once per hour
|
||||
|
||||
public static File getCacheFolder() {
|
||||
// Try to make the folder
|
||||
if (!CacheFolder.exists()) {
|
||||
CacheFolder.mkdirs();
|
||||
}
|
||||
// Can't make folder? Use default
|
||||
if (!CacheFolder.exists()) {
|
||||
CacheFolder = new File("orebfuscator_cache");
|
||||
}
|
||||
return CacheFolder;
|
||||
}
|
||||
|
||||
private static boolean[] TransparentBlocks;
|
||||
private static boolean[] TransparentBlocksMode1;
|
||||
private static boolean[] TransparentBlocksMode2;
|
||||
|
||||
public static boolean isBlockTransparent(int id) {
|
||||
if (id < 0)
|
||||
id += 256;
|
||||
|
||||
if (id >= 256) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return TransparentBlocks[id];
|
||||
}
|
||||
|
||||
private static void generateTransparentBlocks() {
|
||||
if(TransparentBlocks == null) {
|
||||
readInitialTransparentBlocks();
|
||||
}
|
||||
|
||||
boolean[] transparentBlocks = EngineMode == 1
|
||||
? TransparentBlocksMode1
|
||||
: TransparentBlocksMode2;
|
||||
|
||||
System.arraycopy(transparentBlocks, 0, TransparentBlocks, 0, TransparentBlocks.length);
|
||||
|
||||
List<Integer> customTransparentBlocks = getMaterialIdsByPath("Lists.TransparentBlocks", new Integer[]{ });
|
||||
|
||||
for(int blockId : customTransparentBlocks) {
|
||||
if(blockId >= 0 && blockId <= 255) {
|
||||
TransparentBlocks[blockId] = true;
|
||||
}
|
||||
}
|
||||
|
||||
List<Integer> customNonTransparentBlocks = getMaterialIdsByPath("Lists.NonTransparentBlocks", new Integer[]{ });
|
||||
|
||||
for(int blockId : customNonTransparentBlocks) {
|
||||
if(blockId >= 0 && blockId <= 255) {
|
||||
TransparentBlocks[blockId] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void readInitialTransparentBlocks() {
|
||||
TransparentBlocks = new boolean[256];
|
||||
Arrays.fill(TransparentBlocks, false);
|
||||
|
||||
InputStream mainStream = Orebfuscator.class.getResourceAsStream("/resources/transparent_blocks.txt");
|
||||
readTransparentBlocks(TransparentBlocks, mainStream);
|
||||
|
||||
TransparentBlocksMode1 = new boolean[256];
|
||||
System.arraycopy(TransparentBlocks, 0, TransparentBlocksMode1, 0, TransparentBlocksMode1.length);
|
||||
InputStream mode1Stream = Orebfuscator.class.getResourceAsStream("/resources/transparent_blocks_mode1.txt");
|
||||
if(mode1Stream != null) readTransparentBlocks(TransparentBlocksMode1, mode1Stream);
|
||||
|
||||
TransparentBlocksMode2 = new boolean[256];
|
||||
System.arraycopy(TransparentBlocks, 0, TransparentBlocksMode2, 0, TransparentBlocksMode2.length);
|
||||
InputStream mode2Stream = Orebfuscator.class.getResourceAsStream("/resources/transparent_blocks_mode2.txt");
|
||||
if(mode2Stream != null) readTransparentBlocks(TransparentBlocksMode2, mode2Stream);
|
||||
}
|
||||
|
||||
private static void readTransparentBlocks(boolean[] transparentBlocks, InputStream stream) {
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
|
||||
String line;
|
||||
|
||||
while ((line = reader.readLine()) != null) {
|
||||
int index1 = line.indexOf(":");
|
||||
int index2 = line.indexOf(" ", index1);
|
||||
int blockId = Integer.parseInt(line.substring(0, index1));
|
||||
boolean isTransparent = line.substring(index1 + 1, index2).equals("true");
|
||||
|
||||
transparentBlocks[blockId] = isTransparent;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isObfuscated(int id, World.Environment environment) {
|
||||
if (id < 0)
|
||||
id += 256;
|
||||
|
||||
// Nether case
|
||||
if (environment == World.Environment.NETHER) {
|
||||
return id == 87 || NetherObfuscateBlocks[id];
|
||||
}
|
||||
|
||||
// Normal case
|
||||
return id == 1 || ObfuscateBlocks[id];
|
||||
}
|
||||
|
||||
public static boolean isDarknessObfuscated(int id) {
|
||||
if (id < 0)
|
||||
id += 256;
|
||||
|
||||
return DarknessBlocks[id];
|
||||
}
|
||||
|
||||
public static boolean isProximityObfuscated(int y, int id) {
|
||||
if (id < 0)
|
||||
id += 256;
|
||||
|
||||
return ProximityHiderBlocks[id];
|
||||
}
|
||||
|
||||
public static boolean isProximityHiderOn(int y, int id) {
|
||||
return (UseYLocationProximity && y >= ProximityHiderEnd) ||
|
||||
(!UseYLocationProximity && y <= ProximityHiderEnd);
|
||||
}
|
||||
|
||||
public static boolean skipProximityHiderCheck(int y) {
|
||||
return UseYLocationProximity && y < ProximityHiderEnd;
|
||||
}
|
||||
|
||||
public static boolean proximityHiderDeobfuscate() {
|
||||
return UseYLocationProximity;
|
||||
}
|
||||
|
||||
public static boolean isWorldDisabled(String name) {
|
||||
for (String world : Worlds) {
|
||||
if (world.equalsIgnoreCase(name)) {
|
||||
return UseWorldsAsBlacklist;
|
||||
}
|
||||
}
|
||||
return !UseWorldsAsBlacklist;
|
||||
}
|
||||
|
||||
public static String getWorlds() {
|
||||
String retval = "";
|
||||
for (String world : Worlds) {
|
||||
retval += world + ", ";
|
||||
}
|
||||
return retval.length() > 1 ? retval.substring(0, retval.length() - 2) : retval;
|
||||
}
|
||||
|
||||
public static int getRandomBlock(int index, boolean alternate, World.Environment environment) {
|
||||
if (environment == World.Environment.NETHER)
|
||||
return (int) (NetherRandomBlocks[index]);
|
||||
return (int) (alternate ? RandomBlocks2[index] : RandomBlocks[index]);
|
||||
}
|
||||
|
||||
public static Integer[] getRandomBlocks(boolean alternate, World.Environment environment) {
|
||||
if (environment == World.Environment.NETHER)
|
||||
return NetherRandomBlocks;
|
||||
return (alternate ? RandomBlocks2 : RandomBlocks);
|
||||
}
|
||||
|
||||
public static void shuffleRandomBlocks() {
|
||||
synchronized (RandomBlocks) {
|
||||
Collections.shuffle(Arrays.asList(RandomBlocks));
|
||||
Collections.shuffle(Arrays.asList(RandomBlocks2));
|
||||
}
|
||||
}
|
||||
|
||||
public static int random(int max) {
|
||||
return random.nextInt(max);
|
||||
}
|
||||
|
||||
// Set
|
||||
|
||||
public static void setEngineMode(int data) {
|
||||
setData("Integers.EngineMode", data);
|
||||
EngineMode = data;
|
||||
}
|
||||
|
||||
public static void setUpdateRadius(int data) {
|
||||
setData("Integers.UpdateRadius", data);
|
||||
UpdateRadius = data;
|
||||
}
|
||||
|
||||
public static void setInitialRadius(int data) {
|
||||
setData("Integers.InitialRadius", data);
|
||||
InitialRadius = data;
|
||||
}
|
||||
|
||||
public static void setProximityHiderDistance(int data) {
|
||||
setData("Integers.ProximityHiderDistance", data);
|
||||
ProximityHiderDistance = data;
|
||||
}
|
||||
|
||||
public static void setAirGeneratorMaxChance(int data) {
|
||||
setData("Integers.AirGeneratorMaxChance", data);
|
||||
AirGeneratorMaxChance = data;
|
||||
}
|
||||
|
||||
public static void setUseProximityHider(boolean data) {
|
||||
setData("Booleans.UseProximityHider", data);
|
||||
UseProximityHider = data;
|
||||
}
|
||||
|
||||
public static void setDarknessHideBlocks(boolean data) {
|
||||
setData("Booleans.DarknessHideBlocks", data);
|
||||
DarknessHideBlocks = data;
|
||||
}
|
||||
|
||||
public static void setNoObfuscationForOps(boolean data) {
|
||||
setData("Booleans.NoObfuscationForOps", data);
|
||||
NoObfuscationForOps = data;
|
||||
}
|
||||
|
||||
public static void setNoObfuscationForPermission(boolean data) {
|
||||
setData("Booleans.NoObfuscationForPermission", data);
|
||||
NoObfuscationForPermission = data;
|
||||
}
|
||||
|
||||
public static void setLoginNotification(boolean data) {
|
||||
setData("Booleans.LoginNotification", data);
|
||||
LoginNotification = data;
|
||||
}
|
||||
|
||||
public static void setAntiTexturePackAndFreecam(boolean data) {
|
||||
setData("Booleans.AntiTexturePackAndFreecam", data);
|
||||
AntiTexturePackAndFreecam = data;
|
||||
}
|
||||
|
||||
public static void setUseCache(boolean data) {
|
||||
setData("Booleans.UseCache", data);
|
||||
UseCache = data;
|
||||
}
|
||||
|
||||
public static void setEnabled(boolean data) {
|
||||
setData("Booleans.Enabled", data);
|
||||
Enabled = data;
|
||||
}
|
||||
|
||||
public static void setUseWorldsAsBlacklist(boolean data) {
|
||||
setData("Booleans.UseWorldsAsBlacklist", data);
|
||||
UseWorldsAsBlacklist = data;
|
||||
}
|
||||
|
||||
public static void setWorldEnabled(String name, boolean enabled) {
|
||||
if (enabled && !UseWorldsAsBlacklist || !enabled && UseWorldsAsBlacklist) {
|
||||
Worlds.add(name);
|
||||
} else {
|
||||
Worlds.remove(name);
|
||||
}
|
||||
setData("Lists.Worlds", Worlds);
|
||||
}
|
||||
|
||||
private static boolean getBoolean(String path, boolean defaultData) {
|
||||
if (getConfig().get(path) == null)
|
||||
setData(path, defaultData);
|
||||
return getConfig().getBoolean(path, defaultData);
|
||||
}
|
||||
|
||||
private static String getString(String path, String defaultData) {
|
||||
if (getConfig().get(path) == null)
|
||||
setData(path, defaultData);
|
||||
return getConfig().getString(path, defaultData);
|
||||
}
|
||||
|
||||
private static int getInt(String path, int defaultData) {
|
||||
if (getConfig().get(path) == null)
|
||||
setData(path, defaultData);
|
||||
return getConfig().getInt(path, defaultData);
|
||||
}
|
||||
|
||||
private static List<String> getStringList(String path, List<String> defaultData) {
|
||||
if (getConfig().get(path) == null)
|
||||
setData(path, defaultData);
|
||||
return getConfig().getStringList(path);
|
||||
}
|
||||
|
||||
private static void setData(String path, Object data) {
|
||||
try {
|
||||
getConfig().set(path, data);
|
||||
save();
|
||||
} catch (Exception e) {
|
||||
Orebfuscator.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void setBlockValues(boolean[] boolArray, List<Integer> blocks, boolean transparent) {
|
||||
for (int i = 0; i < boolArray.length; i++) {
|
||||
boolArray[i] = blocks.contains(i);
|
||||
|
||||
// If block is transparent while we don't want them to, or the other way around
|
||||
if (transparent != isBlockTransparent((short) i)) {
|
||||
// Remove it
|
||||
boolArray[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setBlockValues(boolean[] boolArray, List<Integer> blocks) {
|
||||
for (int i = 0; i < boolArray.length; i++) {
|
||||
boolArray[i] = blocks.contains(i);
|
||||
}
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
|
||||
// Version check
|
||||
int version = getInt("ConfigVersion", CONFIG_VERSION);
|
||||
if (version < CONFIG_VERSION) {
|
||||
setData("ConfigVersion", CONFIG_VERSION);
|
||||
}
|
||||
|
||||
EngineMode = getInt("Integers.EngineMode", EngineMode);
|
||||
if (EngineMode != 1 && EngineMode != 2) {
|
||||
EngineMode = 2;
|
||||
Orebfuscator.log("EngineMode must be 1 or 2.");
|
||||
}
|
||||
|
||||
InitialRadius = clamp(getInt("Integers.InitialRadius", InitialRadius), 0, 2);
|
||||
if (InitialRadius == 0) {
|
||||
Orebfuscator.log("Warning, InitialRadius is 0. This will cause all exposed blocks to be obfuscated.");
|
||||
}
|
||||
|
||||
UpdateRadius = clamp(getInt("Integers.UpdateRadius", UpdateRadius), 1, 5);
|
||||
MaxLoadedCacheFiles = clamp(getInt("Integers.MaxLoadedCacheFiles", MaxLoadedCacheFiles), 16, 128);
|
||||
ProximityHiderDistance = clamp(getInt("Integers.ProximityHiderDistance", ProximityHiderDistance), 2, 64);
|
||||
|
||||
ProximityHiderID = getMaterialIdByPath("Integers.ProximityHiderID", ProximityHiderID);
|
||||
ProximityHiderEnd = clamp(getInt("Integers.ProximityHiderEnd", ProximityHiderEnd), 0, 255);
|
||||
AirGeneratorMaxChance = clamp(getInt("Integers.AirGeneratorMaxChance", AirGeneratorMaxChance), 40, 100);
|
||||
UseProximityHider = getBoolean("Booleans.UseProximityHider", UseProximityHider);
|
||||
UseSpecialBlockForProximityHider = getBoolean("Booleans.UseSpecialBlockForProximityHider", UseSpecialBlockForProximityHider);
|
||||
UseYLocationProximity = getBoolean("Booleans.UseYLocationProximity", UseYLocationProximity);
|
||||
UpdateOnDamage = getBoolean("Booleans.UpdateOnDamage", UpdateOnDamage);
|
||||
DarknessHideBlocks = getBoolean("Booleans.DarknessHideBlocks", DarknessHideBlocks);
|
||||
NoObfuscationForOps = getBoolean("Booleans.NoObfuscationForOps", NoObfuscationForOps);
|
||||
NoObfuscationForPermission = getBoolean("Booleans.NoObfuscationForPermission", NoObfuscationForPermission);
|
||||
UseCache = getBoolean("Booleans.UseCache", UseCache);
|
||||
LoginNotification = getBoolean("Booleans.LoginNotification", LoginNotification);
|
||||
AntiTexturePackAndFreecam = getBoolean("Booleans.AntiTexturePackAndFreecam", AntiTexturePackAndFreecam);
|
||||
UseWorldsAsBlacklist = getBoolean("Booleans.UseWorldsAsBlacklist", UseWorldsAsBlacklist);
|
||||
Enabled = getBoolean("Booleans.Enabled", Enabled);
|
||||
NoObfuscationForMetadata = getBoolean("Booleans.NoObfuscationForMetadata", NoObfuscationForMetadata);
|
||||
NoObfuscationForMetadataTagName = getString("Strings.NoObfuscationForMetadataTagName", NoObfuscationForMetadataTagName);
|
||||
DeleteCacheFilesAfterDays = getInt("Integers.DeleteCacheFilesAfterDays", DeleteCacheFilesAfterDays);
|
||||
//UseChunkReloader = getBoolean("Booleans.UseChunkReloader", UseChunkReloader);
|
||||
|
||||
generateTransparentBlocks();
|
||||
|
||||
// Read block lists
|
||||
setBlockValues(ObfuscateBlocks, getMaterialIdsByPath("Lists.ObfuscateBlocks", new Integer[]{14, 15, 16, 21, 54, 56, 73, 74, 129, 130}), false);
|
||||
setBlockValues(NetherObfuscateBlocks, getMaterialIdsByPath("Lists.NetherObfuscateBlocks", new Integer[]{87, 153}), false);
|
||||
setBlockValues(DarknessBlocks, getMaterialIdsByPath("Lists.DarknessBlocks", new Integer[]{52, 54}));
|
||||
setBlockValues(ProximityHiderBlocks, getMaterialIdsByPath("Lists.ProximityHiderBlocks", new Integer[]{23, 52, 54, 56, 58, 61, 62, 116, 129, 130, 145, 146}));
|
||||
|
||||
//Support old DisabledWorlds value
|
||||
if(getConfig().get("Lists.DisabledWorlds") != null) {
|
||||
Worlds = getConfig().getStringList("Lists.DisabledWorlds");
|
||||
getConfig().set("Lists.DisabledWorlds", null);
|
||||
}
|
||||
|
||||
// List of worlds (either disabled or enabled depending on WorldsAsBlacklist value).
|
||||
Worlds = getStringList("Lists.Worlds", Worlds);
|
||||
|
||||
// Read the cache location
|
||||
CacheLocation = getString("Strings.CacheLocation", CacheLocation);
|
||||
CacheFolder = new File(CacheLocation);
|
||||
|
||||
RandomBlocks = getMaterialIdsByPath("Lists.RandomBlocks", RandomBlocks).toArray(new Integer[0]);
|
||||
NetherRandomBlocks = getMaterialIdsByPath("Lists.NetherRandomBlocks", NetherRandomBlocks).toArray(new Integer[0]);
|
||||
|
||||
// Validate RandomBlocks
|
||||
for (int i = 0; i < RandomBlocks.length; i++) {
|
||||
// Don't want people to put chests and other stuff that lags the hell out of players.
|
||||
if (RandomBlocks[i] == null || OrebfuscatorConfig.isBlockTransparent((short) (int) RandomBlocks[i])) {
|
||||
RandomBlocks[i] = 1;
|
||||
}
|
||||
}
|
||||
RandomBlocks2 = RandomBlocks;
|
||||
|
||||
save();
|
||||
|
||||
createPaletteBlocks();
|
||||
|
||||
Orebfuscator.nms.setMaxLoadedCacheFiles(MaxLoadedCacheFiles);
|
||||
|
||||
//Make sure cache is cleared if config was changed since last start
|
||||
try {
|
||||
ObfuscatedDataCache.checkCacheAndConfigSynchronized();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static int getMaterialIdByPath(String path, int defaultMaterialId) {
|
||||
String materialName = getConfig().get(path) != null ? getConfig().getString(path): Integer.toString(defaultMaterialId);
|
||||
MaterialResult material = getMaterial(materialName, defaultMaterialId);
|
||||
|
||||
setData(path, material.name);
|
||||
|
||||
return material.id;
|
||||
}
|
||||
|
||||
private static List<Integer> getMaterialIdsByPath(String path, Integer[] defaultMaterials) {
|
||||
List<String> list;
|
||||
|
||||
if(getConfig().get(path) != null) {
|
||||
list = getConfig().getStringList(path);
|
||||
} else {
|
||||
list = new ArrayList<String>();
|
||||
|
||||
for(int materialId : defaultMaterials) {
|
||||
list.add(DeprecatedMethods.getMaterial(materialId).name());
|
||||
}
|
||||
}
|
||||
|
||||
List<Integer> result = new ArrayList<Integer>();
|
||||
|
||||
for(int i = 0; i < list.size(); i++) {
|
||||
MaterialResult material = getMaterial(list.get(i), null);
|
||||
|
||||
if(material != null) {
|
||||
list.set(i, material.name);
|
||||
result.add(material.id);
|
||||
}
|
||||
}
|
||||
|
||||
setData(path, list);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static MaterialResult getMaterial(String materialName, Integer defaultMaterialId) {
|
||||
Integer materialId;
|
||||
String defaultMaterialName = defaultMaterialId != null ? DeprecatedMethods.getMaterial(defaultMaterialId).name(): null;
|
||||
|
||||
try {
|
||||
if(Character.isDigit(materialName.charAt(0))) {
|
||||
materialId = Integer.parseInt(materialName);
|
||||
|
||||
Material obj = DeprecatedMethods.getMaterial(materialId);
|
||||
|
||||
if(obj != null) {
|
||||
materialName = obj.name();
|
||||
} else {
|
||||
if(defaultMaterialId != null) {
|
||||
Orebfuscator.log("Material with ID = " + materialId + " is not found. Will be used default material: " + defaultMaterialName);
|
||||
materialId = defaultMaterialId;
|
||||
materialName = defaultMaterialName;
|
||||
} else {
|
||||
Orebfuscator.log("Material with ID = " + materialId + " is not found. Skipped.");
|
||||
materialId = null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Material obj = Material.getMaterial(materialName.toUpperCase());
|
||||
|
||||
if(obj != null) {
|
||||
materialId = DeprecatedMethods.getMaterialId(obj);
|
||||
} else {
|
||||
if(defaultMaterialId != null) {
|
||||
Orebfuscator.log("Material " + materialName + " is not found. Will be used default material: " + defaultMaterialName);
|
||||
materialId = defaultMaterialId;
|
||||
materialName = defaultMaterialName;
|
||||
} else {
|
||||
Orebfuscator.log("Material " + materialName + " is not found. Skipped.");
|
||||
materialId = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if(defaultMaterialId != null) {
|
||||
Orebfuscator.log("Invalid material ID or name: " + materialName + ". Will be used default material: " + defaultMaterialName);
|
||||
materialId = defaultMaterialId;
|
||||
materialName = defaultMaterialName;
|
||||
} else {
|
||||
Orebfuscator.log("Invalid material ID or name: " + materialName + ". Skipped.");
|
||||
materialId = null;
|
||||
}
|
||||
}
|
||||
|
||||
return materialId != null ? new MaterialResult(materialId, materialName): null;
|
||||
}
|
||||
|
||||
private static void createPaletteBlocks() {
|
||||
//Nether
|
||||
ArrayList<Integer> nether = new ArrayList<Integer>();
|
||||
|
||||
nether.add(0);
|
||||
nether.add(87);
|
||||
|
||||
if(ProximityHiderID != 0 && ProximityHiderID != 87) {
|
||||
nether.add(ProximityHiderID);
|
||||
}
|
||||
|
||||
for(Integer id : NetherRandomBlocks) {
|
||||
if(id != null && nether.indexOf(id) < 0) {
|
||||
nether.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
NetherPaletteBlocks = new int[nether.size()];
|
||||
for(int i = 0; i < NetherPaletteBlocks.length; i++) NetherPaletteBlocks[i] = nether.get(i);
|
||||
|
||||
//Normal
|
||||
ArrayList<Integer> normal = new ArrayList<Integer>();
|
||||
|
||||
normal.add(0);
|
||||
normal.add(1);
|
||||
|
||||
if(ProximityHiderID != 0 && ProximityHiderID != 1) {
|
||||
normal.add(ProximityHiderID);
|
||||
}
|
||||
|
||||
for(Integer id : RandomBlocks) {
|
||||
if(id != null && normal.indexOf(id) < 0) {
|
||||
normal.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
for(Integer id : RandomBlocks2) {
|
||||
if(id != null && normal.indexOf(id) < 0) {
|
||||
normal.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
NormalPaletteBlocks = new int[normal.size()];
|
||||
for(int i = 0; i < NormalPaletteBlocks.length; i++) NormalPaletteBlocks[i] = normal.get(i);
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
Orebfuscator.instance.reloadConfig();
|
||||
load();
|
||||
}
|
||||
|
||||
public static void save() {
|
||||
Orebfuscator.instance.saveConfig();
|
||||
}
|
||||
|
||||
public static boolean obfuscateForPlayer(Player player) {
|
||||
return !(playerBypassOp(player) || playerBypassPerms(player) || playerBypassMetadata(player));
|
||||
}
|
||||
|
||||
public static boolean playerBypassOp(Player player) {
|
||||
boolean ret = false;
|
||||
try {
|
||||
ret = OrebfuscatorConfig.NoObfuscationForOps && player.isOp();
|
||||
} catch (Exception e) {
|
||||
Orebfuscator.log("Error while obtaining Operator status for player" + player.getName() + ": " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static boolean playerBypassPerms(Player player) {
|
||||
boolean ret = false;
|
||||
try {
|
||||
ret = OrebfuscatorConfig.NoObfuscationForPermission && player.hasPermission("Orebfuscator.deobfuscate");
|
||||
} catch (Exception e) {
|
||||
Orebfuscator.log("Error while obtaining permissions for player" + player.getName() + ": " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static boolean playerBypassMetadata(Player player) {
|
||||
boolean ret = false;
|
||||
try {
|
||||
ret = OrebfuscatorConfig.NoObfuscationForMetadata
|
||||
&& player.hasMetadata(OrebfuscatorConfig.NoObfuscationForMetadataTagName)
|
||||
&& player.getMetadata(OrebfuscatorConfig.NoObfuscationForMetadataTagName).get(0).asBoolean();
|
||||
} catch (Exception e) {
|
||||
Orebfuscator.log("Error while obtaining metadata for player" + player.getName() + ": " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static FileConfiguration getConfig() {
|
||||
return Orebfuscator.instance.getConfig();
|
||||
}
|
||||
|
||||
private static int clamp(int value, int min, int max) {
|
||||
if (value < min)
|
||||
value = min;
|
||||
if (value > max)
|
||||
value = max;
|
||||
return value;
|
||||
}
|
||||
}
|
|
@ -6,17 +6,16 @@ import org.bukkit.Bukkit;
|
|||
import org.bukkit.World;
|
||||
|
||||
import com.lishid.orebfuscator.Orebfuscator;
|
||||
import com.lishid.orebfuscator.OrebfuscatorConfig;
|
||||
|
||||
public class CacheCleaner implements Runnable {
|
||||
public void run() {
|
||||
if(!OrebfuscatorConfig.Enabled || OrebfuscatorConfig.DeleteCacheFilesAfterDays <= 0) return;
|
||||
if(!Orebfuscator.config.isEnabled() || Orebfuscator.config.getDeleteCacheFilesAfterDays() <= 0) return;
|
||||
|
||||
int count = 0;
|
||||
|
||||
for(World world : Bukkit.getWorlds()) {
|
||||
File cacheFolder = new File(OrebfuscatorConfig.getCacheFolder(), world.getName());
|
||||
count += ObfuscatedDataCache.deleteFiles(cacheFolder, OrebfuscatorConfig.DeleteCacheFilesAfterDays);
|
||||
File cacheFolder = new File(ObfuscatedDataCache.getCacheFolder(), world.getName());
|
||||
count += ObfuscatedDataCache.deleteFiles(cacheFolder, Orebfuscator.config.getDeleteCacheFilesAfterDays());
|
||||
}
|
||||
|
||||
Orebfuscator.log("Cache cleaner completed, deleted files: " + count);
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.io.DataOutputStream;
|
|||
import java.io.File;
|
||||
|
||||
import com.lishid.orebfuscator.Orebfuscator;
|
||||
import com.lishid.orebfuscator.OrebfuscatorConfig;
|
||||
import com.lishid.orebfuscator.nms.INBT;
|
||||
|
||||
public class ObfuscatedCachedChunk {
|
||||
|
@ -78,8 +77,6 @@ public class ObfuscatedCachedChunk {
|
|||
// Check if statuses makes sense
|
||||
if (nbt.getInt("X") != x || nbt.getInt("Z") != z)
|
||||
return;
|
||||
if (OrebfuscatorConfig.UseProximityHider != nbt.getBoolean("PH") || OrebfuscatorConfig.InitialRadius != nbt.getInt("IR"))
|
||||
return;
|
||||
|
||||
// Get Hash
|
||||
hash = nbt.getLong("Hash");
|
||||
|
@ -104,8 +101,6 @@ public class ObfuscatedCachedChunk {
|
|||
// Set status indicator
|
||||
nbt.setInt("X", x);
|
||||
nbt.setInt("Z", z);
|
||||
nbt.setInt("IR", OrebfuscatorConfig.InitialRadius);
|
||||
nbt.setBoolean("PH", OrebfuscatorConfig.UseProximityHider);
|
||||
|
||||
// Set hash
|
||||
nbt.setLong("Hash", hash);
|
||||
|
|
|
@ -23,13 +23,15 @@ import java.io.IOException;
|
|||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.lishid.orebfuscator.Orebfuscator;
|
||||
import com.lishid.orebfuscator.OrebfuscatorConfig;
|
||||
import com.lishid.orebfuscator.nms.IChunkCache;
|
||||
import com.lishid.orebfuscator.utils.FileHelper;
|
||||
|
||||
public class ObfuscatedDataCache {
|
||||
private static final String cacheFileName = "cache_config.yml";
|
||||
private static File cacheFolder;
|
||||
private static IChunkCache internalCache;
|
||||
|
||||
private static IChunkCache getInternalCache() {
|
||||
|
@ -38,6 +40,26 @@ public class ObfuscatedDataCache {
|
|||
}
|
||||
return internalCache;
|
||||
}
|
||||
|
||||
public static void resetCacheFolder() {
|
||||
cacheFolder = null;
|
||||
}
|
||||
|
||||
public static File getCacheFolder() {
|
||||
if(cacheFolder == null) {
|
||||
cacheFolder = new File(Bukkit.getServer().getWorldContainer(), Orebfuscator.config.getCacheLocation());
|
||||
}
|
||||
|
||||
// Try to make the folder
|
||||
if (!cacheFolder.exists()) {
|
||||
cacheFolder.mkdirs();
|
||||
}
|
||||
// Can't make folder? Use default
|
||||
if (!cacheFolder.exists()) {
|
||||
cacheFolder = new File("orebfuscator_cache");
|
||||
}
|
||||
return cacheFolder;
|
||||
}
|
||||
|
||||
public static void closeCacheFiles() {
|
||||
getInternalCache().closeCacheFiles();
|
||||
|
@ -46,7 +68,7 @@ public class ObfuscatedDataCache {
|
|||
public static void checkCacheAndConfigSynchronized() throws IOException {
|
||||
String configContent = Orebfuscator.instance.getConfig().saveToString();
|
||||
|
||||
File cacheFolder = OrebfuscatorConfig.getCacheFolder();
|
||||
File cacheFolder = getCacheFolder();
|
||||
File cacheConfigFile = new File(cacheFolder, cacheFileName);
|
||||
String cacheConfigContent = FileHelper.readFile(cacheConfigFile);
|
||||
|
||||
|
@ -58,7 +80,7 @@ public class ObfuscatedDataCache {
|
|||
public static void clearCache() throws IOException {
|
||||
closeCacheFiles();
|
||||
|
||||
File cacheFolder = OrebfuscatorConfig.getCacheFolder();
|
||||
File cacheFolder = getCacheFolder();
|
||||
File cacheConfigFile = new File(cacheFolder, cacheFileName);
|
||||
|
||||
if(cacheFolder.exists()) {
|
||||
|
|
|
@ -23,7 +23,6 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.lishid.orebfuscator.Orebfuscator;
|
||||
import com.lishid.orebfuscator.OrebfuscatorConfig;
|
||||
import com.lishid.orebfuscator.cache.ObfuscatedDataCache;
|
||||
|
||||
public class OrebfuscatorCommandExecutor {
|
||||
|
@ -39,7 +38,7 @@ public class OrebfuscatorCommandExecutor {
|
|||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("engine") && args.length > 1) {
|
||||
int engine = OrebfuscatorConfig.EngineMode;
|
||||
int engine = Orebfuscator.config.getEngineMode();
|
||||
try {
|
||||
engine = new Integer(args[1]);
|
||||
}
|
||||
|
@ -52,14 +51,14 @@ public class OrebfuscatorCommandExecutor {
|
|||
return true;
|
||||
}
|
||||
else {
|
||||
OrebfuscatorConfig.setEngineMode(engine);
|
||||
Orebfuscator.configManager.setEngineMode(engine);
|
||||
Orebfuscator.message(sender, "Engine set to: " + engine);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("updateradius") && args.length > 1) {
|
||||
int radius = OrebfuscatorConfig.UpdateRadius;
|
||||
int radius = Orebfuscator.config.getUpdateRadius();
|
||||
try {
|
||||
radius = new Integer(args[1]);
|
||||
}
|
||||
|
@ -67,13 +66,13 @@ public class OrebfuscatorCommandExecutor {
|
|||
Orebfuscator.message(sender, args[1] + " is not a number!");
|
||||
return true;
|
||||
}
|
||||
OrebfuscatorConfig.setUpdateRadius(radius);
|
||||
Orebfuscator.message(sender, "UpdateRadius set to: " + OrebfuscatorConfig.UpdateRadius);
|
||||
Orebfuscator.configManager.setUpdateRadius(radius);
|
||||
Orebfuscator.message(sender, "UpdateRadius set to: " + Orebfuscator.config.getUpdateRadius());
|
||||
return true;
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("initialradius") && args.length > 1) {
|
||||
int radius = OrebfuscatorConfig.InitialRadius;
|
||||
int radius = Orebfuscator.config.getInitialRadius();
|
||||
try {
|
||||
radius = new Integer(args[1]);
|
||||
}
|
||||
|
@ -81,118 +80,76 @@ public class OrebfuscatorCommandExecutor {
|
|||
Orebfuscator.message(sender, args[1] + " is not a number!");
|
||||
return true;
|
||||
}
|
||||
OrebfuscatorConfig.setInitialRadius(radius);
|
||||
Orebfuscator.configManager.setInitialRadius(radius);
|
||||
Orebfuscator.message(sender, "InitialRadius set to: " + radius);
|
||||
return true;
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("airgen") && args.length > 1) {
|
||||
int airgen = OrebfuscatorConfig.AirGeneratorMaxChance;
|
||||
try {
|
||||
airgen = new Integer(args[1]);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
Orebfuscator.message(sender, args[1] + " is not a number!");
|
||||
return true;
|
||||
}
|
||||
OrebfuscatorConfig.setAirGeneratorMaxChance(airgen);
|
||||
Orebfuscator.message(sender, "AirGeneratorMaxChance set to: " + airgen);
|
||||
return true;
|
||||
}
|
||||
|
||||
else if ((args[0].equalsIgnoreCase("proximity") | args[0].equalsIgnoreCase("proximityhider")) && args.length > 1) {
|
||||
int ProximityHiderDistance = OrebfuscatorConfig.ProximityHiderDistance;
|
||||
try {
|
||||
ProximityHiderDistance = new Integer(args[1]);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
Orebfuscator.message(sender, args[1] + " is not a number!");
|
||||
return true;
|
||||
}
|
||||
OrebfuscatorConfig.setProximityHiderDistance(ProximityHiderDistance);
|
||||
Orebfuscator.message(sender, "ProximityHider Distance set to: " + ProximityHiderDistance);
|
||||
return true;
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("enable") || args[0].equalsIgnoreCase("disable")) {
|
||||
boolean data = args[0].equalsIgnoreCase("enable");
|
||||
|
||||
if (args[0].equalsIgnoreCase("enable") && args.length == 1) {
|
||||
OrebfuscatorConfig.setEnabled(true);
|
||||
Orebfuscator.configManager.setEnabled(true);
|
||||
Orebfuscator.message(sender, "Enabled.");
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("disable") && args.length == 1) {
|
||||
OrebfuscatorConfig.setEnabled(false);
|
||||
Orebfuscator.configManager.setEnabled(false);
|
||||
Orebfuscator.message(sender, "Disabled.");
|
||||
}
|
||||
|
||||
else if (args.length > 1) {
|
||||
if (args[1].equalsIgnoreCase("darknesshide")) {
|
||||
OrebfuscatorConfig.setDarknessHideBlocks(data);
|
||||
Orebfuscator.message(sender, "Darkness obfuscation " + (data ? "enabled" : "disabled") + ".");
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("op")) {
|
||||
OrebfuscatorConfig.setNoObfuscationForOps(data);
|
||||
if (args[1].equalsIgnoreCase("op")) {
|
||||
Orebfuscator.configManager.setNoObfuscationForOps(data);
|
||||
Orebfuscator.message(sender, "Ops No-Obfuscation " + (data ? "enabled" : "disabled") + ".");
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("perms") || args[1].equalsIgnoreCase("permissions")) {
|
||||
OrebfuscatorConfig.setNoObfuscationForPermission(data);
|
||||
Orebfuscator.configManager.setNoObfuscationForPermission(data);
|
||||
Orebfuscator.message(sender, "Permissions No-Obfuscation " + (data ? "enabled" : "disabled") + ".");
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("cache")) {
|
||||
OrebfuscatorConfig.setUseCache(data);
|
||||
Orebfuscator.configManager.setUseCache(data);
|
||||
Orebfuscator.message(sender, "Cache " + (data ? "enabled" : "disabled") + ".");
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("axr")) {
|
||||
OrebfuscatorConfig.setAntiTexturePackAndFreecam(data);
|
||||
Orebfuscator.message(sender, "AntiTexturePackAndFreecam " + (data ? "enabled" : "disabled") + ".");
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("notification")) {
|
||||
OrebfuscatorConfig.setLoginNotification(data);
|
||||
Orebfuscator.configManager.setLoginNotification(data);
|
||||
Orebfuscator.message(sender, "Login Notification " + (data ? "enabled" : "disabled") + ".");
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("world") && args.length > 2) {
|
||||
OrebfuscatorConfig.setWorldEnabled(args[2], data);
|
||||
Orebfuscator.message(sender, "World \"" + args[2] + "\" obfuscation " + (data ? "enabled" : "disabled") + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("use") && args.length > 1) {
|
||||
if (args[1].equalsIgnoreCase("blacklist")) {
|
||||
OrebfuscatorConfig.setUseWorldsAsBlacklist(true);
|
||||
Orebfuscator.message(sender, "Use worlds as blacklist.");
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("whitelist")) {
|
||||
OrebfuscatorConfig.setUseWorldsAsBlacklist(false);
|
||||
Orebfuscator.message(sender, "Use worlds as whitelist.");
|
||||
}
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("reload")) {
|
||||
OrebfuscatorConfig.reload();
|
||||
Orebfuscator.instance.reloadOrebfuscatorConfig();
|
||||
Orebfuscator.message(sender, "Reload complete.");
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("status")) {
|
||||
String status = Orebfuscator.instance.getIsProtocolLibFound()
|
||||
? (OrebfuscatorConfig.Enabled ? "Enabled" : "Disabled")
|
||||
? (Orebfuscator.config.isEnabled() ? "Enabled" : "Disabled")
|
||||
: "ProtocolLib is not found! Plugin cannot be enabled.";
|
||||
|
||||
Orebfuscator.message(sender, "Orebfuscator " + Orebfuscator.instance.getDescription().getVersion() + " is: " + status);
|
||||
Orebfuscator.message(sender, "Engine Mode: " + OrebfuscatorConfig.EngineMode);
|
||||
Orebfuscator.message(sender, "Engine Mode: " + Orebfuscator.config.getEngineMode());
|
||||
|
||||
Orebfuscator.message(sender, "Caching: " + (OrebfuscatorConfig.UseCache ? "Enabled" : "Disabled"));
|
||||
Orebfuscator.message(sender, "ProximityHider: " + (OrebfuscatorConfig.UseProximityHider ? "Enabled" : "Disabled"));
|
||||
Orebfuscator.message(sender, "DarknessHideBlocks: " + (OrebfuscatorConfig.DarknessHideBlocks ? "Enabled": "Disabled"));
|
||||
Orebfuscator.message(sender, "Caching: " + (Orebfuscator.config.isUseCache() ? "Enabled" : "Disabled"));
|
||||
Orebfuscator.message(sender, "ProximityHider: " + (Orebfuscator.config.isProximityHiderEnabled() ? "Enabled" : "Disabled"));
|
||||
Orebfuscator.message(sender, "DarknessHideBlocks: " + (Orebfuscator.config.getDefaultWorld().isDarknessHideBlocks() ? "Enabled": "Disabled"));
|
||||
|
||||
Orebfuscator.message(sender, "Initial Obfuscation Radius: " + OrebfuscatorConfig.InitialRadius);
|
||||
Orebfuscator.message(sender, "Update Radius: " + OrebfuscatorConfig.UpdateRadius);
|
||||
Orebfuscator.message(sender, "Initial Obfuscation Radius: " + Orebfuscator.config.getInitialRadius());
|
||||
Orebfuscator.message(sender, "Update Radius: " + Orebfuscator.config.getUpdateRadius());
|
||||
|
||||
String worlds = "";
|
||||
|
||||
String worlds = OrebfuscatorConfig.getWorlds();
|
||||
for(String name : Orebfuscator.config.getWorlds().keySet()) {
|
||||
if(worlds.length() > 0) {
|
||||
name += ", ";
|
||||
}
|
||||
|
||||
worlds += name;
|
||||
}
|
||||
|
||||
Orebfuscator.message(sender, "Worlds: " + (worlds.equals("") ? "None" : worlds));
|
||||
Orebfuscator.message(sender, "Use worlds as: " + (OrebfuscatorConfig.UseWorldsAsBlacklist ? "Blacklist" : "Whitelist"));
|
||||
Orebfuscator.message(sender, "Use worlds as: " + (Orebfuscator.config.getDefaultWorld().isEnabled() ? "Blacklist" : "Whitelist"));
|
||||
}
|
||||
|
||||
else if (args[0].equalsIgnoreCase("clearcache")) {
|
||||
|
|
|
@ -0,0 +1,335 @@
|
|||
/**
|
||||
* @author Aleksey Terzi
|
||||
*
|
||||
*/
|
||||
|
||||
package com.lishid.orebfuscator.config;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.lishid.orebfuscator.utils.Globals;
|
||||
|
||||
public class ConfigManager {
|
||||
private static final int CONFIG_VERSION = 13;
|
||||
|
||||
private boolean[] transparentBlocks;
|
||||
private boolean[] transparentBlocksMode1;
|
||||
private boolean[] transparentBlocksMode2;
|
||||
|
||||
private JavaPlugin plugin;
|
||||
private Logger logger;
|
||||
private OrebfuscatorConfig orebfuscatorConfig;
|
||||
private MaterialReader materialReader;
|
||||
|
||||
public ConfigManager(JavaPlugin plugin, Logger logger, OrebfuscatorConfig orebfuscatorConfig) {
|
||||
this.plugin = plugin;
|
||||
this.logger = logger;
|
||||
this.orebfuscatorConfig = orebfuscatorConfig;
|
||||
this.materialReader = new MaterialReader(this.plugin, this.logger);
|
||||
}
|
||||
|
||||
public WorldConfig getWorld(World world) {
|
||||
if(world == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
WorldConfig baseCfg;
|
||||
|
||||
switch(world.getEnvironment()) {
|
||||
case THE_END:
|
||||
baseCfg = this.orebfuscatorConfig.getEndWorld();
|
||||
break;
|
||||
case NETHER:
|
||||
baseCfg = this.orebfuscatorConfig.getNetherWorld();
|
||||
break;
|
||||
default:
|
||||
baseCfg = this.orebfuscatorConfig.getNormalWorld();
|
||||
}
|
||||
|
||||
WorldConfig cfg = this.orebfuscatorConfig.getWorlds().get(world.getName().toLowerCase());
|
||||
|
||||
if(cfg == null) {
|
||||
return baseCfg;
|
||||
}
|
||||
|
||||
if(!cfg.isInitialized()) {
|
||||
cfg.init(baseCfg);
|
||||
this.logger.log(Level.INFO, Globals.LogPrefix + "Config for world '" + world.getName() + "' is initialized.");
|
||||
}
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
// Version check
|
||||
int version = getInt("ConfigVersion", CONFIG_VERSION);
|
||||
if (version < CONFIG_VERSION) {
|
||||
if(version <= 12) {
|
||||
new Convert12To13(this.plugin).convert();
|
||||
logger.info(Globals.LogPrefix + "Configuration file have been converted to new version.");
|
||||
} else {
|
||||
getConfig().set("ConfigVersion", CONFIG_VERSION);
|
||||
}
|
||||
}
|
||||
|
||||
boolean useCache = getBoolean("Booleans.UseCache", true);
|
||||
int maxLoadedCacheFiles = getInt("Integers.MaxLoadedCacheFiles", 64, 16, 128);
|
||||
String cacheLocation = getString("Strings.CacheLocation", "orebfuscator_cache");
|
||||
int deleteCacheFilesAfterDays = getInt("Integers.DeleteCacheFilesAfterDays", 0);
|
||||
boolean enabled = getBoolean("Booleans.Enabled", true);
|
||||
boolean updateOnDamage = getBoolean("Booleans.UpdateOnDamage", true);
|
||||
|
||||
int engineMode = getInt("Integers.EngineMode", 2);
|
||||
if (engineMode != 1 && engineMode != 2) {
|
||||
engineMode = 2;
|
||||
logger.info(Globals.LogPrefix + "EngineMode must be 1 or 2.");
|
||||
}
|
||||
|
||||
int initialRadius = getInt("Integers.InitialRadius", 1, 0, 2);
|
||||
if (initialRadius == 0) {
|
||||
logger.info(Globals.LogPrefix + "Warning, InitialRadius is 0. This will cause all exposed blocks to be obfuscated.");
|
||||
}
|
||||
|
||||
int updateRadius = getInt("Integers.UpdateRadius", 2, 1, 5);
|
||||
boolean noObfuscationForMetadata = getBoolean("Booleans.NoObfuscationForMetadata", true);
|
||||
String noObfuscationForMetadataTagName = getString("Strings.NoObfuscationForMetadataTagName", "NPC");
|
||||
boolean noObfuscationForOps = getBoolean("Booleans.NoObfuscationForOps", false);
|
||||
boolean noObfuscationForPermission = getBoolean("Booleans.NoObfuscationForPermission", false);
|
||||
boolean loginNotification = getBoolean("Booleans.LoginNotification", true);
|
||||
|
||||
generateTransparentBlocks(engineMode);
|
||||
|
||||
this.orebfuscatorConfig.setUseCache(useCache);
|
||||
this.orebfuscatorConfig.setMaxLoadedCacheFiles(maxLoadedCacheFiles);
|
||||
this.orebfuscatorConfig.setCacheLocation(cacheLocation);
|
||||
this.orebfuscatorConfig.setDeleteCacheFilesAfterDays(deleteCacheFilesAfterDays);
|
||||
this.orebfuscatorConfig.setEnabled(enabled);
|
||||
this.orebfuscatorConfig.setUpdateOnDamage(updateOnDamage);
|
||||
this.orebfuscatorConfig.setEngineMode(engineMode);
|
||||
this.orebfuscatorConfig.setInitialRadius(initialRadius);
|
||||
this.orebfuscatorConfig.setUpdateRadius(updateRadius);
|
||||
this.orebfuscatorConfig.setNoObfuscationForMetadata(noObfuscationForMetadata);
|
||||
this.orebfuscatorConfig.setNoObfuscationForMetadataTagName(noObfuscationForMetadataTagName);
|
||||
this.orebfuscatorConfig.setNoObfuscationForOps(noObfuscationForOps);
|
||||
this.orebfuscatorConfig.setNoObfuscationForPermission(noObfuscationForPermission);
|
||||
this.orebfuscatorConfig.setLoginNotification(loginNotification);
|
||||
this.orebfuscatorConfig.setTransparentBlocks(this.transparentBlocks);
|
||||
|
||||
new WorldReader(this.plugin, this.logger, this.orebfuscatorConfig, this.materialReader).load();
|
||||
|
||||
this.orebfuscatorConfig.setProximityHiderEnabled();
|
||||
|
||||
logger.info(Globals.LogPrefix + "Proximity Hider is " + (this.orebfuscatorConfig.isProximityHiderEnabled() ? "Enabled": "Disabled"));
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
public void setEngineMode(int value) {
|
||||
getConfig().set("Integers.EngineMode", value);
|
||||
save();
|
||||
this.orebfuscatorConfig.setEngineMode(value);
|
||||
}
|
||||
|
||||
public void setUpdateRadius(int value) {
|
||||
getConfig().set("Integers.UpdateRadius", value);
|
||||
save();
|
||||
this.orebfuscatorConfig.setUpdateRadius(value);
|
||||
}
|
||||
|
||||
public void setInitialRadius(int value) {
|
||||
getConfig().set("Integers.InitialRadius", value);
|
||||
save();
|
||||
this.orebfuscatorConfig.setInitialRadius(value);
|
||||
}
|
||||
|
||||
public void setProximityHiderDistance(int value) {
|
||||
getConfig().set("Integers.ProximityHiderDistance", value);
|
||||
save();
|
||||
this.orebfuscatorConfig.getDefaultWorld().getProximityHiderConfig().setDistance(value);
|
||||
}
|
||||
|
||||
public void setNoObfuscationForOps(boolean value) {
|
||||
getConfig().set("Booleans.NoObfuscationForOps", value);
|
||||
save();
|
||||
this.orebfuscatorConfig.setNoObfuscationForOps(value);
|
||||
}
|
||||
|
||||
public void setNoObfuscationForPermission(boolean value) {
|
||||
getConfig().set("Booleans.NoObfuscationForPermission", value);
|
||||
save();
|
||||
this.orebfuscatorConfig.setNoObfuscationForPermission(value);
|
||||
}
|
||||
|
||||
public void setLoginNotification(boolean value) {
|
||||
getConfig().set("Booleans.LoginNotification", value);
|
||||
save();
|
||||
this.orebfuscatorConfig.setLoginNotification(value);
|
||||
}
|
||||
|
||||
public void setUseCache(boolean value) {
|
||||
getConfig().set("Booleans.UseCache", value);
|
||||
save();
|
||||
this.orebfuscatorConfig.setUseCache(value);
|
||||
}
|
||||
|
||||
public void setEnabled(boolean value) {
|
||||
getConfig().set("Booleans.Enabled", value);
|
||||
save();
|
||||
this.orebfuscatorConfig.setEnabled(value);
|
||||
}
|
||||
|
||||
private FileConfiguration getConfig() {
|
||||
return this.plugin.getConfig();
|
||||
}
|
||||
|
||||
private void save() {
|
||||
this.plugin.saveConfig();
|
||||
}
|
||||
|
||||
private String getString(String path, String defaultData, boolean withSave) {
|
||||
if (getConfig().get(path) == null) {
|
||||
if(!withSave) {
|
||||
return defaultData;
|
||||
}
|
||||
|
||||
getConfig().set(path, defaultData);
|
||||
}
|
||||
|
||||
return getConfig().getString(path, defaultData);
|
||||
}
|
||||
|
||||
private String getString(String path, String defaultData) {
|
||||
return getString(path, defaultData, true);
|
||||
}
|
||||
|
||||
private int getInt(String path, int defaultData) {
|
||||
return getInt(path, defaultData, true);
|
||||
}
|
||||
|
||||
private int getInt(String path, int defaultData, boolean withSave) {
|
||||
if (getConfig().get(path) == null) {
|
||||
if(!withSave) {
|
||||
return defaultData;
|
||||
}
|
||||
|
||||
getConfig().set(path, defaultData);
|
||||
}
|
||||
|
||||
return getConfig().getInt(path, defaultData);
|
||||
}
|
||||
|
||||
private int getInt(String path, int defaultData, int min, int max, boolean withSave) {
|
||||
if (getConfig().get(path) == null && withSave) {
|
||||
getConfig().set(path, defaultData);
|
||||
}
|
||||
|
||||
int value = getConfig().get(path) != null ? getConfig().getInt(path, defaultData): defaultData;
|
||||
|
||||
if(value < min) {
|
||||
value = min;
|
||||
}
|
||||
else if(value > max) {
|
||||
value = max;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private int getInt(String path, int defaultData, int min, int max) {
|
||||
return getInt(path, defaultData, min, max, true);
|
||||
}
|
||||
|
||||
private boolean getBoolean(String path, boolean defaultData, boolean withSave) {
|
||||
if (getConfig().get(path) == null) {
|
||||
if(!withSave) {
|
||||
return defaultData;
|
||||
}
|
||||
|
||||
getConfig().set(path, defaultData);
|
||||
}
|
||||
|
||||
return getConfig().getBoolean(path, defaultData);
|
||||
}
|
||||
|
||||
private boolean getBoolean(String path, boolean defaultData) {
|
||||
return getBoolean(path, defaultData, true);
|
||||
}
|
||||
|
||||
private void generateTransparentBlocks(int engineMode) {
|
||||
if(this.transparentBlocks == null) {
|
||||
readInitialTransparentBlocks();
|
||||
}
|
||||
|
||||
boolean[] transparentBlocks = engineMode == 1
|
||||
? this.transparentBlocksMode1
|
||||
: this.transparentBlocksMode2;
|
||||
|
||||
System.arraycopy(transparentBlocks, 0, this.transparentBlocks, 0, this.transparentBlocks.length);
|
||||
|
||||
Integer[] customTransparentBlocks = this.materialReader.getMaterialIdsByPath("Lists.TransparentBlocks", new Integer[0], true);
|
||||
|
||||
if(customTransparentBlocks != null) {
|
||||
for(int blockId : customTransparentBlocks) {
|
||||
if(blockId >= 0 && blockId <= 255) {
|
||||
this.transparentBlocks[blockId] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Integer[] customNonTransparentBlocks = this.materialReader.getMaterialIdsByPath("Lists.NonTransparentBlocks", new Integer[0], true);
|
||||
|
||||
if(customNonTransparentBlocks != null) {
|
||||
for(int blockId : customNonTransparentBlocks) {
|
||||
if(blockId >= 0 && blockId <= 255) {
|
||||
this.transparentBlocks[blockId] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void readInitialTransparentBlocks() {
|
||||
this.transparentBlocks = new boolean[256];
|
||||
Arrays.fill(this.transparentBlocks, false);
|
||||
|
||||
InputStream mainStream = ConfigManager.class.getResourceAsStream("/resources/transparent_blocks.txt");
|
||||
readTransparentBlocks(this.transparentBlocks, mainStream);
|
||||
|
||||
this.transparentBlocksMode1 = new boolean[256];
|
||||
System.arraycopy(this.transparentBlocks, 0, this.transparentBlocksMode1, 0, this.transparentBlocksMode1.length);
|
||||
InputStream mode1Stream = ConfigManager.class.getResourceAsStream("/resources/transparent_blocks_mode1.txt");
|
||||
if(mode1Stream != null) readTransparentBlocks(this.transparentBlocksMode1, mode1Stream);
|
||||
|
||||
this.transparentBlocksMode2 = new boolean[256];
|
||||
System.arraycopy(this.transparentBlocks, 0, this.transparentBlocksMode2, 0, this.transparentBlocksMode2.length);
|
||||
InputStream mode2Stream = ConfigManager.class.getResourceAsStream("/resources/transparent_blocks_mode2.txt");
|
||||
if(mode2Stream != null) readTransparentBlocks(this.transparentBlocksMode2, mode2Stream);
|
||||
}
|
||||
|
||||
private void readTransparentBlocks(boolean[] transparentBlocks, InputStream stream) {
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
|
||||
String line;
|
||||
|
||||
while ((line = reader.readLine()) != null) {
|
||||
int index1 = line.indexOf(":");
|
||||
int index2 = line.indexOf(" ", index1);
|
||||
int blockId = Integer.parseInt(line.substring(0, index1));
|
||||
boolean isTransparent = line.substring(index1 + 1, index2).equals("true");
|
||||
|
||||
transparentBlocks[blockId] = isTransparent;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
/**
|
||||
* @author Aleksey Terzi
|
||||
*
|
||||
*/
|
||||
|
||||
package com.lishid.orebfuscator.config;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Convert12To13 {
|
||||
private static final int CONFIG_VERSION = 13;
|
||||
|
||||
private JavaPlugin plugin;
|
||||
private FileConfiguration config;
|
||||
|
||||
public Convert12To13(JavaPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void convert() {
|
||||
this.config = new YamlConfiguration();
|
||||
setGlobalValues();
|
||||
setWorldValues();
|
||||
|
||||
String contents = this.config.saveToString();
|
||||
|
||||
try {
|
||||
this.plugin.getConfig().loadFromString(contents);
|
||||
} catch (InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void setGlobalValues() {
|
||||
FileConfiguration oldConfig = this.plugin.getConfig();
|
||||
|
||||
this.config.set("ConfigVersion", CONFIG_VERSION);
|
||||
this.config.set("Booleans.UseCache", oldConfig.get("Booleans.UseCache"));
|
||||
this.config.set("Booleans.Enabled", oldConfig.get("Booleans.Enabled"));
|
||||
this.config.set("Booleans.UpdateOnDamage", oldConfig.get("Booleans.UpdateOnDamage"));
|
||||
this.config.set("Booleans.NoObfuscationForMetadata", oldConfig.get("Booleans.NoObfuscationForMetadata"));
|
||||
this.config.set("Booleans.NoObfuscationForOps", oldConfig.get("Booleans.NoObfuscationForOps"));
|
||||
this.config.set("Booleans.NoObfuscationForPermission", oldConfig.get("Booleans.NoObfuscationForPermission"));
|
||||
this.config.set("Booleans.LoginNotification", oldConfig.get("Booleans.LoginNotification"));
|
||||
this.config.set("Integers.MaxLoadedCacheFiles", oldConfig.get("Integers.MaxLoadedCacheFiles"));
|
||||
this.config.set("Integers.DeleteCacheFilesAfterDays", oldConfig.get("Integers.DeleteCacheFilesAfterDays"));
|
||||
this.config.set("Integers.EngineMode", oldConfig.get("Integers.EngineMode"));
|
||||
this.config.set("Integers.InitialRadius", oldConfig.get("Integers.InitialRadius"));
|
||||
this.config.set("Integers.UpdateRadius", oldConfig.get("Integers.UpdateRadius"));
|
||||
this.config.set("Strings.CacheLocation", oldConfig.get("Strings.CacheLocation"));
|
||||
this.config.set("Strings.NoObfuscationForMetadataTagName", oldConfig.get("Strings.NoObfuscationForMetadataTagName"));
|
||||
this.config.set("Lists.TransparentBlocks", oldConfig.get("Lists.TransparentBlocks"));
|
||||
this.config.set("Lists.NonTransparentBlocks", oldConfig.get("Lists.NonTransparentBlocks"));
|
||||
}
|
||||
|
||||
private void setWorldValues() {
|
||||
FileConfiguration oldConfig = this.plugin.getConfig();
|
||||
|
||||
boolean worldEnabled = oldConfig.get("Booleans.UseWorldsAsBlacklist") == null
|
||||
|| oldConfig.getBoolean("Booleans.UseWorldsAsBlacklist");
|
||||
|
||||
// Default World
|
||||
this.config.set("Worlds.Default.Types", new String[] { "DEFAULT" });
|
||||
this.config.set("Worlds.Default.Enabled", worldEnabled);
|
||||
this.config.set("Worlds.Default.AntiTexturePackAndFreecam", oldConfig.get("Booleans.AntiTexturePackAndFreecam"));
|
||||
this.config.set("Worlds.Default.AirGeneratorMaxChance", oldConfig.get("Integers.AirGeneratorMaxChance"));
|
||||
this.config.set("Worlds.Default.DarknessHideBlocks", oldConfig.get("Booleans.DarknessHideBlocks"));
|
||||
this.config.set("Worlds.Default.DarknessBlocks", oldConfig.get("Lists.DarknessBlocks"));
|
||||
this.config.set("Worlds.Default.Mode1Block", 1);
|
||||
|
||||
this.config.set("Worlds.Default.ProximityHider.Enabled", oldConfig.get("Booleans.UseProximityHider"));
|
||||
this.config.set("Worlds.Default.ProximityHider.Distance", oldConfig.get("Integers.ProximityHiderDistance"));
|
||||
this.config.set("Worlds.Default.ProximityHider.SpecialBlock", oldConfig.get("Integers.ProximityHiderID"));
|
||||
this.config.set("Worlds.Default.ProximityHider.Y", oldConfig.get("Integers.ProximityHiderEnd"));
|
||||
this.config.set("Worlds.Default.ProximityHider.UseSpecialBlock", oldConfig.get("Booleans.UseSpecialBlockForProximityHider"));
|
||||
this.config.set("Worlds.Default.ProximityHider.ObfuscateAboveY", oldConfig.get("Booleans.UseYLocationProximity"));
|
||||
this.config.set("Worlds.Default.ProximityHider.ProximityHiderBlocks", oldConfig.get("Lists.ProximityHiderBlocks"));
|
||||
|
||||
//Normal and TheEnd Worlds
|
||||
this.config.set("Worlds.Normal.Types", new String[] { "NORMAL", "THE_END" });
|
||||
this.config.set("Worlds.Normal.Mode1Block", 1);
|
||||
this.config.set("Worlds.Normal.RandomBlocks", oldConfig.get("Lists.RandomBlocks"));
|
||||
this.config.set("Worlds.Normal.ObfuscateBlocks", oldConfig.get("Lists.ObfuscateBlocks"));
|
||||
|
||||
//Nether World
|
||||
this.config.set("Worlds.Nether.Types", new String[] { "NETHER" });
|
||||
this.config.set("Worlds.Nether.Mode1Block", 87);
|
||||
this.config.set("Worlds.Nether.RandomBlocks", oldConfig.get("Lists.NetherRandomBlocks"));
|
||||
this.config.set("Worlds.Nether.ObfuscateBlocks", oldConfig.get("Lists.NetherObfuscateBlocks"));
|
||||
|
||||
List<String> worldNames = oldConfig.getStringList("Lists.Worlds");
|
||||
|
||||
if(worldNames == null) {
|
||||
worldNames = oldConfig.getStringList("Lists.DisabledWorlds");
|
||||
}
|
||||
|
||||
if(worldNames != null && worldNames.size() > 0) {
|
||||
this.config.set("Worlds.CustomWorld.Names", worldNames);
|
||||
this.config.set("Worlds.CustomWorld.Enabled", !worldEnabled);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,150 @@
|
|||
/**
|
||||
* @author Aleksey Terzi
|
||||
*
|
||||
*/
|
||||
|
||||
package com.lishid.orebfuscator.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Material;
|
||||
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 MaterialReader {
|
||||
private static class MaterialResult {
|
||||
public Integer id;
|
||||
public String name;
|
||||
|
||||
public MaterialResult(int id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
private JavaPlugin plugin;
|
||||
private Logger logger;
|
||||
|
||||
public MaterialReader(JavaPlugin plugin, Logger logger) {
|
||||
this.plugin = plugin;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
private FileConfiguration getConfig() {
|
||||
return this.plugin.getConfig();
|
||||
}
|
||||
|
||||
public Integer getMaterialId(String materialName) {
|
||||
return getMaterial(materialName, null).id;
|
||||
}
|
||||
|
||||
public Integer getMaterialIdByPath(String path, Integer defaultMaterialId, boolean withSave) {
|
||||
boolean hasKey = getConfig().get(path) != null;
|
||||
|
||||
if(!hasKey && defaultMaterialId == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String materialName = hasKey ? getConfig().getString(path): Integer.toString(defaultMaterialId);
|
||||
MaterialResult material = getMaterial(materialName, defaultMaterialId);
|
||||
|
||||
if(withSave || hasKey) {
|
||||
getConfig().set(path, material.name);
|
||||
}
|
||||
|
||||
return material.id;
|
||||
}
|
||||
|
||||
public Integer[] getMaterialIdsByPath(String path, Integer[] defaultMaterials, boolean withSave) {
|
||||
List<String> list;
|
||||
|
||||
if(getConfig().get(path) != null) {
|
||||
list = getConfig().getStringList(path);
|
||||
withSave = true;
|
||||
} else {
|
||||
if(defaultMaterials != null) {
|
||||
list = new ArrayList<String>();
|
||||
|
||||
for(int materialId : defaultMaterials) {
|
||||
list.add(DeprecatedMethods.getMaterial(materialId).name());
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
List<Integer> result = new ArrayList<Integer>();
|
||||
|
||||
for(int i = 0; i < list.size(); i++) {
|
||||
MaterialResult material = getMaterial(list.get(i), null);
|
||||
|
||||
if(material != null) {
|
||||
list.set(i, material.name);
|
||||
result.add(material.id);
|
||||
}
|
||||
}
|
||||
|
||||
if(withSave) {
|
||||
getConfig().set(path, list);
|
||||
}
|
||||
|
||||
return result.toArray(new Integer[0]);
|
||||
}
|
||||
|
||||
private MaterialResult getMaterial(String materialName, Integer defaultMaterialId) {
|
||||
Integer materialId;
|
||||
String defaultMaterialName = defaultMaterialId != null ? DeprecatedMethods.getMaterial(defaultMaterialId).name(): null;
|
||||
|
||||
try {
|
||||
if(Character.isDigit(materialName.charAt(0))) {
|
||||
materialId = Integer.parseInt(materialName);
|
||||
|
||||
Material obj = DeprecatedMethods.getMaterial(materialId);
|
||||
|
||||
if(obj != null) {
|
||||
materialName = obj.name();
|
||||
} else {
|
||||
if(defaultMaterialId != null) {
|
||||
this.logger.info(Globals.LogPrefix + "Material with ID = " + materialId + " is not found. Will be used default material: " + defaultMaterialName);
|
||||
materialId = defaultMaterialId;
|
||||
materialName = defaultMaterialName;
|
||||
} else {
|
||||
this.logger.info(Globals.LogPrefix + "Material with ID = " + materialId + " is not found. Skipped.");
|
||||
materialId = null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Material obj = Material.getMaterial(materialName.toUpperCase());
|
||||
|
||||
if(obj != null) {
|
||||
materialId = DeprecatedMethods.getMaterialId(obj);
|
||||
} else {
|
||||
if(defaultMaterialId != null) {
|
||||
this.logger.info(Globals.LogPrefix + "Material " + materialName + " is not found. Will be used default material: " + defaultMaterialName);
|
||||
materialId = defaultMaterialId;
|
||||
materialName = defaultMaterialName;
|
||||
} else {
|
||||
this.logger.info(Globals.LogPrefix + "Material " + materialName + " is not found. Skipped.");
|
||||
materialId = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if(defaultMaterialId != null) {
|
||||
this.logger.info(Globals.LogPrefix + "Invalid material ID or name: " + materialName + ". Will be used default material: " + defaultMaterialName);
|
||||
materialId = defaultMaterialId;
|
||||
materialName = defaultMaterialName;
|
||||
} else {
|
||||
this.logger.info(Globals.LogPrefix + "Invalid material ID or name: " + materialName + ". Skipped.");
|
||||
materialId = null;
|
||||
}
|
||||
}
|
||||
|
||||
return materialId != null ? new MaterialResult(materialId, materialName): null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,305 @@
|
|||
/**
|
||||
* @author Aleksey Terzi
|
||||
*
|
||||
*/
|
||||
|
||||
package com.lishid.orebfuscator.config;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.lishid.orebfuscator.Orebfuscator;
|
||||
|
||||
public class OrebfuscatorConfig {
|
||||
// Caching
|
||||
private boolean useCache;
|
||||
private int maxLoadedCacheFiles;
|
||||
private String cacheLocation;
|
||||
private int deleteCacheFilesAfterDays;
|
||||
|
||||
// Main engine config
|
||||
private boolean enabled;
|
||||
private boolean updateOnDamage;
|
||||
private int engineMode;
|
||||
private int initialRadius;
|
||||
private int updateRadius;
|
||||
private boolean noObfuscationForMetadata;
|
||||
private String noObfuscationForMetadataTagName;
|
||||
private boolean noObfuscationForOps;
|
||||
private boolean noObfuscationForPermission;
|
||||
private boolean loginNotification;
|
||||
|
||||
private boolean[] transparentBlocks;
|
||||
|
||||
private WorldConfig defaultWorld;
|
||||
private WorldConfig normalWorld;
|
||||
private WorldConfig endWorld;
|
||||
private WorldConfig netherWorld;
|
||||
private Map<String, WorldConfig> worlds;
|
||||
|
||||
private boolean proximityHiderEnabled;
|
||||
|
||||
private static final int antiHitHackDecrementFactor = 1000;
|
||||
private static final int antiHitHackMaxViolation = 15;
|
||||
private static final int proximityHiderRate = 500;
|
||||
private static final int chunkReloaderRate = 500;
|
||||
private static final boolean useChunkReloader = false;
|
||||
private static final long cacheCleanRate = 60 * 60 * 20;//once per hour
|
||||
|
||||
public boolean isUseCache() {
|
||||
return this.useCache;
|
||||
}
|
||||
|
||||
public void setUseCache(boolean value) {
|
||||
this.useCache = value;
|
||||
}
|
||||
|
||||
public int getMaxLoadedCacheFiles() {
|
||||
return this.maxLoadedCacheFiles;
|
||||
}
|
||||
|
||||
public void setMaxLoadedCacheFiles(int value) {
|
||||
this.maxLoadedCacheFiles = value;
|
||||
}
|
||||
|
||||
public String getCacheLocation() {
|
||||
return this.cacheLocation;
|
||||
}
|
||||
|
||||
public void setCacheLocation(String value) {
|
||||
this.cacheLocation = value;
|
||||
}
|
||||
|
||||
public int getDeleteCacheFilesAfterDays() {
|
||||
return this.deleteCacheFilesAfterDays;
|
||||
}
|
||||
|
||||
public void setDeleteCacheFilesAfterDays(int value) {
|
||||
this.deleteCacheFilesAfterDays = value;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean value) {
|
||||
this.enabled = value;
|
||||
}
|
||||
|
||||
public boolean isUpdateOnDamage() {
|
||||
return this.updateOnDamage;
|
||||
}
|
||||
|
||||
public void setUpdateOnDamage(boolean value) {
|
||||
this.updateOnDamage = value;
|
||||
}
|
||||
|
||||
public int getEngineMode() {
|
||||
return this.engineMode;
|
||||
}
|
||||
|
||||
public void setEngineMode(int value) {
|
||||
this.engineMode = value;
|
||||
}
|
||||
|
||||
public int getInitialRadius() {
|
||||
return this.initialRadius;
|
||||
}
|
||||
|
||||
public void setInitialRadius(int value) {
|
||||
this.initialRadius = value;
|
||||
}
|
||||
|
||||
public int getUpdateRadius() {
|
||||
return this.updateRadius;
|
||||
}
|
||||
|
||||
public void setUpdateRadius(int value) {
|
||||
this.updateRadius = value;
|
||||
}
|
||||
|
||||
public boolean isNoObfuscationForMetadata() {
|
||||
return this.noObfuscationForMetadata;
|
||||
}
|
||||
|
||||
public void setNoObfuscationForMetadata(boolean value) {
|
||||
this.noObfuscationForMetadata = value;
|
||||
}
|
||||
|
||||
public String getNoObfuscationForMetadataTagName() {
|
||||
return this.noObfuscationForMetadataTagName;
|
||||
}
|
||||
|
||||
public void setNoObfuscationForMetadataTagName(String value) {
|
||||
this.noObfuscationForMetadataTagName = value;
|
||||
}
|
||||
|
||||
public boolean isNoObfuscationForOps() {
|
||||
return this.noObfuscationForOps;
|
||||
}
|
||||
|
||||
public void setNoObfuscationForOps(boolean value) {
|
||||
this.noObfuscationForOps = value;
|
||||
}
|
||||
|
||||
public boolean isNoObfuscationForPermission() {
|
||||
return this.noObfuscationForPermission;
|
||||
}
|
||||
|
||||
public void setNoObfuscationForPermission(boolean value) {
|
||||
this.noObfuscationForPermission = value;
|
||||
}
|
||||
|
||||
public boolean isLoginNotification() {
|
||||
return this.loginNotification;
|
||||
}
|
||||
|
||||
public void setLoginNotification(boolean value) {
|
||||
this.loginNotification = value;
|
||||
}
|
||||
|
||||
public boolean[] getTransparentBlocks() {
|
||||
return this.transparentBlocks;
|
||||
}
|
||||
|
||||
public void setTransparentBlocks(boolean[] value) {
|
||||
this.transparentBlocks = value;
|
||||
}
|
||||
|
||||
public WorldConfig getDefaultWorld() {
|
||||
return this.defaultWorld;
|
||||
}
|
||||
|
||||
public void setDefaultWorld(WorldConfig value) {
|
||||
this.defaultWorld = value;
|
||||
}
|
||||
|
||||
public WorldConfig getNormalWorld() {
|
||||
return this.normalWorld;
|
||||
}
|
||||
|
||||
public void setNormalWorld(WorldConfig value) {
|
||||
this.normalWorld = value;
|
||||
}
|
||||
|
||||
public WorldConfig getEndWorld() {
|
||||
return this.endWorld;
|
||||
}
|
||||
|
||||
public void setEndWorld(WorldConfig value) {
|
||||
this.endWorld = value;
|
||||
}
|
||||
|
||||
public WorldConfig getNetherWorld() {
|
||||
return this.netherWorld;
|
||||
}
|
||||
|
||||
public void setNetherWorld(WorldConfig value) {
|
||||
this.netherWorld = value;
|
||||
}
|
||||
|
||||
public Map<String, WorldConfig> getWorlds() {
|
||||
return this.worlds;
|
||||
}
|
||||
|
||||
public void setWorlds(Map<String, WorldConfig> value) {
|
||||
this.worlds = value;
|
||||
}
|
||||
|
||||
public boolean isProximityHiderEnabled() {
|
||||
return this.proximityHiderEnabled;
|
||||
}
|
||||
|
||||
public void setProximityHiderEnabled() {
|
||||
this.proximityHiderEnabled = this.normalWorld.getProximityHiderConfig().isEnabled()
|
||||
|| this.endWorld.getProximityHiderConfig().isEnabled()
|
||||
|| this.netherWorld.getProximityHiderConfig().isEnabled()
|
||||
;
|
||||
|
||||
if(!this.proximityHiderEnabled) {
|
||||
for(WorldConfig world : this.worlds.values()) {
|
||||
if(world.getProximityHiderConfig().isEnabled() != null && world.getProximityHiderConfig().isEnabled()) {
|
||||
this.proximityHiderEnabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getAntiHitHackDecrementFactor() {
|
||||
return antiHitHackDecrementFactor;
|
||||
}
|
||||
|
||||
public int getAntiHitHackMaxViolation() {
|
||||
return antiHitHackMaxViolation;
|
||||
}
|
||||
|
||||
public int getProximityHiderRate() {
|
||||
return proximityHiderRate;
|
||||
}
|
||||
|
||||
public int getChunkReloaderRate() {
|
||||
return chunkReloaderRate;
|
||||
}
|
||||
|
||||
public boolean isUseChunkReloader() {
|
||||
return useChunkReloader;
|
||||
}
|
||||
|
||||
public long getCacheCleanRate() {
|
||||
return cacheCleanRate;
|
||||
}
|
||||
|
||||
// Helper methods
|
||||
|
||||
public boolean isBlockTransparent(int id) {
|
||||
if (id < 0)
|
||||
id += 256;
|
||||
|
||||
if (id >= 256) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.transparentBlocks[id];
|
||||
}
|
||||
|
||||
public boolean obfuscateForPlayer(Player player) {
|
||||
return !(playerBypassOp(player) || playerBypassPerms(player) || playerBypassMetadata(player));
|
||||
}
|
||||
|
||||
public boolean playerBypassOp(Player player) {
|
||||
boolean ret = false;
|
||||
try {
|
||||
ret = this.noObfuscationForOps && player.isOp();
|
||||
} catch (Exception e) {
|
||||
Orebfuscator.log("Error while obtaining Operator status for player" + player.getName() + ": " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean playerBypassPerms(Player player) {
|
||||
boolean ret = false;
|
||||
try {
|
||||
ret = this.noObfuscationForPermission && player.hasPermission("Orebfuscator.deobfuscate");
|
||||
} catch (Exception e) {
|
||||
Orebfuscator.log("Error while obtaining permissions for player" + player.getName() + ": " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean playerBypassMetadata(Player player) {
|
||||
boolean ret = false;
|
||||
try {
|
||||
ret = this.noObfuscationForMetadata
|
||||
&& player.hasMetadata(this.noObfuscationForMetadataTagName)
|
||||
&& player.getMetadata(this.noObfuscationForMetadataTagName).get(0).asBoolean();
|
||||
} catch (Exception e) {
|
||||
Orebfuscator.log("Error while obtaining metadata for player" + player.getName() + ": " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,193 @@
|
|||
/**
|
||||
* @author Aleksey Terzi
|
||||
*
|
||||
*/
|
||||
|
||||
package com.lishid.orebfuscator.config;
|
||||
|
||||
|
||||
public class ProximityHiderConfig {
|
||||
public static class BlockSetting implements Cloneable {
|
||||
public int blockId;
|
||||
public int y;
|
||||
public boolean obfuscateAboveY;
|
||||
|
||||
public BlockSetting clone() throws CloneNotSupportedException {
|
||||
BlockSetting clone = new BlockSetting();
|
||||
clone.blockId = this.blockId;
|
||||
clone.y = this.y;
|
||||
clone.obfuscateAboveY = this.obfuscateAboveY;
|
||||
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
|
||||
private static final Integer[] defaultProximityHiderBlockIds = new Integer[]{ 23, 52, 54, 56, 58, 61, 62, 116, 129, 130, 145, 146 };
|
||||
|
||||
private Boolean enabled;
|
||||
private Integer distance;
|
||||
private int distanceSquared;
|
||||
private Integer specialBlockID;
|
||||
private Integer y;
|
||||
private Boolean useSpecialBlock;
|
||||
private Boolean obfuscateAboveY;
|
||||
private Integer[] proximityHiderBlockIds;
|
||||
private BlockSetting[] proximityHiderBlockSettings;
|
||||
private int[] proximityHiderBlockMatrix;
|
||||
|
||||
public void setDefaults() {
|
||||
this.enabled = true;
|
||||
this.distance = 8;
|
||||
this.distanceSquared = this.distance * this.distance;
|
||||
this.specialBlockID = 1;
|
||||
this.y = 255;
|
||||
this.useSpecialBlock = true;
|
||||
this.obfuscateAboveY = false;
|
||||
this.proximityHiderBlockIds = defaultProximityHiderBlockIds;
|
||||
}
|
||||
|
||||
public void init(ProximityHiderConfig baseCfg) {
|
||||
if(this.enabled == null) {
|
||||
this.enabled = baseCfg.enabled;
|
||||
}
|
||||
|
||||
if(this.distance == null) {
|
||||
this.distance = baseCfg.distance;
|
||||
this.distanceSquared = baseCfg.distanceSquared;
|
||||
}
|
||||
|
||||
if(this.specialBlockID == null) {
|
||||
this.specialBlockID = baseCfg.specialBlockID;
|
||||
}
|
||||
|
||||
if(this.y == null) {
|
||||
this.y = baseCfg.y;
|
||||
}
|
||||
|
||||
if(this.useSpecialBlock == null) {
|
||||
this.useSpecialBlock = baseCfg.useSpecialBlock;
|
||||
}
|
||||
|
||||
if(this.obfuscateAboveY == null) {
|
||||
this.obfuscateAboveY = baseCfg.obfuscateAboveY;
|
||||
}
|
||||
|
||||
if(this.proximityHiderBlockIds == null && baseCfg.proximityHiderBlockIds != null) {
|
||||
this.proximityHiderBlockIds = baseCfg.proximityHiderBlockIds.clone();
|
||||
}
|
||||
|
||||
if(this.proximityHiderBlockSettings == null && baseCfg.proximityHiderBlockSettings != null) {
|
||||
this.proximityHiderBlockSettings = baseCfg.proximityHiderBlockSettings.clone();
|
||||
}
|
||||
|
||||
setProximityHiderBlockMatrix();
|
||||
}
|
||||
|
||||
public Boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(Boolean value) {
|
||||
this.enabled = value;
|
||||
}
|
||||
|
||||
public Integer getDistance() {
|
||||
return this.distance;
|
||||
}
|
||||
|
||||
public void setDistance(Integer value) {
|
||||
this.distance = value;
|
||||
this.distanceSquared = this.distance != null ? this.distance * this.distance: 0;
|
||||
}
|
||||
|
||||
public int getDistanceSquared() {
|
||||
return this.distanceSquared;
|
||||
}
|
||||
|
||||
public Integer getSpecialBlockID() {
|
||||
return this.specialBlockID;
|
||||
}
|
||||
|
||||
public void setSpecialBlockID(Integer value) {
|
||||
this.specialBlockID = value;
|
||||
}
|
||||
|
||||
public Integer getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public void setY(Integer value) {
|
||||
this.y = value;
|
||||
}
|
||||
|
||||
public Boolean isUseSpecialBlock() {
|
||||
return this.useSpecialBlock;
|
||||
}
|
||||
|
||||
public void setUseSpecialBlock(Boolean value) {
|
||||
this.useSpecialBlock = value;
|
||||
}
|
||||
|
||||
public Boolean isObfuscateAboveY() {
|
||||
return this.obfuscateAboveY;
|
||||
}
|
||||
|
||||
public void setObfuscateAboveY(Boolean value) {
|
||||
this.obfuscateAboveY = value;
|
||||
}
|
||||
|
||||
public void setProximityHiderBlockIds(Integer[] value) {
|
||||
this.proximityHiderBlockIds = value;
|
||||
}
|
||||
|
||||
public Integer[] getProximityHiderBlockIds() {
|
||||
return this.proximityHiderBlockIds;
|
||||
}
|
||||
|
||||
public BlockSetting[] getProximityHiderBlockSettings() {
|
||||
return this.proximityHiderBlockSettings;
|
||||
}
|
||||
|
||||
public void setProximityHiderBlockSettings(BlockSetting[] value) {
|
||||
this.proximityHiderBlockSettings = value;
|
||||
}
|
||||
|
||||
public int[] getProximityHiderBlockMatrix() {
|
||||
return this.proximityHiderBlockMatrix;
|
||||
}
|
||||
|
||||
private void setProximityHiderBlockMatrix() {
|
||||
this.proximityHiderBlockMatrix = new int[256];
|
||||
|
||||
if(this.proximityHiderBlockIds != null) {
|
||||
for(int blockId : this.proximityHiderBlockIds) {
|
||||
this.proximityHiderBlockMatrix[blockId] = this.obfuscateAboveY ? -this.y: this.y;
|
||||
}
|
||||
}
|
||||
|
||||
if(this.proximityHiderBlockSettings != null) {
|
||||
for(BlockSetting block : this.proximityHiderBlockSettings) {
|
||||
this.proximityHiderBlockMatrix[block.blockId] = block.obfuscateAboveY ? -block.y: block.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Help methods
|
||||
|
||||
public boolean isProximityObfuscated(int y, int id) {
|
||||
if (id < 0)
|
||||
id += 256;
|
||||
|
||||
int proximityY = this.proximityHiderBlockMatrix[id];
|
||||
|
||||
if(proximityY == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(proximityY > 0) {
|
||||
return y <= proximityY;
|
||||
}
|
||||
|
||||
return y >= (proximityY & 0x7FFFFFFF);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,288 @@
|
|||
/**
|
||||
* @author Aleksey Terzi
|
||||
*
|
||||
*/
|
||||
|
||||
package com.lishid.orebfuscator.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class WorldConfig {
|
||||
private Boolean enabled;
|
||||
private Boolean darknessHideBlocks;
|
||||
private Boolean antiTexturePackAndFreecam;
|
||||
private Integer airGeneratorMaxChance;
|
||||
private boolean[] obfuscateBlocks;
|
||||
private boolean[] obfuscateAndProximityBlocks;
|
||||
private boolean[] darknessBlocks;
|
||||
private Integer[] randomBlocks;
|
||||
private Integer[] randomBlocks2;
|
||||
private Integer mode1BlockId;
|
||||
private int[] paletteBlocks;
|
||||
private ProximityHiderConfig proximityHiderConfig;
|
||||
private boolean initialized;
|
||||
|
||||
public WorldConfig() {
|
||||
this.proximityHiderConfig = new ProximityHiderConfig();
|
||||
}
|
||||
|
||||
public void setDefaults() {
|
||||
this.enabled = true;
|
||||
this.darknessHideBlocks = false;
|
||||
this.antiTexturePackAndFreecam = true;
|
||||
this.airGeneratorMaxChance = 43;
|
||||
this.obfuscateBlocks = new boolean[256];
|
||||
|
||||
this.darknessBlocks = new boolean[256];
|
||||
this.darknessBlocks[52] = true;
|
||||
this.darknessBlocks[54] = true;
|
||||
|
||||
this.randomBlocks = new Integer[0];
|
||||
this.randomBlocks2 = this.randomBlocks;
|
||||
|
||||
this.mode1BlockId = 1;
|
||||
this.paletteBlocks = null;
|
||||
|
||||
this.proximityHiderConfig.setDefaults();
|
||||
}
|
||||
|
||||
public void init(WorldConfig baseWorld) {
|
||||
if(this.initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(baseWorld != null) {
|
||||
if(this.enabled == null) {
|
||||
this.enabled = baseWorld.enabled;
|
||||
}
|
||||
|
||||
if(this.darknessHideBlocks == null) {
|
||||
this.darknessHideBlocks = baseWorld.darknessHideBlocks;
|
||||
}
|
||||
|
||||
if(this.antiTexturePackAndFreecam == null) {
|
||||
this.antiTexturePackAndFreecam = baseWorld.antiTexturePackAndFreecam;
|
||||
}
|
||||
|
||||
if(this.airGeneratorMaxChance == null) {
|
||||
this.airGeneratorMaxChance = baseWorld.airGeneratorMaxChance;
|
||||
}
|
||||
|
||||
if(this.obfuscateBlocks == null) {
|
||||
this.obfuscateBlocks = baseWorld.obfuscateBlocks != null ? baseWorld.obfuscateBlocks.clone(): null;
|
||||
}
|
||||
|
||||
if(this.darknessBlocks == null) {
|
||||
this.darknessBlocks = baseWorld.darknessBlocks != null ? baseWorld.darknessBlocks.clone(): null;
|
||||
}
|
||||
|
||||
if(this.randomBlocks == null) {
|
||||
this.randomBlocks = baseWorld.randomBlocks != null ? baseWorld.randomBlocks.clone(): null;
|
||||
this.randomBlocks2 = baseWorld.randomBlocks2 != null ? baseWorld.randomBlocks2.clone(): null;
|
||||
}
|
||||
|
||||
if(this.mode1BlockId == null) {
|
||||
this.mode1BlockId = baseWorld.mode1BlockId;
|
||||
}
|
||||
|
||||
this.proximityHiderConfig.init(baseWorld.proximityHiderConfig);
|
||||
setObfuscateAndProximityBlocks();
|
||||
}
|
||||
|
||||
setPaletteBlocks();
|
||||
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
public boolean isInitialized() {
|
||||
return this.initialized;
|
||||
}
|
||||
|
||||
public Boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(Boolean value) {
|
||||
this.enabled = value;
|
||||
}
|
||||
|
||||
public Boolean isDarknessHideBlocks() {
|
||||
return this.darknessHideBlocks;
|
||||
}
|
||||
|
||||
public void setDarknessHideBlocks(Boolean value) {
|
||||
this.darknessHideBlocks = value;
|
||||
}
|
||||
|
||||
public Boolean isAntiTexturePackAndFreecam() {
|
||||
return this.antiTexturePackAndFreecam;
|
||||
}
|
||||
|
||||
public void setAntiTexturePackAndFreecam(Boolean value) {
|
||||
this.antiTexturePackAndFreecam = value;
|
||||
}
|
||||
|
||||
public Integer getAirGeneratorMaxChance() {
|
||||
return this.airGeneratorMaxChance;
|
||||
}
|
||||
|
||||
public void setAirGeneratorMaxChance(Integer value) {
|
||||
this.airGeneratorMaxChance = value;
|
||||
}
|
||||
|
||||
public boolean[] getObfuscateBlocks() {
|
||||
return this.obfuscateBlocks;
|
||||
}
|
||||
|
||||
public void setObfuscateBlocks(boolean[] values) {
|
||||
this.obfuscateBlocks = values;
|
||||
}
|
||||
|
||||
public Integer[] getObfuscateBlockIds() {
|
||||
if(this.obfuscateBlocks == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Integer> result = new ArrayList<Integer>();
|
||||
|
||||
for(int i = 0; i < this.obfuscateBlocks.length; i++) {
|
||||
if(this.obfuscateBlocks[i]) {
|
||||
result.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
return result.toArray(new Integer[0]);
|
||||
}
|
||||
|
||||
private void setObfuscateAndProximityBlocks() {
|
||||
this.obfuscateAndProximityBlocks = new boolean[256];
|
||||
|
||||
boolean isProximityHiderEnabled = this.proximityHiderConfig != null && this.proximityHiderConfig.isEnabled();
|
||||
int[] proximityHiderBlocks = isProximityHiderEnabled ? this.proximityHiderConfig.getProximityHiderBlockMatrix(): null;
|
||||
|
||||
for(int i = 0; i < this.obfuscateAndProximityBlocks.length; i++) {
|
||||
this.obfuscateAndProximityBlocks[i] =
|
||||
this.obfuscateBlocks[i]
|
||||
|| isProximityHiderEnabled && proximityHiderBlocks[i] != 0
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean[] getDarknessBlocks() {
|
||||
return this.darknessBlocks;
|
||||
}
|
||||
|
||||
public void setDarknessBlocks(boolean[] values) {
|
||||
this.darknessBlocks = values;
|
||||
}
|
||||
|
||||
public Integer[] getDarknessBlockIds() {
|
||||
if(this.darknessBlocks == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Integer> result = new ArrayList<Integer>();
|
||||
|
||||
for(int i = 0; i < this.darknessBlocks.length; i++) {
|
||||
if(this.darknessBlocks[i]) {
|
||||
result.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
return result.toArray(new Integer[0]);
|
||||
}
|
||||
|
||||
public Integer[] getRandomBlocks() {
|
||||
return this.randomBlocks;
|
||||
}
|
||||
|
||||
public Integer[] getRandomBlocks2() {
|
||||
return this.randomBlocks2;
|
||||
}
|
||||
|
||||
public void setRandomBlocks(Integer[] values) {
|
||||
this.randomBlocks = values;
|
||||
this.randomBlocks2 = values;
|
||||
}
|
||||
|
||||
public void shuffleRandomBlocks() {
|
||||
synchronized (this.randomBlocks) {
|
||||
Collections.shuffle(Arrays.asList(this.randomBlocks));
|
||||
Collections.shuffle(Arrays.asList(this.randomBlocks2));
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getMode1BlockId() {
|
||||
return this.mode1BlockId;
|
||||
}
|
||||
|
||||
public void setMode1BlockId(Integer value) {
|
||||
this.mode1BlockId = value;
|
||||
}
|
||||
|
||||
public int[] getPaletteBlocks() {
|
||||
return this.paletteBlocks;
|
||||
}
|
||||
|
||||
private void setPaletteBlocks() {
|
||||
if(this.randomBlocks == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
HashSet<Integer> map = new HashSet<Integer>();
|
||||
|
||||
map.add(0);
|
||||
map.add(this.mode1BlockId);
|
||||
|
||||
if(this.proximityHiderConfig.isUseSpecialBlock()) {
|
||||
map.add(this.proximityHiderConfig.getSpecialBlockID());
|
||||
}
|
||||
|
||||
for(Integer id : this.randomBlocks) {
|
||||
if(id != null) {
|
||||
map.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
int[] paletteBlocks = new int[map.size()];
|
||||
int index = 0;
|
||||
|
||||
for(Integer id : map) {
|
||||
paletteBlocks[index++] = id;
|
||||
}
|
||||
|
||||
this.paletteBlocks = paletteBlocks;
|
||||
}
|
||||
|
||||
public ProximityHiderConfig getProximityHiderConfig() {
|
||||
return this.proximityHiderConfig;
|
||||
}
|
||||
|
||||
public void setProximityHiderConfig(ProximityHiderConfig value) {
|
||||
this.proximityHiderConfig = value;
|
||||
}
|
||||
|
||||
// Helper methods
|
||||
|
||||
public boolean isObfuscated(int id) {
|
||||
if (id < 0)
|
||||
id += 256;
|
||||
|
||||
return this.obfuscateAndProximityBlocks[id];
|
||||
}
|
||||
|
||||
public boolean isDarknessObfuscated(int id) {
|
||||
if (id < 0)
|
||||
id += 256;
|
||||
|
||||
return this.darknessBlocks[id];
|
||||
}
|
||||
|
||||
public int getRandomBlock(int index, boolean alternate) {
|
||||
return (int)(alternate ? this.randomBlocks2[index] : this.randomBlocks[index]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,430 @@
|
|||
/**
|
||||
* @author Aleksey Terzi
|
||||
*
|
||||
*/
|
||||
|
||||
package com.lishid.orebfuscator.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.lishid.orebfuscator.utils.Globals;
|
||||
|
||||
public class WorldReader {
|
||||
private static enum WorldType { Default, Normal, TheEnd, Nether }
|
||||
|
||||
private boolean[] transparentBlocks;
|
||||
|
||||
private WorldConfig defaultWorld;
|
||||
private WorldConfig normalWorld;
|
||||
private WorldConfig endWorld;
|
||||
private WorldConfig netherWorld;
|
||||
private Map<String, WorldConfig> worlds;
|
||||
|
||||
private JavaPlugin plugin;
|
||||
private Logger logger;
|
||||
private OrebfuscatorConfig orebfuscatorConfig;
|
||||
private MaterialReader materialReader;
|
||||
|
||||
public WorldReader(
|
||||
JavaPlugin plugin,
|
||||
Logger logger,
|
||||
OrebfuscatorConfig orebfuscatorConfig,
|
||||
MaterialReader materialReader
|
||||
)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
this.logger = logger;
|
||||
this.orebfuscatorConfig = orebfuscatorConfig;
|
||||
this.materialReader = materialReader;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
this.transparentBlocks = this.orebfuscatorConfig.getTransparentBlocks();
|
||||
|
||||
ConfigurationSection section = getConfig().getConfigurationSection("Worlds");
|
||||
Set<String> keys = section != null ? section.getKeys(false): new HashSet<String>();
|
||||
|
||||
this.defaultWorld = readWorldByType(keys, WorldType.Default, null);
|
||||
this.normalWorld = readWorldByType(keys, WorldType.Normal, this.defaultWorld);
|
||||
this.endWorld = readWorldByType(keys, WorldType.TheEnd, this.defaultWorld);
|
||||
this.netherWorld = readWorldByType(keys, WorldType.Nether, this.defaultWorld);
|
||||
|
||||
this.worlds = new WeakHashMap<String, WorldConfig>();
|
||||
|
||||
for(String key : keys) {
|
||||
readWorldsByName("Worlds." + key);
|
||||
}
|
||||
|
||||
this.orebfuscatorConfig.setDefaultWorld(this.defaultWorld);
|
||||
this.orebfuscatorConfig.setNormalWorld(this.normalWorld);
|
||||
this.orebfuscatorConfig.setEndWorld(this.endWorld);
|
||||
this.orebfuscatorConfig.setNetherWorld(this.netherWorld);
|
||||
this.orebfuscatorConfig.setWorlds(this.worlds);
|
||||
}
|
||||
|
||||
private FileConfiguration getConfig() {
|
||||
return this.plugin.getConfig();
|
||||
}
|
||||
|
||||
public static String createPath(String path, String key, FileConfiguration config) {
|
||||
int counter = 1;
|
||||
String newPath = path + "." + key;
|
||||
|
||||
while(config.get(newPath) != null) {
|
||||
newPath = path + "." + key + (counter++);
|
||||
}
|
||||
|
||||
return newPath;
|
||||
}
|
||||
|
||||
private WorldConfig readWorldByType(Set<String> keys, WorldType worldType, WorldConfig baseWorld) {
|
||||
WorldConfig world = null;
|
||||
|
||||
for(String key : keys) {
|
||||
String worldPath = "Worlds." + key;
|
||||
List<String> types = getStringList(worldPath + ".Types", null, false);
|
||||
|
||||
if(types != null && types.size() > 0 && parseWorldTypes(types).contains(worldType)) {
|
||||
if(worldType == WorldType.Default) {
|
||||
world = new WorldConfig();
|
||||
world.setDefaults();
|
||||
}
|
||||
|
||||
world = readWorld(worldPath, world, worldType == WorldType.Default);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(world == null) {
|
||||
switch(worldType) {
|
||||
case Default:
|
||||
world = createDefaultWorld(createPath("Worlds", "Default", getConfig()));
|
||||
break;
|
||||
case Normal:
|
||||
world = createNormalWorld(createPath("Worlds", "Normal", getConfig()));
|
||||
break;
|
||||
case TheEnd:
|
||||
world = createEndWorld(createPath("Worlds", "TheEnd", getConfig()));
|
||||
break;
|
||||
case Nether:
|
||||
world = createNetherWorld(createPath("Worlds", "Nether", getConfig()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
world.init(baseWorld);
|
||||
|
||||
return world;
|
||||
}
|
||||
|
||||
private void readWorldsByName(String worldPath) {
|
||||
List<String> names = getStringList(worldPath + ".Names", null, false);
|
||||
|
||||
if(names == null || names.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for(String name : names) {
|
||||
String key = name.toLowerCase();
|
||||
|
||||
if(!this.worlds.containsKey(key)) {
|
||||
this.worlds.put(key, readWorld(worldPath, null, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<WorldType> parseWorldTypes(List<String> types) {
|
||||
List<WorldType> parsedTypes = new ArrayList<WorldType>();
|
||||
|
||||
for(String type : types) {
|
||||
WorldType worldType;
|
||||
|
||||
if(type.equalsIgnoreCase("DEFAULT")) {
|
||||
worldType = WorldType.Default;
|
||||
} else if(type.equalsIgnoreCase("NORMAL")) {
|
||||
worldType = WorldType.Normal;
|
||||
} else if(type.equalsIgnoreCase("THE_END")) {
|
||||
worldType = WorldType.TheEnd;
|
||||
} else if(type.equalsIgnoreCase("NETHER")) {
|
||||
worldType = WorldType.Nether;
|
||||
} else {
|
||||
this.logger.log(Level.WARNING, Globals.LogPrefix + "World type '" + type + "' is not supported.");
|
||||
continue;
|
||||
}
|
||||
|
||||
parsedTypes.add(worldType);
|
||||
}
|
||||
|
||||
return parsedTypes;
|
||||
}
|
||||
|
||||
private WorldConfig readWorld(String worldPath, WorldConfig cfg, boolean withSave) {
|
||||
if(cfg == null) {
|
||||
cfg = new WorldConfig();
|
||||
}
|
||||
|
||||
Boolean enabled = getBoolean(worldPath + ".Enabled", cfg.isEnabled(), withSave);
|
||||
Boolean antiTexturePackAndFreecam = getBoolean(worldPath + ".AntiTexturePackAndFreecam", cfg.isAntiTexturePackAndFreecam(), withSave);
|
||||
Integer airGeneratorMaxChance = getInt(worldPath + ".AirGeneratorMaxChance", cfg.getAirGeneratorMaxChance(), 40, 100, withSave);
|
||||
Boolean darknessHideBlocks = getBoolean(worldPath + ".DarknessHideBlocks", cfg.isDarknessHideBlocks(), withSave);
|
||||
boolean[] darknessBlocks = readBlockMatrix(cfg.getDarknessBlocks(), cfg.getDarknessBlockIds(), worldPath + ".DarknessBlocks", withSave);
|
||||
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);
|
||||
|
||||
readProximityHider(worldPath, cfg, withSave);
|
||||
|
||||
cfg.setEnabled(enabled);
|
||||
cfg.setAntiTexturePackAndFreecam(antiTexturePackAndFreecam);
|
||||
cfg.setAirGeneratorMaxChance(airGeneratorMaxChance);
|
||||
cfg.setDarknessHideBlocks(darknessHideBlocks);
|
||||
cfg.setDarknessBlocks(darknessBlocks);
|
||||
cfg.setMode1BlockId(mode1Block);
|
||||
cfg.setRandomBlocks(randomBlocks);
|
||||
cfg.setObfuscateBlocks(obfuscateBlocks);
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
private void readProximityHider(String worldPath, WorldConfig worldConfig, boolean withSave) {
|
||||
ProximityHiderConfig cfg = worldConfig.getProximityHiderConfig();
|
||||
|
||||
String sectionPath = worldPath + ".ProximityHider";
|
||||
Boolean enabled = getBoolean(sectionPath + ".Enabled", cfg.isEnabled(), withSave);
|
||||
Integer distance = getInt(sectionPath + ".Distance", cfg.getDistance(), 2, 64, withSave);
|
||||
Integer specialBlockID = this.materialReader.getMaterialIdByPath(sectionPath + ".SpecialBlock", cfg.getSpecialBlockID(), withSave);
|
||||
Integer y = getInt(sectionPath + ".Y", cfg.getY(), 0, 255, withSave);
|
||||
Boolean useSpecialBlock = getBoolean(sectionPath + ".UseSpecialBlock", cfg.isUseSpecialBlock(), withSave);
|
||||
Boolean useYLocationProximity = getBoolean(sectionPath + ".ObfuscateAboveY", cfg.isObfuscateAboveY(), withSave);
|
||||
Integer[] proximityHiderBlockIds = this.materialReader.getMaterialIdsByPath(sectionPath + ".ProximityHiderBlocks", cfg.getProximityHiderBlockIds(), withSave);
|
||||
ProximityHiderConfig.BlockSetting[] proximityHiderBlockSettings = readProximityHiderBlockSettings(sectionPath + ".ProximityHiderBlockSettings", cfg.getProximityHiderBlockSettings());
|
||||
|
||||
cfg.setEnabled(enabled);
|
||||
cfg.setDistance(distance);
|
||||
cfg.setSpecialBlockID(specialBlockID);
|
||||
cfg.setY(y);
|
||||
cfg.setUseSpecialBlock(useSpecialBlock);
|
||||
cfg.setObfuscateAboveY(useYLocationProximity);
|
||||
cfg.setProximityHiderBlockIds(proximityHiderBlockIds);
|
||||
cfg.setProximityHiderBlockSettings(proximityHiderBlockSettings);
|
||||
}
|
||||
|
||||
private ProximityHiderConfig.BlockSetting[] readProximityHiderBlockSettings(
|
||||
String configKey,
|
||||
ProximityHiderConfig.BlockSetting[] defaultBlocks
|
||||
)
|
||||
{
|
||||
ConfigurationSection section = getConfig().getConfigurationSection(configKey);
|
||||
|
||||
if(section == null) {
|
||||
return defaultBlocks;
|
||||
}
|
||||
|
||||
Set<String> keys = section.getKeys(false);
|
||||
|
||||
List<ProximityHiderConfig.BlockSetting> list = new ArrayList<ProximityHiderConfig.BlockSetting>();
|
||||
|
||||
for(String key : keys) {
|
||||
Integer blockId = this.materialReader.getMaterialId(key);
|
||||
|
||||
if(blockId == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String blockPath = configKey + "." + key;
|
||||
|
||||
ProximityHiderConfig.BlockSetting block = new ProximityHiderConfig.BlockSetting();
|
||||
block.blockId = blockId;
|
||||
block.y = getConfig().getInt(blockPath + ".Y", 255);
|
||||
block.obfuscateAboveY = getConfig().getBoolean(blockPath + ".ObfuscateAboveY", false);
|
||||
|
||||
list.add(block);
|
||||
}
|
||||
|
||||
return list.toArray(new ProximityHiderConfig.BlockSetting[0]);
|
||||
}
|
||||
|
||||
private boolean[] readBlockMatrix(boolean[] original, Integer[] defaultBlockIds, String configKey, boolean withSave) {
|
||||
boolean[] blocks = original;
|
||||
Integer[] blockIds = this.materialReader.getMaterialIdsByPath(configKey, defaultBlockIds, withSave);
|
||||
|
||||
if(blockIds != null) {
|
||||
if(blocks == null) {
|
||||
blocks = new boolean[256];
|
||||
}
|
||||
|
||||
setBlockValues(blocks, blockIds);
|
||||
}
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
private WorldConfig createDefaultWorld(String worldPath) {
|
||||
getConfig().set(worldPath + ".Types", new String[] { "DEFAULT" });
|
||||
|
||||
WorldConfig world = new WorldConfig();
|
||||
world.setDefaults();
|
||||
|
||||
return readWorld(worldPath, world, true);
|
||||
}
|
||||
|
||||
private WorldConfig createNormalWorld(String worldPath) {
|
||||
Integer[] randomBlocks = new Integer[]{ 1, 4, 5, 14, 15, 16, 21, 46, 48, 49, 56, 73, 82, 129 };
|
||||
Integer[] obfuscateBlockIds = new Integer[] { 14, 15, 16, 21, 54, 56, 73, 74, 129, 130 };
|
||||
|
||||
getConfig().set(worldPath + ".Types", new String[] { "NORMAL" });
|
||||
|
||||
this.materialReader.getMaterialIdByPath(worldPath + ".Mode1Block", 1, true);
|
||||
this.materialReader.getMaterialIdsByPath(worldPath + ".RandomBlocks", randomBlocks, true);
|
||||
this.materialReader.getMaterialIdsByPath(worldPath + ".ObfuscateBlocks", obfuscateBlockIds, true);
|
||||
|
||||
boolean[] obfuscateBlocks = new boolean[256];
|
||||
|
||||
setBlockValues(obfuscateBlocks, obfuscateBlockIds, false);
|
||||
|
||||
obfuscateBlocks[1] = true;
|
||||
|
||||
WorldConfig cfg = new WorldConfig();
|
||||
cfg.setObfuscateBlocks(obfuscateBlocks);
|
||||
cfg.setRandomBlocks(randomBlocks);
|
||||
cfg.setMode1BlockId(1);
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
private WorldConfig createEndWorld(String worldPath) {
|
||||
Integer[] randomBlocks = new Integer[]{ 7, 49, 121, 201, 206 };
|
||||
Integer[] obfuscateBlockIds = new Integer[] { 121 };
|
||||
|
||||
getConfig().set(worldPath + ".Types", new String[] { "THE_END" });
|
||||
|
||||
this.materialReader.getMaterialIdByPath(worldPath + ".Mode1Block", 121, true);
|
||||
this.materialReader.getMaterialIdsByPath(worldPath + ".RandomBlocks", randomBlocks, true);
|
||||
this.materialReader.getMaterialIdsByPath(worldPath + ".ObfuscateBlocks", obfuscateBlockIds, true);
|
||||
|
||||
boolean[] obfuscateBlocks = new boolean[256];
|
||||
|
||||
setBlockValues(obfuscateBlocks, obfuscateBlockIds, false);
|
||||
|
||||
obfuscateBlocks[121] = true;
|
||||
|
||||
WorldConfig cfg = new WorldConfig();
|
||||
cfg.setRandomBlocks(randomBlocks);
|
||||
cfg.setObfuscateBlocks(obfuscateBlocks);
|
||||
cfg.setMode1BlockId(121);
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
private WorldConfig createNetherWorld(String worldPath) {
|
||||
Integer[] randomBlocks = new Integer[]{ 13, 87, 88, 112, 153 };
|
||||
Integer[] obfuscateBlockIds = new Integer[]{ 87, 153 };
|
||||
|
||||
getConfig().set(worldPath + ".Types", new String[] { "NETHER" });
|
||||
|
||||
this.materialReader.getMaterialIdByPath(worldPath + ".Mode1Block", 87, true);
|
||||
this.materialReader.getMaterialIdsByPath(worldPath + ".RandomBlocks", randomBlocks, true);
|
||||
this.materialReader.getMaterialIdsByPath(worldPath + ".ObfuscateBlocks", obfuscateBlockIds, true);
|
||||
|
||||
boolean[] obfuscateBlocks = new boolean[256];
|
||||
|
||||
setBlockValues(obfuscateBlocks, obfuscateBlockIds, false);
|
||||
|
||||
obfuscateBlocks[87] = true;
|
||||
|
||||
WorldConfig cfg = new WorldConfig();
|
||||
cfg.setRandomBlocks(randomBlocks);
|
||||
cfg.setObfuscateBlocks(obfuscateBlocks);
|
||||
cfg.setMode1BlockId(87);
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
private static void setBlockValues(boolean[] boolArray, Integer[] blocks) {
|
||||
List<Integer> blockList = Arrays.asList(blocks);
|
||||
|
||||
for (int i = 0; i < boolArray.length; i++) {
|
||||
boolArray[i] = blockList.contains(i);
|
||||
}
|
||||
}
|
||||
|
||||
private void setBlockValues(boolean[] boolArray, Integer[] blocks, boolean transparent) {
|
||||
List<Integer> blockList = Arrays.asList(blocks);
|
||||
|
||||
for (int i = 0; i < boolArray.length; i++) {
|
||||
boolArray[i] = blockList.contains(i);
|
||||
|
||||
// If block is transparent while we don't want them to, or the other way around
|
||||
if (transparent != isBlockTransparent((short) i)) {
|
||||
// Remove it
|
||||
boolArray[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Integer getInt(String path, Integer defaultData, int min, int max, boolean withSave) {
|
||||
if (getConfig().get(path) == null && withSave) {
|
||||
getConfig().set(path, defaultData);
|
||||
}
|
||||
|
||||
Integer value = getConfig().get(path) != null ? (Integer)getConfig().getInt(path): defaultData;
|
||||
|
||||
if(value != null) {
|
||||
if(value < min) {
|
||||
value = min;
|
||||
}
|
||||
else if(value > max) {
|
||||
value = max;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private Boolean getBoolean(String path, Boolean defaultData, boolean withSave) {
|
||||
if (getConfig().get(path) == null) {
|
||||
if(!withSave) {
|
||||
return defaultData;
|
||||
}
|
||||
|
||||
getConfig().set(path, defaultData);
|
||||
}
|
||||
|
||||
return getConfig().get(path) != null ? (Boolean)getConfig().getBoolean(path): defaultData;
|
||||
}
|
||||
|
||||
private List<String> getStringList(String path, List<String> defaultData, boolean withSave) {
|
||||
if (getConfig().get(path) == null) {
|
||||
if(!withSave) {
|
||||
return defaultData;
|
||||
}
|
||||
|
||||
getConfig().set(path, defaultData);
|
||||
}
|
||||
|
||||
return getConfig().getStringList(path);
|
||||
}
|
||||
|
||||
private boolean isBlockTransparent(int id) {
|
||||
if (id < 0)
|
||||
id += 256;
|
||||
|
||||
if (id >= 256) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.transparentBlocks[id];
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@ import org.bukkit.GameMode;
|
|||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.lishid.orebfuscator.OrebfuscatorConfig;
|
||||
import com.lishid.orebfuscator.Orebfuscator;
|
||||
|
||||
public class BlockHitManager {
|
||||
private static HashMap<Player, PlayerBlockTracking> playersBlockTrackingStatus = new HashMap<Player, PlayerBlockTracking>();
|
||||
|
@ -42,13 +42,13 @@ public class BlockHitManager {
|
|||
playerBlockTracking.setBlock(block);
|
||||
playerBlockTracking.updateTime();
|
||||
|
||||
int decrement = (int) (time / OrebfuscatorConfig.AntiHitHackDecrementFactor);
|
||||
int decrement = (int) (time / Orebfuscator.config.getAntiHitHackDecrementFactor());
|
||||
playerBlockTracking.decrementHackingIndicator(decrement);
|
||||
|
||||
if (playerBlockTracking.getHackingIndicator() == OrebfuscatorConfig.AntiHitHackMaxViolation)
|
||||
playerBlockTracking.incrementHackingIndicator(OrebfuscatorConfig.AntiHitHackMaxViolation);
|
||||
if (playerBlockTracking.getHackingIndicator() == Orebfuscator.config.getAntiHitHackMaxViolation())
|
||||
playerBlockTracking.incrementHackingIndicator(Orebfuscator.config.getAntiHitHackMaxViolation());
|
||||
|
||||
if (playerBlockTracking.getHackingIndicator() > OrebfuscatorConfig.AntiHitHackMaxViolation)
|
||||
if (playerBlockTracking.getHackingIndicator() > Orebfuscator.config.getAntiHitHackMaxViolation())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -57,7 +57,7 @@ public class BlockHitManager {
|
|||
public static boolean canFakeHit(Player player) {
|
||||
PlayerBlockTracking playerBlockTracking = getPlayerBlockTracking(player);
|
||||
|
||||
if (playerBlockTracking.getHackingIndicator() > OrebfuscatorConfig.AntiHitHackMaxViolation)
|
||||
if (playerBlockTracking.getHackingIndicator() > Orebfuscator.config.getAntiHitHackMaxViolation())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -67,7 +67,7 @@ public class BlockHitManager {
|
|||
PlayerBlockTracking playerBlockTracking = getPlayerBlockTracking(player);
|
||||
playerBlockTracking.incrementHackingIndicator();
|
||||
|
||||
if (playerBlockTracking.getHackingIndicator() > OrebfuscatorConfig.AntiHitHackMaxViolation)
|
||||
if (playerBlockTracking.getHackingIndicator() > Orebfuscator.config.getAntiHitHackMaxViolation())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.bukkit.event.block.BlockPistonExtendEvent;
|
|||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
|
||||
import com.lishid.orebfuscator.DeprecatedMethods;
|
||||
import com.lishid.orebfuscator.OrebfuscatorConfig;
|
||||
import com.lishid.orebfuscator.Orebfuscator;
|
||||
import com.lishid.orebfuscator.hithack.BlockHitManager;
|
||||
import com.lishid.orebfuscator.obfuscation.BlockUpdate;
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class OrebfuscatorBlockListener implements Listener {
|
|||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockDamage(BlockDamageEvent event) {
|
||||
if (!OrebfuscatorConfig.UpdateOnDamage) {
|
||||
if (!Orebfuscator.config.isUpdateOnDamage()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
|||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
import com.lishid.orebfuscator.Orebfuscator;
|
||||
import com.lishid.orebfuscator.OrebfuscatorConfig;
|
||||
import com.lishid.orebfuscator.hithack.BlockHitManager;
|
||||
import com.lishid.orebfuscator.obfuscation.BlockUpdate;
|
||||
import com.lishid.orebfuscator.obfuscation.ProximityHider;
|
||||
|
@ -42,15 +41,15 @@ public class OrebfuscatorPlayerListener implements Listener {
|
|||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (OrebfuscatorConfig.LoginNotification) {
|
||||
if (OrebfuscatorConfig.playerBypassOp(player)) {
|
||||
if (Orebfuscator.config.isLoginNotification()) {
|
||||
if (Orebfuscator.config.playerBypassOp(player)) {
|
||||
Orebfuscator.message(player, "Orebfuscator bypassed because you are OP.");
|
||||
} else if (OrebfuscatorConfig.playerBypassPerms(player)) {
|
||||
} else if (Orebfuscator.config.playerBypassPerms(player)) {
|
||||
Orebfuscator.message(player, "Orebfuscator bypassed because you have permission.");
|
||||
}
|
||||
}
|
||||
|
||||
if (OrebfuscatorConfig.UseProximityHider) {
|
||||
if (Orebfuscator.config.isProximityHiderEnabled()) {
|
||||
ProximityHider.addPlayerToCheck(event.getPlayer(), null);
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +57,7 @@ public class OrebfuscatorPlayerListener implements Listener {
|
|||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
BlockHitManager.clearHistory(event.getPlayer());
|
||||
if (OrebfuscatorConfig.UseProximityHider) {
|
||||
if (Orebfuscator.config.isProximityHiderEnabled()) {
|
||||
ProximityHider.clearPlayer(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +84,7 @@ public class OrebfuscatorPlayerListener implements Listener {
|
|||
public void onPlayerChangeWorld(PlayerChangedWorldEvent event) {
|
||||
BlockHitManager.clearHistory(event.getPlayer());
|
||||
|
||||
if (OrebfuscatorConfig.UseProximityHider) {
|
||||
if (Orebfuscator.config.isProximityHiderEnabled()) {
|
||||
ProximityHider.clearBlocksForOldWorld(event.getPlayer());
|
||||
ProximityHider.addPlayerToCheck(event.getPlayer(), null);
|
||||
}
|
||||
|
@ -93,7 +92,7 @@ public class OrebfuscatorPlayerListener implements Listener {
|
|||
|
||||
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
if (OrebfuscatorConfig.UseProximityHider) {
|
||||
if (Orebfuscator.config.isProximityHiderEnabled()) {
|
||||
if(event.getCause() != TeleportCause.END_PORTAL
|
||||
&& event.getCause() != TeleportCause.NETHER_PORTAL
|
||||
)
|
||||
|
@ -105,7 +104,7 @@ public class OrebfuscatorPlayerListener implements Listener {
|
|||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
if (OrebfuscatorConfig.UseProximityHider) {
|
||||
if (Orebfuscator.config.isProximityHiderEnabled()) {
|
||||
ProximityHider.addPlayerToCheck(event.getPlayer(), event.getFrom());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,14 +28,15 @@ import org.bukkit.block.Block;
|
|||
|
||||
import com.lishid.orebfuscator.DeprecatedMethods;
|
||||
import com.lishid.orebfuscator.Orebfuscator;
|
||||
import com.lishid.orebfuscator.OrebfuscatorConfig;
|
||||
import com.lishid.orebfuscator.cache.ObfuscatedCachedChunk;
|
||||
import com.lishid.orebfuscator.cache.ObfuscatedDataCache;
|
||||
import com.lishid.orebfuscator.config.WorldConfig;
|
||||
import com.lishid.orebfuscator.nms.IBlockInfo;
|
||||
import com.lishid.orebfuscator.types.ChunkCoord;
|
||||
|
||||
public class BlockUpdate {
|
||||
public static boolean needsUpdate(Block block) {
|
||||
return !OrebfuscatorConfig.isBlockTransparent(DeprecatedMethods.getTypeId(block));
|
||||
return !Orebfuscator.config.isBlockTransparent(DeprecatedMethods.getTypeId(block));
|
||||
}
|
||||
|
||||
public static void update(Block block) {
|
||||
|
@ -52,15 +53,16 @@ public class BlockUpdate {
|
|||
}
|
||||
|
||||
World world = blocks.get(0).getWorld();
|
||||
WorldConfig worldConfig = Orebfuscator.configManager.getWorld(world);
|
||||
HashSet<IBlockInfo> updateBlocks = new HashSet<IBlockInfo>();
|
||||
HashSet<ChunkCoord> invalidChunks = new HashSet<ChunkCoord>();
|
||||
int updateRadius = OrebfuscatorConfig.UpdateRadius;
|
||||
int updateRadius = Orebfuscator.config.getUpdateRadius();
|
||||
|
||||
for (Block block : blocks) {
|
||||
if (needsUpdate(block)) {
|
||||
IBlockInfo blockInfo = Orebfuscator.nms.getBlockInfo(world, block.getX(), block.getY(), block.getZ());
|
||||
|
||||
getAjacentBlocks(updateBlocks, world, blockInfo, updateRadius);
|
||||
getAjacentBlocks(updateBlocks, world, worldConfig, blockInfo, updateRadius);
|
||||
|
||||
if((blockInfo.getX() & 0xf) == 0) {
|
||||
invalidChunks.add(new ChunkCoord((blockInfo.getX() >> 4) - 1, blockInfo.getZ() >> 4));
|
||||
|
@ -86,13 +88,14 @@ public class BlockUpdate {
|
|||
}
|
||||
|
||||
World world = locations.get(0).getWorld();
|
||||
WorldConfig worldConfig = Orebfuscator.configManager.getWorld(world);
|
||||
HashSet<IBlockInfo> updateBlocks = new HashSet<IBlockInfo>();
|
||||
HashSet<ChunkCoord> invalidChunks = new HashSet<ChunkCoord>();
|
||||
|
||||
for (Location location : locations) {
|
||||
IBlockInfo blockInfo = Orebfuscator.nms.getBlockInfo(world, location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
|
||||
getAjacentBlocks(updateBlocks, world, blockInfo, updateRadius);
|
||||
getAjacentBlocks(updateBlocks, world, worldConfig, blockInfo, updateRadius);
|
||||
|
||||
if((blockInfo.getX() & 0xf) == 0) {
|
||||
invalidChunks.add(new ChunkCoord((blockInfo.getX() >> 4) - 1, blockInfo.getZ() >> 4));
|
||||
|
@ -119,9 +122,9 @@ public class BlockUpdate {
|
|||
}
|
||||
|
||||
private static void invalidateCachedChunks(World world, Set<ChunkCoord> invalidChunks) {
|
||||
if(invalidChunks.isEmpty() || !OrebfuscatorConfig.UseCache) return;
|
||||
if(invalidChunks.isEmpty() || !Orebfuscator.config.isUseCache()) return;
|
||||
|
||||
File cacheFolder = new File(OrebfuscatorConfig.getCacheFolder(), world.getName());
|
||||
File cacheFolder = new File(ObfuscatedDataCache.getCacheFolder(), world.getName());
|
||||
|
||||
for(ChunkCoord chunk : invalidChunks) {
|
||||
ObfuscatedCachedChunk cache = new ObfuscatedCachedChunk(cacheFolder, chunk.x, chunk.z);
|
||||
|
@ -131,25 +134,30 @@ public class BlockUpdate {
|
|||
}
|
||||
}
|
||||
|
||||
private static void getAjacentBlocks(HashSet<IBlockInfo> allBlocks, World world, IBlockInfo blockInfo, int countdown) {
|
||||
private static void getAjacentBlocks(
|
||||
HashSet<IBlockInfo> allBlocks,
|
||||
World world,
|
||||
WorldConfig worldConfig,
|
||||
IBlockInfo blockInfo,
|
||||
int countdown
|
||||
)
|
||||
{
|
||||
if (blockInfo == null) return;
|
||||
|
||||
int blockId = blockInfo.getTypeId();
|
||||
|
||||
if ((OrebfuscatorConfig.isObfuscated(blockId, world.getEnvironment())
|
||||
|| OrebfuscatorConfig.isDarknessObfuscated(blockId)))
|
||||
{
|
||||
if ((worldConfig.isObfuscated(blockId) || worldConfig.isDarknessObfuscated(blockId))) {
|
||||
allBlocks.add(blockInfo);
|
||||
}
|
||||
|
||||
if (countdown > 0) {
|
||||
countdown--;
|
||||
getAjacentBlocks(allBlocks, world, Orebfuscator.nms.getBlockInfo(world, blockInfo.getX() + 1, blockInfo.getY(), blockInfo.getZ()), countdown);
|
||||
getAjacentBlocks(allBlocks, world, Orebfuscator.nms.getBlockInfo(world, blockInfo.getX() - 1, blockInfo.getY(), blockInfo.getZ()), countdown);
|
||||
getAjacentBlocks(allBlocks, world, Orebfuscator.nms.getBlockInfo(world, blockInfo.getX(), blockInfo.getY() + 1, blockInfo.getZ()), countdown);
|
||||
getAjacentBlocks(allBlocks, world, Orebfuscator.nms.getBlockInfo(world, blockInfo.getX(), blockInfo.getY() - 1, blockInfo.getZ()), countdown);
|
||||
getAjacentBlocks(allBlocks, world, Orebfuscator.nms.getBlockInfo(world, blockInfo.getX(), blockInfo.getY(), blockInfo.getZ() + 1), countdown);
|
||||
getAjacentBlocks(allBlocks, world, Orebfuscator.nms.getBlockInfo(world, blockInfo.getX(), blockInfo.getY(), blockInfo.getZ() - 1), countdown);
|
||||
getAjacentBlocks(allBlocks, world, worldConfig, Orebfuscator.nms.getBlockInfo(world, blockInfo.getX() + 1, blockInfo.getY(), blockInfo.getZ()), countdown);
|
||||
getAjacentBlocks(allBlocks, world, worldConfig, Orebfuscator.nms.getBlockInfo(world, blockInfo.getX() - 1, blockInfo.getY(), blockInfo.getZ()), countdown);
|
||||
getAjacentBlocks(allBlocks, world, worldConfig, Orebfuscator.nms.getBlockInfo(world, blockInfo.getX(), blockInfo.getY() + 1, blockInfo.getZ()), countdown);
|
||||
getAjacentBlocks(allBlocks, world, worldConfig, Orebfuscator.nms.getBlockInfo(world, blockInfo.getX(), blockInfo.getY() - 1, blockInfo.getZ()), countdown);
|
||||
getAjacentBlocks(allBlocks, world, worldConfig, Orebfuscator.nms.getBlockInfo(world, blockInfo.getX(), blockInfo.getY(), blockInfo.getZ() + 1), countdown);
|
||||
getAjacentBlocks(allBlocks, world, worldConfig, Orebfuscator.nms.getBlockInfo(world, blockInfo.getX(), blockInfo.getY(), blockInfo.getZ() - 1), countdown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,31 +19,37 @@ package com.lishid.orebfuscator.obfuscation;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.lishid.orebfuscator.Orebfuscator;
|
||||
import com.lishid.orebfuscator.OrebfuscatorConfig;
|
||||
import com.lishid.orebfuscator.cache.ObfuscatedCachedChunk;
|
||||
import com.lishid.orebfuscator.cache.ObfuscatedDataCache;
|
||||
import com.lishid.orebfuscator.chunkmap.ChunkData;
|
||||
import com.lishid.orebfuscator.chunkmap.ChunkMapManager;
|
||||
import com.lishid.orebfuscator.config.ProximityHiderConfig;
|
||||
import com.lishid.orebfuscator.config.WorldConfig;
|
||||
import com.lishid.orebfuscator.types.BlockCoord;
|
||||
import com.lishid.orebfuscator.types.BlockState;
|
||||
|
||||
public class Calculations {
|
||||
private static Random random = new Random();
|
||||
|
||||
public static byte[] obfuscateOrUseCache(ChunkData chunkData, Player player) throws IOException {
|
||||
if(chunkData.primaryBitMask == 0) return null;
|
||||
|
||||
if (!OrebfuscatorConfig.Enabled // Plugin enabled
|
||||
|| OrebfuscatorConfig.isWorldDisabled(player.getWorld().getName()) // World not enabled
|
||||
|| !OrebfuscatorConfig.obfuscateForPlayer(player)) // Should the player have obfuscation?
|
||||
{
|
||||
if (!Orebfuscator.config.isEnabled() || !Orebfuscator.config.obfuscateForPlayer(player)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
WorldConfig worldConfig = Orebfuscator.configManager.getWorld(player.getWorld());
|
||||
|
||||
if(!worldConfig.isEnabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] output;
|
||||
|
||||
ObfuscatedCachedChunk cache = tryUseCache(chunkData, player);
|
||||
|
@ -88,22 +94,20 @@ public class Calculations {
|
|||
}
|
||||
|
||||
private static byte[] obfuscate(ChunkData chunkData, Player player, ArrayList<BlockCoord> proximityBlocks) throws IOException {
|
||||
Environment environment = player.getWorld().getEnvironment();
|
||||
int initialRadius = OrebfuscatorConfig.InitialRadius;
|
||||
WorldConfig worldConfig = Orebfuscator.configManager.getWorld(player.getWorld());
|
||||
ProximityHiderConfig proximityHider = worldConfig.getProximityHiderConfig();
|
||||
int initialRadius = Orebfuscator.config.getInitialRadius();
|
||||
|
||||
// Track of pseudo-randomly assigned randomBlock
|
||||
int randomIncrement = 0;
|
||||
int randomIncrement2 = 0;
|
||||
int randomCave = 0;
|
||||
// Track of whether a block should be obfuscated or not
|
||||
boolean obfuscate = false;
|
||||
boolean specialObfuscate = false;
|
||||
|
||||
int engineMode = OrebfuscatorConfig.EngineMode;
|
||||
int maxChance = OrebfuscatorConfig.AirGeneratorMaxChance;
|
||||
int engineMode = Orebfuscator.config.getEngineMode();
|
||||
int maxChance = worldConfig.getAirGeneratorMaxChance();
|
||||
int incrementMax = maxChance;
|
||||
|
||||
int randomBlocksLength = OrebfuscatorConfig.getRandomBlocks(false, environment).length;
|
||||
int randomBlocksLength = worldConfig.getRandomBlocks().length;
|
||||
boolean randomAlternate = false;
|
||||
|
||||
int startX = chunkData.chunkX << 4;
|
||||
|
@ -115,11 +119,11 @@ public class Calculations {
|
|||
manager.init();
|
||||
|
||||
for(int i = 0; i < manager.getSectionCount(); i++) {
|
||||
OrebfuscatorConfig.shuffleRandomBlocks();
|
||||
worldConfig.shuffleRandomBlocks();
|
||||
|
||||
for(int offsetY = 0; offsetY < 16; offsetY++) {
|
||||
for(int offsetZ = 0; offsetZ < 16; offsetZ++) {
|
||||
incrementMax = (maxChance + OrebfuscatorConfig.random(maxChance)) / 2;
|
||||
incrementMax = (maxChance + random(maxChance)) / 2;
|
||||
|
||||
for(int offsetX = 0; offsetX < 16; offsetX++) {
|
||||
int blockData = manager.readNextBlock();
|
||||
|
@ -132,14 +136,14 @@ public class Calculations {
|
|||
int z = startZ | offsetZ;
|
||||
|
||||
// Initialize data
|
||||
obfuscate = false;
|
||||
specialObfuscate = false;
|
||||
boolean obfuscate = false;
|
||||
boolean specialObfuscate = false;
|
||||
|
||||
// Check if the block should be obfuscated for the default engine modes
|
||||
if (OrebfuscatorConfig.isObfuscated(blockState.id, environment)) {
|
||||
if (worldConfig.isObfuscated(blockState.id)) {
|
||||
if (initialRadius == 0) {
|
||||
// Do not interfere with PH
|
||||
if (OrebfuscatorConfig.UseProximityHider && OrebfuscatorConfig.isProximityObfuscated(y, blockState.id)) {
|
||||
if (proximityHider.isEnabled() && proximityHider.isProximityObfuscated(y, blockState.id)) {
|
||||
if (!areAjacentBlocksTransparent(manager, player.getWorld(), false, x, y, z, 1)) {
|
||||
obfuscate = true;
|
||||
}
|
||||
|
@ -156,45 +160,43 @@ public class Calculations {
|
|||
}
|
||||
|
||||
// Check if the block should be obfuscated because of proximity check
|
||||
if (!obfuscate && OrebfuscatorConfig.UseProximityHider && OrebfuscatorConfig.isProximityObfuscated(y, blockState.id)) {
|
||||
if (OrebfuscatorConfig.isProximityHiderOn(y, blockState.id)) {
|
||||
BlockCoord block = new BlockCoord(x, y, z);
|
||||
if (block != null) {
|
||||
proximityBlocks.add(block);
|
||||
}
|
||||
|
||||
obfuscate = true;
|
||||
if (OrebfuscatorConfig.UseSpecialBlockForProximityHider) {
|
||||
specialObfuscate = true;
|
||||
}
|
||||
}
|
||||
if (!obfuscate && proximityHider.isEnabled() && proximityHider.isProximityObfuscated(y, blockState.id)) {
|
||||
BlockCoord block = new BlockCoord(x, y, z);
|
||||
if (block != null) {
|
||||
proximityBlocks.add(block);
|
||||
}
|
||||
|
||||
obfuscate = true;
|
||||
if (proximityHider.isUseSpecialBlock()) {
|
||||
specialObfuscate = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the block is obfuscated
|
||||
if (obfuscate) {
|
||||
if (specialObfuscate) {
|
||||
// Proximity hider
|
||||
blockState.id = OrebfuscatorConfig.ProximityHiderID;
|
||||
blockState.id = proximityHider.getSpecialBlockID();
|
||||
} else {
|
||||
randomIncrement2 = OrebfuscatorConfig.random(incrementMax);
|
||||
|
||||
if (engineMode == 1) {
|
||||
// Engine mode 1, replace with stone
|
||||
blockState.id = (environment == Environment.NETHER ? 87 : 1);
|
||||
blockState.id = worldConfig.getMode1BlockId();
|
||||
} else if (engineMode == 2) {
|
||||
// Ending mode 2, replace with random block
|
||||
if (randomBlocksLength > 1) {
|
||||
randomIncrement = CalculationsUtil.increment(randomIncrement, randomBlocksLength);
|
||||
}
|
||||
|
||||
blockState.id = OrebfuscatorConfig.getRandomBlock(randomIncrement, randomAlternate, environment);
|
||||
blockState.id = worldConfig.getRandomBlock(randomIncrement, randomAlternate);
|
||||
randomAlternate = !randomAlternate;
|
||||
}
|
||||
// Anti texturepack and freecam
|
||||
if (OrebfuscatorConfig.AntiTexturePackAndFreecam) {
|
||||
// Add random air blocks
|
||||
if (randomIncrement2 == 0) {
|
||||
randomCave = 1 + OrebfuscatorConfig.random(3);
|
||||
if (worldConfig.isAntiTexturePackAndFreecam()) {
|
||||
// Add random air blocks
|
||||
randomIncrement2 = random(incrementMax);
|
||||
|
||||
if (randomIncrement2 == 0) {
|
||||
randomCave = 1 + random(3);
|
||||
}
|
||||
|
||||
if (randomCave > 0) {
|
||||
|
@ -208,7 +210,7 @@ public class Calculations {
|
|||
}
|
||||
|
||||
// Check if the block should be obfuscated because of the darkness
|
||||
if (!obfuscate && OrebfuscatorConfig.DarknessHideBlocks && OrebfuscatorConfig.isDarknessObfuscated(blockState.id)) {
|
||||
if (!obfuscate && worldConfig.isDarknessHideBlocks() && worldConfig.isDarknessObfuscated(blockState.id)) {
|
||||
if (!areAjacentBlocksBright(player.getWorld(), x, y, z, 1)) {
|
||||
// Hide block, setting it to air
|
||||
blockState.id = 0;
|
||||
|
@ -224,7 +226,7 @@ public class Calculations {
|
|||
if(offsetY == 0 && offsetZ == 0 && offsetX == 0) {
|
||||
manager.finalizeOutput();
|
||||
manager.initOutputPalette();
|
||||
addBlocksToPalette(manager, environment);
|
||||
addBlocksToPalette(manager, worldConfig);
|
||||
manager.initOutputSection();
|
||||
}
|
||||
|
||||
|
@ -245,30 +247,26 @@ public class Calculations {
|
|||
return output;
|
||||
}
|
||||
|
||||
private static void addBlocksToPalette(ChunkMapManager manager, Environment environment) {
|
||||
private static void addBlocksToPalette(ChunkMapManager manager, WorldConfig worldConfig) {
|
||||
if(!manager.inputHasNonAirBlock()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int[] list = environment == Environment.NETHER
|
||||
? OrebfuscatorConfig.NetherPaletteBlocks
|
||||
: OrebfuscatorConfig.NormalPaletteBlocks;
|
||||
|
||||
for(int id : list) {
|
||||
for(int id : worldConfig.getPaletteBlocks()) {
|
||||
int blockData = ChunkMapManager.getBlockDataFromId(id);
|
||||
manager.addToOutputPalette(blockData);
|
||||
}
|
||||
}
|
||||
|
||||
private static ObfuscatedCachedChunk tryUseCache(ChunkData chunkData, Player player) {
|
||||
if (!OrebfuscatorConfig.UseCache) return null;
|
||||
if (!Orebfuscator.config.isUseCache()) return null;
|
||||
|
||||
chunkData.useCache = true;
|
||||
|
||||
// Hash the chunk
|
||||
long hash = CalculationsUtil.Hash(chunkData.data, chunkData.data.length);
|
||||
// Get cache folder
|
||||
File cacheFolder = new File(OrebfuscatorConfig.getCacheFolder(), player.getWorld().getName());
|
||||
File cacheFolder = new File(ObfuscatedDataCache.getCacheFolder(), player.getWorld().getName());
|
||||
// Create cache objects
|
||||
ObfuscatedCachedChunk cache = new ObfuscatedCachedChunk(cacheFolder, chunkData.chunkX, chunkData.chunkZ);
|
||||
|
||||
|
@ -339,7 +337,7 @@ public class Calculations {
|
|||
id = ChunkMapManager.getBlockIdFromData(blockData);
|
||||
}
|
||||
|
||||
if (OrebfuscatorConfig.isBlockTransparent(id)) {
|
||||
if (Orebfuscator.config.isBlockTransparent(id)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -386,61 +384,8 @@ public class Calculations {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
//16 bit char for block data, including 12 bits for block id
|
||||
/*
|
||||
private static final int BLOCKID_MAX = 4096;
|
||||
private static char[] cacheMap = new char[BLOCKID_MAX];
|
||||
|
||||
static {
|
||||
buildCacheMap();
|
||||
|
||||
private static int random(int max) {
|
||||
return random.nextInt(max);
|
||||
}
|
||||
|
||||
public static void buildCacheMap() {
|
||||
for (int i = 0; i < 4096; i++) {
|
||||
cacheMap[i] = (char) i;
|
||||
if (OrebfuscatorConfig.isBlockTransparent((short) i) && !isBlockSpecialObfuscated(64, (char) i)) {
|
||||
cacheMap[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void PrepareBufferForCaching(byte[] data, int bytes) {
|
||||
for (int i = 0; i < bytes / 2; i++) {
|
||||
int blockId = chunkGetBlockId(data, i);
|
||||
|
||||
blockId = cacheMap[blockId % BLOCKID_MAX];
|
||||
|
||||
chunkSetBlockId(data, i, blockId);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isBlockSpecialObfuscated(int y, char id) {
|
||||
if (OrebfuscatorConfig.DarknessHideBlocks && OrebfuscatorConfig.isDarknessObfuscated(id)) {
|
||||
return true;
|
||||
}
|
||||
if (OrebfuscatorConfig.UseProximityHider && OrebfuscatorConfig.isProximityObfuscated(y, id)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void RepaintChunkToBuffer(byte[] data, ChunkInfo info) {
|
||||
byte[] original = info.original;
|
||||
int bytes = info.bytes;
|
||||
|
||||
for (int i = 0; i < bytes / 2; i++) {
|
||||
int newId = chunkGetBlockId(data, i);
|
||||
int originalId = chunkGetBlockId(original, i);
|
||||
|
||||
if (newId == 0 && originalId != 0) {
|
||||
if (OrebfuscatorConfig.isBlockTransparent((short) originalId)) {
|
||||
if (!isBlockSpecialObfuscated(0, (char) originalId)) {
|
||||
chunkSetBlockId(data, i, originalId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -16,8 +16,9 @@ import org.bukkit.World;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.lishid.orebfuscator.Orebfuscator;
|
||||
import com.lishid.orebfuscator.OrebfuscatorConfig;
|
||||
import com.lishid.orebfuscator.cache.ObfuscatedCachedChunk;
|
||||
import com.lishid.orebfuscator.cache.ObfuscatedDataCache;
|
||||
import com.lishid.orebfuscator.config.ProximityHiderConfig;
|
||||
import com.lishid.orebfuscator.nms.IChunkManager;
|
||||
import com.lishid.orebfuscator.types.ChunkCoord;
|
||||
|
||||
|
@ -55,13 +56,13 @@ public class ChunkReloader extends Thread implements Runnable {
|
|||
while (!this.isInterrupted() && !kill.get()) {
|
||||
try {
|
||||
// Wait until necessary
|
||||
long timeWait = lastExecute + OrebfuscatorConfig.ChunkReloaderRate - System.currentTimeMillis();
|
||||
long timeWait = lastExecute + Orebfuscator.config.getChunkReloaderRate() - System.currentTimeMillis();
|
||||
lastExecute = System.currentTimeMillis();
|
||||
if (timeWait > 0) {
|
||||
Thread.sleep(timeWait);
|
||||
}
|
||||
|
||||
if (!OrebfuscatorConfig.UseChunkReloader) {
|
||||
if (!Orebfuscator.config.isUseChunkReloader()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -137,11 +138,11 @@ public class ChunkReloader extends Thread implements Runnable {
|
|||
}
|
||||
|
||||
private static void scheduleReloadChunks(final World world, HashSet<ChunkCoord> chunksForReloadForWorld) {
|
||||
File cacheFolder = new File(OrebfuscatorConfig.getCacheFolder(), world.getName());
|
||||
File cacheFolder = new File(ObfuscatedDataCache.getCacheFolder(), world.getName());
|
||||
final IChunkManager chunkManager = Orebfuscator.nms.getChunkManager(world);
|
||||
|
||||
for(final ChunkCoord chunk : chunksForReloadForWorld) {
|
||||
if(OrebfuscatorConfig.UseCache) {
|
||||
if(Orebfuscator.config.isUseCache()) {
|
||||
ObfuscatedCachedChunk cache = new ObfuscatedCachedChunk(cacheFolder, chunk.x, chunk.z);
|
||||
if(cache.getHash() != 0) continue;
|
||||
}
|
||||
|
@ -179,7 +180,11 @@ public class ChunkReloader extends Thread implements Runnable {
|
|||
}
|
||||
|
||||
if(affectedPlayers.size() > 0) {
|
||||
ProximityHider.addPlayersToReload(affectedPlayers);
|
||||
ProximityHiderConfig proximityHider = Orebfuscator.configManager.getWorld(world).getProximityHiderConfig();
|
||||
|
||||
if(proximityHider.isEnabled()) {
|
||||
ProximityHider.addPlayersToReload(affectedPlayers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,9 +197,10 @@ public class ChunkReloader extends Thread implements Runnable {
|
|||
}
|
||||
|
||||
public static void addLoadedChunk(World world, int chunkX, int chunkZ) {
|
||||
if (!OrebfuscatorConfig.Enabled // Plugin enabled
|
||||
|| OrebfuscatorConfig.isWorldDisabled(world.getName()) // World not enabled
|
||||
|| !OrebfuscatorConfig.UseChunkReloader)
|
||||
if (!Orebfuscator.config.isEnabled() // Plugin enabled
|
||||
|| !Orebfuscator.config.isUseChunkReloader()
|
||||
|| !Orebfuscator.configManager.getWorld(world).isEnabled() // World not enabled
|
||||
)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -213,9 +219,10 @@ public class ChunkReloader extends Thread implements Runnable {
|
|||
}
|
||||
|
||||
public static void addUnloadedChunk(World world, int chunkX, int chunkZ) {
|
||||
if (!OrebfuscatorConfig.Enabled // Plugin enabled
|
||||
|| OrebfuscatorConfig.isWorldDisabled(world.getName()) // World not enabled
|
||||
|| !OrebfuscatorConfig.UseChunkReloader)
|
||||
if (!Orebfuscator.config.isEnabled() // Plugin enabled
|
||||
|| !Orebfuscator.config.isUseChunkReloader()
|
||||
|| !Orebfuscator.configManager.getWorld(world).isEnabled() // World not enabled
|
||||
)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ import org.bukkit.entity.Player;
|
|||
|
||||
import com.lishid.orebfuscator.DeprecatedMethods;
|
||||
import com.lishid.orebfuscator.Orebfuscator;
|
||||
import com.lishid.orebfuscator.OrebfuscatorConfig;
|
||||
import com.lishid.orebfuscator.config.ProximityHiderConfig;
|
||||
import com.lishid.orebfuscator.config.WorldConfig;
|
||||
import com.lishid.orebfuscator.types.BlockCoord;
|
||||
import com.lishid.orebfuscator.types.BlockState;
|
||||
|
||||
|
@ -65,22 +66,16 @@ public class ProximityHider extends Thread implements Runnable {
|
|||
while (!this.isInterrupted() && !kill.get()) {
|
||||
try {
|
||||
// Wait until necessary
|
||||
long timeWait = lastExecute + OrebfuscatorConfig.ProximityHiderRate - System.currentTimeMillis();
|
||||
long timeWait = lastExecute + Orebfuscator.config.getProximityHiderRate() - System.currentTimeMillis();
|
||||
lastExecute = System.currentTimeMillis();
|
||||
if (timeWait > 0) {
|
||||
Thread.sleep(timeWait);
|
||||
}
|
||||
|
||||
if (!OrebfuscatorConfig.UseProximityHider) {
|
||||
if (!Orebfuscator.config.isProximityHiderEnabled()) {
|
||||
running = false;
|
||||
return;
|
||||
}
|
||||
|
||||
int checkRadius = OrebfuscatorConfig.ProximityHiderDistance >> 4;
|
||||
|
||||
if((OrebfuscatorConfig.ProximityHiderDistance & 0xf) != 0) {
|
||||
checkRadius++;
|
||||
}
|
||||
|
||||
HashMap<Player, Location> checkPlayers = new HashMap<Player, Location>();
|
||||
|
||||
|
@ -89,9 +84,6 @@ public class ProximityHider extends Thread implements Runnable {
|
|||
playersToCheck.clear();
|
||||
}
|
||||
|
||||
int distance = OrebfuscatorConfig.ProximityHiderDistance;
|
||||
int distanceSquared = distance * distance;
|
||||
|
||||
for (Player p : checkPlayers.keySet()) {
|
||||
|
||||
if (p == null) {
|
||||
|
@ -121,8 +113,6 @@ public class ProximityHider extends Thread implements Runnable {
|
|||
proximityHiderTrackerLocal.put(p, localPlayerInfo = new ProximityHiderPlayer(p.getWorld()));
|
||||
}
|
||||
|
||||
int y = (int) Math.floor(p.getLocation().getY());
|
||||
|
||||
synchronized (proximityHiderTracker) {
|
||||
ProximityHiderPlayer playerInfo = proximityHiderTracker.get(p);
|
||||
|
||||
|
@ -137,13 +127,22 @@ public class ProximityHider extends Thread implements Runnable {
|
|||
}
|
||||
}
|
||||
|
||||
if (OrebfuscatorConfig.skipProximityHiderCheck(y)) continue;
|
||||
|
||||
if(localPlayerInfo.getWorld() == null || p.getWorld() == null || !p.getWorld().equals(localPlayerInfo.getWorld())) {
|
||||
localPlayerInfo.clearChunks();
|
||||
continue;
|
||||
}
|
||||
|
||||
WorldConfig worldConfig = Orebfuscator.configManager.getWorld(p.getWorld());
|
||||
ProximityHiderConfig proximityHider = worldConfig.getProximityHiderConfig();
|
||||
|
||||
int checkRadius = proximityHider.getDistance() >> 4;
|
||||
|
||||
if((proximityHider.getDistance() & 0xf) != 0) {
|
||||
checkRadius++;
|
||||
}
|
||||
|
||||
int distanceSquared = proximityHider.getDistanceSquared();
|
||||
|
||||
ArrayList<BlockCoord> removedBlocks = new ArrayList<BlockCoord>();
|
||||
Location playerLocation = p.getLocation();
|
||||
int minChunkX = (playerLocation.getBlockX() >> 4) - checkRadius;
|
||||
|
@ -167,7 +166,7 @@ public class ProximityHider extends Thread implements Runnable {
|
|||
|
||||
Location blockLocation = new Location(localPlayerInfo.getWorld(), b.x, b.y, b.z);
|
||||
|
||||
if (OrebfuscatorConfig.proximityHiderDeobfuscate() || playerLocation.distanceSquared(blockLocation) < distanceSquared) {
|
||||
if (proximityHider.isObfuscateAboveY() || playerLocation.distanceSquared(blockLocation) < distanceSquared) {
|
||||
removedBlocks.add(b);
|
||||
|
||||
BlockState blockState = Orebfuscator.nms.getBlockState(localPlayerInfo.getWorld(), b.x, b.y, b.z);
|
||||
|
@ -206,7 +205,7 @@ public class ProximityHider extends Thread implements Runnable {
|
|||
if (thread.isInterrupted() || !thread.isAlive())
|
||||
running = false;
|
||||
|
||||
if (!running && OrebfuscatorConfig.UseProximityHider) {
|
||||
if (!running && Orebfuscator.config.isProximityHiderEnabled()) {
|
||||
// Load ProximityHider
|
||||
ProximityHider.Load();
|
||||
}
|
||||
|
@ -214,7 +213,9 @@ public class ProximityHider extends Thread implements Runnable {
|
|||
}
|
||||
|
||||
public static void addProximityBlocks(Player player, int chunkX, int chunkZ, ArrayList<BlockCoord> blocks) {
|
||||
if (!OrebfuscatorConfig.UseProximityHider) return;
|
||||
ProximityHiderConfig proximityHider = Orebfuscator.configManager.getWorld(player.getWorld()).getProximityHiderConfig();
|
||||
|
||||
if (!proximityHider.isEnabled()) return;
|
||||
|
||||
restart();
|
||||
|
||||
|
@ -277,7 +278,7 @@ public class ProximityHider extends Thread implements Runnable {
|
|||
}
|
||||
|
||||
public static void addPlayersToReload(HashSet<Player> players) {
|
||||
if (!OrebfuscatorConfig.UseProximityHider) return;
|
||||
if (!Orebfuscator.config.isProximityHiderEnabled()) return;
|
||||
|
||||
synchronized (playersToReload) {
|
||||
playersToReload.addAll(players);
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package com.lishid.orebfuscator.utils;
|
||||
|
||||
public class Globals {
|
||||
public static final String LogPrefix = "[OFC] ";
|
||||
}
|
Loading…
Reference in New Issue