mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-04-12 22:35:43 +02:00
[SAFETY COMMIT, REFACTOR, BREAKING]
Moving big parts of code between sub-projects. Some refactoring was needed to unlink some classes. Deprecated methods removed. Some utility methods were moved to differently named utilities. Few signatures changed (e.g. BlockProperties.init). Most changes should only concern bugs or developers who dug into some NCP deeply (not sure those exist). It should still all be there.
This commit is contained in:
parent
8e313f4a47
commit
ee1f410dae
7
.pydevproject
Normal file
7
.pydevproject
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?eclipse-pydev version="1.0"?>
|
||||
|
||||
<pydev_project>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
|
||||
</pydev_project>
|
@ -5,12 +5,12 @@
|
||||
<artifactId>ncpcommons</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>NCPCommons</name>
|
||||
<version>1.0.0</version>
|
||||
<version>static</version>
|
||||
|
||||
<parent>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>nocheatplus-parent</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>static</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@ -0,0 +1,54 @@
|
||||
package fr.neatmonster.nocheatplus.utilities;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
/**
|
||||
* String utility methods (working with or returning strings).
|
||||
* @author mc_dev
|
||||
*
|
||||
*/
|
||||
public class StringUtil {
|
||||
|
||||
/** Decimal format for "#.###" */
|
||||
public static final DecimalFormat fdec3 = new DecimalFormat();
|
||||
/** Decimal format for "#.#" */
|
||||
public static final DecimalFormat fdec1 = new DecimalFormat();
|
||||
|
||||
static {
|
||||
// 3 digits.
|
||||
DecimalFormatSymbols sym = fdec3.getDecimalFormatSymbols();
|
||||
sym.setDecimalSeparator('.');
|
||||
fdec3.setDecimalFormatSymbols(sym);
|
||||
fdec3.setMaximumFractionDigits(3);
|
||||
fdec3.setMinimumIntegerDigits(1);
|
||||
// 1 digit.
|
||||
sym = fdec1.getDecimalFormatSymbols();
|
||||
sym.setDecimalSeparator('.');
|
||||
fdec1.setDecimalFormatSymbols(sym);
|
||||
fdec1.setMaximumFractionDigits(1);
|
||||
fdec1.setMinimumIntegerDigits(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Join parts with link.
|
||||
*
|
||||
* @param input
|
||||
* @param link
|
||||
* @return
|
||||
*/
|
||||
public static <O extends Object> String join(final Collection<O> input, final String link)
|
||||
{
|
||||
final StringBuilder builder = new StringBuilder(Math.max(300, input.size() * 10));
|
||||
boolean first = true;
|
||||
for (final Object obj : input) {
|
||||
if (!first) builder.append(link);
|
||||
builder.append(obj.toString());
|
||||
first = false;
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
@ -262,8 +262,8 @@ public class TestCoordMap {
|
||||
|
||||
final Random random = new Random(System.nanoTime() - (System.currentTimeMillis() % 2 == 1 ? 37 : 137));
|
||||
|
||||
final int n = 20000; // Number of coordinates.
|
||||
final int max = 1000; // Coordinate maximum.
|
||||
final int n = 10000; // Number of coordinates.
|
||||
final int max = 800; // Coordinate maximum.
|
||||
|
||||
int [][] coords = getUniqueRandomCoords(n, max, random);
|
||||
|
||||
|
@ -5,12 +5,12 @@
|
||||
<artifactId>ncpcompat</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>NCPCompat</name>
|
||||
<version>1.0.0</version>
|
||||
<version>static</version>
|
||||
|
||||
<parent>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>nocheatplus-parent</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>static</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
@ -23,12 +23,11 @@
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcommons</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<type>jar</type>
|
||||
<version>static</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<description>API for the compatibility modules. Uses Bukkit.
|
||||
<description>API for the compatibility modules. Uses Bukkit. In fact this is the base of NCP that needs Bukkit but just not much more.
|
||||
|
||||
Version updating is done for NCPPlugin mainly, expect the other poms version to change randomly rather.</description>
|
||||
</project>
|
||||
|
@ -1,6 +1,5 @@
|
||||
package fr.neatmonster.nocheatplus.compat.bukkit;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -12,34 +11,16 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
|
||||
import fr.neatmonster.nocheatplus.utilities.PotionUtil;
|
||||
|
||||
public class MCAccessBukkit implements MCAccess{
|
||||
|
||||
/**
|
||||
* Get amplifier for a potion effect.
|
||||
* @param player
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public static double getPotionEffectAmplifier(final Player player, final PotionEffectType type) {
|
||||
if (!player.hasPotionEffect(type)) return Double.MIN_VALUE;
|
||||
final Collection<PotionEffect> effects = player.getActivePotionEffects();
|
||||
double max = Double.MIN_VALUE;
|
||||
for (final PotionEffect effect : effects){
|
||||
if (effect.getType() == type){
|
||||
max = Math.max(max, effect.getAmplifier());
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor to let it fail.
|
||||
*/
|
||||
@ -122,12 +103,12 @@ public class MCAccessBukkit implements MCAccess{
|
||||
|
||||
@Override
|
||||
public double getJumpAmplifier(final Player player) {
|
||||
return getPotionEffectAmplifier(player, PotionEffectType.JUMP);
|
||||
return PotionUtil.getPotionEffectAmplifier(player, PotionEffectType.JUMP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getFasterMovementAmplifier(final Player player) {
|
||||
return getPotionEffectAmplifier(player, PotionEffectType.SPEED);
|
||||
return PotionUtil.getPotionEffectAmplifier(player, PotionEffectType.SPEED);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,93 @@
|
||||
package fr.neatmonster.nocheatplus.config;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
|
||||
public class RawConfigFile extends YamlConfiguration{
|
||||
|
||||
/**
|
||||
* Return double within given bounds, with preset. Mainly used for hidden settings.
|
||||
*
|
||||
* @param data
|
||||
* @param path
|
||||
* @param min
|
||||
* @param max
|
||||
* @param preset
|
||||
* @return
|
||||
*/
|
||||
public double getDouble(final String path, final double min, final double max, final double preset){
|
||||
final double value = getDouble(path, preset);
|
||||
if (value < min) return min;
|
||||
else if (value > max) return max;
|
||||
else return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to get a type id from the path somehow, return null if nothing found.<br>
|
||||
* Will attempt to interpret strings, will return negative or out of range values.
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
public Integer getTypeId(final String path){
|
||||
return getTypeId(path, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to get a type id from the path somehow, return preset if nothing found.<br>
|
||||
* Will attempt to interpret strings, will return negative or out of range values.
|
||||
* @param path
|
||||
* @param preset
|
||||
* @return
|
||||
*/
|
||||
public Integer getTypeId(final String path, final Integer preset){
|
||||
String content = getString(path, null);
|
||||
if (content != null){
|
||||
Integer id = parseTypeId(content);
|
||||
if (id != null) return id;
|
||||
}
|
||||
int id = getInt(path, Integer.MAX_VALUE);
|
||||
return id == Integer.MAX_VALUE ? preset : id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to get an int id from a string.<br>
|
||||
* Will return out of range numbers, attempts to parse materials.
|
||||
* @param content
|
||||
* @return
|
||||
*/
|
||||
public static Integer parseTypeId(String content) {
|
||||
content = content.trim().toUpperCase();
|
||||
try{
|
||||
return Integer.parseInt(content);
|
||||
}
|
||||
catch(NumberFormatException e){}
|
||||
try{
|
||||
Material mat = Material.matchMaterial(content.replace(' ', '_').replace('-', '_').replace('.', '_'));
|
||||
if (mat != null) return mat.getId();
|
||||
}
|
||||
catch (Exception e) {}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.bukkit.configuration.file.YamlConfiguration#saveToString()
|
||||
*/
|
||||
@Override
|
||||
public String saveToString() {
|
||||
// Some reflection wizardly to avoid having a lot of linebreaks in the yaml file, and get a "footer" into the file.
|
||||
// TODO: Interesting, but review this: still necessary/useful in CB-1.4 ?.
|
||||
try {
|
||||
Field op;
|
||||
op = YamlConfiguration.class.getDeclaredField("yamlOptions");
|
||||
op.setAccessible(true);
|
||||
final DumperOptions options = (DumperOptions) op.get(this);
|
||||
options.setWidth(200);
|
||||
} catch (final Exception e) {}
|
||||
|
||||
return super.saveToString();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package fr.neatmonster.nocheatplus.config;
|
||||
|
||||
/**
|
||||
* Auxiliary for config paths that have to be used in this module. These are likely to be referenced from ConfPaths (plugin module).<br>
|
||||
* Not happy with these, but seem necessary for refactoring.
|
||||
* @author mc_dev
|
||||
*
|
||||
*/
|
||||
public class RootConfPaths {
|
||||
|
||||
// Sub-paths that are used with different path prefixes potentially.
|
||||
public static final String SUB_IGNOREPASSABLE = "ignorepassable";
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package fr.neatmonster.nocheatplus.utilities;
|
||||
package fr.neatmonster.nocheatplus.logging;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
@ -7,6 +7,8 @@ import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
||||
|
||||
/**
|
||||
* Static access methods for logging access (mostly uses the Bukkit logger).
|
||||
* @author mc_dev
|
||||
@ -134,7 +136,7 @@ public class LogUtil {
|
||||
*/
|
||||
public static <O extends Object> boolean scheduleLog(final Level level, final List<O> parts, final String link)
|
||||
{
|
||||
return scheduleLog(level, CheckUtils.join(parts, link));
|
||||
return scheduleLog(level, StringUtil.join(parts, link));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,112 @@
|
||||
package fr.neatmonster.nocheatplus.logging;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.util.logging.Formatter;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Could not think of anything better, likely a refactoring stage.
|
||||
* @author mc_dev
|
||||
*
|
||||
*/
|
||||
public class StaticLogFile {
|
||||
|
||||
/**
|
||||
* The formatter that is used to format the log file.
|
||||
*/
|
||||
protected static class LogFileFormatter extends Formatter {
|
||||
|
||||
/**
|
||||
* Create a new instance of the log file formatter.
|
||||
*
|
||||
* @return the log file formatter
|
||||
*/
|
||||
public static LogFileFormatter newInstance() {
|
||||
return new LogFileFormatter();
|
||||
}
|
||||
|
||||
/** The date formatter. */
|
||||
private final SimpleDateFormat date;
|
||||
|
||||
/**
|
||||
* Instantiates a new log file formatter.
|
||||
*/
|
||||
private LogFileFormatter() {
|
||||
date = new SimpleDateFormat("yy.MM.dd HH:mm:ss");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.logging.Formatter#format(java.util.logging.LogRecord)
|
||||
*/
|
||||
@Override
|
||||
public String format(final LogRecord record) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
final Throwable ex = record.getThrown();
|
||||
|
||||
builder.append(date.format(record.getMillis()));
|
||||
builder.append(" [");
|
||||
builder.append(record.getLevel().getLocalizedName().toUpperCase());
|
||||
builder.append("] ");
|
||||
builder.append(record.getMessage());
|
||||
builder.append('\n');
|
||||
|
||||
if (ex != null) {
|
||||
final StringWriter writer = new StringWriter();
|
||||
ex.printStackTrace(new PrintWriter(writer));
|
||||
builder.append(writer);
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
/** The file logger. */
|
||||
public static Logger fileLogger = null;
|
||||
/** The file handler. */
|
||||
private static FileHandler fileHandler = null;
|
||||
|
||||
/**
|
||||
* Cleanup.
|
||||
*/
|
||||
public static void cleanup() {
|
||||
fileHandler.flush();
|
||||
fileHandler.close();
|
||||
final Logger logger = Logger.getLogger("NoCheatPlus");
|
||||
logger.removeHandler(fileHandler);
|
||||
fileHandler = null;
|
||||
}
|
||||
public static void setupLogger(File logFile){
|
||||
// Setup the file logger.
|
||||
final Logger logger = Logger.getAnonymousLogger();
|
||||
logger.setLevel(Level.INFO);
|
||||
logger.setUseParentHandlers(false);
|
||||
for (final Handler h : logger.getHandlers())
|
||||
logger.removeHandler(h);
|
||||
if (fileHandler != null) {
|
||||
fileHandler.close();
|
||||
logger.removeHandler(fileHandler);
|
||||
fileHandler = null;
|
||||
}
|
||||
try {
|
||||
try {
|
||||
logFile.getParentFile().mkdirs();
|
||||
} catch (final Exception e) {
|
||||
LogUtil.logSevere(e);
|
||||
}
|
||||
fileHandler = new FileHandler(logFile.getCanonicalPath(), true);
|
||||
fileHandler.setLevel(Level.ALL);
|
||||
fileHandler.setFormatter(StaticLogFile.LogFileFormatter.newInstance());
|
||||
logger.addHandler(fileHandler);
|
||||
} catch (final Exception e) {
|
||||
LogUtil.logSevere(e);
|
||||
}
|
||||
fileLogger = logger;
|
||||
}
|
||||
|
||||
}
|
@ -15,11 +15,10 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.config.ConfPaths;
|
||||
import fr.neatmonster.nocheatplus.config.ConfigFile;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import fr.neatmonster.nocheatplus.config.RawConfigFile;
|
||||
import fr.neatmonster.nocheatplus.config.RootConfPaths;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
|
||||
/**
|
||||
* Properties of blocks.
|
||||
@ -244,8 +243,8 @@ public class BlockProperties {
|
||||
Material.POTATO,
|
||||
};
|
||||
|
||||
private static BlockCache blockCache = NoCheatPlus.getMCAccess().getBlockCache(null);
|
||||
private static final PlayerLocation pLoc = new PlayerLocation(NoCheatPlus.getMCAccess(), null);
|
||||
private static BlockCache blockCache = null;
|
||||
private static PlayerLocation pLoc = null;
|
||||
|
||||
protected static final long[] blockFlags = new long[maxBlocks];
|
||||
|
||||
@ -271,22 +270,20 @@ public class BlockProperties {
|
||||
public static final int F_HEIGHT100 = 0x100;
|
||||
/** Climbable like ladder and vine (allow to land on without taking damage). */
|
||||
public static final int F_CLIMBABLE = 0x200;
|
||||
|
||||
static{
|
||||
init();
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
try{
|
||||
initTools();
|
||||
initBlocks();
|
||||
}
|
||||
catch(Throwable t){
|
||||
LogUtil.logSevere(t);
|
||||
}
|
||||
public static void init(final MCAccess mcAccess) {
|
||||
blockCache = mcAccess.getBlockCache(null);
|
||||
pLoc = new PlayerLocation(mcAccess, null);
|
||||
try{
|
||||
initTools(mcAccess);
|
||||
initBlocks(mcAccess);
|
||||
}
|
||||
catch(Throwable t){
|
||||
LogUtil.logSevere(t);
|
||||
}
|
||||
}
|
||||
|
||||
private static void initTools() {
|
||||
private static void initTools(final MCAccess mcAccess) {
|
||||
tools.clear();
|
||||
tools.put(268, new ToolProps(ToolType.SWORD, MaterialBase.WOOD));
|
||||
tools.put(269, new ToolProps(ToolType.SPADE, MaterialBase.WOOD));
|
||||
@ -316,12 +313,11 @@ public class BlockProperties {
|
||||
tools.put(359, new ToolProps(ToolType.SHEARS, MaterialBase.NONE));
|
||||
}
|
||||
|
||||
private static void initBlocks() {
|
||||
private static void initBlocks(final MCAccess mcAccess) {
|
||||
Arrays.fill(blocks, null);
|
||||
///////////////////////////
|
||||
// Initalize block flags
|
||||
///////////////////////////
|
||||
final MCAccess mcAccess = NoCheatPlus.getMCAccess();
|
||||
for (int i = 0; i <maxBlocks; i++){
|
||||
blockFlags[i] = 0;
|
||||
|
||||
@ -636,7 +632,8 @@ public class BlockProperties {
|
||||
final World world = location.getWorld();
|
||||
final boolean onGround = isOnGround(player, location) || world.getBlockTypeIdAt(x, y, z) == Material.WATER_LILY.getId();
|
||||
final boolean inWater = isInWater(world.getBlockTypeIdAt(x, y + 1, z));
|
||||
final int haste = player.hasPotionEffect(PotionEffectType.FAST_DIGGING) ? 1 : 0;
|
||||
final int haste = (int) Math.round(PotionUtil.getPotionEffectAmplifier(player, PotionEffectType.FAST_DIGGING));
|
||||
// TODO: haste: int / double !?
|
||||
return getBreakingDuration(blockId, itemInHand, onGround, inWater, helmet != null && helmet.containsEnchantment(Enchantment.WATER_WORKER), haste);
|
||||
}
|
||||
|
||||
@ -671,6 +668,7 @@ public class BlockProperties {
|
||||
*/
|
||||
public static long getBreakingDuration(final int blockId, final BlockProps blockProps, final ToolProps toolProps, final boolean onGround, final boolean inWater, boolean aquaAffinity, int efficiency, int haste) {
|
||||
final long dur = getBreakingDuration(blockId, blockProps, toolProps, onGround, inWater, aquaAffinity, efficiency);
|
||||
// TODO: haste ...
|
||||
return haste > 0 ? ((long) (dur * 0.66)) : dur;
|
||||
}
|
||||
|
||||
@ -876,12 +874,12 @@ public class BlockProperties {
|
||||
blockCache.setAccess(location.getWorld());
|
||||
pLoc.setBlockCache(blockCache);
|
||||
pLoc.set(location, player, 0.3);
|
||||
if (pLoc.isIllegal()) {
|
||||
blockCache.cleanup();
|
||||
pLoc.cleanup();
|
||||
CheckUtils.onIllegalMove(player);
|
||||
return false;
|
||||
}
|
||||
// if (pLoc.isIllegal()) {
|
||||
// blockCache.cleanup();
|
||||
// pLoc.cleanup();
|
||||
// CheckUtils.onIllegalMove(player);
|
||||
// return false;
|
||||
// }
|
||||
final boolean onGround = pLoc.isOnGround();
|
||||
blockCache.cleanup();
|
||||
pLoc.cleanup();
|
||||
@ -1020,11 +1018,11 @@ public class BlockProperties {
|
||||
* API access to read extra properties from files.
|
||||
* @param config
|
||||
*/
|
||||
public static void applyConfig(final ConfigFile config, final String pathPrefix) {
|
||||
public static void applyConfig(final RawConfigFile config, final String pathPrefix) {
|
||||
// Ignore passable.
|
||||
for (final String input : config.getStringList(pathPrefix + ConfPaths.SUB_IGNOREPASSABLE)){
|
||||
final Integer id = ConfigFile.parseTypeId(input);
|
||||
if (id == null || id < 0 || id >= 4096) LogUtil.logWarning("[NoCheatplus] Bad block id (" + pathPrefix + ConfPaths.SUB_IGNOREPASSABLE + "): " + input);
|
||||
for (final String input : config.getStringList(pathPrefix + RootConfPaths.SUB_IGNOREPASSABLE)){
|
||||
final Integer id = RawConfigFile.parseTypeId(input);
|
||||
if (id == null || id < 0 || id >= 4096) LogUtil.logWarning("[NoCheatplus] Bad block id (" + pathPrefix + RootConfPaths.SUB_IGNOREPASSABLE + "): " + input);
|
||||
else blockFlags[id] |= F_IGN_PASSABLE;
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package fr.neatmonster.nocheatplus.utilities;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
/**
|
||||
* Desperate :).
|
||||
* @author mc_dev
|
||||
*
|
||||
*/
|
||||
public class ColorUtil {
|
||||
|
||||
/**
|
||||
* Removes the colors of a message.
|
||||
*
|
||||
* @param text
|
||||
* the text
|
||||
* @return the string
|
||||
*/
|
||||
public static String removeColors(String text) {
|
||||
for (final ChatColor c : ChatColor.values())
|
||||
text = text.replace("&" + c.getChar(), "");
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace colors of a message.
|
||||
*
|
||||
* @param text
|
||||
* the text
|
||||
* @return the string
|
||||
*/
|
||||
public static String replaceColors(String text) {
|
||||
for (final ChatColor c : ChatColor.values())
|
||||
text = text.replace("&" + c.getChar(), c.toString());
|
||||
return text;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package fr.neatmonster.nocheatplus.utilities;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
/**
|
||||
* Could not help it.
|
||||
* @author mc_dev
|
||||
*
|
||||
*/
|
||||
public class PotionUtil {
|
||||
|
||||
/**
|
||||
* Get amplifier for a potion effect.
|
||||
* @param player
|
||||
* @param type
|
||||
* @return Double.MIN_VALUE if not present, otherwise the maximal amplifier.
|
||||
*/
|
||||
public static final double getPotionEffectAmplifier(final Player player, final PotionEffectType type) {
|
||||
if (!player.hasPotionEffect(type)) return Double.MIN_VALUE;
|
||||
final Collection<PotionEffect> effects = player.getActivePotionEffects();
|
||||
double max = Double.MIN_VALUE;
|
||||
for (final PotionEffect effect : effects){
|
||||
if (effect.getType() == type){
|
||||
max = Math.max(max, effect.getAmplifier());
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
}
|
@ -7,6 +7,8 @@ import java.util.Map;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
|
||||
/**
|
||||
* A not too fat stats class re-used from other plugins.
|
||||
* @author asofold
|
@ -5,24 +5,19 @@
|
||||
<artifactId>ncpcompatcb2511</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>NCPCompatCB2511</name>
|
||||
<version>1.0.0</version>
|
||||
<version>static</version>
|
||||
|
||||
<parent>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>nocheatplus-parent</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>static</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcommons</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcompat</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>static</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
|
@ -5,24 +5,19 @@
|
||||
<artifactId>ncpcompatcb2512</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>NCPCompatCB2512</name>
|
||||
<version>1.0.0</version>
|
||||
<version>static</version>
|
||||
|
||||
<parent>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>nocheatplus-parent</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>static</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcommons</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcompat</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>static</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
|
@ -5,24 +5,19 @@
|
||||
<artifactId>ncpcompatcb2545</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>NCPCompatCB2545</name>
|
||||
<version>1.0.0</version>
|
||||
<version>static</version>
|
||||
|
||||
<parent>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>nocheatplus-parent</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>static</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcommons</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcompat</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>static</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
|
@ -5,24 +5,19 @@
|
||||
<artifactId>ncpcompatcbdev</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>NCPCompatCBDev</name>
|
||||
<version>1.0.0</version>
|
||||
<version>static</version>
|
||||
|
||||
<parent>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>nocheatplus-parent</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>static</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcommons</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcompat</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>static</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
|
@ -34,32 +34,32 @@
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcommons</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>static</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcompat</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>static</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcompatcb2511</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>static</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcompatcb2512</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>static</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcompatcb2545</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>static</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcompatcbdev</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>static</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package fr.neatmonster.nocheatplus;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@ -55,6 +56,8 @@ import fr.neatmonster.nocheatplus.config.DefaultConfig;
|
||||
import fr.neatmonster.nocheatplus.event.IHaveMethodOrder;
|
||||
import fr.neatmonster.nocheatplus.event.ListenerManager;
|
||||
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.logging.StaticLogFile;
|
||||
import fr.neatmonster.nocheatplus.metrics.Metrics;
|
||||
import fr.neatmonster.nocheatplus.metrics.Metrics.Graph;
|
||||
import fr.neatmonster.nocheatplus.metrics.Metrics.Plotter;
|
||||
@ -64,7 +67,6 @@ import fr.neatmonster.nocheatplus.permissions.PermissionUtil.CommandProtectionEn
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.players.DataManager;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
|
||||
import fr.neatmonster.nocheatplus.utilities.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
||||
import fr.neatmonster.nocheatplus.utilities.Updates;
|
||||
|
||||
@ -392,6 +394,10 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
||||
// Cleanup the configuration manager.
|
||||
if (verbose) LogUtil.logInfo("[NoCheatPlus] Cleanup ConfigManager...");
|
||||
ConfigManager.cleanup();
|
||||
|
||||
// Cleanup file logger.
|
||||
if (verbose) LogUtil.logInfo("[NoCheatPlus] Cleanup file logger...");
|
||||
StaticLogFile.cleanup();
|
||||
|
||||
// Tell the server administrator the we finished unloading NoCheatPlus.
|
||||
if (verbose) LogUtil.logInfo("[NoCheatPlus] All cleanup done.");
|
||||
@ -442,6 +448,9 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
||||
// Read the configuration files.
|
||||
ConfigManager.init(this);
|
||||
|
||||
// Setup file logger.
|
||||
StaticLogFile.setupLogger(new File(getDataFolder(), ConfigManager.getConfigFile().getString(ConfPaths.LOGGING_FILENAME)));
|
||||
|
||||
// Allow entries to TickTask (just in case).
|
||||
TickTask.setLocked(false);
|
||||
|
||||
@ -478,7 +487,7 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
||||
@Override
|
||||
public void onReload() {
|
||||
// Only for reloading, not INeedConfig.
|
||||
BlockProperties.init();
|
||||
BlockProperties.init(getMCAccess());
|
||||
final ConfigFile config = ConfigManager.getConfigFile();
|
||||
BlockProperties.applyConfig(config, ConfPaths.COMPATIBILITY_BLOCKS);
|
||||
undoCommandChanges();
|
||||
|
@ -9,7 +9,7 @@ import fr.neatmonster.nocheatplus.actions.types.CancelAction;
|
||||
import fr.neatmonster.nocheatplus.actions.types.CommandAction;
|
||||
import fr.neatmonster.nocheatplus.actions.types.DummyAction;
|
||||
import fr.neatmonster.nocheatplus.actions.types.LogAction;
|
||||
import fr.neatmonster.nocheatplus.utilities.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
|
||||
/*
|
||||
* MMP"""""""MM dP oo MM""""""""`M dP
|
||||
|
@ -4,7 +4,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandException;
|
||||
|
||||
import fr.neatmonster.nocheatplus.checks.ViolationData;
|
||||
import fr.neatmonster.nocheatplus.utilities.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
|
||||
/*
|
||||
* MM'""""'YMM dP
|
||||
|
@ -7,8 +7,9 @@ import fr.neatmonster.nocheatplus.actions.Action;
|
||||
import fr.neatmonster.nocheatplus.checks.ViolationData;
|
||||
import fr.neatmonster.nocheatplus.config.ConfPaths;
|
||||
import fr.neatmonster.nocheatplus.config.ConfigFile;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
import fr.neatmonster.nocheatplus.utilities.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.logging.StaticLogFile;
|
||||
import fr.neatmonster.nocheatplus.utilities.ColorUtil;
|
||||
|
||||
/*
|
||||
* M""MMMMMMMM MMP"""""""MM dP oo
|
||||
@ -72,9 +73,9 @@ public class LogAction extends ActionWithParameters {
|
||||
public boolean execute(final ViolationData violationData) {
|
||||
if (!violationData.player.hasPermission(violationData.getPermissionSilent())) {
|
||||
final String message = super.getMessage(violationData);
|
||||
if (toChat) NoCheatPlus.sendAdminNotifyMessage(ChatColor.RED + "NCP: " + ChatColor.WHITE + CheckUtils.replaceColors(message));
|
||||
if (toConsole) LogUtil.logInfo("[NoCheatPlus] " + CheckUtils.removeColors(message));
|
||||
if (toFile) CheckUtils.fileLogger.info(CheckUtils.removeColors(message));
|
||||
if (toChat) NoCheatPlus.sendAdminNotifyMessage(ChatColor.RED + "NCP: " + ChatColor.WHITE + ColorUtil.replaceColors(message));
|
||||
if (toConsole) LogUtil.logInfo("[NoCheatPlus] " + ColorUtil.removeColors(message));
|
||||
if (toFile) StaticLogFile.fileLogger.info(ColorUtil.removeColors(message));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package fr.neatmonster.nocheatplus.checks;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
|
||||
import fr.neatmonster.nocheatplus.utilities.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
|
||||
public abstract class AsyncCheck extends Check {
|
||||
|
||||
|
@ -11,10 +11,10 @@ import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
|
||||
import fr.neatmonster.nocheatplus.hooks.NCPHookManager;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.metrics.MetricsData;
|
||||
import fr.neatmonster.nocheatplus.players.DataManager;
|
||||
import fr.neatmonster.nocheatplus.players.ExecutionHistory;
|
||||
import fr.neatmonster.nocheatplus.utilities.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
||||
|
||||
/*
|
||||
|
@ -9,7 +9,7 @@ import fr.neatmonster.nocheatplus.actions.ActionList;
|
||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||
import fr.neatmonster.nocheatplus.actions.types.CancelAction;
|
||||
import fr.neatmonster.nocheatplus.checks.access.IViolationInfo;
|
||||
import fr.neatmonster.nocheatplus.utilities.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
|
||||
/*
|
||||
* M""MMMMM""M oo dP dP oo M""""""'YMM dP
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.entity.Player;
|
||||
import fr.neatmonster.nocheatplus.checks.AsyncCheck;
|
||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
import fr.neatmonster.nocheatplus.utilities.ColorUtil;
|
||||
|
||||
/**
|
||||
* NOTE: EARLY REFACTORING STATE, MOST METHODS NEED SYNC OVER DATA !
|
||||
@ -31,7 +31,7 @@ public class Captcha extends AsyncCheck implements ICaptcha{
|
||||
// Yes, clear his data and do not worry anymore about him.
|
||||
data.reset();
|
||||
data.captchaStarted = false;
|
||||
player.sendMessage(CheckUtils.replaceColors(cc.captchaSuccess));
|
||||
player.sendMessage(ColorUtil.replaceColors(cc.captchaSuccess));
|
||||
} else {
|
||||
// Increment his tries number counter.
|
||||
data.captchTries++;
|
||||
@ -86,7 +86,7 @@ public class Captcha extends AsyncCheck implements ICaptcha{
|
||||
|
||||
@Override
|
||||
public void sendCaptcha(Player player, ChatConfig cc, ChatData data) {
|
||||
player.sendMessage(CheckUtils.replaceColors(cc.captchaQuestion.replace("[captcha]",
|
||||
player.sendMessage(ColorUtil.replaceColors(cc.captchaQuestion.replace("[captcha]",
|
||||
data.captchaGenerated)));
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import fr.neatmonster.nocheatplus.checks.Check;
|
||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
import fr.neatmonster.nocheatplus.utilities.ColorUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
||||
|
||||
/**
|
||||
@ -67,7 +67,7 @@ public class Commands extends Check {
|
||||
return true;
|
||||
}
|
||||
else if (cc.chatWarningCheck && now - data.chatWarningTime > cc.chatWarningTimeout && (100f * nw / cc.commandsLevel > cc.chatWarningLevel || 100f * data.commandsShortTermWeight / cc.commandsShortTermLevel > cc.chatWarningLevel)){
|
||||
player.sendMessage(CheckUtils.replaceColors(cc.chatWarningMessage));
|
||||
player.sendMessage(ColorUtil.replaceColors(cc.chatWarningMessage));
|
||||
data.chatWarningTime = now;
|
||||
}
|
||||
else{
|
||||
|
@ -5,7 +5,7 @@ import org.bukkit.entity.Player;
|
||||
import fr.neatmonster.nocheatplus.checks.Check;
|
||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.checks.combined.CombinedData;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
import fr.neatmonster.nocheatplus.utilities.ColorUtil;
|
||||
|
||||
public class Relog extends Check {
|
||||
|
||||
@ -36,7 +36,7 @@ public class Relog extends Check {
|
||||
if (now - data.relogWarningTime > cc.relogWarningTimeout)
|
||||
data.relogWarnings = 0;
|
||||
if (data.relogWarnings < cc.relogWarningNumber) {
|
||||
player.sendMessage(CheckUtils.replaceColors(cc.relogWarningMessage));
|
||||
player.sendMessage(ColorUtil.replaceColors(cc.relogWarningMessage));
|
||||
data.relogWarningTime = now;
|
||||
data.relogWarnings++;
|
||||
} else{
|
||||
|
@ -19,8 +19,10 @@ import fr.neatmonster.nocheatplus.checks.combined.CombinedData;
|
||||
import fr.neatmonster.nocheatplus.command.INotifyReload;
|
||||
import fr.neatmonster.nocheatplus.config.ConfigFile;
|
||||
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
import fr.neatmonster.nocheatplus.utilities.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.ColorUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
||||
|
||||
/**
|
||||
* Some alternative more or less advanced analysis methods.
|
||||
@ -213,7 +215,7 @@ public class Text extends AsyncCheck implements INotifyReload{
|
||||
wWords /= (float) letterCounts.words.length;
|
||||
score += wWords;
|
||||
|
||||
if (debug && score > 0f) debugParts.add("Simple score: " + CheckUtils.fdec3.format(score));
|
||||
if (debug && score > 0f) debugParts.add("Simple score: " + StringUtil.fdec3.format(score));
|
||||
|
||||
// Engine:
|
||||
// TODO: more fine grained sync !
|
||||
@ -268,7 +270,7 @@ public class Text extends AsyncCheck implements INotifyReload{
|
||||
}
|
||||
}
|
||||
else if (cc.chatWarningCheck && time - data.chatWarningTime > cc.chatWarningTimeout && (100f * accumulated / cc.textFreqNormLevel > cc.chatWarningLevel || 100f * shortTermAccumulated / cc.textFreqShortTermLevel > cc.chatWarningLevel)){
|
||||
player.sendMessage(CheckUtils.replaceColors(cc.chatWarningMessage));
|
||||
player.sendMessage(ColorUtil.replaceColors(cc.chatWarningMessage));
|
||||
data.chatWarningTime = time;
|
||||
}
|
||||
else {
|
||||
@ -285,15 +287,15 @@ public class Text extends AsyncCheck implements INotifyReload{
|
||||
for (String key : keys) {
|
||||
Float s = engMap.get(key);
|
||||
if (s.floatValue() > 0.0f)
|
||||
debugParts.add(key + ":" + CheckUtils.fdec3.format(s));
|
||||
debugParts.add(key + ":" + StringUtil.fdec3.format(s));
|
||||
}
|
||||
if (wEngine > 0.0f)
|
||||
debugParts.add("Engine score (" + (cc.textEngineMaximum?"max":"sum") + "): " + CheckUtils.fdec3.format(wEngine));
|
||||
debugParts.add("Engine score (" + (cc.textEngineMaximum?"max":"sum") + "): " + StringUtil.fdec3.format(wEngine));
|
||||
|
||||
debugParts.add("Final score: " + CheckUtils.fdec3.format(score));
|
||||
debugParts.add("Normal: min=" + CheckUtils.fdec3.format(cc.textFreqNormMin) +", weight=" + CheckUtils.fdec3.format(cc.textFreqNormWeight) + " => accumulated=" + CheckUtils.fdec3.format(accumulated));
|
||||
debugParts.add("Short-term: min=" + CheckUtils.fdec3.format(cc.textFreqShortTermMin) +", weight=" + CheckUtils.fdec3.format(cc.textFreqShortTermWeight) + " => accumulated=" + CheckUtils.fdec3.format(shortTermAccumulated));
|
||||
debugParts.add("vl: " + CheckUtils.fdec3.format(data.textVL));
|
||||
debugParts.add("Final score: " + StringUtil.fdec3.format(score));
|
||||
debugParts.add("Normal: min=" + StringUtil.fdec3.format(cc.textFreqNormMin) +", weight=" + StringUtil.fdec3.format(cc.textFreqNormWeight) + " => accumulated=" + StringUtil.fdec3.format(accumulated));
|
||||
debugParts.add("Short-term: min=" + StringUtil.fdec3.format(cc.textFreqShortTermMin) +", weight=" + StringUtil.fdec3.format(cc.textFreqShortTermWeight) + " => accumulated=" + StringUtil.fdec3.format(shortTermAccumulated));
|
||||
debugParts.add("vl: " + StringUtil.fdec3.format(data.textVL));
|
||||
LogUtil.scheduleLogInfo(debugParts, " | ");
|
||||
debugParts.clear();
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import fr.neatmonster.nocheatplus.components.IHaveCheckType;
|
||||
import fr.neatmonster.nocheatplus.components.IRemoveData;
|
||||
import fr.neatmonster.nocheatplus.config.ConfPaths;
|
||||
import fr.neatmonster.nocheatplus.config.ConfigFile;
|
||||
import fr.neatmonster.nocheatplus.utilities.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -18,9 +18,9 @@ import fr.neatmonster.nocheatplus.checks.access.ICheckConfig;
|
||||
import fr.neatmonster.nocheatplus.config.ConfPaths;
|
||||
import fr.neatmonster.nocheatplus.config.ConfigFile;
|
||||
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
import fr.neatmonster.nocheatplus.utilities.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
||||
|
||||
public class CombinedConfig extends ACheckConfig {
|
||||
|
||||
@ -117,7 +117,7 @@ public class CombinedConfig extends ACheckConfig {
|
||||
}
|
||||
}
|
||||
invulnerableModifierDefault = defaultMod;
|
||||
if (error) LogUtil.logInfo("[NoCheatPlus] Damage causes can be: " + CheckUtils.join(Arrays.asList(DamageCause.values()), ", "));
|
||||
if (error) LogUtil.logInfo("[NoCheatPlus] Damage causes can be: " + StringUtil.join(Arrays.asList(DamageCause.values()), ", "));
|
||||
invulnerableTriggerAlways = config.getBoolean(ConfPaths.COMBINED_INVULNERABLE_TRIGGERS_ALWAYS);
|
||||
invulnerableTriggerFallDistance = config.getBoolean(ConfPaths.COMBINED_INVULNERABLE_TRIGGERS_FALLDISTANCE);
|
||||
|
||||
|
@ -13,7 +13,7 @@ import fr.neatmonster.nocheatplus.checks.Check;
|
||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.checks.combined.Improbable;
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
||||
|
||||
/*
|
||||
@ -151,7 +151,7 @@ public class Reach extends Check {
|
||||
else cancelByPenalty = false;
|
||||
|
||||
if (cc.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){
|
||||
player.sendMessage("NC+: Attack " + (cancel ? (cancelByPenalty ? "(cancel/penalty) ":"(cancel/reach) ") : "") + damaged.getType()+ " height="+ CheckUtils.fdec3.format(height) + " dist=" + CheckUtils.fdec3.format(lenpRel) +" @" + CheckUtils.fdec3.format(reachMod));
|
||||
player.sendMessage("NC+: Attack " + (cancel ? (cancelByPenalty ? "(cancel/penalty) ":"(cancel/reach) ") : "") + damaged.getType()+ " height="+ StringUtil.fdec3.format(height) + " dist=" + StringUtil.fdec3.format(lenpRel) +" @" + StringUtil.fdec3.format(reachMod));
|
||||
}
|
||||
|
||||
return cancel;
|
||||
|
@ -50,12 +50,13 @@ import fr.neatmonster.nocheatplus.components.IHaveCheckType;
|
||||
import fr.neatmonster.nocheatplus.components.IRemoveData;
|
||||
import fr.neatmonster.nocheatplus.components.TickListener;
|
||||
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
import fr.neatmonster.nocheatplus.utilities.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
|
||||
import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
||||
|
||||
/*
|
||||
* M"""""`'"""`YM oo
|
||||
@ -396,10 +397,10 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||
StringBuilder builder = new StringBuilder(250);
|
||||
final Location loc = player.getLocation();
|
||||
builder.append(player.getName());
|
||||
builder.append(" " + from.getWorld().getName() + " " + CheckUtils.fdec3.format(from.getX()) + (from.getX() == loc.getX() ? "" : ("(" + CheckUtils.fdec3.format(loc.getX()) + ")")));
|
||||
builder.append(", " + CheckUtils.fdec3.format(from.getY()) + (from.getY() == loc.getY() ? "" : ("(" + CheckUtils.fdec3.format(loc.getY()) + ")")));
|
||||
builder.append(", " + CheckUtils.fdec3.format(from.getZ()) + (from.getZ() == loc.getZ() ? "" : ("(" + CheckUtils.fdec3.format(loc.getZ()) + ")")));
|
||||
builder.append(" -> " + CheckUtils.fdec3.format(to.getX()) + ", " + CheckUtils.fdec3.format(to.getY()) + ", " + CheckUtils.fdec3.format(to.getZ()));
|
||||
builder.append(" " + from.getWorld().getName() + " " + StringUtil.fdec3.format(from.getX()) + (from.getX() == loc.getX() ? "" : ("(" + StringUtil.fdec3.format(loc.getX()) + ")")));
|
||||
builder.append(", " + StringUtil.fdec3.format(from.getY()) + (from.getY() == loc.getY() ? "" : ("(" + StringUtil.fdec3.format(loc.getY()) + ")")));
|
||||
builder.append(", " + StringUtil.fdec3.format(from.getZ()) + (from.getZ() == loc.getZ() ? "" : ("(" + StringUtil.fdec3.format(loc.getZ()) + ")")));
|
||||
builder.append(" -> " + StringUtil.fdec3.format(to.getX()) + ", " + StringUtil.fdec3.format(to.getY()) + ", " + StringUtil.fdec3.format(to.getZ()));
|
||||
System.out.print(builder.toString());
|
||||
}
|
||||
|
||||
@ -515,7 +516,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||
// Remember where we send the player to.
|
||||
data.setTeleported(newTo);
|
||||
if (cc.debug){
|
||||
System.out.println(player.getName() + " set back to: " + newTo.getWorld() + CheckUtils.fdec3.format(newTo.getX()) + ", " + CheckUtils.fdec3.format(newTo.getY()) + ", " + CheckUtils.fdec3.format(newTo.getZ()));
|
||||
System.out.println(player.getName() + " set back to: " + newTo.getWorld() + StringUtil.fdec3.format(newTo.getX()) + ", " + StringUtil.fdec3.format(newTo.getY()) + ", " + StringUtil.fdec3.format(newTo.getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,8 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
|
||||
import fr.neatmonster.nocheatplus.checks.Check;
|
||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
|
||||
import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
||||
|
||||
/*
|
||||
* M"""""""`YM MM""""""""`M dP dP
|
||||
@ -161,7 +161,7 @@ public class NoFall extends Check {
|
||||
data.noFallFallDistance -= yDiff;
|
||||
}
|
||||
|
||||
if (cc.debug) System.out.println(player.getName() + " NoFall: mc=" + CheckUtils.fdec3.format(player.getFallDistance()) +" / nf=" + CheckUtils.fdec3.format(data.noFallFallDistance) + (oldNFDist < data.noFallFallDistance ? " (+" + CheckUtils.fdec3.format(data.noFallFallDistance - oldNFDist) + ")" : ""));
|
||||
if (cc.debug) System.out.println(player.getName() + " NoFall: mc=" + StringUtil.fdec3.format(player.getFallDistance()) +" / nf=" + StringUtil.fdec3.format(data.noFallFallDistance) + (oldNFDist < data.noFallFallDistance ? " (+" + StringUtil.fdec3.format(data.noFallFallDistance - oldNFDist) + ")" : ""));
|
||||
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,8 @@ import fr.neatmonster.nocheatplus.checks.ViolationData;
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.utilities.ActionFrequency;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
|
||||
import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
||||
|
||||
/*
|
||||
@ -308,14 +308,14 @@ public class SurvivalFly extends Check {
|
||||
// TODO: also show resetcond (!)
|
||||
StringBuilder builder = new StringBuilder(500);
|
||||
builder.append(player.getName() + " ground: " + (data.noFallAssumeGround ? "(assumeonground) " : "") + (fromOnGround ? "onground -> " : (resetFrom ? "resetcond -> " : "--- -> ")) + (toOnGround ? "onground" : (resetTo ? "resetcond" : "---")) + "\n");
|
||||
builder.append(player.getName() + " hDist: " + CheckUtils.fdec3.format(hDistance) + " / " + CheckUtils.fdec3.format(hAllowedDistance) + " , vDist: " + CheckUtils.fdec3.format(yDistance) + " / " + CheckUtils.fdec3.format(vAllowedDistance) + "\n");
|
||||
builder.append(player.getName() + " vfreedom: " + CheckUtils.fdec3.format(data.verticalFreedom) + " (vv=" + CheckUtils.fdec3.format(data.verticalVelocity) + "/vvc=" + data.verticalVelocityCounter + "), jumpphase: " + data.sfJumpPhase + "\n");
|
||||
builder.append(player.getName() + " hDist: " + StringUtil.fdec3.format(hDistance) + " / " + StringUtil.fdec3.format(hAllowedDistance) + " , vDist: " + StringUtil.fdec3.format(yDistance) + " / " + StringUtil.fdec3.format(vAllowedDistance) + "\n");
|
||||
builder.append(player.getName() + " vfreedom: " + StringUtil.fdec3.format(data.verticalFreedom) + " (vv=" + StringUtil.fdec3.format(data.verticalVelocity) + "/vvc=" + data.verticalVelocityCounter + "), jumpphase: " + data.sfJumpPhase + "\n");
|
||||
if (!resetFrom && !resetTo) {
|
||||
// if (cc.survivalFlyAccountingH && data.hDistCount.bucketScore(1) > 0 && data.hDistCount.bucketScore(2) > 0) builder.append(player.getName() + " hacc=" + data.hDistSum.bucketScore(2) + "->" + data.hDistSum.bucketScore(1) + "\n");
|
||||
if (cc.survivalFlyAccountingV && data.vDistCount.bucketScore(1) > 0 && data.vDistCount.bucketScore(2) > 0) builder.append(player.getName() + " vacc=" + data.vDistSum.bucketScore(2) + "->" + data.vDistSum.bucketScore(1) + "\n");
|
||||
}
|
||||
if (player.isSleeping()) tags.add("sleeping");
|
||||
if (!tags.isEmpty()) builder.append(player.getName() + " tags: " + CheckUtils.join(tags, "+") + "\n");
|
||||
if (!tags.isEmpty()) builder.append(player.getName() + " tags: " + StringUtil.join(tags, "+") + "\n");
|
||||
System.out.print(builder.toString());
|
||||
}
|
||||
|
||||
@ -475,7 +475,7 @@ public class SurvivalFly extends Check {
|
||||
vd.setParameter(ParameterName.LOCATION_FROM, String.format(Locale.US, "%.2f, %.2f, %.2f", from.getX(), from.getY(), from.getZ()));
|
||||
vd.setParameter(ParameterName.LOCATION_TO, String.format(Locale.US, "%.2f, %.2f, %.2f", to.getX(), to.getY(), to.getZ()));
|
||||
vd.setParameter(ParameterName.DISTANCE, String.format(Locale.US, "%.2f", to.getLocation().distance(from.getLocation())));
|
||||
vd.setParameter(ParameterName.TAGS, CheckUtils.join(tags, "+"));
|
||||
vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
|
||||
}
|
||||
if (executeActions(vd)) {
|
||||
data.sfLastYDist = Double.MAX_VALUE;
|
||||
|
@ -16,7 +16,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.utilities.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
|
||||
public class CommandUtil {
|
||||
|
||||
|
@ -8,8 +8,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||
import fr.neatmonster.nocheatplus.command.DelayableCommand;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.utilities.LogUtil;
|
||||
|
||||
public class BanCommand extends DelayableCommand {
|
||||
|
||||
|
@ -7,8 +7,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||
import fr.neatmonster.nocheatplus.command.DelayableCommand;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.utilities.LogUtil;
|
||||
|
||||
public class KickCommand extends DelayableCommand {
|
||||
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.command.CommandSender;
|
||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||
import fr.neatmonster.nocheatplus.command.NCPCommand;
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
||||
|
||||
public class KickListCommand extends NCPCommand {
|
||||
|
||||
@ -21,7 +21,7 @@ public class KickListCommand extends NCPCommand {
|
||||
final String[] kicked = NoCheatPlus.getLoginDeniedPlayers();
|
||||
if (kicked.length < 100) Arrays.sort(kicked);
|
||||
sender.sendMessage(TAG + "Temporarily kicked players:");
|
||||
sender.sendMessage(CheckUtils.join(Arrays.asList(kicked), " "));
|
||||
sender.sendMessage(StringUtil.join(Arrays.asList(kicked), " "));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.entity.Player;
|
||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||
import fr.neatmonster.nocheatplus.command.DelayableCommand;
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
import fr.neatmonster.nocheatplus.utilities.ColorUtil;
|
||||
|
||||
/**
|
||||
* For warnings etc.
|
||||
@ -38,7 +38,7 @@ public class TellCommand extends DelayableCommand {
|
||||
|
||||
private void tell(String name, String message) {
|
||||
Player player = Bukkit.getServer().getPlayerExact(name);
|
||||
if (player != null) player.sendMessage(CheckUtils.replaceColors(message));
|
||||
if (player != null) player.sendMessage(ColorUtil.replaceColors(message));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,8 +7,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||
import fr.neatmonster.nocheatplus.command.DelayableCommand;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.utilities.LogUtil;
|
||||
|
||||
public class TempKickCommand extends DelayableCommand {
|
||||
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.command.CommandSender;
|
||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||
import fr.neatmonster.nocheatplus.command.NCPCommand;
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
||||
|
||||
/**
|
||||
* This command just shows a list of all commands.
|
||||
@ -39,7 +39,7 @@ public class CommandsCommand extends NCPCommand {
|
||||
if (cmd != null){
|
||||
all += cmd.getUsage().replace("<command>", "ncp") + "Auxiliary commands (actions):\n";
|
||||
}
|
||||
all += CheckUtils.join(Arrays.asList(moreCommands), "\n");
|
||||
all += StringUtil.join(Arrays.asList(moreCommands), "\n");
|
||||
allCommands = all;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ import fr.neatmonster.nocheatplus.command.CommandUtil;
|
||||
import fr.neatmonster.nocheatplus.command.NCPCommand;
|
||||
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
||||
|
||||
public class ExemptCommand extends NCPCommand {
|
||||
|
||||
@ -34,7 +34,7 @@ public class ExemptCommand extends NCPCommand {
|
||||
checkType = CheckType.valueOf(args[2].toUpperCase().replace('-', '_').replace('.', '_'));
|
||||
} catch (Exception e){
|
||||
sender.sendMessage(TAG + "Could not interpret: " + args[2]);
|
||||
sender.sendMessage(TAG + "Check type should be one of: " + CheckUtils.join(Arrays.asList(CheckType.values()), " | "));
|
||||
sender.sendMessage(TAG + "Check type should be one of: " + StringUtil.join(Arrays.asList(CheckType.values()), " | "));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.command.NCPCommand;
|
||||
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
||||
|
||||
public class ExemptionsCommand extends NCPCommand {
|
||||
|
||||
@ -33,7 +33,7 @@ public class ExemptionsCommand extends NCPCommand {
|
||||
if (NCPExemptionManager.isExempted(playerName, type)) entries.add(type.toString());
|
||||
}
|
||||
if (entries.isEmpty()) sender.sendMessage(TAG + "No exemption entries available for " + playerName +" .");
|
||||
else sender.sendMessage(TAG + "Exemptions for " + playerName + ": " + CheckUtils.join(entries, ", "));
|
||||
else sender.sendMessage(TAG + "Exemptions for " + playerName + ": " + StringUtil.join(entries, ", "));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.command.CommandSender;
|
||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||
import fr.neatmonster.nocheatplus.command.NCPCommand;
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
||||
|
||||
public class LagCommand extends NCPCommand {
|
||||
@ -27,7 +27,7 @@ public class LagCommand extends NCPCommand {
|
||||
for (long ms : new long[]{second, medium, max}){
|
||||
double lag = TickTask.getLag(ms);
|
||||
int p = Math.max(0, (int) ((lag - 1.0) * 100.0));
|
||||
builder.append(" " + p + "%[" + CheckUtils.fdec1.format((double) ms / 1200.0) + "s]" );
|
||||
builder.append(" " + p + "%[" + StringUtil.fdec1.format((double) ms / 1200.0) + "s]" );
|
||||
}
|
||||
long[] spikeDurations = TickTask.getLagSpikeDurations();
|
||||
int[] spikes = TickTask.getLagSpikes();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package fr.neatmonster.nocheatplus.command.admin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -14,9 +15,9 @@ import fr.neatmonster.nocheatplus.command.NCPCommand;
|
||||
import fr.neatmonster.nocheatplus.config.ConfPaths;
|
||||
import fr.neatmonster.nocheatplus.config.ConfigFile;
|
||||
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
||||
import fr.neatmonster.nocheatplus.logging.StaticLogFile;
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.players.DataManager;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
|
||||
public class ReloadCommand extends NCPCommand {
|
||||
|
||||
@ -49,7 +50,9 @@ public class ReloadCommand extends NCPCommand {
|
||||
// Do the actual reload.
|
||||
ConfigManager.cleanup();
|
||||
ConfigManager.init(plugin);
|
||||
DataManager.clearConfigs(); // Here you have to add XConfig.clear() form now on.
|
||||
StaticLogFile.cleanup();
|
||||
StaticLogFile.setupLogger(new File(plugin.getDataFolder(), ConfigManager.getConfigFile().getString(ConfPaths.LOGGING_FILENAME)));
|
||||
DataManager.clearConfigs(); // There you have to add XConfig.clear() form now on.
|
||||
|
||||
// Tell the plugin to adapt to new config.
|
||||
for (final INotifyReload component : notifyReload){
|
||||
@ -63,7 +66,7 @@ public class ReloadCommand extends NCPCommand {
|
||||
final String info = "[NoCheatPlus] Configuration reloaded.";
|
||||
if (!(sender instanceof ConsoleCommandSender)) Bukkit.getLogger().info(info);
|
||||
final ConfigFile config = ConfigManager.getConfigFile();
|
||||
if (config.getBoolean(ConfPaths.LOGGING_ACTIVE) && config.getBoolean(ConfPaths.LOGGING_FILE)) CheckUtils.fileLogger.info(info);
|
||||
if (config.getBoolean(ConfPaths.LOGGING_ACTIVE) && config.getBoolean(ConfPaths.LOGGING_FILE)) StaticLogFile.fileLogger.info(info);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import fr.neatmonster.nocheatplus.command.CommandUtil;
|
||||
import fr.neatmonster.nocheatplus.command.NCPCommand;
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.players.DataManager;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
||||
|
||||
public class RemovePlayerCommand extends NCPCommand {
|
||||
|
||||
@ -36,7 +36,7 @@ public class RemovePlayerCommand extends NCPCommand {
|
||||
checkType = CheckType.valueOf(args[2].toUpperCase().replace('-', '_').replace('.', '_'));
|
||||
} catch (Exception e){
|
||||
sender.sendMessage(TAG + "Could not interpret: " + args[2]);
|
||||
sender.sendMessage(TAG + "Check type should be one of: " + CheckUtils.join(Arrays.asList(CheckType.values()), " | "));
|
||||
sender.sendMessage(TAG + "Check type should be one of: " + StringUtil.join(Arrays.asList(CheckType.values()), " | "));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import fr.neatmonster.nocheatplus.command.CommandUtil;
|
||||
import fr.neatmonster.nocheatplus.command.NCPCommand;
|
||||
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
|
||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
||||
|
||||
public class UnexemptCommand extends NCPCommand {
|
||||
|
||||
@ -34,7 +34,7 @@ public class UnexemptCommand extends NCPCommand {
|
||||
checkType = CheckType.valueOf(args[2].toUpperCase().replace('-', '_').replace('.', '_'));
|
||||
} catch (Exception e){
|
||||
sender.sendMessage(TAG + "Could not interpret: " + args[2]);
|
||||
sender.sendMessage(TAG + "Check type should be one of: " + CheckUtils.join(Arrays.asList(CheckType.values()), " | "));
|
||||
sender.sendMessage(TAG + "Check type should be one of: " + StringUtil.join(Arrays.asList(CheckType.values()), " | "));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import fr.neatmonster.nocheatplus.compat.cb2545.MCAccessCB2545;
|
||||
import fr.neatmonster.nocheatplus.compat.cbdev.MCAccessCBDev;
|
||||
import fr.neatmonster.nocheatplus.config.ConfPaths;
|
||||
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
||||
import fr.neatmonster.nocheatplus.utilities.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
|
||||
/**
|
||||
* Factory class to hide potentially dirty stuff.
|
||||
|
@ -525,9 +525,9 @@ public abstract class ConfPaths {
|
||||
public static final String COMPATIBILITY_BUKKITONLY = COMPATIBILITY + "bukkitapionly";
|
||||
public static final String COMPATIBILITY_BLOCKS = COMPATIBILITY + "blocks.";
|
||||
|
||||
// Sub paths that are used with different path prefixes potentially.
|
||||
// Sub-paths that are used with different path prefixes potentially.
|
||||
public static final String SUB_DEBUG = "debug";
|
||||
public static final String SUB_IGNOREPASSABLE = "ignorepassable";
|
||||
public static final String SUB_IGNOREPASSABLE = RootConfPaths.SUB_IGNOREPASSABLE;
|
||||
public static final String SUB_LAG = "lag";
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,6 @@
|
||||
package fr.neatmonster.nocheatplus.config;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.MemorySection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
|
||||
import fr.neatmonster.nocheatplus.actions.Action;
|
||||
import fr.neatmonster.nocheatplus.actions.ActionFactory;
|
||||
@ -22,9 +17,9 @@ import fr.neatmonster.nocheatplus.actions.ActionList;
|
||||
* d8888P
|
||||
*/
|
||||
/**
|
||||
* A special configuration class created to handle the loading/saving of actions lists.
|
||||
* A special configuration class created to handle the loading/saving of actions lists. This is for normal use with the plugin.
|
||||
*/
|
||||
public class ConfigFile extends YamlConfiguration {
|
||||
public class ConfigFile extends RawConfigFile {
|
||||
|
||||
/** The factory. */
|
||||
private ActionFactory factory;
|
||||
@ -60,70 +55,6 @@ public class ConfigFile extends YamlConfiguration {
|
||||
return factory.createActionList(value, permission);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return double within given bounds, with preset. Mainly used for hidden settings.
|
||||
*
|
||||
* @param data
|
||||
* @param path
|
||||
* @param min
|
||||
* @param max
|
||||
* @param preset
|
||||
* @return
|
||||
*/
|
||||
public double getDouble(final String path, final double min, final double max, final double preset){
|
||||
final double value = getDouble(path, preset);
|
||||
if (value < min) return min;
|
||||
else if (value > max) return max;
|
||||
else return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to get a type id from the path somehow, return null if nothing found.<br>
|
||||
* Will attempt to interpret strings, will return negative or out of range values.
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
public Integer getTypeId(final String path){
|
||||
return getTypeId(path, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to get a type id from the path somehow, return preset if nothing found.<br>
|
||||
* Will attempt to interpret strings, will return negative or out of range values.
|
||||
* @param path
|
||||
* @param preset
|
||||
* @return
|
||||
*/
|
||||
public Integer getTypeId(final String path, final Integer preset){
|
||||
String content = getString(path, null);
|
||||
if (content != null){
|
||||
Integer id = parseTypeId(content);
|
||||
if (id != null) return id;
|
||||
}
|
||||
int id = getInt(path, Integer.MAX_VALUE);
|
||||
return id == Integer.MAX_VALUE ? preset : id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to get an int id from a string.<br>
|
||||
* Will return out of range numbers, attempts to parse materials.
|
||||
* @param content
|
||||
* @return
|
||||
*/
|
||||
public static Integer parseTypeId(String content) {
|
||||
content = content.trim().toUpperCase();
|
||||
try{
|
||||
return Integer.parseInt(content);
|
||||
}
|
||||
catch(NumberFormatException e){}
|
||||
try{
|
||||
Material mat = Material.matchMaterial(content.replace(' ', '_').replace('-', '_').replace('.', '_'));
|
||||
if (mat != null) return mat.getId();
|
||||
}
|
||||
catch (Exception e) {}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do this after reading new data.
|
||||
*/
|
||||
@ -131,24 +62,6 @@ public class ConfigFile extends YamlConfiguration {
|
||||
factory = ConfigManager.getActionFactory(((MemorySection) this.get(ConfPaths.STRINGS)).getValues(false));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.bukkit.configuration.file.YamlConfiguration#saveToString()
|
||||
*/
|
||||
@Override
|
||||
public String saveToString() {
|
||||
// Some reflection wizardly to avoid having a lot of linebreaks in the yaml file, and get a "footer" into the
|
||||
// file.
|
||||
try {
|
||||
Field op;
|
||||
op = YamlConfiguration.class.getDeclaredField("yamlOptions");
|
||||
op.setAccessible(true);
|
||||
final DumperOptions options = (DumperOptions) op.get(this);
|
||||
options.setWidth(200);
|
||||
} catch (final Exception e) {}
|
||||
|
||||
return super.saveToString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely store ActionLists back into the yml file.
|
||||
*
|
||||
|
@ -1,26 +1,15 @@
|
||||
package fr.neatmonster.nocheatplus.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.util.logging.Formatter;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.MemoryConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||
import fr.neatmonster.nocheatplus.actions.ActionFactory;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
import fr.neatmonster.nocheatplus.utilities.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
|
||||
/*
|
||||
* MM'""""'YMM .8888b oo M"""""`'"""`YM
|
||||
@ -38,63 +27,8 @@ import fr.neatmonster.nocheatplus.utilities.LogUtil;
|
||||
*/
|
||||
public class ConfigManager {
|
||||
|
||||
/**
|
||||
* The formatter that is used to format the log file.
|
||||
*/
|
||||
private static class LogFileFormatter extends Formatter {
|
||||
|
||||
/**
|
||||
* Create a new instance of the log file formatter.
|
||||
*
|
||||
* @return the log file formatter
|
||||
*/
|
||||
public static LogFileFormatter newInstance() {
|
||||
return new LogFileFormatter();
|
||||
}
|
||||
|
||||
/** The date formatter. */
|
||||
private final SimpleDateFormat date;
|
||||
|
||||
/**
|
||||
* Instantiates a new log file formatter.
|
||||
*/
|
||||
private LogFileFormatter() {
|
||||
date = new SimpleDateFormat("yy.MM.dd HH:mm:ss");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.logging.Formatter#format(java.util.logging.LogRecord)
|
||||
*/
|
||||
@Override
|
||||
public String format(final LogRecord record) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
final Throwable ex = record.getThrown();
|
||||
|
||||
builder.append(date.format(record.getMillis()));
|
||||
builder.append(" [");
|
||||
builder.append(record.getLevel().getLocalizedName().toUpperCase());
|
||||
builder.append("] ");
|
||||
builder.append(record.getMessage());
|
||||
builder.append('\n');
|
||||
|
||||
if (ex != null) {
|
||||
final StringWriter writer = new StringWriter();
|
||||
ex.printStackTrace(new PrintWriter(writer));
|
||||
builder.append(writer);
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/** The map containing the configuration files per world. */
|
||||
private static final Map<String, ConfigFile> worldsMap = new HashMap<String, ConfigFile>();
|
||||
|
||||
/** The file handler. */
|
||||
private static FileHandler fileHandler = null;
|
||||
|
||||
/** The log file. */
|
||||
public static File logFile = null;
|
||||
|
||||
public static interface ActionFactoryFactory{
|
||||
public ActionFactory newActionFactory(Map<String, Object> library);
|
||||
@ -141,11 +75,7 @@ public class ConfigManager {
|
||||
* Cleanup.
|
||||
*/
|
||||
public static void cleanup() {
|
||||
fileHandler.flush();
|
||||
fileHandler.close();
|
||||
final Logger logger = Logger.getLogger("NoCheatPlus");
|
||||
logger.removeHandler(fileHandler);
|
||||
fileHandler = null;
|
||||
|
||||
setActionFactoryFactory(null);
|
||||
}
|
||||
|
||||
@ -201,7 +131,8 @@ public class ConfigManager {
|
||||
* @param plugin
|
||||
* the instance of NoCheatPlus
|
||||
*/
|
||||
public static synchronized void init(final NoCheatPlus plugin) {
|
||||
public static synchronized void init(final Plugin plugin) {
|
||||
// (This can lead to minor problems with async checks during reloading.)
|
||||
worldsMap.clear();
|
||||
// Try to obtain and parse the global configuration file.
|
||||
final File globalFile = new File(plugin.getDataFolder(), "config.yml");
|
||||
@ -215,11 +146,11 @@ public class ConfigManager {
|
||||
try {
|
||||
if (globalConfig.getBoolean(ConfPaths.SAVEBACKCONFIG)) globalConfig.save(globalFile);
|
||||
} catch (final Exception e) {
|
||||
Bukkit.getLogger().severe("[NoCheatPlus] Could not save back config.yml (see exception below).");
|
||||
LogUtil.logSevere("[NoCheatPlus] Could not save back config.yml (see exception below).");
|
||||
LogUtil.logSevere(e);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
Bukkit.getLogger().severe("[NoCheatPlus] Could not load config.yml (see exception below). Continue with default settings...");
|
||||
LogUtil.logSevere("[NoCheatPlus] Could not load config.yml (see exception below). Continue with default settings...");
|
||||
LogUtil.logSevere(e);
|
||||
}
|
||||
else {
|
||||
@ -229,40 +160,13 @@ public class ConfigManager {
|
||||
try {
|
||||
globalConfig.save(globalFile);
|
||||
} catch (final Exception e) {
|
||||
Bukkit.getLogger().severe("[NoCheatPlus] Could not save default config.yml (see exception below).");
|
||||
LogUtil.logSevere(e);
|
||||
}
|
||||
}
|
||||
globalConfig.regenerateActionLists();
|
||||
worldsMap.put(null, globalConfig);
|
||||
|
||||
// Setup the file logger.
|
||||
final Logger logger = Logger.getAnonymousLogger();
|
||||
logger.setLevel(Level.INFO);
|
||||
logger.setUseParentHandlers(false);
|
||||
for (final Handler h : logger.getHandlers())
|
||||
logger.removeHandler(h);
|
||||
if (fileHandler != null) {
|
||||
fileHandler.close();
|
||||
logger.removeHandler(fileHandler);
|
||||
fileHandler = null;
|
||||
}
|
||||
logFile = new File(plugin.getDataFolder(), globalConfig.getString(ConfPaths.LOGGING_FILENAME));
|
||||
try {
|
||||
try {
|
||||
logFile.getParentFile().mkdirs();
|
||||
} catch (final Exception e) {
|
||||
LogUtil.logSevere(e);
|
||||
}
|
||||
fileHandler = new FileHandler(logFile.getCanonicalPath(), true);
|
||||
fileHandler.setLevel(Level.ALL);
|
||||
fileHandler.setFormatter(LogFileFormatter.newInstance());
|
||||
logger.addHandler(fileHandler);
|
||||
} catch (final Exception e) {
|
||||
LogUtil.logSevere(e);
|
||||
}
|
||||
CheckUtils.fileLogger = logger;
|
||||
|
||||
|
||||
final MemoryConfiguration worldDefaults = PathUtils.getWorldsDefaultConfig(globalConfig);
|
||||
|
||||
// Try to obtain and parse the world-specific configuration files.
|
||||
@ -288,12 +192,12 @@ public class ConfigManager {
|
||||
try{
|
||||
if (worldConfig.getBoolean(ConfPaths.SAVEBACKCONFIG)) worldConfig.save(worldFile);
|
||||
} catch (final Exception e){
|
||||
Bukkit.getLogger().severe("[NoCheatPlus] Couldn't save back world-specific configuration for "
|
||||
LogUtil.logSevere("[NoCheatPlus] Couldn't save back world-specific configuration for "
|
||||
+ worldEntry.getKey() + " (see exception below).");
|
||||
LogUtil.logSevere(e);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
Bukkit.getLogger().severe("[NoCheatPlus] Couldn't load world-specific configuration for "
|
||||
LogUtil.logSevere("[NoCheatPlus] Couldn't load world-specific configuration for "
|
||||
+ worldEntry.getKey() + " (see exception below). Continue with global default settings...");
|
||||
LogUtil.logSevere(e);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.EventExecutor;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
|
||||
/**
|
||||
* listener registered for one event only. Allows to delegate to other registered listeners.
|
||||
|
@ -16,7 +16,7 @@ import org.bukkit.plugin.Plugin;
|
||||
import fr.neatmonster.nocheatplus.components.ComponentWithName;
|
||||
import fr.neatmonster.nocheatplus.event.GenericListener.MethodEntry;
|
||||
import fr.neatmonster.nocheatplus.event.GenericListener.MethodEntry.MethodOrder;
|
||||
import fr.neatmonster.nocheatplus.utilities.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
|
||||
/**
|
||||
* This class allows to register event-listeners which will all be called form within one event handler per event+priority combination.<br>
|
||||
|
@ -1,50 +1,17 @@
|
||||
package fr.neatmonster.nocheatplus.utilities;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
|
||||
/**
|
||||
* Random auxiliary gear, some might have general quality. Contents are likely to get moved to other classes.
|
||||
*/
|
||||
public class CheckUtils {
|
||||
|
||||
/** The file logger. */
|
||||
public static Logger fileLogger = null;
|
||||
|
||||
/** Decimal format for "#.###" */
|
||||
public static final DecimalFormat fdec3 = new DecimalFormat();
|
||||
|
||||
/** Decimal format for "#.#" */
|
||||
public static final DecimalFormat fdec1 = new DecimalFormat();
|
||||
|
||||
static {
|
||||
// 3 digits.
|
||||
DecimalFormatSymbols sym = fdec3.getDecimalFormatSymbols();
|
||||
sym.setDecimalSeparator('.');
|
||||
fdec3.setDecimalFormatSymbols(sym);
|
||||
fdec3.setMaximumFractionDigits(3);
|
||||
fdec3.setMinimumIntegerDigits(1);
|
||||
// 1 digit.
|
||||
sym = fdec1.getDecimalFormatSymbols();
|
||||
sym.setDecimalSeparator('.');
|
||||
fdec1.setDecimalFormatSymbols(sym);
|
||||
fdec1.setMaximumFractionDigits(1);
|
||||
fdec1.setMinimumIntegerDigits(1);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Check if a player looks at a target of a specific size, with a specific
|
||||
* precision value (roughly).
|
||||
*
|
||||
@ -137,7 +104,7 @@ public class CheckUtils {
|
||||
* the second String, must not be null
|
||||
* @return result distance
|
||||
*/
|
||||
private static int levenshteinDistance(CharSequence s, CharSequence t) {
|
||||
public static int levenshteinDistance(CharSequence s, CharSequence t) {
|
||||
if (s == null || t == null) throw new IllegalArgumentException("Strings must not be null");
|
||||
|
||||
int n = s.length();
|
||||
@ -184,107 +151,6 @@ public class CheckUtils {
|
||||
|
||||
return p[n];
|
||||
}
|
||||
|
||||
/**
|
||||
* Join parts with link.
|
||||
*
|
||||
* @param input
|
||||
* @param link
|
||||
* @return
|
||||
*/
|
||||
public static <O extends Object> String join(final Collection<O> input, final String link)
|
||||
{
|
||||
final StringBuilder builder = new StringBuilder(Math.max(300, input.size() * 10));
|
||||
boolean first = true;
|
||||
for (final Object obj : input) {
|
||||
if (!first) builder.append(link);
|
||||
builder.append(obj.toString());
|
||||
first = false;
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method.
|
||||
* @deprecated Use LogUtil.scheduleLogInfo instead.
|
||||
* @param parts
|
||||
* @param link
|
||||
* @return
|
||||
*/
|
||||
public static <O extends Object> boolean scheduleOutputJoined(final List<O> parts, String link)
|
||||
{
|
||||
return LogUtil.scheduleLogInfo(parts, link);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use instead: scheduleLogInfo
|
||||
* @param message
|
||||
* @return
|
||||
*/
|
||||
public static boolean scheduleOutput(final String message) {
|
||||
try {
|
||||
return Bukkit.getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("NoCheatPlus"), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getLogger().info(message);
|
||||
}
|
||||
}) != -1;
|
||||
} catch (final Exception exc) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the colors of a message.
|
||||
*
|
||||
* @param text
|
||||
* the text
|
||||
* @return the string
|
||||
*/
|
||||
public static String removeColors(String text) {
|
||||
for (final ChatColor c : ChatColor.values())
|
||||
text = text.replace("&" + c.getChar(), "");
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace colors of a message.
|
||||
*
|
||||
* @param text
|
||||
* the text
|
||||
* @return the string
|
||||
*/
|
||||
public static String replaceColors(String text) {
|
||||
for (final ChatColor c : ChatColor.values())
|
||||
text = text.replace("&" + c.getChar(), c.toString());
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use instead: LogUtil.scheduleLogInfo or similar.
|
||||
* @param t
|
||||
*/
|
||||
public static void scheduleOutput(final Throwable t) {
|
||||
scheduleOutput(toString(t));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Use instead: LogUtil.logSevere
|
||||
* @param t
|
||||
*/
|
||||
public static void logSevere(final Throwable t) {
|
||||
LogUtil.logSevere(toString(t));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use instead: LogUtil.toString
|
||||
* @param t
|
||||
* @return
|
||||
*/
|
||||
public static final String toString(final Throwable t){
|
||||
return LogUtil.toString(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Angle of a 2d vector, x being the side at the angle. (radians).
|
||||
@ -336,41 +202,6 @@ public class CheckUtils {
|
||||
return yawDiff;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use instead: LogUtil.logSevere
|
||||
* @param msg
|
||||
*/
|
||||
public static void logSevere(final String msg) {
|
||||
Bukkit.getLogger().severe((msg));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use instead: LogUtil.logWarning
|
||||
* @param msg
|
||||
*/
|
||||
public static void logWarning(final String msg) {
|
||||
Bukkit.getLogger().warning((msg));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use instead: LogUtil.logInfo
|
||||
* @param msg
|
||||
*/
|
||||
public static void logInfo(final String msg) {
|
||||
Bukkit.getLogger().info((msg));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height from getLocation().getY() to head / above head.<br>
|
||||
* NOTE: Currently this is pretty much useless, it returns 1.0 most of the time.
|
||||
* @deprecated This has been moved to MCAccess (compat).
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public static double getHeight(final Entity entity) {
|
||||
return NoCheatPlus.getMCAccess().getHeight(entity);
|
||||
}
|
||||
|
||||
public static void onIllegalMove(final Player player){
|
||||
player.kickPlayer("Illegal move.");
|
||||
LogUtil.logWarning("[NCP] Disconnect " + player.getName() + " due to illegal move!");
|
||||
|
@ -15,6 +15,7 @@ import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.checks.ViolationData;
|
||||
import fr.neatmonster.nocheatplus.checks.access.ICheckData;
|
||||
import fr.neatmonster.nocheatplus.components.TickListener;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
import fr.neatmonster.nocheatplus.metrics.MetricsData;
|
||||
import fr.neatmonster.nocheatplus.players.DataManager;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user