mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-25 20:16:13 +01:00
Code cleaning and preventing self killing income
This commit is contained in:
parent
5c715e35f8
commit
19f9175072
@ -33,6 +33,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import com.gamingmesh.jobs.Signs.SignUtil;
|
||||
import com.gamingmesh.jobs.config.ConfigManager;
|
||||
import com.gamingmesh.jobs.container.ActionInfo;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
@ -47,12 +48,19 @@ import com.gamingmesh.jobs.i18n.Language;
|
||||
import com.gamingmesh.jobs.stuff.ActionBar;
|
||||
import com.gamingmesh.jobs.stuff.JobsClassLoader;
|
||||
import com.gamingmesh.jobs.stuff.Loging;
|
||||
import com.gamingmesh.jobs.stuff.Scboard;
|
||||
import com.gamingmesh.jobs.stuff.ScheduleUtil;
|
||||
import com.gamingmesh.jobs.tasks.BufferedPaymentThread;
|
||||
import com.gamingmesh.jobs.tasks.DatabaseSaveThread;
|
||||
|
||||
public class Jobs {
|
||||
public static Jobs instance = new Jobs();
|
||||
// public static JobsPlugin plugin = new JobsPlugin();
|
||||
private static PlayerManager pManager = new PlayerManager();
|
||||
private static Language lManager = new Language();
|
||||
private static SignUtil signManager = new SignUtil();
|
||||
private static Scboard scboardManager = new Scboard();
|
||||
private static ScheduleUtil scheduleManager = new ScheduleUtil();
|
||||
|
||||
private static Logger pLogger;
|
||||
private static File dataFolder;
|
||||
@ -83,6 +91,54 @@ public class Jobs {
|
||||
return pManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns schedule manager
|
||||
* @return the schedule manager
|
||||
*/
|
||||
public static ScheduleUtil getSchedule() {
|
||||
return scheduleManager;
|
||||
}
|
||||
|
||||
public static void setSchedule(JobsPlugin plugin) {
|
||||
scheduleManager = new ScheduleUtil(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns scoreboard manager
|
||||
* @return the scoreboard manager
|
||||
*/
|
||||
public static Scboard getScboard() {
|
||||
return scboardManager;
|
||||
}
|
||||
|
||||
public static void setScboard(JobsPlugin plugin) {
|
||||
scboardManager = new Scboard(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns sign manager
|
||||
* @return the sign manager
|
||||
*/
|
||||
public static SignUtil getSignUtil() {
|
||||
return signManager;
|
||||
}
|
||||
|
||||
public static void setSignUtil(JobsPlugin plugin) {
|
||||
signManager = new SignUtil(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns language manager
|
||||
* @return the language manager
|
||||
*/
|
||||
public static Language getLanguage() {
|
||||
return lManager;
|
||||
}
|
||||
|
||||
public static void setLanguage(JobsPlugin plugin) {
|
||||
lManager = new Language(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the plugin logger
|
||||
*/
|
||||
@ -207,7 +263,7 @@ public class Jobs {
|
||||
}
|
||||
|
||||
ConfigManager.getJobsConfiguration().reload();
|
||||
Language.reload(ConfigManager.getJobsConfiguration().getLocale());
|
||||
Jobs.getLanguage().reload(ConfigManager.getJobsConfiguration().getLocale());
|
||||
ConfigManager.getJobConfig().reload();
|
||||
usedSlots.clear();
|
||||
for (Job job : jobs) {
|
||||
|
@ -27,7 +27,6 @@ import net.elseland.xikage.MythicMobs.API.MythicMobsAPI;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
@ -42,12 +41,10 @@ import com.gamingmesh.jobs.listeners.McMMOlistener;
|
||||
import com.gamingmesh.jobs.listeners.MythicMobsListener;
|
||||
import com.gamingmesh.jobs.listeners.PistonProtectionListener;
|
||||
import com.gamingmesh.jobs.stuff.OfflinePlayerList;
|
||||
import com.gamingmesh.jobs.stuff.ScheduleUtil;
|
||||
import com.gamingmesh.jobs.stuff.TabComplete;
|
||||
import com.gamingmesh.jobs.config.YmlMaker;
|
||||
|
||||
public class JobsPlugin extends JavaPlugin {
|
||||
public static Plugin instance;
|
||||
public static CoreProtectAPI CPAPI;
|
||||
public static MythicMobsAPI MMAPI;
|
||||
public static boolean CPPresent = false;
|
||||
@ -96,7 +93,6 @@ public class JobsPlugin extends JavaPlugin {
|
||||
this.setEnabled(false);
|
||||
}
|
||||
|
||||
instance = this;
|
||||
OfflinePlayerList.fillList();
|
||||
YmlMaker jobConfig = new YmlMaker(this, "jobConfig.yml");
|
||||
jobConfig.saveDefaultConfig();
|
||||
@ -109,6 +105,11 @@ public class JobsPlugin extends JavaPlugin {
|
||||
|
||||
Jobs.setPermissionHandler(new PermissionHandler(this));
|
||||
|
||||
Jobs.setSignUtil(this);
|
||||
Jobs.setScboard(this);
|
||||
Jobs.setSchedule(this);
|
||||
Jobs.setLanguage(this);
|
||||
|
||||
Jobs.setPluginLogger(getLogger());
|
||||
|
||||
Jobs.setDataFolder(getDataFolder());
|
||||
@ -116,7 +117,7 @@ public class JobsPlugin extends JavaPlugin {
|
||||
ConfigManager.registerJobsConfiguration(new JobsConfiguration(this));
|
||||
ConfigManager.registerJobConfig(new JobConfig(this));
|
||||
|
||||
getCommand("jobs").setExecutor(new JobsCommands());
|
||||
getCommand("jobs").setExecutor(new JobsCommands(this));
|
||||
|
||||
this.getCommand("jobs").setTabCompleter(new TabComplete());
|
||||
|
||||
@ -154,12 +155,13 @@ public class JobsPlugin extends JavaPlugin {
|
||||
// all loaded properly.
|
||||
|
||||
if (ConfigManager.getJobsConfiguration().useGlobalBoostScheduler)
|
||||
ScheduleUtil.scheduler();
|
||||
ScheduleUtil.DateUpdater();
|
||||
Jobs.getSchedule().scheduler();
|
||||
Jobs.getSchedule().DateUpdater();
|
||||
|
||||
String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &6Plugin has been enabled succesfully.");
|
||||
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
|
||||
console.sendMessage(message);
|
||||
Jobs.getLanguage().reload(ConfigManager.getJobsConfiguration().getLocale());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -180,8 +180,8 @@ public class PlayerManager {
|
||||
Jobs.getJobsDAO().joinJob(jPlayer, job);
|
||||
PerformCommands.PerformCommandsOnJoin(jPlayer, job);
|
||||
Jobs.takeSlot(job);
|
||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
|
||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
||||
Jobs.getSignUtil().SignUpdate(job.getName());
|
||||
Jobs.getSignUtil().SignUpdate("gtoplist");
|
||||
job.updateTotalPlayers();
|
||||
// }
|
||||
}
|
||||
@ -211,8 +211,8 @@ public class PlayerManager {
|
||||
PerformCommands.PerformCommandsOnLeave(jPlayer, job);
|
||||
Jobs.leaveSlot(job);
|
||||
|
||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
|
||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
||||
Jobs.getSignUtil().SignUpdate(job.getName());
|
||||
Jobs.getSignUtil().SignUpdate("gtoplist");
|
||||
job.updateTotalPlayers();
|
||||
// }
|
||||
}
|
||||
@ -228,8 +228,8 @@ public class PlayerManager {
|
||||
PerformCommands.PerformCommandsOnLeave(jPlayer, job.getJob());
|
||||
Jobs.leaveSlot(job.getJob());
|
||||
|
||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getJob().getName());
|
||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
||||
Jobs.getSignUtil().SignUpdate(job.getJob().getName());
|
||||
Jobs.getSignUtil().SignUpdate("gtoplist");
|
||||
job.getJob().updateTotalPlayers();
|
||||
}
|
||||
|
||||
@ -268,8 +268,8 @@ public class PlayerManager {
|
||||
jPlayer.promoteJob(job, levels, jPlayer);
|
||||
jPlayer.save(Jobs.getJobsDAO());
|
||||
|
||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
|
||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
||||
Jobs.getSignUtil().SignUpdate(job.getName());
|
||||
Jobs.getSignUtil().SignUpdate("gtoplist");
|
||||
// }
|
||||
}
|
||||
|
||||
@ -283,8 +283,8 @@ public class PlayerManager {
|
||||
// synchronized (jPlayer.saveLock) {
|
||||
jPlayer.demoteJob(job, levels);
|
||||
jPlayer.save(Jobs.getJobsDAO());
|
||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
|
||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
||||
Jobs.getSignUtil().SignUpdate(job.getName());
|
||||
Jobs.getSignUtil().SignUpdate("gtoplist");
|
||||
// }
|
||||
}
|
||||
|
||||
@ -304,8 +304,8 @@ public class PlayerManager {
|
||||
performLevelUp(jPlayer, job, oldLevel);
|
||||
|
||||
jPlayer.save(Jobs.getJobsDAO());
|
||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
|
||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
||||
Jobs.getSignUtil().SignUpdate(job.getName());
|
||||
Jobs.getSignUtil().SignUpdate("gtoplist");
|
||||
// }
|
||||
}
|
||||
|
||||
@ -323,8 +323,8 @@ public class PlayerManager {
|
||||
prog.addExperience(-experience);
|
||||
|
||||
jPlayer.save(Jobs.getJobsDAO());
|
||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
|
||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
||||
Jobs.getSignUtil().SignUpdate(job.getName());
|
||||
Jobs.getSignUtil().SignUpdate("gtoplist");
|
||||
// }
|
||||
}
|
||||
|
||||
@ -419,8 +419,8 @@ public class PlayerManager {
|
||||
jPlayer.reloadHonorific();
|
||||
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
|
||||
performCommandOnLevelUp(jPlayer, prog.getJob(), oldLevel);
|
||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
|
||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
||||
Jobs.getSignUtil().SignUpdate(job.getName());
|
||||
Jobs.getSignUtil().SignUpdate("gtoplist");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,231 +1,243 @@
|
||||
package com.gamingmesh.jobs.Signs;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Skull;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.JobsPlugin;
|
||||
import com.gamingmesh.jobs.config.CommentedYamlConfiguration;
|
||||
import com.gamingmesh.jobs.config.ConfigManager;
|
||||
import com.gamingmesh.jobs.container.TopList;
|
||||
import com.gamingmesh.jobs.i18n.Language;
|
||||
|
||||
public class SignUtil {
|
||||
|
||||
public static SignInfo Signs = new SignInfo();
|
||||
|
||||
// Sign file
|
||||
public static void LoadSigns() {
|
||||
Thread threadd = new Thread() {
|
||||
public void run() {
|
||||
|
||||
Signs.GetAllSigns().clear();
|
||||
File file = new File(JobsPlugin.instance.getDataFolder(), "Signs.yml");
|
||||
YamlConfiguration f = YamlConfiguration.loadConfiguration(file);
|
||||
|
||||
if (!f.isConfigurationSection("Signs"))
|
||||
return;
|
||||
|
||||
ConfigurationSection ConfCategory = f.getConfigurationSection("Signs");
|
||||
ArrayList<String> categoriesList = new ArrayList<String>(ConfCategory.getKeys(false));
|
||||
if (categoriesList.size() == 0)
|
||||
return;
|
||||
for (String category : categoriesList) {
|
||||
ConfigurationSection NameSection = ConfCategory.getConfigurationSection(category);
|
||||
com.gamingmesh.jobs.Signs.Sign newTemp = new com.gamingmesh.jobs.Signs.Sign();
|
||||
newTemp.setCategory(Integer.valueOf(category));
|
||||
newTemp.setWorld(NameSection.getString("World"));
|
||||
newTemp.setX(NameSection.getDouble("X"));
|
||||
newTemp.setY(NameSection.getDouble("Y"));
|
||||
newTemp.setZ(NameSection.getDouble("Z"));
|
||||
newTemp.setNumber(NameSection.getInt("Number"));
|
||||
newTemp.setJobName(NameSection.getString("JobName"));
|
||||
newTemp.setSpecial(NameSection.getBoolean("Special"));
|
||||
Signs.addSign(newTemp);
|
||||
}
|
||||
return;
|
||||
}
|
||||
};
|
||||
threadd.start();
|
||||
}
|
||||
|
||||
// Signs save file
|
||||
public static void saveSigns() {
|
||||
|
||||
Thread threadd = new Thread() {
|
||||
public void run() {
|
||||
File f = new File(JobsPlugin.instance.getDataFolder(), "Signs.yml");
|
||||
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
|
||||
|
||||
CommentedYamlConfiguration writer = new CommentedYamlConfiguration();
|
||||
conf.options().copyDefaults(true);
|
||||
|
||||
writer.addComment("Signs", "DO NOT EDIT THIS FILE BY HAND!");
|
||||
|
||||
if (!conf.isConfigurationSection("Signs"))
|
||||
conf.createSection("Signs");
|
||||
|
||||
for (com.gamingmesh.jobs.Signs.Sign one : Signs.GetAllSigns()) {
|
||||
String path = "Signs." + String.valueOf(one.GetCategory());
|
||||
writer.set(path + ".World", one.GetWorld());
|
||||
writer.set(path + ".X", one.GetX());
|
||||
writer.set(path + ".Y", one.GetY());
|
||||
writer.set(path + ".Z", one.GetZ());
|
||||
writer.set(path + ".Number", one.GetNumber());
|
||||
writer.set(path + ".JobName", one.GetJobName());
|
||||
writer.set(path + ".Special", one.isSpecial());
|
||||
}
|
||||
|
||||
try {
|
||||
writer.save(f);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
;
|
||||
}
|
||||
return;
|
||||
}
|
||||
};
|
||||
threadd.start();
|
||||
}
|
||||
|
||||
public static boolean SignUpdate(String JobName) {
|
||||
List<com.gamingmesh.jobs.Signs.Sign> Copy = new ArrayList<com.gamingmesh.jobs.Signs.Sign>(Signs.GetAllSigns().size());
|
||||
for (com.gamingmesh.jobs.Signs.Sign foo : Signs.GetAllSigns()) {
|
||||
Copy.add(foo);
|
||||
}
|
||||
int timelapse = 1;
|
||||
for (com.gamingmesh.jobs.Signs.Sign one : Copy) {
|
||||
String SignJobName = one.GetJobName();
|
||||
if (JobName.equalsIgnoreCase(SignJobName)) {
|
||||
String SignsWorld = one.GetWorld();
|
||||
double SignsX = one.GetX();
|
||||
double SignsY = one.GetY();
|
||||
double SignsZ = one.GetZ();
|
||||
int number = one.GetNumber() - 1;
|
||||
|
||||
List<TopList> PlayerList = new ArrayList<TopList>();
|
||||
if (!JobName.equalsIgnoreCase("gtoplist")) {
|
||||
PlayerList = Jobs.getJobsDAO().toplist(SignJobName, number);
|
||||
} else {
|
||||
PlayerList = Jobs.getJobsDAO().getGlobalTopList(number);
|
||||
}
|
||||
if (PlayerList.size() != 0) {
|
||||
World world = Bukkit.getWorld(SignsWorld);
|
||||
if (world == null)
|
||||
continue;
|
||||
Location nloc = new Location(world, SignsX, SignsY, SignsZ);
|
||||
Block block = nloc.getBlock();
|
||||
if (!(block.getState() instanceof org.bukkit.block.Sign)) {
|
||||
Signs.GetAllSigns().remove(one);
|
||||
saveSigns();
|
||||
} else {
|
||||
org.bukkit.block.Sign sign = (org.bukkit.block.Sign) block.getState();
|
||||
if (!one.isSpecial()) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (i >= PlayerList.size()) {
|
||||
break;
|
||||
}
|
||||
String PlayerName = ((TopList) PlayerList.get(i)).getPlayerName();
|
||||
|
||||
if (PlayerName != null && PlayerName.length() > 8) {
|
||||
String PlayerNameStrip = PlayerName.split("(?<=\\G.{7})")[0];
|
||||
PlayerName = PlayerNameStrip + "~";
|
||||
}
|
||||
|
||||
if (PlayerName == null)
|
||||
PlayerName = "Unknown";
|
||||
|
||||
String line = Language.getMessage("signs.List");
|
||||
line = line.replace("[number]", String.valueOf(i + number + 1));
|
||||
line = line.replace("[player]", PlayerName);
|
||||
line = line.replace("[level]", String.valueOf(((TopList) PlayerList.get(i)).getLevel()));
|
||||
|
||||
sign.setLine(i, line);
|
||||
}
|
||||
sign.update();
|
||||
UpdateHead(sign.getLocation(), ((TopList) PlayerList.get(0)).getPlayerName(), timelapse);
|
||||
} else {
|
||||
String PlayerName = ((TopList) PlayerList.get(0)).getPlayerName();
|
||||
if (PlayerName.length() > 18) {
|
||||
String PlayerNameStrip = PlayerName.split("(?<=\\G.{13})")[0];
|
||||
PlayerName = PlayerNameStrip + "~";
|
||||
}
|
||||
String line1 = Language.getMessage("signs.SpecialList." + one.GetNumber() + ".1");
|
||||
line1 = line1.replace("[number]", String.valueOf(one.GetNumber() + number + 1));
|
||||
line1 = line1.replace("[player]", PlayerName);
|
||||
line1 = line1.replace("[level]", String.valueOf(((TopList) PlayerList.get(0)).getLevel()));
|
||||
|
||||
sign.setLine(0, line1);
|
||||
|
||||
line1 = Language.getMessage("signs.SpecialList." + one.GetNumber() + ".2");
|
||||
line1 = line1.replace("[number]", String.valueOf(one.GetNumber() + number + 1));
|
||||
line1 = line1.replace("[player]", PlayerName);
|
||||
line1 = line1.replace("[level]", String.valueOf(((TopList) PlayerList.get(0)).getLevel()));
|
||||
|
||||
sign.setLine(1, line1);
|
||||
|
||||
line1 = Language.getMessage("signs.SpecialList." + one.GetNumber() + ".3");
|
||||
line1 = line1.replace("[number]", String.valueOf(one.GetNumber() + number + 1));
|
||||
line1 = line1.replace("[player]", PlayerName);
|
||||
line1 = line1.replace("[level]", String.valueOf(((TopList) PlayerList.get(0)).getLevel()));
|
||||
|
||||
sign.setLine(2, line1);
|
||||
|
||||
line1 = Language.getMessage("signs.SpecialList." + one.GetNumber() + ".4");
|
||||
line1 = line1.replace("[number]", String.valueOf(one.GetNumber() + number + 1));
|
||||
line1 = line1.replace("[player]", PlayerName);
|
||||
line1 = line1.replace("[level]", String.valueOf(((TopList) PlayerList.get(0)).getLevel()));
|
||||
|
||||
sign.setLine(3, line1);
|
||||
sign.update();
|
||||
UpdateHead(sign.getLocation(), ((TopList) PlayerList.get(0)).getPlayerName(), timelapse);
|
||||
}
|
||||
|
||||
timelapse++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void UpdateHead(final Location loc, final String Playername, final int timelapse) {
|
||||
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(JobsPlugin.instance, new Runnable() {
|
||||
public void run() {
|
||||
|
||||
loc.setY(loc.getY() + 1);
|
||||
|
||||
if (Playername == null)
|
||||
return;
|
||||
|
||||
Block block = loc.getBlock();
|
||||
|
||||
if (block == null)
|
||||
return;
|
||||
|
||||
if (!(block.getState() instanceof Skull))
|
||||
return;
|
||||
|
||||
Skull skull = (Skull) block.getState();
|
||||
|
||||
if (skull == null)
|
||||
return;
|
||||
|
||||
skull.setOwner(Playername);
|
||||
skull.update();
|
||||
return;
|
||||
}
|
||||
}, timelapse * ConfigManager.getJobsConfiguration().InfoUpdateInterval * 20L);
|
||||
}
|
||||
}
|
||||
package com.gamingmesh.jobs.Signs;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Skull;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.JobsPlugin;
|
||||
import com.gamingmesh.jobs.config.CommentedYamlConfiguration;
|
||||
import com.gamingmesh.jobs.config.ConfigManager;
|
||||
import com.gamingmesh.jobs.container.TopList;
|
||||
import com.gamingmesh.jobs.i18n.Language;
|
||||
|
||||
public class SignUtil {
|
||||
|
||||
public SignUtil() {
|
||||
}
|
||||
|
||||
public SignInfo Signs = new SignInfo();
|
||||
private JobsPlugin plugin;
|
||||
|
||||
public SignUtil(JobsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public SignInfo getSigns(){
|
||||
return Signs;
|
||||
}
|
||||
|
||||
// Sign file
|
||||
public void LoadSigns() {
|
||||
Thread threadd = new Thread() {
|
||||
public void run() {
|
||||
|
||||
Signs.GetAllSigns().clear();
|
||||
File file = new File(plugin.getDataFolder(), "Signs.yml");
|
||||
YamlConfiguration f = YamlConfiguration.loadConfiguration(file);
|
||||
|
||||
if (!f.isConfigurationSection("Signs"))
|
||||
return;
|
||||
|
||||
ConfigurationSection ConfCategory = f.getConfigurationSection("Signs");
|
||||
ArrayList<String> categoriesList = new ArrayList<String>(ConfCategory.getKeys(false));
|
||||
if (categoriesList.size() == 0)
|
||||
return;
|
||||
for (String category : categoriesList) {
|
||||
ConfigurationSection NameSection = ConfCategory.getConfigurationSection(category);
|
||||
com.gamingmesh.jobs.Signs.Sign newTemp = new com.gamingmesh.jobs.Signs.Sign();
|
||||
newTemp.setCategory(Integer.valueOf(category));
|
||||
newTemp.setWorld(NameSection.getString("World"));
|
||||
newTemp.setX(NameSection.getDouble("X"));
|
||||
newTemp.setY(NameSection.getDouble("Y"));
|
||||
newTemp.setZ(NameSection.getDouble("Z"));
|
||||
newTemp.setNumber(NameSection.getInt("Number"));
|
||||
newTemp.setJobName(NameSection.getString("JobName"));
|
||||
newTemp.setSpecial(NameSection.getBoolean("Special"));
|
||||
Signs.addSign(newTemp);
|
||||
}
|
||||
return;
|
||||
}
|
||||
};
|
||||
threadd.start();
|
||||
}
|
||||
|
||||
// Signs save file
|
||||
public void saveSigns() {
|
||||
|
||||
Thread threadd = new Thread() {
|
||||
public void run() {
|
||||
File f = new File(plugin.getDataFolder(), "Signs.yml");
|
||||
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
|
||||
|
||||
CommentedYamlConfiguration writer = new CommentedYamlConfiguration();
|
||||
conf.options().copyDefaults(true);
|
||||
|
||||
writer.addComment("Signs", "DO NOT EDIT THIS FILE BY HAND!");
|
||||
|
||||
if (!conf.isConfigurationSection("Signs"))
|
||||
conf.createSection("Signs");
|
||||
|
||||
for (com.gamingmesh.jobs.Signs.Sign one : Signs.GetAllSigns()) {
|
||||
String path = "Signs." + String.valueOf(one.GetCategory());
|
||||
writer.set(path + ".World", one.GetWorld());
|
||||
writer.set(path + ".X", one.GetX());
|
||||
writer.set(path + ".Y", one.GetY());
|
||||
writer.set(path + ".Z", one.GetZ());
|
||||
writer.set(path + ".Number", one.GetNumber());
|
||||
writer.set(path + ".JobName", one.GetJobName());
|
||||
writer.set(path + ".Special", one.isSpecial());
|
||||
}
|
||||
|
||||
try {
|
||||
writer.save(f);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
;
|
||||
}
|
||||
return;
|
||||
}
|
||||
};
|
||||
threadd.start();
|
||||
}
|
||||
|
||||
public boolean SignUpdate(String JobName) {
|
||||
List<com.gamingmesh.jobs.Signs.Sign> Copy = new ArrayList<com.gamingmesh.jobs.Signs.Sign>(Signs.GetAllSigns().size());
|
||||
for (com.gamingmesh.jobs.Signs.Sign foo : Signs.GetAllSigns()) {
|
||||
Copy.add(foo);
|
||||
}
|
||||
int timelapse = 1;
|
||||
for (com.gamingmesh.jobs.Signs.Sign one : Copy) {
|
||||
String SignJobName = one.GetJobName();
|
||||
if (JobName.equalsIgnoreCase(SignJobName)) {
|
||||
String SignsWorld = one.GetWorld();
|
||||
double SignsX = one.GetX();
|
||||
double SignsY = one.GetY();
|
||||
double SignsZ = one.GetZ();
|
||||
int number = one.GetNumber() - 1;
|
||||
|
||||
List<TopList> PlayerList = new ArrayList<TopList>();
|
||||
if (!JobName.equalsIgnoreCase("gtoplist")) {
|
||||
PlayerList = Jobs.getJobsDAO().toplist(SignJobName, number);
|
||||
} else {
|
||||
PlayerList = Jobs.getJobsDAO().getGlobalTopList(number);
|
||||
}
|
||||
if (PlayerList.size() != 0) {
|
||||
World world = Bukkit.getWorld(SignsWorld);
|
||||
if (world == null)
|
||||
continue;
|
||||
Location nloc = new Location(world, SignsX, SignsY, SignsZ);
|
||||
Block block = nloc.getBlock();
|
||||
if (!(block.getState() instanceof org.bukkit.block.Sign)) {
|
||||
Signs.GetAllSigns().remove(one);
|
||||
saveSigns();
|
||||
} else {
|
||||
org.bukkit.block.Sign sign = (org.bukkit.block.Sign) block.getState();
|
||||
if (!one.isSpecial()) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (i >= PlayerList.size()) {
|
||||
break;
|
||||
}
|
||||
String PlayerName = ((TopList) PlayerList.get(i)).getPlayerName();
|
||||
|
||||
if (PlayerName != null && PlayerName.length() > 8) {
|
||||
String PlayerNameStrip = PlayerName.split("(?<=\\G.{7})")[0];
|
||||
PlayerName = PlayerNameStrip + "~";
|
||||
}
|
||||
|
||||
if (PlayerName == null)
|
||||
PlayerName = "Unknown";
|
||||
|
||||
String line = Language.getMessage("signs.List");
|
||||
line = line.replace("[number]", String.valueOf(i + number + 1));
|
||||
line = line.replace("[player]", PlayerName);
|
||||
line = line.replace("[level]", String.valueOf(((TopList) PlayerList.get(i)).getLevel()));
|
||||
|
||||
sign.setLine(i, line);
|
||||
}
|
||||
sign.update();
|
||||
UpdateHead(sign.getLocation(), ((TopList) PlayerList.get(0)).getPlayerName(), timelapse);
|
||||
} else {
|
||||
String PlayerName = ((TopList) PlayerList.get(0)).getPlayerName();
|
||||
if (PlayerName.length() > 18) {
|
||||
String PlayerNameStrip = PlayerName.split("(?<=\\G.{13})")[0];
|
||||
PlayerName = PlayerNameStrip + "~";
|
||||
}
|
||||
String line1 = Language.getMessage("signs.SpecialList." + one.GetNumber() + ".1");
|
||||
line1 = line1.replace("[number]", String.valueOf(one.GetNumber() + number + 1));
|
||||
line1 = line1.replace("[player]", PlayerName);
|
||||
line1 = line1.replace("[level]", String.valueOf(((TopList) PlayerList.get(0)).getLevel()));
|
||||
|
||||
sign.setLine(0, line1);
|
||||
|
||||
line1 = Language.getMessage("signs.SpecialList." + one.GetNumber() + ".2");
|
||||
line1 = line1.replace("[number]", String.valueOf(one.GetNumber() + number + 1));
|
||||
line1 = line1.replace("[player]", PlayerName);
|
||||
line1 = line1.replace("[level]", String.valueOf(((TopList) PlayerList.get(0)).getLevel()));
|
||||
|
||||
sign.setLine(1, line1);
|
||||
|
||||
line1 = Language.getMessage("signs.SpecialList." + one.GetNumber() + ".3");
|
||||
line1 = line1.replace("[number]", String.valueOf(one.GetNumber() + number + 1));
|
||||
line1 = line1.replace("[player]", PlayerName);
|
||||
line1 = line1.replace("[level]", String.valueOf(((TopList) PlayerList.get(0)).getLevel()));
|
||||
|
||||
sign.setLine(2, line1);
|
||||
|
||||
line1 = Language.getMessage("signs.SpecialList." + one.GetNumber() + ".4");
|
||||
line1 = line1.replace("[number]", String.valueOf(one.GetNumber() + number + 1));
|
||||
line1 = line1.replace("[player]", PlayerName);
|
||||
line1 = line1.replace("[level]", String.valueOf(((TopList) PlayerList.get(0)).getLevel()));
|
||||
|
||||
sign.setLine(3, line1);
|
||||
sign.update();
|
||||
UpdateHead(sign.getLocation(), ((TopList) PlayerList.get(0)).getPlayerName(), timelapse);
|
||||
}
|
||||
|
||||
timelapse++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void UpdateHead(final Location loc, final String Playername, final int timelapse) {
|
||||
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
|
||||
loc.setY(loc.getY() + 1);
|
||||
|
||||
if (Playername == null)
|
||||
return;
|
||||
|
||||
Block block = loc.getBlock();
|
||||
|
||||
if (block == null)
|
||||
return;
|
||||
|
||||
if (!(block.getState() instanceof Skull))
|
||||
return;
|
||||
|
||||
Skull skull = (Skull) block.getState();
|
||||
|
||||
if (skull == null)
|
||||
return;
|
||||
|
||||
skull.setOwner(Playername);
|
||||
skull.update();
|
||||
return;
|
||||
}
|
||||
}, timelapse * ConfigManager.getJobsConfiguration().InfoUpdateInterval * 20L);
|
||||
}
|
||||
}
|
||||
|
@ -62,13 +62,17 @@ import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
import com.gamingmesh.jobs.stuff.GiveItem;
|
||||
import com.gamingmesh.jobs.stuff.OfflinePlayerList;
|
||||
import com.gamingmesh.jobs.stuff.Perm;
|
||||
import com.gamingmesh.jobs.stuff.Scboard;
|
||||
import com.gamingmesh.jobs.stuff.Sorting;
|
||||
import com.gamingmesh.jobs.stuff.TimeManage;
|
||||
import com.gamingmesh.jobs.stuff.TranslateName;
|
||||
|
||||
public class JobsCommands implements CommandExecutor {
|
||||
private static final String label = "jobs";
|
||||
private JobsPlugin plugin;
|
||||
|
||||
public JobsCommands(JobsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (args.length == 0)
|
||||
@ -1066,9 +1070,9 @@ public class JobsCommands implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
if (!args[0].equalsIgnoreCase("gtoplist"))
|
||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(oldjob.getName());
|
||||
Jobs.getSignUtil().SignUpdate(oldjob.getName());
|
||||
else
|
||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
||||
Jobs.getSignUtil().SignUpdate("gtoplist");
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1135,7 +1139,7 @@ public class JobsCommands implements CommandExecutor {
|
||||
}
|
||||
player.setScoreboard(board);
|
||||
|
||||
Scboard.addNew(player);
|
||||
Jobs.getScboard().addNew(player);
|
||||
|
||||
//player.sendMessage(ChatColor.GOLD + Language.getMessage("scoreboard.clear"));
|
||||
|
||||
@ -1224,7 +1228,7 @@ public class JobsCommands implements CommandExecutor {
|
||||
player.setScoreboard(board);
|
||||
//player.sendMessage(ChatColor.GOLD + Language.getMessage("scoreboard.clear"));
|
||||
|
||||
Scboard.addNew(player);
|
||||
Jobs.getScboard().addNew(player);
|
||||
|
||||
int from = start;
|
||||
if (start >= 15)
|
||||
@ -1485,7 +1489,7 @@ public class JobsCommands implements CommandExecutor {
|
||||
sendUsage(sender, "glog");
|
||||
return true;
|
||||
}
|
||||
Bukkit.getScheduler().runTaskAsynchronously(JobsPlugin.instance, new Runnable() {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Map<LogAmounts, Double> unsortMap = new HashMap<LogAmounts, Double>();
|
||||
|
@ -264,8 +264,8 @@ public class JobsConfiguration {
|
||||
loadRestrictedBlocks();
|
||||
// Item/Block/mobs name list
|
||||
loadItemList();
|
||||
// Item/Block/mobs name list
|
||||
com.gamingmesh.jobs.Signs.SignUtil.LoadSigns();
|
||||
// signs information
|
||||
Jobs.getSignUtil().LoadSigns();
|
||||
|
||||
// loadScheduler();
|
||||
}
|
||||
@ -1100,7 +1100,7 @@ public class JobsConfiguration {
|
||||
}
|
||||
|
||||
private synchronized void loadItemList() {
|
||||
YmlMaker ItemFile = new YmlMaker((JavaPlugin) JobsPlugin.instance, "ItemList.yml");
|
||||
YmlMaker ItemFile = new YmlMaker((JavaPlugin) plugin, "ItemList.yml");
|
||||
ItemFile.saveDefaultConfig();
|
||||
List<String> section = ItemFile.getConfig().getStringList("ItemList");
|
||||
ListOfNames.clear();
|
||||
@ -1208,7 +1208,7 @@ public class JobsConfiguration {
|
||||
languages.add("ru");
|
||||
|
||||
for (String lang : languages) {
|
||||
YmlMaker langFile = new YmlMaker((JavaPlugin) JobsPlugin.instance, "locale" + File.separator + "messages_" + lang + ".yml");
|
||||
YmlMaker langFile = new YmlMaker((JavaPlugin) plugin, "locale" + File.separator + "messages_" + lang + ".yml");
|
||||
if (langFile != null)
|
||||
langFile.saveDefaultConfig();
|
||||
}
|
||||
|
@ -60,6 +60,11 @@ public abstract class JobsDAO {
|
||||
|
||||
private JobsConnectionPool pool;
|
||||
private String prefix;
|
||||
private JobsPlugin plugin;
|
||||
|
||||
public JobsDAO(JobsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
protected JobsDAO(String driverName, String url, String username, String password, String prefix) {
|
||||
this.prefix = prefix;
|
||||
@ -492,7 +497,7 @@ public abstract class JobsDAO {
|
||||
}
|
||||
|
||||
public void fixUuid(final CommandSender sender) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(JobsPlugin.instance, new Runnable() {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
JobsConnection conn = getConnection();
|
||||
@ -539,7 +544,7 @@ public abstract class JobsDAO {
|
||||
}
|
||||
|
||||
public void fixName(final CommandSender sender) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(JobsPlugin.instance, new Runnable() {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
JobsConnection conn = getConnection();
|
||||
|
@ -28,57 +28,62 @@ import com.gamingmesh.jobs.config.ConfigManager;
|
||||
import com.gamingmesh.jobs.config.YmlMaker;
|
||||
|
||||
public class Language {
|
||||
public static FileConfiguration enlocale;
|
||||
public static FileConfiguration customlocale;
|
||||
public static FileConfiguration enlocale;
|
||||
public static FileConfiguration customlocale;
|
||||
private JobsPlugin plugin;
|
||||
|
||||
static {
|
||||
customlocale = new YmlMaker((JavaPlugin) JobsPlugin.instance, "locale/messages_" + ConfigManager.getJobsConfiguration().localeString + ".yml").getConfig();
|
||||
enlocale = new YmlMaker((JavaPlugin) JobsPlugin.instance, "locale/messages_en.yml").getConfig();
|
||||
if (customlocale == null)
|
||||
customlocale = enlocale;
|
||||
}
|
||||
public Language(JobsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
private Language() {
|
||||
}
|
||||
// static {
|
||||
// customlocale = new YmlMaker((JavaPlugin) plugin, "locale/messages_" + ConfigManager.getJobsConfiguration().localeString + ".yml").getConfig();
|
||||
// enlocale = new YmlMaker((JavaPlugin) JobsPlugin.instance, "locale/messages_en.yml").getConfig();
|
||||
// if (customlocale == null)
|
||||
// customlocale = enlocale;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Reloads the config
|
||||
*/
|
||||
public static void reload(Locale locale) {
|
||||
customlocale = new YmlMaker((JavaPlugin) JobsPlugin.instance, "locale/messages_" + ConfigManager.getJobsConfiguration().localeString + ".yml").getConfig();
|
||||
enlocale = new YmlMaker((JavaPlugin) JobsPlugin.instance, "locale/messages_en.yml").getConfig();
|
||||
if (customlocale == null)
|
||||
customlocale = enlocale;
|
||||
}
|
||||
public Language() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message with the correct key
|
||||
* @param key - the key of the message
|
||||
* @return the message
|
||||
*/
|
||||
/**
|
||||
* Reloads the config
|
||||
*/
|
||||
public void reload(Locale locale) {
|
||||
customlocale = new YmlMaker((JavaPlugin) plugin, "locale/messages_" + ConfigManager.getJobsConfiguration().localeString + ".yml").getConfig();
|
||||
enlocale = new YmlMaker((JavaPlugin) plugin, "locale/messages_en.yml").getConfig();
|
||||
if (customlocale == null)
|
||||
customlocale = enlocale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message with the correct key
|
||||
* @param key - the key of the message
|
||||
* @return the message
|
||||
*/
|
||||
public static String getMessage(String key) {
|
||||
if (customlocale == null || !customlocale.contains(key))
|
||||
return enlocale.contains(key) == true ? ChatColor.translateAlternateColorCodes('&', enlocale.getString(key)) : "Cant find locale";
|
||||
return customlocale.contains(key) == true ? ChatColor.translateAlternateColorCodes('&', customlocale.getString(key)) : "Cant find locale";
|
||||
}
|
||||
if (customlocale == null || !customlocale.contains(key))
|
||||
return enlocale.contains(key) == true ? ChatColor.translateAlternateColorCodes('&', enlocale.getString(key)) : "Cant find locale";
|
||||
return customlocale.contains(key) == true ? ChatColor.translateAlternateColorCodes('&', customlocale.getString(key)) : "Cant find locale";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message with the correct key
|
||||
* @param key - the key of the message
|
||||
* @return the message
|
||||
*/
|
||||
public static String getDefaultMessage(String key) {
|
||||
return enlocale.contains(key) == true ? ChatColor.translateAlternateColorCodes('&', enlocale.getString(key)) : "Cant find locale";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if key exists
|
||||
* @param key - the key of the message
|
||||
* @return true/false
|
||||
*/
|
||||
public static boolean containsKey(String key) {
|
||||
if (customlocale == null || !customlocale.contains(key))
|
||||
return enlocale.contains(key);
|
||||
return customlocale.contains(key);
|
||||
}
|
||||
/**
|
||||
* Get the message with the correct key
|
||||
* @param key - the key of the message
|
||||
* @return the message
|
||||
*/
|
||||
public static String getDefaultMessage(String key) {
|
||||
return enlocale.contains(key) == true ? ChatColor.translateAlternateColorCodes('&', enlocale.getString(key)) : "Cant find locale";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if key exists
|
||||
* @param key - the key of the message
|
||||
* @return true/false
|
||||
*/
|
||||
public static boolean containsKey(String key) {
|
||||
if (customlocale == null || !customlocale.contains(key))
|
||||
return enlocale.contains(key);
|
||||
return customlocale.contains(key);
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,6 @@ import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.JobsPlugin;
|
||||
import com.gamingmesh.jobs.Gui.GuiInfoList;
|
||||
import com.gamingmesh.jobs.Gui.GuiTools;
|
||||
import com.gamingmesh.jobs.Signs.SignUtil;
|
||||
import com.gamingmesh.jobs.config.ConfigManager;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
@ -229,7 +228,7 @@ public class JobsListener implements Listener {
|
||||
|
||||
Location loc = block.getLocation();
|
||||
|
||||
for (com.gamingmesh.jobs.Signs.Sign one : SignUtil.Signs.GetAllSigns()) {
|
||||
for (com.gamingmesh.jobs.Signs.Sign one : Jobs.getSignUtil().getSigns().GetAllSigns()) {
|
||||
|
||||
if (one.GetX() != loc.getBlockX())
|
||||
continue;
|
||||
@ -244,8 +243,8 @@ public class JobsListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
SignUtil.Signs.removeSign(one);
|
||||
SignUtil.saveSigns();
|
||||
Jobs.getSignUtil().getSigns().removeSign(one);
|
||||
Jobs.getSignUtil().saveSigns();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -310,8 +309,8 @@ public class JobsListener implements Listener {
|
||||
Location loc = sign.getLocation();
|
||||
|
||||
int category = 1;
|
||||
if (com.gamingmesh.jobs.Signs.SignUtil.Signs.GetAllSigns().size() > 0)
|
||||
category = com.gamingmesh.jobs.Signs.SignUtil.Signs.GetAllSigns().get(com.gamingmesh.jobs.Signs.SignUtil.Signs.GetAllSigns().size() - 1).GetCategory() + 1;
|
||||
if (Jobs.getSignUtil().getSigns().GetAllSigns().size() > 0)
|
||||
category = Jobs.getSignUtil().getSigns().GetAllSigns().get(Jobs.getSignUtil().getSigns().GetAllSigns().size() - 1).GetCategory() + 1;
|
||||
signInfo.setNumber(Number);
|
||||
signInfo.setWorld(loc.getWorld().getName());
|
||||
signInfo.setX(loc.getX());
|
||||
@ -324,16 +323,16 @@ public class JobsListener implements Listener {
|
||||
signInfo.setJobName("gtoplist");
|
||||
signInfo.setSpecial(special);
|
||||
|
||||
com.gamingmesh.jobs.Signs.SignUtil.Signs.addSign(signInfo);
|
||||
com.gamingmesh.jobs.Signs.SignUtil.saveSigns();
|
||||
Jobs.getSignUtil().getSigns().addSign(signInfo);
|
||||
Jobs.getSignUtil().saveSigns();
|
||||
event.setCancelled(true);
|
||||
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(JobsPlugin.instance, new Runnable() {
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
if (!signtype.equalsIgnoreCase("gtoplist"))
|
||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate(job.getName());
|
||||
Jobs.getSignUtil().SignUpdate(job.getName());
|
||||
else
|
||||
com.gamingmesh.jobs.Signs.SignUtil.SignUpdate("gtoplist");
|
||||
Jobs.getSignUtil().SignUpdate("gtoplist");
|
||||
return;
|
||||
}
|
||||
}, 1L);
|
||||
@ -466,7 +465,7 @@ public class JobsListener implements Listener {
|
||||
if (!ConfigManager.getJobsConfiguration().WaterBlockBreake)
|
||||
return;
|
||||
if (event.getBlock().getState().hasMetadata(JobsPaymentListener.PlacedBlockMetadata)) {
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(JobsPlugin.instance, new Runnable() {
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
event.getBlock().getState().removeMetadata(JobsPaymentListener.PlacedBlockMetadata, plugin);
|
||||
return;
|
||||
|
@ -931,6 +931,12 @@ public class JobsPaymentListener implements Listener {
|
||||
// Calulating multiplaier
|
||||
multiplier = multiplier * NearSpawnerMultiplier * PetPayMultiplier;
|
||||
|
||||
if (lVictim instanceof Player && !lVictim.hasMetadata("NPC")) {
|
||||
Player VPlayer = (Player) lVictim;
|
||||
if (jDamager.getUserName().equalsIgnoreCase(VPlayer.getName()))
|
||||
return;
|
||||
}
|
||||
|
||||
Jobs.action(jDamager, new EntityActionInfo(lVictim, ActionType.KILL), multiplier, item, armor);
|
||||
|
||||
// Payment for killing player with particular job, except NPC's
|
||||
|
@ -1,154 +1,157 @@
|
||||
package com.gamingmesh.jobs.stuff;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.config.ConfigManager;
|
||||
import com.gamingmesh.jobs.economy.BufferedPayment;
|
||||
import com.gamingmesh.jobs.i18n.Language;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hamzaxx
|
||||
*/
|
||||
public class ActionBar {
|
||||
private static int cleanVersion = 182;
|
||||
private static String version = "";
|
||||
private static Object packet;
|
||||
private static Method getHandle;
|
||||
private static Method sendPacket;
|
||||
private static Field playerConnection;
|
||||
private static Class<?> nmsChatSerializer;
|
||||
private static Class<?> nmsIChatBaseComponent;
|
||||
private static Class<?> packetType;
|
||||
|
||||
static {
|
||||
try {
|
||||
version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
|
||||
// Translating version to integer for simpler use
|
||||
try {
|
||||
cleanVersion = Integer.parseInt(version.replace("v", "").replace("V", "").replace("_", "").replace("r", "").replace("R", ""));
|
||||
} catch (NumberFormatException e) {
|
||||
// Fail save if it for some reason can't translate version to integer
|
||||
if (version.contains("v1_7"))
|
||||
cleanVersion = 170;
|
||||
if (version.contains("v1_6"))
|
||||
cleanVersion = 160;
|
||||
if (version.contains("v1_5"))
|
||||
cleanVersion = 150;
|
||||
if (version.contains("v1_4"))
|
||||
cleanVersion = 140;
|
||||
if (version.contains("v1_8_R1"))
|
||||
cleanVersion = 181;
|
||||
if (version.contains("v1_8_R2"))
|
||||
cleanVersion = 182;
|
||||
if (version.contains("v1_8_R3"))
|
||||
cleanVersion = 183;
|
||||
}
|
||||
|
||||
packetType = Class.forName(getPacketPlayOutChat());
|
||||
Class<?> typeCraftPlayer = Class.forName(getCraftPlayerClasspath());
|
||||
Class<?> typeNMSPlayer = Class.forName(getNMSPlayerClasspath());
|
||||
Class<?> typePlayerConnection = Class.forName(getPlayerConnectionClasspath());
|
||||
nmsChatSerializer = Class.forName(getChatSerializerClasspath());
|
||||
nmsIChatBaseComponent = Class.forName(getIChatBaseComponentClasspath());
|
||||
getHandle = typeCraftPlayer.getMethod("getHandle");
|
||||
playerConnection = typeNMSPlayer.getField("playerConnection");
|
||||
sendPacket = typePlayerConnection.getMethod("sendPacket", Class.forName(getPacketClasspath()));
|
||||
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | NoSuchFieldException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Error {0}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowActionBar(BufferedPayment payment) {
|
||||
String playername = payment.getOfflinePlayer().getName();
|
||||
if (!Jobs.actionbartoggle.containsKey(playername) && ConfigManager.getJobsConfiguration().JobsToggleEnabled)
|
||||
Jobs.actionbartoggle.put(playername, true);
|
||||
|
||||
if (playername != null && Jobs.actionbartoggle.size() > 0)
|
||||
if (Jobs.actionbartoggle.containsKey(playername)) {
|
||||
Boolean show = Jobs.actionbartoggle.get(playername);
|
||||
Player abp = (Player) payment.getOfflinePlayer();
|
||||
if (abp != null && show) {
|
||||
String Message = Language.getMessage("command.toggle.output.paid");
|
||||
Message = Message.replace("[amount]", String.valueOf((((int) (payment.getAmount() * 100)) / 100.0)));
|
||||
Message = Message.replace("[exp]", String.valueOf((((int) (payment.getExp() * 100)) / 100.0)));
|
||||
ActionBar.send(abp, ChatColor.GREEN + Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void send(Player receivingPacket, String msg) {
|
||||
try {
|
||||
if (msg == null || nmsChatSerializer == null)
|
||||
return;
|
||||
|
||||
if (cleanVersion < 180) {
|
||||
receivingPacket.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
|
||||
return;
|
||||
}
|
||||
|
||||
Object serialized = nmsChatSerializer.getMethod("a", String.class).invoke(null, "{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', msg) + "\"}");
|
||||
if (cleanVersion > 180) {
|
||||
packet = packetType.getConstructor(nmsIChatBaseComponent, byte.class).newInstance(serialized, (byte) 2);
|
||||
} else {
|
||||
packet = packetType.getConstructor(nmsIChatBaseComponent, int.class).newInstance(serialized, 2);
|
||||
}
|
||||
Object player = getHandle.invoke(receivingPacket);
|
||||
Object connection = playerConnection.get(player);
|
||||
sendPacket.invoke(connection, packet);
|
||||
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | InstantiationException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Error {0}", ex);
|
||||
}
|
||||
|
||||
try {
|
||||
Object player = getHandle.invoke(receivingPacket);
|
||||
Object connection = playerConnection.get(player);
|
||||
sendPacket.invoke(connection, packet);
|
||||
} catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Error {0}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getCraftPlayerClasspath() {
|
||||
return "org.bukkit.craftbukkit." + version + ".entity.CraftPlayer";
|
||||
}
|
||||
|
||||
private static String getPlayerConnectionClasspath() {
|
||||
return "net.minecraft.server." + version + ".PlayerConnection";
|
||||
}
|
||||
|
||||
private static String getNMSPlayerClasspath() {
|
||||
return "net.minecraft.server." + version + ".EntityPlayer";
|
||||
}
|
||||
|
||||
private static String getPacketClasspath() {
|
||||
return "net.minecraft.server." + version + ".Packet";
|
||||
}
|
||||
|
||||
private static String getIChatBaseComponentClasspath() {
|
||||
return "net.minecraft.server." + version + ".IChatBaseComponent";
|
||||
}
|
||||
|
||||
private static String getChatSerializerClasspath() {
|
||||
|
||||
if (cleanVersion < 182) {
|
||||
return "net.minecraft.server." + version + ".ChatSerializer";
|
||||
} else {
|
||||
return "net.minecraft.server." + version + ".IChatBaseComponent$ChatSerializer";// 1_8_R2 moved to IChatBaseComponent
|
||||
}
|
||||
}
|
||||
|
||||
private static String getPacketPlayOutChat() {
|
||||
return "net.minecraft.server." + version + ".PacketPlayOutChat";
|
||||
}
|
||||
package com.gamingmesh.jobs.stuff;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.config.ConfigManager;
|
||||
import com.gamingmesh.jobs.economy.BufferedPayment;
|
||||
import com.gamingmesh.jobs.i18n.Language;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hamzaxx
|
||||
*/
|
||||
public class ActionBar {
|
||||
private static int cleanVersion = 1820;
|
||||
private static String version = "";
|
||||
private static Object packet;
|
||||
private static Method getHandle;
|
||||
private static Method sendPacket;
|
||||
private static Field playerConnection;
|
||||
private static Class<?> nmsChatSerializer;
|
||||
private static Class<?> nmsIChatBaseComponent;
|
||||
private static Class<?> packetType;
|
||||
|
||||
static {
|
||||
try {
|
||||
version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
|
||||
// Translating version to integer for simpler use
|
||||
try {
|
||||
cleanVersion = Integer.parseInt(version.replace("v", "").replace("V", "").replace("_", "").replace("r", "").replace("R", ""));
|
||||
} catch (NumberFormatException e) {
|
||||
// Fail save if it for some reason can't translate version to integer
|
||||
if (version.contains("v1_7"))
|
||||
cleanVersion = 1700;
|
||||
if (version.contains("v1_6"))
|
||||
cleanVersion = 1600;
|
||||
if (version.contains("v1_5"))
|
||||
cleanVersion = 1500;
|
||||
if (version.contains("v1_4"))
|
||||
cleanVersion = 1400;
|
||||
if (version.contains("v1_8_R1"))
|
||||
cleanVersion = 1810;
|
||||
if (version.contains("v1_8_R2"))
|
||||
cleanVersion = 1820;
|
||||
if (version.contains("v1_8_R3"))
|
||||
cleanVersion = 1830;
|
||||
}
|
||||
|
||||
if (cleanVersion < 1000)
|
||||
cleanVersion = cleanVersion * 10;
|
||||
|
||||
packetType = Class.forName(getPacketPlayOutChat());
|
||||
Class<?> typeCraftPlayer = Class.forName(getCraftPlayerClasspath());
|
||||
Class<?> typeNMSPlayer = Class.forName(getNMSPlayerClasspath());
|
||||
Class<?> typePlayerConnection = Class.forName(getPlayerConnectionClasspath());
|
||||
nmsChatSerializer = Class.forName(getChatSerializerClasspath());
|
||||
nmsIChatBaseComponent = Class.forName(getIChatBaseComponentClasspath());
|
||||
getHandle = typeCraftPlayer.getMethod("getHandle");
|
||||
playerConnection = typeNMSPlayer.getField("playerConnection");
|
||||
sendPacket = typePlayerConnection.getMethod("sendPacket", Class.forName(getPacketClasspath()));
|
||||
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | NoSuchFieldException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Error {0}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowActionBar(BufferedPayment payment) {
|
||||
String playername = payment.getOfflinePlayer().getName();
|
||||
if (!Jobs.actionbartoggle.containsKey(playername) && ConfigManager.getJobsConfiguration().JobsToggleEnabled)
|
||||
Jobs.actionbartoggle.put(playername, true);
|
||||
|
||||
if (playername != null && Jobs.actionbartoggle.size() > 0)
|
||||
if (Jobs.actionbartoggle.containsKey(playername)) {
|
||||
Boolean show = Jobs.actionbartoggle.get(playername);
|
||||
Player abp = (Player) payment.getOfflinePlayer();
|
||||
if (abp != null && show) {
|
||||
String Message = Language.getMessage("command.toggle.output.paid");
|
||||
Message = Message.replace("[amount]", String.format("%.2f", payment.getAmount()));
|
||||
Message = Message.replace("[exp]", String.format("%.2f", payment.getExp()));
|
||||
ActionBar.send(abp, ChatColor.GREEN + Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void send(Player receivingPacket, String msg) {
|
||||
try {
|
||||
if (msg == null || nmsChatSerializer == null)
|
||||
return;
|
||||
|
||||
if (cleanVersion < 1800) {
|
||||
receivingPacket.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
|
||||
return;
|
||||
}
|
||||
|
||||
Object serialized = nmsChatSerializer.getMethod("a", String.class).invoke(null, "{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', msg) + "\"}");
|
||||
if (cleanVersion > 1800) {
|
||||
packet = packetType.getConstructor(nmsIChatBaseComponent, byte.class).newInstance(serialized, (byte) 2);
|
||||
} else {
|
||||
packet = packetType.getConstructor(nmsIChatBaseComponent, int.class).newInstance(serialized, 2);
|
||||
}
|
||||
Object player = getHandle.invoke(receivingPacket);
|
||||
Object connection = playerConnection.get(player);
|
||||
sendPacket.invoke(connection, packet);
|
||||
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | InstantiationException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Error {0}", ex);
|
||||
}
|
||||
|
||||
try {
|
||||
Object player = getHandle.invoke(receivingPacket);
|
||||
Object connection = playerConnection.get(player);
|
||||
sendPacket.invoke(connection, packet);
|
||||
} catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Error {0}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getCraftPlayerClasspath() {
|
||||
return "org.bukkit.craftbukkit." + version + ".entity.CraftPlayer";
|
||||
}
|
||||
|
||||
private static String getPlayerConnectionClasspath() {
|
||||
return "net.minecraft.server." + version + ".PlayerConnection";
|
||||
}
|
||||
|
||||
private static String getNMSPlayerClasspath() {
|
||||
return "net.minecraft.server." + version + ".EntityPlayer";
|
||||
}
|
||||
|
||||
private static String getPacketClasspath() {
|
||||
return "net.minecraft.server." + version + ".Packet";
|
||||
}
|
||||
|
||||
private static String getIChatBaseComponentClasspath() {
|
||||
return "net.minecraft.server." + version + ".IChatBaseComponent";
|
||||
}
|
||||
|
||||
private static String getChatSerializerClasspath() {
|
||||
|
||||
if (cleanVersion < 1820) {
|
||||
return "net.minecraft.server." + version + ".ChatSerializer";
|
||||
} else {
|
||||
return "net.minecraft.server." + version + ".IChatBaseComponent$ChatSerializer";// 1_8_R2 moved to IChatBaseComponent
|
||||
}
|
||||
}
|
||||
|
||||
private static String getPacketPlayOutChat() {
|
||||
return "net.minecraft.server." + version + ".PacketPlayOutChat";
|
||||
}
|
||||
}
|
@ -1,18 +1,15 @@
|
||||
package com.gamingmesh.jobs.stuff;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Debug {
|
||||
public static void D(String message) {
|
||||
|
||||
Player player = Bukkit.getPlayer("Zrips");
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
player.sendMessage(ChatColor.DARK_GRAY + "[Debug] " + ChatColor.DARK_AQUA + ChatColor.translateAlternateColorCodes('&', message));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
package com.gamingmesh.jobs.stuff;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Debug {
|
||||
public static void D(String message) {
|
||||
Player player = Bukkit.getPlayer("Zrips");
|
||||
if (player == null)
|
||||
return;
|
||||
player.sendMessage(ChatColor.DARK_GRAY + "[Debug] " + ChatColor.DARK_AQUA + ChatColor.translateAlternateColorCodes('&', message));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1,56 +1,56 @@
|
||||
package com.gamingmesh.jobs.stuff;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.container.ActionInfo;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.container.Log;
|
||||
|
||||
public class Loging {
|
||||
|
||||
public static void recordToLog(JobsPlayer jPlayer, ActionInfo info, double amount, double expAmount) {
|
||||
recordToLog(jPlayer, info.getType().getName(), info.getNameWithSub(), amount, expAmount);
|
||||
}
|
||||
|
||||
public static void recordToLog(JobsPlayer jPlayer, String ActionName, String item, double amount, double expAmount) {
|
||||
List<Log> logList = jPlayer.getLog();
|
||||
boolean found = false;
|
||||
|
||||
if (jPlayer.getLog().size() > 0 && ScheduleUtil.dateByInt != jPlayer.getLog().get(0).getDate()) {
|
||||
ScheduleUtil.dateByInt = TimeManage.timeInInt();
|
||||
if (ScheduleUtil.dateByInt != jPlayer.getLog().get(0).getDate()) {
|
||||
Jobs.getJobsDAO().saveLog(jPlayer);
|
||||
jPlayer.getLog().clear();
|
||||
}
|
||||
}
|
||||
|
||||
for (Log one : logList) {
|
||||
if (!one.getActionType().equalsIgnoreCase(ActionName))
|
||||
continue;
|
||||
one.add(item, amount, expAmount);
|
||||
found = true;
|
||||
}
|
||||
if (!found) {
|
||||
Log log = new Log(ActionName);
|
||||
log.add(item, amount, expAmount);
|
||||
logList.add(log);
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadToLog(JobsPlayer jPlayer, String ActionName, String item, int count, double money, double expAmount) {
|
||||
List<Log> logList = jPlayer.getLog();
|
||||
boolean found = false;
|
||||
for (Log one : logList) {
|
||||
if (!one.getActionType().equalsIgnoreCase(ActionName))
|
||||
continue;
|
||||
one.add(item, count, money, expAmount);
|
||||
found = true;
|
||||
}
|
||||
if (!found) {
|
||||
Log log = new Log(ActionName);
|
||||
log.add(item, count, money, expAmount);
|
||||
logList.add(log);
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gamingmesh.jobs.stuff;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.container.ActionInfo;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.container.Log;
|
||||
|
||||
public class Loging {
|
||||
|
||||
public static void recordToLog(JobsPlayer jPlayer, ActionInfo info, double amount, double expAmount) {
|
||||
recordToLog(jPlayer, info.getType().getName(), info.getNameWithSub(), amount, expAmount);
|
||||
}
|
||||
|
||||
public static void recordToLog(JobsPlayer jPlayer, String ActionName, String item, double amount, double expAmount) {
|
||||
List<Log> logList = jPlayer.getLog();
|
||||
boolean found = false;
|
||||
|
||||
if (jPlayer.getLog().size() > 0 && Jobs.getSchedule().getDateByInt() != jPlayer.getLog().get(0).getDate()) {
|
||||
Jobs.getSchedule().setDateByInt(TimeManage.timeInInt());
|
||||
if (Jobs.getSchedule().getDateByInt() != jPlayer.getLog().get(0).getDate()) {
|
||||
Jobs.getJobsDAO().saveLog(jPlayer);
|
||||
jPlayer.getLog().clear();
|
||||
}
|
||||
}
|
||||
|
||||
for (Log one : logList) {
|
||||
if (!one.getActionType().equalsIgnoreCase(ActionName))
|
||||
continue;
|
||||
one.add(item, amount, expAmount);
|
||||
found = true;
|
||||
}
|
||||
if (!found) {
|
||||
Log log = new Log(ActionName);
|
||||
log.add(item, amount, expAmount);
|
||||
logList.add(log);
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadToLog(JobsPlayer jPlayer, String ActionName, String item, int count, double money, double expAmount) {
|
||||
List<Log> logList = jPlayer.getLog();
|
||||
boolean found = false;
|
||||
for (Log one : logList) {
|
||||
if (!one.getActionType().equalsIgnoreCase(ActionName))
|
||||
continue;
|
||||
one.add(item, count, money, expAmount);
|
||||
found = true;
|
||||
}
|
||||
if (!found) {
|
||||
Log log = new Log(ActionName);
|
||||
log.add(item, count, money, expAmount);
|
||||
logList.add(log);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,10 +13,17 @@ import com.gamingmesh.jobs.config.ConfigManager;
|
||||
|
||||
public class Scboard {
|
||||
|
||||
private static ConcurrentHashMap<String, Long> timerMap = new ConcurrentHashMap<String, Long>();
|
||||
private ConcurrentHashMap<String, Long> timerMap = new ConcurrentHashMap<String, Long>();
|
||||
private JobsPlugin plugin;
|
||||
|
||||
private static void RunScheduler() {
|
||||
public Scboard() {
|
||||
}
|
||||
|
||||
public Scboard(JobsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
private void RunScheduler() {
|
||||
Iterator<Entry<String, Long>> MeinMapIter = timerMap.entrySet().iterator();
|
||||
while (MeinMapIter.hasNext()) {
|
||||
Entry<String, Long> Map = MeinMapIter.next();
|
||||
@ -31,7 +38,7 @@ public class Scboard {
|
||||
}
|
||||
|
||||
if (timerMap.size() > 0)
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(JobsPlugin.instance, new Runnable() {
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
RunScheduler();
|
||||
return;
|
||||
@ -40,7 +47,7 @@ public class Scboard {
|
||||
return;
|
||||
}
|
||||
|
||||
public static void addNew(Player player) {
|
||||
public void addNew(Player player) {
|
||||
timerMap.put(player.getName(), System.currentTimeMillis());
|
||||
RunScheduler();
|
||||
}
|
||||
|
@ -1,133 +1,149 @@
|
||||
package com.gamingmesh.jobs.stuff;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.gamingmesh.jobs.JobsPlugin;
|
||||
import com.gamingmesh.jobs.config.ConfigManager;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.Schedule;
|
||||
import com.gamingmesh.jobs.i18n.Language;
|
||||
|
||||
public class ScheduleUtil {
|
||||
|
||||
public static int dateByInt = 0;
|
||||
|
||||
public static void DateUpdater() {
|
||||
if (dateByInt == 0)
|
||||
dateByInt = TimeManage.timeInInt();
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(JobsPlugin.instance, new Runnable() {
|
||||
public void run() {
|
||||
|
||||
dateByInt = TimeManage.timeInInt();
|
||||
|
||||
DateUpdater();
|
||||
return;
|
||||
}
|
||||
}, 60 * 20L);
|
||||
}
|
||||
|
||||
public static boolean scheduler() {
|
||||
if (ConfigManager.getJobsConfiguration().BoostSchedule.size() > 0 && ConfigManager.getJobsConfiguration().useGlobalBoostScheduler) {
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
|
||||
Date date = new Date();
|
||||
|
||||
String currenttime = dateFormat.format(date);
|
||||
|
||||
int Current = Integer.valueOf(currenttime.replace(":", "")).intValue();
|
||||
|
||||
String CurrentDayName = GetWeekDay();
|
||||
|
||||
for (Schedule one : ConfigManager.getJobsConfiguration().BoostSchedule) {
|
||||
|
||||
int From = one.GetFrom();
|
||||
int Until = one.GetUntil();
|
||||
|
||||
List<String> days = one.GetDays();
|
||||
|
||||
if (one.isStarted() && one.getBroadcastInfoOn() < System.currentTimeMillis() && one.GetBroadcastInterval() > 0) {
|
||||
one.setBroadcastInfoOn(System.currentTimeMillis() + one.GetBroadcastInterval() * 60 * 1000);
|
||||
for (String oneMsg : one.GetMessageToBroadcast()) {
|
||||
Bukkit.broadcastMessage(oneMsg);
|
||||
}
|
||||
}
|
||||
|
||||
if (((one.isNextDay() && (Current >= From && Current < one.GetUntil() || Current >= one.GetNextFrom() && Current < one.GetNextUntil()) && !one
|
||||
.isStarted()) || !one.isNextDay() && (Current >= From && Current < Until)) && (days.contains(CurrentDayName) || days.contains("all")) && !one
|
||||
.isStarted()) {
|
||||
|
||||
if (one.isBroadcastOnStart())
|
||||
if (one.GetMessageOnStart().size() == 0)
|
||||
Bukkit.broadcastMessage(Language.getMessage("message.boostStarted"));
|
||||
else
|
||||
for (String oneMsg : one.GetMessageOnStart()) {
|
||||
Bukkit.broadcastMessage(oneMsg);
|
||||
}
|
||||
|
||||
for (Job onejob : one.GetJobs()) {
|
||||
onejob.setExpBoost(one.GetExpBoost());
|
||||
onejob.setMoneyBoost(one.GetMoneyBoost());
|
||||
}
|
||||
|
||||
one.setBroadcastInfoOn(System.currentTimeMillis() + one.GetBroadcastInterval() * 60 * 1000);
|
||||
|
||||
one.setStarted(true);
|
||||
one.setStoped(false);
|
||||
break;
|
||||
} else if (((one.isNextDay() && Current > one.GetNextUntil() && Current < one.GetFrom() && !one.isStoped()) || !one.isNextDay() && Current > Until
|
||||
&& ((days.contains(CurrentDayName)) || days.contains("all"))) && !one.isStoped()) {
|
||||
if (one.isBroadcastOnStop())
|
||||
if (one.GetMessageOnStop().size() == 0)
|
||||
Bukkit.broadcastMessage(Language.getMessage("message.boostStoped"));
|
||||
else
|
||||
for (String oneMsg : one.GetMessageOnStop()) {
|
||||
Bukkit.broadcastMessage(oneMsg);
|
||||
}
|
||||
for (Job onejob : one.GetJobs()) {
|
||||
onejob.setExpBoost(1.0);
|
||||
onejob.setMoneyBoost(1.0);
|
||||
}
|
||||
one.setStoped(true);
|
||||
one.setStarted(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(JobsPlugin.instance, new Runnable() {
|
||||
public void run() {
|
||||
scheduler();
|
||||
return;
|
||||
}
|
||||
}, 30 * 20L);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String GetWeekDay() {
|
||||
Calendar c = Calendar.getInstance();
|
||||
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
|
||||
switch (dayOfWeek) {
|
||||
case 2:
|
||||
return "monday";
|
||||
case 3:
|
||||
return "tuesday";
|
||||
case 4:
|
||||
return "wednesday";
|
||||
case 5:
|
||||
return "thursday";
|
||||
case 6:
|
||||
return "friday";
|
||||
case 7:
|
||||
return "saturday";
|
||||
case 1:
|
||||
return "sunday";
|
||||
}
|
||||
return "all";
|
||||
}
|
||||
}
|
||||
package com.gamingmesh.jobs.stuff;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.gamingmesh.jobs.JobsPlugin;
|
||||
import com.gamingmesh.jobs.config.ConfigManager;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.Schedule;
|
||||
import com.gamingmesh.jobs.i18n.Language;
|
||||
|
||||
public class ScheduleUtil {
|
||||
|
||||
public int dateByInt = 0;
|
||||
|
||||
private JobsPlugin plugin;
|
||||
|
||||
public ScheduleUtil() {
|
||||
}
|
||||
|
||||
public ScheduleUtil(JobsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public int getDateByInt(){
|
||||
return dateByInt;
|
||||
}
|
||||
public void setDateByInt(int time){
|
||||
dateByInt = time;
|
||||
}
|
||||
|
||||
public void DateUpdater() {
|
||||
if (dateByInt == 0)
|
||||
dateByInt = TimeManage.timeInInt();
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
|
||||
dateByInt = TimeManage.timeInInt();
|
||||
|
||||
DateUpdater();
|
||||
return;
|
||||
}
|
||||
}, 60 * 20L);
|
||||
}
|
||||
|
||||
public boolean scheduler() {
|
||||
if (ConfigManager.getJobsConfiguration().BoostSchedule.size() > 0 && ConfigManager.getJobsConfiguration().useGlobalBoostScheduler) {
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
|
||||
Date date = new Date();
|
||||
|
||||
String currenttime = dateFormat.format(date);
|
||||
|
||||
int Current = Integer.valueOf(currenttime.replace(":", "")).intValue();
|
||||
|
||||
String CurrentDayName = GetWeekDay();
|
||||
|
||||
for (Schedule one : ConfigManager.getJobsConfiguration().BoostSchedule) {
|
||||
|
||||
int From = one.GetFrom();
|
||||
int Until = one.GetUntil();
|
||||
|
||||
List<String> days = one.GetDays();
|
||||
|
||||
if (one.isStarted() && one.getBroadcastInfoOn() < System.currentTimeMillis() && one.GetBroadcastInterval() > 0) {
|
||||
one.setBroadcastInfoOn(System.currentTimeMillis() + one.GetBroadcastInterval() * 60 * 1000);
|
||||
for (String oneMsg : one.GetMessageToBroadcast()) {
|
||||
Bukkit.broadcastMessage(oneMsg);
|
||||
}
|
||||
}
|
||||
|
||||
if (((one.isNextDay() && (Current >= From && Current < one.GetUntil() || Current >= one.GetNextFrom() && Current < one.GetNextUntil()) && !one
|
||||
.isStarted()) || !one.isNextDay() && (Current >= From && Current < Until)) && (days.contains(CurrentDayName) || days.contains("all")) && !one
|
||||
.isStarted()) {
|
||||
|
||||
if (one.isBroadcastOnStart())
|
||||
if (one.GetMessageOnStart().size() == 0)
|
||||
Bukkit.broadcastMessage(Language.getMessage("message.boostStarted"));
|
||||
else
|
||||
for (String oneMsg : one.GetMessageOnStart()) {
|
||||
Bukkit.broadcastMessage(oneMsg);
|
||||
}
|
||||
|
||||
for (Job onejob : one.GetJobs()) {
|
||||
onejob.setExpBoost(one.GetExpBoost());
|
||||
onejob.setMoneyBoost(one.GetMoneyBoost());
|
||||
}
|
||||
|
||||
one.setBroadcastInfoOn(System.currentTimeMillis() + one.GetBroadcastInterval() * 60 * 1000);
|
||||
|
||||
one.setStarted(true);
|
||||
one.setStoped(false);
|
||||
break;
|
||||
} else if (((one.isNextDay() && Current > one.GetNextUntil() && Current < one.GetFrom() && !one.isStoped()) || !one.isNextDay() && Current > Until
|
||||
&& ((days.contains(CurrentDayName)) || days.contains("all"))) && !one.isStoped()) {
|
||||
if (one.isBroadcastOnStop())
|
||||
if (one.GetMessageOnStop().size() == 0)
|
||||
Bukkit.broadcastMessage(Language.getMessage("message.boostStoped"));
|
||||
else
|
||||
for (String oneMsg : one.GetMessageOnStop()) {
|
||||
Bukkit.broadcastMessage(oneMsg);
|
||||
}
|
||||
for (Job onejob : one.GetJobs()) {
|
||||
onejob.setExpBoost(1.0);
|
||||
onejob.setMoneyBoost(1.0);
|
||||
}
|
||||
one.setStoped(true);
|
||||
one.setStarted(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
scheduler();
|
||||
return;
|
||||
}
|
||||
}, 30 * 20L);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String GetWeekDay() {
|
||||
Calendar c = Calendar.getInstance();
|
||||
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
|
||||
switch (dayOfWeek) {
|
||||
case 2:
|
||||
return "monday";
|
||||
case 3:
|
||||
return "tuesday";
|
||||
case 4:
|
||||
return "wednesday";
|
||||
case 5:
|
||||
return "thursday";
|
||||
case 6:
|
||||
return "friday";
|
||||
case 7:
|
||||
return "saturday";
|
||||
case 1:
|
||||
return "sunday";
|
||||
}
|
||||
return "all";
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
name: Jobs
|
||||
description: Jobs Plugin for the BukkitAPI
|
||||
main: com.gamingmesh.jobs.JobsPlugin
|
||||
version: 2.55.1
|
||||
version: 2.56.0
|
||||
author: phrstbrn
|
||||
softdepend: [Vault, CoreProtect, MythicMobs, McMMO]
|
||||
commands:
|
||||
|
Loading…
Reference in New Issue
Block a user