mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 14:05:25 +01:00
Allow to set bossbar bar colors by jobs
This commit is contained in:
parent
2b14078860
commit
c490e34fc6
@ -1,147 +1,163 @@
|
|||||||
|
|
||||||
package com.gamingmesh.jobs.config;
|
package com.gamingmesh.jobs.config;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.boss.BarColor;
|
import org.bukkit.boss.BarColor;
|
||||||
import org.bukkit.boss.BarStyle;
|
import org.bukkit.boss.BarStyle;
|
||||||
import org.bukkit.boss.BossBar;
|
import org.bukkit.boss.BossBar;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
import com.gamingmesh.jobs.container.BossBarInfo;
|
import com.gamingmesh.jobs.container.BossBarInfo;
|
||||||
import com.gamingmesh.jobs.container.JobProgression;
|
import com.gamingmesh.jobs.container.Job;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobProgression;
|
||||||
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
public class BossBarManager {
|
|
||||||
|
public class BossBarManager {
|
||||||
Jobs plugin;
|
|
||||||
|
Jobs plugin;
|
||||||
public BossBarManager(Jobs plugin) {
|
|
||||||
this.plugin = plugin;
|
public BossBarManager(Jobs plugin) {
|
||||||
}
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
public synchronized void ShowJobProgression(final JobsPlayer player) {
|
|
||||||
if (Jobs.getActionBar().getVersion() < 1900)
|
public synchronized void ShowJobProgression(final JobsPlayer player) {
|
||||||
return;
|
if (Jobs.getActionBar().getVersion() < 1900)
|
||||||
|
return;
|
||||||
if (player == null)
|
|
||||||
return;
|
if (player == null)
|
||||||
|
return;
|
||||||
List<String> temp = new ArrayList<String>();
|
|
||||||
|
List<String> temp = new ArrayList<String>();
|
||||||
temp.addAll(player.getUpdateBossBarFor());
|
|
||||||
|
temp.addAll(player.getUpdateBossBarFor());
|
||||||
for (String one : temp) {
|
|
||||||
for (JobProgression oneJob : player.getJobProgression()) {
|
for (String one : temp) {
|
||||||
if (one.equalsIgnoreCase(oneJob.getJob().getName()))
|
for (JobProgression oneJob : player.getJobProgression()) {
|
||||||
ShowJobProgression(player, oneJob);
|
if (one.equalsIgnoreCase(oneJob.getJob().getName()))
|
||||||
}
|
ShowJobProgression(player, oneJob);
|
||||||
}
|
}
|
||||||
player.clearUpdateBossBarFor();
|
}
|
||||||
}
|
player.clearUpdateBossBarFor();
|
||||||
|
}
|
||||||
public synchronized void ShowJobProgression(final JobsPlayer player, final JobProgression jobProg) {
|
|
||||||
if (Jobs.getActionBar().getVersion() < 1900)
|
public synchronized void ShowJobProgression(final JobsPlayer player, final JobProgression jobProg) {
|
||||||
return;
|
if (Jobs.getActionBar().getVersion() < 1900)
|
||||||
String playername = player.getUserName();
|
return;
|
||||||
if (!Jobs.getBossBarToggleList().containsKey(playername) && Jobs.getGCManager().BossBarsMessageByDefault)
|
String playername = player.getUserName();
|
||||||
Jobs.getBossBarToggleList().put(playername, true);
|
if (!Jobs.getBossBarToggleList().containsKey(playername) && Jobs.getGCManager().BossBarsMessageByDefault)
|
||||||
|
Jobs.getBossBarToggleList().put(playername, true);
|
||||||
if (!Jobs.getBossBarToggleList().containsKey(playername))
|
|
||||||
return;
|
if (!Jobs.getBossBarToggleList().containsKey(playername))
|
||||||
|
return;
|
||||||
Boolean show = Jobs.getBossBarToggleList().get(playername);
|
|
||||||
|
Boolean show = Jobs.getBossBarToggleList().get(playername);
|
||||||
if (!show)
|
|
||||||
return;
|
if (!show)
|
||||||
|
return;
|
||||||
BossBar bar = null;
|
|
||||||
BossBarInfo OldOne = null;
|
BossBar bar = null;
|
||||||
for (BossBarInfo one : player.getBossBarInfo()) {
|
BossBarInfo OldOne = null;
|
||||||
if (!one.getJobName().equalsIgnoreCase(jobProg.getJob().getName()))
|
for (BossBarInfo one : player.getBossBarInfo()) {
|
||||||
continue;
|
if (!one.getJobName().equalsIgnoreCase(jobProg.getJob().getName()))
|
||||||
|
continue;
|
||||||
one.cancel();
|
|
||||||
bar = one.getBar();
|
one.cancel();
|
||||||
OldOne = one;
|
bar = one.getBar();
|
||||||
break;
|
OldOne = one;
|
||||||
}
|
break;
|
||||||
NumberFormat formatter = new DecimalFormat("#0.00");
|
}
|
||||||
|
NumberFormat formatter = new DecimalFormat("#0.00");
|
||||||
String message = Jobs.getLanguage().getMessage("command.stats.output",
|
|
||||||
"%joblevel%", Integer.valueOf(jobProg.getLevel()).toString(),
|
String message = Jobs.getLanguage().getMessage("command.stats.output",
|
||||||
"%jobname%", jobProg.getJob().getChatColor() + jobProg.getJob().getName() + ChatColor.WHITE,
|
"%joblevel%", Integer.valueOf(jobProg.getLevel()).toString(),
|
||||||
"%jobxp%", formatter.format(Math.round(jobProg.getExperience() * 100.0) / 100.0),
|
"%jobname%", jobProg.getJob().getChatColor() + jobProg.getJob().getName() + ChatColor.WHITE,
|
||||||
"%jobmaxxp%", jobProg.getMaxExperience());
|
"%jobxp%", formatter.format(Math.round(jobProg.getExperience() * 100.0) / 100.0),
|
||||||
|
"%jobmaxxp%", jobProg.getMaxExperience());
|
||||||
if (bar == null) {
|
|
||||||
BarColor color = BarColor.BLUE;
|
if (bar == null) {
|
||||||
switch (player.getBossBarInfo().size()) {
|
BarColor color = getColor(jobProg.getJob());
|
||||||
case 1:
|
if (color == null) {
|
||||||
color = BarColor.GREEN;
|
switch (player.getBossBarInfo().size()) {
|
||||||
break;
|
case 1:
|
||||||
case 2:
|
color = BarColor.GREEN;
|
||||||
color = BarColor.RED;
|
break;
|
||||||
break;
|
case 2:
|
||||||
case 3:
|
color = BarColor.RED;
|
||||||
color = BarColor.WHITE;
|
break;
|
||||||
break;
|
case 3:
|
||||||
case 4:
|
color = BarColor.WHITE;
|
||||||
color = BarColor.YELLOW;
|
break;
|
||||||
break;
|
case 4:
|
||||||
case 5:
|
color = BarColor.YELLOW;
|
||||||
color = BarColor.PINK;
|
break;
|
||||||
break;
|
case 5:
|
||||||
case 6:
|
color = BarColor.PINK;
|
||||||
color = BarColor.PURPLE;
|
break;
|
||||||
break;
|
case 6:
|
||||||
}
|
color = BarColor.PURPLE;
|
||||||
bar = Bukkit.createBossBar(message, color, BarStyle.SEGMENTED_20);
|
break;
|
||||||
} else
|
default:
|
||||||
bar.setTitle(message);
|
color = BarColor.BLUE;
|
||||||
|
break;
|
||||||
double percentage = jobProg.getExperience() / jobProg.getMaxExperience();
|
}
|
||||||
try {
|
}
|
||||||
bar.setProgress(percentage);
|
bar = Bukkit.createBossBar(message, color, BarStyle.SEGMENTED_20);
|
||||||
if (OldOne == null) {
|
} else
|
||||||
Player target = Bukkit.getPlayer(player.getPlayer().getUniqueId());
|
bar.setTitle(message);
|
||||||
if (target == null)
|
|
||||||
return;
|
double percentage = jobProg.getExperience() / jobProg.getMaxExperience();
|
||||||
bar.addPlayer(target);
|
try {
|
||||||
OldOne = new BossBarInfo(player.getUserName(), jobProg.getJob().getName(), bar);
|
bar.setProgress(percentage);
|
||||||
player.getBossBarInfo().add(OldOne);
|
if (OldOne == null) {
|
||||||
}
|
Player target = Bukkit.getPlayer(player.getPlayer().getUniqueId());
|
||||||
bar.setVisible(true);
|
if (target == null)
|
||||||
} catch (NoSuchMethodError e) {
|
return;
|
||||||
}
|
bar.addPlayer(target);
|
||||||
|
OldOne = new BossBarInfo(player.getUserName(), jobProg.getJob().getName(), bar);
|
||||||
if (OldOne == null)
|
player.getBossBarInfo().add(OldOne);
|
||||||
return;
|
}
|
||||||
|
bar.setVisible(true);
|
||||||
OldOne.setId(Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
} catch (NoSuchMethodError e) {
|
||||||
@Override
|
}
|
||||||
public void run() {
|
|
||||||
|
if (OldOne == null)
|
||||||
for (BossBarInfo one : player.getBossBarInfo()) {
|
return;
|
||||||
if (!one.getPlayerName().equalsIgnoreCase(player.getUserName()))
|
|
||||||
continue;
|
OldOne.setId(Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||||
|
@Override
|
||||||
if (!one.getJobName().equalsIgnoreCase(jobProg.getJob().getName()))
|
public void run() {
|
||||||
continue;
|
|
||||||
|
for (BossBarInfo one : player.getBossBarInfo()) {
|
||||||
BossBar tempBar = one.getBar();
|
if (!one.getPlayerName().equalsIgnoreCase(player.getUserName()))
|
||||||
tempBar.setVisible(false);
|
continue;
|
||||||
break;
|
|
||||||
}
|
if (!one.getJobName().equalsIgnoreCase(jobProg.getJob().getName()))
|
||||||
return;
|
continue;
|
||||||
}
|
|
||||||
}, Jobs.getGCManager().BossBarTimer * 20L));
|
BossBar tempBar = one.getBar();
|
||||||
|
tempBar.setVisible(false);
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}, Jobs.getGCManager().BossBarTimer * 20L));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private BarColor getColor(Job job) {
|
||||||
|
if (job.getBossbar() == null)
|
||||||
|
return null;
|
||||||
|
for (BarColor color : BarColor.values()) {
|
||||||
|
if (job.getBossbar().equalsIgnoreCase(color.name()))
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -29,6 +29,7 @@ import java.util.List;
|
|||||||
import org.apache.commons.lang.StringEscapeUtils;
|
import org.apache.commons.lang.StringEscapeUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.boss.BarColor;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
@ -49,7 +50,6 @@ import com.gamingmesh.jobs.container.JobLimitedItems;
|
|||||||
import com.gamingmesh.jobs.container.JobPermission;
|
import com.gamingmesh.jobs.container.JobPermission;
|
||||||
import com.gamingmesh.jobs.resources.jfep.Parser;
|
import com.gamingmesh.jobs.resources.jfep.Parser;
|
||||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||||
import com.gamingmesh.jobs.stuff.Debug;
|
|
||||||
|
|
||||||
public class ConfigManager {
|
public class ConfigManager {
|
||||||
private Jobs plugin;
|
private Jobs plugin;
|
||||||
@ -154,6 +154,16 @@ public class ConfigManager {
|
|||||||
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid ChatColour property. Defaulting to WHITE!");
|
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid ChatColour property. Defaulting to WHITE!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String bossbar = null;
|
||||||
|
if (jobSection.contains("BossBarColour")) {
|
||||||
|
bossbar = jobSection.getString("BossBarColour", "");
|
||||||
|
if (bossbar == null) {
|
||||||
|
color = ChatColor.WHITE;
|
||||||
|
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid BossBarColour property.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DisplayMethod displayMethod = DisplayMethod.matchMethod(jobSection.getString("chat-display", ""));
|
DisplayMethod displayMethod = DisplayMethod.matchMethod(jobSection.getString("chat-display", ""));
|
||||||
if (displayMethod == null) {
|
if (displayMethod == null) {
|
||||||
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid chat-display property. Defaulting to None!");
|
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid chat-display property. Defaulting to None!");
|
||||||
@ -406,7 +416,7 @@ public class ConfigManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Job job = new Job(jobName, jobShortName, description, color, maxExpEquation, displayMethod, maxLevel, vipmaxLevel, maxSlots, jobPermissions, jobCommand,
|
Job job = new Job(jobName, jobShortName, description, color, maxExpEquation, displayMethod, maxLevel, vipmaxLevel, maxSlots, jobPermissions, jobCommand,
|
||||||
jobConditions, jobItems, jobLimitedItems, JobsCommandOnJoin, JobsCommandOnLeave, GUIitem);
|
jobConditions, jobItems, jobLimitedItems, JobsCommandOnJoin, JobsCommandOnLeave, GUIitem, bossbar);
|
||||||
|
|
||||||
for (ActionType actionType : ActionType.values()) {
|
for (ActionType actionType : ActionType.values()) {
|
||||||
ConfigurationSection typeSection = jobSection.getConfigurationSection(actionType.getName());
|
ConfigurationSection typeSection = jobSection.getConfigurationSection(actionType.getName());
|
||||||
|
@ -71,6 +71,7 @@ public class Job {
|
|||||||
private Double bonus = null;
|
private Double bonus = null;
|
||||||
|
|
||||||
private BoostMultiplier boost = new BoostMultiplier();
|
private BoostMultiplier boost = new BoostMultiplier();
|
||||||
|
private String bossbar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -93,7 +94,7 @@ public class Job {
|
|||||||
*/
|
*/
|
||||||
public Job(String jobName, String jobShortName, String description, ChatColor jobColour, Parser maxExpEquation, DisplayMethod displayMethod, int maxLevel,
|
public Job(String jobName, String jobShortName, String description, ChatColor jobColour, Parser maxExpEquation, DisplayMethod displayMethod, int maxLevel,
|
||||||
int vipmaxLevel, Integer maxSlots, List<JobPermission> jobPermissions, List<JobCommands> jobCommands, List<JobConditions> jobConditions, List<JobItems> jobItems,
|
int vipmaxLevel, Integer maxSlots, List<JobPermission> jobPermissions, List<JobCommands> jobCommands, List<JobConditions> jobConditions, List<JobItems> jobItems,
|
||||||
List<JobLimitedItems> jobLimitedItems, List<String> CmdOnJoin, List<String> CmdOnLeave, ItemStack GUIitem) {
|
List<JobLimitedItems> jobLimitedItems, List<String> CmdOnJoin, List<String> CmdOnLeave, ItemStack GUIitem, String bossbar) {
|
||||||
this.jobName = jobName;
|
this.jobName = jobName;
|
||||||
this.jobShortName = jobShortName;
|
this.jobShortName = jobShortName;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
@ -111,6 +112,7 @@ public class Job {
|
|||||||
this.CmdOnJoin = CmdOnJoin;
|
this.CmdOnJoin = CmdOnJoin;
|
||||||
this.CmdOnLeave = CmdOnLeave;
|
this.CmdOnLeave = CmdOnLeave;
|
||||||
this.GUIitem = GUIitem;
|
this.GUIitem = GUIitem;
|
||||||
|
this.bossbar = bossbar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBoost(CurrencyType type, double Point) {
|
public void addBoost(CurrencyType type, double Point) {
|
||||||
@ -342,4 +344,12 @@ public class Job {
|
|||||||
public List<JobLimitedItems> getLimitedItems() {
|
public List<JobLimitedItems> getLimitedItems() {
|
||||||
return Collections.unmodifiableList(jobLimitedItems);
|
return Collections.unmodifiableList(jobLimitedItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getBossbar() {
|
||||||
|
return bossbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBossbar(String bossbar) {
|
||||||
|
this.bossbar = bossbar;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,208 +1,208 @@
|
|||||||
/**
|
/**
|
||||||
* Jobs Plugin for Bukkit
|
* Jobs Plugin for Bukkit
|
||||||
* Copyright (C) 2011 Zak Ford <zak.j.ford@gmail.com>
|
* Copyright (C) 2011 Zak Ford <zak.j.ford@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.gamingmesh.jobs.economy;
|
package com.gamingmesh.jobs.economy;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
import com.gamingmesh.jobs.api.JobsPaymentEvent;
|
import com.gamingmesh.jobs.api.JobsPaymentEvent;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||||
import com.gamingmesh.jobs.tasks.BufferedPaymentTask;
|
import com.gamingmesh.jobs.tasks.BufferedPaymentTask;
|
||||||
|
|
||||||
public class BufferedEconomy {
|
public class BufferedEconomy {
|
||||||
private Jobs plugin;
|
private Jobs plugin;
|
||||||
private Economy economy;
|
private Economy economy;
|
||||||
private LinkedBlockingQueue<BufferedPayment> payments = new LinkedBlockingQueue<BufferedPayment>();
|
private LinkedBlockingQueue<BufferedPayment> payments = new LinkedBlockingQueue<BufferedPayment>();
|
||||||
private final Map<UUID, BufferedPayment> paymentCache = Collections.synchronizedMap(new HashMap<UUID, BufferedPayment>());
|
private final Map<UUID, BufferedPayment> paymentCache = Collections.synchronizedMap(new HashMap<UUID, BufferedPayment>());
|
||||||
|
|
||||||
private OfflinePlayer ServerAccount = null;
|
private OfflinePlayer ServerAccount = null;
|
||||||
private OfflinePlayer ServerTaxesAccount = null;
|
private OfflinePlayer ServerTaxesAccount = null;
|
||||||
|
|
||||||
PaymentData PaymentData = new PaymentData();
|
PaymentData PaymentData = new PaymentData();
|
||||||
|
|
||||||
public BufferedEconomy(Jobs plugin, Economy economy) {
|
public BufferedEconomy(Jobs plugin, Economy economy) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.economy = economy;
|
this.economy = economy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add payment to player's payment buffer
|
* Add payment to player's payment buffer
|
||||||
* @param player - player to be paid
|
* @param player - player to be paid
|
||||||
* @param amount - amount to be paid
|
* @param amount - amount to be paid
|
||||||
*/
|
*/
|
||||||
public void pay(JobsPlayer player, double amount, double points, double exp) {
|
public void pay(JobsPlayer player, double amount, double points, double exp) {
|
||||||
pay(new BufferedPayment(player.getPlayer(), amount, points, exp));
|
pay(new BufferedPayment(player.getPlayer(), amount, points, exp));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add payment to player's payment buffer
|
* Add payment to player's payment buffer
|
||||||
* @param payment - payment to be paid
|
* @param payment - payment to be paid
|
||||||
*/
|
*/
|
||||||
public void pay(BufferedPayment payment) {
|
public void pay(BufferedPayment payment) {
|
||||||
payments.add(payment);
|
payments.add(payment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String format(double money) {
|
public String format(double money) {
|
||||||
return economy.format(money);
|
return economy.format(money);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Payout all players the amount they are going to be paid
|
* Payout all players the amount they are going to be paid
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void payAll() {
|
public void payAll() {
|
||||||
if (payments.isEmpty())
|
if (payments.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
synchronized (paymentCache) {
|
synchronized (paymentCache) {
|
||||||
|
|
||||||
Double TotalAmount = 0.0;
|
Double TotalAmount = 0.0;
|
||||||
Double TotalPoints = 0.0;
|
Double TotalPoints = 0.0;
|
||||||
Double TaxesAmount = 0.0;
|
Double TaxesAmount = 0.0;
|
||||||
Double TaxesPoints = 0.0;
|
Double TaxesPoints = 0.0;
|
||||||
|
|
||||||
// combine all payments using paymentCache
|
// combine all payments using paymentCache
|
||||||
while (!payments.isEmpty()) {
|
while (!payments.isEmpty()) {
|
||||||
BufferedPayment payment = payments.remove();
|
BufferedPayment payment = payments.remove();
|
||||||
TotalAmount += payment.getAmount();
|
TotalAmount += payment.getAmount();
|
||||||
TotalPoints += payment.getPoints();
|
TotalPoints += payment.getPoints();
|
||||||
|
|
||||||
if (Jobs.getGCManager().UseTaxes) {
|
if (Jobs.getGCManager().UseTaxes) {
|
||||||
TaxesAmount += payment.getAmount() * (Jobs.getGCManager().TaxesAmount / 100.0);
|
TaxesAmount += payment.getAmount() * (Jobs.getGCManager().TaxesAmount / 100.0);
|
||||||
TaxesPoints += payment.getPoints() * (Jobs.getGCManager().TaxesAmount / 100.0);
|
TaxesPoints += payment.getPoints() * (Jobs.getGCManager().TaxesAmount / 100.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (payment.getOfflinePlayer() == null)
|
if (payment.getOfflinePlayer() == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
UUID uuid = payment.getOfflinePlayer().getUniqueId();
|
UUID uuid = payment.getOfflinePlayer().getUniqueId();
|
||||||
if (paymentCache.containsKey(uuid)) {
|
if (paymentCache.containsKey(uuid)) {
|
||||||
BufferedPayment existing = paymentCache.get(uuid);
|
BufferedPayment existing = paymentCache.get(uuid);
|
||||||
|
|
||||||
double money = payment.getAmount();
|
double money = payment.getAmount();
|
||||||
double points = payment.getPoints();
|
double points = payment.getPoints();
|
||||||
double exp = payment.getExp();
|
double exp = payment.getExp();
|
||||||
|
|
||||||
if (Jobs.getGCManager().TakeFromPlayersPayment && Jobs.getGCManager().UseTaxes) {
|
if (Jobs.getGCManager().TakeFromPlayersPayment && Jobs.getGCManager().UseTaxes) {
|
||||||
money = money - (money * (Jobs.getGCManager().TaxesAmount / 100.0));
|
money = money - (money * (Jobs.getGCManager().TaxesAmount / 100.0));
|
||||||
points = points - (points * (Jobs.getGCManager().TaxesAmount / 100.0));
|
points = points - (points * (Jobs.getGCManager().TaxesAmount / 100.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
existing.setAmount(existing.getAmount() + money);
|
existing.setAmount(existing.getAmount() + money);
|
||||||
existing.setPoints(existing.getPoints() + points);
|
existing.setPoints(existing.getPoints() + points);
|
||||||
existing.setExp(existing.getExp() + exp);
|
existing.setExp(existing.getExp() + exp);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
double money = payment.getAmount();
|
double money = payment.getAmount();
|
||||||
double points = payment.getPoints();
|
double points = payment.getPoints();
|
||||||
|
|
||||||
if (Jobs.getGCManager().TakeFromPlayersPayment && Jobs.getGCManager().UseTaxes) {
|
if (Jobs.getGCManager().TakeFromPlayersPayment && Jobs.getGCManager().UseTaxes) {
|
||||||
payment.setAmount(money - (money * (Jobs.getGCManager().TaxesAmount / 100.0)));
|
payment.setAmount(money - (money * (Jobs.getGCManager().TaxesAmount / 100.0)));
|
||||||
payment.setPoints(points - (points * (Jobs.getGCManager().TaxesAmount / 100.0)));
|
payment.setPoints(points - (points * (Jobs.getGCManager().TaxesAmount / 100.0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
paymentCache.put(uuid, payment);
|
paymentCache.put(uuid, payment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasMoney = false;
|
boolean hasMoney = false;
|
||||||
String ServerAccountname = Jobs.getGCManager().ServerAcountName;
|
String ServerAccountname = Jobs.getGCManager().ServerAcountName;
|
||||||
String ServerTaxesAccountname = Jobs.getGCManager().ServertaxesAcountName;
|
String ServerTaxesAccountname = Jobs.getGCManager().ServertaxesAcountName;
|
||||||
if (this.ServerAccount == null)
|
if (this.ServerAccount == null)
|
||||||
this.ServerAccount = Bukkit.getOfflinePlayer(ServerAccountname);
|
this.ServerAccount = Bukkit.getOfflinePlayer(ServerAccountname);
|
||||||
|
|
||||||
if (this.ServerTaxesAccount == null)
|
if (this.ServerTaxesAccount == null)
|
||||||
this.ServerTaxesAccount = Bukkit.getOfflinePlayer(ServerTaxesAccountname);
|
this.ServerTaxesAccount = Bukkit.getOfflinePlayer(ServerTaxesAccountname);
|
||||||
|
|
||||||
if (Jobs.getGCManager().UseTaxes && Jobs.getGCManager().TransferToServerAccount && ServerTaxesAccount != null) {
|
if (Jobs.getGCManager().UseTaxes && Jobs.getGCManager().TransferToServerAccount && ServerTaxesAccount != null) {
|
||||||
economy.depositPlayer(ServerTaxesAccount, TaxesAmount);
|
economy.depositPlayer(ServerTaxesAccount, TaxesAmount);
|
||||||
|
|
||||||
if (ServerTaxesAccount.isOnline()) {
|
if (ServerTaxesAccount.isOnline()) {
|
||||||
if (!Jobs.getActionbarToggleList().containsKey(ServerTaxesAccountname) && Jobs.getGCManager().ActionBarsMessageByDefault)
|
if (!Jobs.getActionbarToggleList().containsKey(ServerTaxesAccountname) && Jobs.getGCManager().ActionBarsMessageByDefault)
|
||||||
Jobs.getActionbarToggleList().put(ServerTaxesAccountname, true);
|
Jobs.getActionbarToggleList().put(ServerTaxesAccountname, true);
|
||||||
if (Jobs.getActionbarToggleList().containsKey(ServerTaxesAccountname) && Jobs.getActionbarToggleList().get(ServerTaxesAccountname)) {
|
if (Jobs.getActionbarToggleList().containsKey(ServerTaxesAccountname) && Jobs.getActionbarToggleList().get(ServerTaxesAccountname)) {
|
||||||
Jobs.getActionBar().send(Bukkit.getPlayer(ServerAccountname), Jobs.getLanguage().getMessage("message.taxes", "[amount]", (int) (TotalAmount * 100)
|
Jobs.getActionBar().send(Bukkit.getPlayer(ServerAccountname), Jobs.getLanguage().getMessage("message.taxes", "[amount]", (int) (TotalAmount * 100)
|
||||||
/ 100.0));
|
/ 100.0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Jobs.getGCManager().UseServerAccount) {
|
if (Jobs.getGCManager().UseServerAccount) {
|
||||||
if (economy.hasMoney(ServerAccountname, TotalAmount)) {
|
if (economy.hasMoney(ServerAccountname, TotalAmount)) {
|
||||||
hasMoney = true;
|
hasMoney = true;
|
||||||
economy.withdrawPlayer(ServerAccountname, TotalAmount);
|
economy.withdrawPlayer(ServerAccountname, TotalAmount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Schedule all payments
|
// Schedule all payments
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (BufferedPayment payment : paymentCache.values()) {
|
for (BufferedPayment payment : paymentCache.values()) {
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (payment.getOfflinePlayer() == null)
|
if (payment.getOfflinePlayer() == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// JobsPayment event
|
// JobsPayment event
|
||||||
JobsPaymentEvent JobsPaymentEvent = new JobsPaymentEvent(payment.getOfflinePlayer(), payment.getAmount(), payment.getPoints());
|
JobsPaymentEvent JobsPaymentEvent = new JobsPaymentEvent(payment.getOfflinePlayer(), payment.getAmount(), payment.getPoints());
|
||||||
Bukkit.getServer().getPluginManager().callEvent(JobsPaymentEvent);
|
Bukkit.getServer().getPluginManager().callEvent(JobsPaymentEvent);
|
||||||
// If event is canceled, dont do anything
|
// If event is canceled, dont do anything
|
||||||
if (JobsPaymentEvent.isCancelled())
|
if (JobsPaymentEvent.isCancelled())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
payment.setAmount(JobsPaymentEvent.getAmount());
|
payment.setAmount(JobsPaymentEvent.getAmount());
|
||||||
payment.setPoints(JobsPaymentEvent.getPoints());
|
payment.setPoints(JobsPaymentEvent.getPoints());
|
||||||
|
|
||||||
if (Jobs.getGCManager().UseServerAccount) {
|
if (Jobs.getGCManager().UseServerAccount) {
|
||||||
if (!hasMoney) {
|
if (!hasMoney) {
|
||||||
Jobs.getActionBar().send(payment.getOfflinePlayer().getPlayer(), ChatColor.RED + Jobs.getLanguage().getMessage("economy.error.nomoney"));
|
Jobs.getActionBar().send(payment.getOfflinePlayer().getPlayer(), ChatColor.RED + Jobs.getLanguage().getMessage("economy.error.nomoney"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (Jobs.getGCManager().isEconomyAsync())
|
if (Jobs.getGCManager().isEconomyAsync())
|
||||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new BufferedPaymentTask(this, economy, payment), i);
|
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new BufferedPaymentTask(this, economy, payment), i);
|
||||||
else
|
else
|
||||||
Bukkit.getScheduler().runTaskLater(plugin, new BufferedPaymentTask(this, economy, payment), i);
|
Bukkit.getScheduler().runTaskLater(plugin, new BufferedPaymentTask(this, economy, payment), i);
|
||||||
} else {
|
} else {
|
||||||
if (Jobs.getGCManager().isEconomyAsync())
|
if (Jobs.getGCManager().isEconomyAsync())
|
||||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new BufferedPaymentTask(this, economy, payment), i);
|
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new BufferedPaymentTask(this, economy, payment), i);
|
||||||
else
|
else
|
||||||
Bukkit.getScheduler().runTaskLater(plugin, new BufferedPaymentTask(this, economy, payment), i);
|
Bukkit.getScheduler().runTaskLater(plugin, new BufferedPaymentTask(this, economy, payment), i);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// Action bar stuff
|
// Action bar stuff
|
||||||
Jobs.getActionBar().ShowActionBar(payment);
|
Jobs.getActionBar().ShowActionBar(payment);
|
||||||
if (payment.getOfflinePlayer().isOnline()) {
|
if (payment.getOfflinePlayer().isOnline() && Jobs.getActionBar().getVersion() > 1900) {
|
||||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(payment.getOfflinePlayer().getName());
|
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(payment.getOfflinePlayer().getName());
|
||||||
Jobs.getBBManager().ShowJobProgression(jPlayer);
|
Jobs.getBBManager().ShowJobProgression(jPlayer);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// empty payment cache
|
// empty payment cache
|
||||||
paymentCache.clear();
|
paymentCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,8 @@ public class ActionBar {
|
|||||||
cleanVersion = 1920;
|
cleanVersion = 1920;
|
||||||
if (version.contains("v1_10_R1"))
|
if (version.contains("v1_10_R1"))
|
||||||
cleanVersion = 11010;
|
cleanVersion = 11010;
|
||||||
|
if (version.contains("v1_11_R1"))
|
||||||
|
cleanVersion = 11110;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cleanVersion < 1400)
|
if (cleanVersion < 1400)
|
||||||
|
Loading…
Reference in New Issue
Block a user