Ready for Minecraft 1.12

This commit is contained in:
Rammelkast committed 2017-11-20 19:34:51 +01:00
1 parent 2d064ee849
commit f609758d28
9 files changed
+73 -29

No files matched your search

@@ -16,7 +16,7 @@ import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.event.EventListener;
import com.rammelkast.anticheatreloaded.util.NPC_1_11;
import com.rammelkast.anticheatreloaded.util.NPC_1_12;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
/**
@@ -24,7 +24,7 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
*/
public class KillAuraCheck {
private static final Map<UUID, NPC_1_11> NPC_LIST = new HashMap<UUID, NPC_1_11>();
private static final Map<UUID, NPC_1_12> NPC_LIST = new HashMap<UUID, NPC_1_12>();
private static final Map<UUID, Integer> VL_COUNT = new HashMap<UUID, Integer>();
public static void cleanPlayer(Player p) {
@@ -72,7 +72,7 @@ public class KillAuraCheck {
if (NPC_LIST.containsKey(p.getUniqueId()))
NPC_LIST.get(p.getUniqueId()).damage(e, p);
else {
NPC_1_11 npc = new NPC_1_11(p);
NPC_1_12 npc = new NPC_1_12(p);
NPC_LIST.put(p.getUniqueId(), npc);
npc.spawn();
}
@@ -0,0 +1,17 @@
package com.rammelkast.anticheatreloaded.check.player;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
*
* @author Rammelkast
*
*/
public class GhosthandCheck {
public static final Map<UUID, Integer> FLAG_COUNT = new HashMap<UUID, Integer>();
public static final int MAX_FLAGS = 3; // TODO config?
}
@@ -26,6 +26,7 @@ import com.rammelkast.anticheatreloaded.config.yaml.CommentedConfiguration;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
public class ConfigurationFile {
@@ -59,7 +60,13 @@ public class ConfigurationFile {
this.saveDefault = saveDefault;
if (saveDefault) {
defaultConfigFile = YamlConfiguration.loadConfiguration(plugin.getResource(fileName));
InputStreamReader reader = new InputStreamReader(plugin.getResource(fileName));
defaultConfigFile = YamlConfiguration.loadConfiguration(reader);
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
load();
}
@@ -26,6 +26,8 @@ import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
import com.rammelkast.anticheatreloaded.config.providers.Lang;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.sql.PreparedStatement;
@@ -50,7 +52,13 @@ public class MySQLLangHolder extends ConfigurationTable implements InvocationHan
@Override
public void open() {
defaults = YamlConfiguration.loadConfiguration(AntiCheat.getPlugin().getResource("lang.yml"));
InputStreamReader reader = new InputStreamReader(AntiCheat.getPlugin().getResource("lang.yml"));
defaults = YamlConfiguration.loadConfiguration(reader);
try {
reader.close();
} catch (IOException e1) {
e1.printStackTrace();
}
stringValues = new HashMap<String, String>();
listValues = new HashMap<String, List<String>>();
@@ -26,6 +26,8 @@ import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
import com.rammelkast.anticheatreloaded.config.providers.Magic;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.sql.ResultSet;
@@ -47,7 +49,13 @@ public class MySQLMagicHolder extends ConfigurationTable implements InvocationHa
@Override
public void open() {
defaults = YamlConfiguration.loadConfiguration(AntiCheat.getPlugin().getResource("magic.yml"));
InputStreamReader reader = new InputStreamReader(AntiCheat.getPlugin().getResource("magic.yml"));
defaults = YamlConfiguration.loadConfiguration(reader);
try {
reader.close();
} catch (IOException e1) {
e1.printStackTrace();
}
ints = new HashMap<String, Integer>();
doubles = new HashMap<String, Double>();
@@ -33,6 +33,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.Map;
@@ -188,7 +189,9 @@ public class CommentedConfiguration extends YamlConfiguration {
CommentedConfiguration config = new CommentedConfiguration();
try {
config.load(stream);
InputStreamReader reader = new InputStreamReader(stream);
config.load(reader);
reader.close();
} catch (IOException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex);
} catch (InvalidConfigurationException ex) {
@@ -18,6 +18,11 @@
package com.rammelkast.anticheatreloaded.manage;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.bukkit.BanList.Type;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@@ -28,10 +33,6 @@ import com.rammelkast.anticheatreloaded.util.Group;
import com.rammelkast.anticheatreloaded.util.User;
import com.rammelkast.anticheatreloaded.util.Utilities;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class UserManager {
private List<User> users = new ArrayList<User>();
private static AntiCheatManager manager;
@@ -243,7 +244,7 @@ public class UserManager {
}
}
} else if (event.equalsIgnoreCase("BAN")) {
user.getPlayer().setBanned(true);
Bukkit.getBanList(Type.NAME).addBan(user.getPlayer().getName(), RED + banReason, null, null);
user.getPlayer().kickPlayer(RED + banReason);
String msg = RED + config.getLang().BAN_BROADCAST().replaceAll("&player", name) + " (" + CheckType.getName(type) + ")";
if (!msg.equals("")) {
@@ -5,9 +5,9 @@ import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_11_R1.CraftServer;
import org.bukkit.craftbukkit.v1_11_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
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.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerMoveEvent;
@@ -17,19 +17,19 @@ import org.bukkit.util.Vector;
import com.mojang.authlib.GameProfile;
import com.rammelkast.anticheatreloaded.AntiCheat;
import net.minecraft.server.v1_11_R1.EntityHuman;
import net.minecraft.server.v1_11_R1.EntityPlayer;
import net.minecraft.server.v1_11_R1.MinecraftServer;
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_11_R1.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_11_R1.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_11_R1.PlayerConnection;
import net.minecraft.server.v1_11_R1.PlayerInteractManager;
import net.minecraft.server.v1_11_R1.World;
import net.minecraft.server.v1_11_R1.WorldServer;
import net.minecraft.server.v1_12_R1.EntityHuman;
import net.minecraft.server.v1_12_R1.EntityPlayer;
import net.minecraft.server.v1_12_R1.MinecraftServer;
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_12_R1.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_12_R1.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_12_R1.PlayerConnection;
import net.minecraft.server.v1_12_R1.PlayerInteractManager;
import net.minecraft.server.v1_12_R1.World;
import net.minecraft.server.v1_12_R1.WorldServer;
public class NPC_1_11 {
public class NPC_1_12 {
private final UUID owner;
private final String name;
@@ -42,7 +42,7 @@ public class NPC_1_11 {
return this.entityId;
}
public NPC_1_11(Player owner) {
public NPC_1_12(Player owner) {
this.owner = owner.getUniqueId();
this.name = NameGenerator.generateName();
Location eyelocation = owner.getEyeLocation();