mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 05:55:27 +01:00
Fix file loading when the plugin/server reloaded, #353
- Fix permission for /jobs quest & /jobs shop, #358
This commit is contained in:
parent
523ef32acd
commit
62f5718eb1
@ -39,7 +39,7 @@ public class SignUtil {
|
||||
return;
|
||||
|
||||
Signs.GetAllSigns().clear();
|
||||
File file = new File(plugin.getDataFolder(), "Signs.yml");
|
||||
File file = new File(Jobs.getFolder(), "Signs.yml");
|
||||
YamlConfiguration f = YamlConfiguration.loadConfiguration(file);
|
||||
|
||||
if (!f.isConfigurationSection("Signs"))
|
||||
@ -47,7 +47,7 @@ public class SignUtil {
|
||||
|
||||
ConfigurationSection ConfCategory = f.getConfigurationSection("Signs");
|
||||
ArrayList<String> categoriesList = new ArrayList<>(ConfCategory.getKeys(false));
|
||||
if (categoriesList.size() == 0)
|
||||
if (categoriesList.isEmpty())
|
||||
return;
|
||||
for (String category : categoriesList) {
|
||||
ConfigurationSection NameSection = ConfCategory.getConfigurationSection(category);
|
||||
@ -70,7 +70,7 @@ public class SignUtil {
|
||||
if (!Jobs.getGCManager().SignsEnabled)
|
||||
return;
|
||||
|
||||
File f = new File(plugin.getDataFolder(), "Signs.yml");
|
||||
File f = new File(Jobs.getFolder(), "Signs.yml");
|
||||
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
|
||||
|
||||
CommentedYamlConfiguration writer = new CommentedYamlConfiguration();
|
||||
@ -126,9 +126,8 @@ public class SignUtil {
|
||||
double SignsZ = one.GetZ();
|
||||
int number = one.GetNumber() - 1;
|
||||
|
||||
if (!JobName.equalsIgnoreCase("gtoplist")) {
|
||||
if (!JobName.equalsIgnoreCase("gtoplist"))
|
||||
PlayerList = Jobs.getJobsDAO().toplist(SignJobName, number);
|
||||
}
|
||||
|
||||
if (PlayerList.isEmpty())
|
||||
continue;
|
||||
|
@ -20,27 +20,25 @@ public class quests implements Cmd {
|
||||
@Override
|
||||
@JobCommand(400)
|
||||
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
||||
if (!Jobs.hasPermission(sender, "jobs.commands.quests", true))
|
||||
return true;
|
||||
|
||||
JobsPlayer jPlayer = null;
|
||||
|
||||
if (args.length >= 1 && args[0].equals("next")) {
|
||||
|
||||
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
|
||||
jPlayer.resetQuests();
|
||||
} else {
|
||||
if (args.length >= 1) {
|
||||
if (!Jobs.hasPermission(sender, "jobs.command.admin.quests", true)) {
|
||||
if (!Jobs.hasPermission(sender, "jobs.command.admin.quests", true))
|
||||
return true;
|
||||
}
|
||||
|
||||
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
|
||||
} else if (sender instanceof Player) {
|
||||
} else if (sender instanceof Player)
|
||||
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
if (jPlayer == null) {
|
||||
if (!Jobs.hasPermission(sender, "jobs.command.quests", true))
|
||||
return true;
|
||||
|
||||
if (args.length >= 1)
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfo"));
|
||||
else
|
||||
|
@ -17,9 +17,6 @@ public class shop implements Cmd {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Jobs.hasPermission(sender, "jobs.commands.shop", true))
|
||||
return true;
|
||||
|
||||
if (args.length != 0 && args.length != 1) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "shop");
|
||||
return true;
|
||||
|
@ -116,7 +116,7 @@ public class LanguageManager {
|
||||
ConfigReader c = null;
|
||||
try {
|
||||
c = new ConfigReader(f);
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (c == null)
|
||||
@ -678,7 +678,7 @@ public class LanguageManager {
|
||||
c.get("scoreboard.gtopline", "&2Global top list");
|
||||
c.get("scoreboard.line", "&2%number%. &e%playername% (&6%level%&e)");
|
||||
|
||||
Jobs.getGCManager().keys = new ArrayList<>(c.getC().getConfigurationSection("signs.secondline").getKeys(false));
|
||||
Jobs.getGCManager().keys = new ArrayList<String>(c.getC().getConfigurationSection("signs.secondline").getKeys(false));
|
||||
|
||||
// Write back config
|
||||
c.save();
|
||||
|
@ -71,7 +71,7 @@ public class YmlMaker {
|
||||
}
|
||||
|
||||
public boolean exists() {
|
||||
return ConfigFile != null && ConfigFile.exists() ? false : ConfigFile.exists();
|
||||
return ConfigFile != null && ConfigFile.exists() ? true : ConfigFile.exists();
|
||||
}
|
||||
|
||||
public void createNewFile() {
|
||||
|
@ -22,9 +22,6 @@ import com.gamingmesh.jobs.listeners.JobsPaymentListener;
|
||||
|
||||
public class FurnaceBrewingHandling {
|
||||
|
||||
public FurnaceBrewingHandling() {
|
||||
}
|
||||
|
||||
static HashMap<UUID, List<blockLoc>> furnaceMap = new HashMap<>();
|
||||
static HashMap<UUID, List<blockLoc>> brewingMap = new HashMap<>();
|
||||
|
||||
@ -39,82 +36,85 @@ public class FurnaceBrewingHandling {
|
||||
int totalb = 0;
|
||||
|
||||
if (Jobs.getGCManager().isFurnacesReassign()) {
|
||||
if (config.contains("Furnace")) {
|
||||
ConfigurationSection section = config.getConfigurationSection("Furnace");
|
||||
ConfigurationSection section = config.getConfigurationSection("Furnace");
|
||||
|
||||
try {
|
||||
for (String one : section.getKeys(false)) {
|
||||
String value = section.getString(one);
|
||||
List<String> ls = new ArrayList<>();
|
||||
if (value.contains(";"))
|
||||
ls.addAll(Arrays.asList(value.split(";")));
|
||||
else
|
||||
ls.add(value);
|
||||
UUID uuid = UUID.fromString(one);
|
||||
if (section == null)
|
||||
return;
|
||||
|
||||
if (uuid == null)
|
||||
continue;
|
||||
List<blockLoc> blist = new ArrayList<>();
|
||||
for (String oneL : ls) {
|
||||
blockLoc bl = new blockLoc(oneL);
|
||||
Block block = bl.getBlock();
|
||||
if (block == null)
|
||||
continue;
|
||||
try {
|
||||
for (String one : section.getKeys(false)) {
|
||||
String value = section.getString(one);
|
||||
List<String> ls = new ArrayList<>();
|
||||
if (value.contains(";"))
|
||||
ls.addAll(Arrays.asList(value.split(";")));
|
||||
else
|
||||
ls.add(value);
|
||||
UUID uuid = UUID.fromString(one);
|
||||
|
||||
block.removeMetadata(JobsPaymentListener.furnaceOwnerMetadata, Jobs.getInstance());
|
||||
block.setMetadata(JobsPaymentListener.furnaceOwnerMetadata, new FixedMetadataValue(Jobs.getInstance(), one));
|
||||
if (uuid == null)
|
||||
continue;
|
||||
List<blockLoc> blist = new ArrayList<>();
|
||||
for (String oneL : ls) {
|
||||
blockLoc bl = new blockLoc(oneL);
|
||||
Block block = bl.getBlock();
|
||||
if (block == null)
|
||||
continue;
|
||||
|
||||
blist.add(bl);
|
||||
}
|
||||
if (!blist.isEmpty()) {
|
||||
furnaceMap.put(uuid, blist);
|
||||
totalf += blist.size();
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
block.removeMetadata(JobsPaymentListener.furnaceOwnerMetadata, Jobs.getInstance());
|
||||
block.setMetadata(JobsPaymentListener.furnaceOwnerMetadata, new FixedMetadataValue(Jobs.getInstance(), one));
|
||||
|
||||
blist.add(bl);
|
||||
}
|
||||
if (!blist.isEmpty()) {
|
||||
furnaceMap.put(uuid, blist);
|
||||
totalf += blist.size();
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (Jobs.getGCManager().isBrewingStandsReassign())
|
||||
if (config.contains("Brewing")) {
|
||||
ConfigurationSection section = config.getConfigurationSection("Brewing");
|
||||
if (Jobs.getGCManager().isBrewingStandsReassign()) {
|
||||
ConfigurationSection section = config.getConfigurationSection("Brewing");
|
||||
|
||||
try {
|
||||
for (String one : section.getKeys(false)) {
|
||||
String value = section.getString(one);
|
||||
List<String> ls = new ArrayList<>();
|
||||
if (value.contains(";"))
|
||||
ls.addAll(Arrays.asList(value.split(";")));
|
||||
else
|
||||
ls.add(value);
|
||||
UUID uuid = UUID.fromString(one);
|
||||
if (section == null)
|
||||
return;
|
||||
|
||||
if (uuid == null)
|
||||
continue;
|
||||
try {
|
||||
for (String one : section.getKeys(false)) {
|
||||
String value = section.getString(one);
|
||||
List<String> ls = new ArrayList<>();
|
||||
if (value.contains(";"))
|
||||
ls.addAll(Arrays.asList(value.split(";")));
|
||||
else
|
||||
ls.add(value);
|
||||
UUID uuid = UUID.fromString(one);
|
||||
|
||||
List<blockLoc> blist = new ArrayList<>();
|
||||
for (String oneL : ls) {
|
||||
blockLoc bl = new blockLoc(oneL);
|
||||
Block block = bl.getBlock();
|
||||
if (block == null)
|
||||
continue;
|
||||
if (uuid == null)
|
||||
continue;
|
||||
|
||||
block.removeMetadata(JobsPaymentListener.brewingOwnerMetadata, Jobs.getInstance());
|
||||
block.setMetadata(JobsPaymentListener.brewingOwnerMetadata, new FixedMetadataValue(Jobs.getInstance(), one));
|
||||
List<blockLoc> blist = new ArrayList<>();
|
||||
for (String oneL : ls) {
|
||||
blockLoc bl = new blockLoc(oneL);
|
||||
Block block = bl.getBlock();
|
||||
if (block == null)
|
||||
continue;
|
||||
|
||||
blist.add(bl);
|
||||
}
|
||||
if (!blist.isEmpty()) {
|
||||
brewingMap.put(uuid, blist);
|
||||
totalb += blist.size();
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
block.removeMetadata(JobsPaymentListener.brewingOwnerMetadata, Jobs.getInstance());
|
||||
block.setMetadata(JobsPaymentListener.brewingOwnerMetadata, new FixedMetadataValue(Jobs.getInstance(), one));
|
||||
|
||||
blist.add(bl);
|
||||
}
|
||||
if (!blist.isEmpty()) {
|
||||
brewingMap.put(uuid, blist);
|
||||
totalb += blist.size();
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (totalf > 0 || totalb > 0)
|
||||
Jobs.consoleMsg("&e[Jobs] Loaded " + totalf + " furnaces and " + totalb + " brewing stands for reassigning.");
|
||||
@ -122,11 +122,11 @@ public class FurnaceBrewingHandling {
|
||||
|
||||
public static void save() {
|
||||
YmlMaker f = new YmlMaker(Jobs.getInstance(), "furnaceBrewingStands.yml");
|
||||
|
||||
if (!f.exists())
|
||||
f.createNewFile();
|
||||
|
||||
f.saveDefaultConfig();
|
||||
|
||||
FileConfiguration config = f.getConfig();
|
||||
|
||||
if (Jobs.getGCManager().isFurnacesReassign()) {
|
||||
@ -142,9 +142,8 @@ public class FurnaceBrewingHandling {
|
||||
|
||||
full += oneL.toString();
|
||||
}
|
||||
if (!full.isEmpty()) {
|
||||
if (!full.isEmpty())
|
||||
config.set("Furnace." + one.getKey().toString(), full);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,7 +199,6 @@ public class FurnaceBrewingHandling {
|
||||
if (ls == null)
|
||||
return true;
|
||||
|
||||
// TODO Fix error when removing the furnaces from the file, but removing all
|
||||
for (blockLoc one : ls) {
|
||||
if (!one.getLocation().equals(block.getLocation()))
|
||||
continue;
|
||||
@ -227,7 +225,6 @@ public class FurnaceBrewingHandling {
|
||||
if (ls == null)
|
||||
return true;
|
||||
|
||||
// TODO Fix error when removing the brewers from the file, but removing all
|
||||
for (blockLoc one : ls) {
|
||||
if (!one.getLocation().equals(block.getLocation()))
|
||||
continue;
|
||||
@ -280,7 +277,7 @@ public class FurnaceBrewingHandling {
|
||||
|
||||
List<blockLoc> ls = furnaceMap.get(player.getUniqueId());
|
||||
if (ls == null)
|
||||
ls = new ArrayList<>();
|
||||
ls = new ArrayList<blockLoc>();
|
||||
ls.add(new blockLoc(block.getLocation()));
|
||||
furnaceMap.put(player.getUniqueId(), ls);
|
||||
|
||||
@ -324,7 +321,7 @@ public class FurnaceBrewingHandling {
|
||||
|
||||
List<blockLoc> ls = brewingMap.get(player.getUniqueId());
|
||||
if (ls == null)
|
||||
ls = new ArrayList<>();
|
||||
ls = new ArrayList<blockLoc>();
|
||||
ls.add(new blockLoc(block.getLocation()));
|
||||
brewingMap.put(player.getUniqueId(), ls);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user