Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Commit

Permalink
Changed default messages and added start of config validation
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlOfDuty committed Jun 27, 2018
1 parent 900cafc commit c66ffb7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 14 deletions.
24 changes: 21 additions & 3 deletions src/main/java/com/karlofduty/altfinder/AltFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.karlofduty.altfinder.commands.IPCommand;
import com.karlofduty.altfinder.commands.MCLeaksCommand;
import me.gong.mcleaks.MCLeaksAPI;
import org.bukkit.ChatColor;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
Expand All @@ -12,6 +13,7 @@
public class AltFinder extends JavaPlugin
{
public static FileConfiguration config;
private static String configVersion = "00001";
public final MCLeaksAPI mcLeaksAPI = MCLeaksAPI.builder()
.threadCount(2)
.expireAfter(30, TimeUnit.MINUTES).build();
Expand All @@ -20,12 +22,24 @@ public class AltFinder extends JavaPlugin
@Override
public void onEnable()
{
instance = this;

//TODO: Config validation
saveDefaultConfig();
config = this.getConfig();
//Fired when the server enables the plugin
instance = this;
if(!config.getString("config-version").equalsIgnoreCase(configVersion))
{
logColoured(ChatColor.YELLOW + "Your config was made for an older version of AltFinder, you can check the GitHub page for new config options or remove 'config-version' from config.yml\n" +
"\n" +
"Current config version: " + config.getString("config-version") + "\n"+
"Compatible config version: " + configVersion + "\n");
}

// Set command executors
this.getCommand("ip").setExecutor(new IPCommand());
this.getCommand("mcleaks").setExecutor(new MCLeaksCommand());

// Register events
getServer().getPluginManager().registerEvents(new EventListener(), this);
}

Expand Down Expand Up @@ -53,8 +67,12 @@ public static void log(String message)
{
instance.getServer().getLogger().info(message);
}
public static void logColoured(String message)
{
getConsole().sendMessage(message);
}
public static void logWarning(String message)
{
instance.getServer().getLogger().warning(message);
instance.getServer().getLogger().warning(ChatColor.GOLD + message);
}
}
3 changes: 2 additions & 1 deletion src/main/java/com/karlofduty/altfinder/ConfigValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ static String getParsedString(String configPath, CommandSender source, String ta
result = result.replaceAll("<targetip>", targetIP);

result = ChatColor.translateAlternateColorCodes('&', result);
AltFinder.getInstance().getLogger().info(ChatColor.stripColor(result));
AltFinder.log("[Server -> " + sourceName + "]: " + ChatColor.stripColor(result));
return result;
}

// Gets the info needed for getParsedString(...) from either an online or offline player
static String[] getPlayerInfo(String username)
{
if(Bukkit.getPlayer(username) != null)
Expand Down
24 changes: 14 additions & 10 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@
## &K RANDOM
## &O ITALIC

# Only change this value if you have manually added new config entries and want to remove the console warning
config-version: "00001"

database:
type: "mysql"
mysql:
database: "altfinder"
hostname: "127.0.0.1"
port: "3306"
username: ""
username: "root"
password: ""

# Settings related to the anti-mcleaks part of the plugin
Expand All @@ -51,21 +55,21 @@ mcleaks:
# Actions to take when an error occurs and a player can't be checked
error:
notify: true
notification: "&eAn error occurred while automatically checking <targetplayer> in the MCLeaks database."
notification: "&6An error occurred while automatically checking &e<targetplayer>&6 in the MCLeaks database."
execute-command: true
command: "mail send admin Error occured checking <targetplayer>"

# Actions to take when a player is not on the confirmed mcleaks list
not-mcleaks:
notify: false
notification: "&e<targetplayer> is &2NOT &eon the list of confirmed MCLeaksChecker accounts although may still be one."
notification: "&e<targetplayer>&6 is &2NOT &6on the list of confirmed MCLeaksChecker accounts although may still be one."
execute-command: false
command: "setgroup <targetplayer> Trusted"

# Actions to take when a player is on the confirmed mcleaks list
is-mcleaks:
notify: true
notification: "&e<targetplayer> &cIS &eon the list of confirmed MCLeaks accounts."
notification: "&e<targetplayer>&6 &cIS &6on the list of confirmed MCLeaks accounts."
execute-command: true
command: "ban <targetplayer> Using a stolen/hacked account."

Expand All @@ -84,16 +88,16 @@ commands:

# /ip
ip:
self: "&eYour current IP address is &6<sourceip>&e."
other: "&eThe player's current IP address is &6<targetip>&e."
no-such-player: "&eThat player is not currently online."
self: "&6Your current IP address is &e<sourceip>&6."
other: "&6The player's current IP address is &e<targetip>&6."
no-such-player: "&6That player is not currently online."

# /mcleaks
mcleaks:
error: "&6An error occurred fetching player from MCLeaksChecker database, try again later."
not-found: "&e<targetplayer> is &2NOT &eon the list of confirmed MCLeaks accounts although may still be one."
found: "&e<targetplayer> &cIS &eon the list of confirmed MCLeaksChecker account."
no-such-player: "&e<targetplayer> has not joined the server before."
not-found: "&e<targetplayer>&6 is &2NOT &6on the list of confirmed MCLeaks accounts although may still be one."
found: "&e<targetplayer>&6 &cIS &6on the list of confirmed MCLeaksChecker account."
no-such-player: "&e<targetplayer> &6has not joined the server before."

# General command feedback, target player variables do not work here
no-perm: "&cYou do not have permission to do that."
Expand Down

0 comments on commit c66ffb7

Please sign in to comment.