mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 22:15:28 +00:00
Added multilanguage capability
This commit is contained in:
1 parent
0f8ba3a6e9
commit
ba33955442
8 files changed
+125
-16
No files matched your search
@@ -33,6 +33,7 @@
|
|||||||
<includes>
|
<includes>
|
||||||
<include>plugin.yml</include>
|
<include>plugin.yml</include>
|
||||||
<include>config.yml</include>
|
<include>config.yml</include>
|
||||||
|
<include>lang.yml</include>
|
||||||
</includes>
|
</includes>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -257,6 +257,14 @@ public class Anticheat extends JavaPlugin
|
|||||||
logger.log(Level.INFO, "[AC] Config file created.");
|
logger.log(Level.INFO, "[AC] Config file created.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!new File(getDataFolder() + "/lang.yml").exists())
|
||||||
|
{
|
||||||
|
saveResource("lang.yml",false);
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
logger.log(Level.INFO, "[AC] Lang file created.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForUpdate()
|
private void checkForUpdate()
|
||||||
|
|||||||
@@ -36,8 +36,10 @@ public class Configuration
|
|||||||
private File configFile = null;
|
private File configFile = null;
|
||||||
private File levelFile = null;
|
private File levelFile = null;
|
||||||
private File bukkitFile = null;
|
private File bukkitFile = null;
|
||||||
|
private File langFile = null;
|
||||||
private FileConfiguration config;
|
private FileConfiguration config;
|
||||||
private FileConfiguration level;
|
private FileConfiguration level;
|
||||||
|
private FileConfiguration lang;
|
||||||
private boolean logConsole;
|
private boolean logConsole;
|
||||||
private boolean logXRay;
|
private boolean logXRay;
|
||||||
private boolean alertXRay;
|
private boolean alertXRay;
|
||||||
@@ -45,6 +47,7 @@ public class Configuration
|
|||||||
private boolean verboseStartup;
|
private boolean verboseStartup;
|
||||||
private int fileLogLevel = 0;
|
private int fileLogLevel = 0;
|
||||||
private String updateFolder;
|
private String updateFolder;
|
||||||
|
private static Language language;
|
||||||
private List<String> worlds = new ArrayList<String>();
|
private List<String> worlds = new ArrayList<String>();
|
||||||
|
|
||||||
public Configuration(AnticheatManager instance)
|
public Configuration(AnticheatManager instance)
|
||||||
@@ -53,6 +56,7 @@ public class Configuration
|
|||||||
configFile = new File(micromanage.getPlugin().getDataFolder()+"/config.yml");
|
configFile = new File(micromanage.getPlugin().getDataFolder()+"/config.yml");
|
||||||
levelFile = new File(micromanage.getPlugin().getDataFolder()+"/data/level.yml");
|
levelFile = new File(micromanage.getPlugin().getDataFolder()+"/data/level.yml");
|
||||||
bukkitFile = new File("bukkit.yml");
|
bukkitFile = new File("bukkit.yml");
|
||||||
|
langFile = new File(micromanage.getPlugin().getDataFolder()+"/lang.yml");
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,6 +107,11 @@ public class Configuration
|
|||||||
return fileLogLevel;
|
return fileLogLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Language getLang()
|
||||||
|
{
|
||||||
|
return language;
|
||||||
|
}
|
||||||
|
|
||||||
public final void load()
|
public final void load()
|
||||||
{
|
{
|
||||||
FileConfiguration bukkit;
|
FileConfiguration bukkit;
|
||||||
@@ -110,6 +119,8 @@ public class Configuration
|
|||||||
config = YamlConfiguration.loadConfiguration(configFile);
|
config = YamlConfiguration.loadConfiguration(configFile);
|
||||||
level = YamlConfiguration.loadConfiguration(levelFile);
|
level = YamlConfiguration.loadConfiguration(levelFile);
|
||||||
bukkit = YamlConfiguration.loadConfiguration(bukkitFile);
|
bukkit = YamlConfiguration.loadConfiguration(bukkitFile);
|
||||||
|
lang = YamlConfiguration.loadConfiguration(langFile);
|
||||||
|
language = new Language(lang);
|
||||||
updateFolder = bukkit.getString("settings.update-folder");
|
updateFolder = bukkit.getString("settings.update-folder");
|
||||||
if(config.getString("Logging.Log to console") != null)
|
if(config.getString("Logging.Log to console") != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package net.h31ix.anticheat;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
public class Language
|
||||||
|
{
|
||||||
|
private static String[] medAlert = null;
|
||||||
|
private static String[] highAlert = null;
|
||||||
|
private static String[] warning = null;
|
||||||
|
private static String banReason = null;
|
||||||
|
private static String banBroadcast = null;
|
||||||
|
private static String kickReason = null;
|
||||||
|
private static String kickBroadcast = null;
|
||||||
|
|
||||||
|
public Language(FileConfiguration file)
|
||||||
|
{
|
||||||
|
medAlert = file.getList("alert.medium_alert").toArray(new String[file.getList("alert.medium_alert").size()]);
|
||||||
|
highAlert = file.getList("alert.high_alert").toArray(new String[file.getList("alert.high_alert").size()]);
|
||||||
|
warning = file.getList("warning.player_warning").toArray(new String[file.getList("warning.player_warning").size()]);
|
||||||
|
banReason = file.getString("ban.ban_reason");
|
||||||
|
banBroadcast = file.getString("ban.ban_broadcast");
|
||||||
|
kickReason = file.getString("kick.kick_reason");
|
||||||
|
kickBroadcast = file.getString("kick.kick_broadcast");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String [] getMediumAlert()
|
||||||
|
{
|
||||||
|
return medAlert;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String [] getHighAlert()
|
||||||
|
{
|
||||||
|
return highAlert;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String [] getWarning()
|
||||||
|
{
|
||||||
|
return warning;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBanReason()
|
||||||
|
{
|
||||||
|
return banReason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBanBroadcast()
|
||||||
|
{
|
||||||
|
return banBroadcast;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKickReason()
|
||||||
|
{
|
||||||
|
return kickReason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKickBroadcast()
|
||||||
|
{
|
||||||
|
return kickBroadcast;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,7 +27,6 @@ import org.bukkit.ChatColor;
|
|||||||
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.Egg;
|
|
||||||
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;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ package net.h31ix.anticheat.manage;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import net.h31ix.anticheat.Configuration;
|
import net.h31ix.anticheat.Configuration;
|
||||||
|
import net.h31ix.anticheat.Language;
|
||||||
import net.h31ix.anticheat.util.Utilities;
|
import net.h31ix.anticheat.util.Utilities;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@@ -36,6 +37,7 @@ public class PlayerManager
|
|||||||
|
|
||||||
private static Map<String,Integer> level = new HashMap<String,Integer>();
|
private static Map<String,Integer> level = new HashMap<String,Integer>();
|
||||||
private static Configuration config = null;
|
private static Configuration config = null;
|
||||||
|
private static Language lang;
|
||||||
private static final int MED_THRESHOLD = 20;
|
private static final int MED_THRESHOLD = 20;
|
||||||
private static final int HIGH_THRESHOLD = 50;
|
private static final int HIGH_THRESHOLD = 50;
|
||||||
private static final int LEVEL_MAX = 60;
|
private static final int LEVEL_MAX = 60;
|
||||||
@@ -43,23 +45,18 @@ public class PlayerManager
|
|||||||
|
|
||||||
public PlayerManager(AnticheatManager instance) {
|
public PlayerManager(AnticheatManager instance) {
|
||||||
config = instance.getConfiguration();
|
config = instance.getConfiguration();
|
||||||
|
lang = config.getLang();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void reactMedium(Player player)
|
private static void reactMedium(Player player)
|
||||||
{
|
{
|
||||||
execute("Medium",player);
|
execute("Medium",player);
|
||||||
String [] alert = new String[2];
|
Utilities.alert(formatArray(lang.getMediumAlert(),player,ChatColor.YELLOW));
|
||||||
alert[0] = ChatColor.YELLOW+"[ALERT] "+ChatColor.WHITE+player.getName()+ChatColor.YELLOW+" has entered the MEDIUM hack level.";
|
|
||||||
alert[1] = ChatColor.YELLOW+"[ALERT] This means they may be using a hacked client or may have a bad connection!";
|
|
||||||
Utilities.alert(alert);
|
|
||||||
}
|
}
|
||||||
private static void reactHigh(Player player)
|
private static void reactHigh(Player player)
|
||||||
{
|
{
|
||||||
execute("High",player);
|
execute("High",player);
|
||||||
String [] alert = new String[2];
|
Utilities.alert(formatArray(lang.getHighAlert(),player,ChatColor.RED));
|
||||||
alert[0] = ChatColor.RED+"[ALERT] "+ChatColor.WHITE+player.getName()+ChatColor.RED+" has entered the HIGH hack level.";
|
|
||||||
alert[1] = ChatColor.RED+"[ALERT] This means they probably are hacking or are lagging out!";
|
|
||||||
Utilities.alert(alert);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void increaseLevel(Player player)
|
public void increaseLevel(Player player)
|
||||||
@@ -149,19 +146,34 @@ public class PlayerManager
|
|||||||
}
|
}
|
||||||
else if(result.equalsIgnoreCase("KICK"))
|
else if(result.equalsIgnoreCase("KICK"))
|
||||||
{
|
{
|
||||||
player.kickPlayer(ChatColor.RED+"Kicked by AntiCheat");
|
player.kickPlayer(formatString(lang.getKickReason(),player,ChatColor.RED));
|
||||||
player.getServer().broadcastMessage(ChatColor.RED+"[AntiCheat] "+player.getName()+" was kicked for hacking.");
|
player.getServer().broadcastMessage(formatString(lang.getKickBroadcast(),player,ChatColor.RED));
|
||||||
}
|
}
|
||||||
else if(result.equalsIgnoreCase("WARN"))
|
else if(result.equalsIgnoreCase("WARN"))
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED+"[AntiCheat] Hacks are not allowed on this server.");
|
String[] message = formatArray(lang.getWarning(),player,ChatColor.RED);
|
||||||
player.sendMessage(ChatColor.RED+"[AntiCheat] If you continue to use hacks, action will be taken.");
|
for(String string : message)
|
||||||
|
{
|
||||||
|
player.sendMessage(string);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(result.equalsIgnoreCase("BAN"))
|
else if(result.equalsIgnoreCase("BAN"))
|
||||||
{
|
{
|
||||||
player.setBanned(true);
|
player.setBanned(true);
|
||||||
player.kickPlayer(ChatColor.RED+"Banned by AntiCheat");
|
player.kickPlayer(formatString(lang.getBanReason(),player,ChatColor.RED));
|
||||||
player.getServer().broadcastMessage(ChatColor.RED+"[AntiCheat] "+player.getName()+" was banned for hacking.");
|
player.getServer().broadcastMessage(formatString(lang.getBanBroadcast(),player,ChatColor.RED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private static String [] formatArray(String [] array, Player player, ChatColor color)
|
||||||
|
{
|
||||||
|
for(int i=0;i<array.length;i++)
|
||||||
|
{
|
||||||
|
array[i] = formatString(array[i],player,color);
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
private static String formatString(String string, Player player, ChatColor color)
|
||||||
|
{
|
||||||
|
return color+string.replaceAll("&player", ChatColor.WHITE+player.getName()+color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.h31ix.anticheat.Anticheat;
|
import net.h31ix.anticheat.Anticheat;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
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;
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
alert:
|
||||||
|
medium_alert:
|
||||||
|
- '[ALERT] &player has entered the MEDIUM hack level.'
|
||||||
|
- '[ALERT] This means they may be using a hacked client or may have a bad connection!'
|
||||||
|
high_alert:
|
||||||
|
- '[ALERT] &player has entered the HIGH hack level.'
|
||||||
|
- '[ALERT] This means they probably are hacking or are lagging out!'
|
||||||
|
warning:
|
||||||
|
player_warning:
|
||||||
|
- '[AntiCheat] Hacks are not allowed on this server.'
|
||||||
|
- '[AntiCheat] If you continue to use hacks, action will be taken.'
|
||||||
|
ban:
|
||||||
|
ban_reason: 'Banned by AntiCheat'
|
||||||
|
ban_broadcast: '[AntiCheat] &player was banned for hacking.'
|
||||||
|
kick:
|
||||||
|
kick_reason: 'Kicked by AntiCheat'
|
||||||
|
kick_broadcast: '[AntiCheat] &player was kicked for hacking.'
|
||||||
|
|
||||||
Reference in new issue
Block a user