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:
parent
401c6c1c6d
commit
320b9c08f4
@ -24,10 +24,7 @@ import java.lang.reflect.Method;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
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.JobItems;
|
||||||
import com.gamingmesh.jobs.container.JobProgression;
|
import com.gamingmesh.jobs.container.JobProgression;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
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.container.TopList;
|
||||||
import com.gamingmesh.jobs.economy.PaymentData;
|
import com.gamingmesh.jobs.economy.PaymentData;
|
||||||
import com.gamingmesh.jobs.i18n.Language;
|
import com.gamingmesh.jobs.i18n.Language;
|
||||||
|
@ -1343,6 +1343,7 @@ public class JobsConfiguration {
|
|||||||
GetConfigString("signs.SpecialList.3.3", "&8[level] level", writer, conf, true);
|
GetConfigString("signs.SpecialList.3.3", "&8[level] level", writer, conf, true);
|
||||||
GetConfigString("signs.SpecialList.3.4", "&b************", 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.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.topline", "&2[Jobs]", writer, conf, true);
|
||||||
GetConfigString("signs.secondline.join", "&2Join", writer, conf, true);
|
GetConfigString("signs.secondline.join", "&2Join", writer, conf, true);
|
||||||
GetConfigString("signs.secondline.leave", "&4Leave", writer, conf, true);
|
GetConfigString("signs.secondline.leave", "&4Leave", writer, conf, true);
|
||||||
|
@ -32,6 +32,7 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.SignChangeEvent;
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
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.container.JobsPlayer;
|
||||||
import com.gamingmesh.jobs.i18n.Language;
|
import com.gamingmesh.jobs.i18n.Language;
|
||||||
|
|
||||||
|
import Signs.SignUtil;
|
||||||
|
|
||||||
public class JobsListener implements Listener {
|
public class JobsListener implements Listener {
|
||||||
// hook to the main plugin
|
// hook to the main plugin
|
||||||
private JobsPlugin plugin;
|
private JobsPlugin plugin;
|
||||||
|
|
||||||
public JobsListener(JobsPlugin plugin) {
|
public JobsListener(JobsPlugin plugin) {
|
||||||
this.plugin = 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)
|
Bukkit.dispatchCommand(player, "jobs " + command + " " + ChatColor.stripColor(sign.getLine(2)) + " " + ChatColor.stripColor(sign.getLine(3)));
|
||||||
// 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)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onSignDestroy(BlockBreakEvent event) {
|
||||||
// make sure plugin is enabled
|
|
||||||
if (!plugin.isEnabled())
|
|
||||||
return;
|
|
||||||
Jobs.getPlayerManager().playerJoin(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
if (!plugin.isEnabled())
|
||||||
public void onPlayerJoinMonitor(PlayerJoinEvent event) {
|
return;
|
||||||
// make sure plugin is enabled
|
|
||||||
if (!plugin.isEnabled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
/*
|
if (!ConfigManager.getJobsConfiguration().SignsEnabled)
|
||||||
* We need to recalculate again to check for world permission and revoke permissions
|
return;
|
||||||
* 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)
|
Material material = event.getBlock().getType();
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
|
||||||
// make sure plugin is enabled
|
|
||||||
if (!plugin.isEnabled())
|
|
||||||
return;
|
|
||||||
Jobs.getPlayerManager().playerQuit(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
if (material != Material.WALL_SIGN && material != Material.SIGN && material != Material.SIGN_POST)
|
||||||
public void onPlayerWorldChange(PlayerChangedWorldEvent event) {
|
return;
|
||||||
if (!plugin.isEnabled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
|
Block block = event.getBlock();
|
||||||
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
if (block == null)
|
||||||
public void onSignInteract(PlayerInteractEvent event) {
|
return;
|
||||||
|
|
||||||
if (!plugin.isEnabled())
|
if (!(block.getState() instanceof Sign))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!ConfigManager.getJobsConfiguration().SignsEnabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Player player = (Player) event.getPlayer();
|
Player player = (Player) event.getPlayer();
|
||||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
|
||||||
return;
|
Sign sign = (Sign) block.getState();
|
||||||
|
String FirstLine = sign.getLine(0);
|
||||||
Material material = event.getClickedBlock().getType();
|
if (FirstLine.equalsIgnoreCase(Language.getMessage("signs.topline")))
|
||||||
|
if (!player.hasPermission("jobs.command.signs")) {
|
||||||
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();
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
player.sendMessage(Language.getMessage("signs.cantdestroy"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Location loc = block.getLocation();
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(JobsPlugin.instance, new Runnable() {
|
for (Signs.Sign one : SignUtil.Signs.GetAllSigns()) {
|
||||||
public void run() {
|
|
||||||
if (!signtype.equalsIgnoreCase("gtoplist"))
|
if (one.GetX() != loc.getBlockX())
|
||||||
Signs.SignUtil.SignUpdate(job.getName());
|
continue;
|
||||||
else
|
if (one.GetY() != loc.getBlockY())
|
||||||
Signs.SignUtil.SignUpdate("gtoplist");
|
continue;
|
||||||
return;
|
if (one.GetZ() != loc.getBlockZ())
|
||||||
}
|
continue;
|
||||||
}, 1L);
|
|
||||||
|
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)
|
String jobname = ChatColor.stripColor(event.getLine(2)).toLowerCase();
|
||||||
public void onSignChange(SignChangeEvent event) {
|
|
||||||
if (!plugin.isEnabled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!ConfigManager.getJobsConfiguration().SignsEnabled)
|
final Job job = Jobs.getJob(jobname);
|
||||||
return;
|
|
||||||
|
|
||||||
if (ChatColor.stripColor(event.getLine(0)).equalsIgnoreCase(ChatColor.stripColor(Language.getMessage("signs.topline"))) && !ChatColor.stripColor(event.getLine(1)).equalsIgnoreCase("toplist"))
|
if (job == null && !signtype.equalsIgnoreCase("gtoplist")) {
|
||||||
event.setLine(0, Convert(Language.getMessage("signs.topline")));
|
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
|
else
|
||||||
return;
|
Signs.SignUtil.SignUpdate("gtoplist");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}, 1L);
|
||||||
|
}
|
||||||
|
|
||||||
if (!event.getPlayer().hasPermission("jobs.command.signs")) {
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
event.setCancelled(true);
|
public void onSignChange(SignChangeEvent event) {
|
||||||
event.getPlayer().sendMessage(Language.getMessage("signs.cantcreate"));
|
if (!plugin.isEnabled())
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
String command = ChatColor.stripColor(event.getLine(1)).toLowerCase();
|
if (!ConfigManager.getJobsConfiguration().SignsEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
for (String key : ConfigManager.getJobsConfiguration().keys) {
|
if (ChatColor.stripColor(event.getLine(0)).equalsIgnoreCase(ChatColor.stripColor(Language.getMessage("signs.topline"))) && !ChatColor.stripColor(event.getLine(1))
|
||||||
if (command.equalsIgnoreCase(ChatColor.stripColor(Language.getMessage("signs.secondline." + key)))) {
|
.equalsIgnoreCase("toplist"))
|
||||||
event.setLine(1, Convert(Language.getMessage("signs.secondline." + key)));
|
event.setLine(0, Convert(Language.getMessage("signs.topline")));
|
||||||
break;
|
else
|
||||||
}
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
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 (!event.getPlayer().hasPermission("jobs.command.signs")) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
event.getPlayer().sendMessage(Language.getMessage("signs.cantcreate"));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String Convert(String line) {
|
String command = ChatColor.stripColor(event.getLine(1)).toLowerCase();
|
||||||
Pattern ReplacePatern = Pattern.compile("&([0-9a-fk-or])");
|
|
||||||
return ReplacePatern.matcher(ChatColor.translateAlternateColorCodes('&', line)).replaceAll("\u00a7$1");
|
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
|
Job job = Jobs.getJob(ChatColor.stripColor(event.getLine(2)));
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
|
||||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
|
||||||
if (!plugin.isEnabled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!ConfigManager.getJobsConfiguration().getModifyChat())
|
if (job == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
String color = ConfigManager.getJobsConfiguration().SignsColorizeJobName ? job.getChatColor().toString() : "";
|
||||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
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(" "))
|
// Adding to chat prefix job name
|
||||||
honorific = "";
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
|
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||||
|
if (!plugin.isEnabled())
|
||||||
|
return;
|
||||||
|
|
||||||
String format = event.getFormat();
|
if (!ConfigManager.getJobsConfiguration().getModifyChat())
|
||||||
format = format.replace("%1$s", honorific + "%1$s");
|
return;
|
||||||
event.setFormat(format);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Changing chat prefix variable to job name
|
Player player = event.getPlayer();
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||||
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
|
String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() + " " : "";
|
||||||
@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)
|
if (honorific.equalsIgnoreCase(" "))
|
||||||
public void onWorldLoad(WorldLoadEvent event) {
|
honorific = "";
|
||||||
World world = event.getWorld();
|
|
||||||
PluginManager pm = plugin.getServer().getPluginManager();
|
String format = event.getFormat();
|
||||||
if (pm.getPermission("jobs.world." + world.getName().toLowerCase()) == null)
|
format = format.replace("%1$s", honorific + "%1$s");
|
||||||
pm.addPermission(new Permission("jobs.world." + world.getName().toLowerCase(), PermissionDefault.TRUE));
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -925,7 +925,6 @@ public class JobsPaymentListener implements Listener {
|
|||||||
Jobs.action(jDamager, new CustomKillInfo(job.getJob().getName(), ActionType.CUSTOMKILL), multiplier, item, armor);
|
Jobs.action(jDamager, new CustomKillInfo(job.getJob().getName(), ActionType.CUSTOMKILL), multiplier, item, armor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: Jobs
|
name: Jobs
|
||||||
description: Jobs Plugin for the BukkitAPI
|
description: Jobs Plugin for the BukkitAPI
|
||||||
main: com.gamingmesh.jobs.JobsPlugin
|
main: com.gamingmesh.jobs.JobsPlugin
|
||||||
version: 2.48.0
|
version: 2.48.1
|
||||||
author: phrstbrn
|
author: phrstbrn
|
||||||
softdepend: [Vault]
|
softdepend: [Vault]
|
||||||
commands:
|
commands:
|
||||||
|
Loading…
Reference in New Issue
Block a user