mirror of
https://github.com/Zrips/Jobs.git
synced 2025-02-03 14:01:55 +01:00
Just some optimizations
This commit is contained in:
parent
db987fb532
commit
6a017df07f
@ -731,7 +731,7 @@ public class Jobs extends JavaPlugin {
|
||||
* Executes clean shutdown
|
||||
*/
|
||||
public static void shutdown() {
|
||||
Bukkit.getOnlinePlayers().forEach(p -> getPlayerManager().getJobsPlayer(p).clearBossMaps());
|
||||
//Bukkit.getOnlinePlayers().forEach(p -> getPlayerManager().getJobsPlayer(p).clearBossMaps());
|
||||
|
||||
if (saveTask != null)
|
||||
saveTask.shutdown();
|
||||
|
@ -33,12 +33,12 @@ public class leave implements Cmd {
|
||||
}
|
||||
|
||||
if (Jobs.getGCManager().EnableConfirmation) {
|
||||
String uuid = pSender.getUniqueId().toString();
|
||||
java.util.UUID uuid = pSender.getUniqueId();
|
||||
|
||||
if (!Util.confirmLeave.contains(uuid)) {
|
||||
Util.confirmLeave.add(uuid);
|
||||
if (!Util.leaveConfirm.contains(uuid)) {
|
||||
Util.leaveConfirm.add(uuid);
|
||||
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.confirmLeave.remove(uuid),
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.leaveConfirm.remove(uuid),
|
||||
20 * Jobs.getGCManager().ConfirmExpiryTime);
|
||||
|
||||
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.confirmationNeed", "[jobname]", jobName,
|
||||
@ -46,7 +46,7 @@ public class leave implements Cmd {
|
||||
return true;
|
||||
}
|
||||
|
||||
Util.confirmLeave.remove(uuid);
|
||||
Util.leaveConfirm.remove(uuid);
|
||||
}
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
|
||||
|
@ -32,12 +32,12 @@ public class leaveall implements Cmd {
|
||||
}
|
||||
|
||||
if (Jobs.getGCManager().EnableConfirmation) {
|
||||
String uuid = pSender.getUniqueId().toString();
|
||||
java.util.UUID uuid = pSender.getUniqueId();
|
||||
|
||||
if (!Util.confirmLeave.contains(uuid)) {
|
||||
Util.confirmLeave.add(uuid);
|
||||
if (!Util.leaveConfirm.contains(uuid)) {
|
||||
Util.leaveConfirm.add(uuid);
|
||||
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.confirmLeave.remove(uuid),
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.leaveConfirm.remove(uuid),
|
||||
20 * Jobs.getGCManager().ConfirmExpiryTime);
|
||||
|
||||
pSender.sendMessage(Jobs.getLanguage().getMessage("command.leaveall.confirmationNeed", "[time]",
|
||||
@ -45,7 +45,7 @@ public class leaveall implements Cmd {
|
||||
return true;
|
||||
}
|
||||
|
||||
Util.confirmLeave.remove(uuid);
|
||||
Util.leaveConfirm.remove(uuid);
|
||||
}
|
||||
|
||||
Jobs.getPlayerManager().leaveAllJobs(jPlayer);
|
||||
|
@ -39,6 +39,7 @@ import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -74,8 +75,8 @@ public class ConfigManager {
|
||||
File f = jobFile;
|
||||
InputStreamReader s = null;
|
||||
try {
|
||||
s = new InputStreamReader(new FileInputStream(f), "UTF-8");
|
||||
} catch (UnsupportedEncodingException | FileNotFoundException e1) {
|
||||
s = new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8);
|
||||
} catch (FileNotFoundException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
@ -97,8 +98,6 @@ public class ConfigManager {
|
||||
conf.options().pathSeparator('/');
|
||||
try {
|
||||
conf.load(s);
|
||||
if (s != null)
|
||||
s.close();
|
||||
} catch (Exception e) {
|
||||
Jobs.getPluginLogger().severe("==================== Jobs ====================");
|
||||
Jobs.getPluginLogger().severe("Unable to load jobConfig.yml!");
|
||||
@ -167,7 +166,6 @@ public class ConfigManager {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public KeyValues getKeyValue(String myKey, ActionType actionType, String jobName) {
|
||||
|
||||
String type = null;
|
||||
String subType = "";
|
||||
String meta = "";
|
||||
@ -393,9 +391,8 @@ public class ConfigManager {
|
||||
YmlMaker jobConfig = new YmlMaker(Jobs.getInstance(), "jobConfig.yml");
|
||||
jobConfig.saveDefaultConfig();
|
||||
}
|
||||
InputStreamReader s = new InputStreamReader(new FileInputStream(f), "UTF-8");
|
||||
|
||||
ArrayList<Job> jobs = new ArrayList<>();
|
||||
InputStreamReader s = new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8);
|
||||
|
||||
Jobs.setNoneJob(null);
|
||||
|
||||
@ -412,7 +409,6 @@ public class ConfigManager {
|
||||
conf.options().pathSeparator('/');
|
||||
try {
|
||||
conf.load(s);
|
||||
s.close();
|
||||
} catch (Exception e) {
|
||||
Jobs.getPluginLogger().severe("==================== Jobs ====================");
|
||||
Jobs.getPluginLogger().severe("Unable to load jobConfig.yml!");
|
||||
@ -434,8 +430,9 @@ public class ConfigManager {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String jobKey : jobsSection.getKeys(false)) {
|
||||
ArrayList<Job> jobs = new ArrayList<>();
|
||||
|
||||
for (String jobKey : jobsSection.getKeys(false)) {
|
||||
// Ignoring example job
|
||||
if (jobKey.equalsIgnoreCase("exampleJob"))
|
||||
continue;
|
||||
@ -607,20 +604,19 @@ public class ConfigManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (material != null)
|
||||
GUIitem = material.newItemStack();
|
||||
|
||||
if (guiSection.contains("Enchantments")) {
|
||||
List<String> enchants = guiSection.getStringList("Enchantments");
|
||||
if (!enchants.isEmpty()) {
|
||||
for (String str4 : enchants) {
|
||||
String[] enchantid = str4.split(":");
|
||||
if ((GUIitem.getItemMeta() instanceof EnchantmentStorageMeta)) {
|
||||
EnchantmentStorageMeta enchantMeta = (EnchantmentStorageMeta) GUIitem.getItemMeta();
|
||||
enchantMeta.addStoredEnchant(CMIEnchantment.getEnchantment(enchantid[0]), Integer.parseInt(enchantid[1]), true);
|
||||
GUIitem.setItemMeta(enchantMeta);
|
||||
} else
|
||||
GUIitem.addUnsafeEnchantment(CMIEnchantment.getEnchantment(enchantid[0]), Integer.parseInt(enchantid[1]));
|
||||
}
|
||||
for (String str4 : guiSection.getStringList("Enchantments")) {
|
||||
String[] enchantid = str4.split(":");
|
||||
if ((GUIitem.getItemMeta() instanceof EnchantmentStorageMeta)) {
|
||||
EnchantmentStorageMeta enchantMeta = (EnchantmentStorageMeta) GUIitem.getItemMeta();
|
||||
enchantMeta.addStoredEnchant(CMIEnchantment.getEnchantment(enchantid[0]), Integer.parseInt(enchantid[1]), true);
|
||||
GUIitem.setItemMeta(enchantMeta);
|
||||
} else
|
||||
GUIitem.addUnsafeEnchantment(CMIEnchantment.getEnchantment(enchantid[0]), Integer.parseInt(enchantid[1]));
|
||||
}
|
||||
} else if (guiSection.contains("CustomSkull")) {
|
||||
String skullOwner = guiSection.getString("CustomSkull");
|
||||
@ -639,17 +635,14 @@ public class ConfigManager {
|
||||
} else if (guiSection.isInt("Id") && guiSection.isInt("Data")) {
|
||||
GUIitem = CMIMaterial.get(guiSection.getInt("Id"), guiSection.getInt("Data")).newItemStack();
|
||||
if (guiSection.contains("Enchantments")) {
|
||||
List<String> enchants = guiSection.getStringList("Enchantments");
|
||||
if (enchants.size() > 0) {
|
||||
for (String str4 : enchants) {
|
||||
String[] id = str4.split(":");
|
||||
if ((GUIitem.getItemMeta() instanceof EnchantmentStorageMeta)) {
|
||||
EnchantmentStorageMeta enchantMeta = (EnchantmentStorageMeta) GUIitem.getItemMeta();
|
||||
enchantMeta.addStoredEnchant(CMIEnchantment.getEnchantment(id[0]), Integer.parseInt(id[1]), true);
|
||||
GUIitem.setItemMeta(enchantMeta);
|
||||
} else
|
||||
GUIitem.addUnsafeEnchantment(CMIEnchantment.getEnchantment(id[0]), Integer.parseInt(id[1]));
|
||||
}
|
||||
for (String str4 : guiSection.getStringList("Enchantments")) {
|
||||
String[] id = str4.split(":");
|
||||
if ((GUIitem.getItemMeta() instanceof EnchantmentStorageMeta)) {
|
||||
EnchantmentStorageMeta enchantMeta = (EnchantmentStorageMeta) GUIitem.getItemMeta();
|
||||
enchantMeta.addStoredEnchant(CMIEnchantment.getEnchantment(id[0]), Integer.parseInt(id[1]), true);
|
||||
GUIitem.setItemMeta(enchantMeta);
|
||||
} else
|
||||
GUIitem.addUnsafeEnchantment(CMIEnchantment.getEnchantment(id[0]), Integer.parseInt(id[1]));
|
||||
}
|
||||
} else if (guiSection.contains("CustomSkull")) {
|
||||
String skullOwner = guiSection.getString("CustomSkull");
|
||||
@ -1206,11 +1199,11 @@ public class ConfigManager {
|
||||
Jobs.setNoneJob(job);
|
||||
else
|
||||
jobs.add(job);
|
||||
|
||||
Jobs.setJobs(jobs);
|
||||
}
|
||||
|
||||
Jobs.consoleMsg("&e[Jobs] Loaded " + Jobs.getJobs().size() + " jobs!");
|
||||
Jobs.setJobs(jobs);
|
||||
|
||||
Jobs.consoleMsg("&e[Jobs] Loaded " + jobs.size() + " jobs!");
|
||||
if (!Jobs.getExplore().isExploreEnabled())
|
||||
Jobs.consoleMsg("&6[Jobs] Explorer jobs manager are not enabled!");
|
||||
else
|
||||
|
@ -5,7 +5,7 @@ import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -34,8 +34,8 @@ public class YmlMaker {
|
||||
public void reloadConfig() {
|
||||
InputStreamReader f = null;
|
||||
try {
|
||||
f = new InputStreamReader(new FileInputStream(ConfigFile), "UTF-8");
|
||||
} catch (UnsupportedEncodingException | FileNotFoundException e1) {
|
||||
f = new InputStreamReader(new FileInputStream(ConfigFile), StandardCharsets.UTF_8);
|
||||
} catch (FileNotFoundException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,6 @@ public abstract class JobsDAO {
|
||||
|
||||
worldsTableFields(String type, boolean unique) {
|
||||
this.type = type;
|
||||
|
||||
this.unique = unique;
|
||||
}
|
||||
|
||||
@ -98,7 +97,6 @@ public abstract class JobsDAO {
|
||||
|
||||
jobsNameTableFields(String type, boolean unique) {
|
||||
this.type = type;
|
||||
|
||||
this.unique = unique;
|
||||
}
|
||||
|
||||
@ -129,7 +127,6 @@ public abstract class JobsDAO {
|
||||
|
||||
UserTableFields(String type) {
|
||||
this.type = type;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -159,7 +156,6 @@ public abstract class JobsDAO {
|
||||
|
||||
JobsTableFields(String type) {
|
||||
this.type = type;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -190,7 +186,6 @@ public abstract class JobsDAO {
|
||||
|
||||
ArchiveTableFields(String type) {
|
||||
this.type = type;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -222,7 +217,6 @@ public abstract class JobsDAO {
|
||||
|
||||
BlockTableFields(String type) {
|
||||
this.type = type;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -252,7 +246,6 @@ public abstract class JobsDAO {
|
||||
|
||||
LimitTableFields(String type) {
|
||||
this.ttype = type;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -285,7 +278,6 @@ public abstract class JobsDAO {
|
||||
|
||||
LogTableFields(String type) {
|
||||
this.type = type;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -313,7 +305,6 @@ public abstract class JobsDAO {
|
||||
|
||||
PointsTableFields(String type) {
|
||||
this.type = type;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1761,7 +1752,7 @@ public abstract class JobsDAO {
|
||||
PreparedStatement prest = null;
|
||||
ResultSet res = null;
|
||||
try {
|
||||
prest = conn.prepareStatement("SELECT * FROM `" + DBTables.UsersTable.getTableName() + "`;");
|
||||
prest = conn.prepareStatement("SELECT * FROM `" + DBTables.UsersTable.getTableName() + "`;");
|
||||
res = prest.executeQuery();
|
||||
while (res.next()) {
|
||||
long seen = System.currentTimeMillis();
|
||||
@ -1787,9 +1778,7 @@ public abstract class JobsDAO {
|
||||
}
|
||||
|
||||
public JobsPlayer loadFromDao(JobsPlayer jPlayer) {
|
||||
|
||||
List<JobsDAOData> list = getAllJobs(jPlayer.getName(), jPlayer.getUniqueId());
|
||||
// synchronized (jPlayer.saveLock) {
|
||||
jPlayer.progression.clear();
|
||||
for (JobsDAOData jobdata : list) {
|
||||
if (!plugin.isEnabled())
|
||||
@ -1810,17 +1799,14 @@ public abstract class JobsDAO {
|
||||
jPlayer.reloadLimits();
|
||||
jPlayer.setUserId(Jobs.getPlayerManager().getPlayerId(jPlayer.getUniqueId()));
|
||||
loadPoints(jPlayer);
|
||||
// }
|
||||
return jPlayer;
|
||||
}
|
||||
|
||||
public JobsPlayer loadFromDao(OfflinePlayer player) {
|
||||
|
||||
JobsPlayer jPlayer = new JobsPlayer(player.getName());
|
||||
jPlayer.setPlayerUUID(player.getUniqueId());
|
||||
|
||||
List<JobsDAOData> list = getAllJobs(player);
|
||||
// synchronized (jPlayer.saveLock) {
|
||||
jPlayer.progression.clear();
|
||||
for (JobsDAOData jobdata : list) {
|
||||
if (!plugin.isEnabled())
|
||||
@ -1841,7 +1827,6 @@ public abstract class JobsDAO {
|
||||
jPlayer.reloadLimits();
|
||||
jPlayer.setUserId(Jobs.getPlayerManager().getPlayerId(player.getUniqueId()));
|
||||
loadPoints(jPlayer);
|
||||
// }
|
||||
return jPlayer;
|
||||
}
|
||||
|
||||
@ -1927,7 +1912,6 @@ public abstract class JobsDAO {
|
||||
}
|
||||
|
||||
public void updateSeen(JobsPlayer player) {
|
||||
|
||||
if (player.getUserId() == -1) {
|
||||
insertPlayer(player);
|
||||
return;
|
||||
@ -1981,7 +1965,7 @@ public abstract class JobsDAO {
|
||||
PreparedStatement prest = null;
|
||||
ResultSet res = null;
|
||||
try {
|
||||
prest = conn.prepareStatement("SELECT `id`,`" + UserTableFields.donequests.getCollumn()
|
||||
prest = conn.prepareStatement("SELECT `id`, `" + UserTableFields.donequests.getCollumn()
|
||||
+ "` FROM `" + DBTables.UsersTable.getTableName() + "` WHERE `" + UserTableFields.player_uuid.getCollumn() + "` = ?;");
|
||||
prest.setString(1, player.getUniqueId().toString());
|
||||
res = prest.executeQuery();
|
||||
|
@ -99,9 +99,7 @@ public class JobsManager {
|
||||
}
|
||||
|
||||
private synchronized JobsMySQL startMysql() {
|
||||
|
||||
ConfigReader c = Jobs.getGCManager().getConfig();
|
||||
|
||||
String legacyUrl = c.getC().getString("mysql.url");
|
||||
if (legacyUrl != null) {
|
||||
String jdbcString = "jdbc:mysql://";
|
||||
@ -114,9 +112,9 @@ public class JobsManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (username == null) {
|
||||
Jobs.getPluginLogger().severe("mysql username property invalid or missing");
|
||||
username = "root";
|
||||
}
|
||||
|
||||
if (plugin.isEnabled()) {
|
||||
|
@ -30,14 +30,13 @@ public class FurnaceBrewingHandling {
|
||||
if (!f.exists())
|
||||
return;
|
||||
|
||||
FileConfiguration config = f.getConfig();
|
||||
|
||||
int totalf = 0;
|
||||
int totalb = 0;
|
||||
|
||||
FileConfiguration config = f.getConfig();
|
||||
|
||||
if (Jobs.getGCManager().isFurnacesReassign()) {
|
||||
ConfigurationSection section = config.getConfigurationSection("Furnace");
|
||||
|
||||
if (section == null)
|
||||
return;
|
||||
|
||||
@ -49,10 +48,11 @@ public class FurnaceBrewingHandling {
|
||||
ls.addAll(Arrays.asList(value.split(";")));
|
||||
else
|
||||
ls.add(value);
|
||||
UUID uuid = UUID.fromString(one);
|
||||
|
||||
UUID uuid = UUID.fromString(one);
|
||||
if (uuid == null)
|
||||
continue;
|
||||
|
||||
List<blockLoc> blist = new ArrayList<>();
|
||||
for (String oneL : ls) {
|
||||
blockLoc bl = new blockLoc(oneL);
|
||||
@ -65,9 +65,10 @@ public class FurnaceBrewingHandling {
|
||||
|
||||
blist.add(bl);
|
||||
}
|
||||
|
||||
if (!blist.isEmpty()) {
|
||||
furnaceMap.put(uuid, blist);
|
||||
totalf += blist.size();
|
||||
totalf++;
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
@ -77,7 +78,6 @@ public class FurnaceBrewingHandling {
|
||||
|
||||
if (Jobs.getGCManager().isBrewingStandsReassign()) {
|
||||
ConfigurationSection section = config.getConfigurationSection("Brewing");
|
||||
|
||||
if (section == null)
|
||||
return;
|
||||
|
||||
@ -89,8 +89,8 @@ public class FurnaceBrewingHandling {
|
||||
ls.addAll(Arrays.asList(value.split(";")));
|
||||
else
|
||||
ls.add(value);
|
||||
UUID uuid = UUID.fromString(one);
|
||||
|
||||
UUID uuid = UUID.fromString(one);
|
||||
if (uuid == null)
|
||||
continue;
|
||||
|
||||
@ -106,9 +106,10 @@ public class FurnaceBrewingHandling {
|
||||
|
||||
blist.add(bl);
|
||||
}
|
||||
|
||||
if (!blist.isEmpty()) {
|
||||
brewingMap.put(uuid, blist);
|
||||
totalb += blist.size();
|
||||
totalb++;
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
@ -132,11 +133,8 @@ public class FurnaceBrewingHandling {
|
||||
if (Jobs.getGCManager().isFurnacesReassign()) {
|
||||
config.set("Furnace", null);
|
||||
for (Entry<UUID, List<blockLoc>> one : furnaceMap.entrySet()) {
|
||||
|
||||
String full = "";
|
||||
|
||||
for (blockLoc oneL : one.getValue()) {
|
||||
|
||||
if (!full.isEmpty())
|
||||
full += ";";
|
||||
|
||||
@ -150,11 +148,9 @@ public class FurnaceBrewingHandling {
|
||||
if (Jobs.getGCManager().isBrewingStandsReassign()) {
|
||||
config.set("Brewing", null);
|
||||
for (Entry<UUID, List<blockLoc>> one : brewingMap.entrySet()) {
|
||||
|
||||
String full = "";
|
||||
|
||||
for (blockLoc oneL : one.getValue()) {
|
||||
|
||||
if (!full.isEmpty())
|
||||
full += ";";
|
||||
|
||||
@ -171,16 +167,12 @@ public class FurnaceBrewingHandling {
|
||||
|
||||
public static int getTotalFurnaces(UUID uuid) {
|
||||
List<blockLoc> ls = furnaceMap.get(uuid);
|
||||
if (ls == null)
|
||||
return 0;
|
||||
return ls.size();
|
||||
return ls == null ? 0 : ls.size();
|
||||
}
|
||||
|
||||
public static int getTotalBrewingStands(UUID uuid) {
|
||||
List<blockLoc> ls = brewingMap.get(uuid);
|
||||
if (ls == null)
|
||||
return 0;
|
||||
return ls.size();
|
||||
return ls == null ? 0 : ls.size();
|
||||
}
|
||||
|
||||
public static boolean removeFurnace(Block block) {
|
||||
@ -369,4 +361,12 @@ public class FurnaceBrewingHandling {
|
||||
}
|
||||
return ls.size();
|
||||
}
|
||||
|
||||
public static HashMap<UUID, List<blockLoc>> getBrewingMap() {
|
||||
return brewingMap;
|
||||
}
|
||||
|
||||
public static HashMap<UUID, List<blockLoc>> getFurnaceMap() {
|
||||
return furnaceMap;
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,8 @@ public class Util {
|
||||
|
||||
private static HashMap<UUID, String> jobsEditorMap = new HashMap<>();
|
||||
private static HashMap<UUID, String> questsEditorMap = new HashMap<>();
|
||||
public static List<String> confirmLeave = new ArrayList<>();
|
||||
@Deprecated public static List<String> confirmLeave = new ArrayList<>();
|
||||
public static List<UUID> leaveConfirm = new ArrayList<>();
|
||||
|
||||
private static HashMap<String, JobsWorld> jobsWorlds = new HashMap<>();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user