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;
|
||||
|
||||
|
||||
public class RawMessage {
|
||||
|
||||
private List<String> parts = new ArrayList<>();
|
||||
@ -83,20 +82,19 @@ public class RawMessage {
|
||||
if (text.equalsIgnoreCase(" "))
|
||||
return text;
|
||||
text = CMIChatColor.deColorize(text);
|
||||
List<String> splited = new ArrayList<>();
|
||||
|
||||
List<String> splited = new ArrayList<String>();
|
||||
if (text.contains(" ")) {
|
||||
for (String one : text.split(" ")) {
|
||||
/**if (this.isBreakLine() && one.contains("\\n")) {
|
||||
String[] split = one.split("\\\\n");
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
if (i < split.length - 1) {
|
||||
splited.add(split[i] + "\n");
|
||||
} else {
|
||||
splited.add(split[i]);
|
||||
}
|
||||
}
|
||||
} else {*/
|
||||
// if (this.isBreakLine() && one.contains("\\n")) {
|
||||
// String[] split = one.split("\\\\n");
|
||||
// for (int i = 0; i < split.length; i++) {
|
||||
// if (i < split.length - 1) {
|
||||
// splited.add(split[i] + "\n");
|
||||
// } else {
|
||||
// splited.add(split[i]);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
splited.add(one);
|
||||
// }
|
||||
splited.add(" ");
|
||||
@ -125,9 +123,10 @@ public class RawMessage {
|
||||
}
|
||||
|
||||
if (one.contains("&")) {
|
||||
Pattern pattern = Pattern.compile("(&[0123456789abcdefklmnor])");
|
||||
Pattern pattern = Pattern.compile("(&[0123456789abcdefklmnorABCDEFKLMNOR])");
|
||||
Matcher match = pattern.matcher(one);
|
||||
while (match.find()) {
|
||||
|
||||
String color = CMIChatColor.getLastColors(match.group(0));
|
||||
CMIChatColor c = CMIChatColor.getColor(color);
|
||||
if (c != null) {
|
||||
@ -136,7 +135,7 @@ public class RawMessage {
|
||||
} else if (c.isReset()) {
|
||||
formats.clear();
|
||||
lastColor = null;
|
||||
firstBlockColor = null;
|
||||
// firstBlockColor = null;
|
||||
} else if (c.isColor()) {
|
||||
lastColor = c;
|
||||
formats.clear();
|
||||
@ -159,6 +158,7 @@ public class RawMessage {
|
||||
|
||||
newText += colorString + one;
|
||||
}
|
||||
|
||||
return newText;
|
||||
}
|
||||
|
||||
|
@ -424,7 +424,7 @@ public class Placeholder {
|
||||
case user_jobs:
|
||||
List<JobProgression> l = user.getJobProgression();
|
||||
if (l.isEmpty()) {
|
||||
return "none";
|
||||
return "";
|
||||
}
|
||||
|
||||
JobProgression prog = l.get(ThreadLocalRandom.current().nextInt(l.size()));
|
||||
@ -475,7 +475,7 @@ public class Placeholder {
|
||||
Job jobs = getJobFromValue(vals.get(0));
|
||||
return jobs == null ? "no" : convert(user.isInJob(jobs));
|
||||
case user_job_$1:
|
||||
return j == null ? "none" : j.getJob().getName();
|
||||
return j == null ? "" : j.getJob().getName();
|
||||
|
||||
case maxjobs:
|
||||
Double max = Jobs.getPermissionManager().getMaxPermission(user, "jobs.max");
|
||||
|
@ -265,21 +265,28 @@ public class PlayerManager {
|
||||
int y = 0;
|
||||
int i = 0;
|
||||
int total = playersUUIDCache.size();
|
||||
|
||||
for (Entry<UUID, JobsPlayer> one : playersUUIDCache.entrySet()) {
|
||||
JobsPlayer jPlayer = one.getValue();
|
||||
|
||||
if (resetID)
|
||||
jPlayer.setUserId(-1);
|
||||
|
||||
JobsDAO dao = Jobs.getJobsDAO();
|
||||
dao.updateSeen(jPlayer);
|
||||
if (jPlayer.getUserId() == -1)
|
||||
|
||||
if (!resetID && jPlayer.getUserId() == -1)
|
||||
continue;
|
||||
|
||||
for (JobProgression oneJ : jPlayer.getJobProgression())
|
||||
dao.insertJob(jPlayer, oneJ);
|
||||
dao.saveLog(jPlayer);
|
||||
dao.savePoints(jPlayer);
|
||||
dao.recordPlayersLimits(jPlayer);
|
||||
|
||||
i++;
|
||||
y++;
|
||||
|
||||
if (y >= 1000) {
|
||||
Jobs.consoleMsg("&e[Jobs] Saved " + i + "/" + total + " players data");
|
||||
y = 0;
|
||||
|
@ -118,6 +118,9 @@ public class BossBarManager {
|
||||
case 20:
|
||||
style = BarStyle.SEGMENTED_20;
|
||||
break;
|
||||
default:
|
||||
style = BarStyle.SEGMENTED_6;
|
||||
break;
|
||||
}
|
||||
bar = Bukkit.createBossBar(message, color, style);
|
||||
} else
|
||||
|
@ -20,7 +20,6 @@ package com.gamingmesh.jobs.container;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
import com.gamingmesh.jobs.stuff.TimeManage;
|
||||
|
||||
public class JobProgression {
|
||||
|
@ -359,17 +359,6 @@ public class JobsPlayer {
|
||||
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
|
||||
* @return the job progression
|
||||
@ -639,7 +628,7 @@ public class JobsPlayer {
|
||||
|
||||
public int getMaxJobLevelAllowed(Job job) {
|
||||
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();
|
||||
else
|
||||
maxLevel = job.getMaxLevel();
|
||||
|
@ -487,6 +487,7 @@ public abstract class JobsDAO {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected abstract void setupConfig() throws SQLException;
|
||||
|
||||
protected abstract void checkUpdate() throws SQLException;
|
||||
@ -1522,11 +1523,9 @@ public abstract class JobsDAO {
|
||||
Convert convertData = list.get(i);
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(convertData.getUserUUID());
|
||||
if (jPlayer == null)
|
||||
continue;
|
||||
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(3, convertData.getLevel());
|
||||
insert.setInt(4, convertData.getExp());
|
||||
|
@ -192,14 +192,13 @@ public class JobsMySQL extends JobsDAO {
|
||||
@Override
|
||||
public boolean truncate(String table) {
|
||||
Statement statement = null;
|
||||
String query = null;
|
||||
try {
|
||||
if (!this.isTable(table)) {
|
||||
Jobs.consoleMsg("&cTable \"" + table + "\" does not exist.");
|
||||
return false;
|
||||
}
|
||||
statement = getConnection().createStatement();
|
||||
query = "DELETE FROM " + table + ";";
|
||||
String query = "DELETE FROM " + table + ";";
|
||||
statement.executeUpdate(query);
|
||||
return true;
|
||||
} catch (SQLException e) {
|
||||
|
@ -23,7 +23,6 @@ import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.api.JobsPaymentEvent;
|
||||
import com.gamingmesh.jobs.container.CurrencyType;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
import com.gamingmesh.jobs.stuff.ToggleBarHandling;
|
||||
import com.gamingmesh.jobs.tasks.BufferedPaymentTask;
|
||||
import org.bukkit.Bukkit;
|
||||
|
Loading…
Reference in New Issue
Block a user