mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-21 15:41:19 +01:00
Fixed issue when the database is not converted correctly
This commit is contained in:
parent
edfe56803a
commit
647533f57a
@ -19,7 +19,6 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
import com.gamingmesh.jobs.CMILib.VersionChecker.Version;
|
import com.gamingmesh.jobs.CMILib.VersionChecker.Version;
|
||||||
|
|
||||||
|
|
||||||
public class RawMessage {
|
public class RawMessage {
|
||||||
|
|
||||||
private List<String> parts = new ArrayList<>();
|
private List<String> parts = new ArrayList<>();
|
||||||
@ -83,22 +82,21 @@ public class RawMessage {
|
|||||||
if (text.equalsIgnoreCase(" "))
|
if (text.equalsIgnoreCase(" "))
|
||||||
return text;
|
return text;
|
||||||
text = CMIChatColor.deColorize(text);
|
text = CMIChatColor.deColorize(text);
|
||||||
List<String> splited = new ArrayList<>();
|
List<String> splited = new ArrayList<String>();
|
||||||
|
|
||||||
if (text.contains(" ")) {
|
if (text.contains(" ")) {
|
||||||
for (String one : text.split(" ")) {
|
for (String one : text.split(" ")) {
|
||||||
/**if (this.isBreakLine() && one.contains("\\n")) {
|
// if (this.isBreakLine() && one.contains("\\n")) {
|
||||||
String[] split = one.split("\\\\n");
|
// String[] split = one.split("\\\\n");
|
||||||
for (int i = 0; i < split.length; i++) {
|
// for (int i = 0; i < split.length; i++) {
|
||||||
if (i < split.length - 1) {
|
// if (i < split.length - 1) {
|
||||||
splited.add(split[i] + "\n");
|
// splited.add(split[i] + "\n");
|
||||||
} else {
|
// } else {
|
||||||
splited.add(split[i]);
|
// splited.add(split[i]);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
} else {*/
|
// } else {
|
||||||
splited.add(one);
|
splited.add(one);
|
||||||
//}
|
// }
|
||||||
splited.add(" ");
|
splited.add(" ");
|
||||||
}
|
}
|
||||||
if (text.length() > 1 && text.endsWith(" "))
|
if (text.length() > 1 && text.endsWith(" "))
|
||||||
@ -125,9 +123,10 @@ public class RawMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (one.contains("&")) {
|
if (one.contains("&")) {
|
||||||
Pattern pattern = Pattern.compile("(&[0123456789abcdefklmnor])");
|
Pattern pattern = Pattern.compile("(&[0123456789abcdefklmnorABCDEFKLMNOR])");
|
||||||
Matcher match = pattern.matcher(one);
|
Matcher match = pattern.matcher(one);
|
||||||
while (match.find()) {
|
while (match.find()) {
|
||||||
|
|
||||||
String color = CMIChatColor.getLastColors(match.group(0));
|
String color = CMIChatColor.getLastColors(match.group(0));
|
||||||
CMIChatColor c = CMIChatColor.getColor(color);
|
CMIChatColor c = CMIChatColor.getColor(color);
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
@ -136,7 +135,7 @@ public class RawMessage {
|
|||||||
} else if (c.isReset()) {
|
} else if (c.isReset()) {
|
||||||
formats.clear();
|
formats.clear();
|
||||||
lastColor = null;
|
lastColor = null;
|
||||||
firstBlockColor = null;
|
// firstBlockColor = null;
|
||||||
} else if (c.isColor()) {
|
} else if (c.isColor()) {
|
||||||
lastColor = c;
|
lastColor = c;
|
||||||
formats.clear();
|
formats.clear();
|
||||||
@ -159,6 +158,7 @@ public class RawMessage {
|
|||||||
|
|
||||||
newText += colorString + one;
|
newText += colorString + one;
|
||||||
}
|
}
|
||||||
|
|
||||||
return newText;
|
return newText;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ public class RawMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public RawMessage add(String text, String hoverText, String command, String suggestion, String url) {
|
public RawMessage add(String text, String hoverText, String command, String suggestion, String url) {
|
||||||
|
|
||||||
if (text == null)
|
if (text == null)
|
||||||
return this;
|
return this;
|
||||||
text = provessText(text);
|
text = provessText(text);
|
||||||
@ -267,7 +267,7 @@ public class RawMessage {
|
|||||||
String f = "{\"text\":\"" + ChatColor.translateAlternateColorCodes('&', makeMessyText(text)).replace(colorReplacerPlaceholder, "&") + "\"";
|
String f = "{\"text\":\"" + ChatColor.translateAlternateColorCodes('&', makeMessyText(text)).replace(colorReplacerPlaceholder, "&") + "\"";
|
||||||
|
|
||||||
if (hoverText != null && !hoverText.isEmpty()) {
|
if (hoverText != null && !hoverText.isEmpty()) {
|
||||||
hoverText = provessText(hoverText);
|
hoverText = provessText(hoverText);
|
||||||
hoverText = hoverText.replace(" \n", " \\n");
|
hoverText = hoverText.replace(" \n", " \\n");
|
||||||
hoverText = hoverText.replace("\n", "\\n");
|
hoverText = hoverText.replace("\n", "\\n");
|
||||||
f += ",\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + ChatColor.translateAlternateColorCodes('&', hoverText) + "\"}]}}";
|
f += ",\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + ChatColor.translateAlternateColorCodes('&', hoverText) + "\"}]}}";
|
||||||
@ -281,8 +281,8 @@ public class RawMessage {
|
|||||||
suggestion = suggestion.replace(" \\n", " \\\\n");
|
suggestion = suggestion.replace(" \\n", " \\\\n");
|
||||||
suggestion = suggestion.replace(" \n", " \\\\n");
|
suggestion = suggestion.replace(" \n", " \\\\n");
|
||||||
|
|
||||||
if (suggestion != null)
|
if (suggestion != null)
|
||||||
f += ",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"" + CMIChatColor.deColorize(suggestion) + "\"}";
|
f += ",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"" + CMIChatColor.deColorize(suggestion) + "\"}";
|
||||||
}
|
}
|
||||||
if (url != null) {
|
if (url != null) {
|
||||||
url = provessText(url);
|
url = provessText(url);
|
||||||
@ -294,7 +294,7 @@ public class RawMessage {
|
|||||||
if (command != null) {
|
if (command != null) {
|
||||||
if (!command.startsWith("/"))
|
if (!command.startsWith("/"))
|
||||||
command = "/" + command;
|
command = "/" + command;
|
||||||
command = provessText(command);
|
command = provessText(command);
|
||||||
f += ",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"" + command + "\"}";
|
f += ",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"" + command + "\"}";
|
||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
@ -406,8 +406,8 @@ public class RawMessage {
|
|||||||
loreS = ",Lore:[" + loreS + "]";
|
loreS = ",Lore:[" + loreS + "]";
|
||||||
}
|
}
|
||||||
f += ",\"hoverEvent\":{\"action\":\"show_item\",\"value\":\"{id:" + itemName + ",Count:1b,tag:{display:{Name:\\\"" + CMIChatColor.translateAlternateColorCodes(ItemName) + "\\\"" + loreS
|
f += ",\"hoverEvent\":{\"action\":\"show_item\",\"value\":\"{id:" + itemName + ",Count:1b,tag:{display:{Name:\\\"" + CMIChatColor.translateAlternateColorCodes(ItemName) + "\\\"" + loreS
|
||||||
+ "}"
|
+ "}"
|
||||||
+ Enchants + "}}\"}";
|
+ Enchants + "}}\"}";
|
||||||
|
|
||||||
if (suggestion != null)
|
if (suggestion != null)
|
||||||
f += ",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"" + suggestion + "\"}";
|
f += ",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"" + suggestion + "\"}";
|
||||||
|
@ -424,7 +424,7 @@ public class Placeholder {
|
|||||||
case user_jobs:
|
case user_jobs:
|
||||||
List<JobProgression> l = user.getJobProgression();
|
List<JobProgression> l = user.getJobProgression();
|
||||||
if (l.isEmpty()) {
|
if (l.isEmpty()) {
|
||||||
return "none";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
JobProgression prog = l.get(ThreadLocalRandom.current().nextInt(l.size()));
|
JobProgression prog = l.get(ThreadLocalRandom.current().nextInt(l.size()));
|
||||||
@ -475,7 +475,7 @@ public class Placeholder {
|
|||||||
Job jobs = getJobFromValue(vals.get(0));
|
Job jobs = getJobFromValue(vals.get(0));
|
||||||
return jobs == null ? "no" : convert(user.isInJob(jobs));
|
return jobs == null ? "no" : convert(user.isInJob(jobs));
|
||||||
case user_job_$1:
|
case user_job_$1:
|
||||||
return j == null ? "none" : j.getJob().getName();
|
return j == null ? "" : j.getJob().getName();
|
||||||
|
|
||||||
case maxjobs:
|
case maxjobs:
|
||||||
Double max = Jobs.getPermissionManager().getMaxPermission(user, "jobs.max");
|
Double max = Jobs.getPermissionManager().getMaxPermission(user, "jobs.max");
|
||||||
|
@ -265,21 +265,28 @@ public class PlayerManager {
|
|||||||
int y = 0;
|
int y = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int total = playersUUIDCache.size();
|
int total = playersUUIDCache.size();
|
||||||
|
|
||||||
for (Entry<UUID, JobsPlayer> one : playersUUIDCache.entrySet()) {
|
for (Entry<UUID, JobsPlayer> one : playersUUIDCache.entrySet()) {
|
||||||
JobsPlayer jPlayer = one.getValue();
|
JobsPlayer jPlayer = one.getValue();
|
||||||
|
|
||||||
if (resetID)
|
if (resetID)
|
||||||
jPlayer.setUserId(-1);
|
jPlayer.setUserId(-1);
|
||||||
|
|
||||||
JobsDAO dao = Jobs.getJobsDAO();
|
JobsDAO dao = Jobs.getJobsDAO();
|
||||||
dao.updateSeen(jPlayer);
|
dao.updateSeen(jPlayer);
|
||||||
if (jPlayer.getUserId() == -1)
|
|
||||||
|
if (!resetID && jPlayer.getUserId() == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (JobProgression oneJ : jPlayer.getJobProgression())
|
for (JobProgression oneJ : jPlayer.getJobProgression())
|
||||||
dao.insertJob(jPlayer, oneJ);
|
dao.insertJob(jPlayer, oneJ);
|
||||||
dao.saveLog(jPlayer);
|
dao.saveLog(jPlayer);
|
||||||
dao.savePoints(jPlayer);
|
dao.savePoints(jPlayer);
|
||||||
dao.recordPlayersLimits(jPlayer);
|
dao.recordPlayersLimits(jPlayer);
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
y++;
|
y++;
|
||||||
|
|
||||||
if (y >= 1000) {
|
if (y >= 1000) {
|
||||||
Jobs.consoleMsg("&e[Jobs] Saved " + i + "/" + total + " players data");
|
Jobs.consoleMsg("&e[Jobs] Saved " + i + "/" + total + " players data");
|
||||||
y = 0;
|
y = 0;
|
||||||
|
@ -118,6 +118,9 @@ public class BossBarManager {
|
|||||||
case 20:
|
case 20:
|
||||||
style = BarStyle.SEGMENTED_20;
|
style = BarStyle.SEGMENTED_20;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
style = BarStyle.SEGMENTED_6;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
bar = Bukkit.createBossBar(message, color, style);
|
bar = Bukkit.createBossBar(message, color, style);
|
||||||
} else
|
} else
|
||||||
|
@ -20,7 +20,6 @@ package com.gamingmesh.jobs.container;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.stuff.Debug;
|
|
||||||
import com.gamingmesh.jobs.stuff.TimeManage;
|
import com.gamingmesh.jobs.stuff.TimeManage;
|
||||||
|
|
||||||
public class JobProgression {
|
public class JobProgression {
|
||||||
@ -255,7 +254,7 @@ public class JobProgression {
|
|||||||
return lastExperience == null ? 0D : lastExperience;
|
return lastExperience == null ? 0D : lastExperience;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLastExperience(Double lastExperience) {
|
public void setLastExperience(Double lastExperience) {
|
||||||
this.lastExperience = lastExperience;
|
this.lastExperience = lastExperience;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,17 +359,6 @@ public class JobsPlayer {
|
|||||||
return Collections.unmodifiableList(progression);
|
return Collections.unmodifiableList(progression);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if have permission
|
|
||||||
* @return true if have
|
|
||||||
*/
|
|
||||||
public boolean havePermission(String perm) {
|
|
||||||
Player player = Bukkit.getPlayer(getUniqueId());
|
|
||||||
if (player != null)
|
|
||||||
return player.hasPermission(perm);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the job progression with the certain job
|
* Get the job progression with the certain job
|
||||||
* @return the job progression
|
* @return the job progression
|
||||||
@ -639,7 +628,7 @@ public class JobsPlayer {
|
|||||||
|
|
||||||
public int getMaxJobLevelAllowed(Job job) {
|
public int getMaxJobLevelAllowed(Job job) {
|
||||||
int maxLevel = 0;
|
int maxLevel = 0;
|
||||||
if (havePermission("jobs." + job.getName() + ".vipmaxlevel"))
|
if (getPlayer().hasPermission("jobs." + job.getName() + ".vipmaxlevel"))
|
||||||
maxLevel = job.getVipMaxLevel() > job.getMaxLevel() ? job.getVipMaxLevel() : job.getMaxLevel();
|
maxLevel = job.getVipMaxLevel() > job.getMaxLevel() ? job.getVipMaxLevel() : job.getMaxLevel();
|
||||||
else
|
else
|
||||||
maxLevel = job.getMaxLevel();
|
maxLevel = job.getMaxLevel();
|
||||||
|
@ -487,6 +487,7 @@ public abstract class JobsDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
protected abstract void setupConfig() throws SQLException;
|
protected abstract void setupConfig() throws SQLException;
|
||||||
|
|
||||||
protected abstract void checkUpdate() throws SQLException;
|
protected abstract void checkUpdate() throws SQLException;
|
||||||
@ -1522,11 +1523,9 @@ public abstract class JobsDAO {
|
|||||||
Convert convertData = list.get(i);
|
Convert convertData = list.get(i);
|
||||||
|
|
||||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(convertData.getUserUUID());
|
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(convertData.getUserUUID());
|
||||||
if (jPlayer == null)
|
|
||||||
continue;
|
|
||||||
Job job = Jobs.getJob(convertData.getJobId());
|
Job job = Jobs.getJob(convertData.getJobId());
|
||||||
|
|
||||||
insert.setInt(1, jPlayer.getUserId());
|
insert.setInt(1, jPlayer != null ? jPlayer.getUserId() : -1);
|
||||||
insert.setInt(2, convertData.getJobId());
|
insert.setInt(2, convertData.getJobId());
|
||||||
insert.setInt(3, convertData.getLevel());
|
insert.setInt(3, convertData.getLevel());
|
||||||
insert.setInt(4, convertData.getExp());
|
insert.setInt(4, convertData.getExp());
|
||||||
|
@ -192,14 +192,13 @@ public class JobsMySQL extends JobsDAO {
|
|||||||
@Override
|
@Override
|
||||||
public boolean truncate(String table) {
|
public boolean truncate(String table) {
|
||||||
Statement statement = null;
|
Statement statement = null;
|
||||||
String query = null;
|
|
||||||
try {
|
try {
|
||||||
if (!this.isTable(table)) {
|
if (!this.isTable(table)) {
|
||||||
Jobs.consoleMsg("&cTable \"" + table + "\" does not exist.");
|
Jobs.consoleMsg("&cTable \"" + table + "\" does not exist.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
statement = getConnection().createStatement();
|
statement = getConnection().createStatement();
|
||||||
query = "DELETE FROM " + table + ";";
|
String query = "DELETE FROM " + table + ";";
|
||||||
statement.executeUpdate(query);
|
statement.executeUpdate(query);
|
||||||
return true;
|
return true;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
@ -23,7 +23,6 @@ import com.gamingmesh.jobs.Jobs;
|
|||||||
import com.gamingmesh.jobs.api.JobsPaymentEvent;
|
import com.gamingmesh.jobs.api.JobsPaymentEvent;
|
||||||
import com.gamingmesh.jobs.container.CurrencyType;
|
import com.gamingmesh.jobs.container.CurrencyType;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
import com.gamingmesh.jobs.stuff.Debug;
|
|
||||||
import com.gamingmesh.jobs.stuff.ToggleBarHandling;
|
import com.gamingmesh.jobs.stuff.ToggleBarHandling;
|
||||||
import com.gamingmesh.jobs.tasks.BufferedPaymentTask;
|
import com.gamingmesh.jobs.tasks.BufferedPaymentTask;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -37,9 +37,9 @@ public class BufferedPaymentTask implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (payment.get(CurrencyType.MONEY) > 0) {
|
if (payment.get(CurrencyType.MONEY) > 0) {
|
||||||
economy.depositPlayer(payment.getOfflinePlayer(), payment.get(CurrencyType.MONEY));
|
economy.depositPlayer(payment.getOfflinePlayer(), payment.get(CurrencyType.MONEY));
|
||||||
}else {
|
} else {
|
||||||
if (!economy.withdrawPlayer(payment.getOfflinePlayer(), -payment.get(CurrencyType.MONEY)))
|
if (!economy.withdrawPlayer(payment.getOfflinePlayer(), -payment.get(CurrencyType.MONEY)))
|
||||||
bufferedEconomy.pay(payment);
|
bufferedEconomy.pay(payment);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user