Fixed a lot of things. Plugin should work a lot better on 1.12 now.

This commit is contained in:
marcomoesman committed 2018-08-13 14:36:05 +02:00
1 parent f609758d28
commit 06c1eab2e6
52 files changed
+416 -343

No files matched your search

@@ -20,7 +20,7 @@ package com.rammelkast.anticheatreloaded.util;
import org.bukkit.ChatColor;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import java.util.ArrayList;
import java.util.Arrays;
@@ -41,8 +41,8 @@ public class Group {
ChatColor c = ChatColor.valueOf(color);
if (c == null) {
AntiCheat.getPlugin().getLogger().warning("Event '" + name + "' was initialized with the color '" + color + "' which is invalid.");
AntiCheat.getPlugin().getLogger().warning("This event will not run properly. See http://jd.bukkit.org/apidocs/org/bukkit/ChatColor.html#enum_constant_summary for a list of valid colors");
AntiCheatReloaded.getPlugin().getLogger().warning("Event '" + name + "' was initialized with the color '" + color + "' which is invalid.");
AntiCheatReloaded.getPlugin().getLogger().warning("This event will not run properly. See http://jd.bukkit.org/apidocs/org/bukkit/ChatColor.html#enum_constant_summary for a list of valid colors");
} else {
this.color = c;
}
@@ -75,9 +75,9 @@ public class Group {
throw new Exception();
}
} catch (Exception ex) {
AntiCheat.getPlugin().getLogger().warning("An event was initialized with an invalid string: '" + string + "'");
AntiCheat.getPlugin().getLogger().warning("The proper format is: 'name : threshold : color : action' such as 'High : 50 : RED : KICK'");
AntiCheat.getPlugin().getLogger().warning("This event will NOT run. (" + ex.getMessage() + ")");
AntiCheatReloaded.getPlugin().getLogger().warning("An event was initialized with an invalid string: '" + string + "'");
AntiCheatReloaded.getPlugin().getLogger().warning("The proper format is: 'name : threshold : color : action' such as 'High : 50 : RED : KICK'");
AntiCheatReloaded.getPlugin().getLogger().warning("This event will NOT run. (" + ex.getMessage() + ")");
return null;
}
}
@@ -5,20 +5,24 @@ import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import com.mojang.authlib.GameProfile;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import net.minecraft.server.v1_12_R1.EntityHuman;
import net.minecraft.server.v1_12_R1.EntityPlayer;
import net.minecraft.server.v1_12_R1.EnumItemSlot;
import net.minecraft.server.v1_12_R1.MinecraftServer;
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityTeleport;
@@ -62,6 +66,8 @@ public class NPC_1_12 {
this.location.getZ(), 0.0f, 0.0f);
this.npc.collides = false;
this.npc.setInvisible(true);
this.npc.setEquipment(EnumItemSlot.CHEST, AntiCheatReloaded.getRandom().nextBoolean() ? CraftItemStack.asNMSCopy(new ItemStack(Material.DIAMOND_CHESTPLATE)) : CraftItemStack.asNMSCopy(new ItemStack(Material.CHAINMAIL_CHESTPLATE)));
this.npc.setEquipment(EnumItemSlot.FEET, AntiCheatReloaded.getRandom().nextBoolean() ? CraftItemStack.asNMSCopy(new ItemStack(Material.CHAINMAIL_BOOTS)) : CraftItemStack.asNMSCopy(new ItemStack(Material.DIAMOND_BOOTS)));
this.entityId = this.npc.getId();
final PlayerConnection connection = ((CraftPlayer) this.getOwner()).getHandle().playerConnection;
connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER,
@@ -89,10 +95,13 @@ public class NPC_1_12 {
new BukkitRunnable() {
@Override
public void run() {
if (NPC_1_12.this.npc == null || NPC_1_12.this.getOwner() == null) {
return;
}
npc.setInvisible(true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
}
}.runTaskLater(AntiCheat.getPlugin(), 4);
}.runTaskLater(AntiCheatReloaded.getPlugin(), 4);
}
}else {
Location eyelocation = e.getPlayer().getEyeLocation();
@@ -137,10 +146,13 @@ public class NPC_1_12 {
new BukkitRunnable() {
@Override
public void run() {
if (NPC_1_12.this.npc == null || NPC_1_12.this.getOwner() == null) {
return;
}
npc.setInvisible(true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
}
}.runTaskLater(AntiCheat.getPlugin(), 6);
}.runTaskLater(AntiCheatReloaded.getPlugin(), 6);
}
}
}
@@ -159,10 +171,13 @@ public class NPC_1_12 {
new BukkitRunnable() {
@Override
public void run() {
if (NPC_1_12.this.npc == null || NPC_1_12.this.getOwner() == null) {
return;
}
npc.setInvisible(true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
}
}.runTaskLater(AntiCheat.getPlugin(), 6 + new Random().nextInt(7));
}.runTaskLater(AntiCheatReloaded.getPlugin(), 6 + new Random().nextInt(7));
}
}
@@ -176,10 +191,13 @@ public class NPC_1_12 {
new BukkitRunnable() {
@Override
public void run() {
if (NPC_1_12.this.npc == null || NPC_1_12.this.getOwner() == null) {
return;
}
npc.setInvisible(true);
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
}
}.runTaskLater(AntiCheat.getPlugin(), 6 + new Random().nextInt(8));
}.runTaskLater(AntiCheatReloaded.getPlugin(), 6 + new Random().nextInt(8));
}
}
@@ -15,7 +15,9 @@ public class NameGenerator {
"New",
"Ultra",
"Killer",
"Swift"
"Swift",
"Yolo",
"Rammel"
});
private static final List<String> END = Arrays.asList(new String[]{
@@ -26,9 +28,7 @@ public class NameGenerator {
"Minecraft",
"Games",
"Bawz",
"1",
"51",
"99",
"kast",
"" + new Random().nextInt(100)
});
@@ -24,7 +24,7 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.providers.Magic;
@@ -104,7 +104,7 @@ public class PastebinReport {
}
private void appendLogs() {
List<String> logs = AntiCheat.getManager().getLoggingManager().getLastLogs();
List<String> logs = AntiCheatReloaded.getManager().getLoggingManager().getLastLogs();
if (logs.size() == 0) {
append("No recent logs.");
return;
@@ -116,8 +116,8 @@ public class PastebinReport {
private void appendSystemInfo() {
Runtime runtime = Runtime.getRuntime();
Configuration config = AntiCheat.getManager().getConfiguration();
append("AntiCheat Version: " + AntiCheat.getVersion());
Configuration config = AntiCheatReloaded.getManager().getConfiguration();
append("AntiCheat Version: " + AntiCheatReloaded.getVersion());
append("Server Version: " + Bukkit.getVersion());
append("Server Implementation: " + Bukkit.getName());
append("Server ID: " + Bukkit.getServerId());
@@ -130,7 +130,7 @@ public class PastebinReport {
append("Online Mode: " + Bukkit.getOnlineMode());
append("Players: " + Bukkit.getOnlinePlayers().size() + "/" + Bukkit.getMaxPlayers());
append("Plugin Count: " + Bukkit.getPluginManager().getPlugins().length);
append("Plugin Uptime: " + ((System.currentTimeMillis() - AntiCheat.getPlugin().getLoadTime()) / 1000) / 60 + " minutes");
append("Plugin Uptime: " + ((System.currentTimeMillis() - AntiCheatReloaded.getPlugin().getLoadTime()) / 1000) / 60 + " minutes");
append("Enterprise: " + config.getConfig().enterprise.getValue());
if (config.getConfig().enterprise.getValue()) {
append("- Server name: " + config.getEnterprise().serverName.getValue());
@@ -143,8 +143,8 @@ public class PastebinReport {
private void appendMagicDiff() {
// This is hacky, and I like it
Magic magic = AntiCheat.getManager().getConfiguration().getMagic();
FileConfiguration file = YamlConfiguration.loadConfiguration(new File(AntiCheat.getPlugin().getDataFolder(), "magic.yml"));
Magic magic = AntiCheatReloaded.getManager().getConfiguration().getMagic();
FileConfiguration file = YamlConfiguration.loadConfiguration(new File(AntiCheatReloaded.getPlugin().getDataFolder(), "magic.yml"));
boolean changed = false;
for (Field field : Magic.class.getFields()) {
Object defaultValue = file.get(field.getName());
@@ -169,11 +169,11 @@ public class PastebinReport {
}
private void appendEventHandlers() {
report.append(AntiCheat.getManager().getEventChainReport());
report.append(AntiCheatReloaded.getManager().getEventChainReport());
}
private void writeReport() throws IOException {
File f = new File(AntiCheat.getPlugin().getDataFolder() + "/report.txt");
File f = new File(AntiCheatReloaded.getPlugin().getDataFolder() + "/report.txt");
FileWriter r = new FileWriter(f);
BufferedWriter writer = new BufferedWriter(r);
writer.write(report.toString());
@@ -24,7 +24,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.util.rule.Rule;
@@ -41,7 +41,7 @@ public class User {
private int level = 0;
private Location goodLocation;
private List<ItemStack> inventorySnapshot = null;
private Configuration config = AntiCheat.getManager().getConfiguration();
private Configuration config = AntiCheatReloaded.getManager().getConfiguration();
private int toX, toY, toZ;
private String[] messages = new String[2];
private Long[] messageTimes = new Long[2];
@@ -151,7 +151,7 @@ public class User {
// Check levels
for (Group l : getLevels()) {
if (l.getLevel() == level) {
AntiCheat.getManager().getUserManager().alert(this, l, type);
AntiCheatReloaded.getManager().getUserManager().alert(this, l, type);
if (l.getLevel() == config.getGroups().getHighestLevel()) {
level = l.getLevel() - 10;
}
@@ -28,7 +28,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.NumberConversions;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import java.util.ArrayList;
import java.util.HashMap;
@@ -59,7 +59,7 @@ public final class Utilities {
}
}
for (String msg : message) {
AntiCheat.getManager().log(msg);
AntiCheatReloaded.getManager().log(msg);
}
}
@@ -1,6 +1,8 @@
package com.rammelkast.anticheatreloaded.util;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@@ -8,10 +10,27 @@ import org.bukkit.entity.Player;
public class VersionUtil {
private static final List<String> SUPPORTED_VERSIONS = Arrays.asList(new String[] {
"v1_8",
"v1_9",
"v1_10",
"v1_11",
"v1_12"
});
public static String getVersion() {
return Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
}
public static boolean isSupported() {
for (String versionId : SUPPORTED_VERSIONS) {
if (getVersion().startsWith(versionId)) {
return true;
}
}
return false;
}
private static final EnumSet<Material> MOVE_UP_BLOCKS_1_8 = EnumSet.of(Material.ACACIA_STAIRS,
Material.BIRCH_WOOD_STAIRS, Material.BRICK_STAIRS, Material.COBBLESTONE_STAIRS, Material.DARK_OAK_STAIRS,
Material.JUNGLE_WOOD_STAIRS, Material.NETHER_BRICK_STAIRS, Material.QUARTZ_STAIRS,
@@ -52,6 +71,9 @@ public class VersionUtil {
public static boolean isFrostWalk(Player player) {
if (getVersion().startsWith("v1_9") || getVersion().startsWith("v1_10") || getVersion().startsWith("v1_11") || getVersion().startsWith("v1_12")) {
if (player.getInventory().getBoots() == null) {
return false;
}
return player.getInventory().getBoots().containsEnchantment(NMS_1_9_PLUS.FROST_WALKER);
} else {
return false;
@@ -21,7 +21,7 @@ package com.rammelkast.anticheatreloaded.util.enterprise;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitTask;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.util.User;
import com.rammelkast.anticheatreloaded.util.Utilities;
@@ -137,7 +137,7 @@ public class Database {
connection.setAutoCommit(false);
if (logInterval != 0) {
eventTask = Bukkit.getScheduler().runTaskTimerAsynchronously(AntiCheat.getPlugin(), new Runnable() {
eventTask = Bukkit.getScheduler().runTaskTimerAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override
public void run() {
flushEvents();
@@ -146,7 +146,7 @@ public class Database {
}
if(syncLevels && syncInterval != 0) {
syncTask = Bukkit.getScheduler().runTaskTimerAsynchronously(AntiCheat.getPlugin(), new Runnable() {
syncTask = Bukkit.getScheduler().runTaskTimerAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override
public void run() {
syncUsers();
@@ -154,7 +154,7 @@ public class Database {
}, syncInterval * 20, syncInterval * 20);
}
AntiCheat.getPlugin().verboseLog("Connected to the database.");
AntiCheatReloaded.getPlugin().verboseLog("Connected to the database.");
} catch (SQLException e) {
e.printStackTrace();
}
@@ -203,7 +203,7 @@ public class Database {
public void cleanEvents() {
if (logLife != 0) {
Bukkit.getScheduler().runTaskAsynchronously(AntiCheat.getPlugin(), new Runnable() {
Bukkit.getScheduler().runTaskAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override
public void run() {
try {
@@ -213,7 +213,7 @@ public class Database {
statement.executeUpdate();
connection.commit();
AntiCheat.getPlugin().verboseLog("Cleaned " + statement.getUpdateCount() + " old events from the database");
AntiCheatReloaded.getPlugin().verboseLog("Cleaned " + statement.getUpdateCount() + " old events from the database");
} catch (SQLException e) {
e.printStackTrace();
}
@@ -223,8 +223,8 @@ public class Database {
}
private void syncUsers() {
for (User user : AntiCheat.getManager().getUserManager().getUsers()) {
AntiCheat.getManager().getConfiguration().getLevels().updateLevelToUser(user);
for (User user : AntiCheatReloaded.getManager().getUserManager().getUsers()) {
AntiCheatReloaded.getManager().getConfiguration().getLevels().updateLevelToUser(user);
}
}
}
@@ -20,7 +20,7 @@ package com.rammelkast.anticheatreloaded.util.rule;
import org.bukkit.GameMode;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.util.Group;
import com.rammelkast.anticheatreloaded.util.User;
@@ -175,7 +175,7 @@ public class Rule {
if (variable.equals("player_level") && Utilities.isInt(value)) {
user.setLevel(Integer.parseInt(value));
} else if (variable.equals("player_group") && Utilities.isInt(value)) {
for (Group group : AntiCheat.getManager().getConfiguration().getGroups().getGroups()) {
for (Group group : AntiCheatReloaded.getManager().getConfiguration().getGroups().getGroups()) {
if (group.getName().equalsIgnoreCase(value)) {
user.setLevel(group.getLevel());
}
@@ -196,7 +196,7 @@ public class Rule {
text = text.split("\\.")[1];
List<String> action = new ArrayList<String>();
action.add(text);
AntiCheat.getManager().getUserManager().execute(user, action, type);
AntiCheatReloaded.getManager().getUserManager().execute(user, action, type);
}
}