1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 05:55:27 +01:00

Lets compact sign save file

Lets save player data if he finished quest
New questtoplist as a sign variable to show top list by quests done on
signs
This commit is contained in:
Zrips 2019-08-14 15:20:58 +03:00
parent 1b9217393f
commit f7936dafb7
3 changed files with 28 additions and 10 deletions

View File

@ -109,14 +109,17 @@ public class SignUtil {
newTemp.setType(SignTopType.getType(NameSection.getString("Type")));
newTemp.setNumber(NameSection.getInt("Number"));
if (NameSection.isString("JobName"))
newTemp.setJobName(NameSection.getString("JobName"));
if (NameSection.isString("JobName")) {
SignTopType t = SignTopType.getType(NameSection.getString("JobName"));
if (t == null)
newTemp.setJobName(NameSection.getString("JobName"));
}
newTemp.setSpecial(NameSection.getBoolean("Special"));
HashMap<String, jobsSign> old = SignsByType.get(newTemp.getJobName().toLowerCase());
HashMap<String, jobsSign> old = SignsByType.get(newTemp.getIdentifier().toLowerCase());
if (old == null) {
old = new HashMap<String, jobsSign>();
SignsByType.put(newTemp.getJobName().toLowerCase(), old);
SignsByType.put(newTemp.getIdentifier().toLowerCase(), old);
}
String loc = newTemp.locToBlockString();
if (loc == null) {
@ -171,6 +174,8 @@ public class SignUtil {
return SignUpdate(null, type);
}
public static Integer questSignUpdateShed = null;
public boolean SignUpdate(Job job, SignTopType type) {
if (!Jobs.getGCManager().SignsEnabled)
return true;
@ -248,8 +253,10 @@ public class SignUtil {
org.bukkit.block.Sign sign = (org.bukkit.block.Sign) block.getState();
if (!jSign.isSpecial()) {
for (int i = 0; i < 4; i++) {
if (i + number >= PlayerList.size())
break;
if (i + number >= PlayerList.size()) {
sign.setLine(i, "");
continue;
}
String PlayerName = PlayerList.get(i + number).getPlayerName();
if (PlayerName == null)

View File

@ -147,7 +147,7 @@ public class jobsSign {
}
public SignTopType getType() {
return type == null ? SignTopType.toplist : type;
return type == null ? SignTopType.getType(jobName) == null ? SignTopType.toplist : SignTopType.getType(jobName) : type;
}
public void setType(SignTopType type) {

View File

@ -26,10 +26,12 @@ import java.util.Map.Entry;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.Signs.SignTopType;
import com.gamingmesh.jobs.Signs.SignUtil;
import com.gamingmesh.jobs.dao.JobsDAO;
import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.resources.jfep.Parser;
@ -506,7 +508,6 @@ public class JobsPlayer {
newLevel = maxLevel;
setLevel(job, newLevel);
Jobs.getPlayerManager().performCommandOnLevelUp(this, job, newLevel - 1);
// }
}
@ -1060,9 +1061,19 @@ public class JobsPlayer {
this.doneQuests = doneQuests;
}
public void addDoneQuest() {
Jobs.getSignUtil().SignUpdate(SignTopType.questtoplist);
public void addDoneQuest() {
this.doneQuests++;
this.setSaved(false);
if (SignUtil.questSignUpdateShed == null) {
SignUtil.questSignUpdateShed = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Jobs.getInstance(), new Runnable() {
@Override
public void run() {
Jobs.getSignUtil().SignUpdate(SignTopType.questtoplist);
SignUtil.questSignUpdateShed = null;
}
}, Jobs.getGCManager().getSavePeriod() * 60 * 20L);
}
}
public int getFurnaceCount() {