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

Extend job comparison by name

This commit is contained in:
montlikadani 2021-05-23 16:28:33 +02:00
parent 5f5e1f7113
commit 417738f2e3
3 changed files with 9 additions and 5 deletions

View File

@ -1399,7 +1399,9 @@ public class Jobs extends JavaPlugin {
}
public static void perform(JobsPlayer jPlayer, ActionInfo info, BufferedPayment payment, Job job) {
JobsExpGainEvent jobsExpGainEvent = new JobsExpGainEvent(payment.getOfflinePlayer(), job, payment.get(CurrencyType.EXP));
double expPayment = payment.get(CurrencyType.EXP);
JobsExpGainEvent jobsExpGainEvent = new JobsExpGainEvent(payment.getOfflinePlayer(), job, expPayment);
Bukkit.getServer().getPluginManager().callEvent(jobsExpGainEvent);
// If event is canceled, don't do anything
if (jobsExpGainEvent.isCancelled())
@ -1425,7 +1427,7 @@ public class Jobs extends JavaPlugin {
getLoging().recordToLog(jPlayer, info, payment.getPayment());
}
if (prog.addExperience(payment.get(CurrencyType.EXP)))
if (prog.addExperience(expPayment))
getPlayerManager().performLevelUp(jPlayer, prog.getJob(), oldLevel);
}

View File

@ -199,7 +199,8 @@ public class Job {
* @return true if same
*/
public boolean isSame(Job job) {
return job != null && (id == job.getId() || fullName.equalsIgnoreCase(job.getName()));
return job != null && (id == job.getId() || jobName.equalsIgnoreCase(job.getName())
|| fullName.equalsIgnoreCase(job.getJobFullName()) || fullName.equalsIgnoreCase(job.getName()));
}
/**

View File

@ -275,8 +275,9 @@ public class JobsPaymentListener implements Listener {
return;
Sheep sheep = (Sheep) event.getEntity();
// mob spawner, no payment or experience
if (sheep.hasMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata()) && !Jobs.getGCManager().payNearSpawner()) {
if (!Jobs.getGCManager().payNearSpawner() && sheep.hasMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata())) {
sheep.removeMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), plugin);
return;
}
@ -507,7 +508,7 @@ public class JobsPaymentListener implements Listener {
}
// mob spawner, no payment or experience
if (animal.hasMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata()) && !Jobs.getGCManager().payNearSpawner()) {
if (!Jobs.getGCManager().payNearSpawner() && animal.hasMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata())) {
animal.removeMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), plugin);
return;
}