Now we use Maven - plugin description/website added to

plugin.yml - a bit of missing whitespace formatting
This commit is contained in:
Evenprime 2011-11-19 00:41:57 +01:00
parent d502f66472
commit 79d545f5e3
34 changed files with 207 additions and 104 deletions

31
.gitignore vendored Normal file
View File

@ -0,0 +1,31 @@
# Eclipse stuff
/.classpath
/.project
/.settings
# netbeans
/nbproject
# we use maven!
/build.xml
# maven
/target
# vim
.*.sw[a-p]
# various other potential build files
/build
/bin
/dist
/manifest.mf
# Mac filesystem dust
/.DS_Store
# intellij
*.iml
*.ipr
*.iws
.idea/

View File

@ -1,9 +1,12 @@
name: NoCheat
version: ${project.version}
description: ${project.description}
author: Evenprime
website: ${project.url}
main: cc.co.evenprime.bukkit.nocheat.NoCheat
version: 2.16c
commands:
nocheat:

84
pom.xml Normal file
View File

@ -0,0 +1,84 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>NoCheat</groupId>
<artifactId>NoCheat</artifactId>
<version>2.16c</version>
<packaging>jar</packaging>
<name>NoCheat</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<pluginRepositories>
<pluginRepository>
<id>bukkit-plugins</id>
<url>http://repo.bukkit.org/artifactory/plugins-release</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.8.1-R5-SNAPSHOT</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>bukkit-repo</id>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
<url>http://repo.bukkit.org/artifactory/repo</url>
</repository>
</repositories>
<description>Detect and Fight the exploitation of various Flaws/Bugs in Minecraft.</description>
<url>http://dev.bukkit.org/server-mods/nocheat</url>
<scm>
<connection>scm:git:https://github.com/Evenprime/NoCheat.git</connection>
<developerConnection>scm:git:https://github.com/Evenprime/NoCheat.git</developerConnection>
<url>https://github.com/Evenprime/NoCheat</url>
</scm>
<build>
<sourceDirectory>${basedir}/src</sourceDirectory>
<resources>
<resource>
<targetPath>.</targetPath>
<filtering>true</filtering>
<directory>.</directory>
<includes>
<include>plugin.yml</include>
<include>README.txt</include>
<include>LICENSE.txt</include>
</includes>
</resource>
</resources>
<defaultGoal>clean install</defaultGoal>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.1</version>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
<finalName>NoCheat</finalName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@ -8,7 +8,7 @@ import cc.co.evenprime.bukkit.nocheat.data.BaseData;
public interface NoCheatPlayer {
public boolean hasPermission(String permission);
public String getName();
public Player getPlayer();
@ -16,11 +16,11 @@ public interface NoCheatPlayer {
public BaseData getData();
public boolean isSprinting();
public int getTicksLived();
public void increaseAge(int ticks);
public ConfigurationCache getConfiguration();
public float getSpeedAmplifier();

View File

@ -1,6 +1,5 @@
package cc.co.evenprime.bukkit.nocheat.checks;
import cc.co.evenprime.bukkit.nocheat.NoCheat;
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
import cc.co.evenprime.bukkit.nocheat.actions.types.ActionWithParameters.WildCard;

View File

@ -82,7 +82,7 @@ public class DirectionCheck extends BlockBreakCheck {
switch (wildcard) {
case VIOLATIONS:
return String.format(Locale.US, "%d", (int)player.getData().blockbreak.directionVL);
return String.format(Locale.US, "%d", (int) player.getData().blockbreak.directionVL);
default:
return super.getParameter(wildcard, player);

View File

@ -36,13 +36,13 @@ public class NoswingCheck extends BlockBreakCheck {
public boolean isEnabled(CCBlockBreak cc) {
return cc.noswingCheck;
}
public String getParameter(WildCard wildcard, NoCheatPlayer player) {
switch (wildcard) {
case VIOLATIONS:
return String.format(Locale.US, "%d", (int)player.getData().blockbreak.noswingVL);
return String.format(Locale.US, "%d", (int) player.getData().blockbreak.noswingVL);
default:
return super.getParameter(wildcard, player);

View File

@ -55,7 +55,7 @@ public class ReachCheck extends BlockBreakCheck {
switch (wildcard) {
case VIOLATIONS:
return String.format(Locale.US, "%d", (int)player.getData().blockbreak.reachVL);
return String.format(Locale.US, "%d", (int) player.getData().blockbreak.reachVL);
case REACHDISTANCE:
return String.format(Locale.US, "%.2f", player.getData().blockbreak.reachDistance);

View File

@ -96,7 +96,7 @@ public class DirectionCheck extends BlockPlaceCheck {
switch (wildcard) {
case VIOLATIONS:
return String.format(Locale.US, "%d", (int)player.getData().blockplace.directionVL);
return String.format(Locale.US, "%d", (int) player.getData().blockplace.directionVL);
default:
return super.getParameter(wildcard, player);

View File

@ -56,7 +56,7 @@ public class ReachCheck extends BlockPlaceCheck {
switch (wildcard) {
case VIOLATIONS:
return String.format(Locale.US, "%d", (int)player.getData().blockplace.reachVL);
return String.format(Locale.US, "%d", (int) player.getData().blockplace.reachVL);
case REACHDISTANCE:
return String.format(Locale.US, "%.2f", player.getData().blockplace.reachdistance);

View File

@ -77,7 +77,7 @@ public class DirectionCheck extends FightCheck {
switch (wildcard) {
case VIOLATIONS:
return String.format(Locale.US, "%d", (int)player.getData().fight.directionVL);
return String.format(Locale.US, "%d", (int) player.getData().fight.directionVL);
default:
return super.getParameter(wildcard, player);
}

View File

@ -19,7 +19,7 @@ public class NoswingCheck extends FightCheck {
public boolean check(NoCheatPlayer player, FightData data, CCFight cc) {
boolean cancel = false;
// did he swing his arm before?
if(data.armswung) {
data.armswung = false;
@ -37,13 +37,13 @@ public class NoswingCheck extends FightCheck {
public boolean isEnabled(CCFight cc) {
return cc.noswingCheck;
}
public String getParameter(WildCard wildcard, NoCheatPlayer player) {
switch (wildcard) {
case VIOLATIONS:
return String.format(Locale.US, "%d", (int)player.getData().fight.noswingVL);
return String.format(Locale.US, "%d", (int) player.getData().fight.noswingVL);
default:
return super.getParameter(wildcard, player);
}

View File

@ -42,7 +42,7 @@ public class SelfhitCheck extends FightCheck {
switch (wildcard) {
case VIOLATIONS:
return String.format(Locale.US, "%d", (int)player.getData().fight.selfhitVL);
return String.format(Locale.US, "%d", (int) player.getData().fight.selfhitVL);
default:
return super.getParameter(wildcard, player);
}

View File

@ -47,10 +47,9 @@ public class FlyingCheck extends MovingCheck {
// In case of creative gamemode, give at least 0.60 speed limit
// horizontal
double speedLimitHorizontal = player.isCreative() ? Math.max(creativeSpeed, ccmoving.flyingSpeedLimitHorizontal) : ccmoving.flyingSpeedLimitHorizontal;
speedLimitHorizontal *= player.getSpeedAmplifier();
result += Math.max(0.0D, horizontalDistance - moving.horizFreedom - speedLimitHorizontal);
boolean sprinting = player.isSprinting();
@ -99,13 +98,13 @@ public class FlyingCheck extends MovingCheck {
public boolean isEnabled(CCMoving moving) {
return moving.allowFlying && moving.runflyCheck;
}
public String getParameter(WildCard wildcard, NoCheatPlayer player) {
switch (wildcard) {
case VIOLATIONS:
return String.format(Locale.US, "%d", (int)player.getData().moving.runflyVL);
return String.format(Locale.US, "%d", (int) player.getData().moving.runflyVL);
default:
return super.getParameter(wildcard, player);
}

View File

@ -74,7 +74,7 @@ public class MorePacketsCheck extends MovingCheck {
// went over the limit
if(!plugin.skipCheck() && packetsAboveLimit > 0) {
data.morePacketsVL += packetsAboveLimit;
data.packets = packetsAboveLimit;
final boolean cancel = executeActions(player, cc.morePacketsActions.getActions(data.morePacketsVL));
@ -103,13 +103,13 @@ public class MorePacketsCheck extends MovingCheck {
public boolean isEnabled(CCMoving moving) {
return moving.morePacketsCheck;
}
@Override
public String getParameter(WildCard wildcard, NoCheatPlayer player) {
switch (wildcard) {
case VIOLATIONS:
return String.format(Locale.US, "%d", (int)player.getData().moving.morePacketsVL);
return String.format(Locale.US, "%d", (int) player.getData().moving.morePacketsVL);
case PACKETS:
return String.valueOf(player.getData().moving.packets);
default:

View File

@ -106,7 +106,7 @@ public class NoFallCheck extends MovingCheck {
switch (wildcard) {
case VIOLATIONS:
return String.format(Locale.US, "%d", (int)player.getData().moving.nofallVL);
return String.format(Locale.US, "%d", (int) player.getData().moving.nofallVL);
case FALLDISTANCE:
return String.format(Locale.US, "%.2f", player.getData().moving.fallDistance);
default:

View File

@ -37,7 +37,7 @@ public class GodmodeCheck extends TimedCheck {
boolean cancel = false;
// How far behind is the player with his ticks
int behind = Math.min(10, (data.ticksLived + cc.tickTime) - ticksLived);
int behind = Math.min(10, (data.ticksLived + cc.tickTime) - ticksLived);
// difference should be >= tickTime for perfect synchronization
if(behind <= 1) {
// player as fast as expected, give him credit for that
@ -45,7 +45,7 @@ public class GodmodeCheck extends TimedCheck {
// Reduce violation level over time
data.godmodeVL -= cc.tickTime / 2.0;
} else if(behind <= (cc.tickTime / 2)+1) {
} else if(behind <= (cc.tickTime / 2) + 1) {
// close enough, let it pass
data.ticksBehind -= cc.tickTime / 4;
// Reduce violation level over time
@ -63,16 +63,14 @@ public class GodmodeCheck extends TimedCheck {
cancel = executeActions(player, cc.godmodeActions.getActions(data.godmodeVL));
if(cancel) {
// Catch up for at least some of the ticks
try {
player.increaseAge(cc.tickTime);
}
catch(Exception e) {
} catch(Exception e) {
e.printStackTrace();
}
// Reduce the time the player is behind accordingly
data.ticksBehind -= cc.tickTime;
}
@ -82,7 +80,7 @@ public class GodmodeCheck extends TimedCheck {
if(data.ticksBehind < 0) {
data.ticksBehind = 0;
}
if(data.godmodeVL < 0) {
data.godmodeVL = 0;
}
@ -104,7 +102,7 @@ public class GodmodeCheck extends TimedCheck {
switch (wildcard) {
case VIOLATIONS:
return String.format(Locale.US, "%d", (int)player.getData().timed.godmodeVL);
return String.format(Locale.US, "%d", (int) player.getData().timed.godmodeVL);
default:
return super.getParameter(wildcard, player);
}

View File

@ -31,7 +31,7 @@ public abstract class Configuration {
private final static OptionNode DEBUG = new OptionNode("debug", ROOT, DataType.PARENT);
public final static OptionNode DEBUG_SHOWACTIVECHECKS = new OptionNode("showactivechecks", DEBUG, DataType.BOOLEAN);
public static final OptionNode DEBUG_COMPATIBILITY = new OptionNode("compatibility", DEBUG, DataType.BOOLEAN);
private final static OptionNode MOVING = new OptionNode("moving", ROOT, DataType.PARENT);
public final static OptionNode MOVING_CHECK = new OptionNode("check", MOVING, DataType.BOOLEAN);
public final static OptionNode MOVING_IDENTIFYCREATIVEMODE = new OptionNode("identifycreativemode", MOVING, DataType.BOOLEAN);

View File

@ -48,7 +48,7 @@ public class FlatFileAction {
} catch(IOException e) {
e.printStackTrace();
}
for(Action a : actions) {
mapper.addAction(a);
}
@ -62,50 +62,45 @@ public class FlatFileAction {
// four pieces is the minimum we need, no matter what it is
if(parts.length < 4) {
throw new IllegalArgumentException("The line "+line+" of the file "+file.getName()+" is malformed. It has not enough parts.");
throw new IllegalArgumentException("The line " + line + " of the file " + file.getName() + " is malformed. It has not enough parts.");
}
String type = parts[0];
String name = parts[1];
int delay = 0;
try {
delay = Integer.parseInt(parts[2]);
} catch(Exception e) {
throw new IllegalArgumentException("Couldn't parse third parameter of action " + name + " from file " + file.getName() + ". It is " + parts[2] + " but should be a number.");
}
catch(Exception e) {
throw new IllegalArgumentException("Couldn't parse third parameter of action "+name+" from file "+file.getName()+". It is "+parts[2]+" but should be a number.");
}
int repeat = 0;
try {
repeat = Integer.parseInt(parts[3]);
} catch(Exception e) {
throw new IllegalArgumentException("Couldn't parse fourth parameter of action " + name + " from file " + file.getName() + ". It is " + parts[2] + " but should be a number.");
}
catch(Exception e) {
throw new IllegalArgumentException("Couldn't parse fourth parameter of action "+name+" from file "+file.getName()+". It is "+parts[2]+" but should be a number.");
}
if(type.equalsIgnoreCase("log")) {
// A log action, it seems
if(parts.length < 5) {
throw new IllegalArgumentException("Missing fifth parameter of action "+name+" from file "+file.getName()+".");
throw new IllegalArgumentException("Missing fifth parameter of action " + name + " from file " + file.getName() + ".");
}
return readLogAction(name, delay, repeat, parts[4]);
}
else if(type.equalsIgnoreCase("consolecommand")) {
} else if(type.equalsIgnoreCase("consolecommand")) {
// A consolecommand action, it seems
if(parts.length < 5) {
throw new IllegalArgumentException("Missing fifth parameter of action "+name+" from file "+file.getName()+".");
throw new IllegalArgumentException("Missing fifth parameter of action " + name + " from file " + file.getName() + ".");
}
return new ConsolecommandAction(name, delay, repeat, parts[4]);
}
else if(type.equalsIgnoreCase("special")) {
} else if(type.equalsIgnoreCase("special")) {
// A "special" actions, it seems
return new SpecialAction(name, delay, repeat);
}
else {
throw new IllegalArgumentException("Unknown action type "+type+ " of action with name "+name+".");
} else {
throw new IllegalArgumentException("Unknown action type " + type + " of action with name " + name + ".");
}
}
@ -113,19 +108,18 @@ public class FlatFileAction {
private Action readLogAction(String name, int delay, int repeat, String lastPart) {
String[] rest = lastPart.split("\\s+", 2);
if(rest.length < 2) {
throw new IllegalArgumentException("Missing sixth parameter of action "+name+" from file "+file.getName()+".");
throw new IllegalArgumentException("Missing sixth parameter of action " + name + " from file " + file.getName() + ".");
}
LogLevel level;
try {
level = LogLevel.getLogLevelFromString(rest[0]);
} catch(IllegalArgumentException e) {
throw new IllegalArgumentException("Illegal fifth parameter of action " + name + ". " + e.getMessage());
}
catch(IllegalArgumentException e) {
throw new IllegalArgumentException("Illegal fifth parameter of action "+name+". "+e.getMessage());
}
return new LogAction(name, delay, repeat, level, rest[1]);
}

View File

@ -6,7 +6,6 @@ public class CCDebug {
public final boolean showchecks;
public final boolean overrideIdiocy;
public CCDebug(Configuration data) {

View File

@ -38,12 +38,12 @@ public class CCMoving {
check = data.getBoolean(Configuration.MOVING_CHECK);
identifyCreativeMode = data.getBoolean(Configuration.MOVING_IDENTIFYCREATIVEMODE);
runflyCheck = data.getBoolean(Configuration.MOVING_RUNFLY_CHECK);
walkingSpeedLimit = ((double) data.getInteger(Configuration.MOVING_RUNFLY_WALKINGSPEEDLIMIT)) / 100D;
sprintingSpeedLimit = ((double) data.getInteger(Configuration.MOVING_RUNFLY_SPRINTINGSPEEDLIMIT)) / 100D;
jumpheight = ((double) data.getInteger(Configuration.MOVING_RUNFLY_JUMPHEIGHT)) / 100D;
actions = data.getActionList(Configuration.MOVING_RUNFLY_ACTIONS);
actions = data.getActionList(Configuration.MOVING_RUNFLY_ACTIONS);
swimmingCheck = data.getBoolean(Configuration.MOVING_RUNFLY_CHECKSWIMMING);
swimmingSpeedLimit = ((double) data.getInteger(Configuration.MOVING_RUNFLY_SWIMMINGSPEEDLIMIT)) / 100D;

View File

@ -17,7 +17,7 @@ public class BlockBreakData extends Data {
public double noswingVL = 0.0D;
public double reachDistance;
public boolean armswung = true;
@Override
public void clearCriticalData() {
instaBrokenBlockLocation.reset();

View File

@ -68,7 +68,7 @@ public class PlayerManager {
public void cleanDataMap() {
long time = System.currentTimeMillis();
List<String> removals = new ArrayList<String>(5);
for(Entry<String, NoCheatPlayerImpl> e : this.players.entrySet()) {
if(e.getValue().shouldBeRemoved(time)) {
removals.add(e.getKey());

View File

@ -3,9 +3,10 @@ package cc.co.evenprime.bukkit.nocheat.data;
import org.bukkit.Location;
/**
* A class to store x,y,z triple data, instead of using bukkits Location objects,
* A class to store x,y,z triple data, instead of using bukkits Location
* objects,
* which can't be easily recycled
*
*
*/
public final class PreciseLocation {
@ -32,6 +33,7 @@ public final class PreciseLocation {
public final boolean isSet() {
return x != Double.MAX_VALUE;
}
public final void reset() {
x = Double.MAX_VALUE;
y = Double.MAX_VALUE;

View File

@ -9,11 +9,10 @@ import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
import cc.co.evenprime.bukkit.nocheat.events.EventManager;
import cc.co.evenprime.bukkit.nocheat.log.LogLevel;
public class ActiveCheckPrinter {
public static void printActiveChecks(NoCheat plugin, List<EventManager> eventManagers) {
boolean introPrinted = false;
String intro = "[NoCheat] Active Checks: ";

View File

@ -1,46 +1,43 @@
package cc.co.evenprime.bukkit.nocheat.debug;
public class Performance {
private long totalTime = 0;
private long counter = 1; // start with 1 to avoid DIV/0 errors
private final boolean enabled;
private static final long NANO = 1;
private static final long MICRO = NANO * 1000;
private static final long MILLI = MICRO * 1000;
private static final long SECOND = MILLI * 1000;
private static final long MINUTE = SECOND * 60;
private long totalTime = 0;
private long counter = 1; // start with 1 to avoid
// DIV/0 errors
private final boolean enabled;
private static final long NANO = 1;
private static final long MICRO = NANO * 1000;
private static final long MILLI = MICRO * 1000;
private static final long SECOND = MILLI * 1000;
private static final long MINUTE = SECOND * 60;
public Performance(boolean enabled) {
this.enabled = enabled;
}
public void addTime(long nanoTime) {
counter++;
this.totalTime += nanoTime;
}
public long getTotalTime() {
return this.totalTime;
}
public long getRelativeTime() {
return this.totalTime / this.counter;
}
public long getCounter() {
return this.counter;
}
public boolean isEnabled() {
return enabled;
}
private static String getAppropriateUnit(long timeInNanoseconds) {
// more than 10 minutes
@ -83,7 +80,7 @@ public class Performance {
return timeInNanoseconds / NANO;
}
}
public static String toString(long timeInNanoseconds) {
return convertToAppropriateUnit(timeInNanoseconds) + " " + getAppropriateUnit(timeInNanoseconds);
}

View File

@ -9,8 +9,6 @@ public class PerformanceManager {
BLOCKBREAK, BLOCKDAMAGE, BLOCKPLACE, CHAT, MOVING, VELOCITY, FIGHT, TIMED
}
private final Map<Type, Performance> map;
public PerformanceManager() {

View File

@ -87,7 +87,7 @@ public class BlockBreakEventManager extends EventManager {
// direction check that are insta-breaks
data.instaBrokenBlockLocation.set(event.getBlock());
}
@Override
protected void handlePlayerAnimationEvent(final PlayerAnimationEvent event, final Priority priority) {
plugin.getPlayer(event.getPlayer()).getData().blockbreak.armswung = true;

View File

@ -46,7 +46,7 @@ public class ChatEventManager extends EventManager {
final NoCheatPlayer player = plugin.getPlayer(event.getPlayer());
final CCChat cc = player.getConfiguration().chat;
if(!cc.check || player.hasPermission(Permissions.CHAT)) {
return;
}

View File

@ -225,7 +225,7 @@ public abstract class EventManager {
m.handlePlayerAnimationEvent(event, priority);
}
}
@Override
public void onPlayerToggleSprint(final PlayerToggleSprintEvent event) {
if(ignoreCancelledEvents && event.isCancelled())

View File

@ -70,7 +70,7 @@ public class FightEventManager extends EventManager {
if(cancelled)
event.setCancelled(cancelled);
}
@Override
protected void handlePlayerAnimationEvent(final PlayerAnimationEvent event, final Priority priority) {
plugin.getPlayer(event.getPlayer()).getData().fight.armswung = true;

View File

@ -89,7 +89,7 @@ public class MovingEventManager extends EventManager {
if(event.getPlayer().isInsideVehicle()) {
return;
}
// Get the world-specific configuration that applies here
final NoCheatPlayer player = plugin.getPlayer(event.getPlayer());
final CCMoving cc = player.getConfiguration().moving;

View File

@ -80,7 +80,7 @@ public class TimedEventManager extends EventManager {
if(performanceCheck)
nanoTimeStart = System.nanoTime();
handleEvent(plugin.getPlayer((Player)p.getBukkitEntity()));
handleEvent(plugin.getPlayer((Player) p.getBukkitEntity()));
// store performance time
if(performanceCheck)

View File

@ -4,16 +4,16 @@ import org.bukkit.ChatColor;
/**
* Somehow manage color codes in NoCheat
*
*
*/
public class Colors {
public static String replaceColors(String text) {
for(ChatColor c : ChatColor.values()) {
text = text.replace("&" + Integer.toHexString(c.getCode()), c.toString());
}
return text;
}
}