1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-25 20:16:13 +01:00

Update permission boost by force when checking with command

This commit is contained in:
Zrips 2017-01-10 17:28:35 +02:00
parent dd6806ac2d
commit 28df77bbf0
5 changed files with 32 additions and 16 deletions

View File

@ -910,7 +910,7 @@ public class Jobs extends JavaPlugin {
player.giveExp(expInt);
}
}
Boost boost = Jobs.getPlayerManager().getFinalBonus(jPlayer, prog.getJob(), ent, victim);
Boost boost = Jobs.getPlayerManager().getFinalBonus(jPlayer, prog.getJob(), ent, victim, false);
// Calculate income
if (income != 0D) {

View File

@ -447,7 +447,7 @@ public class PlayerManager {
if (sound != null && player != null && player.getLocation() != null)
player.getWorld().playSound(player.getLocation(), sound, levelUpEvent.getSoundVolume(), levelUpEvent.getSoundPitch());
else
Bukkit.getConsoleSender().sendMessage("[Jobs] Cant find sound by name: " + levelUpEvent.getTitleChangeSoundName() + ". Please update it");
Bukkit.getConsoleSender().sendMessage("[Jobs] Cant find sound by name: " + levelUpEvent.getTitleChangeSound().name() + ". Please update it");
}
String message;
@ -488,7 +488,7 @@ public class PlayerManager {
player.getWorld().playSound(player.getLocation(), sound, levelUpEvent.getTitleChangeVolume(),
levelUpEvent.getTitleChangePitch());
else
Bukkit.getConsoleSender().sendMessage("[Jobs] Cant find sound by name: " + levelUpEvent.getTitleChangeSoundName() + ". Please update it");
Bukkit.getConsoleSender().sendMessage("[Jobs] Cant find sound by name: " + levelUpEvent.getTitleChangeSound().name() + ". Please update it");
}
// user would skill up
if (Jobs.getGCManager().isBroadcastingSkillups()) {
@ -568,9 +568,13 @@ public class PlayerManager {
}
public BoostMultiplier getBoost(JobsPlayer player, Job job) {
return getBoost(player, job, false);
}
public BoostMultiplier getBoost(JobsPlayer player, Job job, boolean force) {
BoostMultiplier b = new BoostMultiplier();
for (CurrencyType one : CurrencyType.values()) {
b.add(one, getBoost(player, job, one, false));
b.add(one, getBoost(player, job, one, force));
}
return b;
}
@ -673,11 +677,15 @@ public class PlayerManager {
McMMO, PetPay, NearSpawner, Permission, Global, Dynamic, Item, Area
}
public Boost getFinalBonus(JobsPlayer player, Job prog) {
return getFinalBonus(player, prog, null, null);
public Boost getFinalBonus(JobsPlayer player, Job prog, boolean force) {
return getFinalBonus(player, prog, null, null, force);
}
public Boost getFinalBonus(JobsPlayer player, Job prog, Entity ent, LivingEntity victim) {
public Boost getFinalBonus(JobsPlayer player, Job prog) {
return getFinalBonus(player, prog, null, null, false);
}
public Boost getFinalBonus(JobsPlayer player, Job prog, Entity ent, LivingEntity victim, boolean force) {
Boost boost = new Boost();
if (player == null || prog == null)
@ -701,7 +709,7 @@ public class PlayerManager {
if (victim != null && victim.hasMetadata(this.getMobSpawnerMetadata()))
boost.add(BoostOf.NearSpawner, new BoostMultiplier().add(player.getVipSpawnerMultiplier()));
boost.add(BoostOf.Permission, Jobs.getPlayerManager().getBoost(player, prog));
boost.add(BoostOf.Permission, Jobs.getPlayerManager().getBoost(player, prog, force));
boost.add(BoostOf.Global, prog.getBoost());
if (Jobs.getGCManager().useDynamicPayment)
boost.add(BoostOf.Dynamic, new BoostMultiplier().add(prog.getBonus()));

View File

@ -42,7 +42,7 @@ public class bonus implements Cmd {
if (jPlayer == null)
return false;
Boost boost = Jobs.getPlayerManager().getFinalBonus(jPlayer, job);
Boost boost = Jobs.getPlayerManager().getFinalBonus(jPlayer, job, true);
sender.sendMessage(Jobs.getLanguage().getMessage("command.bonus.output.topline"));

View File

@ -33,6 +33,7 @@ import com.gamingmesh.jobs.dao.JobsDAO;
import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.resources.jfep.Parser;
import com.gamingmesh.jobs.stuff.ChatColor;
import com.gamingmesh.jobs.stuff.Debug;
import com.gamingmesh.jobs.stuff.Perm;
public class JobsPlayer {
@ -189,7 +190,6 @@ public class JobsPlayer {
}
public double getBoost(String JobName, CurrencyType type, boolean force) {
double Boost = 0D;
if (this.OffPlayer == null)
@ -209,6 +209,7 @@ public class JobsPlayer {
if (counter.getType() != type)
continue;
if (force || time - counter.getTime() > 1000 * 60) {
Debug.D("updating perm");
Boost = getPlayerBoost(JobName, type);
counter.setBoost(Boost);
counter.setTime(time);

View File

@ -18,7 +18,9 @@
package com.gamingmesh.jobs.i18n;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.config.YmlMaker;
@ -30,7 +32,6 @@ public class Language {
public Language(Jobs plugin) {
this.plugin = plugin;
reload();
}
/**
@ -51,11 +52,17 @@ public class Language {
public String getMessage(String key, Object... variables) {
String missing = "Missing locale for " + key + " ";
String msg = "";
if (customlocale == null || !customlocale.contains(key))
msg = enlocale.contains(key) == true ? ChatColor.translateAlternateColorCodes('&', enlocale.getString(key)) : missing;
else
msg = customlocale.contains(key) == true ? ChatColor.translateAlternateColorCodes('&', customlocale.getString(key)) : missing;
try {
if (customlocale == null || !customlocale.contains(key))
msg = enlocale.contains(key) == true ? ChatColor.translateAlternateColorCodes('&', enlocale.getString(key)) : missing;
else
msg = customlocale.contains(key) == true ? ChatColor.translateAlternateColorCodes('&', customlocale.getString(key)) : missing;
} catch (Exception e) {
String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &2Cant read language file. Plugin will be disabled.");
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
console.sendMessage(message);
throw e;
}
if (variables.length > 0)
for (int i = 0; i < variables.length; i++) {
if (variables.length >= i + 2)