1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-30 21:07:48 +01:00

Option to show duplicate user messages. Disabled by default.

This commit is contained in:
Zrips 2021-10-26 12:58:52 +03:00
parent 52547b94a5
commit 7f7003ca5f
3 changed files with 124 additions and 113 deletions

View File

@ -125,8 +125,9 @@ public class PlayerManager {
// Checking duplicated UUID's which usually is a cause of previous bugs
if (playerUUIDMap.containsKey(info.getUuid()) && playerUUIDMap.get(info.getUuid()).getID() != info.getID()) {
int id = playerUUIDMap.get(info.getUuid()).getID();
CMIMessages.consoleMessage("&7Duplicate! &5" + info.getName() + " &7same UUID for 2 entries in database. Please remove of one them from users table id1: &2" + id + " &7id2: &2" + info.getID());
if (Jobs.getGCManager().isInformDuplicates())
CMIMessages.consoleMessage("&7Duplicate! &5" + info.getName() + " &7same UUID for 2 entries in database. Please remove of one them from users table id1: &2" + id + " &7id2: &2" + info
.getID());
if (id < info.getID()) {
return;
}
@ -135,8 +136,9 @@ public class PlayerManager {
// Checking duplicated names which usually is a cause of previous bugs
if (playerNameMap.containsKey(info.getName().toLowerCase()) && playerNameMap.get(info.getName().toLowerCase()).getID() != info.getID()) {
int id = playerNameMap.get(info.getName().toLowerCase()).getID();
CMIMessages.consoleMessage("&7Name Duplicate! &5" + info.getName() + " &7same UUID for 2 entries in database. Please remove of one them from users table id1: &2" + id + " &7id2: &2" + info
.getID());
if (Jobs.getGCManager().isInformDuplicates())
CMIMessages.consoleMessage("&7Name Duplicate! &5" + info.getName() + " &7same UUID for 2 entries in database. Please remove of one them from users table id1: &2" + id + " &7id2: &2" + info
.getID());
if (id < info.getID()) {
return;
}
@ -283,7 +285,7 @@ public class PlayerManager {
jPlayer.onConnect();
jPlayer.reloadHonorific();
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
addPlayerToCache(jPlayer);
}

View File

@ -9,123 +9,123 @@ import com.gamingmesh.jobs.container.Job;
public class moneyboost implements Cmd {
@Override
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length > 3 || args.length <= 1) {
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
return true;
}
@Override
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length > 3 || args.length <= 1) {
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
return true;
}
double rate = 1.0;
if (args[0].equalsIgnoreCase("all")) {
try {
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
} catch (NumberFormatException e) {
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
return true;
}
int[] times = parseTime(args);
for (Job job : Jobs.getJobs()) {
job.addBoost(CurrencyType.MONEY, rate, times);
}
sender.sendMessage(
Jobs.getLanguage().getMessage("command.moneyboost.output.boostalladded", "%boost%", rate));
return true;
}
if (args[0].equalsIgnoreCase("reset")) {
if (args[1].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.addBoost(CurrencyType.MONEY, 1.0);
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.allreset"));
} else if (args.length > 1) {
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
job.addBoost(CurrencyType.MONEY, 1.0);
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.jobsboostreset",
"%jobname%", job.getName()));
}
return true;
}
Job job = Jobs.getJob(args[0]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
try {
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
} catch (NumberFormatException e) {
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
return true;
}
job.addBoost(CurrencyType.MONEY, rate, parseTime(args));
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.boostadded", "%boost%", rate,
"%jobname%", job.getName()));
double rate = 1.0;
if (args[0].equalsIgnoreCase("all")) {
try {
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
} catch (NumberFormatException e) {
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
return true;
}
int[] times = parseTime(args);
for (Job job : Jobs.getJobs()) {
job.addBoost(CurrencyType.MONEY, rate, times);
}
sender.sendMessage(
Jobs.getLanguage().getMessage("command.moneyboost.output.boostalladded", "%boost%", rate));
return true;
}
private int[] parseTime(String[] args) {
int[] arr = new int[3];
if (args.length < 2) {
return arr;
if (args[0].equalsIgnoreCase("reset")) {
if (args[1].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.addBoost(CurrencyType.MONEY, 1.0);
}
String time = args[1].toLowerCase();
if (time.isEmpty()) {
return arr;
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.allreset"));
} else if (args.length > 1) {
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
String[] split = time.split("h|hour", 2);
job.addBoost(CurrencyType.MONEY, 1.0);
if (split.length > 0) {
try {
arr[2] = Integer.parseInt(split[0]);
} catch (NumberFormatException e) {
arr[2] = 0;
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.jobsboostreset",
"%jobname%", job.getName()));
}
time = time.replaceAll(arr[2] + "+[h|hour]+", "");
}
if ((split = time.split("m|minute", 2)).length > 0) {
try {
arr[1] = Integer.parseInt(split[0]);
} catch (NumberFormatException e) {
arr[1] = 0;
}
time = time.replaceAll(arr[1] + "+[m|minute]+", "");
}
if ((split = time.split("s|second", 2)).length > 0) {
try {
arr[0] = Integer.parseInt(split[0]);
} catch (NumberFormatException e) {
arr[0] = 0;
}
time = time.replaceAll(arr[0] + "+[s|second]+", "");
}
if (arr[0] == 0 && arr[1] == 0 && arr[2] == 0) {
return new int[3];
}
return arr;
return true;
}
Job job = Jobs.getJob(args[0]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
try {
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
} catch (NumberFormatException e) {
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
return true;
}
job.addBoost(CurrencyType.MONEY, rate, parseTime(args));
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.boostadded", "%boost%", rate,
"%jobname%", job.getName()));
return true;
}
private int[] parseTime(String[] args) {
int[] arr = new int[3];
if (args.length < 2) {
return arr;
}
String time = args[1].toLowerCase();
if (time.isEmpty()) {
return arr;
}
String[] split = time.split("h|hour", 2);
if (split.length > 0) {
try {
arr[2] = Integer.parseInt(split[0]);
} catch (NumberFormatException e) {
arr[2] = 0;
}
time = time.replaceAll(arr[2] + "+[h|hour]+", "");
}
if ((split = time.split("m|minute", 2)).length > 0) {
try {
arr[1] = Integer.parseInt(split[0]);
} catch (NumberFormatException e) {
arr[1] = 0;
}
time = time.replaceAll(arr[1] + "+[m|minute]+", "");
}
if ((split = time.split("s|second", 2)).length > 0) {
try {
arr[0] = Integer.parseInt(split[0]);
} catch (NumberFormatException e) {
arr[0] = 0;
}
time = time.replaceAll(arr[0] + "+[s|second]+", "");
}
if (arr[0] == 0 && arr[1] == 0 && arr[2] == 0) {
return new int[3];
}
return arr;
}
}

View File

@ -82,6 +82,7 @@ public class GeneralConfigManager {
public float maxPaymentCurveFactor;
private boolean FurnacesReassign, BrewingStandsReassign, useTnTFinder = false, ShowNewVersion;
private boolean InformDuplicates;
private FireworkEffect fireworkEffect;
@ -341,6 +342,10 @@ public class GeneralConfigManager {
c.addComment("Optimizations.NewVersion",
"When set to true staff will be informed about new Jobs plugin version", "You need to have jobs.versioncheck permission node");
ShowNewVersion = c.get("Optimizations.NewVersion", true);
c.addComment("Optimizations.InformDuplicates",
"Can be used to check if your database contains any duplicated user entries.");
InformDuplicates = c.get("Optimizations.InformDuplicates", false);
c.addComment("Optimizations.DecimalPlaces.Money",
"Decimal places to be shown");
@ -1154,4 +1159,8 @@ public class GeneralConfigManager {
public FireworkEffect getFireworkEffect() {
return fireworkEffect;
}
public boolean isInformDuplicates() {
return InformDuplicates;
}
}