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,6 +51,8 @@ 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;
@ -238,6 +241,63 @@ public class JobsListener implements Listener {
Bukkit.dispatchCommand(player, "jobs " + command + " " + ChatColor.stripColor(sign.getLine(2)) + " " + ChatColor.stripColor(sign.getLine(3)));
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onSignDestroy(BlockBreakEvent event) {
if (!plugin.isEnabled())
return;
if (!ConfigManager.getJobsConfiguration().SignsEnabled)
return;
Material material = event.getBlock().getType();
if (material != Material.WALL_SIGN && material != Material.SIGN && material != Material.SIGN_POST)
return;
Block block = event.getBlock();
if (block == null)
return;
if (!(block.getState() instanceof Sign))
return;
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();
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())
@ -335,7 +395,8 @@ public class JobsListener implements Listener {
if (!ConfigManager.getJobsConfiguration().SignsEnabled)
return;
if (ChatColor.stripColor(event.getLine(0)).equalsIgnoreCase(ChatColor.stripColor(Language.getMessage("signs.topline"))) && !ChatColor.stripColor(event.getLine(1)).equalsIgnoreCase("toplist"))
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;
@ -362,7 +423,6 @@ public class JobsListener implements Listener {
String color = ConfigManager.getJobsConfiguration().SignsColorizeJobName ? job.getChatColor().toString() : "";
event.setLine(2, Convert(color + job.getName()));
}
private String Convert(String line) {

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: