mirror of
https://github.com/Zrips/Jobs.git
synced 2025-03-09 21:29:23 +01:00
Fixed issue for sign updates
This commit is contained in:
parent
f48e6dcec4
commit
020367fc5e
@ -72,6 +72,13 @@ public class SignUtil {
|
||||
old.put(loc, jSign);
|
||||
}
|
||||
|
||||
public void cancelSignTask() {
|
||||
if (update > -1) {
|
||||
Bukkit.getScheduler().cancelTask(update);
|
||||
update = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Sign file
|
||||
public void LoadSigns() {
|
||||
// Boolean false does not create a file
|
||||
@ -131,6 +138,7 @@ public class SignUtil {
|
||||
Jobs.consoleMsg("&e[Jobs] Loaded " + SignsByLocation.size() + " top list signs");
|
||||
}
|
||||
|
||||
cancelSignTask();
|
||||
signUpdate();
|
||||
}
|
||||
|
||||
@ -164,7 +172,9 @@ public class SignUtil {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return;
|
||||
|
||||
cancelSignTask();
|
||||
signUpdate();
|
||||
}
|
||||
|
||||
private int update = -1;
|
||||
@ -175,10 +185,12 @@ public class SignUtil {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Entry<String, HashMap<String, jobsSign>> one : SignsByType.entrySet()) {
|
||||
SignUpdate(Jobs.getJob(one.getKey()));
|
||||
for (Entry<String, jobsSign> j : SignsByLocation.entrySet()) {
|
||||
SignUpdate(Jobs.getJob(one.getKey()), j.getValue().getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 60 * 20L, Jobs.getGCManager().InfoUpdateInterval * 20L);
|
||||
}, 30 * 20L, Jobs.getGCManager().InfoUpdateInterval * 20L);
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,18 +206,17 @@ public class SignUtil {
|
||||
if (!Jobs.getGCManager().SignsEnabled)
|
||||
return true;
|
||||
|
||||
if (update == -1) {
|
||||
signUpdate();
|
||||
}
|
||||
|
||||
if (job == null)
|
||||
return false;
|
||||
signUpdate();
|
||||
|
||||
if (type == null)
|
||||
type = SignTopType.toplist;
|
||||
|
||||
String JobNameOrType = jobsSign.getIdentifier(job, type);
|
||||
HashMap<String, jobsSign> signs = this.SignsByType.get(JobNameOrType.toLowerCase());
|
||||
String JobNameOrType = null;
|
||||
HashMap<String, jobsSign> signs = null;
|
||||
if (job != null) {
|
||||
JobNameOrType = jobsSign.getIdentifier(job, type);
|
||||
signs = this.SignsByType.get(JobNameOrType.toLowerCase());
|
||||
}
|
||||
|
||||
if (signs == null)
|
||||
return false;
|
||||
@ -255,9 +266,11 @@ public class SignUtil {
|
||||
Block block = loc.getBlock();
|
||||
if (!(block.getState() instanceof org.bukkit.block.Sign)) {
|
||||
|
||||
HashMap<String, jobsSign> tt = this.SignsByType.get(JobNameOrType.toLowerCase());
|
||||
if (tt != null) {
|
||||
tt.remove(jSign.locToBlockString());
|
||||
if (JobNameOrType != null) {
|
||||
HashMap<String, jobsSign> tt = this.SignsByType.get(JobNameOrType.toLowerCase());
|
||||
if (tt != null) {
|
||||
tt.remove(jSign.locToBlockString());
|
||||
}
|
||||
}
|
||||
this.SignsByLocation.remove(jSign.locToBlockString());
|
||||
save = true;
|
||||
|
@ -425,6 +425,7 @@ public class JobsListener implements Listener {
|
||||
player.sendMessage(Jobs.getLanguage().getMessage("signs.cantdestroy"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Jobs.getSignUtil().removeSign(block.getLocation()))
|
||||
Jobs.getSignUtil().saveSigns();
|
||||
}
|
||||
@ -444,13 +445,11 @@ public class JobsListener implements Listener {
|
||||
|
||||
Sign sign = (Sign) block.getState();
|
||||
|
||||
final String signtype = ChatColor.stripColor(event.getLine(1));
|
||||
|
||||
SignTopType type = SignTopType.getType(signtype);
|
||||
|
||||
if (!ChatColor.stripColor(event.getLine(0)).equalsIgnoreCase("[Jobs]"))
|
||||
return;
|
||||
|
||||
final String signtype = ChatColor.stripColor(event.getLine(1));
|
||||
final SignTopType type = SignTopType.getType(signtype);
|
||||
if (type == null)
|
||||
return;
|
||||
|
||||
@ -490,7 +489,6 @@ public class JobsListener implements Listener {
|
||||
}
|
||||
|
||||
jobsSign signInfo = new jobsSign();
|
||||
SignUtil signUtil = Jobs.getSignUtil();
|
||||
|
||||
Location loc = sign.getLocation();
|
||||
signInfo.setLoc(loc);
|
||||
@ -502,6 +500,8 @@ public class JobsListener implements Listener {
|
||||
|
||||
signInfo.setSpecial(special);
|
||||
|
||||
final SignUtil signUtil = Jobs.getSignUtil();
|
||||
|
||||
signUtil.addSign(signInfo);
|
||||
signUtil.saveSigns();
|
||||
event.setCancelled(true);
|
||||
@ -659,12 +659,7 @@ public class JobsListener implements Listener {
|
||||
String name = null;
|
||||
List<String> lore = new ArrayList<>();
|
||||
|
||||
Map<Enchantment, Integer> enchants = new HashMap<>();
|
||||
try {
|
||||
enchants = iih.getEnchantments();
|
||||
} catch (Throwable e) {
|
||||
return;
|
||||
}
|
||||
Map<Enchantment, Integer> enchants = new HashMap<>(iih.getEnchantments());
|
||||
if (enchants.isEmpty())
|
||||
return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user