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

Fix when Entity#isPersistent method does not exist on 1.8 servers

This commit is contained in:
montlikadani 2021-03-29 18:38:11 +02:00
parent 149a71e5da
commit 5c83fcbd11
7 changed files with 29 additions and 31 deletions

View File

@ -40,8 +40,7 @@ public class BossBarManager {
if (Version.getCurrent().isLower(Version.v1_9_R1) || !Jobs.getGCManager().BossBarsMessageByDefault) if (Version.getCurrent().isLower(Version.v1_9_R1) || !Jobs.getGCManager().BossBarsMessageByDefault)
return; return;
Boolean show = ToggleBarHandling.getBossBarToggle().getOrDefault(player.getPlayer().getUniqueId().toString(), true); if (!ToggleBarHandling.getBossBarToggle().getOrDefault(player.getUniqueId().toString(), true))
if (!show)
return; return;
BossBar bar = null; BossBar bar = null;

View File

@ -670,9 +670,7 @@ public class ConfigManager {
String fileName = jobKey.equalsIgnoreCase(EXAMPLEJOBNAME) ? jobKey.toUpperCase() : jobKey.toLowerCase(); String fileName = jobKey.equalsIgnoreCase(EXAMPLEJOBNAME) ? jobKey.toUpperCase() : jobKey.toLowerCase();
YmlMaker newJobFile = new YmlMaker(jobsPathFolder, fileName + ".yml"); YmlMaker newJobFile = new YmlMaker(jobsPathFolder, fileName + ".yml");
if (!newJobFile.exists()) {
newJobFile.createNewFile(); newJobFile.createNewFile();
}
FileConfiguration conf = newJobFile.getConfig(); FileConfiguration conf = newJobFile.getConfig();
conf.options().pathSeparator(File.separatorChar); conf.options().pathSeparator(File.separatorChar);

View File

@ -27,8 +27,8 @@ public class ExploreManager {
} }
public void setPlayerAmount(int amount) { public void setPlayerAmount(int amount) {
if (this.playerAmount < amount) if (playerAmount < amount)
this.playerAmount = amount; playerAmount = amount;
} }
public boolean isExploreEnabled() { public boolean isExploreEnabled() {
@ -44,9 +44,12 @@ public class ExploreManager {
public void load() { public void load() {
if (!exploreEnabled) if (!exploreEnabled)
return; return;
Jobs.consoleMsg("&e[Jobs] Loading explorer data"); Jobs.consoleMsg("&e[Jobs] Loading explorer data");
Jobs.getJobsDAO().loadExplore(); Jobs.getJobsDAO().loadExplore();
Jobs.consoleMsg("&e[Jobs] Loaded explorer data" + (getSize() != 0 ? " (" + getSize() + ")" : "."));
int size = getSize();
Jobs.consoleMsg("&e[Jobs] Loaded explorer data" + (size != 0 ? " (" + size + ")" : "."));
} }
public Map<String, ExploreRegion> getWorlds() { public Map<String, ExploreRegion> getWorlds() {

View File

@ -21,9 +21,9 @@ import com.gamingmesh.jobs.stuff.Util;
public class NameTranslatorManager { public class NameTranslatorManager {
private final HashMap<CMIMaterial, NameList> ListOfNames = new HashMap<>(); private final Map<CMIMaterial, NameList> ListOfNames = new HashMap<>();
private final ArrayList<NameList> ListOfEntities = new ArrayList<>(), ListOfColors = new ArrayList<>(); private final List<NameList> ListOfEntities = new ArrayList<>(), ListOfColors = new ArrayList<>();
private final HashMap<String, NameList> ListOfEnchants = new HashMap<>(), ListOfMMEntities = new HashMap<>(); private final Map<String, NameList> ListOfEnchants = new HashMap<>(), ListOfMMEntities = new HashMap<>();
public String Translate(String materialName, JobInfo info) { public String Translate(String materialName, JobInfo info) {
return Translate(materialName, info.getActionType(), info.getId(), info.getMeta(), info.getName()); return Translate(materialName, info.getActionType(), info.getId(), info.getMeta(), info.getName());
@ -123,8 +123,9 @@ public class NameTranslatorManager {
String mName = materialName; String mName = materialName;
String level = ""; String level = "";
if (mName.contains(":")) { if (mName.contains(":")) {
mName = materialName.split(":")[0]; String[] split = materialName.split(":", 2);
level = ":" + materialName.split(":")[1]; mName = split[0];
level = ":" + split[1];
} }
NameList nameInfo = ListOfEnchants.get(mName.toLowerCase().replace("_", "")); NameList nameInfo = ListOfEnchants.get(mName.toLowerCase().replace("_", ""));
if (nameInfo != null) { if (nameInfo != null) {
@ -247,9 +248,7 @@ public class NameTranslatorManager {
return; return;
File tWordsFolder = new File(Jobs.getFolder(), "TranslatableWords"); File tWordsFolder = new File(Jobs.getFolder(), "TranslatableWords");
if (!tWordsFolder.exists()) {
tWordsFolder.mkdirs(); tWordsFolder.mkdirs();
}
File file = new File(Jobs.getFolder(), "TranslatableWords.yml"); File file = new File(Jobs.getFolder(), "TranslatableWords.yml");
File file2 = new File(tWordsFolder, "Words_" + ls + ".yml"); File file2 = new File(tWordsFolder, "Words_" + ls + ".yml");

View File

@ -2,7 +2,6 @@ package com.gamingmesh.jobs.config;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set;
import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.CMIItemStack; import com.gamingmesh.jobs.CMILib.CMIItemStack;
@ -31,20 +30,18 @@ public class RestrictedBlockManager {
"If you want to have default value for all blocks, enable GlobalBlockTimer in generalConfig file"); "If you want to have default value for all blocks, enable GlobalBlockTimer in generalConfig file");
if (cfg.getC().isConfigurationSection("blocksTimer")) { if (cfg.getC().isConfigurationSection("blocksTimer")) {
Set<String> lss = cfg.getC().getConfigurationSection("blocksTimer").getKeys(false); org.bukkit.configuration.ConfigurationSection section = cfg.getC().getConfigurationSection("blocksTimer");
for (String one : lss) { for (String one : section.getKeys(false)) {
if (((cfg.getC().isString("blocksTimer." + one + ".id")) || (cfg.getC().isInt("blocksTimer." + one + ".id"))) && (cfg.getC().isInt("blocksTimer." + one if (((section.isString(one + ".id")) || (section.isInt(one + ".id"))) && (section.isInt(one + ".cd"))) {
+ ".cd"))) { CMIItemStack cm = ItemManager.getItem(CMIMaterial.get(section.getString(one + ".id")));
CMIItemStack cm = ItemManager.getItem(CMIMaterial.get(cfg.getC().getString("blocksTimer." + one + ".id"))); if (cm == null || !cm.getCMIType().isBlock()) {
if ((cm == null) || (!cm.getCMIType().isBlock())) {
Jobs.consoleMsg("&e[Jobs] Your defined (" + one + ") protected block id/name is not correct!"); Jobs.consoleMsg("&e[Jobs] Your defined (" + one + ") protected block id/name is not correct!");
continue; continue;
} }
restrictedBlocksTimer.put(cm.getCMIType(), cfg.getC().getInt("blocksTimer." + one + ".cd")); int cd = section.getInt(one + ".cd");
restrictedBlocksTimer.put(cm.getCMIType(), cd);
cfg.set("blocksTimer." + cm.getCMIType().name(), cfg.getC().getInt("blocksTimer." + one + ".cd")); cfg.set("blocksTimer." + cm.getCMIType().name(), cd);
} else { } else {
CMIMaterial mat = CMIMaterial.get(one); CMIMaterial mat = CMIMaterial.get(one);
if (mat == CMIMaterial.NONE) if (mat == CMIMaterial.NONE)

View File

@ -416,7 +416,7 @@ public abstract class JobsDAO {
public String getQuery() { public String getQuery() {
String rp = ""; String rp = "";
List<JobsTableInterface> uniques = new ArrayList<>(); List<JobsTableInterface> uniques = new ArrayList<>();
for (JobsTableInterface one : getInterface()) { for (JobsTableInterface one : c) {
if (one.isUnique()) { if (one.isUnique()) {
uniques.add(one); uniques.add(one);
} }
@ -550,9 +550,11 @@ public abstract class JobsDAO {
private boolean checkDefaultCollumns() { private boolean checkDefaultCollumns() {
for (DBTables one : DBTables.values()) { for (DBTables one : DBTables.values()) {
String tableName = one.getTableName();
for (JobsTableInterface oneT : one.getInterface()) { for (JobsTableInterface oneT : one.getInterface()) {
if (!isCollumn(one.getTableName(), oneT.getCollumn())) if (!isCollumn(tableName, oneT.getCollumn()))
addCollumn(one.getTableName(), oneT.getCollumn(), oneT.getType()); addCollumn(tableName, oneT.getCollumn(), oneT.getType());
} }
} }

View File

@ -1689,7 +1689,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onChunkUnload(ChunkUnloadEvent event) { public void onChunkUnload(ChunkUnloadEvent event) {
for (Entity entity : event.getChunk().getEntities()) { for (Entity entity : event.getChunk().getEntities()) {
if (entity.isPersistent()) if (Version.isCurrentEqualOrHigher(Version.v1_13_R1) && entity.isPersistent())
break; break;
if (entity.hasMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata())) if (entity.hasMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata()))