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

Fix for signs on destroy and protection from destroying them if dont

have permission
This commit is contained in:
Zrips 2015-09-10 17:00:43 +03:00
parent 401c6c1c6d
commit 320b9c08f4
5 changed files with 412 additions and 357 deletions

View File

@ -24,10 +24,7 @@ import java.lang.reflect.Method;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
@ -50,8 +47,6 @@ import com.gamingmesh.jobs.container.JobInfo;
import com.gamingmesh.jobs.container.JobItems;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.Log;
import com.gamingmesh.jobs.container.LogAmounts;
import com.gamingmesh.jobs.container.TopList;
import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.i18n.Language;

View File

@ -1343,6 +1343,7 @@ public class JobsConfiguration {
GetConfigString("signs.SpecialList.3.3", "&8[level] level", writer, conf, true);
GetConfigString("signs.SpecialList.3.4", "&b************", writer, conf, true);
GetConfigString("signs.cantcreate", "&4You can't create this sign!", writer, conf, true);
GetConfigString("signs.cantdestroy", "&4You can't destroy this sign!", writer, conf, true);
GetConfigString("signs.topline", "&2[Jobs]", writer, conf, true);
GetConfigString("signs.secondline.join", "&2Join", writer, conf, true);
GetConfigString("signs.secondline.leave", "&4Leave", writer, conf, true);

View File

@ -32,6 +32,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
@ -50,391 +51,450 @@ import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.i18n.Language;
import Signs.SignUtil;
public class JobsListener implements Listener {
// hook to the main plugin
private JobsPlugin plugin;
// hook to the main plugin
private JobsPlugin plugin;
public JobsListener(JobsPlugin plugin) {
this.plugin = plugin;
public JobsListener(JobsPlugin plugin) {
this.plugin = plugin;
}
// @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
// public void onGuiRightClick(InventoryClickEvent event) {
// if (Gui.GuiTools.GuiList.size() == 0)
// return;
//
// Player player = (Player) event.getWhoClicked();
//
// if (!Gui.GuiTools.GuiList.containsKey(player.getName()))
// return;
//
// if (event.getClick() != ClickType.RIGHT)
// return;
//
// event.setCancelled(true);
//
// GuiInfoList joblist = Gui.GuiTools.GuiList.get(player.getName());
//
// if (joblist.isJobInfo())
// return;
//
// int slot = event.getRawSlot();
//
// if (slot < joblist.getJobList().size()) {
// Bukkit.dispatchCommand(player, "jobs join " + joblist.getJobList().get(slot).getName());
// player.getOpenInventory().getTopInventory().setContents(GuiTools.CreateJobsGUI(player).getContents());
// }
// }
//
// @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
// public void onGuiLeftClick(InventoryClickEvent event) {
// if (Gui.GuiTools.GuiList.size() == 0)
// return;
//
// Player player = (Player) event.getWhoClicked();
//
// if (!Gui.GuiTools.GuiList.containsKey(player.getName()))
// return;
//
// event.setCancelled(true);
//
// if (event.getClick() != ClickType.LEFT)
// return;
//
// GuiInfoList joblist = Gui.GuiTools.GuiList.get(player.getName());
//
// if (joblist.isJobInfo())
// return;
//
// int slot = event.getRawSlot();
//
// if (slot < joblist.getJobList().size()) {
// player.closeInventory();
// player.openInventory(GuiTools.CreateJobsSubGUI(player, joblist.getJobList().get(slot)));
// }
// }
//
// @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
// public void onGuiLeftSubClick(InventoryClickEvent event) {
// if (Gui.GuiTools.GuiList.size() == 0)
// return;
//
// Player player = (Player) event.getWhoClicked();
//
// if (!Gui.GuiTools.GuiList.containsKey(player.getName()))
// return;
//
// event.setCancelled(true);
//
// if (event.getClick() != ClickType.LEFT)
// return;
//
// GuiInfoList joblist = Gui.GuiTools.GuiList.get(player.getName());
//
// if (!joblist.isJobInfo())
// return;
//
// int slot = event.getRawSlot();
//
// if (slot == joblist.getbackButton()) {
// player.closeInventory();
// player.openInventory(GuiTools.CreateJobsGUI(player));
// }
// }
//
// @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = false)
// public void onGuiClose(InventoryCloseEvent event) {
// if (Gui.GuiTools.GuiList.size() == 0)
// return;
//
// Player player = (Player) event.getPlayer();
//
// if (Gui.GuiTools.GuiList.containsKey(player.getName()))
// Gui.GuiTools.GuiList.remove(player.getName());
// }
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerJoin(PlayerJoinEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
Jobs.getPlayerManager().playerJoin(event.getPlayer());
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoinMonitor(PlayerJoinEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
/*
* We need to recalculate again to check for world permission and revoke permissions
* if we don't have world permission (from some other permission manager). It's
* necessary to call this twice in case somebody is relying on permissions from this
* plugin on entry to the world.
*/
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
Jobs.getPlayerManager().playerQuit(event.getPlayer());
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerWorldChange(PlayerChangedWorldEvent event) {
if (!plugin.isEnabled())
return;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onSignInteract(PlayerInteractEvent event) {
if (!plugin.isEnabled())
return;
if (!ConfigManager.getJobsConfiguration().SignsEnabled)
return;
Player player = (Player) event.getPlayer();
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
Material material = event.getClickedBlock().getType();
if (material != Material.WALL_SIGN && material != Material.SIGN && material != Material.SIGN_POST)
return;
Block block = event.getClickedBlock();
if (block == null)
return;
if (!(block.getState() instanceof Sign))
return;
Sign sign = (Sign) block.getState();
String FirstLine = sign.getLine(0);
if (!FirstLine.equalsIgnoreCase(Language.getMessage("signs.topline")))
return;
String command = ChatColor.stripColor(sign.getLine(1));
for (String key : ConfigManager.getJobsConfiguration().keys) {
if (command.equalsIgnoreCase(ChatColor.stripColor(Language.getMessage("signs.secondline." + key)))) {
command = key;
break;
}
}
// @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
// public void onGuiRightClick(InventoryClickEvent event) {
// if (Gui.GuiTools.GuiList.size() == 0)
// return;
//
// Player player = (Player) event.getWhoClicked();
//
// if (!Gui.GuiTools.GuiList.containsKey(player.getName()))
// return;
//
// if (event.getClick() != ClickType.RIGHT)
// return;
//
// event.setCancelled(true);
//
// GuiInfoList joblist = Gui.GuiTools.GuiList.get(player.getName());
//
// if (joblist.isJobInfo())
// return;
//
// int slot = event.getRawSlot();
//
// if (slot < joblist.getJobList().size()) {
// Bukkit.dispatchCommand(player, "jobs join " + joblist.getJobList().get(slot).getName());
// player.getOpenInventory().getTopInventory().setContents(GuiTools.CreateJobsGUI(player).getContents());
// }
// }
//
// @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
// public void onGuiLeftClick(InventoryClickEvent event) {
// if (Gui.GuiTools.GuiList.size() == 0)
// return;
//
// Player player = (Player) event.getWhoClicked();
//
// if (!Gui.GuiTools.GuiList.containsKey(player.getName()))
// return;
//
// event.setCancelled(true);
//
// if (event.getClick() != ClickType.LEFT)
// return;
//
// GuiInfoList joblist = Gui.GuiTools.GuiList.get(player.getName());
//
// if (joblist.isJobInfo())
// return;
//
// int slot = event.getRawSlot();
//
// if (slot < joblist.getJobList().size()) {
// player.closeInventory();
// player.openInventory(GuiTools.CreateJobsSubGUI(player, joblist.getJobList().get(slot)));
// }
// }
//
// @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
// public void onGuiLeftSubClick(InventoryClickEvent event) {
// if (Gui.GuiTools.GuiList.size() == 0)
// return;
//
// Player player = (Player) event.getWhoClicked();
//
// if (!Gui.GuiTools.GuiList.containsKey(player.getName()))
// return;
//
// event.setCancelled(true);
//
// if (event.getClick() != ClickType.LEFT)
// return;
//
// GuiInfoList joblist = Gui.GuiTools.GuiList.get(player.getName());
//
// if (!joblist.isJobInfo())
// return;
//
// int slot = event.getRawSlot();
//
// if (slot == joblist.getbackButton()) {
// player.closeInventory();
// player.openInventory(GuiTools.CreateJobsGUI(player));
// }
// }
//
// @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = false)
// public void onGuiClose(InventoryCloseEvent event) {
// if (Gui.GuiTools.GuiList.size() == 0)
// return;
//
// Player player = (Player) event.getPlayer();
//
// if (Gui.GuiTools.GuiList.containsKey(player.getName()))
// Gui.GuiTools.GuiList.remove(player.getName());
// }
Bukkit.dispatchCommand(player, "jobs " + command + " " + ChatColor.stripColor(sign.getLine(2)) + " " + ChatColor.stripColor(sign.getLine(3)));
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerJoin(PlayerJoinEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
Jobs.getPlayerManager().playerJoin(event.getPlayer());
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onSignDestroy(BlockBreakEvent event) {
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoinMonitor(PlayerJoinEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
if (!plugin.isEnabled())
return;
/*
* We need to recalculate again to check for world permission and revoke permissions
* if we don't have world permission (from some other permission manager). It's
* necessary to call this twice in case somebody is relying on permissions from this
* plugin on entry to the world.
*/
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
}
if (!ConfigManager.getJobsConfiguration().SignsEnabled)
return;
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
Jobs.getPlayerManager().playerQuit(event.getPlayer());
}
Material material = event.getBlock().getType();
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerWorldChange(PlayerChangedWorldEvent event) {
if (!plugin.isEnabled())
return;
if (material != Material.WALL_SIGN && material != Material.SIGN && material != Material.SIGN_POST)
return;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
}
Block block = event.getBlock();
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onSignInteract(PlayerInteractEvent event) {
if (block == null)
return;
if (!plugin.isEnabled())
return;
if (!(block.getState() instanceof Sign))
return;
if (!ConfigManager.getJobsConfiguration().SignsEnabled)
return;
Player player = (Player) event.getPlayer();
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
Material material = event.getClickedBlock().getType();
if (material != Material.WALL_SIGN && material != Material.SIGN && material != Material.SIGN_POST)
return;
Block block = event.getClickedBlock();
if (block == null)
return;
if (!(block.getState() instanceof Sign))
return;
Sign sign = (Sign) block.getState();
String FirstLine = sign.getLine(0);
if (!FirstLine.equalsIgnoreCase(Language.getMessage("signs.topline")))
return;
String command = ChatColor.stripColor(sign.getLine(1));
for (String key : ConfigManager.getJobsConfiguration().keys) {
if (command.equalsIgnoreCase(ChatColor.stripColor(Language.getMessage("signs.secondline." + key)))) {
command = key;
break;
}
}
Bukkit.dispatchCommand(player, "jobs " + command + " " + ChatColor.stripColor(sign.getLine(2)) + " " + ChatColor.stripColor(sign.getLine(3)));
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onSignTopListCreate(SignChangeEvent event) {
if (!plugin.isEnabled())
return;
if (!ConfigManager.getJobsConfiguration().SignsEnabled)
return;
Block block = event.getBlock();
if (!(block.getState() instanceof Sign))
return;
Sign sign = (Sign) block.getState();
final String signtype = ChatColor.stripColor(event.getLine(1));
if (!ChatColor.stripColor(event.getLine(0)).equalsIgnoreCase("[Jobs]"))
return;
if (!signtype.equalsIgnoreCase("toplist") && !signtype.equalsIgnoreCase("gtoplist"))
return;
Player player = (Player) event.getPlayer();
if (!event.getPlayer().hasPermission("jobs.command.signs")) {
event.setCancelled(true);
player.sendMessage(Language.getMessage("signs.cantcreate"));
return;
}
String jobname = ChatColor.stripColor(event.getLine(2)).toLowerCase();
final Job job = Jobs.getJob(jobname);
if (job == null && !signtype.equalsIgnoreCase("gtoplist")) {
player.sendMessage(Language.getMessage("command.top.error.nojob"));
return;
}
boolean special = false;
int Number = 0;
String numberString = ChatColor.stripColor(event.getLine(3)).toLowerCase();
if (numberString.contains("s")) {
numberString = numberString.replace("s", "");
special = true;
}
try {
Number = Integer.parseInt(numberString);
} catch (NumberFormatException e) {
player.sendMessage(Language.getMessage("command.error.notNumber"));
return;
}
Signs.Sign signInfo = new Signs.Sign();
Location loc = sign.getLocation();
int category = 1;
if (Signs.SignUtil.Signs.GetAllSigns().size() > 0)
category = Signs.SignUtil.Signs.GetAllSigns().get(Signs.SignUtil.Signs.GetAllSigns().size() - 1).GetCategory() + 1;
signInfo.setNumber(Number);
signInfo.setWorld(loc.getWorld().getName());
signInfo.setX(loc.getX());
signInfo.setY(loc.getY());
signInfo.setZ(loc.getZ());
signInfo.setCategory(category);
if (!signtype.equalsIgnoreCase("gtoplist"))
signInfo.setJobName(job.getName());
else
signInfo.setJobName("gtoplist");
signInfo.setSpecial(special);
Signs.SignUtil.Signs.addSign(signInfo);
Signs.SignUtil.saveSigns();
Player player = (Player) event.getPlayer();
Sign sign = (Sign) block.getState();
String FirstLine = sign.getLine(0);
if (FirstLine.equalsIgnoreCase(Language.getMessage("signs.topline")))
if (!player.hasPermission("jobs.command.signs")) {
event.setCancelled(true);
player.sendMessage(Language.getMessage("signs.cantdestroy"));
return;
}
Location loc = block.getLocation();
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(JobsPlugin.instance, new Runnable() {
public void run() {
if (!signtype.equalsIgnoreCase("gtoplist"))
Signs.SignUtil.SignUpdate(job.getName());
else
Signs.SignUtil.SignUpdate("gtoplist");
return;
}
}, 1L);
for (Signs.Sign one : SignUtil.Signs.GetAllSigns()) {
if (one.GetX() != loc.getBlockX())
continue;
if (one.GetY() != loc.getBlockY())
continue;
if (one.GetZ() != loc.getBlockZ())
continue;
if (!player.hasPermission("jobs.command.signs")) {
event.setCancelled(true);
player.sendMessage(Language.getMessage("signs.cantdestroy"));
return;
}
SignUtil.Signs.removeSign(one);
SignUtil.saveSigns();
break;
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onSignTopListCreate(SignChangeEvent event) {
if (!plugin.isEnabled())
return;
if (!ConfigManager.getJobsConfiguration().SignsEnabled)
return;
Block block = event.getBlock();
if (!(block.getState() instanceof Sign))
return;
Sign sign = (Sign) block.getState();
final String signtype = ChatColor.stripColor(event.getLine(1));
if (!ChatColor.stripColor(event.getLine(0)).equalsIgnoreCase("[Jobs]"))
return;
if (!signtype.equalsIgnoreCase("toplist") && !signtype.equalsIgnoreCase("gtoplist"))
return;
Player player = (Player) event.getPlayer();
if (!event.getPlayer().hasPermission("jobs.command.signs")) {
event.setCancelled(true);
player.sendMessage(Language.getMessage("signs.cantcreate"));
return;
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onSignChange(SignChangeEvent event) {
if (!plugin.isEnabled())
return;
String jobname = ChatColor.stripColor(event.getLine(2)).toLowerCase();
if (!ConfigManager.getJobsConfiguration().SignsEnabled)
return;
final Job job = Jobs.getJob(jobname);
if (ChatColor.stripColor(event.getLine(0)).equalsIgnoreCase(ChatColor.stripColor(Language.getMessage("signs.topline"))) && !ChatColor.stripColor(event.getLine(1)).equalsIgnoreCase("toplist"))
event.setLine(0, Convert(Language.getMessage("signs.topline")));
if (job == null && !signtype.equalsIgnoreCase("gtoplist")) {
player.sendMessage(Language.getMessage("command.top.error.nojob"));
return;
}
boolean special = false;
int Number = 0;
String numberString = ChatColor.stripColor(event.getLine(3)).toLowerCase();
if (numberString.contains("s")) {
numberString = numberString.replace("s", "");
special = true;
}
try {
Number = Integer.parseInt(numberString);
} catch (NumberFormatException e) {
player.sendMessage(Language.getMessage("command.error.notNumber"));
return;
}
Signs.Sign signInfo = new Signs.Sign();
Location loc = sign.getLocation();
int category = 1;
if (Signs.SignUtil.Signs.GetAllSigns().size() > 0)
category = Signs.SignUtil.Signs.GetAllSigns().get(Signs.SignUtil.Signs.GetAllSigns().size() - 1).GetCategory() + 1;
signInfo.setNumber(Number);
signInfo.setWorld(loc.getWorld().getName());
signInfo.setX(loc.getX());
signInfo.setY(loc.getY());
signInfo.setZ(loc.getZ());
signInfo.setCategory(category);
if (!signtype.equalsIgnoreCase("gtoplist"))
signInfo.setJobName(job.getName());
else
signInfo.setJobName("gtoplist");
signInfo.setSpecial(special);
Signs.SignUtil.Signs.addSign(signInfo);
Signs.SignUtil.saveSigns();
event.setCancelled(true);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(JobsPlugin.instance, new Runnable() {
public void run() {
if (!signtype.equalsIgnoreCase("gtoplist"))
Signs.SignUtil.SignUpdate(job.getName());
else
return;
Signs.SignUtil.SignUpdate("gtoplist");
return;
}
}, 1L);
}
if (!event.getPlayer().hasPermission("jobs.command.signs")) {
event.setCancelled(true);
event.getPlayer().sendMessage(Language.getMessage("signs.cantcreate"));
return;
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onSignChange(SignChangeEvent event) {
if (!plugin.isEnabled())
return;
String command = ChatColor.stripColor(event.getLine(1)).toLowerCase();
if (!ConfigManager.getJobsConfiguration().SignsEnabled)
return;
for (String key : ConfigManager.getJobsConfiguration().keys) {
if (command.equalsIgnoreCase(ChatColor.stripColor(Language.getMessage("signs.secondline." + key)))) {
event.setLine(1, Convert(Language.getMessage("signs.secondline." + key)));
break;
}
}
Job job = Jobs.getJob(ChatColor.stripColor(event.getLine(2)));
if (job == null)
return;
String color = ConfigManager.getJobsConfiguration().SignsColorizeJobName ? job.getChatColor().toString() : "";
event.setLine(2, Convert(color + job.getName()));
if (ChatColor.stripColor(event.getLine(0)).equalsIgnoreCase(ChatColor.stripColor(Language.getMessage("signs.topline"))) && !ChatColor.stripColor(event.getLine(1))
.equalsIgnoreCase("toplist"))
event.setLine(0, Convert(Language.getMessage("signs.topline")));
else
return;
if (!event.getPlayer().hasPermission("jobs.command.signs")) {
event.setCancelled(true);
event.getPlayer().sendMessage(Language.getMessage("signs.cantcreate"));
return;
}
private String Convert(String line) {
Pattern ReplacePatern = Pattern.compile("&([0-9a-fk-or])");
return ReplacePatern.matcher(ChatColor.translateAlternateColorCodes('&', line)).replaceAll("\u00a7$1");
String command = ChatColor.stripColor(event.getLine(1)).toLowerCase();
for (String key : ConfigManager.getJobsConfiguration().keys) {
if (command.equalsIgnoreCase(ChatColor.stripColor(Language.getMessage("signs.secondline." + key)))) {
event.setLine(1, Convert(Language.getMessage("signs.secondline." + key)));
break;
}
}
// Adding to chat prefix job name
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerChat(AsyncPlayerChatEvent event) {
if (!plugin.isEnabled())
return;
Job job = Jobs.getJob(ChatColor.stripColor(event.getLine(2)));
if (!ConfigManager.getJobsConfiguration().getModifyChat())
return;
if (job == null)
return;
Player player = event.getPlayer();
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
String color = ConfigManager.getJobsConfiguration().SignsColorizeJobName ? job.getChatColor().toString() : "";
event.setLine(2, Convert(color + job.getName()));
}
String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() + " " : "";
private String Convert(String line) {
Pattern ReplacePatern = Pattern.compile("&([0-9a-fk-or])");
return ReplacePatern.matcher(ChatColor.translateAlternateColorCodes('&', line)).replaceAll("\u00a7$1");
}
if (honorific.equalsIgnoreCase(" "))
honorific = "";
// Adding to chat prefix job name
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerChat(AsyncPlayerChatEvent event) {
if (!plugin.isEnabled())
return;
String format = event.getFormat();
format = format.replace("%1$s", honorific + "%1$s");
event.setFormat(format);
}
if (!ConfigManager.getJobsConfiguration().getModifyChat())
return;
// Changing chat prefix variable to job name
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerChatLow(AsyncPlayerChatEvent event) {
if (!plugin.isEnabled())
return;
if (ConfigManager.getJobsConfiguration().getModifyChat())
return;
Player player = event.getPlayer();
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() + " " : "";
if (honorific.equalsIgnoreCase(" "))
honorific = "";
String format = event.getFormat();
if (!format.contains("{jobs}"))
return;
format = format.replace("{jobs}", honorific);
event.setFormat(format);
}
Player player = event.getPlayer();
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
// Changing chat prefix variable to job name
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerChatHigh(AsyncPlayerChatEvent event) {
if (!plugin.isEnabled())
return;
if (ConfigManager.getJobsConfiguration().getModifyChat())
return;
Player player = event.getPlayer();
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() + " " : "";
if (honorific.equalsIgnoreCase(" "))
honorific = "";
String format = event.getFormat();
if (!format.contains("{jobs}"))
return;
format = format.replace("{jobs}", honorific);
event.setFormat(format);
}
String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() + " " : "";
@EventHandler(priority = EventPriority.MONITOR)
public void onWorldLoad(WorldLoadEvent event) {
World world = event.getWorld();
PluginManager pm = plugin.getServer().getPluginManager();
if (pm.getPermission("jobs.world." + world.getName().toLowerCase()) == null)
pm.addPermission(new Permission("jobs.world." + world.getName().toLowerCase(), PermissionDefault.TRUE));
}
if (honorific.equalsIgnoreCase(" "))
honorific = "";
String format = event.getFormat();
format = format.replace("%1$s", honorific + "%1$s");
event.setFormat(format);
}
// Changing chat prefix variable to job name
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerChatLow(AsyncPlayerChatEvent event) {
if (!plugin.isEnabled())
return;
if (ConfigManager.getJobsConfiguration().getModifyChat())
return;
Player player = event.getPlayer();
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() + " " : "";
if (honorific.equalsIgnoreCase(" "))
honorific = "";
String format = event.getFormat();
if (!format.contains("{jobs}"))
return;
format = format.replace("{jobs}", honorific);
event.setFormat(format);
}
// Changing chat prefix variable to job name
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerChatHigh(AsyncPlayerChatEvent event) {
if (!plugin.isEnabled())
return;
if (ConfigManager.getJobsConfiguration().getModifyChat())
return;
Player player = event.getPlayer();
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() + " " : "";
if (honorific.equalsIgnoreCase(" "))
honorific = "";
String format = event.getFormat();
if (!format.contains("{jobs}"))
return;
format = format.replace("{jobs}", honorific);
event.setFormat(format);
}
@EventHandler(priority = EventPriority.MONITOR)
public void onWorldLoad(WorldLoadEvent event) {
World world = event.getWorld();
PluginManager pm = plugin.getServer().getPluginManager();
if (pm.getPermission("jobs.world." + world.getName().toLowerCase()) == null)
pm.addPermission(new Permission("jobs.world." + world.getName().toLowerCase(), PermissionDefault.TRUE));
}
}

View File

@ -925,7 +925,6 @@ public class JobsPaymentListener implements Listener {
Jobs.action(jDamager, new CustomKillInfo(job.getJob().getName(), ActionType.CUSTOMKILL), multiplier, item, armor);
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)

View File

@ -1,7 +1,7 @@
name: Jobs
description: Jobs Plugin for the BukkitAPI
main: com.gamingmesh.jobs.JobsPlugin
version: 2.48.0
version: 2.48.1
author: phrstbrn
softdepend: [Vault]
commands: