mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-01 23:13:48 +01:00
Fix further issue when an event is not existent in 1.8 servers
This commit is contained in:
parent
add9bbf34f
commit
149a71e5da
@ -708,6 +708,10 @@ public class Jobs extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// register the listeners
|
// register the listeners
|
||||||
|
if (Version.isCurrentEqualOrHigher(Version.v1_9_R1)) {
|
||||||
|
getServer().getPluginManager().registerEvents(new com.gamingmesh.jobs.listeners.Listener1_9(), instance);
|
||||||
|
}
|
||||||
|
|
||||||
getServer().getPluginManager().registerEvents(new JobsListener(this), this);
|
getServer().getPluginManager().registerEvents(new JobsListener(this), this);
|
||||||
getServer().getPluginManager().registerEvents(new JobsPaymentListener(this), this);
|
getServer().getPluginManager().registerEvents(new JobsPaymentListener(this), this);
|
||||||
if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) {
|
if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) {
|
||||||
@ -764,6 +768,10 @@ public class Jobs extends JavaPlugin {
|
|||||||
|
|
||||||
com.gamingmesh.jobs.CMIGUI.GUIManager.registerListener();
|
com.gamingmesh.jobs.CMIGUI.GUIManager.registerListener();
|
||||||
|
|
||||||
|
if (Version.isCurrentEqualOrHigher(Version.v1_9_R1)) {
|
||||||
|
pm.registerEvents(new com.gamingmesh.jobs.listeners.Listener1_9(), instance);
|
||||||
|
}
|
||||||
|
|
||||||
pm.registerEvents(new JobsListener(instance), instance);
|
pm.registerEvents(new JobsListener(instance), instance);
|
||||||
pm.registerEvents(new JobsPaymentListener(instance), instance);
|
pm.registerEvents(new JobsPaymentListener(instance), instance);
|
||||||
if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) {
|
if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) {
|
||||||
|
@ -245,14 +245,11 @@ public class PlayerManager {
|
|||||||
jPlayer = Jobs.getJobsDAO().loadFromDao(player);
|
jPlayer = Jobs.getJobsDAO().loadFromDao(player);
|
||||||
|
|
||||||
if (Jobs.getGCManager().MultiServerCompatability()) {
|
if (Jobs.getGCManager().MultiServerCompatability()) {
|
||||||
ArchivedJobs archivedJobs = Jobs.getJobsDAO().getArchivedJobs(jPlayer);
|
jPlayer.setArchivedJobs(Jobs.getJobsDAO().getArchivedJobs(jPlayer));
|
||||||
if (archivedJobs != null) {
|
|
||||||
jPlayer.setArchivedJobs(archivedJobs);
|
|
||||||
}
|
|
||||||
|
|
||||||
jPlayer.setPaymentLimit(Jobs.getJobsDAO().getPlayersLimits(jPlayer));
|
jPlayer.setPaymentLimit(Jobs.getJobsDAO().getPlayersLimits(jPlayer));
|
||||||
jPlayer.setPoints(Jobs.getJobsDAO().getPlayerPoints(jPlayer));
|
jPlayer.setPoints(Jobs.getJobsDAO().getPlayerPoints(jPlayer));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lets load quest progression
|
// Lets load quest progression
|
||||||
PlayerInfo info = Jobs.getJobsDAO().loadPlayerData(player.getUniqueId());
|
PlayerInfo info = Jobs.getJobsDAO().loadPlayerData(player.getUniqueId());
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
|
@ -30,21 +30,30 @@ public class join implements Cmd {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player pSender = (Player) sender;
|
|
||||||
Job job = Jobs.getJob(args[0]);
|
Job job = Jobs.getJob(args[0]);
|
||||||
if (job == null) {
|
if (job == null) {
|
||||||
// job does not exist
|
// job does not exist
|
||||||
pSender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Jobs.getCommandManager().hasJobPermission(pSender, job)) {
|
if (!Jobs.getCommandManager().hasJobPermission(sender, job)) {
|
||||||
// you do not have permission to join the job
|
// The player do not have permission to join the job
|
||||||
pSender.sendMessage(Jobs.getLanguage().getMessage("general.error.permission"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.permission"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Player pSender = (Player) sender;
|
||||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
|
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
|
||||||
|
if (jPlayer == null) { // Load player into cache
|
||||||
|
Jobs.getPlayerManager().playerJoin(pSender);
|
||||||
|
jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jPlayer == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (jPlayer.isInJob(job)) {
|
if (jPlayer.isInJob(job)) {
|
||||||
// already in job message
|
// already in job message
|
||||||
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.alreadyin", "%jobname%", job.getNameWithColor()));
|
pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.alreadyin", "%jobname%", job.getNameWithColor()));
|
||||||
|
@ -785,7 +785,7 @@ public abstract class JobsDAO {
|
|||||||
while (res.next()) {
|
while (res.next()) {
|
||||||
|
|
||||||
String jobName = res.getString(ArchiveTableFields.job.getCollumn());
|
String jobName = res.getString(ArchiveTableFields.job.getCollumn());
|
||||||
Double exp = res.getDouble(ArchiveTableFields.experience.getCollumn());
|
double exp = res.getDouble(ArchiveTableFields.experience.getCollumn());
|
||||||
int lvl = res.getInt(ArchiveTableFields.level.getCollumn());
|
int lvl = res.getInt(ArchiveTableFields.level.getCollumn());
|
||||||
Long left = res.getLong(ArchiveTableFields.left.getCollumn());
|
Long left = res.getLong(ArchiveTableFields.left.getCollumn());
|
||||||
int jobid = res.getInt(ArchiveTableFields.jobid.getCollumn());
|
int jobid = res.getInt(ArchiveTableFields.jobid.getCollumn());
|
||||||
@ -1820,14 +1820,8 @@ public abstract class JobsDAO {
|
|||||||
|
|
||||||
// add the job
|
// add the job
|
||||||
Job job = Jobs.getJob(jobdata.getJobName());
|
Job job = Jobs.getJob(jobdata.getJobName());
|
||||||
if (job == null)
|
if (job != null)
|
||||||
continue;
|
jPlayer.progression.add(new JobProgression(job, jPlayer, jobdata.getLevel(), jobdata.getExperience()));
|
||||||
|
|
||||||
// create the progression object
|
|
||||||
JobProgression jobProgression = new JobProgression(job, jPlayer, jobdata.getLevel(), jobdata.getExperience());
|
|
||||||
// calculate the max level
|
|
||||||
// add the progression level.
|
|
||||||
jPlayer.progression.add(jobProgression);
|
|
||||||
}
|
}
|
||||||
jPlayer.reloadMaxExperience();
|
jPlayer.reloadMaxExperience();
|
||||||
jPlayer.reloadLimits();
|
jPlayer.reloadLimits();
|
||||||
|
@ -56,7 +56,6 @@ import org.bukkit.event.player.PlayerItemHeldEvent;
|
|||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
|
||||||
import org.bukkit.event.world.StructureGrowEvent;
|
import org.bukkit.event.world.StructureGrowEvent;
|
||||||
import org.bukkit.event.world.WorldLoadEvent;
|
import org.bukkit.event.world.WorldLoadEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -627,27 +626,22 @@ public class JobsListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void JobsArmorChangeEvent(JobsArmorChangeEvent event) {
|
public void jobsArmorChangeEvent(JobsArmorChangeEvent event) {
|
||||||
Jobs.getPlayerManager().resetItemBonusCache(event.getPlayer().getUniqueId());
|
Jobs.getPlayerManager().resetItemBonusCache(event.getPlayer().getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void PlayerItemHeldEvent(PlayerItemHeldEvent event) {
|
public void playerItemHeldEvent(PlayerItemHeldEvent event) {
|
||||||
Jobs.getPlayerManager().resetItemBonusCache(event.getPlayer().getUniqueId());
|
Jobs.getPlayerManager().resetItemBonusCache(event.getPlayer().getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void PlayerItemBreakEvent(PlayerItemBreakEvent event) {
|
public void playerItemBreakEvent(PlayerItemBreakEvent event) {
|
||||||
Jobs.getPlayerManager().resetItemBonusCache(event.getPlayer().getUniqueId());
|
Jobs.getPlayerManager().resetItemBonusCache(event.getPlayer().getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void PlayerItemBreakEvent(InventoryClickEvent event) {
|
public void playerItemBreakEvent(InventoryClickEvent event) {
|
||||||
Jobs.getPlayerManager().resetItemBonusCache(((Player) event.getWhoClicked()).getUniqueId());
|
Jobs.getPlayerManager().resetItemBonusCache(((Player) event.getWhoClicked()).getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerHandSwap(PlayerSwapHandItemsEvent event) {
|
|
||||||
Jobs.getPlayerManager().resetItemBonusCache(event.getPlayer().getUniqueId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
15
src/main/java/com/gamingmesh/jobs/listeners/Listener1_9.java
Normal file
15
src/main/java/com/gamingmesh/jobs/listeners/Listener1_9.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package com.gamingmesh.jobs.listeners;
|
||||||
|
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||||
|
|
||||||
|
import com.gamingmesh.jobs.Jobs;
|
||||||
|
|
||||||
|
public class Listener1_9 implements Listener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerHandSwap(PlayerSwapHandItemsEvent event) {
|
||||||
|
Jobs.getPlayerManager().resetItemBonusCache(event.getPlayer().getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user