mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-19 05:51:29 +01:00
+ [API] Added a real API ("events-based") allowing to cancel checks
+ [General] Added more tolerance when checking player's permissions + [Running] Added a speed limit when climbing into water/lava = [General] Fixed an issue when getting a check's parameters = [MorePacketsVehicle] Fixed an issue when destroying Minecarts = [NoPwnage] Fixed the NoPwnage not kicking the players correctly = [Running] Fixed an issue occurring when falling on ladders - [Running] Removed the "velocity-changed-by-plugins" detection
This commit is contained in:
parent
e48069e73f
commit
c03cfc1a1f
588
Instructions.txt
588
Instructions.txt
@ -418,7 +418,6 @@
|
|||||||
Especially you don't have to and should not use ".*" anywhere when defining
|
Especially you don't have to and should not use ".*" anywhere when defining
|
||||||
NoCheatPlus permissions.
|
NoCheatPlus permissions.
|
||||||
|
|
||||||
|
|
||||||
You can exclude a specific player from getting logged by appending ".silent"
|
You can exclude a specific player from getting logged by appending ".silent"
|
||||||
to the relevant permission node of the specific check. E.g.
|
to the relevant permission node of the specific check. E.g.
|
||||||
|
|
||||||
@ -482,12 +481,6 @@
|
|||||||
seen by players with the permission node "nocheatplus.admin.chatlog" or if
|
seen by players with the permission node "nocheatplus.admin.chatlog" or if
|
||||||
you don't use a permissions plugin, by players who are OP.
|
you don't use a permissions plugin, by players who are OP.
|
||||||
|
|
||||||
showactivechecks:
|
|
||||||
|
|
||||||
Should NoCheatPlus display lists of checks that are enabled for each world.
|
|
||||||
Set to true if you are unsure that your (multiworld) setup of the config
|
|
||||||
files is done correctly.
|
|
||||||
|
|
||||||
debugmessages:
|
debugmessages:
|
||||||
|
|
||||||
Should some additional messages be displayed in the server console, e.g.
|
Should some additional messages be displayed in the server console, e.g.
|
||||||
@ -526,289 +519,6 @@
|
|||||||
what happens if somebody fails checks.
|
what happens if somebody fails checks.
|
||||||
|
|
||||||
|
|
||||||
----------------------------- INVENTORY Subsection -----------------------------
|
|
||||||
|
|
||||||
Checks that at least technically have to do with the inventory or usage of
|
|
||||||
items can be found here.
|
|
||||||
|
|
||||||
1) DROP:
|
|
||||||
|
|
||||||
The "inventory.drop" check. It limits how many separate items a player can
|
|
||||||
drop onto the ground within a specific time. Dropping a lot of separate
|
|
||||||
items at once can cause lag on the server, therefore this check exists.
|
|
||||||
|
|
||||||
active:
|
|
||||||
Should the check be enabled. Set to false if you are not interested in
|
|
||||||
this at all.
|
|
||||||
|
|
||||||
time:
|
|
||||||
Over how many seconds should dropped items be counted, before the
|
|
||||||
counter gets reset and starts at zero again.
|
|
||||||
|
|
||||||
limit:
|
|
||||||
How many items may be dropped in the timeframe that is specified by
|
|
||||||
the "time" setting. Please consider that dying causes a player to drop
|
|
||||||
up to 36 separate items (stacks). Therefore this value shouldn't be
|
|
||||||
set below ~50.
|
|
||||||
|
|
||||||
actions:
|
|
||||||
What should happen when a player goes beyond the set limit. Default
|
|
||||||
settings log a message and kick the player from the server. The VL of
|
|
||||||
the drop check symbolizes how many items a player dropped beyond the
|
|
||||||
set limit. If the limit is 100 and he tried to drop 130, he will have a
|
|
||||||
Violation Level of 130 - 100 = 30.
|
|
||||||
|
|
||||||
2) INSTANTBOW:
|
|
||||||
|
|
||||||
Players may attack extremely fast and with a fully charged bow without
|
|
||||||
waiting for it to be fully pulled back. This is a significant advantage in
|
|
||||||
PvP and PvE combat.
|
|
||||||
|
|
||||||
active:
|
|
||||||
Should players be checked for this behavior. Set to false if you don't
|
|
||||||
care about players using bows faster than normally possible.
|
|
||||||
|
|
||||||
actions:
|
|
||||||
What should happen if the player fails this check. Default is to stop
|
|
||||||
the attack ("cancel" it) and log messages. The Violation Level (VL) for
|
|
||||||
this check the time difference between how long it took the player to
|
|
||||||
fire an arrow and how long NoCheatPlus thinks he should have taken, in
|
|
||||||
1/10 seconds. Therefore a VL of 10 would mean that the player shot an
|
|
||||||
arrow 1 second faster than NoCheatPlus expected. The VL gets increased
|
|
||||||
with every failed check and slowly decreased for every passed check.
|
|
||||||
|
|
||||||
3) INSTANTEAT:
|
|
||||||
|
|
||||||
Players may eat various kinds of food instantly instead of waiting the
|
|
||||||
usual time munching on the item.
|
|
||||||
|
|
||||||
active:
|
|
||||||
Should players be checked for this behavior. Set to false if you don't
|
|
||||||
care about players eating their food faster than normally possible.
|
|
||||||
|
|
||||||
actions:
|
|
||||||
What should happen if the player fails this check. Default is to stop
|
|
||||||
the eating ("cancel" it) and log messages. The Violation Level (VL) for
|
|
||||||
this check the time difference between how long it took the player to
|
|
||||||
eat his food and how long NoCheatPlus thinks he should have taken, in
|
|
||||||
1/10 seconds. Therefore a VL of 10 would mean that the player ate his
|
|
||||||
food 1 second faster than NoCheatPlus expected. The VL gets increased
|
|
||||||
with every failed check and slowly decreased for every passed check.
|
|
||||||
|
|
||||||
|
|
||||||
------------------------------ MOVING Subsection -------------------------------
|
|
||||||
|
|
||||||
Checks that at least technically have to do with the player moving around or
|
|
||||||
impacting the world with his movement can be found here.
|
|
||||||
|
|
||||||
1) RUNFLY:
|
|
||||||
|
|
||||||
Players may move in illegal ways (flying, running too fast) or try to
|
|
||||||
trick the server into thinking that they are not falling/flying by
|
|
||||||
cleverly manipulating the data that they send to the server.
|
|
||||||
|
|
||||||
active:
|
|
||||||
Should players get checked for this type of movement related hacks at
|
|
||||||
all. If deactivated, player may freely move around on the server, fly
|
|
||||||
or run really fast.
|
|
||||||
|
|
||||||
walkspeed:
|
|
||||||
How fast should the player be allowed to walk. Default is "100",
|
|
||||||
meaning 100% of normal walking speed. You will not see this option in
|
|
||||||
your config.yml file, because normally you shouldn't have to change the
|
|
||||||
walking speed of players at all (NoCheatPlus knows when players sprint,
|
|
||||||
use Swiftness potions etc and will already adapt the speed based on that
|
|
||||||
data).
|
|
||||||
|
|
||||||
sneakspeed:
|
|
||||||
How fast should the player be allowed to sneak. Default is "100",
|
|
||||||
meaning 100% of normal sneaking speed. You will not see this option in
|
|
||||||
your config.yml file, because normally you shouldn't have to change the
|
|
||||||
sneaking speed of players at all (NoCheatPlus knows when players sprint,
|
|
||||||
use Swiftness potions etc and will already adapt the speed based on
|
|
||||||
that data).
|
|
||||||
|
|
||||||
blockspeed:
|
|
||||||
How fast should the player be allowed to move while blocking. Default is
|
|
||||||
"100" meaning 100% of normal blocking speed. You will not see this
|
|
||||||
option in your config.yml file, because normally you shouldn't have to
|
|
||||||
change the blocking speed of player at all (NoCheatPlus knows when
|
|
||||||
players block, use Swiftness potions etc and will already adapt the
|
|
||||||
speed based on that data).
|
|
||||||
|
|
||||||
swimspeed:
|
|
||||||
How fast should the player be allowed to swim. Default is "100",
|
|
||||||
meaning 100% of normal swimming speed. You will not see this option in
|
|
||||||
your config.yml file, because normally you shouldn't have to change the
|
|
||||||
swimming speed of players at all (NoCheatPlus knows when players sprint,
|
|
||||||
use Swiftness potions etc and will already adapt the speed based on
|
|
||||||
that data).
|
|
||||||
|
|
||||||
sprintspeed:
|
|
||||||
How fast should the player be allowed to sprint. Default is "100",
|
|
||||||
meaning 100% of normal sprinting speed. You will not see this option in
|
|
||||||
your config.yml file, because normally you shouldn't have to change the
|
|
||||||
sprinting speed of players at all (NoCheatPlus knows when players
|
|
||||||
sprint, use Swiftness potions etc and will already adapt the speed based
|
|
||||||
on that data).
|
|
||||||
|
|
||||||
cobwebspeed:
|
|
||||||
How fast should the player be allowed to move while being into cobweb.
|
|
||||||
Default is "100" meaning 100% of normal speed while being into cobweb.
|
|
||||||
You will not see this option in your config.yml file, because normally
|
|
||||||
you shouldn't have to change the speed while being into cobweb of
|
|
||||||
players at all (NoCheatPlus knows when players are in cobweb, use
|
|
||||||
Swiftness potions etc and will already adapt the speed based on that
|
|
||||||
data).
|
|
||||||
|
|
||||||
maxcooldown:
|
|
||||||
How much time the player can spend in the air if his velocity has been
|
|
||||||
modified by an external plugin (PreciousStones for example). The default
|
|
||||||
delay is 10 seconds because it sounds like a player won't spend more
|
|
||||||
than 10 seconds in the air.
|
|
||||||
|
|
||||||
allowfastsneaking:
|
|
||||||
Should sneaking players be allowed to move as fast as normal players.
|
|
||||||
Set this to true, if you use plugins that enable players to do that
|
|
||||||
(e.g. the "Heroes" plugin or other RPG plugins tend to do that)
|
|
||||||
|
|
||||||
allowfastblock:
|
|
||||||
Should players blocking be allowed to move as fast as normal players.
|
|
||||||
Set this to true if you use plugins that enable players to do that.
|
|
||||||
|
|
||||||
actions:
|
|
||||||
What should happen when a player sneaks/swims/walks/runs faster than
|
|
||||||
normally allowed or is flying. Default is to log messages (depending on
|
|
||||||
how severe the cheating is) and teleport the player to the last known
|
|
||||||
legitimate location on ground that NoCheatPlus can remember for that
|
|
||||||
player ("cancel" the movement).
|
|
||||||
|
|
||||||
checknofall:
|
|
||||||
Should players be checked for a common type of "nofall" hack, that
|
|
||||||
allows them to avoid taking damage when falling. If you don't care
|
|
||||||
about fall damage, you can deactivate this. It gets deactivated if a
|
|
||||||
player is allowed to fly (see some lines below), because it doesn't
|
|
||||||
make sense to allow flying and then hurt players when they land.
|
|
||||||
|
|
||||||
nofallaggressivemode:
|
|
||||||
Enable an improved version of nofall check, that will catch additional
|
|
||||||
types of "nofall" hacks and deal damage to players directly. This is
|
|
||||||
usually safe to activate. It will only work if the "checknofall" is
|
|
||||||
also set to "true".
|
|
||||||
|
|
||||||
nofallactions:
|
|
||||||
What should happen if a player is considered to be using a "nofall"
|
|
||||||
hack. Default reaction is to log a message and encourage Bukkit to deal
|
|
||||||
fall damage anyway ("cancel" the hack). The Violation Level is the
|
|
||||||
fall distance in blocks that the player tried to avoid. It gets
|
|
||||||
increased every time that the player fails the check, and decreased
|
|
||||||
over time if the player doesn't fail the check.
|
|
||||||
|
|
||||||
FLYING:
|
|
||||||
This is an entire subsection dedicated to the "moving.flying" check.
|
|
||||||
It will be used instead of the "runfly" check whenever a player has
|
|
||||||
the right to fly.
|
|
||||||
|
|
||||||
allowflyingalways:
|
|
||||||
Should all players be allowed to fly always.
|
|
||||||
|
|
||||||
allowflyingincreative:
|
|
||||||
Should players that are set to "creative mode" be allowed to fly. If
|
|
||||||
they are already allowed because of "allowflyingalways" to fly, this
|
|
||||||
setting gets ignored.
|
|
||||||
|
|
||||||
flyingspeedlimithorizontal:
|
|
||||||
How many 1/100 blocks may a player fly horizontal within one "step".
|
|
||||||
The official "creative mode" flying reaches speeds of about 0.6
|
|
||||||
blocks which means a value of 60 here.
|
|
||||||
|
|
||||||
flyingspeedlimitvertical:
|
|
||||||
How many 1/100 blocks may a player fly vertically up within one
|
|
||||||
"step". A value of 100 which means 1 block seems reasonable for most
|
|
||||||
cases.
|
|
||||||
|
|
||||||
flyingheightlimit:
|
|
||||||
What is the maximum height (in blocks) that a player may reach by
|
|
||||||
flying, relative to the max world height he is in. Some servers
|
|
||||||
experience lag when players fly very, very high. This value is how
|
|
||||||
far above the map height a player may fly.
|
|
||||||
|
|
||||||
actions:
|
|
||||||
What should happen if a player flies faster/higher than defined here?
|
|
||||||
Default is to log messages and to prevent the player from moving
|
|
||||||
("cancel" his last movement). The Violation Level (VL) of this check
|
|
||||||
is the distance that the player went beyond what NoCheatPlus allowed
|
|
||||||
him. The VL increases with every failed check and slowly decreases for
|
|
||||||
every passed check.
|
|
||||||
|
|
||||||
2) MOREPACKETS:
|
|
||||||
|
|
||||||
The morepackets check is complementary to the "runfly" check. While the
|
|
||||||
"runfly" check(s) limit the distance a player can move per step, this
|
|
||||||
"morepackets" check limits the number of "steps" a player may take per
|
|
||||||
second. A normal value is 20 steps per second.
|
|
||||||
|
|
||||||
active:
|
|
||||||
Should players be checked for this kind of cheating. If you are not
|
|
||||||
interested in players that cheat that way, set this to false. It is a
|
|
||||||
good idea to have this active, because players that cheat by sending
|
|
||||||
more packets than normally allowed may lag the server (each of those
|
|
||||||
packets has to be processed, after all).
|
|
||||||
|
|
||||||
actions:
|
|
||||||
What should happen if a player is considered to be cheating by taking
|
|
||||||
more steps per second than normal. Default is to log messages and
|
|
||||||
teleport the player back to a location where he was ~1 second before
|
|
||||||
("cancel" his movement). The Violation Level VL is the number of
|
|
||||||
packets that the player sent beyond the expected amount.
|
|
||||||
|
|
||||||
3) MOREPACKETSVEHICULE:
|
|
||||||
|
|
||||||
The morepacketsvehicule check is complementary to the "morepackets" check.
|
|
||||||
While the "morepacket" check limit the number of player-move packets send
|
|
||||||
per second, this "morepacketsvehicle" limit the number of vehicule-move
|
|
||||||
packets sent per second. A normal value is 20 packets per second.
|
|
||||||
|
|
||||||
active:
|
|
||||||
Should players be checked for this kind of cheating. If you are not
|
|
||||||
interested in players that cheat that way, set this to false. It is a
|
|
||||||
good idea to have this active, because players that cheat by sending
|
|
||||||
more packets than normally allowed may lag the server (each of those
|
|
||||||
packets has to be processed, after all).
|
|
||||||
|
|
||||||
actions:
|
|
||||||
What should happen if a player is considered to be cheating by taking
|
|
||||||
more steps per second than normal. Default is to log messages and break
|
|
||||||
the boat the player is using. The Violation Level VL is the number of
|
|
||||||
packets that the player sent beyond the expected amount.
|
|
||||||
|
|
||||||
4) WATERWALK:
|
|
||||||
|
|
||||||
The waterwalk check is used to prevent players from walking on water using
|
|
||||||
a client dedicated to griefing (this mode is usually called Jesus mod).
|
|
||||||
Firstly, it'll check if the player's move is valid (not only moving the X
|
|
||||||
and Z axes but also on the Y axis and, of course, if the player is near the
|
|
||||||
surface (most of the griefing client set the player 0.3 blocks under the
|
|
||||||
water surface). Secondly, it'll make sure the player is using the borders
|
|
||||||
of the block to climb outside the water (it prevents players using griefing
|
|
||||||
clients to simply jump multiple times over the water).
|
|
||||||
|
|
||||||
active:
|
|
||||||
Should players be checked for this kind of cheating. If you are not
|
|
||||||
interested in players that cheat that way, set this to false. It is a
|
|
||||||
good idea to have this active, because players won't be able to cross
|
|
||||||
easily the oceans.
|
|
||||||
|
|
||||||
actions:
|
|
||||||
What should happen if a player is considered to be cheating by walking
|
|
||||||
on water. Default is to log messages and to prevent the player from
|
|
||||||
moving ("cancel" his last movement). The Violation Level (VL) of this
|
|
||||||
check is the distance between the player and the surface or how far away
|
|
||||||
he is from the normal position if a player climbing a block. The VL
|
|
||||||
increases with every failed check and slowly decreases for every passed
|
|
||||||
check.
|
|
||||||
|
|
||||||
|
|
||||||
---------------------------- BLOCKBREAK Subsection -----------------------------
|
---------------------------- BLOCKBREAK Subsection -----------------------------
|
||||||
|
|
||||||
Checks that at least technically have to do with the player breaking blocks.
|
Checks that at least technically have to do with the player breaking blocks.
|
||||||
@ -1098,6 +808,10 @@
|
|||||||
"warnings" times already, the "commands" will be executed for him.
|
"warnings" times already, the "commands" will be executed for him.
|
||||||
Warnings get removed if the time of the last warning was more than
|
Warnings get removed if the time of the last warning was more than
|
||||||
"timeout" ms ago.
|
"timeout" ms ago.
|
||||||
|
|
||||||
|
kickmessage:
|
||||||
|
The message that will be displayed to the player is he is kicked by the
|
||||||
|
NoPwnage check.
|
||||||
|
|
||||||
actions:
|
actions:
|
||||||
NoPwnage allows you to decide what should happen when a player reaches
|
NoPwnage allows you to decide what should happen when a player reaches
|
||||||
@ -1107,6 +821,10 @@
|
|||||||
|
|
||||||
"[player]" and "[ip]" wildcards will be replaced by the actual data
|
"[player]" and "[ip]" wildcards will be replaced by the actual data
|
||||||
during execution.
|
during execution.
|
||||||
|
|
||||||
|
IMPORTANT: Please notice that cancelling the check will not cancel the
|
||||||
|
actual message but kick the player (and the kick message defined in the
|
||||||
|
configuration will displayed on the player's screen).
|
||||||
|
|
||||||
captcha.enabled:
|
captcha.enabled:
|
||||||
Should players that get to "banlevel" be presented with a captcha first
|
Should players that get to "banlevel" be presented with a captcha first
|
||||||
@ -1352,6 +1070,296 @@
|
|||||||
between the real values and the values defined in the configuration.
|
between the real values and the values defined in the configuration.
|
||||||
|
|
||||||
|
|
||||||
|
----------------------------- INVENTORY Subsection -----------------------------
|
||||||
|
|
||||||
|
Checks that at least technically have to do with the inventory or usage of
|
||||||
|
items can be found here.
|
||||||
|
|
||||||
|
1) DROP:
|
||||||
|
|
||||||
|
The "inventory.drop" check. It limits how many separate items a player can
|
||||||
|
drop onto the ground within a specific time. Dropping a lot of separate
|
||||||
|
items at once can cause lag on the server, therefore this check exists.
|
||||||
|
|
||||||
|
active:
|
||||||
|
Should the check be enabled. Set to false if you are not interested in
|
||||||
|
this at all.
|
||||||
|
|
||||||
|
time:
|
||||||
|
Over how many seconds should dropped items be counted, before the
|
||||||
|
counter gets reset and starts at zero again.
|
||||||
|
|
||||||
|
limit:
|
||||||
|
How many items may be dropped in the timeframe that is specified by
|
||||||
|
the "time" setting. Please consider that dying causes a player to drop
|
||||||
|
up to 36 separate items (stacks). Therefore this value shouldn't be
|
||||||
|
set below ~50.
|
||||||
|
|
||||||
|
actions:
|
||||||
|
What should happen when a player goes beyond the set limit. Default
|
||||||
|
settings log a message and kick the player from the server. The VL of
|
||||||
|
the drop check symbolizes how many items a player dropped beyond the
|
||||||
|
set limit. If the limit is 100 and he tried to drop 130, he will have a
|
||||||
|
Violation Level of 130 - 100 = 30.
|
||||||
|
|
||||||
|
2) INSTANTBOW:
|
||||||
|
|
||||||
|
Players may attack extremely fast and with a fully charged bow without
|
||||||
|
waiting for it to be fully pulled back. This is a significant advantage in
|
||||||
|
PvP and PvE combat.
|
||||||
|
|
||||||
|
active:
|
||||||
|
Should players be checked for this behavior. Set to false if you don't
|
||||||
|
care about players using bows faster than normally possible.
|
||||||
|
|
||||||
|
actions:
|
||||||
|
What should happen if the player fails this check. Default is to stop
|
||||||
|
the attack ("cancel" it) and log messages. The Violation Level (VL) for
|
||||||
|
this check the time difference between how long it took the player to
|
||||||
|
fire an arrow and how long NoCheatPlus thinks he should have taken, in
|
||||||
|
1/10 seconds. Therefore a VL of 10 would mean that the player shot an
|
||||||
|
arrow 1 second faster than NoCheatPlus expected. The VL gets increased
|
||||||
|
with every failed check and slowly decreased for every passed check.
|
||||||
|
|
||||||
|
3) INSTANTEAT:
|
||||||
|
|
||||||
|
Players may eat various kinds of food instantly instead of waiting the
|
||||||
|
usual time munching on the item.
|
||||||
|
|
||||||
|
active:
|
||||||
|
Should players be checked for this behavior. Set to false if you don't
|
||||||
|
care about players eating their food faster than normally possible.
|
||||||
|
|
||||||
|
actions:
|
||||||
|
What should happen if the player fails this check. Default is to stop
|
||||||
|
the eating ("cancel" it) and log messages. The Violation Level (VL) for
|
||||||
|
this check the time difference between how long it took the player to
|
||||||
|
eat his food and how long NoCheatPlus thinks he should have taken, in
|
||||||
|
1/10 seconds. Therefore a VL of 10 would mean that the player ate his
|
||||||
|
food 1 second faster than NoCheatPlus expected. The VL gets increased
|
||||||
|
with every failed check and slowly decreased for every passed check.
|
||||||
|
|
||||||
|
|
||||||
|
------------------------------ MOVING Subsection -------------------------------
|
||||||
|
|
||||||
|
Checks that at least technically have to do with the player moving around or
|
||||||
|
impacting the world with his movement can be found here.
|
||||||
|
|
||||||
|
1) RUNFLY:
|
||||||
|
|
||||||
|
Players may move in illegal ways (flying, running too fast) or try to
|
||||||
|
trick the server into thinking that they are not falling/flying by
|
||||||
|
cleverly manipulating the data that they send to the server.
|
||||||
|
|
||||||
|
active:
|
||||||
|
Should players get checked for this type of movement related hacks at
|
||||||
|
all. If deactivated, player may freely move around on the server, fly
|
||||||
|
or run really fast.
|
||||||
|
|
||||||
|
walkspeed:
|
||||||
|
How fast should the player be allowed to walk. Default is "100",
|
||||||
|
meaning 100% of normal walking speed. You will not see this option in
|
||||||
|
your config.yml file, because normally you shouldn't have to change the
|
||||||
|
walking speed of players at all (NoCheatPlus knows when players sprint,
|
||||||
|
use Swiftness potions etc and will already adapt the speed based on that
|
||||||
|
data).
|
||||||
|
|
||||||
|
sneakspeed:
|
||||||
|
How fast should the player be allowed to sneak. Default is "100",
|
||||||
|
meaning 100% of normal sneaking speed. You will not see this option in
|
||||||
|
your config.yml file, because normally you shouldn't have to change the
|
||||||
|
sneaking speed of players at all (NoCheatPlus knows when players sprint,
|
||||||
|
use Swiftness potions etc and will already adapt the speed based on
|
||||||
|
that data).
|
||||||
|
|
||||||
|
blockspeed:
|
||||||
|
How fast should the player be allowed to move while blocking. Default is
|
||||||
|
"100" meaning 100% of normal blocking speed. You will not see this
|
||||||
|
option in your config.yml file, because normally you shouldn't have to
|
||||||
|
change the blocking speed of player at all (NoCheatPlus knows when
|
||||||
|
players block, use Swiftness potions etc and will already adapt the
|
||||||
|
speed based on that data).
|
||||||
|
|
||||||
|
swimspeed:
|
||||||
|
How fast should the player be allowed to swim. Default is "100",
|
||||||
|
meaning 100% of normal swimming speed. You will not see this option in
|
||||||
|
your config.yml file, because normally you shouldn't have to change the
|
||||||
|
swimming speed of players at all (NoCheatPlus knows when players sprint,
|
||||||
|
use Swiftness potions etc and will already adapt the speed based on
|
||||||
|
that data).
|
||||||
|
|
||||||
|
verticalswimspped:
|
||||||
|
How fast should the player be allowed to swim (but on the vertical
|
||||||
|
axis). Default is "100", meaning 100% of normal swimming speed. You will
|
||||||
|
not see this option in our config.yml file, because normally you
|
||||||
|
shouldn't have to change the swimming speed of players at all
|
||||||
|
(NoCheatPlus knows when players sprint, use Swiftness potions etc and
|
||||||
|
will already adapt the speed based on that data).
|
||||||
|
|
||||||
|
sprintspeed:
|
||||||
|
How fast should the player be allowed to sprint. Default is "100",
|
||||||
|
meaning 100% of normal sprinting speed. You will not see this option in
|
||||||
|
your config.yml file, because normally you shouldn't have to change the
|
||||||
|
sprinting speed of players at all (NoCheatPlus knows when players
|
||||||
|
sprint, use Swiftness potions etc and will already adapt the speed based
|
||||||
|
on that data).
|
||||||
|
|
||||||
|
cobwebspeed:
|
||||||
|
How fast should the player be allowed to move while being into cobweb.
|
||||||
|
Default is "100" meaning 100% of normal speed while being into cobweb.
|
||||||
|
You will not see this option in your config.yml file, because normally
|
||||||
|
you shouldn't have to change the speed while being into cobweb of
|
||||||
|
players at all (NoCheatPlus knows when players are in cobweb, use
|
||||||
|
Swiftness potions etc and will already adapt the speed based on that
|
||||||
|
data).
|
||||||
|
|
||||||
|
allowfastsneaking:
|
||||||
|
Should sneaking players be allowed to move as fast as normal players.
|
||||||
|
Set this to true, if you use plugins that enable players to do that
|
||||||
|
(e.g. the "Heroes" plugin or other RPG plugins tend to do that)
|
||||||
|
|
||||||
|
allowfastblock:
|
||||||
|
Should players blocking be allowed to move as fast as normal players.
|
||||||
|
Set this to true if you use plugins that enable players to do that.
|
||||||
|
|
||||||
|
actions:
|
||||||
|
What should happen when a player sneaks/swims/walks/runs faster than
|
||||||
|
normally allowed or is flying. Default is to log messages (depending on
|
||||||
|
how severe the cheating is) and teleport the player to the last known
|
||||||
|
legitimate location on ground that NoCheatPlus can remember for that
|
||||||
|
player ("cancel" the movement).
|
||||||
|
|
||||||
|
NOFALL:
|
||||||
|
This is an entire subsection dedicated to the "moving.nofall" check.
|
||||||
|
It will be used to check if the player has tried to avoid fall
|
||||||
|
damages.
|
||||||
|
|
||||||
|
active:
|
||||||
|
Should players be checked for a common type of "nofall" hack, that
|
||||||
|
allows them to avoid taking damage when falling. If you don't care
|
||||||
|
about fall damage, you can deactivate this. It gets deactivated if a
|
||||||
|
player is allowed to fly (see some lines below), because it doesn't
|
||||||
|
make sense to allow flying and then hurt players when they land.
|
||||||
|
|
||||||
|
aggressivemode:
|
||||||
|
Enable an improved version of nofall check, that will catch additional
|
||||||
|
types of "nofall" hacks and deal damage to players directly. This is
|
||||||
|
usually safe to activate. It will only work if the "checknofall" is
|
||||||
|
also set to "true".
|
||||||
|
|
||||||
|
actions:
|
||||||
|
What should happen if a player is considered to be using a "nofall"
|
||||||
|
hack. Default reaction is to log a message and encourage Bukkit to
|
||||||
|
deal fall damage anyway ("cancel" the hack). The Violation Level is
|
||||||
|
the fall distance in blocks that the player tried to avoid. It gets
|
||||||
|
increased every time that the player fails the check, and decreased
|
||||||
|
over time if the player doesn't fail the check.
|
||||||
|
|
||||||
|
FLYING:
|
||||||
|
This is an entire subsection dedicated to the "moving.flying" check.
|
||||||
|
It will be used instead of the "runfly" check whenever a player has
|
||||||
|
the right to fly.
|
||||||
|
|
||||||
|
allowflyingalways:
|
||||||
|
Should all players be allowed to fly always.
|
||||||
|
|
||||||
|
allowflyingincreative:
|
||||||
|
Should players that are set to "creative mode" be allowed to fly. If
|
||||||
|
they are already allowed because of "allowflyingalways" to fly, this
|
||||||
|
setting gets ignored.
|
||||||
|
|
||||||
|
flyingspeedlimithorizontal:
|
||||||
|
How many 1/100 blocks may a player fly horizontal within one "step".
|
||||||
|
The official "creative mode" flying reaches speeds of about 0.6
|
||||||
|
blocks which means a value of 60 here.
|
||||||
|
|
||||||
|
flyingspeedlimitvertical:
|
||||||
|
How many 1/100 blocks may a player fly vertically up within one
|
||||||
|
"step". A value of 100 which means 1 block seems reasonable for most
|
||||||
|
cases.
|
||||||
|
|
||||||
|
flyingheightlimit:
|
||||||
|
What is the maximum height (in blocks) that a player may reach by
|
||||||
|
flying, relative to the max world height he is in. Some servers
|
||||||
|
experience lag when players fly very, very high. This value is how
|
||||||
|
far above the map height a player may fly.
|
||||||
|
|
||||||
|
actions:
|
||||||
|
What should happen if a player flies faster/higher than defined here?
|
||||||
|
Default is to log messages and to prevent the player from moving
|
||||||
|
("cancel" his last movement). The Violation Level (VL) of this check
|
||||||
|
is the distance that the player went beyond what NoCheatPlus allowed
|
||||||
|
him. The VL increases with every failed check and slowly decreases for
|
||||||
|
every passed check.
|
||||||
|
|
||||||
|
2) MOREPACKETS:
|
||||||
|
|
||||||
|
The morepackets check is complementary to the "runfly" check. While the
|
||||||
|
"runfly" check(s) limit the distance a player can move per step, this
|
||||||
|
"morepackets" check limits the number of "steps" a player may take per
|
||||||
|
second. A normal value is 20 steps per second.
|
||||||
|
|
||||||
|
active:
|
||||||
|
Should players be checked for this kind of cheating. If you are not
|
||||||
|
interested in players that cheat that way, set this to false. It is a
|
||||||
|
good idea to have this active, because players that cheat by sending
|
||||||
|
more packets than normally allowed may lag the server (each of those
|
||||||
|
packets has to be processed, after all).
|
||||||
|
|
||||||
|
actions:
|
||||||
|
What should happen if a player is considered to be cheating by taking
|
||||||
|
more steps per second than normal. Default is to log messages and
|
||||||
|
teleport the player back to a location where he was ~1 second before
|
||||||
|
("cancel" his movement). The Violation Level VL is the number of
|
||||||
|
packets that the player sent beyond the expected amount.
|
||||||
|
|
||||||
|
3) MOREPACKETSVEHICULE:
|
||||||
|
|
||||||
|
The morepacketsvehicule check is complementary to the "morepackets" check.
|
||||||
|
While the "morepacket" check limit the number of player-move packets send
|
||||||
|
per second, this "morepacketsvehicle" limit the number of vehicule-move
|
||||||
|
packets sent per second. A normal value is 20 packets per second.
|
||||||
|
|
||||||
|
active:
|
||||||
|
Should players be checked for this kind of cheating. If you are not
|
||||||
|
interested in players that cheat that way, set this to false. It is a
|
||||||
|
good idea to have this active, because players that cheat by sending
|
||||||
|
more packets than normally allowed may lag the server (each of those
|
||||||
|
packets has to be processed, after all).
|
||||||
|
|
||||||
|
actions:
|
||||||
|
What should happen if a player is considered to be cheating by taking
|
||||||
|
more steps per second than normal. Default is to log messages and break
|
||||||
|
the boat the player is using. The Violation Level VL is the number of
|
||||||
|
packets that the player sent beyond the expected amount.
|
||||||
|
|
||||||
|
4) WATERWALK:
|
||||||
|
|
||||||
|
The waterwalk check is used to prevent players from walking on water using
|
||||||
|
a client dedicated to griefing (this mode is usually called Jesus mod).
|
||||||
|
Firstly, it'll check if the player's move is valid (not only moving the X
|
||||||
|
and Z axes but also on the Y axis and, of course, if the player is near the
|
||||||
|
surface (most of the griefing client set the player 0.3 blocks under the
|
||||||
|
water surface). Secondly, it'll make sure the player is using the borders
|
||||||
|
of the block to climb outside the water (it prevents players using griefing
|
||||||
|
clients to simply jump multiple times over the water).
|
||||||
|
|
||||||
|
active:
|
||||||
|
Should players be checked for this kind of cheating. If you are not
|
||||||
|
interested in players that cheat that way, set this to false. It is a
|
||||||
|
good idea to have this active, because players won't be able to cross
|
||||||
|
easily the oceans.
|
||||||
|
|
||||||
|
actions:
|
||||||
|
What should happen if a player is considered to be cheating by walking
|
||||||
|
on water. Default is to log messages and to prevent the player from
|
||||||
|
moving ("cancel" his last movement). The Violation Level (VL) of this
|
||||||
|
check is the distance between the player and the surface or how far away
|
||||||
|
he is from the normal position if a player climbing a block. The VL
|
||||||
|
increases with every failed check and slowly decreases for every passed
|
||||||
|
check.
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
------------------------------- STRINGS Section --------------------------------
|
------------------------------- STRINGS Section --------------------------------
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<!-- Informations -->
|
<!-- Informations -->
|
||||||
<name>NoCheatPlus</name>
|
<name>NoCheatPlus</name>
|
||||||
<version>3.5.9</version>
|
<version>3.6</version>
|
||||||
<description>Detect and fight the exploitation of various flaws/bugs in Minecraft.</description>
|
<description>Detect and fight the exploitation of various flaws/bugs in Minecraft.</description>
|
||||||
<url>http://dev.bukkit.org/server-mods/nocheatplus</url>
|
<url>http://dev.bukkit.org/server-mods/nocheatplus</url>
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ public class CommandHandler implements CommandExecutor {
|
|||||||
|
|
||||||
for (final Permission permission : perms)
|
for (final Permission permission : perms)
|
||||||
if (permission.getName().startsWith(prefix))
|
if (permission.getName().startsWith(prefix))
|
||||||
sender.sendMessage(permission.getName() + ": " + player.hasPermission(permission));
|
sender.sendMessage(permission.getName() + ": " + NCPPlayer.hasPermission(player, permission.getName()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ public class CommandHandler implements CommandExecutor {
|
|||||||
private boolean handleReloadCommand(final CommandSender sender) {
|
private boolean handleReloadCommand(final CommandSender sender) {
|
||||||
|
|
||||||
// Players need a special permission for this
|
// Players need a special permission for this
|
||||||
if (!(sender instanceof Player) || sender.hasPermission(Permissions.ADMIN_RELOAD)) {
|
if (!(sender instanceof Player) || NCPPlayer.hasPermission(sender, Permissions.ADMIN_RELOAD)) {
|
||||||
sender.sendMessage("[NoCheatPlus] Reloading configuration");
|
sender.sendMessage("[NoCheatPlus] Reloading configuration");
|
||||||
ConfigManager.cleanup();
|
ConfigManager.cleanup();
|
||||||
ConfigManager.init();
|
ConfigManager.init();
|
||||||
@ -121,7 +121,7 @@ public class CommandHandler implements CommandExecutor {
|
|||||||
ConfPaths.MISCELLANEOUS_PROTECTPLUGINS);
|
ConfPaths.MISCELLANEOUS_PROTECTPLUGINS);
|
||||||
|
|
||||||
// Hide NoCheatPlus's commands if the player doesn't have the required permission
|
// Hide NoCheatPlus's commands if the player doesn't have the required permission
|
||||||
if (protectPlugins && !sender.hasPermission("nocheatplus.admin.commands")) {
|
if (protectPlugins && !NCPPlayer.hasPermission(sender, "nocheatplus.admin.commands")) {
|
||||||
sender.sendMessage("Unknown command. Type \"help\" for help.");
|
sender.sendMessage("Unknown command. Type \"help\" for help.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package fr.neatmonster.nocheatplus;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -13,7 +12,6 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.checks.CheckConfig;
|
|
||||||
import fr.neatmonster.nocheatplus.checks.WorkaroundsListener;
|
import fr.neatmonster.nocheatplus.checks.WorkaroundsListener;
|
||||||
import fr.neatmonster.nocheatplus.checks.blockbreak.BlockBreakListener;
|
import fr.neatmonster.nocheatplus.checks.blockbreak.BlockBreakListener;
|
||||||
import fr.neatmonster.nocheatplus.checks.blockplace.BlockPlaceListener;
|
import fr.neatmonster.nocheatplus.checks.blockplace.BlockPlaceListener;
|
||||||
@ -25,61 +23,19 @@ import fr.neatmonster.nocheatplus.config.ConfPaths;
|
|||||||
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Permissions;
|
import fr.neatmonster.nocheatplus.players.informations.Permissions;
|
||||||
import fr.neatmonster.nocheatplus.utilities.Colors;
|
|
||||||
import fr.neatmonster.nocheatplus.utilities.LagMeasureTask;
|
import fr.neatmonster.nocheatplus.utilities.LagMeasureTask;
|
||||||
import fr.neatmonster.nocheatplus.utilities.LogEvent;
|
|
||||||
|
|
||||||
public class NoCheatPlus extends JavaPlugin implements Listener {
|
public class NoCheatPlus extends JavaPlugin implements Listener {
|
||||||
public enum Check {
|
|
||||||
BLOCKBREAK("blockbreak"),
|
|
||||||
BLOCKPLACE("blockplace"),
|
|
||||||
CHAT("chat"),
|
|
||||||
FIGHT("fight"),
|
|
||||||
INVENTORY("inventory"),
|
|
||||||
MOVING("moving");
|
|
||||||
|
|
||||||
private final String group;
|
|
||||||
|
|
||||||
private Check(final String group) {
|
|
||||||
this.group = group;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getGroup() {
|
|
||||||
return group;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static NoCheatPlus instance = null;
|
public static NoCheatPlus instance = null;
|
||||||
|
|
||||||
public static CheckConfig getConfig(final Player player, final Check check) {
|
|
||||||
return NCPPlayer.getPlayer(player).getConfig(check.getGroup());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean skipCheck() {
|
public static boolean skipCheck() {
|
||||||
return instance.lagMeasureTask == null ? false : instance.lagMeasureTask.skipCheck();
|
return instance.lagMeasureTask == null ? false : instance.lagMeasureTask.skipCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
private CommandHandler commandHandler;
|
private CommandHandler commandHandler;
|
||||||
private Logger fileLogger;
|
|
||||||
private LagMeasureTask lagMeasureTask;
|
private LagMeasureTask lagMeasureTask;
|
||||||
private List<Listener> listeners;
|
private List<Listener> listeners;
|
||||||
|
|
||||||
@EventHandler(
|
|
||||||
priority = EventPriority.MONITOR)
|
|
||||||
public void logEvent(final LogEvent event) {
|
|
||||||
if (event.toConsole())
|
|
||||||
// Console logs are not colored
|
|
||||||
System.out.println(Colors.removeColors(event.getPrefix() + event.getMessage()));
|
|
||||||
if (event.toChat())
|
|
||||||
for (final Player player : Bukkit.getServer().getOnlinePlayers())
|
|
||||||
if (player.hasPermission(Permissions.ADMIN_CHATLOG))
|
|
||||||
// Chat logs are potentially colored
|
|
||||||
player.sendMessage(Colors.replaceColors(event.getPrefix() + event.getMessage()));
|
|
||||||
if (event.toFile())
|
|
||||||
// File logs are not colored
|
|
||||||
fileLogger.info(Colors.removeColors(event.getMessage()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
|
||||||
@ -146,60 +102,56 @@ public class NoCheatPlus extends JavaPlugin implements Listener {
|
|||||||
return;
|
return;
|
||||||
String message = "";
|
String message = "";
|
||||||
// Disable Zombe's fly mod
|
// Disable Zombe's fly mod
|
||||||
if (!player.hasPermission(Permissions.ZOMBE_FLY))
|
if (!NCPPlayer.hasPermission(player, Permissions.ZOMBE_FLY))
|
||||||
message = message + "§f §f §1 §0 §2 §4";
|
message = message + "§f §f §1 §0 §2 §4";
|
||||||
// Disable Zombe's noclip
|
// Disable Zombe's noclip
|
||||||
if (!player.hasPermission(Permissions.ZOMBE_NOCLIP))
|
if (!NCPPlayer.hasPermission(player, Permissions.ZOMBE_NOCLIP))
|
||||||
message = message + "§f §f §4 §0 §9 §6";
|
message = message + "§f §f §4 §0 §9 §6";
|
||||||
// Disable Zombe's cheat
|
// Disable Zombe's cheat
|
||||||
if (!player.hasPermission(Permissions.ZOMBE_CHEAT))
|
if (!NCPPlayer.hasPermission(player, Permissions.ZOMBE_CHEAT))
|
||||||
message = message + "§f §f §2 §0 §4 §8";
|
message = message + "§f §f §2 §0 §4 §8";
|
||||||
// Disable CJB's fly mod
|
// Disable CJB's fly mod
|
||||||
if (!player.hasPermission(Permissions.CJB_FLY))
|
if (!NCPPlayer.hasPermission(player, Permissions.CJB_FLY))
|
||||||
message = message + "§3 §9 §2 §0 §0 §1";
|
message = message + "§3 §9 §2 §0 §0 §1";
|
||||||
// Disable CJB's xray
|
// Disable CJB's xray
|
||||||
if (!player.hasPermission(Permissions.CJB_XRAY))
|
if (!NCPPlayer.hasPermission(player, Permissions.CJB_XRAY))
|
||||||
message = message + "§3 §9 §2 §0 §0 §2";
|
message = message + "§3 §9 §2 §0 §0 §2";
|
||||||
// Disable CJB's radar
|
// Disable CJB's radar
|
||||||
if (!player.hasPermission(Permissions.CJB_RADAR))
|
if (!NCPPlayer.hasPermission(player, Permissions.CJB_RADAR))
|
||||||
message = message + "§3 §9 §2 §0 §0 §3";
|
message = message + "§3 §9 §2 §0 §0 §3";
|
||||||
// Disable Rei's Minimap's cave mode
|
// Disable Rei's Minimap's cave mode
|
||||||
if (player.hasPermission(Permissions.REI_CAVE))
|
if (NCPPlayer.hasPermission(player, Permissions.REI_CAVE))
|
||||||
message = message + "§0§0§1§e§f";
|
message = message + "§0§0§1§e§f";
|
||||||
// Disable Rei's Minimap's radar
|
// Disable Rei's Minimap's radar
|
||||||
if (player.hasPermission(Permissions.REI_RADAR))
|
if (NCPPlayer.hasPermission(player, Permissions.REI_RADAR))
|
||||||
message = message + "§0§0§2§3§4§5§6§7§e§f";
|
message = message + "§0§0§2§3§4§5§6§7§e§f";
|
||||||
// Disable Minecraft AutoMap's ores
|
// Disable Minecraft AutoMap's ores
|
||||||
if (!player.hasPermission(Permissions.MINECRAFTAUTOMAP_ORES))
|
if (!NCPPlayer.hasPermission(player, Permissions.MINECRAFTAUTOMAP_ORES))
|
||||||
message = message + "§0§0§1§f§e";
|
message = message + "§0§0§1§f§e";
|
||||||
// Disable Minecraft AutoMap's cave mode
|
// Disable Minecraft AutoMap's cave mode
|
||||||
if (!player.hasPermission(Permissions.MINECRAFTAUTOMAP_CAVE))
|
if (!NCPPlayer.hasPermission(player, Permissions.MINECRAFTAUTOMAP_CAVE))
|
||||||
message = message + "§0§0§2§f§e";
|
message = message + "§0§0§2§f§e";
|
||||||
// Disable Minecraft AutoMap's radar
|
// Disable Minecraft AutoMap's radar
|
||||||
if (!player.hasPermission(Permissions.MINECRAFTAUTOMAP_RADAR))
|
if (!NCPPlayer.hasPermission(player, Permissions.MINECRAFTAUTOMAP_RADAR))
|
||||||
message = message + "§0§0§3§4§5§6§7§8§f§e";
|
message = message + "§0§0§3§4§5§6§7§8§f§e";
|
||||||
// Disable Smart Moving's climbing
|
// Disable Smart Moving's climbing
|
||||||
if (!player.hasPermission(Permissions.SMARTMOVING_CLIMBING))
|
if (!NCPPlayer.hasPermission(player, Permissions.SMARTMOVING_CLIMBING))
|
||||||
message = message + "§0§1§0§1§2§f§f";
|
message = message + "§0§1§0§1§2§f§f";
|
||||||
// Disable Smart Moving's climbing
|
// Disable Smart Moving's climbing
|
||||||
if (!player.hasPermission(Permissions.SMARTMOVING_SWIMMING))
|
if (!NCPPlayer.hasPermission(player, Permissions.SMARTMOVING_SWIMMING))
|
||||||
message = message + "§0§1§3§4§f§f";
|
message = message + "§0§1§3§4§f§f";
|
||||||
// Disable Smart Moving's climbing
|
// Disable Smart Moving's climbing
|
||||||
if (!player.hasPermission(Permissions.SMARTMOVING_CRAWLING))
|
if (!NCPPlayer.hasPermission(player, Permissions.SMARTMOVING_CRAWLING))
|
||||||
message = message + "§0§1§5§f§f";
|
message = message + "§0§1§5§f§f";
|
||||||
// Disable Smart Moving's climbing
|
// Disable Smart Moving's climbing
|
||||||
if (!player.hasPermission(Permissions.SMARTMOVING_SLIDING))
|
if (!NCPPlayer.hasPermission(player, Permissions.SMARTMOVING_SLIDING))
|
||||||
message = message + "§0§1§6§f§f";
|
message = message + "§0§1§6§f§f";
|
||||||
// Disable Smart Moving's climbing
|
// Disable Smart Moving's climbing
|
||||||
if (!player.hasPermission(Permissions.SMARTMOVING_JUMPING))
|
if (!NCPPlayer.hasPermission(player, Permissions.SMARTMOVING_JUMPING))
|
||||||
message = message + "§0§1§8§9§a§b§f§f";
|
message = message + "§0§1§8§9§a§b§f§f";
|
||||||
// Disable Smart Moving's climbing
|
// Disable Smart Moving's climbing
|
||||||
if (!player.hasPermission(Permissions.SMARTMOVING_FLYING))
|
if (!NCPPlayer.hasPermission(player, Permissions.SMARTMOVING_FLYING))
|
||||||
message = message + "§0§1§7§f§f";
|
message = message + "§0§1§7§f§f";
|
||||||
player.sendMessage(message);
|
player.sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFileLogger(final Logger logger) {
|
|
||||||
fileLogger = logger;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,13 @@ package fr.neatmonster.nocheatplus.checks;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.CommandException;
|
import org.bukkit.command.CommandException;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.actions.Action;
|
import fr.neatmonster.nocheatplus.actions.Action;
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
@ -19,11 +22,12 @@ import fr.neatmonster.nocheatplus.config.ConfPaths;
|
|||||||
import fr.neatmonster.nocheatplus.config.ConfigFile;
|
import fr.neatmonster.nocheatplus.config.ConfigFile;
|
||||||
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
|
import fr.neatmonster.nocheatplus.players.informations.Permissions;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
||||||
import fr.neatmonster.nocheatplus.utilities.LogEvent;
|
|
||||||
|
|
||||||
public abstract class Check {
|
public abstract class Check {
|
||||||
private static final Map<String, Check> checks = new HashMap<String, Check>();
|
private static final Map<String, Check> checks = new HashMap<String, Check>();
|
||||||
|
private static Logger fileLogger = null;
|
||||||
|
|
||||||
public static CheckConfig newConfig(final String group, final String worldName) {
|
public static CheckConfig newConfig(final String group, final String worldName) {
|
||||||
if (checks.containsKey(group))
|
if (checks.containsKey(group))
|
||||||
@ -37,8 +41,42 @@ public abstract class Check {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove instances of &X
|
||||||
|
*
|
||||||
|
* @param text
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String removeColors(String text) {
|
||||||
|
|
||||||
|
for (final ChatColor c : ChatColor.values())
|
||||||
|
text = text.replace("&" + c.getChar(), "");
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace instances of &X with a color
|
||||||
|
*
|
||||||
|
* @param text
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String replaceColors(String text) {
|
||||||
|
|
||||||
|
for (final ChatColor c : ChatColor.values())
|
||||||
|
text = text.replace("&" + c.getChar(), c.toString());
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setFileLogger(final Logger logger) {
|
||||||
|
fileLogger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
private final Class<? extends CheckConfig> configClass;
|
private final Class<? extends CheckConfig> configClass;
|
||||||
|
|
||||||
private final Class<? extends CheckData> dataClass;
|
private final Class<? extends CheckData> dataClass;
|
||||||
|
|
||||||
public Check(final String name, final Class<? extends CheckConfig> configClass,
|
public Check(final String name, final Class<? extends CheckConfig> configClass,
|
||||||
@ -102,20 +140,29 @@ public abstract class Check {
|
|||||||
if (!configurationFile.getBoolean(ConfPaths.LOGGING_ACTIVE))
|
if (!configurationFile.getBoolean(ConfPaths.LOGGING_ACTIVE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Fire one of our custom "Log" Events
|
final String prefix = configurationFile.getString(ConfPaths.LOGGING_PREFIX);
|
||||||
Bukkit.getServer()
|
final String message = l.getLogMessage(player, check);
|
||||||
.getPluginManager()
|
if (configurationFile.getBoolean(ConfPaths.LOGGING_LOGTOCONSOLE) && l.toConsole())
|
||||||
.callEvent(
|
// Console logs are not colored
|
||||||
new LogEvent(configurationFile.getString(ConfPaths.LOGGING_PREFIX), l.getLogMessage(player,
|
System.out.println(removeColors(prefix + message));
|
||||||
check), configurationFile.getBoolean(ConfPaths.LOGGING_LOGTOCONSOLE) && l.toConsole(),
|
if (configurationFile.getBoolean(ConfPaths.LOGGING_LOGTOINGAMECHAT) && l.toChat())
|
||||||
configurationFile.getBoolean(ConfPaths.LOGGING_LOGTOINGAMECHAT) && l.toChat(),
|
for (final Player bukkitPlayer : Bukkit.getServer().getOnlinePlayers())
|
||||||
configurationFile.getBoolean(ConfPaths.LOGGING_LOGTOFILE) && l.toFile()));
|
if (NCPPlayer.hasPermission(bukkitPlayer, Permissions.ADMIN_CHATLOG))
|
||||||
|
// Chat logs are potentially colored
|
||||||
|
bukkitPlayer.sendMessage(replaceColors(prefix + message));
|
||||||
|
if (configurationFile.getBoolean(ConfPaths.LOGGING_LOGTOFILE) && l.toFile())
|
||||||
|
// File logs are not colored
|
||||||
|
fileLogger.info(removeColors(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGroup() {
|
public String getGroup() {
|
||||||
return name.contains(".") ? name.split("\\.")[0] : name;
|
return name.contains(".") ? name.split("\\.")[0] : name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name.contains(".") ? name.split("\\.")[name.split("\\.").length - 1] : name;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace a parameter for commands or log actions with an actual
|
* Replace a parameter for commands or log actions with an actual
|
||||||
* value. Individual checks should override this to get their own
|
* value. Individual checks should override this to get their own
|
||||||
|
154
src/fr/neatmonster/nocheatplus/checks/CheckEvent.java
Normal file
154
src/fr/neatmonster/nocheatplus/checks/CheckEvent.java
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
package fr.neatmonster.nocheatplus.checks;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The event created when actions are executed.
|
||||||
|
*/
|
||||||
|
public abstract class CheckEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
|
/** The Constant handlers. */
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the handler list.
|
||||||
|
*
|
||||||
|
* @return the handler list
|
||||||
|
*/
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The check which has triggered this event. */
|
||||||
|
private final Check check;
|
||||||
|
|
||||||
|
/** The player who has triggered this event. */
|
||||||
|
private NCPPlayer player;
|
||||||
|
|
||||||
|
/** The actions which are going to be executed if the event isn't cancelled. */
|
||||||
|
private ActionList actions;
|
||||||
|
|
||||||
|
/** The violation level of the player for the specified check. */
|
||||||
|
private double vL;
|
||||||
|
|
||||||
|
/** The boolean used to know if the event is cancelled. */
|
||||||
|
private boolean cancel = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new check event.
|
||||||
|
*
|
||||||
|
* @param check
|
||||||
|
* the check
|
||||||
|
* @param player
|
||||||
|
* the player
|
||||||
|
* @param actions
|
||||||
|
* the actions
|
||||||
|
* @param vL
|
||||||
|
* the vL
|
||||||
|
*/
|
||||||
|
public CheckEvent(final Check check, final NCPPlayer player, final ActionList actions, final double vL) {
|
||||||
|
this.check = check;
|
||||||
|
this.player = player;
|
||||||
|
this.actions = actions;
|
||||||
|
this.vL = vL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the actions which are going to be executed if the event isn't cancelled.
|
||||||
|
*
|
||||||
|
* @return the actions
|
||||||
|
*/
|
||||||
|
public ActionList getActions() {
|
||||||
|
return actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the check which has triggered this event.
|
||||||
|
*
|
||||||
|
* @return the check
|
||||||
|
*/
|
||||||
|
public Check getCheck() {
|
||||||
|
return check;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.bukkit.event.Event#getHandlers()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the player who has triggered the event.
|
||||||
|
*
|
||||||
|
* @return the player
|
||||||
|
*/
|
||||||
|
public Player getPlayer() {
|
||||||
|
return player.getBukkitPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the violation level of the player for the specified check.
|
||||||
|
*
|
||||||
|
* @return the vL
|
||||||
|
*/
|
||||||
|
public double getVL() {
|
||||||
|
return vL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.bukkit.event.Cancellable#isCancelled()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the actions which are going to be executed if the event isn't cancelled.
|
||||||
|
*
|
||||||
|
* @param actions
|
||||||
|
* the new actions
|
||||||
|
*/
|
||||||
|
public void setActions(final ActionList actions) {
|
||||||
|
this.actions = actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.bukkit.event.Cancellable#setCancelled(boolean)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setCancelled(final boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the player who has triggered the event.
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
* the new player
|
||||||
|
*/
|
||||||
|
public void setPlayer(final Player player) {
|
||||||
|
this.player = NCPPlayer.getPlayer(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the violation level of the player for the specified check.
|
||||||
|
*
|
||||||
|
* @param vL
|
||||||
|
* the new vL
|
||||||
|
*/
|
||||||
|
public void setVL(final double vL) {
|
||||||
|
this.vL = vL;
|
||||||
|
}
|
||||||
|
}
|
@ -269,7 +269,7 @@ public class CheckUtils {
|
|||||||
return (fromType & INGROUND) == INGROUND;
|
return (fromType & INGROUND) == INGROUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isLadder(final int value) {
|
public static boolean isLadder(final int value) {
|
||||||
return (value & LADDER) == LADDER;
|
return (value & LADDER) == LADDER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package fr.neatmonster.nocheatplus.checks.blockbreak;
|
||||||
|
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
|
import fr.neatmonster.nocheatplus.checks.CheckEvent;
|
||||||
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
|
|
||||||
|
public class BlockBreakEvent extends CheckEvent {
|
||||||
|
|
||||||
|
public BlockBreakEvent(final BlockBreakCheck check, final NCPPlayer player, final ActionList actions,
|
||||||
|
final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockBreakCheck getCheck() {
|
||||||
|
return (BlockBreakCheck) super.getCheck();
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,9 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.blockbreak;
|
package fr.neatmonster.nocheatplus.checks.blockbreak;
|
||||||
|
|
||||||
import java.util.Locale;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.checks.CheckUtils;
|
import fr.neatmonster.nocheatplus.checks.CheckUtils;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
||||||
@ -15,6 +16,14 @@ import fr.neatmonster.nocheatplus.utilities.locations.SimpleLocation;
|
|||||||
*/
|
*/
|
||||||
public class DirectionCheck extends BlockBreakCheck {
|
public class DirectionCheck extends BlockBreakCheck {
|
||||||
|
|
||||||
|
public class DirectionCheckEvent extends BlockBreakEvent {
|
||||||
|
|
||||||
|
public DirectionCheckEvent(final DirectionCheck check, final NCPPlayer player, final ActionList actions,
|
||||||
|
final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public DirectionCheck() {
|
public DirectionCheck() {
|
||||||
super("direction");
|
super("direction");
|
||||||
}
|
}
|
||||||
@ -77,11 +86,20 @@ public class DirectionCheck extends BlockBreakCheck {
|
|||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final DirectionCheckEvent event = new DirectionCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", (int) getData(player).directionVL);
|
return String.valueOf(getData(player).directionVL);
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.blockbreak;
|
package fr.neatmonster.nocheatplus.checks.blockbreak;
|
||||||
|
|
||||||
import java.util.Locale;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
||||||
|
|
||||||
@ -15,12 +15,20 @@ import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
|||||||
*/
|
*/
|
||||||
public class FastBreakCheck extends BlockBreakCheck {
|
public class FastBreakCheck extends BlockBreakCheck {
|
||||||
|
|
||||||
|
public class FastBreakCheckEvent extends BlockBreakEvent {
|
||||||
|
|
||||||
|
public FastBreakCheckEvent(final FastBreakCheck check, final NCPPlayer player, final ActionList actions,
|
||||||
|
final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public FastBreakCheck() {
|
public FastBreakCheck() {
|
||||||
super("fastbreak");
|
super("fastbreak");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check(final fr.neatmonster.nocheatplus.players.NCPPlayer player, final Object... args) {
|
public boolean check(final NCPPlayer player, final Object... args) {
|
||||||
final BlockBreakConfig cc = getConfig(player);
|
final BlockBreakConfig cc = getConfig(player);
|
||||||
final BlockBreakData data = getData(player);
|
final BlockBreakData data = getData(player);
|
||||||
|
|
||||||
@ -58,11 +66,20 @@ public class FastBreakCheck extends BlockBreakCheck {
|
|||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final FastBreakCheckEvent event = new FastBreakCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", (int) getData(player).fastBreakVL);
|
return String.valueOf(Math.round(getData(player).fastBreakVL));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.blockbreak;
|
package fr.neatmonster.nocheatplus.checks.blockbreak;
|
||||||
|
|
||||||
import java.util.Locale;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
||||||
|
|
||||||
@ -13,6 +14,14 @@ import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
|||||||
*/
|
*/
|
||||||
public class NoswingCheck extends BlockBreakCheck {
|
public class NoswingCheck extends BlockBreakCheck {
|
||||||
|
|
||||||
|
public class NoswingCheckEvent extends BlockBreakEvent {
|
||||||
|
|
||||||
|
public NoswingCheckEvent(final NoswingCheck check, final NCPPlayer player, final ActionList actions,
|
||||||
|
final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public NoswingCheck() {
|
public NoswingCheck() {
|
||||||
super("noswing");
|
super("noswing");
|
||||||
}
|
}
|
||||||
@ -43,11 +52,20 @@ public class NoswingCheck extends BlockBreakCheck {
|
|||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final NoswingCheckEvent event = new NoswingCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", (int) getData(player).noswingVL);
|
return String.valueOf(Math.round(getData(player).noswingVL));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.blockbreak;
|
package fr.neatmonster.nocheatplus.checks.blockbreak;
|
||||||
|
|
||||||
import java.util.Locale;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.checks.CheckUtils;
|
import fr.neatmonster.nocheatplus.checks.CheckUtils;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
||||||
@ -17,6 +17,13 @@ import fr.neatmonster.nocheatplus.utilities.locations.SimpleLocation;
|
|||||||
*/
|
*/
|
||||||
public class ReachCheck extends BlockBreakCheck {
|
public class ReachCheck extends BlockBreakCheck {
|
||||||
|
|
||||||
|
public class ReachCheckEvent extends BlockBreakEvent {
|
||||||
|
|
||||||
|
public ReachCheckEvent(final ReachCheck check, final NCPPlayer player, final ActionList actions, final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ReachCheck() {
|
public ReachCheck() {
|
||||||
super("reach");
|
super("reach");
|
||||||
}
|
}
|
||||||
@ -57,13 +64,22 @@ public class ReachCheck extends BlockBreakCheck {
|
|||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final ReachCheckEvent event = new ReachCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", (int) getData(player).reachVL);
|
return String.valueOf(Math.round(getData(player).reachVL));
|
||||||
else if (wildcard == ParameterName.REACHDISTANCE)
|
else if (wildcard == ParameterName.REACHDISTANCE)
|
||||||
return String.format(Locale.US, "%.2f", getData(player).reachDistance);
|
return String.valueOf(Math.round(getData(player).reachDistance));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.blockplace;
|
package fr.neatmonster.nocheatplus.checks.blockplace;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
import fr.neatmonster.nocheatplus.checks.Check;
|
import fr.neatmonster.nocheatplus.checks.Check;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
@ -32,7 +30,8 @@ public abstract class BlockPlaceCheck extends Check {
|
|||||||
if (wildcard == ParameterName.PLACE_LOCATION) {
|
if (wildcard == ParameterName.PLACE_LOCATION) {
|
||||||
final SimpleLocation l = getData(player).blockPlaced;
|
final SimpleLocation l = getData(player).blockPlaced;
|
||||||
if (l.isSet())
|
if (l.isSet())
|
||||||
return String.format(Locale.US, "%d %d %d", l.x, l.y, l.z);
|
return String.valueOf(Math.round(l.x)) + " " + String.valueOf(Math.round(l.y)) + " "
|
||||||
|
+ String.valueOf(Math.round(l.z));
|
||||||
else
|
else
|
||||||
return "null";
|
return "null";
|
||||||
}
|
}
|
||||||
@ -40,7 +39,8 @@ public abstract class BlockPlaceCheck extends Check {
|
|||||||
else if (wildcard == ParameterName.PLACE_AGAINST) {
|
else if (wildcard == ParameterName.PLACE_AGAINST) {
|
||||||
final SimpleLocation l = getData(player).blockPlacedAgainst;
|
final SimpleLocation l = getData(player).blockPlacedAgainst;
|
||||||
if (l.isSet())
|
if (l.isSet())
|
||||||
return String.format(Locale.US, "%d %d %d", l.x, l.y, l.z);
|
return String.valueOf(Math.round(l.x)) + " " + String.valueOf(Math.round(l.y)) + " "
|
||||||
|
+ String.valueOf(Math.round(l.z));
|
||||||
else
|
else
|
||||||
return "null";
|
return "null";
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package fr.neatmonster.nocheatplus.checks.blockplace;
|
||||||
|
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
|
import fr.neatmonster.nocheatplus.checks.CheckEvent;
|
||||||
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
|
|
||||||
|
public class BlockPlaceEvent extends CheckEvent {
|
||||||
|
|
||||||
|
public BlockPlaceEvent(final BlockPlaceCheck check, final NCPPlayer player, final ActionList actions,
|
||||||
|
final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockPlaceCheck getCheck() {
|
||||||
|
return (BlockPlaceCheck) super.getCheck();
|
||||||
|
}
|
||||||
|
}
|
@ -152,9 +152,9 @@ public class BlockPlaceListener extends CheckListener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Check if the text is the same
|
// Check if the text is the same
|
||||||
if (!event.getPlayer().hasPermission(Permissions.BLOCKPLACE_AUTOSIGN)
|
if (!player.hasPermission(Permissions.BLOCKPLACE_AUTOSIGN) && event.getLine(0).equals(data.lastSignText[0])
|
||||||
&& event.getLine(0).equals(data.lastSignText[0]) && event.getLine(1).equals(data.lastSignText[1])
|
&& event.getLine(1).equals(data.lastSignText[1]) && event.getLine(2).equals(data.lastSignText[2])
|
||||||
&& event.getLine(2).equals(data.lastSignText[2]) && event.getLine(3).equals(data.lastSignText[3])
|
&& event.getLine(3).equals(data.lastSignText[3])
|
||||||
&& data.lastSignText[0].equals(data.lastLastSignText[0])
|
&& data.lastSignText[0].equals(data.lastLastSignText[0])
|
||||||
&& data.lastSignText[1].equals(data.lastLastSignText[1])
|
&& data.lastSignText[1].equals(data.lastLastSignText[1])
|
||||||
&& data.lastSignText[2].equals(data.lastLastSignText[2])
|
&& data.lastSignText[2].equals(data.lastLastSignText[2])
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.blockplace;
|
package fr.neatmonster.nocheatplus.checks.blockplace;
|
||||||
|
|
||||||
import java.util.Locale;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.checks.CheckUtils;
|
import fr.neatmonster.nocheatplus.checks.CheckUtils;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
||||||
@ -17,6 +17,14 @@ import fr.neatmonster.nocheatplus.utilities.locations.SimpleLocation;
|
|||||||
*/
|
*/
|
||||||
public class DirectionCheck extends BlockPlaceCheck {
|
public class DirectionCheck extends BlockPlaceCheck {
|
||||||
|
|
||||||
|
public class DirectionCheckEvent extends BlockPlaceEvent {
|
||||||
|
|
||||||
|
public DirectionCheckEvent(final DirectionCheck check, final NCPPlayer player, final ActionList actions,
|
||||||
|
final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public DirectionCheck() {
|
public DirectionCheck() {
|
||||||
super("direction");
|
super("direction");
|
||||||
}
|
}
|
||||||
@ -96,11 +104,20 @@ public class DirectionCheck extends BlockPlaceCheck {
|
|||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final DirectionCheckEvent event = new DirectionCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", (int) getData(player).directionVL);
|
return String.valueOf(Math.round(getData(player).directionVL));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.blockplace;
|
package fr.neatmonster.nocheatplus.checks.blockplace;
|
||||||
|
|
||||||
import java.util.Locale;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
||||||
|
|
||||||
@ -13,6 +14,14 @@ import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
|||||||
*/
|
*/
|
||||||
public class FastPlaceCheck extends BlockPlaceCheck {
|
public class FastPlaceCheck extends BlockPlaceCheck {
|
||||||
|
|
||||||
|
public class FastPlaceCheckEvent extends BlockPlaceEvent {
|
||||||
|
|
||||||
|
public FastPlaceCheckEvent(final FastPlaceCheck check, final NCPPlayer player, final ActionList actions,
|
||||||
|
final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public FastPlaceCheck() {
|
public FastPlaceCheck() {
|
||||||
super("fastplace");
|
super("fastplace");
|
||||||
}
|
}
|
||||||
@ -50,11 +59,20 @@ public class FastPlaceCheck extends BlockPlaceCheck {
|
|||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final FastPlaceCheckEvent event = new FastPlaceCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", (int) getData(player).fastPlaceVL);
|
return String.valueOf(Math.round(getData(player).fastPlaceVL));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.blockplace;
|
package fr.neatmonster.nocheatplus.checks.blockplace;
|
||||||
|
|
||||||
import java.util.Locale;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
||||||
|
|
||||||
@ -12,6 +13,14 @@ import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
|||||||
*/
|
*/
|
||||||
public class ProjectileCheck extends BlockPlaceCheck {
|
public class ProjectileCheck extends BlockPlaceCheck {
|
||||||
|
|
||||||
|
public class ProjectileCheckEvent extends BlockPlaceEvent {
|
||||||
|
|
||||||
|
public ProjectileCheckEvent(final ProjectileCheck check, final NCPPlayer player, final ActionList actions,
|
||||||
|
final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ProjectileCheck() {
|
public ProjectileCheck() {
|
||||||
super("projectile");
|
super("projectile");
|
||||||
}
|
}
|
||||||
@ -49,11 +58,20 @@ public class ProjectileCheck extends BlockPlaceCheck {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final ProjectileCheckEvent event = new ProjectileCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", (int) getData(player).projectileVL);
|
return String.valueOf(Math.round(getData(player).projectileVL));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.blockplace;
|
package fr.neatmonster.nocheatplus.checks.blockplace;
|
||||||
|
|
||||||
import java.util.Locale;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.checks.CheckUtils;
|
import fr.neatmonster.nocheatplus.checks.CheckUtils;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
||||||
@ -17,6 +17,13 @@ import fr.neatmonster.nocheatplus.utilities.locations.SimpleLocation;
|
|||||||
*/
|
*/
|
||||||
public class ReachCheck extends BlockPlaceCheck {
|
public class ReachCheck extends BlockPlaceCheck {
|
||||||
|
|
||||||
|
public class ReachCheckEvent extends BlockPlaceEvent {
|
||||||
|
|
||||||
|
public ReachCheckEvent(final ReachCheck check, final NCPPlayer player, final ActionList actions, final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ReachCheck() {
|
public ReachCheck() {
|
||||||
super("reach");
|
super("reach");
|
||||||
}
|
}
|
||||||
@ -57,13 +64,22 @@ public class ReachCheck extends BlockPlaceCheck {
|
|||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final ReachCheckEvent event = new ReachCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", (int) getData(player).reachVL);
|
return String.valueOf(Math.round(getData(player).reachVL));
|
||||||
else if (wildcard == ParameterName.REACHDISTANCE)
|
else if (wildcard == ParameterName.REACHDISTANCE)
|
||||||
return String.format(Locale.US, "%.2f", getData(player).reachdistance);
|
return String.valueOf(Math.round(getData(player).reachdistance));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,9 @@ package fr.neatmonster.nocheatplus.checks.chat;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -10,12 +13,22 @@ import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
|||||||
*/
|
*/
|
||||||
public class ArrivalsLimitCheck extends ChatCheck {
|
public class ArrivalsLimitCheck extends ChatCheck {
|
||||||
|
|
||||||
|
public class ArrivalsLimitCheckEvent extends ChatEvent {
|
||||||
|
|
||||||
|
public ArrivalsLimitCheckEvent(final ArrivalsLimitCheck check, final NCPPlayer player,
|
||||||
|
final ActionList actions, final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Used to know if the cooldown is enabled and since when
|
// Used to know if the cooldown is enabled and since when
|
||||||
private boolean cooldown = false;
|
private boolean cooldown = false;
|
||||||
|
|
||||||
private long cooldownStartTime = 0L;
|
private long cooldownStartTime = 0L;
|
||||||
|
|
||||||
// Used to remember the latest joins;
|
// Used to remember the latest joins;
|
||||||
private long[] joinsTimes = null;
|
private long[] joinsTimes = null;
|
||||||
|
|
||||||
private String[] joinsPlayers = null;
|
private String[] joinsPlayers = null;
|
||||||
|
|
||||||
public ArrivalsLimitCheck() {
|
public ArrivalsLimitCheck() {
|
||||||
@ -41,13 +54,12 @@ public class ArrivalsLimitCheck extends ChatCheck {
|
|||||||
cooldownStartTime = 0L;
|
cooldownStartTime = 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the new players cooldown is active
|
// If the new players cooldown is active...
|
||||||
else if (cooldown)
|
else if (cooldown)
|
||||||
// Kick the player who joined
|
// Kick the player who joined
|
||||||
cancel = executeActions(player, cc.arrivalsLimitActions, 0);
|
cancel = executeActions(player, cc.arrivalsLimitActions, 0);
|
||||||
|
|
||||||
// If more than limit new players have joined in less than limit time
|
|
||||||
else if (System.currentTimeMillis() - joinsTimes[0] < cc.arrivalsLimitTimeframe) {
|
else if (System.currentTimeMillis() - joinsTimes[0] < cc.arrivalsLimitTimeframe) {
|
||||||
|
// ...if more than limit new players have joined in less than limit time
|
||||||
// Enable the new players cooldown
|
// Enable the new players cooldown
|
||||||
cooldown = true;
|
cooldown = true;
|
||||||
cooldownStartTime = System.currentTimeMillis();
|
cooldownStartTime = System.currentTimeMillis();
|
||||||
@ -67,4 +79,13 @@ public class ArrivalsLimitCheck extends ChatCheck {
|
|||||||
|
|
||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final ArrivalsLimitCheckEvent event = new ArrivalsLimitCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ public class ChatConfig extends CheckConfig {
|
|||||||
public final int noPwnageWarnLevel;
|
public final int noPwnageWarnLevel;
|
||||||
public final long noPwnageWarnTimeout;
|
public final long noPwnageWarnTimeout;
|
||||||
public final int noPwnageBanLevel;
|
public final int noPwnageBanLevel;
|
||||||
|
public final String noPwnageKickMessage;
|
||||||
public final ActionList noPwnageActions;
|
public final ActionList noPwnageActions;
|
||||||
|
|
||||||
public final boolean noPwnageMoveCheck;
|
public final boolean noPwnageMoveCheck;
|
||||||
@ -82,6 +83,7 @@ public class ChatConfig extends CheckConfig {
|
|||||||
noPwnageWarnLevel = data.getInt(ConfPaths.CHAT_NOPWNAGE_WARNLEVEL);
|
noPwnageWarnLevel = data.getInt(ConfPaths.CHAT_NOPWNAGE_WARNLEVEL);
|
||||||
noPwnageWarnTimeout = data.getLong(ConfPaths.CHAT_NOPWNAGE_WARNTIMEOUT);
|
noPwnageWarnTimeout = data.getLong(ConfPaths.CHAT_NOPWNAGE_WARNTIMEOUT);
|
||||||
noPwnageBanLevel = data.getInt(ConfPaths.CHAT_NOPWNAGE_BANLEVEL);
|
noPwnageBanLevel = data.getInt(ConfPaths.CHAT_NOPWNAGE_BANLEVEL);
|
||||||
|
noPwnageKickMessage = data.getString(ConfPaths.CHAT_NOPWNAGE_KICKMESSAGE);
|
||||||
noPwnageActions = data.getActionList(ConfPaths.CHAT_NOPWNAGE_ACTIONS, Permissions.CHAT_NOPWNAGE);
|
noPwnageActions = data.getActionList(ConfPaths.CHAT_NOPWNAGE_ACTIONS, Permissions.CHAT_NOPWNAGE);
|
||||||
|
|
||||||
noPwnageMoveCheck = data.getBoolean(ConfPaths.CHAT_NOPWNAGE_MOVE_CHECK);
|
noPwnageMoveCheck = data.getBoolean(ConfPaths.CHAT_NOPWNAGE_MOVE_CHECK);
|
||||||
|
17
src/fr/neatmonster/nocheatplus/checks/chat/ChatEvent.java
Normal file
17
src/fr/neatmonster/nocheatplus/checks/chat/ChatEvent.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package fr.neatmonster.nocheatplus.checks.chat;
|
||||||
|
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
|
import fr.neatmonster.nocheatplus.checks.CheckEvent;
|
||||||
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
|
|
||||||
|
public class ChatEvent extends CheckEvent {
|
||||||
|
|
||||||
|
public ChatEvent(final ChatCheck check, final NCPPlayer player, final ActionList actions, final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChatCheck getCheck() {
|
||||||
|
return (ChatCheck) super.getCheck();
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,6 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.PlayerChatEvent;
|
import org.bukkit.event.player.PlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||||
|
|
||||||
@ -64,7 +63,11 @@ public class ChatListener extends CheckListener {
|
|||||||
|
|
||||||
// First the nopwnage check
|
// First the nopwnage check
|
||||||
if (cc.noPwnageCheck && !player.hasPermission(Permissions.CHAT_NOPWNAGE))
|
if (cc.noPwnageCheck && !player.hasPermission(Permissions.CHAT_NOPWNAGE))
|
||||||
cancelled = noPwnageCheck.check(player);
|
if (noPwnageCheck.check(player, event)) {
|
||||||
|
player.getBukkitPlayer().kickPlayer(cc.noPwnageKickMessage);
|
||||||
|
return;
|
||||||
|
} else
|
||||||
|
cancelled = event.isCancelled();
|
||||||
|
|
||||||
// Second the color check
|
// Second the color check
|
||||||
if (!cancelled && cc.colorCheck && !player.hasPermission(Permissions.CHAT_COLOR))
|
if (!cancelled && cc.colorCheck && !player.hasPermission(Permissions.CHAT_COLOR))
|
||||||
@ -97,7 +100,7 @@ public class ChatListener extends CheckListener {
|
|||||||
|
|
||||||
// Protect the /plugins, /pl, /? commands to prevent players for seeing which plugins are installed
|
// Protect the /plugins, /pl, /? commands to prevent players for seeing which plugins are installed
|
||||||
if (cc.protectPlugins && (command.equals("plugins") || command.equals("pl") || command.equals("?"))
|
if (cc.protectPlugins && (command.equals("plugins") || command.equals("pl") || command.equals("?"))
|
||||||
&& !event.getPlayer().hasPermission(Permissions.ADMIN_PLUGINS)) {
|
&& !player.hasPermission(Permissions.ADMIN_PLUGINS)) {
|
||||||
event.getPlayer().sendMessage(
|
event.getPlayer().sendMessage(
|
||||||
ChatColor.RED + "I'm sorry, but you do not have permission to perform this command. "
|
ChatColor.RED + "I'm sorry, but you do not have permission to perform this command. "
|
||||||
+ "Please contact the server administrators if you believe that this is in error.");
|
+ "Please contact the server administrators if you believe that this is in error.");
|
||||||
@ -109,9 +112,8 @@ public class ChatListener extends CheckListener {
|
|||||||
// to be used by a player who is OP or has the required permissions
|
// to be used by a player who is OP or has the required permissions
|
||||||
if (cc.opByConsoleOnly
|
if (cc.opByConsoleOnly
|
||||||
&& (command.equals("op")
|
&& (command.equals("op")
|
||||||
&& (event.getPlayer().isOp() || event.getPlayer().hasPermission("bukkit.command.op.give")) || command
|
&& (event.getPlayer().isOp() || player.hasPermission("bukkit.command.op.give")) || command
|
||||||
.equals("deop")
|
.equals("deop") && (event.getPlayer().isOp() || player.hasPermission("bukkit.command.op.take")))) {
|
||||||
&& (event.getPlayer().isOp() || event.getPlayer().hasPermission("bukkit.command.op.take")))) {
|
|
||||||
event.getPlayer().sendMessage(ChatColor.RED + "This command can only be executed from the console!");
|
event.getPlayer().sendMessage(ChatColor.RED + "This command can only be executed from the console!");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -122,25 +124,6 @@ public class ChatListener extends CheckListener {
|
|||||||
chat(event);
|
chat(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* We listen to PlayerJoin events for the nopwnage check
|
|
||||||
*
|
|
||||||
* @param event
|
|
||||||
* The PlayerJoin Event
|
|
||||||
*/
|
|
||||||
@EventHandler(
|
|
||||||
priority = EventPriority.LOWEST)
|
|
||||||
public void join(final PlayerJoinEvent event) {
|
|
||||||
|
|
||||||
final NCPPlayer player = NCPPlayer.getPlayer(event.getPlayer());
|
|
||||||
final ChatConfig cc = (ChatConfig) getConfig(player);
|
|
||||||
final ChatData data = (ChatData) getData(player);
|
|
||||||
|
|
||||||
// Check if the join is valid
|
|
||||||
if (cc.noPwnageCheck && !player.hasPermission(Permissions.CHAT_NOPWNAGE))
|
|
||||||
noPwnageCheck.handleJoin(player, data, cc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We listen to PlayerLogin events for the arrivalslimit check
|
* We listen to PlayerLogin events for the arrivalslimit check
|
||||||
*
|
*
|
||||||
@ -148,19 +131,24 @@ public class ChatListener extends CheckListener {
|
|||||||
* The PlayerLogin Event
|
* The PlayerLogin Event
|
||||||
*/
|
*/
|
||||||
@EventHandler(
|
@EventHandler(
|
||||||
ignoreCancelled = true, priority = EventPriority.LOWEST)
|
priority = EventPriority.LOWEST)
|
||||||
public void login(final PlayerLoginEvent event) {
|
public void login(final PlayerLoginEvent event) {
|
||||||
|
|
||||||
// Do not check the players if the server has just restarted
|
|
||||||
if (System.currentTimeMillis() - ManagementFactory.getRuntimeMXBean().getStartTime() < 120000L)
|
|
||||||
return;
|
|
||||||
|
|
||||||
final NCPPlayer player = NCPPlayer.getPlayer(event.getPlayer());
|
final NCPPlayer player = NCPPlayer.getPlayer(event.getPlayer());
|
||||||
final ChatConfig cc = (ChatConfig) getConfig(player);
|
final ChatConfig cc = (ChatConfig) getConfig(player);
|
||||||
final ChatData data = (ChatData) getData(player);
|
final ChatData data = (ChatData) getData(player);
|
||||||
|
|
||||||
// Only check new players, not the regular players
|
/*** NOPWNAGE CHECK ***/
|
||||||
if (System.currentTimeMillis() - event.getPlayer().getFirstPlayed() > cc.arrivalsLimitNewTime)
|
// Check if the join is legit
|
||||||
|
if (cc.noPwnageCheck && !player.hasPermission(Permissions.CHAT_NOPWNAGE))
|
||||||
|
if (noPwnageCheck.handleJoin(player, data, cc))
|
||||||
|
event.disallow(Result.KICK_OTHER, cc.noPwnageKickMessage);
|
||||||
|
|
||||||
|
/*** ARRIVALSLIMIT CHECK ***/
|
||||||
|
// Do not check the players if the event is already cancelled,
|
||||||
|
// if the server has just restarted or if it is a regular player
|
||||||
|
if (event.getResult() == Result.KICK_OTHER
|
||||||
|
|| System.currentTimeMillis() - ManagementFactory.getRuntimeMXBean().getStartTime() < 120000L
|
||||||
|
|| System.currentTimeMillis() - event.getPlayer().getFirstPlayed() > cc.arrivalsLimitNewTime)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (cc.arrivalsLimitCheck && arrivalsLimitCheck.check(player, data, cc))
|
if (cc.arrivalsLimitCheck && arrivalsLimitCheck.check(player, data, cc))
|
||||||
|
@ -1,13 +1,21 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.chat;
|
package fr.neatmonster.nocheatplus.checks.chat;
|
||||||
|
|
||||||
import java.util.Locale;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
||||||
|
|
||||||
public class ColorCheck extends ChatCheck {
|
public class ColorCheck extends ChatCheck {
|
||||||
|
|
||||||
|
public class ColorCheckEvent extends ChatEvent {
|
||||||
|
|
||||||
|
public ColorCheckEvent(final ColorCheck check, final NCPPlayer player, final ActionList actions, final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ColorCheck() {
|
public ColorCheck() {
|
||||||
super("color");
|
super("color");
|
||||||
}
|
}
|
||||||
@ -32,11 +40,20 @@ public class ColorCheck extends ChatCheck {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final ColorCheckEvent event = new ColorCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", getData(player).colorVL);
|
return String.valueOf(Math.round(getData(player).colorVL));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,13 @@ import java.util.Random;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerChatEvent;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.config.ConfPaths;
|
import fr.neatmonster.nocheatplus.config.ConfPaths;
|
||||||
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.utilities.Colors;
|
|
||||||
import fr.neatmonster.nocheatplus.utilities.locations.SimpleLocation;
|
import fr.neatmonster.nocheatplus.utilities.locations.SimpleLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,10 +19,19 @@ import fr.neatmonster.nocheatplus.utilities.locations.SimpleLocation;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class NoPwnageCheck extends ChatCheck {
|
public class NoPwnageCheck extends ChatCheck {
|
||||||
|
public class NoPwnageCheckEvent extends ChatEvent {
|
||||||
|
|
||||||
|
public NoPwnageCheckEvent(final NoPwnageCheck check, final NCPPlayer player, final ActionList actions,
|
||||||
|
final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String lastBanCausingMessage;
|
private String lastBanCausingMessage;
|
||||||
private long lastBanCausingMessageTime;
|
private long lastBanCausingMessageTime;
|
||||||
private String lastGlobalMessage;
|
private String lastGlobalMessage;
|
||||||
private long lastGlobalMessageTime;
|
private long lastGlobalMessageTime;
|
||||||
|
|
||||||
private int globalRepeated;
|
private int globalRepeated;
|
||||||
|
|
||||||
private final Random random = new Random();
|
private final Random random = new Random();
|
||||||
@ -40,16 +50,15 @@ public class NoPwnageCheck extends ChatCheck {
|
|||||||
public boolean check(final NCPPlayer player, final Object... args) {
|
public boolean check(final NCPPlayer player, final Object... args) {
|
||||||
final ChatConfig cc = getConfig(player);
|
final ChatConfig cc = getConfig(player);
|
||||||
final ChatData data = getData(player);
|
final ChatData data = getData(player);
|
||||||
|
final PlayerChatEvent event = (PlayerChatEvent) args[0];
|
||||||
|
|
||||||
boolean cancel = false;
|
boolean cancel = false;
|
||||||
|
|
||||||
if (data.commandsHaveBeenRun || !player.getBukkitPlayer().isOnline())
|
// If the player has filled out the captcha, return
|
||||||
return false;
|
if (data.commandsHaveBeenRun || !player.getBukkitPlayer().isOnline() || cc.noPwnageCaptchaCheck
|
||||||
|
&& data.captchaDone)
|
||||||
// Player is supposed to fill out a captcha
|
|
||||||
if (cc.noPwnageCaptchaCheck && data.captchaDone)
|
|
||||||
// His reply was valid, he isn't a spambot
|
// His reply was valid, he isn't a spambot
|
||||||
return false;
|
return cancel;
|
||||||
|
|
||||||
if (cc.noPwnageCaptchaCheck && data.captchaStarted) {
|
if (cc.noPwnageCaptchaCheck && data.captchaStarted) {
|
||||||
// Correct answer?
|
// Correct answer?
|
||||||
@ -62,14 +71,17 @@ public class NoPwnageCheck extends ChatCheck {
|
|||||||
|
|
||||||
// He failed too much times
|
// He failed too much times
|
||||||
if (data.captchaTries > cc.noPwnageCaptchaTries)
|
if (data.captchaTries > cc.noPwnageCaptchaTries)
|
||||||
if (player.getBukkitPlayer().isOnline())
|
if (player.getBukkitPlayer().isOnline()) {
|
||||||
// Execute the commands, it's a spambot
|
// Execute the commands, it's a spambot
|
||||||
runCommands(player, "failed captcha", data, cc);
|
data.reason = "failed captcha";
|
||||||
|
cancel = executeActions(player, cc.noPwnageActions, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Increment the number of times he replied
|
// Increment the number of times he replied
|
||||||
data.captchaTries++;
|
data.captchaTries++;
|
||||||
}
|
}
|
||||||
return true;
|
event.setCancelled(true);
|
||||||
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do some pre-testing for the next check
|
// Do some pre-testing for the next check
|
||||||
@ -148,7 +160,7 @@ public class NoPwnageCheck extends ChatCheck {
|
|||||||
data.captchaAnswer = captcha;
|
data.captchaAnswer = captcha;
|
||||||
data.captchaQuestion = ChatColor.RED + "Please type '" + ChatColor.GOLD + captcha + ChatColor.RED
|
data.captchaQuestion = ChatColor.RED + "Please type '" + ChatColor.GOLD + captcha + ChatColor.RED
|
||||||
+ "' to continue sending messages/commands.";
|
+ "' to continue sending messages/commands.";
|
||||||
cancel = true;
|
event.setCancelled(true);
|
||||||
player.sendMessage(data.captchaQuestion);
|
player.sendMessage(data.captchaQuestion);
|
||||||
} else if (player.getBukkitPlayer().isOnline()) {
|
} else if (player.getBukkitPlayer().isOnline()) {
|
||||||
// Execute the commands, it's a spambot
|
// Execute the commands, it's a spambot
|
||||||
@ -157,8 +169,9 @@ public class NoPwnageCheck extends ChatCheck {
|
|||||||
data.lastWarningTime = now;
|
data.lastWarningTime = now;
|
||||||
if (cc.noPwnageWarnOthers)
|
if (cc.noPwnageWarnOthers)
|
||||||
warnOthers(player);
|
warnOthers(player);
|
||||||
runCommands(player, "spambotlike behaviour", data, cc);
|
data.reason = "spambotlike behaviour";
|
||||||
return true;
|
event.setCancelled(true);
|
||||||
|
return executeActions(player, cc.noPwnageActions, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remember his message and some other data
|
// Remember his message and some other data
|
||||||
@ -171,6 +184,18 @@ public class NoPwnageCheck extends ChatCheck {
|
|||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
getData(player).ip = player.getBukkitPlayer().getAddress().toString().substring(1).split(":")[0];
|
||||||
|
getData(player).commandsHaveBeenRun = true;
|
||||||
|
|
||||||
|
final NoPwnageCheckEvent event = new NoPwnageCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is used to generate a captcha
|
* This function is used to generate a captcha
|
||||||
*
|
*
|
||||||
@ -200,24 +225,26 @@ public class NoPwnageCheck extends ChatCheck {
|
|||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleJoin(final NCPPlayer player, final ChatData data, final ChatConfig cc) {
|
public boolean handleJoin(final NCPPlayer player, final ChatData data, final ChatConfig cc) {
|
||||||
|
boolean cancel = false;
|
||||||
final long now = System.currentTimeMillis();
|
final long now = System.currentTimeMillis();
|
||||||
|
|
||||||
// Relog check (cf. documentation)
|
// Re-login check (cf. documentation)
|
||||||
if (cc.noPwnageRelogCheck && now - data.leaveTime <= cc.noPwnageRelogTime) {
|
if (cc.noPwnageRelogCheck && now - data.leaveTime <= cc.noPwnageRelogTime) {
|
||||||
if (now - data.lastRelogWarningTime >= cc.noPwnageRelogTimeout)
|
if (now - data.lastRelogWarningTime >= cc.noPwnageRelogTimeout)
|
||||||
data.relogWarnings = 0;
|
data.relogWarnings = 0;
|
||||||
|
|
||||||
if (data.relogWarnings < cc.noPwnageRelogWarnings) {
|
if (data.relogWarnings < cc.noPwnageRelogWarnings) {
|
||||||
player.sendMessage(Colors.replaceColors(ConfigManager.getConfigFile().getString(
|
player.sendMessage(replaceColors(ConfigManager.getConfigFile().getString(ConfPaths.LOGGING_PREFIX))
|
||||||
ConfPaths.LOGGING_PREFIX))
|
|
||||||
+ ChatColor.DARK_RED
|
+ ChatColor.DARK_RED
|
||||||
+ "You relogged really fast! If you keep doing that, you're going to be banned.");
|
+ "You relogged really fast! If you keep doing that, you're going to be banned.");
|
||||||
data.lastRelogWarningTime = now;
|
data.lastRelogWarningTime = now;
|
||||||
data.relogWarnings++;
|
data.relogWarnings++;
|
||||||
} else if (now - data.lastRelogWarningTime < cc.noPwnageRelogTimeout)
|
} else if (now - data.lastRelogWarningTime < cc.noPwnageRelogTimeout) {
|
||||||
// Run the commands, it's a spambot
|
// Run the commands, it's a spambot
|
||||||
runCommands(player, "relogged too fast", data, cc);
|
data.reason = "relogged too fast";
|
||||||
|
cancel = executeActions(player, cc.noPwnageActions, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remember his location
|
// Remember his location
|
||||||
@ -227,6 +254,8 @@ public class NoPwnageCheck extends ChatCheck {
|
|||||||
data.joinTime = now;
|
data.joinTime = now;
|
||||||
|
|
||||||
data.commandsHaveBeenRun = false;
|
data.commandsHaveBeenRun = false;
|
||||||
|
|
||||||
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -252,28 +281,6 @@ public class NoPwnageCheck extends ChatCheck {
|
|||||||
return mi;
|
return mi;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This function executes the commands defined in the configuration
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* The Player
|
|
||||||
* @param reason
|
|
||||||
* The reason
|
|
||||||
* @param data
|
|
||||||
* The ChatData
|
|
||||||
* @param cc
|
|
||||||
* The ChatConfig
|
|
||||||
*/
|
|
||||||
private void runCommands(final NCPPlayer player, final String reason, final ChatData data, final ChatConfig cc) {
|
|
||||||
data.reason = reason;
|
|
||||||
data.ip = player.getBukkitPlayer().getAddress().toString().substring(1).split(":")[0];
|
|
||||||
|
|
||||||
if (player.getBukkitPlayer().isOnline()) {
|
|
||||||
data.commandsHaveBeenRun = true;
|
|
||||||
executeActions(player, cc.noPwnageActions, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is used to know if two messages are similar
|
* This function is used to know if two messages are similar
|
||||||
*
|
*
|
||||||
@ -352,7 +359,7 @@ public class NoPwnageCheck extends ChatCheck {
|
|||||||
* The Player
|
* The Player
|
||||||
*/
|
*/
|
||||||
private void warnPlayer(final NCPPlayer player) {
|
private void warnPlayer(final NCPPlayer player) {
|
||||||
player.sendMessage(Colors.replaceColors(ConfigManager.getConfigFile().getString(ConfPaths.LOGGING_PREFIX))
|
player.sendMessage(replaceColors(ConfigManager.getConfigFile().getString(ConfPaths.LOGGING_PREFIX))
|
||||||
+ ChatColor.DARK_RED
|
+ ChatColor.DARK_RED
|
||||||
+ "Our system has detected unusual bot activities coming from you. Please be careful with what you say. DON'T repeat what you just said either, unless you want to be banned.");
|
+ "Our system has detected unusual bot activities coming from you. Please be careful with what you say. DON'T repeat what you just said either, unless you want to be banned.");
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.fight;
|
package fr.neatmonster.nocheatplus.checks.fight;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import net.minecraft.server.EntityPlayer;
|
import net.minecraft.server.EntityPlayer;
|
||||||
import net.minecraft.server.MobEffectList;
|
import net.minecraft.server.MobEffectList;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.checks.CheckUtils;
|
import fr.neatmonster.nocheatplus.checks.CheckUtils;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Permissions;
|
import fr.neatmonster.nocheatplus.players.informations.Permissions;
|
||||||
@ -18,6 +18,14 @@ import fr.neatmonster.nocheatplus.utilities.locations.PreciseLocation;
|
|||||||
|
|
||||||
public class CriticalCheck extends FightCheck {
|
public class CriticalCheck extends FightCheck {
|
||||||
|
|
||||||
|
public class CriticalCheckEvent extends FightEvent {
|
||||||
|
|
||||||
|
public CriticalCheckEvent(final CriticalCheck check, final NCPPlayer player, final ActionList actions,
|
||||||
|
final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public CriticalCheck() {
|
public CriticalCheck() {
|
||||||
super("critical", Permissions.FIGHT_CRITICAL);
|
super("critical", Permissions.FIGHT_CRITICAL);
|
||||||
}
|
}
|
||||||
@ -79,11 +87,20 @@ public class CriticalCheck extends FightCheck {
|
|||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final CriticalCheckEvent event = new CriticalCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", getData(player).criticalVL);
|
return String.valueOf(Math.round(getData(player).criticalVL));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.fight;
|
package fr.neatmonster.nocheatplus.checks.fight;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import net.minecraft.server.Entity;
|
import net.minecraft.server.Entity;
|
||||||
import net.minecraft.server.EntityComplex;
|
import net.minecraft.server.EntityComplex;
|
||||||
import net.minecraft.server.EntityComplexPart;
|
import net.minecraft.server.EntityComplexPart;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.checks.CheckUtils;
|
import fr.neatmonster.nocheatplus.checks.CheckUtils;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Permissions;
|
import fr.neatmonster.nocheatplus.players.informations.Permissions;
|
||||||
@ -19,6 +21,14 @@ import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
|||||||
*/
|
*/
|
||||||
public class DirectionCheck extends FightCheck {
|
public class DirectionCheck extends FightCheck {
|
||||||
|
|
||||||
|
public class DirectionCheckEvent extends FightEvent {
|
||||||
|
|
||||||
|
public DirectionCheckEvent(final DirectionCheck check, final NCPPlayer player, final ActionList actions,
|
||||||
|
final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public DirectionCheck() {
|
public DirectionCheck() {
|
||||||
super("direction", Permissions.FIGHT_DIRECTION);
|
super("direction", Permissions.FIGHT_DIRECTION);
|
||||||
}
|
}
|
||||||
@ -90,11 +100,20 @@ public class DirectionCheck extends FightCheck {
|
|||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final DirectionCheckEvent event = new DirectionCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", (int) getData(player).directionVL);
|
return String.valueOf(Math.round(getData(player).directionVL));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
17
src/fr/neatmonster/nocheatplus/checks/fight/FightEvent.java
Normal file
17
src/fr/neatmonster/nocheatplus/checks/fight/FightEvent.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package fr.neatmonster.nocheatplus.checks.fight;
|
||||||
|
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
|
import fr.neatmonster.nocheatplus.checks.CheckEvent;
|
||||||
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
|
|
||||||
|
public class FightEvent extends CheckEvent {
|
||||||
|
|
||||||
|
public FightEvent(final FightCheck check, final NCPPlayer player, final ActionList actions, final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FightCheck getCheck() {
|
||||||
|
return (FightCheck) super.getCheck();
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,5 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.fight;
|
package fr.neatmonster.nocheatplus.checks.fight;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import net.minecraft.server.EntityPlayer;
|
import net.minecraft.server.EntityPlayer;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -9,6 +7,7 @@ import org.bukkit.craftbukkit.entity.CraftPlayer;
|
|||||||
|
|
||||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Permissions;
|
import fr.neatmonster.nocheatplus.players.informations.Permissions;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Statistics;
|
import fr.neatmonster.nocheatplus.players.informations.Statistics;
|
||||||
@ -20,6 +19,14 @@ import fr.neatmonster.nocheatplus.players.informations.Statistics;
|
|||||||
*/
|
*/
|
||||||
public class GodmodeCheck extends FightCheck {
|
public class GodmodeCheck extends FightCheck {
|
||||||
|
|
||||||
|
public class GodmodeCheckEvent extends FightEvent {
|
||||||
|
|
||||||
|
public GodmodeCheckEvent(final GodmodeCheck check, final NCPPlayer player, final ActionList actions,
|
||||||
|
final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public GodmodeCheck() {
|
public GodmodeCheck() {
|
||||||
super("godmode", Permissions.FIGHT_GODMODE);
|
super("godmode", Permissions.FIGHT_GODMODE);
|
||||||
}
|
}
|
||||||
@ -112,11 +119,20 @@ public class GodmodeCheck extends FightCheck {
|
|||||||
} catch (final Exception e) {}
|
} catch (final Exception e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final GodmodeCheckEvent event = new GodmodeCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", (int) getData(player).godmodeVL);
|
return String.valueOf(Math.round((int) getData(player).godmodeVL));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.fight;
|
package fr.neatmonster.nocheatplus.checks.fight;
|
||||||
|
|
||||||
import java.util.Locale;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Permissions;
|
import fr.neatmonster.nocheatplus.players.informations.Permissions;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Statistics;
|
import fr.neatmonster.nocheatplus.players.informations.Statistics;
|
||||||
@ -14,6 +15,14 @@ import fr.neatmonster.nocheatplus.players.informations.Statistics;
|
|||||||
*/
|
*/
|
||||||
public class InstanthealCheck extends FightCheck {
|
public class InstanthealCheck extends FightCheck {
|
||||||
|
|
||||||
|
public class InstanthealCheckEvent extends FightEvent {
|
||||||
|
|
||||||
|
public InstanthealCheckEvent(final InstanthealCheck check, final NCPPlayer player, final ActionList actions,
|
||||||
|
final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public InstanthealCheck() {
|
public InstanthealCheck() {
|
||||||
super("instantheal", Permissions.FIGHT_INSTANTHEAL);
|
super("instantheal", Permissions.FIGHT_INSTANTHEAL);
|
||||||
}
|
}
|
||||||
@ -63,11 +72,20 @@ public class InstanthealCheck extends FightCheck {
|
|||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final InstanthealCheckEvent event = new InstanthealCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", (int) getData(player).instanthealVL);
|
return String.valueOf(Math.round(getData(player).instanthealVL));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.fight;
|
package fr.neatmonster.nocheatplus.checks.fight;
|
||||||
|
|
||||||
import java.util.Locale;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Permissions;
|
import fr.neatmonster.nocheatplus.players.informations.Permissions;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
||||||
@ -14,6 +15,14 @@ import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
|||||||
*/
|
*/
|
||||||
public class KnockbackCheck extends FightCheck {
|
public class KnockbackCheck extends FightCheck {
|
||||||
|
|
||||||
|
public class KnockbackCheckEvent extends FightEvent {
|
||||||
|
|
||||||
|
public KnockbackCheckEvent(final KnockbackCheck check, final NCPPlayer player, final ActionList actions,
|
||||||
|
final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public KnockbackCheck() {
|
public KnockbackCheck() {
|
||||||
super("knockback", Permissions.FIGHT_KNOCKBACK);
|
super("knockback", Permissions.FIGHT_KNOCKBACK);
|
||||||
}
|
}
|
||||||
@ -47,11 +56,20 @@ public class KnockbackCheck extends FightCheck {
|
|||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final KnockbackCheckEvent event = new KnockbackCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", (int) getData(player).knockbackVL);
|
return String.valueOf(Math.round(getData(player).knockbackVL));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.fight;
|
package fr.neatmonster.nocheatplus.checks.fight;
|
||||||
|
|
||||||
import java.util.Locale;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Permissions;
|
import fr.neatmonster.nocheatplus.players.informations.Permissions;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
||||||
@ -14,6 +15,14 @@ import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
|||||||
*/
|
*/
|
||||||
public class NoswingCheck extends FightCheck {
|
public class NoswingCheck extends FightCheck {
|
||||||
|
|
||||||
|
public class NoswingCheckEvent extends FightEvent {
|
||||||
|
|
||||||
|
public NoswingCheckEvent(final NoswingCheck check, final NCPPlayer player, final ActionList actions,
|
||||||
|
final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public NoswingCheck() {
|
public NoswingCheck() {
|
||||||
super("noswing", Permissions.FIGHT_NOSWING);
|
super("noswing", Permissions.FIGHT_NOSWING);
|
||||||
}
|
}
|
||||||
@ -43,11 +52,20 @@ public class NoswingCheck extends FightCheck {
|
|||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final NoswingCheckEvent event = new NoswingCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", (int) getData(player).noswingVL);
|
return String.valueOf(Math.round(getData(player).noswingVL));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.fight;
|
package fr.neatmonster.nocheatplus.checks.fight;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import net.minecraft.server.Entity;
|
import net.minecraft.server.Entity;
|
||||||
import net.minecraft.server.EntityComplex;
|
import net.minecraft.server.EntityComplex;
|
||||||
import net.minecraft.server.EntityComplexPart;
|
import net.minecraft.server.EntityComplexPart;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.checks.CheckUtils;
|
import fr.neatmonster.nocheatplus.checks.CheckUtils;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Permissions;
|
import fr.neatmonster.nocheatplus.players.informations.Permissions;
|
||||||
@ -19,6 +21,13 @@ import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
|||||||
*/
|
*/
|
||||||
public class ReachCheck extends FightCheck {
|
public class ReachCheck extends FightCheck {
|
||||||
|
|
||||||
|
public class ReachCheckEvent extends FightEvent {
|
||||||
|
|
||||||
|
public ReachCheckEvent(final ReachCheck check, final NCPPlayer player, final ActionList actions, final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ReachCheck() {
|
public ReachCheck() {
|
||||||
super("reach", Permissions.FIGHT_REACH);
|
super("reach", Permissions.FIGHT_REACH);
|
||||||
}
|
}
|
||||||
@ -82,11 +91,20 @@ public class ReachCheck extends FightCheck {
|
|||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final ReachCheckEvent event = new ReachCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", (int) getData(player).reachVL);
|
return String.valueOf(Math.round(getData(player).reachVL));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.fight;
|
package fr.neatmonster.nocheatplus.checks.fight;
|
||||||
|
|
||||||
import java.util.Locale;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Permissions;
|
import fr.neatmonster.nocheatplus.players.informations.Permissions;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
||||||
@ -15,6 +16,13 @@ import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
|||||||
*/
|
*/
|
||||||
public class SpeedCheck extends FightCheck {
|
public class SpeedCheck extends FightCheck {
|
||||||
|
|
||||||
|
public class SpeedCheckEvent extends FightEvent {
|
||||||
|
|
||||||
|
public SpeedCheckEvent(final SpeedCheck check, final NCPPlayer player, final ActionList actions, final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public SpeedCheck() {
|
public SpeedCheck() {
|
||||||
super("speed", Permissions.FIGHT_SPEED);
|
super("speed", Permissions.FIGHT_SPEED);
|
||||||
}
|
}
|
||||||
@ -54,13 +62,22 @@ public class SpeedCheck extends FightCheck {
|
|||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final SpeedCheckEvent event = new SpeedCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", getData(player).speedVL);
|
return String.valueOf(Math.round(getData(player).speedVL));
|
||||||
else if (wildcard == ParameterName.LIMIT)
|
else if (wildcard == ParameterName.LIMIT)
|
||||||
return String.format(Locale.US, "%d", getConfig(player).speedAttackLimit);
|
return String.valueOf(Math.round(getConfig(player).speedAttackLimit));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.inventory;
|
package fr.neatmonster.nocheatplus.checks.inventory;
|
||||||
|
|
||||||
import java.util.Locale;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
||||||
|
|
||||||
@ -13,6 +14,13 @@ import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
|||||||
*/
|
*/
|
||||||
public class DropCheck extends InventoryCheck {
|
public class DropCheck extends InventoryCheck {
|
||||||
|
|
||||||
|
public class DropCheckEvent extends InventoryEvent {
|
||||||
|
|
||||||
|
public DropCheckEvent(final DropCheck check, final NCPPlayer player, final ActionList actions, final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public DropCheck() {
|
public DropCheck() {
|
||||||
super("drop");
|
super("drop");
|
||||||
}
|
}
|
||||||
@ -52,11 +60,20 @@ public class DropCheck extends InventoryCheck {
|
|||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final DropCheckEvent event = new DropCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", getData(player).dropVL);
|
return String.valueOf(Math.round(getData(player).dropVL));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.inventory;
|
package fr.neatmonster.nocheatplus.checks.inventory;
|
||||||
|
|
||||||
import java.util.Locale;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
||||||
|
|
||||||
@ -14,6 +14,14 @@ import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
|||||||
*/
|
*/
|
||||||
public class InstantBowCheck extends InventoryCheck {
|
public class InstantBowCheck extends InventoryCheck {
|
||||||
|
|
||||||
|
public class InstantBowCheckEvent extends InventoryEvent {
|
||||||
|
|
||||||
|
public InstantBowCheckEvent(final InstantBowCheck check, final NCPPlayer player, final ActionList actions,
|
||||||
|
final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public InstantBowCheck() {
|
public InstantBowCheck() {
|
||||||
super("instantbow");
|
super("instantbow");
|
||||||
}
|
}
|
||||||
@ -54,11 +62,20 @@ public class InstantBowCheck extends InventoryCheck {
|
|||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final InstantBowCheckEvent event = new InstantBowCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", getData(player).instantBowVL);
|
return String.valueOf(Math.round(getData(player).instantBowVL));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.inventory;
|
package fr.neatmonster.nocheatplus.checks.inventory;
|
||||||
|
|
||||||
import java.util.Locale;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
||||||
|
|
||||||
@ -13,6 +13,14 @@ import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
|||||||
*/
|
*/
|
||||||
public class InstantEatCheck extends InventoryCheck {
|
public class InstantEatCheck extends InventoryCheck {
|
||||||
|
|
||||||
|
public class InstantEatCheckEvent extends InventoryEvent {
|
||||||
|
|
||||||
|
public InstantEatCheckEvent(final InstantEatCheck check, final NCPPlayer player, final ActionList actions,
|
||||||
|
final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public InstantEatCheck() {
|
public InstantEatCheck() {
|
||||||
super("instanteat");
|
super("instanteat");
|
||||||
}
|
}
|
||||||
@ -53,11 +61,20 @@ public class InstantEatCheck extends InventoryCheck {
|
|||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final InstantEatCheckEvent event = new InstantEatCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", (int) getData(player).instantEatVL);
|
return String.valueOf(Math.round(getData(player).instantEatVL));
|
||||||
else if (wildcard == ParameterName.FOOD)
|
else if (wildcard == ParameterName.FOOD)
|
||||||
return getData(player).foodMaterial.toString();
|
return getData(player).foodMaterial.toString();
|
||||||
else
|
else
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package fr.neatmonster.nocheatplus.checks.inventory;
|
||||||
|
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
|
import fr.neatmonster.nocheatplus.checks.CheckEvent;
|
||||||
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
|
|
||||||
|
public class InventoryEvent extends CheckEvent {
|
||||||
|
|
||||||
|
public InventoryEvent(final InventoryCheck check, final NCPPlayer player, final ActionList actions, final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InventoryCheck getCheck() {
|
||||||
|
return (InventoryCheck) super.getCheck();
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,9 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.moving;
|
package fr.neatmonster.nocheatplus.checks.moving;
|
||||||
|
|
||||||
import java.util.Locale;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
||||||
import fr.neatmonster.nocheatplus.utilities.locations.PreciseLocation;
|
import fr.neatmonster.nocheatplus.utilities.locations.PreciseLocation;
|
||||||
@ -15,6 +16,14 @@ import fr.neatmonster.nocheatplus.utilities.locations.PreciseLocation;
|
|||||||
*/
|
*/
|
||||||
public class FlyingCheck extends MovingCheck {
|
public class FlyingCheck extends MovingCheck {
|
||||||
|
|
||||||
|
public class FlyingCheckEvent extends MovingEvent {
|
||||||
|
|
||||||
|
public FlyingCheckEvent(final FlyingCheck check, final NCPPlayer player, final ActionList actions,
|
||||||
|
final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Determined by trial and error, the flying movement speed of the creative
|
// Determined by trial and error, the flying movement speed of the creative
|
||||||
// mode
|
// mode
|
||||||
private static final double creativeSpeed = 0.60D;
|
private static final double creativeSpeed = 0.60D;
|
||||||
@ -107,7 +116,7 @@ public class FlyingCheck extends MovingCheck {
|
|||||||
result = resultHoriz + resultVert;
|
result = resultHoriz + resultVert;
|
||||||
|
|
||||||
// The player went to far, either horizontal or vertical
|
// The player went to far, either horizontal or vertical
|
||||||
if (result > 0 && !data.velocityChanged) {
|
if (result > 0) {
|
||||||
|
|
||||||
// Increment violation counter and statistics
|
// Increment violation counter and statistics
|
||||||
data.runflyVL += result;
|
data.runflyVL += result;
|
||||||
@ -136,11 +145,20 @@ public class FlyingCheck extends MovingCheck {
|
|||||||
return newToLocation;
|
return newToLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final FlyingCheckEvent event = new FlyingCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", (int) getData(player).runflyVL);
|
return String.valueOf(Math.round(getData(player).runflyVL));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.moving;
|
package fr.neatmonster.nocheatplus.checks.moving;
|
||||||
|
|
||||||
import java.util.Locale;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
||||||
import fr.neatmonster.nocheatplus.utilities.locations.PreciseLocation;
|
import fr.neatmonster.nocheatplus.utilities.locations.PreciseLocation;
|
||||||
@ -19,6 +20,14 @@ import fr.neatmonster.nocheatplus.utilities.locations.PreciseLocation;
|
|||||||
*/
|
*/
|
||||||
public class MorePacketsCheck extends MovingCheck {
|
public class MorePacketsCheck extends MovingCheck {
|
||||||
|
|
||||||
|
public class MorePacketsCheckEvent extends MovingEvent {
|
||||||
|
|
||||||
|
public MorePacketsCheckEvent(final MorePacketsCheck check, final NCPPlayer player, final ActionList actions,
|
||||||
|
final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 20 would be for perfect internet connections, 22 is good enough
|
// 20 would be for perfect internet connections, 22 is good enough
|
||||||
private final static int packetsPerTimeframe = 22;
|
private final static int packetsPerTimeframe = 22;
|
||||||
|
|
||||||
@ -93,13 +102,22 @@ public class MorePacketsCheck extends MovingCheck {
|
|||||||
return newToLocation;
|
return newToLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final MorePacketsCheckEvent event = new MorePacketsCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", (int) getData(player).morePacketsVL);
|
return String.valueOf(Math.round(getData(player).morePacketsVL));
|
||||||
else if (wildcard == ParameterName.PACKETS)
|
else if (wildcard == ParameterName.PACKETS)
|
||||||
return String.format(Locale.US, "%d", getData(player).packets);
|
return String.valueOf(Math.round(getData(player).packets));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.moving;
|
package fr.neatmonster.nocheatplus.checks.moving;
|
||||||
|
|
||||||
import java.util.Locale;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
||||||
|
|
||||||
@ -17,6 +18,14 @@ import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
|||||||
*/
|
*/
|
||||||
public class MorePacketsVehicleCheck extends MovingCheck {
|
public class MorePacketsVehicleCheck extends MovingCheck {
|
||||||
|
|
||||||
|
public class MorePacketsVehicleCheckEvent extends MovingEvent {
|
||||||
|
|
||||||
|
public MorePacketsVehicleCheckEvent(final MorePacketsVehicleCheck check, final NCPPlayer player,
|
||||||
|
final ActionList actions, final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 20 would be for perfect internet connections, 22 is good enough
|
// 20 would be for perfect internet connections, 22 is good enough
|
||||||
private final static int packetsPerTimeframe = 22;
|
private final static int packetsPerTimeframe = 22;
|
||||||
|
|
||||||
@ -81,13 +90,23 @@ public class MorePacketsVehicleCheck extends MovingCheck {
|
|||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final MorePacketsVehicleCheckEvent event = new MorePacketsVehicleCheckEvent(this, player, actionList,
|
||||||
|
violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", (int) getData(player).morePacketsVehicleVL);
|
return String.valueOf(Math.round(getData(player).morePacketsVehicleVL));
|
||||||
else if (wildcard == ParameterName.PACKETS)
|
else if (wildcard == ParameterName.PACKETS)
|
||||||
return String.format(Locale.US, "%d", getData(player).packetsVehicle);
|
return String.valueOf(Math.round(getData(player).packetsVehicle));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,11 @@ public class MovingConfig extends CheckConfig {
|
|||||||
|
|
||||||
public final boolean runflyCheck;
|
public final boolean runflyCheck;
|
||||||
public final double jumpheight;
|
public final double jumpheight;
|
||||||
public final int maxCooldown;
|
|
||||||
public final boolean identifyCreativeMode;
|
public final boolean identifyCreativeMode;
|
||||||
public final double walkingSpeedLimit;
|
public final double walkingSpeedLimit;
|
||||||
public final double sprintingSpeedLimit;
|
public final double sprintingSpeedLimit;
|
||||||
public final double swimmingSpeedLimit;
|
public final double swimmingSpeedLimit;
|
||||||
|
public final double verticalSwimmingSpeedLimit;
|
||||||
public final boolean sneakingCheck;
|
public final boolean sneakingCheck;
|
||||||
public final double sneakingSpeedLimit;
|
public final double sneakingSpeedLimit;
|
||||||
public final boolean blockingCheck;
|
public final boolean blockingCheck;
|
||||||
@ -35,7 +35,7 @@ public class MovingConfig extends CheckConfig {
|
|||||||
public final ActionList flyingActions;
|
public final ActionList flyingActions;
|
||||||
|
|
||||||
public final boolean nofallCheck;
|
public final boolean nofallCheck;
|
||||||
public final boolean nofallaggressive;
|
public final boolean nofallAggressive;
|
||||||
public final float nofallMultiplier;
|
public final float nofallMultiplier;
|
||||||
public final ActionList nofallActions;
|
public final ActionList nofallActions;
|
||||||
|
|
||||||
@ -59,12 +59,14 @@ public class MovingConfig extends CheckConfig {
|
|||||||
final int walkspeed = data.getInt(ConfPaths.MOVING_RUNFLY_WALKSPEED, 100);
|
final int walkspeed = data.getInt(ConfPaths.MOVING_RUNFLY_WALKSPEED, 100);
|
||||||
final int sprintspeed = data.getInt(ConfPaths.MOVING_RUNFLY_SPRINTSPEED, 100);
|
final int sprintspeed = data.getInt(ConfPaths.MOVING_RUNFLY_SPRINTSPEED, 100);
|
||||||
final int swimspeed = data.getInt(ConfPaths.MOVING_RUNFLY_SWIMSPEED, 100);
|
final int swimspeed = data.getInt(ConfPaths.MOVING_RUNFLY_SWIMSPEED, 100);
|
||||||
|
final int vertSwimSpeed = data.getInt(ConfPaths.MOVING_RUNFLY_VERTICALSWIMSPEED, 100);
|
||||||
final int sneakspeed = data.getInt(ConfPaths.MOVING_RUNFLY_SNEAKSPEED, 100);
|
final int sneakspeed = data.getInt(ConfPaths.MOVING_RUNFLY_SNEAKSPEED, 100);
|
||||||
final int blockspeed = data.getInt(ConfPaths.MOVING_RUNFLY_BLOCKSPEED, 100);
|
final int blockspeed = data.getInt(ConfPaths.MOVING_RUNFLY_BLOCKSPEED, 100);
|
||||||
final int cobWebSpeed = data.getInt(ConfPaths.MOVING_RUNFLY_COBWEBSPEED, 100);
|
final int cobWebSpeed = data.getInt(ConfPaths.MOVING_RUNFLY_COBWEBSPEED, 100);
|
||||||
walkingSpeedLimit = 0.22 * walkspeed / 100D;
|
walkingSpeedLimit = 0.22 * walkspeed / 100D;
|
||||||
sprintingSpeedLimit = 0.35 * sprintspeed / 100D;
|
sprintingSpeedLimit = 0.35 * sprintspeed / 100D;
|
||||||
swimmingSpeedLimit = 0.18 * swimspeed / 100D;
|
swimmingSpeedLimit = 0.18 * swimspeed / 100D;
|
||||||
|
verticalSwimmingSpeedLimit = 0.43 * vertSwimSpeed / 100D;
|
||||||
sneakingSpeedLimit = 0.14 * sneakspeed / 100D;
|
sneakingSpeedLimit = 0.14 * sneakspeed / 100D;
|
||||||
blockingSpeedLimit = 0.16 * blockspeed / 100D;
|
blockingSpeedLimit = 0.16 * blockspeed / 100D;
|
||||||
cobWebHoriSpeedLimit = 0.08 * cobWebSpeed / 100D;
|
cobWebHoriSpeedLimit = 0.08 * cobWebSpeed / 100D;
|
||||||
@ -73,7 +75,6 @@ public class MovingConfig extends CheckConfig {
|
|||||||
|
|
||||||
sneakingCheck = !data.getBoolean(ConfPaths.MOVING_RUNFLY_ALLOWFASTSNEAKING);
|
sneakingCheck = !data.getBoolean(ConfPaths.MOVING_RUNFLY_ALLOWFASTSNEAKING);
|
||||||
blockingCheck = !data.getBoolean(ConfPaths.MOVING_RUNFLY_ALLOWFASTBLOCKING);
|
blockingCheck = !data.getBoolean(ConfPaths.MOVING_RUNFLY_ALLOWFASTBLOCKING);
|
||||||
maxCooldown = data.getInt(ConfPaths.MOVING_RUNFLY_MAXCOOLDOWN);
|
|
||||||
actions = data.getActionList(ConfPaths.MOVING_RUNFLY_ACTIONS, Permissions.MOVING_RUNFLY);
|
actions = data.getActionList(ConfPaths.MOVING_RUNFLY_ACTIONS, Permissions.MOVING_RUNFLY);
|
||||||
|
|
||||||
allowFlying = data.getBoolean(ConfPaths.MOVING_RUNFLY_FLYING_ALLOWALWAYS);
|
allowFlying = data.getBoolean(ConfPaths.MOVING_RUNFLY_FLYING_ALLOWALWAYS);
|
||||||
@ -82,10 +83,10 @@ public class MovingConfig extends CheckConfig {
|
|||||||
flyingHeightLimit = data.getInt(ConfPaths.MOVING_RUNFLY_FLYING_HEIGHTLIMIT);
|
flyingHeightLimit = data.getInt(ConfPaths.MOVING_RUNFLY_FLYING_HEIGHTLIMIT);
|
||||||
flyingActions = data.getActionList(ConfPaths.MOVING_RUNFLY_FLYING_ACTIONS, Permissions.MOVING_FLYING);
|
flyingActions = data.getActionList(ConfPaths.MOVING_RUNFLY_FLYING_ACTIONS, Permissions.MOVING_FLYING);
|
||||||
|
|
||||||
nofallCheck = data.getBoolean(ConfPaths.MOVING_RUNFLY_CHECKNOFALL);
|
nofallCheck = data.getBoolean(ConfPaths.MOVING_RUNFLY_NOFALL_CHECK);
|
||||||
nofallMultiplier = 200 / 100F;
|
nofallMultiplier = 200 / 100F;
|
||||||
nofallaggressive = data.getBoolean(ConfPaths.MOVING_RUNFLY_NOFALLAGGRESSIVE);
|
nofallAggressive = data.getBoolean(ConfPaths.MOVING_RUNFLY_NOFALL_AGGRESSIVE);
|
||||||
nofallActions = data.getActionList(ConfPaths.MOVING_RUNFLY_NOFALLACTIONS, Permissions.MOVING_NOFALL);
|
nofallActions = data.getActionList(ConfPaths.MOVING_RUNFLY_NOFALL_ACTIONS, Permissions.MOVING_NOFALL);
|
||||||
|
|
||||||
morePacketsCheck = data.getBoolean(ConfPaths.MOVING_MOREPACKETS_CHECK);
|
morePacketsCheck = data.getBoolean(ConfPaths.MOVING_MOREPACKETS_CHECK);
|
||||||
morePacketsActions = data.getActionList(ConfPaths.MOVING_MOREPACKETS_ACTIONS, Permissions.MOVING_MOREPACKETS);
|
morePacketsActions = data.getActionList(ConfPaths.MOVING_MOREPACKETS_ACTIONS, Permissions.MOVING_MOREPACKETS);
|
||||||
|
@ -13,7 +13,6 @@ public class MovingData extends CheckData {
|
|||||||
|
|
||||||
// Keep track of the violation levels of the checks
|
// Keep track of the violation levels of the checks
|
||||||
public double runflyVL;
|
public double runflyVL;
|
||||||
public double trackerVL;
|
|
||||||
public double nofallVL;
|
public double nofallVL;
|
||||||
public double morePacketsVL;
|
public double morePacketsVL;
|
||||||
public double morePacketsVehicleVL;
|
public double morePacketsVehicleVL;
|
||||||
@ -45,12 +44,6 @@ public class MovingData extends CheckData {
|
|||||||
public float fallDistance;
|
public float fallDistance;
|
||||||
public float lastAddedFallDistance;
|
public float lastAddedFallDistance;
|
||||||
|
|
||||||
// Is the player flying because of a plugin has modified his velocity
|
|
||||||
public boolean velocityChanged = false;
|
|
||||||
|
|
||||||
// If yes, since when?
|
|
||||||
public long velocityChangedSince = 0L;
|
|
||||||
|
|
||||||
// Remember if the player has already been on the ground
|
// Remember if the player has already been on the ground
|
||||||
public boolean hasAlreadyBeenOnTheGround = false;
|
public boolean hasAlreadyBeenOnTheGround = false;
|
||||||
|
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package fr.neatmonster.nocheatplus.checks.moving;
|
||||||
|
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
|
import fr.neatmonster.nocheatplus.checks.CheckEvent;
|
||||||
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
|
|
||||||
|
public class MovingEvent extends CheckEvent {
|
||||||
|
|
||||||
|
public MovingEvent(final MovingCheck check, final NCPPlayer player, final ActionList actions, final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MovingCheck getCheck() {
|
||||||
|
return (MovingCheck) super.getCheck();
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,8 @@ package fr.neatmonster.nocheatplus.checks.moving;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Boat;
|
||||||
|
import org.bukkit.entity.Minecart;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -114,7 +116,7 @@ public class MovingListener extends CheckListener {
|
|||||||
@EventHandler(
|
@EventHandler(
|
||||||
ignoreCancelled = true, priority = EventPriority.LOWEST)
|
ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
public void boat(final PlayerInteractEvent event) {
|
public void boat(final PlayerInteractEvent event) {
|
||||||
if (!event.getPlayer().hasPermission(Permissions.MOVING_BOATONGROUND)
|
if (!NCPPlayer.hasPermission(event.getPlayer(), Permissions.MOVING_BOATONGROUND)
|
||||||
&& event.getAction() == Action.RIGHT_CLICK_BLOCK
|
&& event.getAction() == Action.RIGHT_CLICK_BLOCK
|
||||||
&& event.getPlayer().getItemInHand().getType() == Material.BOAT
|
&& event.getPlayer().getItemInHand().getType() == Material.BOAT
|
||||||
&& event.getClickedBlock().getType() != Material.WATER
|
&& event.getClickedBlock().getType() != Material.WATER
|
||||||
@ -187,16 +189,6 @@ public class MovingListener extends CheckListener {
|
|||||||
data.lastSafeLocations[1] = event.getFrom();
|
data.lastSafeLocations[1] = event.getFrom();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the player is on/in the ground
|
|
||||||
final int toType = CheckUtils.evaluateLocation(event.getPlayer().getWorld(), data.to);
|
|
||||||
if (data.velocityChanged
|
|
||||||
&& (System.currentTimeMillis() - data.velocityChangedSince > 500L
|
|
||||||
&& (CheckUtils.isOnGround(toType) || CheckUtils.isInGround(toType)) || cc.maxCooldown != -1
|
|
||||||
&& System.currentTimeMillis() - data.velocityChangedSince > cc.maxCooldown)) {
|
|
||||||
data.velocityChanged = false;
|
|
||||||
data.velocityChangedSince = 0L;
|
|
||||||
}
|
|
||||||
|
|
||||||
PreciseLocation newTo = null;
|
PreciseLocation newTo = null;
|
||||||
|
|
||||||
/** RUNFLY CHECK SECTION **/
|
/** RUNFLY CHECK SECTION **/
|
||||||
@ -262,7 +254,7 @@ public class MovingListener extends CheckListener {
|
|||||||
|
|
||||||
// If the player has buried himself, remove the blocks to prevent
|
// If the player has buried himself, remove the blocks to prevent
|
||||||
// him from respawning at the surface
|
// him from respawning at the surface
|
||||||
if (!event.getPlayer().hasPermission(Permissions.MOVING_RESPAWNTRICK)
|
if (!NCPPlayer.hasPermission(event.getPlayer(), Permissions.MOVING_RESPAWNTRICK)
|
||||||
&& (event.getPlayer().getLocation().getBlock().getType() == Material.GRAVEL || event.getPlayer()
|
&& (event.getPlayer().getLocation().getBlock().getType() == Material.GRAVEL || event.getPlayer()
|
||||||
.getLocation().getBlock().getType() == Material.SAND)) {
|
.getLocation().getBlock().getType() == Material.SAND)) {
|
||||||
event.getPlayer().getLocation().getBlock().setType(Material.AIR);
|
event.getPlayer().getLocation().getBlock().setType(Material.AIR);
|
||||||
@ -354,7 +346,7 @@ public class MovingListener extends CheckListener {
|
|||||||
ignoreCancelled = true, priority = EventPriority.LOWEST)
|
ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
public void vehicleMove(final VehicleMoveEvent event) {
|
public void vehicleMove(final VehicleMoveEvent event) {
|
||||||
|
|
||||||
// Don't care for vehicles without passenger
|
// Don't care for vehicles without a player as passenger
|
||||||
if (event.getVehicle().getPassenger() == null || !(event.getVehicle().getPassenger() instanceof Player))
|
if (event.getVehicle().getPassenger() == null || !(event.getVehicle().getPassenger() instanceof Player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -377,11 +369,16 @@ public class MovingListener extends CheckListener {
|
|||||||
|
|
||||||
if (cc.morePacketsVehicleCheck && !player.hasPermission(Permissions.MOVING_MOREPACKETSVEHICLE)
|
if (cc.morePacketsVehicleCheck && !player.hasPermission(Permissions.MOVING_MOREPACKETSVEHICLE)
|
||||||
&& morePacketsVehicleCheck.check(player)) {
|
&& morePacketsVehicleCheck.check(player)) {
|
||||||
// Drop the usual items
|
// Drop the usual items (depending on the vehicle)
|
||||||
event.getVehicle().getWorld()
|
if (event.getVehicle() instanceof Minecart)
|
||||||
.dropItemNaturally(event.getVehicle().getLocation(), new ItemStack(Material.WOOD, 3));
|
event.getVehicle().getWorld()
|
||||||
event.getVehicle().getWorld()
|
.dropItemNaturally(event.getVehicle().getLocation(), new ItemStack(Material.MINECART, 1));
|
||||||
.dropItemNaturally(event.getVehicle().getLocation(), new ItemStack(Material.STICK, 2));
|
else if (event.getVehicle() instanceof Boat) {
|
||||||
|
event.getVehicle().getWorld()
|
||||||
|
.dropItemNaturally(event.getVehicle().getLocation(), new ItemStack(Material.WOOD, 3));
|
||||||
|
event.getVehicle().getWorld()
|
||||||
|
.dropItemNaturally(event.getVehicle().getLocation(), new ItemStack(Material.STICK, 2));
|
||||||
|
}
|
||||||
// Remove the passenger
|
// Remove the passenger
|
||||||
if (event.getVehicle().getPassenger() != null)
|
if (event.getVehicle().getPassenger() != null)
|
||||||
event.getVehicle().setPassenger(null);
|
event.getVehicle().setPassenger(null);
|
||||||
@ -404,10 +401,6 @@ public class MovingListener extends CheckListener {
|
|||||||
|
|
||||||
final MovingData data = (MovingData) getData(NCPPlayer.getPlayer(event.getPlayer()));
|
final MovingData data = (MovingData) getData(NCPPlayer.getPlayer(event.getPlayer()));
|
||||||
|
|
||||||
// Remeber that a plugin changed the player's velocity
|
|
||||||
data.velocityChanged = true;
|
|
||||||
data.velocityChangedSince = System.currentTimeMillis();
|
|
||||||
|
|
||||||
final Vector v = event.getVelocity();
|
final Vector v = event.getVelocity();
|
||||||
|
|
||||||
double newVal = v.getY();
|
double newVal = v.getY();
|
||||||
|
@ -2,7 +2,10 @@ package fr.neatmonster.nocheatplus.checks.moving;
|
|||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.checks.CheckUtils;
|
import fr.neatmonster.nocheatplus.checks.CheckUtils;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
||||||
@ -14,6 +17,14 @@ import fr.neatmonster.nocheatplus.players.informations.Statistics.Id;
|
|||||||
*/
|
*/
|
||||||
public class NoFallCheck extends MovingCheck {
|
public class NoFallCheck extends MovingCheck {
|
||||||
|
|
||||||
|
public class NoFallCheckEvent extends MovingEvent {
|
||||||
|
|
||||||
|
public NoFallCheckEvent(final NoFallCheck check, final NCPPlayer player, final ActionList actions,
|
||||||
|
final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public NoFallCheck() {
|
public NoFallCheck() {
|
||||||
super("nofall");
|
super("nofall");
|
||||||
}
|
}
|
||||||
@ -34,8 +45,10 @@ public class NoFallCheck extends MovingCheck {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the player is in unclimbable vines, do not do the check
|
// If the player is in ladder or unclimbable vines, do not do the check
|
||||||
if (CheckUtils.isVine(CheckUtils.evaluateLocation(player.getWorld(), data.from))
|
if (CheckUtils.isLadder(CheckUtils.evaluateLocation(player.getWorld(), data.from))
|
||||||
|
|| CheckUtils.isLadder(CheckUtils.evaluateLocation(player.getWorld(), data.to))
|
||||||
|
|| CheckUtils.isVine(CheckUtils.evaluateLocation(player.getWorld(), data.from))
|
||||||
|| CheckUtils.isVine(CheckUtils.evaluateLocation(player.getWorld(), data.to))) {
|
|| CheckUtils.isVine(CheckUtils.evaluateLocation(player.getWorld(), data.to))) {
|
||||||
data.fallDistance = 0F;
|
data.fallDistance = 0F;
|
||||||
data.lastAddedFallDistance = 0F;
|
data.lastAddedFallDistance = 0F;
|
||||||
@ -47,7 +60,7 @@ public class NoFallCheck extends MovingCheck {
|
|||||||
// Start with zero fall distance
|
// Start with zero fall distance
|
||||||
data.fallDistance = 0F;
|
data.fallDistance = 0F;
|
||||||
|
|
||||||
if (cc.nofallaggressive && data.fromOnOrInGround && data.toOnOrInGround && data.from.y <= data.to.y
|
if (cc.nofallAggressive && data.fromOnOrInGround && data.toOnOrInGround && data.from.y <= data.to.y
|
||||||
&& player.getBukkitPlayer().getFallDistance() > 3.0F) {
|
&& player.getBukkitPlayer().getFallDistance() > 3.0F) {
|
||||||
data.fallDistance = player.getBukkitPlayer().getFallDistance();
|
data.fallDistance = player.getBukkitPlayer().getFallDistance();
|
||||||
data.nofallVL += data.fallDistance;
|
data.nofallVL += data.fallDistance;
|
||||||
@ -124,11 +137,20 @@ public class NoFallCheck extends MovingCheck {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final NoFallCheckEvent event = new NoFallCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", (int) getData(player).nofallVL);
|
return String.valueOf(Math.round(getData(player).nofallVL));
|
||||||
else if (wildcard == ParameterName.FALLDISTANCE)
|
else if (wildcard == ParameterName.FALLDISTANCE)
|
||||||
return String.format(Locale.US, "%.2f", getData(player).fallDistance);
|
return String.format(Locale.US, "%.2f", getData(player).fallDistance);
|
||||||
else
|
else
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.moving;
|
package fr.neatmonster.nocheatplus.checks.moving;
|
||||||
|
|
||||||
import java.util.Locale;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.checks.CheckUtils;
|
import fr.neatmonster.nocheatplus.checks.CheckUtils;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.players.informations.Permissions;
|
import fr.neatmonster.nocheatplus.players.informations.Permissions;
|
||||||
@ -22,6 +22,14 @@ import fr.neatmonster.nocheatplus.utilities.locations.PreciseLocation;
|
|||||||
*/
|
*/
|
||||||
public class RunningCheck extends MovingCheck {
|
public class RunningCheck extends MovingCheck {
|
||||||
|
|
||||||
|
public class RunningCheckEvent extends MovingEvent {
|
||||||
|
|
||||||
|
public RunningCheckEvent(final RunningCheck check, final NCPPlayer player, final ActionList actions,
|
||||||
|
final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final static double maxBonus = 1D;
|
private final static double maxBonus = 1D;
|
||||||
|
|
||||||
// How many move events can a player have in air before he is expected to
|
// How many move events can a player have in air before he is expected to
|
||||||
@ -31,7 +39,6 @@ public class RunningCheck extends MovingCheck {
|
|||||||
private final NoFallCheck noFallCheck;
|
private final NoFallCheck noFallCheck;
|
||||||
|
|
||||||
public RunningCheck() {
|
public RunningCheck() {
|
||||||
|
|
||||||
super("running");
|
super("running");
|
||||||
|
|
||||||
noFallCheck = new NoFallCheck();
|
noFallCheck = new NoFallCheck();
|
||||||
@ -69,7 +76,10 @@ public class RunningCheck extends MovingCheck {
|
|||||||
0.0D,
|
0.0D,
|
||||||
checkHorizontal(player, data, CheckUtils.isLiquid(fromType) && CheckUtils.isLiquid(toType),
|
checkHorizontal(player, data, CheckUtils.isLiquid(fromType) && CheckUtils.isLiquid(toType),
|
||||||
horizontalDistance, cc));
|
horizontalDistance, cc));
|
||||||
final double resultVert = Math.max(0.0D, checkVertical(player, data, fromOnGround, toOnGround, cc));
|
final double resultVert = Math.max(
|
||||||
|
0.0D,
|
||||||
|
checkVertical(player, data, fromOnGround, toOnGround,
|
||||||
|
CheckUtils.isLiquid(fromType) && CheckUtils.isLiquid(toType), cc));
|
||||||
|
|
||||||
final double result = (resultHoriz + resultVert) * 100;
|
final double result = (resultHoriz + resultVert) * 100;
|
||||||
|
|
||||||
@ -79,7 +89,7 @@ public class RunningCheck extends MovingCheck {
|
|||||||
data.runflyVL *= 0.95;
|
data.runflyVL *= 0.95;
|
||||||
|
|
||||||
// Did the player move in unexpected ways?
|
// Did the player move in unexpected ways?
|
||||||
if (result > 0 && !data.velocityChanged) {
|
if (result > 0) {
|
||||||
// Increment violation counter
|
// Increment violation counter
|
||||||
data.runflyVL += result;
|
data.runflyVL += result;
|
||||||
|
|
||||||
@ -221,7 +231,7 @@ public class RunningCheck extends MovingCheck {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private double checkVertical(final NCPPlayer player, final MovingData data, final boolean fromOnGround,
|
private double checkVertical(final NCPPlayer player, final MovingData data, final boolean fromOnGround,
|
||||||
final boolean toOnGround, final MovingConfig cc) {
|
final boolean toOnGround, final boolean isSwimming, final MovingConfig cc) {
|
||||||
|
|
||||||
// How much higher did the player move than expected??
|
// How much higher did the player move than expected??
|
||||||
double distanceAboveLimit = 0.0D;
|
double distanceAboveLimit = 0.0D;
|
||||||
@ -238,17 +248,20 @@ public class RunningCheck extends MovingCheck {
|
|||||||
if (data.jumpPhase > jumpingLimit + data.lastJumpAmplifier)
|
if (data.jumpPhase > jumpingLimit + data.lastJumpAmplifier)
|
||||||
limit -= (data.jumpPhase - jumpingLimit) * 0.15D;
|
limit -= (data.jumpPhase - jumpingLimit) * 0.15D;
|
||||||
|
|
||||||
// Check if the player is in web and check his move
|
// Handle the calculation differently if the player is in water
|
||||||
final World world = player.getWorld();
|
if (isSwimming && data.to.y - data.from.y > 0D)
|
||||||
if (CheckUtils.isWeb(CheckUtils.evaluateLocation(world, data.from))
|
distanceAboveLimit = data.to.y - data.from.y - cc.verticalSwimmingSpeedLimit;
|
||||||
&& CheckUtils.isWeb(CheckUtils.evaluateLocation(world, data.to))
|
|
||||||
&& Math.abs(data.to.y - data.from.y) > cc.cobWebVertSpeedLimit)
|
|
||||||
distanceAboveLimit = Math.abs(data.to.y - data.from.y - cc.cobWebVertSpeedLimit);
|
|
||||||
|
|
||||||
else
|
// Handle the calculation differently if the player is in cobweb
|
||||||
|
final World world = player.getWorld();
|
||||||
|
if (distanceAboveLimit <= 0D && CheckUtils.isWeb(CheckUtils.evaluateLocation(world, data.from))
|
||||||
|
&& CheckUtils.isWeb(CheckUtils.evaluateLocation(world, data.to)))
|
||||||
|
distanceAboveLimit = Math.abs(data.to.y - data.from.y) - cc.cobWebVertSpeedLimit;
|
||||||
|
|
||||||
|
if (distanceAboveLimit <= 0D)
|
||||||
distanceAboveLimit = data.to.y - data.runflySetBackPoint.y - limit;
|
distanceAboveLimit = data.to.y - data.runflySetBackPoint.y - limit;
|
||||||
|
|
||||||
if (distanceAboveLimit > 0)
|
if (distanceAboveLimit > 0D)
|
||||||
data.statisticCategory = Id.MOV_FLYING;
|
data.statisticCategory = Id.MOV_FLYING;
|
||||||
|
|
||||||
if (toOnGround || fromOnGround)
|
if (toOnGround || fromOnGround)
|
||||||
@ -257,6 +270,15 @@ public class RunningCheck extends MovingCheck {
|
|||||||
return distanceAboveLimit;
|
return distanceAboveLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final RunningCheckEvent event = new RunningCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
@ -264,7 +286,7 @@ public class RunningCheck extends MovingCheck {
|
|||||||
// Workaround for something until I find a better way to do it
|
// Workaround for something until I find a better way to do it
|
||||||
return getData(player).statisticCategory.toString();
|
return getData(player).statisticCategory.toString();
|
||||||
else if (wildcard == ParameterName.VIOLATIONS)
|
else if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", (int) getData(player).runflyVL);
|
return String.valueOf(Math.round(getData(player).runflyVL));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package fr.neatmonster.nocheatplus.checks.moving;
|
package fr.neatmonster.nocheatplus.checks.moving;
|
||||||
|
|
||||||
import java.util.Locale;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
|
import fr.neatmonster.nocheatplus.actions.types.ActionList;
|
||||||
import fr.neatmonster.nocheatplus.checks.CheckUtils;
|
import fr.neatmonster.nocheatplus.checks.CheckUtils;
|
||||||
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
import fr.neatmonster.nocheatplus.players.NCPPlayer;
|
||||||
import fr.neatmonster.nocheatplus.utilities.locations.PreciseLocation;
|
import fr.neatmonster.nocheatplus.utilities.locations.PreciseLocation;
|
||||||
@ -18,6 +18,14 @@ import fr.neatmonster.nocheatplus.utilities.locations.PreciseLocation;
|
|||||||
*/
|
*/
|
||||||
public class WaterWalkCheck extends MovingCheck {
|
public class WaterWalkCheck extends MovingCheck {
|
||||||
|
|
||||||
|
public class WaterWalkCheckEvent extends MovingEvent {
|
||||||
|
|
||||||
|
public WaterWalkCheckEvent(final WaterWalkCheck check, final NCPPlayer player, final ActionList actions,
|
||||||
|
final double vL) {
|
||||||
|
super(check, player, actions, vL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public WaterWalkCheck() {
|
public WaterWalkCheck() {
|
||||||
super("waterwalk");
|
super("waterwalk");
|
||||||
}
|
}
|
||||||
@ -72,14 +80,15 @@ public class WaterWalkCheck extends MovingCheck {
|
|||||||
&& fromBlock.getData() == 0x0)
|
&& fromBlock.getData() == 0x0)
|
||||||
waterStreamsFix = true;
|
waterStreamsFix = true;
|
||||||
|
|
||||||
// Handle the issue with slabs/stairs
|
// Handle the issue with slabs/stairs/soul sand
|
||||||
boolean slabsStairsFix = false;
|
boolean othersFix = false;
|
||||||
for (final BlockFace blockFace : BlockFace.values()) {
|
for (final BlockFace blockFace : BlockFace.values()) {
|
||||||
final Material material = fromBlock.getRelative(blockFace).getType();
|
final Material material = fromBlock.getRelative(blockFace).getType();
|
||||||
if (material == Material.STEP || material == Material.WOOD_STAIRS
|
if (material == Material.STEP || material == Material.WOOD_STAIRS
|
||||||
|| material == Material.COBBLESTONE_STAIRS || material == Material.BRICK_STAIRS
|
|| material == Material.COBBLESTONE_STAIRS || material == Material.BRICK_STAIRS
|
||||||
|| material == Material.SMOOTH_STAIRS || material == Material.NETHER_BRICK_STAIRS)
|
|| material == Material.SMOOTH_STAIRS || material == Material.NETHER_BRICK_STAIRS
|
||||||
slabsStairsFix = true;
|
|| material == Material.SOUL_SAND)
|
||||||
|
othersFix = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate some distances
|
// Calculate some distances
|
||||||
@ -95,8 +104,7 @@ public class WaterWalkCheck extends MovingCheck {
|
|||||||
// Slowly reduce the level with each event
|
// Slowly reduce the level with each event
|
||||||
data.waterWalkVL *= 0.95;
|
data.waterWalkVL *= 0.95;
|
||||||
|
|
||||||
if (!slabsStairsFix && fromLiquid && toLiquid && !upLiquid && !aboveSolid && deltaY == 0D
|
if (!othersFix && fromLiquid && toLiquid && !upLiquid && !aboveSolid && deltaY == 0D && deltaWithSurface < 0.8D) {
|
||||||
&& deltaWithSurface < 0.8D) {
|
|
||||||
// If the player is trying to move while being in water
|
// If the player is trying to move while being in water
|
||||||
// Increment violation counter
|
// Increment violation counter
|
||||||
data.waterWalkVL += resultY;
|
data.waterWalkVL += resultY;
|
||||||
@ -126,11 +134,20 @@ public class WaterWalkCheck extends MovingCheck {
|
|||||||
return newToLocation;
|
return newToLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean executeActions(final NCPPlayer player, final ActionList actionList, final double violationLevel) {
|
||||||
|
final WaterWalkCheckEvent event = new WaterWalkCheckEvent(this, player, actionList, violationLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
return super.executeActions(player, event.getActions(), event.getVL());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
public String getParameter(final ParameterName wildcard, final NCPPlayer player) {
|
||||||
|
|
||||||
if (wildcard == ParameterName.VIOLATIONS)
|
if (wildcard == ParameterName.VIOLATIONS)
|
||||||
return String.format(Locale.US, "%d", (int) getData(player).waterWalkVL);
|
return String.valueOf(Math.round(getData(player).waterWalkVL));
|
||||||
else
|
else
|
||||||
return super.getParameter(wildcard, player);
|
return super.getParameter(wildcard, player);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ public abstract class ConfPaths {
|
|||||||
public static final String LOGGING_LOGTOFILE = LOGGING + "file";
|
public static final String LOGGING_LOGTOFILE = LOGGING + "file";
|
||||||
public static final String LOGGING_LOGTOCONSOLE = LOGGING + "console";
|
public static final String LOGGING_LOGTOCONSOLE = LOGGING + "console";
|
||||||
public static final String LOGGING_LOGTOINGAMECHAT = LOGGING + "ingamechat";
|
public static final String LOGGING_LOGTOINGAMECHAT = LOGGING + "ingamechat";
|
||||||
public static final String LOGGING_SHOWACTIVECHECKS = LOGGING + "showactivechecks";
|
|
||||||
public static final String LOGGING_DEBUGMESSAGES = LOGGING + "debugmessages";
|
public static final String LOGGING_DEBUGMESSAGES = LOGGING + "debugmessages";
|
||||||
|
|
||||||
private static final String MISCELLANEOUS = "miscellaneous.";
|
private static final String MISCELLANEOUS = "miscellaneous.";
|
||||||
@ -46,22 +45,23 @@ public abstract class ConfPaths {
|
|||||||
private static final String MOVING_RUNFLY = MOVING + "runfly.";
|
private static final String MOVING_RUNFLY = MOVING + "runfly.";
|
||||||
public static final String MOVING_RUNFLY_CHECK = MOVING_RUNFLY + "active";
|
public static final String MOVING_RUNFLY_CHECK = MOVING_RUNFLY + "active";
|
||||||
|
|
||||||
// These sixth are not automatically shown in the config
|
// These seventh aren't automatically shown in the config
|
||||||
public static final String MOVING_RUNFLY_WALKSPEED = MOVING_RUNFLY + "walkspeed";
|
public static final String MOVING_RUNFLY_WALKSPEED = MOVING_RUNFLY + "walkspeed";
|
||||||
public static final String MOVING_RUNFLY_SNEAKSPEED = MOVING_RUNFLY + "sneakspeed";
|
public static final String MOVING_RUNFLY_SNEAKSPEED = MOVING_RUNFLY + "sneakspeed";
|
||||||
public static final String MOVING_RUNFLY_BLOCKSPEED = MOVING_RUNFLY + "blockspeed";
|
public static final String MOVING_RUNFLY_BLOCKSPEED = MOVING_RUNFLY + "blockspeed";
|
||||||
public static final String MOVING_RUNFLY_SWIMSPEED = MOVING_RUNFLY + "swimspeed";
|
public static final String MOVING_RUNFLY_SWIMSPEED = MOVING_RUNFLY + "swimspeed";
|
||||||
|
public static final String MOVING_RUNFLY_VERTICALSWIMSPEED = MOVING_RUNFLY + "vertswimspeed";
|
||||||
public static final String MOVING_RUNFLY_SPRINTSPEED = MOVING_RUNFLY + "sprintspeed";
|
public static final String MOVING_RUNFLY_SPRINTSPEED = MOVING_RUNFLY + "sprintspeed";
|
||||||
public static final String MOVING_RUNFLY_COBWEBSPEED = MOVING_RUNFLY + "cobwebspeed";
|
public static final String MOVING_RUNFLY_COBWEBSPEED = MOVING_RUNFLY + "cobwebspeed";
|
||||||
|
|
||||||
public static final String MOVING_RUNFLY_ALLOWFASTSNEAKING = MOVING_RUNFLY + "allowfastsneaking";
|
public static final String MOVING_RUNFLY_ALLOWFASTSNEAKING = MOVING_RUNFLY + "allowfastsneaking";
|
||||||
public static final String MOVING_RUNFLY_ALLOWFASTBLOCKING = MOVING_RUNFLY + "allowfastblocking";
|
public static final String MOVING_RUNFLY_ALLOWFASTBLOCKING = MOVING_RUNFLY + "allowfastblocking";
|
||||||
public static final String MOVING_RUNFLY_MAXCOOLDOWN = MOVING_RUNFLY + "maxcooldown";
|
|
||||||
public static final String MOVING_RUNFLY_ACTIONS = MOVING_RUNFLY + "actions";
|
public static final String MOVING_RUNFLY_ACTIONS = MOVING_RUNFLY + "actions";
|
||||||
|
|
||||||
public static final String MOVING_RUNFLY_CHECKNOFALL = MOVING_RUNFLY + "checknofall";
|
private static final String MOVING_RUNFLY_NOFALL = MOVING_RUNFLY + "nofall.";
|
||||||
public static final String MOVING_RUNFLY_NOFALLAGGRESSIVE = MOVING_RUNFLY + "nofallaggressivemode";
|
public static final String MOVING_RUNFLY_NOFALL_CHECK = MOVING_RUNFLY_NOFALL + "active";
|
||||||
public static final String MOVING_RUNFLY_NOFALLACTIONS = MOVING_RUNFLY + "nofallactions";
|
public static final String MOVING_RUNFLY_NOFALL_AGGRESSIVE = MOVING_RUNFLY_NOFALL + "aggressivemode";
|
||||||
|
public static final String MOVING_RUNFLY_NOFALL_ACTIONS = MOVING_RUNFLY_NOFALL + "actions";
|
||||||
|
|
||||||
private static final String MOVING_RUNFLY_FLYING = MOVING_RUNFLY + "flying.";
|
private static final String MOVING_RUNFLY_FLYING = MOVING_RUNFLY + "flying.";
|
||||||
public static final String MOVING_RUNFLY_FLYING_ALLOWALWAYS = MOVING_RUNFLY_FLYING + "allowflyingalways";
|
public static final String MOVING_RUNFLY_FLYING_ALLOWALWAYS = MOVING_RUNFLY_FLYING + "allowflyingalways";
|
||||||
@ -131,6 +131,7 @@ public abstract class ConfPaths {
|
|||||||
public static final String BLOCKPLACE_PROJECTILE_ACTIONS = BLOCKPLACE_PROJECTILE + "actions";
|
public static final String BLOCKPLACE_PROJECTILE_ACTIONS = BLOCKPLACE_PROJECTILE + "actions";
|
||||||
|
|
||||||
private static final String BLOCKPLACE_FASTSIGN = BLOCKPLACE + "fastsign.";
|
private static final String BLOCKPLACE_FASTSIGN = BLOCKPLACE + "fastsign.";
|
||||||
|
public static final String BLOCKPLACE_FASTSIGN_CHECK = BLOCKPLACE_FASTSIGN + "active";
|
||||||
public static final String BLOCKPLACE_FASTSIGN_EXCLUSIONS = BLOCKPLACE_FASTSIGN + "exclusions";
|
public static final String BLOCKPLACE_FASTSIGN_EXCLUSIONS = BLOCKPLACE_FASTSIGN + "exclusions";
|
||||||
|
|
||||||
private static final String CHAT = CHECKS + "chat.";
|
private static final String CHAT = CHECKS + "chat.";
|
||||||
@ -142,7 +143,8 @@ public abstract class ConfPaths {
|
|||||||
public static final String CHAT_NOPWNAGE_WARNLEVEL = CHAT_NOPWNAGE + "warnlevel";
|
public static final String CHAT_NOPWNAGE_WARNLEVEL = CHAT_NOPWNAGE + "warnlevel";
|
||||||
public static final String CHAT_NOPWNAGE_WARNTIMEOUT = CHAT_NOPWNAGE + "warntimeout";
|
public static final String CHAT_NOPWNAGE_WARNTIMEOUT = CHAT_NOPWNAGE + "warntimeout";
|
||||||
public static final String CHAT_NOPWNAGE_BANLEVEL = CHAT_NOPWNAGE + "banlevel";
|
public static final String CHAT_NOPWNAGE_BANLEVEL = CHAT_NOPWNAGE + "banlevel";
|
||||||
public static final String CHAT_NOPWNAGE_ACTIONS = CHAT_NOPWNAGE + "actions";
|
public static final String CHAT_NOPWNAGE_KICKMESSAGE = CHAT_NOPWNAGE + "kickmessage";
|
||||||
|
public static final String CHAT_NOPWNAGE_ACTIONS = CHAT_NOPWNAGE + "otheractions";
|
||||||
|
|
||||||
private static final String CHAT_NOPWNAGE_MOVE = CHAT_NOPWNAGE + "move.";
|
private static final String CHAT_NOPWNAGE_MOVE = CHAT_NOPWNAGE + "move.";
|
||||||
public static final String CHAT_NOPWNAGE_MOVE_CHECK = CHAT_NOPWNAGE_MOVE + "active";
|
public static final String CHAT_NOPWNAGE_MOVE_CHECK = CHAT_NOPWNAGE_MOVE + "active";
|
||||||
|
@ -3,18 +3,57 @@ package fr.neatmonster.nocheatplus.config;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.logging.FileHandler;
|
import java.util.logging.FileHandler;
|
||||||
|
import java.util.logging.Formatter;
|
||||||
import java.util.logging.Handler;
|
import java.util.logging.Handler;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.LogRecord;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||||
import fr.neatmonster.nocheatplus.utilities.LogFileFormatter;
|
import fr.neatmonster.nocheatplus.checks.Check;
|
||||||
|
|
||||||
public class ConfigManager {
|
public class ConfigManager {
|
||||||
|
private static class LogFileFormatter extends Formatter {
|
||||||
|
|
||||||
|
public static LogFileFormatter newInstance() {
|
||||||
|
return new LogFileFormatter();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final SimpleDateFormat date;
|
||||||
|
|
||||||
|
private LogFileFormatter() {
|
||||||
|
date = new SimpleDateFormat("yy.MM.dd HH:mm:ss");
|
||||||
|
}
|
||||||
|
|
||||||
|
@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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static final Map<String, ConfigFile> worldsMap = new HashMap<String, ConfigFile>();
|
private static final Map<String, ConfigFile> worldsMap = new HashMap<String, ConfigFile>();
|
||||||
|
|
||||||
private static FileHandler fileHandler;
|
private static FileHandler fileHandler;
|
||||||
@ -95,14 +134,14 @@ public class ConfigManager {
|
|||||||
}
|
}
|
||||||
fileHandler = new FileHandler(logFile.getCanonicalPath(), true);
|
fileHandler = new FileHandler(logFile.getCanonicalPath(), true);
|
||||||
fileHandler.setLevel(Level.ALL);
|
fileHandler.setLevel(Level.ALL);
|
||||||
fileHandler.setFormatter(new LogFileFormatter());
|
fileHandler.setFormatter(LogFileFormatter.newInstance());
|
||||||
|
|
||||||
logger.addHandler(fileHandler);
|
logger.addHandler(fileHandler);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
NoCheatPlus.instance.setFileLogger(logger);
|
Check.setFileLogger(logger);
|
||||||
|
|
||||||
// Try to find world-specific config files
|
// Try to find world-specific config files
|
||||||
final HashMap<String, File> worldFiles = new HashMap<String, File>();
|
final HashMap<String, File> worldFiles = new HashMap<String, File>();
|
||||||
|
@ -19,7 +19,6 @@ public class DefaultConfig extends ConfigFile {
|
|||||||
/*** LOGGING ***/
|
/*** LOGGING ***/
|
||||||
|
|
||||||
set(ConfPaths.LOGGING_ACTIVE, true);
|
set(ConfPaths.LOGGING_ACTIVE, true);
|
||||||
set(ConfPaths.LOGGING_SHOWACTIVECHECKS, false);
|
|
||||||
set(ConfPaths.LOGGING_DEBUGMESSAGES, false);
|
set(ConfPaths.LOGGING_DEBUGMESSAGES, false);
|
||||||
set(ConfPaths.LOGGING_PREFIX, "&4NCP&f: ");
|
set(ConfPaths.LOGGING_PREFIX, "&4NCP&f: ");
|
||||||
set(ConfPaths.LOGGING_FILENAME, "nocheatplus.log");
|
set(ConfPaths.LOGGING_FILENAME, "nocheatplus.log");
|
||||||
@ -51,18 +50,17 @@ public class DefaultConfig extends ConfigFile {
|
|||||||
set(ConfPaths.MOVING_RUNFLY_CHECK, true);
|
set(ConfPaths.MOVING_RUNFLY_CHECK, true);
|
||||||
set(ConfPaths.MOVING_RUNFLY_ALLOWFASTSNEAKING, false);
|
set(ConfPaths.MOVING_RUNFLY_ALLOWFASTSNEAKING, false);
|
||||||
set(ConfPaths.MOVING_RUNFLY_ALLOWFASTBLOCKING, false);
|
set(ConfPaths.MOVING_RUNFLY_ALLOWFASTBLOCKING, false);
|
||||||
set(ConfPaths.MOVING_RUNFLY_MAXCOOLDOWN, 10000);
|
|
||||||
set(ConfPaths.MOVING_RUNFLY_ACTIONS,
|
set(ConfPaths.MOVING_RUNFLY_ACTIONS,
|
||||||
"log:moveshort:3:5:f cancel vl>100 log:moveshort:0:5:if cancel vl>400 log:movelong:0:5:cif cancel");
|
"log:moveshort:3:5:f cancel vl>100 log:moveshort:0:5:if cancel vl>400 log:movelong:0:5:cif cancel");
|
||||||
|
|
||||||
set(ConfPaths.MOVING_RUNFLY_CHECKNOFALL, true);
|
set(ConfPaths.MOVING_RUNFLY_NOFALL_CHECK, true);
|
||||||
set(ConfPaths.MOVING_RUNFLY_NOFALLAGGRESSIVE, true);
|
set(ConfPaths.MOVING_RUNFLY_NOFALL_AGGRESSIVE, true);
|
||||||
set(ConfPaths.MOVING_RUNFLY_NOFALLACTIONS, "log:nofall:0:5:cif cancel");
|
set(ConfPaths.MOVING_RUNFLY_NOFALL_ACTIONS, "log:nofall:0:5:cif cancel");
|
||||||
|
|
||||||
set(ConfPaths.MOVING_RUNFLY_FLYING_ALLOWALWAYS, false);
|
set(ConfPaths.MOVING_RUNFLY_FLYING_ALLOWALWAYS, false);
|
||||||
set(ConfPaths.MOVING_RUNFLY_FLYING_ALLOWINCREATIVE, true);
|
set(ConfPaths.MOVING_RUNFLY_FLYING_ALLOWINCREATIVE, true);
|
||||||
set(ConfPaths.MOVING_RUNFLY_FLYING_SPEEDLIMITHORIZONTAL, 60);
|
|
||||||
set(ConfPaths.MOVING_RUNFLY_FLYING_SPEEDLIMITVERTICAL, 100);
|
set(ConfPaths.MOVING_RUNFLY_FLYING_SPEEDLIMITVERTICAL, 100);
|
||||||
|
set(ConfPaths.MOVING_RUNFLY_FLYING_SPEEDLIMITHORIZONTAL, 60);
|
||||||
set(ConfPaths.MOVING_RUNFLY_FLYING_HEIGHTLIMIT, 128);
|
set(ConfPaths.MOVING_RUNFLY_FLYING_HEIGHTLIMIT, 128);
|
||||||
set(ConfPaths.MOVING_RUNFLY_FLYING_ACTIONS,
|
set(ConfPaths.MOVING_RUNFLY_FLYING_ACTIONS,
|
||||||
"log:moveshort:3:5:f cancel vl>100 log:moveshort:0:5:if cancel vl>400 log:movelong:0:5:cif cancel");
|
"log:moveshort:3:5:f cancel vl>100 log:moveshort:0:5:if cancel vl>400 log:movelong:0:5:cif cancel");
|
||||||
@ -83,7 +81,7 @@ public class DefaultConfig extends ConfigFile {
|
|||||||
set(ConfPaths.BLOCKBREAK_FASTBREAK_INTERVALSURVIVAL, 45);
|
set(ConfPaths.BLOCKBREAK_FASTBREAK_INTERVALSURVIVAL, 45);
|
||||||
set(ConfPaths.BLOCKBREAK_FASTBREAK_INTERVALCREATIVE, 145);
|
set(ConfPaths.BLOCKBREAK_FASTBREAK_INTERVALCREATIVE, 145);
|
||||||
set(ConfPaths.BLOCKBREAK_FASTBREAK_ACTIONS,
|
set(ConfPaths.BLOCKBREAK_FASTBREAK_ACTIONS,
|
||||||
"cancel vl>100 log:bbfastbreak:3:5:cif cancel vl>2000 log:bbfastbreak:3:5:cif cmd:kick cancel");
|
"cancel vl>100 log:bbfastbreak:3:5:cif cancel vl>1000 log:bbfastbreak:3:5:cif cmd:kick cancel");
|
||||||
|
|
||||||
set(ConfPaths.BLOCKBREAK_REACH_CHECK, true);
|
set(ConfPaths.BLOCKBREAK_REACH_CHECK, true);
|
||||||
set(ConfPaths.BLOCKBREAK_REACH_ACTIONS, "cancel vl>5 log:bbreach:0:2:if cancel");
|
set(ConfPaths.BLOCKBREAK_REACH_ACTIONS, "cancel vl>5 log:bbreach:0:2:if cancel");
|
||||||
@ -101,7 +99,7 @@ public class DefaultConfig extends ConfigFile {
|
|||||||
set(ConfPaths.BLOCKPLACE_FASTPLACE_CHECK, true);
|
set(ConfPaths.BLOCKPLACE_FASTPLACE_CHECK, true);
|
||||||
set(ConfPaths.BLOCKPLACE_FASTPLACE_INTERVAL, 95);
|
set(ConfPaths.BLOCKPLACE_FASTPLACE_INTERVAL, 95);
|
||||||
set(ConfPaths.BLOCKPLACE_FASTPLACE_ACTIONS,
|
set(ConfPaths.BLOCKPLACE_FASTPLACE_ACTIONS,
|
||||||
"cancel vl>100 log:bpfastplace:3:5:cif cancel vl>2000 log:bpfastplace:3:5:cif cmd:kick cancel");
|
"cancel vl>100 log:bpfastplace:3:5:cif cancel vl>1000 log:bpfastplace:3:5:cif cmd:kick cancel");
|
||||||
|
|
||||||
set(ConfPaths.BLOCKPLACE_REACH_CHECK, true);
|
set(ConfPaths.BLOCKPLACE_REACH_CHECK, true);
|
||||||
set(ConfPaths.BLOCKPLACE_REACH_ACTIONS, "cancel vl>5 log:bpreach:0:2:if cancel");
|
set(ConfPaths.BLOCKPLACE_REACH_ACTIONS, "cancel vl>5 log:bpreach:0:2:if cancel");
|
||||||
@ -116,10 +114,11 @@ public class DefaultConfig extends ConfigFile {
|
|||||||
set(ConfPaths.BLOCKPLACE_PROJECTILE_ACTIONS,
|
set(ConfPaths.BLOCKPLACE_PROJECTILE_ACTIONS,
|
||||||
"cancel vl>150 log:bpprojectile:3:5:if cancel vl>1000 log:bpprojectile:3:5:cif cancel vl>4000 log:bpprojectile:3:5:cif cancel cmd:kick");
|
"cancel vl>150 log:bpprojectile:3:5:if cancel vl>1000 log:bpprojectile:3:5:cif cancel vl>4000 log:bpprojectile:3:5:cif cancel cmd:kick");
|
||||||
|
|
||||||
|
set(ConfPaths.BLOCKPLACE_FASTPLACE_CHECK, true);
|
||||||
set(ConfPaths.BLOCKPLACE_FASTSIGN_EXCLUSIONS,
|
set(ConfPaths.BLOCKPLACE_FASTSIGN_EXCLUSIONS,
|
||||||
Arrays.asList(new String[] {"[public]", "[private]", "[protection]", "[mail]", "[free]", "[kit]",
|
Arrays.asList(new String[] {"[public]", "[private]", "[protection]", "[mail]", "[free]", "[kit]",
|
||||||
"[disposal]", "[heal]", "[time]", "[weather]", "[warp]", "[spawnmob]", "[enchant]", "[trade]",
|
"[disposal]", "[heal]", "[time]", "[weather]", "[warp]", "[spawnmob]", "[enchant]", "[trade]",
|
||||||
"[buy]", "[sell]", "[balance]"}));
|
"[buy]", "[sell]", "[balance]", "[gate]", "[bridge]", "[door]"}));
|
||||||
|
|
||||||
/*** CHAT ***/
|
/*** CHAT ***/
|
||||||
|
|
||||||
@ -129,7 +128,8 @@ public class DefaultConfig extends ConfigFile {
|
|||||||
set(ConfPaths.CHAT_NOPWNAGE_WARNLEVEL, 400);
|
set(ConfPaths.CHAT_NOPWNAGE_WARNLEVEL, 400);
|
||||||
set(ConfPaths.CHAT_NOPWNAGE_WARNTIMEOUT, 30000);
|
set(ConfPaths.CHAT_NOPWNAGE_WARNTIMEOUT, 30000);
|
||||||
set(ConfPaths.CHAT_NOPWNAGE_BANLEVEL, 800);
|
set(ConfPaths.CHAT_NOPWNAGE_BANLEVEL, 800);
|
||||||
set(ConfPaths.CHAT_NOPWNAGE_ACTIONS, "log:nopwnage:2:5:cf cmd:kick cmd:ban cmd:ban-ip");
|
set(ConfPaths.CHAT_NOPWNAGE_KICKMESSAGE, "Kicked by the NoPwnage check of NoCheat+!");
|
||||||
|
set(ConfPaths.CHAT_NOPWNAGE_ACTIONS, "cancel log:nopwnage:2:5:cf cmd:ban cmd:ban-ip");
|
||||||
|
|
||||||
set(ConfPaths.CHAT_NOPWNAGE_MOVE_CHECK, true);
|
set(ConfPaths.CHAT_NOPWNAGE_MOVE_CHECK, true);
|
||||||
set(ConfPaths.CHAT_NOPWNAGE_MOVE_WEIGHTBONUS, 200);
|
set(ConfPaths.CHAT_NOPWNAGE_MOVE_WEIGHTBONUS, 200);
|
||||||
@ -214,50 +214,50 @@ public class DefaultConfig extends ConfigFile {
|
|||||||
set(ConfPaths.FIGHT_CRITICAL_ACTIONS, "cancel vl>50 log:fcritical:0:5:cif cancel");
|
set(ConfPaths.FIGHT_CRITICAL_ACTIONS, "cancel vl>50 log:fcritical:0:5:cif cancel");
|
||||||
|
|
||||||
set(ConfPaths.STRINGS + ".drop",
|
set(ConfPaths.STRINGS + ".drop",
|
||||||
"[player] failed [check]: Tried to drop more items than allowed. VL [violations]");
|
"[player] failed [check]: tried to drop more items than allowed. VL [violations].");
|
||||||
set(ConfPaths.STRINGS + ".moveshort", "[player] failed [check]. VL [violations]");
|
set(ConfPaths.STRINGS + ".moveshort", "[player] failed [check]. VL [violations].");
|
||||||
set(ConfPaths.STRINGS + ".movelong",
|
set(ConfPaths.STRINGS + ".movelong",
|
||||||
"[player] in [world] at [location] moving to [locationto] over distance [movedistance] failed check [check]. Total violation level so far [violations]");
|
"[player] in [world] at [location] moving to [locationto] over distance [movedistance] failed check [check]. Total violation level so far [violations].");
|
||||||
set(ConfPaths.STRINGS + ".nofall",
|
set(ConfPaths.STRINGS + ".nofall",
|
||||||
"[player] failed [check]: tried to avoid fall damage for ~[falldistance] blocks. VL [violations]");
|
"[player] failed [check]: tried to avoid fall damage for ~[falldistance] blocks. VL [violations].");
|
||||||
set(ConfPaths.STRINGS + ".morepackets",
|
set(ConfPaths.STRINGS + ".morepackets",
|
||||||
"[player] failed [check]: Sent [packets] more packets than expected. Total violation level [violations]");
|
"[player] failed [check]: sent [packets] more packets than expected. Total violation level [violations].");
|
||||||
set(ConfPaths.STRINGS + ".waterwalk",
|
set(ConfPaths.STRINGS + ".waterwalk",
|
||||||
"[player] failed [check]: tried to walk on water. Total violation level [violations]");
|
"[player] failed [check]: tried to walk on water. Total violation level [violations].");
|
||||||
set(ConfPaths.STRINGS + ".bbfastbreak",
|
set(ConfPaths.STRINGS + ".bbfastbreak",
|
||||||
"[player] failed [check]: tried to break too much blocks. Total violation level [violations]");
|
"[player] failed [check]: tried to break too much blocks. Total violation level [violations].");
|
||||||
set(ConfPaths.STRINGS + ".bbreach",
|
set(ConfPaths.STRINGS + ".bbreach",
|
||||||
"[player] failed [check]: tried to interact with a block over distance [reachdistance]. VL [violations]");
|
"[player] failed [check]: tried to interact with a block over distance [reachdistance]. VL [violations].");
|
||||||
set(ConfPaths.STRINGS + ".bbdirection",
|
set(ConfPaths.STRINGS + ".bbdirection",
|
||||||
"[player] failed [check]: tried to interact with a block out of line of sight. VL [violations]");
|
"[player] failed [check]: tried to interact with a block out of line of sight. VL [violations].");
|
||||||
set(ConfPaths.STRINGS + ".bbnoswing", "[player] failed [check]: Didn't swing arm. VL [violations]");
|
set(ConfPaths.STRINGS + ".bbnoswing", "[player] failed [check]: Didn't swing arm. VL [violations].");
|
||||||
set(ConfPaths.STRINGS + ".bpfastplace",
|
set(ConfPaths.STRINGS + ".bpfastplace",
|
||||||
"[player] failed [check]: tried to place too much blocks. Total violation level [violations]");
|
"[player] failed [check]: tried to place too much blocks. Total violation level [violations].");
|
||||||
set(ConfPaths.STRINGS + ".bpreach",
|
set(ConfPaths.STRINGS + ".bpreach",
|
||||||
"[player] failed [check]: tried to interact with a block over distance [reachdistance]. VL [violations]");
|
"[player] failed [check]: tried to interact with a block over distance [reachdistance]. VL [violations].");
|
||||||
set(ConfPaths.STRINGS + ".bpdirection",
|
set(ConfPaths.STRINGS + ".bpdirection",
|
||||||
"[player] failed [check]: tried to interact with a block out of line of sight. VL [violations]");
|
"[player] failed [check]: tried to interact with a block out of line of sight. VL [violations].");
|
||||||
set(ConfPaths.STRINGS + ".bpprojectile",
|
set(ConfPaths.STRINGS + ".bpprojectile",
|
||||||
"[player] failed [check]: tried to throw items too quicly. VL [violations]");
|
"[player] failed [check]: tried to throw items too quicly. VL [violations].");
|
||||||
set(ConfPaths.STRINGS + ".nopwnage", "Commands run for [player] ([ip]): [reason]!");
|
set(ConfPaths.STRINGS + ".nopwnage", "[player] ([ip]) failed chat.nopwnage: [reason].");
|
||||||
set(ConfPaths.STRINGS + ".color",
|
set(ConfPaths.STRINGS + ".color",
|
||||||
"[player] failed [check]: Sent colored chat message '[text]'. VL [violations]");
|
"[player] failed [check]: sent colored chat message '[text]'. VL [violations].");
|
||||||
set(ConfPaths.STRINGS + ".fdirection",
|
set(ConfPaths.STRINGS + ".fdirection",
|
||||||
"[player] failed [check]: tried to interact with a block out of line of sight. VL [violations]");
|
"[player] failed [check]: tried to interact with a block out of line of sight. VL [violations].");
|
||||||
set(ConfPaths.STRINGS + ".freach",
|
set(ConfPaths.STRINGS + ".freach",
|
||||||
"[player] failed [check]: tried to attack entity out of reach. VL [violations]");
|
"[player] failed [check]: tried to attack entity out of reach. VL [violations].");
|
||||||
set(ConfPaths.STRINGS + ".fspeed",
|
set(ConfPaths.STRINGS + ".fspeed",
|
||||||
"[player] failed [check]: tried to attack more than [limit] times per second. VL [violations]");
|
"[player] failed [check]: tried to attack more than [limit] times per second. VL [violations].");
|
||||||
set(ConfPaths.STRINGS + ".fnoswing", "[player] failed [check]: Didn't swing arm. VL [violations]");
|
set(ConfPaths.STRINGS + ".fnoswing", "[player] failed [check]: Didn't swing arm. VL [violations].");
|
||||||
set(ConfPaths.STRINGS + ".fgod", "[player] failed [check]: Avoided taking damage or lagging. VL [violations]");
|
set(ConfPaths.STRINGS + ".fgod", "[player] failed [check]: Avoided taking damage or lagging. VL [violations].");
|
||||||
set(ConfPaths.STRINGS + ".fheal",
|
set(ConfPaths.STRINGS + ".fheal",
|
||||||
"[player] failed [check]: Tried to regenerate health faster than normal. VL [violations]");
|
"[player] failed [check]: tried to regenerate health faster than normal. VL [violations].");
|
||||||
set(ConfPaths.STRINGS + ".fknock",
|
set(ConfPaths.STRINGS + ".fknock",
|
||||||
"[player] failed [check]: Tried to do a knockback but wasn't technically sprinting. VL [violations]");
|
"[player] failed [check]: tried to do a knockback but wasn't technically sprinting. VL [violations].");
|
||||||
set(ConfPaths.STRINGS + ".fcritical",
|
set(ConfPaths.STRINGS + ".fcritical",
|
||||||
"[player] failed [check]: Tried to do a critical hit but wasn't technically jumping. VL [violations]");
|
"[player] failed [check]: tried to do a critical hit but wasn't technically jumping. VL [violations].");
|
||||||
set(ConfPaths.STRINGS + ".ibow", "[player] failed [check]: Fires bow to fast. VL [violations]");
|
set(ConfPaths.STRINGS + ".ibow", "[player] failed [check]: fires bow to fast. VL [violations].");
|
||||||
set(ConfPaths.STRINGS + ".ieat", "[player] failed [check]: Eats food [food] too fast. VL [violations]");
|
set(ConfPaths.STRINGS + ".ieat", "[player] failed [check]: eats food [food] too fast. VL [violations].");
|
||||||
set(ConfPaths.STRINGS + ".kick", "kick [player]");
|
set(ConfPaths.STRINGS + ".kick", "kick [player]");
|
||||||
set(ConfPaths.STRINGS + ".ban", "ban [player]");
|
set(ConfPaths.STRINGS + ".ban", "ban [player]");
|
||||||
set(ConfPaths.STRINGS + ".ban-ip", "ban-ip [ip]");
|
set(ConfPaths.STRINGS + ".ban-ip", "ban-ip [ip]");
|
||||||
|
@ -10,6 +10,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -48,6 +49,16 @@ public class NCPPlayer {
|
|||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasPermission(final CommandSender sender, final String permission) {
|
||||||
|
String subPermission = "";
|
||||||
|
for (final String partOfPermission : permission.split("\\.")) {
|
||||||
|
subPermission += (subPermission == "" ? "" : ".") + partOfPermission;
|
||||||
|
if (sender.hasPermission(permission) || sender.hasPermission(permission + ".*"))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
private Player bukkitPlayer;
|
private Player bukkitPlayer;
|
||||||
@ -147,7 +158,13 @@ public class NCPPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermission(final String permission) {
|
public boolean hasPermission(final String permission) {
|
||||||
return bukkitPlayer.hasPermission(permission);
|
String subPermission = "";
|
||||||
|
for (final String partOfPermission : permission.split("\\.")) {
|
||||||
|
subPermission += (subPermission == "" ? "" : ".") + partOfPermission;
|
||||||
|
if (bukkitPlayer.hasPermission(permission) || bukkitPlayer.hasPermission(permission + ".*"))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
|
@ -92,6 +92,4 @@ public class Permissions {
|
|||||||
public static final String ZOMBE_FLY = ZOMBE + ".fly";
|
public static final String ZOMBE_FLY = ZOMBE + ".fly";
|
||||||
public static final String ZOMBE_NOCLIP = ZOMBE + ".noclip";
|
public static final String ZOMBE_NOCLIP = ZOMBE + ".noclip";
|
||||||
public static final String ZOMBE_CHEAT = ZOMBE + ".cheat";
|
public static final String ZOMBE_CHEAT = ZOMBE + ".cheat";
|
||||||
|
|
||||||
private Permissions() {}
|
|
||||||
}
|
}
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
package fr.neatmonster.nocheatplus.utilities;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Somehow manage color codes in NoCheatPlus
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class Colors {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove instances of &X
|
|
||||||
*
|
|
||||||
* @param text
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String removeColors(String text) {
|
|
||||||
|
|
||||||
for (final ChatColor c : ChatColor.values())
|
|
||||||
text = text.replace("&" + c.getChar(), "");
|
|
||||||
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replace instances of &X with a color
|
|
||||||
*
|
|
||||||
* @param text
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String replaceColors(String text) {
|
|
||||||
|
|
||||||
for (final ChatColor c : ChatColor.values())
|
|
||||||
text = text.replace("&" + c.getChar(), c.toString());
|
|
||||||
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
package fr.neatmonster.nocheatplus.utilities;
|
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
public class LogEvent extends Event {
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String message;
|
|
||||||
private String prefix;
|
|
||||||
|
|
||||||
private boolean toConsole, toChat, toFile;
|
|
||||||
|
|
||||||
public LogEvent(final String prefix, final String message, final boolean toConsole, final boolean toChat,
|
|
||||||
final boolean toFile) {
|
|
||||||
this.prefix = prefix;
|
|
||||||
this.message = message;
|
|
||||||
this.toConsole = toConsole;
|
|
||||||
this.toChat = toChat;
|
|
||||||
this.toFile = toFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessage() {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPrefix() {
|
|
||||||
return prefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessage(final String message) {
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPrefix(final String prefix) {
|
|
||||||
this.prefix = prefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setToChat(final boolean toChat) {
|
|
||||||
this.toChat = toChat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setToConsole(final boolean toConsole) {
|
|
||||||
this.toConsole = toConsole;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setToFile(final boolean toFile) {
|
|
||||||
this.toFile = toFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean toChat() {
|
|
||||||
return toChat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean toConsole() {
|
|
||||||
return toConsole;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean toFile() {
|
|
||||||
return toFile;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
package fr.neatmonster.nocheatplus.utilities;
|
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.logging.Formatter;
|
|
||||||
import java.util.logging.LogRecord;
|
|
||||||
|
|
||||||
public class LogFileFormatter extends Formatter {
|
|
||||||
|
|
||||||
private final SimpleDateFormat date;
|
|
||||||
|
|
||||||
public LogFileFormatter() {
|
|
||||||
date = new SimpleDateFormat("yy.MM.dd HH:mm:ss");
|
|
||||||
}
|
|
||||||
|
|
||||||
@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();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user