Rewrote everything to be up-to date with 1.18, using Minimessage, moved config to share and added more things to the config, optimized use of the database
This commit is contained in:
parent
99e5c1b25e
commit
38ce337fe9
4
pom.xml
4
pom.xml
|
|
@ -21,8 +21,8 @@
|
|||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<source>16</source>
|
||||
<target>16</target>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
package com.liteflags;
|
||||
|
||||
import com.liteflags.auth.AuthTimer;
|
||||
import com.liteflags.commands.FlagCMD;
|
||||
import com.liteflags.commands.CommandManager;
|
||||
import com.liteflags.data.database.DatabaseConnection;
|
||||
import com.liteflags.events.ChatEvent;
|
||||
import com.liteflags.events.LoginEvent;
|
||||
import com.liteflags.events.LogoutEvent;
|
||||
import com.liteflags.events.MoveEvent;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.liteflags.config.Config;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class LiteFlags extends JavaPlugin {
|
||||
|
|
@ -17,22 +19,20 @@ public class LiteFlags extends JavaPlugin {
|
|||
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
this.saveDefaultConfig();
|
||||
this.getCommand("flag").setExecutor(new FlagCMD());
|
||||
this.getCommand("flaglist").setExecutor(new FlagCMD());
|
||||
Config.reload();
|
||||
this.getCommand("flag").setExecutor(new CommandManager());
|
||||
this.getServer().getPluginManager().registerEvents(new LoginEvent(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new LogoutEvent(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new ChatEvent(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new MoveEvent(), this);
|
||||
|
||||
try {
|
||||
DatabaseConnection var10000 = this.database;
|
||||
DatabaseConnection.initialize();
|
||||
} catch (SQLException var2) {
|
||||
} catch (SQLException exception) {
|
||||
this.getLogger().severe("*** Could not connect to the database. ***");
|
||||
this.getLogger().severe("*** This plugin will be disabled. ***");
|
||||
this.setEnabled(false);
|
||||
var2.printStackTrace();
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,36 +1,44 @@
|
|||
package com.liteflags.auth;
|
||||
|
||||
import com.liteflags.LiteFlags;
|
||||
import com.liteflags.config.Config;
|
||||
import com.liteflags.data.maps.MapCache;
|
||||
import com.liteflags.util.Utilities;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AuthTimer<taskID> {
|
||||
public LiteFlags flags;
|
||||
public static Map<UUID, Integer> taskID = new HashMap();
|
||||
public static Map<UUID, Integer> taskID = new HashMap<>();
|
||||
|
||||
public AuthTimer(LiteFlags flags) {
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
public static void startTimer(final Player player) {
|
||||
final String uuid = player.getUniqueId().toString();
|
||||
|
||||
int tid = LiteFlags.getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(LiteFlags.getInstance(), new Runnable() {
|
||||
int timeRemaining = LiteFlags.getInstance().getConfig().getInt("Authenticate_Timer");
|
||||
int timeRemaining = Config.AUTH_MESSAGE_REPEAT_TIMER;
|
||||
|
||||
public void run() {
|
||||
if (this.timeRemaining <= 0) {
|
||||
if (player.hasPermission("liteflags.authentication.success")) {
|
||||
AuthTimer.endTask(player);
|
||||
} else {
|
||||
player.sendMessage(Utilities.format(LiteFlags.getInstance().getConfig().getString("Messages.Authenticate").replace("%code%", (CharSequence) MapCache.reauthedPlayers.get(player.getUniqueId().toString()))));
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), LiteFlags.getInstance().getConfig().getString("Authenticate_Timer_Command").replace("%player%", player.getName()).replace("%code%", (CharSequence) MapCache.reauthedPlayers.get(player.getUniqueId().toString())));
|
||||
this.timeRemaining = LiteFlags.getInstance().getConfig().getInt("Authenticate_Timer");
|
||||
player.sendMiniMessage(Config.AUTHENTICATE, List.of(
|
||||
Template.template("code", MapCache.reauthedPlayers.get(uuid))));
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), Config.AUTH_MESSAGE_COMMAND
|
||||
.replaceAll("<player>", player.getName())
|
||||
.replaceAll("<code>", MapCache.reauthedPlayers.get(uuid)));
|
||||
this.timeRemaining = Config.AUTH_MESSAGE_REPEAT_TIMER;
|
||||
}
|
||||
} else if (player.hasPermission("liteflags.authentication.success")) {
|
||||
AuthTimer.endTask(player);
|
||||
|
|
@ -40,7 +48,9 @@ public class AuthTimer<taskID> {
|
|||
|
||||
}
|
||||
}, 0L, 20L);
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), LiteFlags.getInstance().getConfig().getString("Authenticate_Timer_Command").replace("%player%", player.getName()).replace("%code%", (CharSequence) MapCache.reauthedPlayers.get(player.getUniqueId().toString())));
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), Config.AUTH_MESSAGE_COMMAND
|
||||
.replaceAll("<player>", player.getName())
|
||||
.replaceAll("<code>", MapCache.reauthedPlayers.get(uuid)));
|
||||
taskID.put(player.getUniqueId(), tid);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
package com.liteflags.auth;
|
||||
|
||||
import com.liteflags.LiteFlags;
|
||||
import com.liteflags.data.maps.MapCache;
|
||||
import com.liteflags.config.Config;
|
||||
import com.liteflags.util.Utilities;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class Authentication {
|
||||
public static String getAuthKey() {
|
||||
String randChars = "ABCDEFGHIJKLMNPQRSTUVWXYZ123456789abcdefghijklmnopqrstuvwsyz";
|
||||
|
|
@ -21,16 +20,17 @@ public class Authentication {
|
|||
salt.append(randChars.charAt(index));
|
||||
}
|
||||
|
||||
return "." + salt.toString();
|
||||
return "." + salt;
|
||||
}
|
||||
|
||||
public static void checkAuthStatus(UUID uuid) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if (!player.hasPermission("liteflags.authentication.success")) {
|
||||
MapCache.reauthedPlayers.put(player.getUniqueId().toString(), getAuthKey());
|
||||
AuthTimer.startTimer(player);
|
||||
player.sendMessage(Utilities.format(LiteFlags.getInstance().getConfig().getString("Messages.Authenticate").replace("%code%", (CharSequence) MapCache.reauthedPlayers.get(player.getUniqueId().toString()))));
|
||||
}
|
||||
public static void checkAuthStatus(Player player) {
|
||||
if (player.hasPermission("liteflags.authentication.success"))
|
||||
return;
|
||||
|
||||
MapCache.reauthedPlayers.put(player.getUniqueId().toString(), getAuthKey());
|
||||
AuthTimer.startTimer(player);
|
||||
player.sendMiniMessage(Config.AUTHENTICATE,
|
||||
List.of(Template.template("code", MapCache.reauthedPlayers.get(player.getUniqueId().toString()))));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
104
src/main/java/com/liteflags/commands/CommandManager.java
Normal file
104
src/main/java/com/liteflags/commands/CommandManager.java
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
package com.liteflags.commands;
|
||||
|
||||
import com.liteflags.LiteFlags;
|
||||
import com.liteflags.commands.subcommands.*;
|
||||
import com.liteflags.config.Config;
|
||||
import com.liteflags.util.Logger;
|
||||
import com.liteflags.util.Utilities;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CommandManager implements CommandExecutor, TabExecutor {
|
||||
private final List<SubCommand> subCommands;
|
||||
private SubCommand flagPlayer = new CommandFlagPlayer();
|
||||
|
||||
public CommandManager() {
|
||||
LiteFlags liteFlags = LiteFlags.getInstance();
|
||||
|
||||
PluginCommand command = liteFlags.getCommand("flag");
|
||||
if (command == null) {
|
||||
subCommands = null;
|
||||
Logger.severe("Unable to find LiteFLags command.");
|
||||
return;
|
||||
}
|
||||
command.setExecutor(this);
|
||||
command.setTabCompleter(this);
|
||||
|
||||
subCommands = Arrays.asList(//TODO add the flag player command separately
|
||||
new CommandHelp(this),
|
||||
new CommandFlagList(),
|
||||
new CommandFlagPlayer(),
|
||||
new CommandFlagRemove(),
|
||||
new CommandReload()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String cmd, @NotNull String[] args) {
|
||||
if (!commandSender.hasPermission("liteflags.use")) {
|
||||
commandSender.sendMiniMessage(Config.NO_PERMISSION, null);
|
||||
return true;
|
||||
}
|
||||
if (args.length == 0) {
|
||||
commandSender.sendMiniMessage(Config.HELP_MESSAGE_WRAPPER.replaceAll("<commands>", subCommands.stream()
|
||||
.filter(subCommand -> commandSender.hasPermission(subCommand.getPermission()))
|
||||
.map(SubCommand::getHelpMessage)
|
||||
.collect(Collectors.joining("\n"))), null);
|
||||
return true;
|
||||
}
|
||||
|
||||
SubCommand subCommand = getSubCommand(args[0]);
|
||||
|
||||
if (!commandSender.hasPermission(subCommand.getPermission())) {
|
||||
commandSender.sendMiniMessage(Config.NO_PERMISSION, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
return subCommand.onCommand(commandSender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String cmd, @NotNull String[] args) {
|
||||
List<String> res = new ArrayList<>();
|
||||
|
||||
if (args.length <= 1) {
|
||||
res.addAll(subCommands.stream()
|
||||
.filter(subCommand -> commandSender.hasPermission(subCommand.getPermission()))
|
||||
.map(SubCommand::getName)
|
||||
.filter(Objects::nonNull)
|
||||
.filter(name -> args.length == 0 || name.startsWith(args[0]))
|
||||
.collect(Collectors.toList()));
|
||||
res.addAll(Bukkit.getOnlinePlayers().stream()
|
||||
.map(Player::getName)
|
||||
.filter(name -> args.length == 0 || name.startsWith(args[0]))
|
||||
.collect(Collectors.toList()));
|
||||
} else {
|
||||
SubCommand subCommand = getSubCommand(args[0]);
|
||||
if (subCommand != null && commandSender.hasPermission(subCommand.getPermission()))
|
||||
res.addAll(subCommand.getTabComplete(commandSender, args));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public List<SubCommand> getSubCommands() {
|
||||
return subCommands;
|
||||
}
|
||||
|
||||
private SubCommand getSubCommand(String cmdName) {
|
||||
return subCommands.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(subCommand -> subCommand.getName() != null && subCommand.getName().equals(cmdName))
|
||||
.findFirst()
|
||||
.orElse(flagPlayer);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,278 +0,0 @@
|
|||
package com.liteflags.commands;
|
||||
|
||||
import com.liteflags.LiteFlags;
|
||||
import com.liteflags.data.database.Database;
|
||||
import com.liteflags.data.database.Methods;
|
||||
import com.liteflags.data.maps.MapCache;
|
||||
import com.liteflags.util.Utilities;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent.Action;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class FlagCMD implements CommandExecutor {
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
OfflinePlayer target;
|
||||
String removeTimeLetter;
|
||||
if (cmd.getName().equalsIgnoreCase("flag") && sender instanceof Player) {
|
||||
if (sender.hasPermission("liteflags.staff")) {
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid command. /flag help");
|
||||
}
|
||||
|
||||
if (args.length == 1 && args[0].equalsIgnoreCase("help")) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "/flaglist | /fl " + ChatColor.GRAY + "- Shows all the players with active flags");
|
||||
sender.sendMessage(ChatColor.YELLOW + "/flaglist | /fl <player> " + ChatColor.GRAY + "- Shows all flags a player has");
|
||||
sender.sendMessage(ChatColor.YELLOW + "/flag <player> <time> <reason> " + ChatColor.GRAY + "- This will flag a player for a given reason. Ex: /flag BobTheBuilder 7d Possible hacked client.");
|
||||
}
|
||||
|
||||
if (args.length >= 2) {
|
||||
if (args[0].equalsIgnoreCase("remove")) {
|
||||
if (sender.hasPermission("liteflags.removeflags")) {
|
||||
target = Bukkit.getServer().getOfflinePlayer(args[2]);
|
||||
int id = Integer.parseInt(args[1]);
|
||||
if (args.length == 4) {
|
||||
if (!args[3].isEmpty() && args[3].equalsIgnoreCase("-c") && Database.hasFlags(target.getUniqueId())) {
|
||||
sender.sendMessage(ChatColor.GRAY + "You have successfully removed the flag '" + Database.getFlagReason(target.getUniqueId(), id) + "' from " + ChatColor.YELLOW + target.getName() + "'s" + ChatColor.GRAY + " flag history.");
|
||||
LiteFlags.getInstance().getLogger().info(sender.getName() + " has removed the flag '" + Database.getFlagReason(target.getUniqueId(), id) + "' from " + target.getName() + "'s flag history.");
|
||||
Database.removeFlag(target.getUniqueId(), id);
|
||||
}
|
||||
} else if (args.length == 3) {
|
||||
Utilities.sendFlagConfirmMessage(sender, target, id, Database.getFlagReason(target.getUniqueId(), id));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(Utilities.format(LiteFlags.getInstance().getConfig().getString("Messages.NoPermission")));
|
||||
}
|
||||
} else {
|
||||
target = Bukkit.getServer().getOfflinePlayer(args[0]);
|
||||
if (Methods.getTotalActiveFlags(target) < LiteFlags.getInstance().getConfig().getInt("ActiveFlags.Limit")) {
|
||||
if (target != null) {
|
||||
if (!args[1].equals("*")) {
|
||||
removeTimeLetter = removeLastChar(args[1]);
|
||||
if (!removeTimeLetter.isEmpty()) {
|
||||
if (this.isInt(removeTimeLetter)) {
|
||||
String getLetter = getLastChar(args[1]);
|
||||
String[] validTimes = new String[]{"d", "h", "m"};
|
||||
if (Arrays.asList(validTimes).contains(getLetter)) {
|
||||
int number = Integer.parseInt(removeTimeLetter);
|
||||
int timeInMin = this.convertTimeToMinutes(number, getLetter);
|
||||
long currentTime = TimeUnit.MILLISECONDS.toMinutes(System.currentTimeMillis());
|
||||
int conTime = (int) currentTime + timeInMin;
|
||||
StringBuilder reason = new StringBuilder();
|
||||
|
||||
for (int i = 2; i < args.length; ++i) {
|
||||
if (i > 2) {
|
||||
reason.append(" ");
|
||||
}
|
||||
|
||||
reason.append(args[i]);
|
||||
}
|
||||
|
||||
Database.addFlag(target.getUniqueId(), (long) ((int) TimeUnit.MINUTES.toSeconds((long) conTime)), reason.toString(), sender.getName(), Utilities.convertTime(timeInMin));
|
||||
if (target.isOnline() && !MapCache.activeFlags.contains(target.getName())) {
|
||||
MapCache.activeFlags.add(target.getName());
|
||||
}
|
||||
|
||||
Iterator var25 = Bukkit.getOnlinePlayers().iterator();
|
||||
|
||||
while (var25.hasNext()) {
|
||||
Player staff = (Player) var25.next();
|
||||
if (staff.hasPermission("liteflags.alertflags")) {
|
||||
staff.sendMessage(Utilities.format(LiteFlags.getInstance().getConfig().getString("Messages.FlaggedPlayer").replace("%staff%", sender.getName()).replace("%player%", target.getName()).replace("%flaglength%", Utilities.convertTime(timeInMin)).replace("%reason%", reason.toString())));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + getLetter + " is not a valid letter. (d, h, m)");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + removeTimeLetter + " is not a valid number.");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid time argument! Example: 1d");
|
||||
}
|
||||
} else if (sender.hasPermission("liteflags.flagperm")) {
|
||||
StringBuilder reason = new StringBuilder();
|
||||
|
||||
for (int i = 2; i < args.length; ++i) {
|
||||
if (i > 2) {
|
||||
reason.append(" ");
|
||||
}
|
||||
|
||||
reason.append(args[i]);
|
||||
}
|
||||
|
||||
Database.addFlag(target.getUniqueId(), 0L, reason.toString(), sender.getName(), "Permanent");
|
||||
if (!MapCache.activeFlags.contains(target.getName())) {
|
||||
MapCache.activeFlags.add(target.getName());
|
||||
}
|
||||
|
||||
Iterator var21 = Bukkit.getOnlinePlayers().iterator();
|
||||
|
||||
while (var21.hasNext()) {
|
||||
Player staff = (Player) var21.next();
|
||||
if (staff.hasPermission("liteflags.alertflags")) {
|
||||
staff.sendMessage(Utilities.format(LiteFlags.getInstance().getConfig().getString("Messages.FlaggedPlayer").replace("%staff%", sender.getName()).replace("%player%", target.getName()).replace("%flaglength%", "Permanent").replace("%reason%", reason.toString())));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "You do not have permission to flag permanently.");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(target.getName() + " is not a valid username!");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(Utilities.format(LiteFlags.getInstance().getConfig().getString("Messages.ActiveFlagsLimit").replace("%player%", target.getName())));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(Utilities.format(LiteFlags.getInstance().getConfig().getString("Messages.NoPermission")));
|
||||
}
|
||||
} else if (cmd.getName().equalsIgnoreCase("flaglist")) {
|
||||
if (sender.hasPermission("liteflags.staff")) {
|
||||
if (args.length == 0) {
|
||||
if (MapCache.activeFlags.size() > 0) {
|
||||
Iterator var17 = MapCache.activeFlags.iterator();
|
||||
|
||||
while (var17.hasNext()) {
|
||||
removeTimeLetter = (String) var17.next();
|
||||
OfflinePlayer afPlayer = Bukkit.getServer().getOfflinePlayer(removeTimeLetter);
|
||||
int totalFlags = Methods.getTotalActiveFlags(afPlayer);
|
||||
Utilities.sendStaffHoverMessage(afPlayer, (Player) sender, Utilities.format(LiteFlags.getInstance().getConfig().getString("Messages.AlertActiveFlags").replace("%player%", afPlayer.getName()).replace("%totalactflags%", "" + totalFlags).replace("%consoleFlags%", "" + Methods.consoleFlags).replace("%staffFlags%", "" + Methods.staffFlags)));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GRAY + "No players have active flags.");
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length >= 1) {
|
||||
target = Bukkit.getServer().getOfflinePlayer(args[0]);
|
||||
this.sendFlagMessage(sender, target);
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(Utilities.format(LiteFlags.getInstance().getConfig().getString("Messages.NoPermission")));
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String getLastChar(String str) {
|
||||
return str.substring(str.length() - 1);
|
||||
}
|
||||
|
||||
private static String removeLastChar(String str) {
|
||||
return str.substring(0, str.length() - 1);
|
||||
}
|
||||
|
||||
public int convertTimeToMinutes(int number, String dhm) {
|
||||
if (dhm.equalsIgnoreCase("d")) {
|
||||
return 1440 * number;
|
||||
} else {
|
||||
return dhm.equalsIgnoreCase("h") ? 60 * number : number;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInt(String s) {
|
||||
try {
|
||||
Integer.parseInt(s);
|
||||
return true;
|
||||
} catch (NumberFormatException var3) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void sendFlagMessage(CommandSender sender, OfflinePlayer targetPlayer) {
|
||||
List<String> body = LiteFlags.getInstance().getConfig().getStringList("Messages.PlayerFlagsBody");
|
||||
int i = 0;
|
||||
//int id = false;
|
||||
boolean headerMessage = false;
|
||||
if (Database.hasFlags(targetPlayer.getUniqueId())) {
|
||||
try {
|
||||
ResultSet flag = Database.getPlayerFlags(targetPlayer.getUniqueId());
|
||||
|
||||
label52:
|
||||
while (flag.next()) {
|
||||
long expireTime = TimeUnit.SECONDS.toMinutes((long) flag.getInt("expire_time"));
|
||||
long timeFlagged = TimeUnit.SECONDS.toMinutes((long) flag.getInt("time_flagged"));
|
||||
long currentTime = TimeUnit.SECONDS.toMinutes(System.currentTimeMillis() / 1000L);
|
||||
int convertedExpireTime = (int) expireTime - (int) currentTime;
|
||||
int convertedFlaggedTime = (int) currentTime - (int) timeFlagged;
|
||||
String flaggedBy = flag.getString("flagged_by");
|
||||
String flagLength = flag.getString("flag_length");
|
||||
String reason = flag.getString("reason");
|
||||
int id = flag.getInt("id");
|
||||
TextComponent mainComponent = null;
|
||||
Iterator var20 = body.iterator();
|
||||
|
||||
while (true) {
|
||||
while (true) {
|
||||
if (!var20.hasNext()) {
|
||||
continue label52;
|
||||
}
|
||||
|
||||
String s = (String) var20.next();
|
||||
s = s.replace("%player%", targetPlayer.getName());
|
||||
s = s.replace("%staff%", flaggedBy);
|
||||
s = s.replace("%flaglength%", flagLength);
|
||||
s = s.replace("%reason%", reason);
|
||||
s = s.replace("%flagtime%", Utilities.convertTime(convertedFlaggedTime));
|
||||
if (expireTime != 0L) {
|
||||
s = s.replace("%expiretime%", Utilities.convertTime(convertedExpireTime));
|
||||
}
|
||||
|
||||
s = s.replace("%limit%", "" + Database.countFlags(targetPlayer.getUniqueId()));
|
||||
s = s.replace("%nl%", " ");
|
||||
if (convertedExpireTime < 0 && expireTime != 0L) {
|
||||
s = s.replace("%active%", LiteFlags.getInstance().getConfig().getString("Messages.ExpiredFlags"));
|
||||
mainComponent = new TextComponent(Utilities.format(s));
|
||||
} else {
|
||||
s = s.replace("%active%", LiteFlags.getInstance().getConfig().getString("Messages.ActiveFlags"));
|
||||
mainComponent = new TextComponent(Utilities.format(s));
|
||||
}
|
||||
|
||||
if (!headerMessage) {
|
||||
headerMessage = true;
|
||||
sender.sendMessage(Utilities.format(LiteFlags.getInstance().getConfig().getString("Messages.PlayerFlagsHeader").replace("%limit%", "" + Database.countFlags(targetPlayer.getUniqueId()))));
|
||||
}
|
||||
|
||||
if (!s.contains(LiteFlags.getInstance().getConfig().getString("Messages.ActiveFlags")) && !s.contains(LiteFlags.getInstance().getConfig().getString("Messages.ExpiredFlags"))) {
|
||||
sender.sendMessage(Utilities.format(s));
|
||||
} else {
|
||||
mainComponent.setColor(net.md_5.bungee.api.ChatColor.GOLD);
|
||||
TextComponent removeButton = new TextComponent("[✖]");
|
||||
removeButton.setColor(net.md_5.bungee.api.ChatColor.GRAY);
|
||||
removeButton.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, (new ComponentBuilder(net.md_5.bungee.api.ChatColor.GRAY + "Click to remove this flag")).create()));
|
||||
removeButton.setClickEvent(new ClickEvent(net.md_5.bungee.api.chat.ClickEvent.Action.RUN_COMMAND, "/flag remove " + id + " " + targetPlayer.getName()));
|
||||
mainComponent.addExtra(removeButton);
|
||||
sender.spigot().sendMessage(mainComponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException var23) {
|
||||
var23.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(Utilities.format(LiteFlags.getInstance().getConfig().getString("Messages.PlayerFlagsHeader").replace("%limit%", "" + i)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
20
src/main/java/com/liteflags/commands/SubCommand.java
Normal file
20
src/main/java/com/liteflags/commands/SubCommand.java
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
package com.liteflags.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class SubCommand {
|
||||
|
||||
public abstract boolean onCommand(CommandSender commandSender, String[] args);
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public String getPermission() {
|
||||
return "liteflags." + getName();
|
||||
}
|
||||
|
||||
public abstract List<String> getTabComplete(CommandSender commandSender, String[] args);
|
||||
|
||||
public abstract String getHelpMessage();
|
||||
}
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
package com.liteflags.commands.subcommands;
|
||||
|
||||
import com.liteflags.LiteFlags;
|
||||
import com.liteflags.commands.SubCommand;
|
||||
import com.liteflags.config.Config;
|
||||
import com.liteflags.data.database.Database;
|
||||
import com.liteflags.data.database.Methods;
|
||||
import com.liteflags.data.maps.MapCache;
|
||||
import com.liteflags.util.Logger;
|
||||
import com.liteflags.util.Utilities;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
import net.kyori.adventure.text.minimessage.template.TemplateResolver;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CommandFlagList extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, String[] args) {
|
||||
if (args.length == 1) {
|
||||
if (MapCache.activeFlags.size() > 0) {
|
||||
MapCache.activeFlags.forEach(playerName -> {
|
||||
OfflinePlayer player = Bukkit.getServer().getOfflinePlayerIfCached(playerName);
|
||||
if (player == null) {
|
||||
Logger.warning("% is not a flagged player", playerName);
|
||||
return;
|
||||
}
|
||||
commandSender.sendMiniMessage(Config.ALERT_ACTIVE_FLAGS, List.of(
|
||||
Template.template("player", player.getName() == null ? playerName : player.getName()),
|
||||
Template.template("total_act_flags", String.valueOf( Methods.getTotalActiveFlags(player))),
|
||||
Template.template("console_flags", String.valueOf(Methods.consoleFlags)),
|
||||
Template.template("staff_flags", String.valueOf(Methods.staffFlags))
|
||||
));
|
||||
});
|
||||
} else
|
||||
commandSender.sendMiniMessage(Config.NO_ACTIVE_FLAGS, null);
|
||||
} else if (args.length == 2 || args.length == 3) {
|
||||
List<String> body;
|
||||
if (args.length == 3) {
|
||||
if (!args[2].equals("full")) {
|
||||
commandSender.sendMiniMessage(getHelpMessage(), null);
|
||||
return true;
|
||||
}
|
||||
body = Config.PLAYER_FLAG_LIST_LONG;
|
||||
} else
|
||||
body = Config.PLAYER_FLAG_LIST_SHORT;
|
||||
OfflinePlayer player = Bukkit.getServer().getOfflinePlayerIfCached(args[1]);
|
||||
if (player == null) {
|
||||
commandSender.sendMiniMessage(Config.UNKNOWN_PLAYER, List.of(Template.template("player", args[1])));
|
||||
return true;
|
||||
}
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sendFlagMessage(commandSender, player, body);
|
||||
}
|
||||
}.runTask(LiteFlags.getInstance());
|
||||
} else {
|
||||
//TODO return error
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "list";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabComplete(CommandSender commandSender, String[] args) {
|
||||
ArrayList<String> res = new ArrayList<>();
|
||||
if (args.length == 2)
|
||||
res.addAll(Bukkit.getOnlinePlayers().stream()
|
||||
.map(Player::getName)
|
||||
.filter(name -> args[1].isEmpty() || name.toLowerCase().startsWith(args[1].toLowerCase()))
|
||||
.collect(Collectors.toList()));
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpMessage() {
|
||||
return Config.HELP_FLAG_LIST;
|
||||
}
|
||||
|
||||
public void sendFlagMessage(CommandSender commandSender, OfflinePlayer targetPlayer, List<String> body) {
|
||||
if (targetPlayer == null) {
|
||||
Logger.warning("Player that can't be null is null");
|
||||
return;
|
||||
}
|
||||
MiniMessage miniMessage = MiniMessage.miniMessage();
|
||||
String targetName = targetPlayer.getName();
|
||||
|
||||
targetName = targetName == null ? targetPlayer.getUniqueId().toString() : targetName;
|
||||
try {
|
||||
ResultSet resultSet = Database.getPlayerFlags(targetPlayer.getUniqueId());
|
||||
Component message = null;
|
||||
while (resultSet.next()) {
|
||||
if (message == null) {
|
||||
message = miniMessage.deserialize(Config.PLAYER_FLAGS_HEADER, TemplateResolver.templates(List.of(
|
||||
Template.template("player", targetName),
|
||||
Template.template("flag_amount", String.valueOf(resultSet.getString("total_flags")))
|
||||
)));
|
||||
}
|
||||
long expireTime = TimeUnit.SECONDS.toMinutes(resultSet.getInt("expire_time"));
|
||||
long timeFlagged = TimeUnit.SECONDS.toMinutes(resultSet.getInt("time_flagged"));
|
||||
long currentTime = TimeUnit.SECONDS.toMinutes(System.currentTimeMillis() / 1000L);
|
||||
int convertedExpireTime = (int) expireTime - (int) currentTime;
|
||||
int convertedFlaggedTime = (int) currentTime - (int) timeFlagged;
|
||||
String id = String.valueOf(resultSet.getInt("id"));
|
||||
List<Template> templates = List.of(Template.template("player", targetPlayer.getName()),
|
||||
Template.template("flag", resultSet.getString("reason")),
|
||||
Template.template("staff", resultSet.getString("flagged_by")),
|
||||
Template.template("flag_length", resultSet.getString("flag_length")),
|
||||
Template.template("reason", resultSet.getString("reason")),
|
||||
Template.template("flag_time", Utilities.convertTime(convertedFlaggedTime)),
|
||||
Template.template("expire_time", Utilities.convertTime(convertedExpireTime)),
|
||||
Template.template("nl", "\n"),
|
||||
Template.template("id", id)
|
||||
);
|
||||
String str = String.join("\n", body)
|
||||
.replaceAll("<remove_button>", "<white>" +
|
||||
"<hover:show_text:\"Click to remove this flag\">" +
|
||||
"<click:run_command:/flag remove " + id + " " + targetPlayer.getName() + ">" +
|
||||
"[<red>✖</red>]</click></hover></white>");
|
||||
if (convertedExpireTime < 0 && expireTime != 0L) //Not active
|
||||
str = str.replaceAll("<active>", Config.EXPIRED_FLAGS);
|
||||
else //Active
|
||||
str = str.replaceAll("<active>", Config.ACTIVE_FLAGS);
|
||||
str = "\n" + str;
|
||||
Logger.info(str);
|
||||
message = message.append(miniMessage.deserialize(str, TemplateResolver.templates(templates)));
|
||||
}
|
||||
if (message == null) {
|
||||
commandSender.sendMiniMessage(Config.NO_FLAG_FOUND, null);
|
||||
} else
|
||||
commandSender.sendMessage(message);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
package com.liteflags.commands.subcommands;
|
||||
|
||||
import com.liteflags.LiteFlags;
|
||||
import com.liteflags.commands.SubCommand;
|
||||
import com.liteflags.config.Config;
|
||||
import com.liteflags.data.database.Database;
|
||||
import com.liteflags.data.database.Methods;
|
||||
import com.liteflags.data.maps.MapCache;
|
||||
import com.liteflags.util.Utilities;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
import net.kyori.adventure.text.minimessage.template.TemplateResolver;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CommandFlagPlayer extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, String[] args) {
|
||||
OfflinePlayer target = Bukkit.getServer().getOfflinePlayerIfCached(args[0]);
|
||||
if (target == null) {
|
||||
commandSender.sendMiniMessage(Config.UNKNOWN_PLAYER, List.of(Template.template("player", args[2])));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Config.MAX_ACTIVE_FLAGS >= 0 && Methods.getTotalActiveFlags(target) >= Config.MAX_ACTIVE_FLAGS) {
|
||||
commandSender.sendMiniMessage(Config.ACTIVE_FLAGS_LIMIT, List.of(
|
||||
Template.template("player", target.getName() == null ? target.getUniqueId().toString() : target.getName())
|
||||
));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[1].equals("*")) {
|
||||
permFlag(commandSender, args, target);
|
||||
} else {
|
||||
tempFlag(commandSender, args, target);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void permFlag(CommandSender sender, String[] args, OfflinePlayer target) {
|
||||
if (!sender.hasPermission("liteflags.flagperm")) {
|
||||
sender.sendMessage(ChatColor.RED + "You do not have permission to flag permanently.");
|
||||
return;
|
||||
}
|
||||
|
||||
String reason = String.join(" ", Arrays.copyOfRange(args, 3, args.length));
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Database.addFlag(target.getUniqueId(), 0L, reason, sender.getName(), "Permanent");
|
||||
}
|
||||
}.runTask(LiteFlags.getInstance());
|
||||
|
||||
if (!MapCache.activeFlags.contains(target.getName())) {
|
||||
MapCache.activeFlags.add(target.getName());
|
||||
}
|
||||
|
||||
Component message = MiniMessage.miniMessage().deserialize(Config.FLAGGED_PLAYER, TemplateResolver.templates(List.of(
|
||||
Template.template("staff", sender.getName()),
|
||||
Template.template("player", target.getName() == null ? target.getUniqueId().toString() : target.getName()),
|
||||
Template.template("flag_length", "Permanent"),
|
||||
Template.template("reason", reason)
|
||||
)));
|
||||
|
||||
Bukkit.getOnlinePlayers().stream()
|
||||
.filter(player -> player.hasPermission("liteflags.alertflags"))
|
||||
.forEach(player -> player.sendMessage(message));
|
||||
}
|
||||
|
||||
private void tempFlag(CommandSender commandSender, String[] args, OfflinePlayer target) {
|
||||
if (args[1].length() < 2) {
|
||||
commandSender.sendMiniMessage(Config.INVALID_TIME_ARGUMENT, List.of(Template.template("arg", args[1])));
|
||||
return;
|
||||
}
|
||||
|
||||
String time = args[1].substring(0, args[1].length() - 1);
|
||||
String letter = args[1].substring(args[1].length() - 1);
|
||||
String[] validTimes = new String[]{"d", "h", "m"};
|
||||
if (!time.matches("[1-9][0-9]{0,8}") || !Arrays.asList(validTimes).contains(letter)) {
|
||||
commandSender.sendMiniMessage(Config.INVALID_TIME_ARGUMENT, List.of(Template.template("arg", args[1])));
|
||||
return;
|
||||
}
|
||||
|
||||
int number = Integer.parseInt(time);
|
||||
int timeInMin = this.convertTimeToMinutes(number, letter);
|
||||
long currentTime = TimeUnit.MILLISECONDS.toMinutes(System.currentTimeMillis());
|
||||
int conTime = (int) currentTime + timeInMin;
|
||||
String reason = String.join(" ", Arrays.copyOfRange(args, 2, args.length));
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Database.addFlag(target.getUniqueId(), (int) TimeUnit.MINUTES.toSeconds(conTime), reason, commandSender.getName(), Utilities.convertTime(timeInMin));
|
||||
}
|
||||
}.runTask(LiteFlags.getInstance());
|
||||
|
||||
if (target.isOnline() && !MapCache.activeFlags.contains(target.getName())) {
|
||||
MapCache.activeFlags.add(target.getName());
|
||||
}
|
||||
|
||||
Component message = MiniMessage.miniMessage().deserialize(Config.FLAGGED_PLAYER, TemplateResolver.templates(List.of(
|
||||
Template.template("staff", commandSender.getName()),
|
||||
Template.template("player", target.getName() == null ? target.getUniqueId().toString() : target.getName()),
|
||||
Template.template("flag_length", Utilities.convertTime(timeInMin)),
|
||||
Template.template("reason", reason)
|
||||
)));
|
||||
|
||||
Bukkit.getOnlinePlayers().stream()
|
||||
.filter(player -> player.hasPermission("liteflags.alertflags"))
|
||||
.forEach(player -> player.sendMessage(message));
|
||||
}
|
||||
|
||||
public int convertTimeToMinutes(int number, String dhm) {
|
||||
if (dhm.equalsIgnoreCase("d")) {
|
||||
return 1440 * number;
|
||||
} else {
|
||||
return dhm.equalsIgnoreCase("h") ? 60 * number : number;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabComplete(CommandSender commandSender, String[] args) {
|
||||
ArrayList<String> res = new ArrayList<>();
|
||||
if (args.length == 2)
|
||||
for (int i = 1; i <= 9; i++) {
|
||||
if (args[1].isEmpty() || args[1].startsWith(String.valueOf(i)))
|
||||
res.add(i + "d");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpMessage() {
|
||||
return Config.HELP_FLAG_PLAYER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "liteflags.flagplayer";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
package com.liteflags.commands.subcommands;
|
||||
|
||||
import com.liteflags.commands.SubCommand;
|
||||
import com.liteflags.config.Config;
|
||||
import com.liteflags.data.database.Database;
|
||||
import com.liteflags.util.Logger;
|
||||
import com.liteflags.util.Utilities;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandFlagRemove extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, String[] args) {
|
||||
int id = Integer.parseInt(args[1]);
|
||||
OfflinePlayer target = Bukkit.getServer().getOfflinePlayerIfCached(args[2]);
|
||||
|
||||
if (target == null) {
|
||||
commandSender.sendMiniMessage(Config.UNKNOWN_PLAYER, List.of(Template.template("player", args[2])));
|
||||
return true;
|
||||
}
|
||||
if (args.length == 4) {
|
||||
if (args[3].isEmpty() || !args[3].equalsIgnoreCase("-c")) {
|
||||
commandSender.sendMiniMessage(getHelpMessage(), null);
|
||||
return true;
|
||||
}
|
||||
String flagReason = Database.getFlagReason(target.getUniqueId(), id);
|
||||
flagReason = flagReason == null ? "Flag not found" : flagReason;
|
||||
if (Database.removeFlag(target.getUniqueId(), id)) {
|
||||
commandSender.sendMiniMessage(Config.FLAG_REMOVED, List.of(
|
||||
Template.template("flag_reason", flagReason),
|
||||
Template.template("target", target.getName() == null ? target.getUniqueId().toString() : target.getName())
|
||||
));
|
||||
Logger.info("% has removed the flag '%' from %'s flag history.", commandSender.getName(), flagReason, target.getName());
|
||||
} else {
|
||||
commandSender.sendMiniMessage(Config.NO_FLAG_FOUND, List.of(
|
||||
Template.template("target", target.getName() == null ? target.getUniqueId().toString() : target.getName()),
|
||||
Template.template("id", String.valueOf(id))
|
||||
));
|
||||
}
|
||||
} else if (args.length == 3) {
|
||||
String flagReason = Database.getFlagReason(target.getUniqueId(), id);
|
||||
String name = target.getName();
|
||||
// commandSender.sendMiniMessage("<white>Are you sure you want to remove the flag <flag_reason> from " +
|
||||
// "<yellow><target_name></yellow>'s flag history? " +
|
||||
// "<hover:Click to confirm><click:run_command:/flag remove " + id + " " + target.getName() + " -c>[<green>Confirm</green>]</click></hover></white>", List.of(
|
||||
// Template.template("flag_reason", flagReason == null ? "Unknown" : flagReason),
|
||||
// Template.template("target_name", name == null ? target.getUniqueId().toString() : name),
|
||||
// Template.template("id", String.valueOf(id))
|
||||
// ));
|
||||
commandSender.sendMiniMessage(Config.FLAG_CONFIRM, List.of(
|
||||
Template.template("flag_reason", flagReason == null ? "Unknown" : flagReason),
|
||||
Template.template("target_name", name == null ? target.getUniqueId().toString() : name),
|
||||
Template.template("id", String.valueOf(id))
|
||||
));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "remove";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabComplete(CommandSender commandSender, String[] args) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpMessage() {
|
||||
return Config.HELP_FLAG_REMOVE;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
package com.liteflags.commands.subcommands;
|
||||
|
||||
import com.liteflags.commands.CommandManager;
|
||||
import com.liteflags.commands.SubCommand;
|
||||
import com.liteflags.config.Config;
|
||||
import com.liteflags.util.Utilities;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CommandHelp extends SubCommand {
|
||||
|
||||
private final CommandManager commandManager;
|
||||
|
||||
public CommandHelp(CommandManager commandManager) {
|
||||
super();
|
||||
this.commandManager = commandManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, String[] args) {
|
||||
commandSender.sendMiniMessage(Config.HELP_MESSAGE_WRAPPER.replaceAll("<commands>", commandManager.getSubCommands().stream()
|
||||
.filter(subCommand -> commandSender.hasPermission(subCommand.getPermission()))
|
||||
.map(SubCommand::getHelpMessage)
|
||||
.collect(Collectors.joining("\n"))), null);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "help";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "liteflags.use";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabComplete(CommandSender commandSender, String[] args) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpMessage() {
|
||||
return Config.HELP_MESSAGE;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.liteflags.commands.subcommands;
|
||||
|
||||
import com.liteflags.commands.SubCommand;
|
||||
import com.liteflags.config.Config;
|
||||
import com.liteflags.util.Utilities;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandReload extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, String[] args) {
|
||||
Config.reload();
|
||||
commandSender.sendMiniMessage(Config.CONFIG_RELOADED, null);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabComplete(CommandSender commandSender, String[] args) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpMessage() {
|
||||
return Config.HELP_RELOAD;
|
||||
}
|
||||
}
|
||||
130
src/main/java/com/liteflags/config/AbstractConfig.java
Normal file
130
src/main/java/com/liteflags/config/AbstractConfig.java
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
package com.liteflags.config;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.liteflags.LiteFlags;
|
||||
import com.liteflags.util.Logger;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings({"unused", "SameParameterValue"})
|
||||
abstract class AbstractConfig {
|
||||
File file;
|
||||
YamlConfiguration yaml;
|
||||
|
||||
AbstractConfig(String filename) {
|
||||
init(new File(LiteFlags.getInstance().getDataFolder(), filename), filename);
|
||||
}
|
||||
|
||||
AbstractConfig(File file, String filename) {
|
||||
init(new File(file.getPath() + File.separator + filename), filename);
|
||||
}
|
||||
|
||||
private void init(File file, String filename) {
|
||||
this.file = file;
|
||||
this.yaml = new YamlConfiguration();
|
||||
try {
|
||||
yaml.load(file);
|
||||
} catch (IOException ignore) {
|
||||
} catch (InvalidConfigurationException ex) {
|
||||
Logger.severe(String.format("Could not load %s, please correct your syntax errors", filename));
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
yaml.options().copyDefaults(true);
|
||||
}
|
||||
|
||||
void readConfig(Class<?> clazz, Object instance) {
|
||||
for (Method method : clazz.getDeclaredMethods()) {
|
||||
if (Modifier.isPrivate(method.getModifiers())) {
|
||||
if (method.getParameterTypes().length == 0 && method.getReturnType() == Void.TYPE) {
|
||||
try {
|
||||
method.setAccessible(true);
|
||||
method.invoke(instance);
|
||||
} catch (InvocationTargetException ex) {
|
||||
throw new RuntimeException(ex.getCause());
|
||||
} catch (Exception ex) {
|
||||
Logger.severe("Error invoking %.", method.toString());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
private void save() {
|
||||
try {
|
||||
yaml.save(file);
|
||||
} catch (IOException ex) {
|
||||
Logger.severe("Could not save %.", file.toString());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
void set(String path, Object val) {
|
||||
yaml.addDefault(path, val);
|
||||
yaml.set(path, val);
|
||||
save();
|
||||
}
|
||||
|
||||
String getString(String path, String def) {
|
||||
yaml.addDefault(path, def);
|
||||
return yaml.getString(path, yaml.getString(path));
|
||||
}
|
||||
|
||||
boolean getBoolean(String path, boolean def) {
|
||||
yaml.addDefault(path, def);
|
||||
return yaml.getBoolean(path, yaml.getBoolean(path));
|
||||
}
|
||||
|
||||
int getInt(String path, int def) {
|
||||
yaml.addDefault(path, def);
|
||||
return yaml.getInt(path, yaml.getInt(path));
|
||||
}
|
||||
|
||||
double getDouble(String path, double def) {
|
||||
yaml.addDefault(path, def);
|
||||
return yaml.getDouble(path, yaml.getDouble(path));
|
||||
}
|
||||
|
||||
<T> List<?> getList(String path, T def) {
|
||||
yaml.addDefault(path, def);
|
||||
return yaml.getList(path, yaml.getList(path));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
<T> Map<String, T> getMap(final @NonNull String path, final @Nullable Map<String, T> def) {
|
||||
final ImmutableMap.Builder<String, T> builder = ImmutableMap.builder();
|
||||
if (def != null && yaml.getConfigurationSection(path) == null) {
|
||||
yaml.addDefault(path, def.isEmpty() ? new HashMap<>() : def);
|
||||
return def;
|
||||
}
|
||||
final ConfigurationSection section = yaml.getConfigurationSection(path);
|
||||
if (section != null) {
|
||||
for (String key : section.getKeys(false)) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final T val = (T) section.get(key);
|
||||
if (val != null) {
|
||||
builder.put(key, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
ConfigurationSection getConfigurationSection(String path) {
|
||||
return yaml.getConfigurationSection(path);
|
||||
}
|
||||
}
|
||||
135
src/main/java/com/liteflags/config/Config.java
Normal file
135
src/main/java/com/liteflags/config/Config.java
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
package com.liteflags.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class Config extends AbstractConfig {
|
||||
|
||||
static Config config;
|
||||
static int version;
|
||||
public Config() {
|
||||
super(new File(System.getProperty("user.home") + File.separator + "share" + File.separator + "configs" + File.separator + "LiteFlags"), "config.yml");
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
config = new Config();
|
||||
|
||||
version = config.getInt("config-version", 1);
|
||||
config.set("config-version", 1);
|
||||
|
||||
config.readConfig(Config.class, null);
|
||||
}
|
||||
|
||||
public static String ALERT_ACTIVE_FLAGS = "<gray><hover:show_text:\"Click to view <player>'s flags\"><click:run_command:\"/flag list <player>\">" +
|
||||
"<player> has <red><total_act_flags></red> active flags!</click></hover> " +
|
||||
"(<red><console_flags></red> Console, <red><staff_flags></red> Staff)</gray>";
|
||||
public static String PLAYER_FLAGS_HEADER = "<yellow><player> has <red><flag_amount></red> flags: </yellow>";
|
||||
public static List<String> PLAYER_FLAG_LIST_SHORT = List.of("<yellow>- <active> <flag> <gray><flag_time> ago</gray></yellow>");
|
||||
public static List<String> PLAYER_FLAG_LIST_LONG = List.of(
|
||||
"<nl>",
|
||||
"<gray><st>----</st> <flag_time> ago <st>----</st></gray>",
|
||||
"<dark_gray><player> was <yellow>flagged</yellow> for <flag_length> by <yellow><staff></yellow></dark_gray>",
|
||||
"<dark_gray>Reason: <gold><reason> <active></gold></dark_gray>");
|
||||
public static String REMOVE_BUTTON = "<white>[<red>✖</red>]</white>";
|
||||
public static String ACTIVE_FLAGS = "<white>[<green>Active</green>]</white>";
|
||||
public static String EXPIRED_FLAGS = "<white>[<red>Expired</red>]</white>";
|
||||
public static String NO_PERMISSION = "<red>You do not have permission to do that.</red>";
|
||||
public static String CONFIG_RELOADED = "<green>LiteFlags config reloaded successfully!</green>";
|
||||
public static String ACTIVE_FLAGS_LIMIT = "<yellow><player> <gray>has reached the active flags limit.</gray></yellow>";
|
||||
public static String FLAGGED_PLAYER = "<gold>* <staff> has flagged <player> for (<flag_length>)\nReason: <reason></gold>";
|
||||
public static String AUTHENTICATE = "<gray>You need to authenticate! Type <gold><code></gold> in chat to authenticate. (CaSe SeNsiTiVe)</gray>";
|
||||
public static String AUTHENTICATE_FAILED = "<gray>You need to authenticate! Type <gold><code></gold> in chat to authenticate. (CaSe SeNsiTiVe)</gray>";
|
||||
public static String AUTHENTICATE_SUCCESS = "<gray>You have authed! You can now play!</gray>";
|
||||
public static String NO_ACTIVE_FLAGS = "<gray>No players have active flags.";
|
||||
public static String UNKNOWN_PLAYER = "<red>No player called <player> found.";
|
||||
public static String FLAG_REMOVED = "<gray>You have successfully removed the flag <flag_reason> from <yellow><target></yellow>'s flag history";
|
||||
public static String NO_FLAGS_FOUND = "<red>No flags found for <target> </red>";
|
||||
public static String NO_FLAG_FOUND = "<red>No flag found for <target> with id: <id></red>";
|
||||
public static String INVALID_TIME_ARGUMENT = "<red>Invalid time argument <arg>! Example: 1d</red>";
|
||||
public static String FLAG_CONFIRM = "<white>Are you sure you want to remove the flag <flag_reason> from " +
|
||||
"<yellow><target_name></yellow>'s flag history? " +
|
||||
"<hover:show_text:\"Click to confirm\"><click:run_command:\"/flag remove <id> <target_name> -c\">[<green>Confirm</green>]</click></hover></white>";
|
||||
private static void loadMessages() {
|
||||
ALERT_ACTIVE_FLAGS = config.getString("messages.alert-active-flags", ALERT_ACTIVE_FLAGS);
|
||||
PLAYER_FLAGS_HEADER = config.getString("messages.player-flags-header", PLAYER_FLAGS_HEADER);
|
||||
PLAYER_FLAG_LIST_SHORT = config.getList("messages.player-flag-list-short", PLAYER_FLAG_LIST_SHORT).stream()
|
||||
.filter(object -> object instanceof String) //TODO check if this is needed
|
||||
.map(object -> Objects.toString(object, null))
|
||||
.collect(Collectors.toList());;
|
||||
PLAYER_FLAG_LIST_LONG = config.getList("messages.player-flag-list-long", PLAYER_FLAG_LIST_LONG).stream()
|
||||
.filter(object -> object instanceof String) //TODO check if this is needed
|
||||
.map(object -> Objects.toString(object, null))
|
||||
.collect(Collectors.toList());
|
||||
REMOVE_BUTTON = config.getString("messages.remove-button", REMOVE_BUTTON);
|
||||
ACTIVE_FLAGS = config.getString("messages.active-flags", ACTIVE_FLAGS);
|
||||
EXPIRED_FLAGS = config.getString("messages.expired-flags", EXPIRED_FLAGS);
|
||||
NO_PERMISSION = config.getString("messages.no-permission", NO_PERMISSION);
|
||||
CONFIG_RELOADED = config.getString("messages.config-reloaded", CONFIG_RELOADED);
|
||||
ACTIVE_FLAGS_LIMIT = config.getString("messages.active-flags-limit", ACTIVE_FLAGS_LIMIT);
|
||||
FLAGGED_PLAYER = config.getString("messages.flagged-player", FLAGGED_PLAYER);
|
||||
AUTHENTICATE = config.getString("messages.authenticate", AUTHENTICATE);
|
||||
AUTHENTICATE_FAILED = config.getString("messages.authenticate-failed", AUTHENTICATE_FAILED);
|
||||
AUTHENTICATE_SUCCESS = config.getString("messages.authenticate-success", AUTHENTICATE_SUCCESS);
|
||||
NO_ACTIVE_FLAGS = config.getString("messages.no-active-flags", NO_ACTIVE_FLAGS);
|
||||
UNKNOWN_PLAYER = config.getString("messages.unknown-player", UNKNOWN_PLAYER);
|
||||
FLAG_REMOVED = config.getString("messages.flag-removed", FLAG_REMOVED);
|
||||
NO_FLAGS_FOUND = config.getString("messages.no-flags-found", NO_FLAGS_FOUND);
|
||||
NO_FLAG_FOUND = config.getString("messages.no-flag-found", NO_FLAG_FOUND);
|
||||
INVALID_TIME_ARGUMENT = config.getString("messages.invalid-time-argument", INVALID_TIME_ARGUMENT);
|
||||
FLAG_CONFIRM = config.getString("messages.flag-confirm", FLAG_CONFIRM);
|
||||
}
|
||||
|
||||
public static String HELP_MESSAGE_WRAPPER = "<gold>LiteFlags help:\n<commands></gold>";
|
||||
public static String HELP_MESSAGE = "<green><gold>/flag help</gold>: Show this menu</green>";
|
||||
public static String HELP_FLAG_LIST = "<green><gold>/flag list</gold>: Show all the players with active flags</green>";
|
||||
public static String HELP_FLAG_LIST_PLAYER = "<green><gold>/flag list <player> [full]</gold>: Show the flags a player has</green>";
|
||||
public static String HELP_FLAG_PLAYER = "<green><gold>/flag <player> <time> <reason></gold>: Flag a player for " +
|
||||
"a given reason <i>Ex: /flag BobTheBuilder 7d Possible hacked client.</i></green>";
|
||||
public static String HELP_FLAG_REMOVE = "<green><gold>/flag remove <player> <id>></gold>: Remove a specific flag from a player " +
|
||||
"(easier to use from /flag list <player>)";
|
||||
public static String HELP_RELOAD = "<green><gold>/flag reload</gold>: Reload the config for LiteFlags</green>";
|
||||
private static void loadHelp() {
|
||||
HELP_MESSAGE_WRAPPER = config.getString("help.help-wrapper", HELP_MESSAGE_WRAPPER);
|
||||
HELP_MESSAGE = config.getString("help.help", HELP_MESSAGE);
|
||||
HELP_FLAG_LIST = config.getString("help.flag-list", HELP_FLAG_LIST);
|
||||
HELP_FLAG_LIST_PLAYER = config.getString("help.flag-list-player", HELP_FLAG_LIST_PLAYER);
|
||||
HELP_FLAG_PLAYER = config.getString("help.flag-player", HELP_FLAG_PLAYER);
|
||||
}
|
||||
|
||||
public static String IP = "localhost";
|
||||
public static String PORT = "3306";
|
||||
public static String DATABASE = "liteflags";
|
||||
public static String USERNAME = "root";
|
||||
public static String PASSWORD = "root";
|
||||
public static String DRIVERS = "mysql";
|
||||
private static void loadDatabaseSettings() {
|
||||
IP = config.getString("database.ip", IP);
|
||||
PORT = config.getString("database.port", PORT);
|
||||
DATABASE = config.getString("database.database", DATABASE);
|
||||
USERNAME = config.getString("database.username", USERNAME);
|
||||
PASSWORD = config.getString("database.password", PASSWORD);
|
||||
DRIVERS = config.getString("database.drivers", DRIVERS);
|
||||
}
|
||||
|
||||
public static int MAX_ACTIVE_FLAGS = 5;
|
||||
public static int MAX_FLAGS_LISTED = 10;
|
||||
public static int MIN_RANDOM_RE_AUTH = 14;
|
||||
public static int MAX_RANDOM_RE_AUTH = 30;
|
||||
public static int AUTH_MESSAGE_REPEAT_TIMER = 10;
|
||||
public static String TIME_FORMAT = "Days";
|
||||
public static String AUTH_MESSAGE_COMMAND = "cmi titlemessage <player> -keep:80 &7You need to authenticate! <nl>&7Type &6<code> &7in chat to authenticate. (CaSe SeNsiTiVe)";
|
||||
public static String AUTH_SUCCESS_COMMAND = "lp user <player> permission settemp <permission> true <expire_time>";
|
||||
private static void loadSettings() {
|
||||
MAX_ACTIVE_FLAGS = config.getInt("settings.max-active-flags", MAX_ACTIVE_FLAGS);
|
||||
MAX_FLAGS_LISTED = config.getInt("settings.max-flags-listed", MAX_FLAGS_LISTED);
|
||||
MIN_RANDOM_RE_AUTH = config.getInt("settings.min-random-re-auth", MIN_RANDOM_RE_AUTH);
|
||||
MAX_RANDOM_RE_AUTH = config.getInt("settings.max-random-re-auth", MAX_RANDOM_RE_AUTH);
|
||||
AUTH_MESSAGE_REPEAT_TIMER = config.getInt("settings.auth-message-repeat-timer", AUTH_MESSAGE_REPEAT_TIMER);
|
||||
TIME_FORMAT = config.getString("settings.time-format", TIME_FORMAT);
|
||||
AUTH_MESSAGE_COMMAND = config.getString("settings.auth-message-command", AUTH_MESSAGE_COMMAND);
|
||||
AUTH_SUCCESS_COMMAND = config.getString("settings.auth-success-command", AUTH_SUCCESS_COMMAND);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.liteflags.data.database;
|
||||
|
||||
import com.liteflags.LiteFlags;
|
||||
import com.liteflags.config.Config;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
|
@ -29,84 +29,33 @@ public class Database {
|
|||
|
||||
try {
|
||||
PreparedStatement statement = DatabaseConnection.getConnection().prepareStatement(sql);
|
||||
Throwable var9 = null;
|
||||
|
||||
try {
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setLong(2, expireTime);
|
||||
statement.setString(3, reason);
|
||||
statement.setString(4, flaggedBy);
|
||||
statement.setInt(5, timeFlagged);
|
||||
statement.setString(6, flagLength);
|
||||
statement.execute();
|
||||
} catch (Throwable var19) {
|
||||
var9 = var19;
|
||||
throw var19;
|
||||
} finally {
|
||||
if (statement != null) {
|
||||
if (var9 != null) {
|
||||
try {
|
||||
statement.close();
|
||||
} catch (Throwable var18) {
|
||||
var9.addSuppressed(var18);
|
||||
}
|
||||
} else {
|
||||
statement.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setLong(2, expireTime);
|
||||
statement.setString(3, reason);
|
||||
statement.setString(4, flaggedBy);
|
||||
statement.setInt(5, timeFlagged);
|
||||
statement.setString(6, flagLength);
|
||||
statement.execute();
|
||||
} catch (SQLException var21) {
|
||||
var21.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void removeFlag(UUID uuid, int id) {
|
||||
public static boolean removeFlag(UUID uuid, int id) {
|
||||
String sql = "DELETE FROM player_flags WHERE uuid = ? AND id = ?";
|
||||
|
||||
try {
|
||||
PreparedStatement statement = DatabaseConnection.getConnection().prepareStatement(sql);
|
||||
Throwable var4 = null;
|
||||
|
||||
try {
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setInt(2, id);
|
||||
statement.executeUpdate();
|
||||
} catch (Throwable var14) {
|
||||
var4 = var14;
|
||||
throw var14;
|
||||
} finally {
|
||||
if (statement != null) {
|
||||
if (var4 != null) {
|
||||
try {
|
||||
statement.close();
|
||||
} catch (Throwable var13) {
|
||||
var4.addSuppressed(var13);
|
||||
}
|
||||
} else {
|
||||
statement.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setInt(2, id);
|
||||
if (statement.executeUpdate() > 0)
|
||||
return true;
|
||||
} catch (SQLException var16) {
|
||||
var16.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Integer countFlags(UUID uuid) {
|
||||
int i = 0;
|
||||
|
||||
try {
|
||||
for (ResultSet resultSet = getPlayerFlags(uuid); resultSet.next(); ++i) {
|
||||
}
|
||||
} catch (SQLException var3) {
|
||||
var3.printStackTrace();
|
||||
}
|
||||
|
||||
return i;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void removePlayerCache(UUID uuid) {
|
||||
|
|
@ -141,48 +90,29 @@ public class Database {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean hasFlags(UUID u) {
|
||||
try {
|
||||
if (getStringResult("SELECT * FROM player_flags WHERE uuid = ?", u.toString()).next()) {
|
||||
return true;
|
||||
}
|
||||
} catch (SQLException var2) {
|
||||
var2.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
//
|
||||
// public static boolean hasFlag(UUID uuid, int id) {
|
||||
// try {
|
||||
// if (getStringResult("SELECT * FROM player_flags WHERE uuid = ?", uuid.toString()).next()) {
|
||||
// return true;
|
||||
// }
|
||||
// } catch (SQLException var2) {
|
||||
// var2.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
|
||||
public static void addPlayerCache(UUID uuid, String playerName) {
|
||||
String sql = "INSERT INTO player_cache (uuid, player_name) VALUES (?, ?) ON DUPLICATE KEY UPDATE player_name = ?";
|
||||
|
||||
try {
|
||||
PreparedStatement statement = DatabaseConnection.getConnection().prepareStatement(sql);
|
||||
Throwable var4 = null;
|
||||
|
||||
try {
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setString(2, playerName);
|
||||
statement.setString(3, playerName);
|
||||
statement.execute();
|
||||
} catch (Throwable var14) {
|
||||
var4 = var14;
|
||||
throw var14;
|
||||
} finally {
|
||||
if (statement != null) {
|
||||
if (var4 != null) {
|
||||
try {
|
||||
statement.close();
|
||||
} catch (Throwable var13) {
|
||||
var4.addSuppressed(var13);
|
||||
}
|
||||
} else {
|
||||
statement.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setString(2, playerName);
|
||||
statement.setString(3, playerName);
|
||||
statement.execute();
|
||||
} catch (SQLException var16) {
|
||||
var16.printStackTrace();
|
||||
}
|
||||
|
|
@ -215,7 +145,7 @@ public class Database {
|
|||
}
|
||||
|
||||
public static ResultSet getPlayerFlags(UUID uuid) throws SQLException {
|
||||
return getStringResult("SELECT * FROM player_flags WHERE uuid = ? ORDER BY id DESC LIMIT " + LiteFlags.getInstance().getConfig().getInt("FlagsHistory.ListLimit"), uuid.toString());
|
||||
return getStringResult("SELECT player_flags.*, count(*)over() AS total_flags FROM player_flags WHERE uuid = ? ORDER BY id DESC LIMIT " + Config.MAX_FLAGS_LISTED, uuid.toString());
|
||||
}
|
||||
|
||||
public static ResultSet getActiveTime(UUID uuid) throws SQLException {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.liteflags.data.database;
|
||||
|
||||
import com.liteflags.LiteFlags;
|
||||
import com.liteflags.config.Config;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
|
|
@ -9,12 +9,12 @@ import java.sql.SQLException;
|
|||
public class DatabaseConnection {
|
||||
public static DatabaseConnection instance;
|
||||
public Connection connection;
|
||||
public String drivers = LiteFlags.getInstance().getConfig().getString("Database.Drivers");
|
||||
public String ip = LiteFlags.getInstance().getConfig().getString("Database.IP");
|
||||
public String port = LiteFlags.getInstance().getConfig().getString("Database.Port");
|
||||
public String database = LiteFlags.getInstance().getConfig().getString("Database.Database");
|
||||
public String username = LiteFlags.getInstance().getConfig().getString("Database.Username");
|
||||
public String password = LiteFlags.getInstance().getConfig().getString("Database.Password");
|
||||
public String drivers = Config.DRIVERS;
|
||||
public String ip = Config.IP;
|
||||
public String port = Config.PORT;
|
||||
public String database = Config.DATABASE;
|
||||
public String username = Config.USERNAME;
|
||||
public String password = Config.PASSWORD;
|
||||
|
||||
public DatabaseConnection() throws SQLException {
|
||||
instance = this;
|
||||
|
|
|
|||
|
|
@ -1,26 +1,21 @@
|
|||
package com.liteflags.data.database;
|
||||
|
||||
import com.liteflags.LiteFlags;
|
||||
import com.liteflags.util.Utilities;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
public class Methods {
|
||||
public static int consoleFlags;
|
||||
public static int staffFlags;
|
||||
public static String flagListLimit = LiteFlags.getInstance().getConfig().getString("ActiveFlags.Limit");
|
||||
public static String playerFlagsHeader;
|
||||
|
||||
public static boolean hasActiveFlags(OfflinePlayer player) {
|
||||
try {
|
||||
ResultSet flag = Database.getActiveTime(player.getUniqueId());
|
||||
|
||||
while (flag.next()) {
|
||||
long expireTime = TimeUnit.SECONDS.toMinutes((long) flag.getInt("expire_time"));
|
||||
long expireTime = TimeUnit.SECONDS.toMinutes(flag.getInt("expire_time"));
|
||||
long currentTime = TimeUnit.SECONDS.toMinutes(System.currentTimeMillis() / 1000L);
|
||||
int convertedExpireTime = (int) expireTime - (int) currentTime;
|
||||
|
||||
|
|
@ -90,12 +85,6 @@ public class Methods {
|
|||
}
|
||||
|
||||
public static int getRandomIntegerBetweenRange(int min, int max) {
|
||||
int x = (int) (Math.random() * (double) (max - min + 1)) + min;
|
||||
return x;
|
||||
}
|
||||
|
||||
static {
|
||||
playerFlagsHeader = Utilities.format(LiteFlags.getInstance().getConfig().getString("Messages.PlayerFlagsHeader")
|
||||
.replace("%limit%", flagListLimit));
|
||||
return (int) (Math.random() * (double) (max - min + 1)) + min;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
package com.liteflags.events;
|
||||
|
||||
import com.liteflags.LiteFlags;
|
||||
import com.liteflags.config.Config;
|
||||
import com.liteflags.data.database.Database;
|
||||
import com.liteflags.data.database.Methods;
|
||||
import com.liteflags.data.maps.MapCache;
|
||||
import com.liteflags.util.Logger;
|
||||
import com.liteflags.util.Utilities;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
|
@ -16,6 +15,9 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ChatEvent implements Listener {
|
||||
|
||||
@EventHandler
|
||||
|
|
@ -31,40 +33,45 @@ public class ChatEvent implements Listener {
|
|||
if (e.getMessage().equals(value)) {
|
||||
e.setCancelled(true);
|
||||
|
||||
player.sendMessage(Utilities.format(LiteFlags.getInstance().getConfig().getString("Messages.Authenticate_Success")));
|
||||
player.sendMiniMessage(Config.AUTHENTICATE_SUCCESS, null);
|
||||
|
||||
final int min = LiteFlags.getInstance().getConfig().getInt("RandomReauth.MinNumber");
|
||||
final int max = LiteFlags.getInstance().getConfig().getInt("RandomReauth.MaxNumber");
|
||||
final int min = Config.MIN_RANDOM_RE_AUTH;
|
||||
final int max = Config.MAX_RANDOM_RE_AUTH;
|
||||
|
||||
final String timeAmount = LiteFlags.getInstance().getConfig().getString("RandomReauth.TimeFormat");
|
||||
final String timeAmount = Config.TIME_FORMAT;
|
||||
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(),
|
||||
LiteFlags.getInstance().getConfig().getString("Commands.TempAuthSuccess")
|
||||
.replace("%player%", player.getName())
|
||||
.replace("%permission%", "liteflags.authentication.success")
|
||||
.replace("%expiretime%",
|
||||
Methods.getRandomIntegerBetweenRange(min, max)
|
||||
Config.AUTH_SUCCESS_COMMAND
|
||||
.replaceAll("<player>", player.getName())
|
||||
.replaceAll("<permission>", "liteflags.authentication.success")
|
||||
.replaceAll("<expiretime>", Methods.getRandomIntegerBetweenRange(min, max)
|
||||
+ timeAmount.substring(0, 1).toLowerCase()));
|
||||
}
|
||||
}.runTask(LiteFlags.getInstance());
|
||||
|
||||
MapCache.reauthedPlayers.remove(player.getUniqueId().toString());
|
||||
|
||||
if (Database.inPlayerCache(player.getUniqueId())) {
|
||||
long currentTime = TimeUnit.MILLISECONDS.toMinutes(System.currentTimeMillis());
|
||||
int expireTime = 10080;
|
||||
int conTime = (int) currentTime + expireTime;
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (Database.inPlayerCache(player.getUniqueId())) {
|
||||
long currentTime = TimeUnit.MILLISECONDS.toMinutes(System.currentTimeMillis());
|
||||
int expireTime = 10080;
|
||||
int conTime = (int) currentTime + expireTime;
|
||||
|
||||
Database.addFlag(player.getUniqueId(), (long) ((int) TimeUnit.MINUTES.toSeconds((long) conTime)), "Possible Hacked Client - Logged out before authenticating.", "Console", "7 Days");
|
||||
Database.removePlayerCache(player.getUniqueId());
|
||||
}
|
||||
Database.addFlag(player.getUniqueId(), (int) TimeUnit.MINUTES.toSeconds(conTime), "Possible Hacked Client - Logged out before authenticating.", "Console", "7 Days");
|
||||
Database.removePlayerCache(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
}.runTask(LiteFlags.getInstance());
|
||||
|
||||
} else {
|
||||
e.setCancelled(true);
|
||||
player.sendMessage(Utilities.format(LiteFlags.getInstance().getConfig().getString("Messages.Authenticate_Failed").replace("%code%", (CharSequence) MapCache.reauthedPlayers.get(player.getUniqueId().toString()))));
|
||||
LiteFlags.getInstance().getLogger().info(player.getName() + " tried talking while authenticating: " + e.getMessage());
|
||||
player.sendMiniMessage(Config.AUTHENTICATE_FAILED, List.of(
|
||||
Template.template("code", MapCache.reauthedPlayers.get(player.getUniqueId().toString()))));
|
||||
Logger.info(player.getName() + " tried talking while authenticating: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,15 +2,21 @@ package com.liteflags.events;
|
|||
|
||||
import com.liteflags.LiteFlags;
|
||||
import com.liteflags.auth.Authentication;
|
||||
import com.liteflags.config.Config;
|
||||
import com.liteflags.data.database.Methods;
|
||||
import com.liteflags.data.maps.MapCache;
|
||||
import com.liteflags.util.Utilities;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
import net.kyori.adventure.text.minimessage.template.TemplateResolver;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LoginEvent implements Listener {
|
||||
|
||||
|
|
@ -18,20 +24,29 @@ public class LoginEvent implements Listener {
|
|||
public void onPlayerLogin(PlayerJoinEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
if (!player.hasPermission("liteflags.authentication.bypass")) {
|
||||
Authentication.checkAuthStatus(player.getUniqueId());
|
||||
Authentication.checkAuthStatus(player);
|
||||
}
|
||||
|
||||
if (!Methods.hasActiveFlags(player)) {
|
||||
return;
|
||||
}
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!Methods.hasActiveFlags(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
MapCache.activeFlags.add(player.getName());
|
||||
MapCache.activeFlags.add(player.getName());
|
||||
|
||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||
if (onlinePlayer.hasPermission("liteflags.alertflags") && !LiteFlags.getInstance().getConfig().getString("Messages.AlertActiveFlags").equalsIgnoreCase("disablethis")) {
|
||||
int activeTotalFlags = Methods.getTotalActiveFlags(player);
|
||||
Utilities.sendStaffHoverMessage(player, onlinePlayer, Utilities.format(LiteFlags.getInstance().getConfig().getString("Messages.AlertActiveFlags").replace("%player%", player.getName()).replace("%totalactflags%", "" + activeTotalFlags).replace("%consoleFlags%", "" + Methods.consoleFlags).replace("%staffFlags%", "" + Methods.staffFlags)));
|
||||
Component message = MiniMessage.miniMessage().deserialize(Config.ALERT_ACTIVE_FLAGS, TemplateResolver.templates(List.of(
|
||||
Template.template("player", player.getName()),
|
||||
Template.template("total_act_flags", String.valueOf(Methods.getTotalActiveFlags(player))),
|
||||
Template.template("console_flags", String.valueOf(Methods.consoleFlags)),
|
||||
Template.template("staff_flags", String.valueOf(Methods.staffFlags))
|
||||
)));
|
||||
|
||||
Bukkit.getOnlinePlayers().stream()
|
||||
.filter(onlinePlayer -> onlinePlayer.hasPermission("liteflags.alertflags"))
|
||||
.forEach(onlinePlayer -> onlinePlayer.sendMessage(message));
|
||||
}
|
||||
}
|
||||
}.runTask(LiteFlags.getInstance());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class LogoutEvent implements Listener {
|
||||
|
||||
|
|
@ -20,7 +21,12 @@ public class LogoutEvent implements Listener {
|
|||
}
|
||||
|
||||
if (MapCache.reauthedPlayers.containsKey(player.getUniqueId().toString())) {
|
||||
Database.addPlayerCache(player.getUniqueId(), player.getName());
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Database.addPlayerCache(player.getUniqueId(), player.getName());
|
||||
}
|
||||
}.runTask(LiteFlags.getInstance());
|
||||
MapCache.reauthedPlayers.remove(player.getUniqueId().toString());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ public class MoveEvent implements Listener {
|
|||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
e.setCancelled(MapCache.reauthedPlayers.containsKey(player.getUniqueId().toString()));
|
||||
if (MapCache.reauthedPlayers.containsKey(player.getUniqueId().toString()))
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
37
src/main/java/com/liteflags/util/Logger.java
Normal file
37
src/main/java/com/liteflags/util/Logger.java
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package com.liteflags.util;
|
||||
|
||||
import com.liteflags.LiteFlags;
|
||||
|
||||
public class Logger {
|
||||
|
||||
static private final java.util.logging.Logger logger;
|
||||
|
||||
static {
|
||||
logger = LiteFlags.getInstance().getLogger();
|
||||
}
|
||||
|
||||
public static void info(String info, String... variables)
|
||||
{
|
||||
for (String variable : variables) {
|
||||
info = info.replaceFirst("%", variable);
|
||||
}
|
||||
logger.info(info);
|
||||
}
|
||||
|
||||
public static void warning(String warning, String... variables)
|
||||
{
|
||||
for (String variable : variables) {
|
||||
warning = warning.replaceFirst("%", variable);
|
||||
}
|
||||
logger.warning(warning);
|
||||
}
|
||||
|
||||
public static void severe(String severe, String... variables)
|
||||
{
|
||||
for (String variable : variables) {
|
||||
severe = severe.replaceFirst("%", variable);
|
||||
}
|
||||
logger.severe(severe);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,16 +2,6 @@ package com.liteflags.util;
|
|||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent.Action;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Utilities {
|
||||
public static String convertTime(int time) {
|
||||
int days = (int) TimeUnit.MINUTES.toDays(time);
|
||||
|
|
@ -28,43 +18,10 @@ public class Utilities {
|
|||
}
|
||||
|
||||
private static String formatTime(int value, String s) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return "";
|
||||
case 1:
|
||||
return value + s;
|
||||
default:
|
||||
return value + s + "s";
|
||||
}
|
||||
}
|
||||
|
||||
public static String format(String m) {
|
||||
return ChatColor.translateAlternateColorCodes('&', m);
|
||||
}
|
||||
|
||||
public static void sendStaffHoverMessage(OfflinePlayer targetPlayer, Player staffPlayer, String mainString) {
|
||||
TextComponent mainComponent = new TextComponent(mainString);
|
||||
mainComponent.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, (new ComponentBuilder(ChatColor.GRAY + "Click to view " + targetPlayer.getName() + "'s flags")).create()));
|
||||
mainComponent.setClickEvent(new ClickEvent(net.md_5.bungee.api.chat.ClickEvent.Action.RUN_COMMAND, "/flaglist " + targetPlayer.getName()));
|
||||
staffPlayer.spigot().sendMessage(mainComponent);
|
||||
}
|
||||
|
||||
public static void sendFlagConfirmMessage(CommandSender sender, OfflinePlayer targetPlayer, int id, String flagReason) {
|
||||
TextComponent mainComponent = new TextComponent("Are you sure you want to remove the flag '" + flagReason + "' from " + ChatColor.YELLOW + targetPlayer.getName() + "'s" + ChatColor.GRAY + " flag history? ");
|
||||
mainComponent.setColor(ChatColor.GRAY);
|
||||
TextComponent confirmButton = new TextComponent("[Confirm]");
|
||||
confirmButton.setColor(ChatColor.GREEN);
|
||||
confirmButton.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, (new ComponentBuilder(ChatColor.GREEN + "Click to confirm")).create()));
|
||||
confirmButton.setClickEvent(new ClickEvent(net.md_5.bungee.api.chat.ClickEvent.Action.RUN_COMMAND, "/flag remove " + id + " " + targetPlayer.getName() + " -c"));
|
||||
mainComponent.addExtra(confirmButton);
|
||||
sender.spigot().sendMessage(mainComponent);
|
||||
}
|
||||
|
||||
public static TextComponent textComponent(TextComponent component) {
|
||||
return component;
|
||||
}
|
||||
|
||||
public static void sendMessage(Player player, TextComponent component) {
|
||||
player.spigot().sendMessage(component);
|
||||
return switch (value) {
|
||||
case 0 -> "";
|
||||
case 1 -> value + s;
|
||||
default -> value + s + "s";
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,99 +0,0 @@
|
|||
###################################################################
|
||||
|
||||
# #######
|
||||
# # ##### ###### # # ## #### ####
|
||||
# # # # # # # # # # #
|
||||
# # # ##### ##### # # # # ####
|
||||
# # # # # # ###### # ### #
|
||||
# # # # # # # # # # # #
|
||||
####### # # ###### # ###### # # #### ####
|
||||
|
||||
# By - MrPixxima
|
||||
|
||||
###################################################################
|
||||
|
||||
Database:
|
||||
IP: localhost
|
||||
Port: 3306
|
||||
Database: liteflags
|
||||
Username: root
|
||||
Password: root
|
||||
Drivers: mysql
|
||||
|
||||
#Flag Configuration
|
||||
|
||||
# The amount of active flags a player can have at once.
|
||||
ActiveFlags:
|
||||
Limit: 5
|
||||
|
||||
# It will show the last 5 flags a player has when the command /flag list <player>
|
||||
# 0 will set it to show all flags.
|
||||
FlagsHistory:
|
||||
ListLimit: 10
|
||||
|
||||
#Authentication Configuration
|
||||
|
||||
# This will enable a random time set for a player after they authenticate.
|
||||
# It will set a random number between a min and max number set in the configuration.
|
||||
RandomReauth:
|
||||
|
||||
# This will set the reuth time in (Minutes, Hours, Days)
|
||||
TimeFormat: Days
|
||||
|
||||
# It will choose a random number from these 2 numbers and it will
|
||||
# set their reauth to that random number and how long with Days, Hour, Minutes above. (Ex: 7 Days)
|
||||
MinNumber: 14
|
||||
MaxNumber: 30
|
||||
|
||||
# Commands executed when a player authenticates successfully
|
||||
Commands:
|
||||
|
||||
# The permission a player gets for x amount of time.
|
||||
# This command is only executed when RandomReuth is enabled.
|
||||
TempAuthSuccess: "lp user %player% permission settemp %permission% true %expiretime%"
|
||||
|
||||
# Configurable Messages
|
||||
Messages:
|
||||
|
||||
# Key:
|
||||
# %player% - Returns the given player name
|
||||
# %staff% - Return the given staff member name. (Only works in PlayerFlags list)
|
||||
# %reason% - Returns the reason why a player was flagged
|
||||
# %flagtime% - Returns the time when the flag was applied to the given player
|
||||
# %active% - Displayes the Active and Expired strings depending on if the flags are active/expired.
|
||||
# %expiretime% - Returns when a flag will expire if it is active.
|
||||
# %code% - Returns the code the player needs type to authenticate
|
||||
|
||||
|
||||
# The message it sends to staff when a player has active flags
|
||||
# To disable this set the string to "disablethis"
|
||||
AlertActiveFlags: "&7%player% has &c%totalactflags%&7 active flags!"
|
||||
|
||||
# Flags messages
|
||||
PlayerFlagsHeader: "&7&m------&6 Flags (Limit %limit%) &7&m------"
|
||||
|
||||
PlayerFlagsBody:
|
||||
- "%nl%"
|
||||
- "&7&m----&7 %flagtime% ago &7&m----"
|
||||
- "&8%player% was &eflagged&8 for %flaglength% by &e%staff%"
|
||||
- "&8Reason: &6%reason% %active%"
|
||||
|
||||
# The string for %active% if the flag is active - Leave blank to disable.
|
||||
ActiveFlags: "&f[&aActive&f]"
|
||||
|
||||
# The string for %active% if the flag is expired - Leave blank to disable.
|
||||
ExpiredFlags: "&f[&cExpired&f]"
|
||||
|
||||
NoPermission: "&cYou do not have permission to do that."
|
||||
ActiveFlagsLimit: "&e%player% &7has reached the active flags limit."
|
||||
FlaggedPlayer: "&6* %staff% has flagged %player% for (%flaglength%) - Reason: %reason%"
|
||||
|
||||
# Authenticate messages
|
||||
Authenticate: "&7You need to authenticate! Type &6%code%&7 in chat to authenticate. (CaSe SeNsiTiVe)"
|
||||
Authenticate_Failed: "&7You need to authenticate! Type &6%code%&7 in chat to authenticate. (CaSe SeNsiTiVe)"
|
||||
Authenticate_Success: "&7You have authed! You can now play!"
|
||||
|
||||
# How often should the authenicate message show up on a players screen (In seconds)
|
||||
Authenticate_Timer: 10
|
||||
# The command that broadcast the authenticate message on a players screen.
|
||||
Authenticate_Timer_Command: "tm message %player% You need to authenticate! Type %code% in chat to authenticate. (CaSe SeNsiTiVe)"
|
||||
|
|
@ -3,7 +3,4 @@ main: com.liteflags.LiteFlags
|
|||
version: 0.5
|
||||
commands:
|
||||
flag:
|
||||
description: Flags a player!
|
||||
flaglist:
|
||||
description: Shows players flags!
|
||||
aliases: fl
|
||||
description: Base command for the LiteFlags plugin!
|
||||
Loading…
Reference in New Issue
Block a user