NEW gameplay feature with setting to disable

This commit is contained in:
PikaMug 2020-10-23 02:08:01 -04:00
parent b7183db984
commit 3151801901

View File

@ -168,18 +168,31 @@ public class PlayerListener implements Listener {
// Do nothing, getHand() not present pre-1.9 // Do nothing, getHand() not present pre-1.9
} }
if (e == null || e.equals(EquipmentSlot.HAND)) { // If the event is fired by HAND (main hand) if (e == null || e.equals(EquipmentSlot.HAND)) { // If the event is fired by HAND (main hand)
if (evt.hasBlock() && ItemUtil.isJournal(evt.getPlayer().getItemInHand())) { if (ItemUtil.isJournal(evt.getPlayer().getItemInHand())) {
if (evt.getClickedBlock().getType().name().contains("PORTAL") if (evt.hasBlock()) {
&& plugin.getSettings().canAllowPranks()) { if (evt.getClickedBlock().getType().name().equals("LECTERN")) {
evt.setCancelled(true);
evt.getPlayer().sendMessage(ChatColor.RED + Lang.get(evt.getPlayer(), "journalDenied")
.replace("<journal>", Lang.get(evt.getPlayer(), "journalTitle")));
return;
}
if (plugin.getSettings().canAllowPranks()
&& evt.getClickedBlock().getType().name().contains("PORTAL")) {
evt.setCancelled(true); evt.setCancelled(true);
evt.getPlayer().sendMessage(" " + ChatColor.AQUA + ChatColor.UNDERLINE evt.getPlayer().sendMessage(" " + ChatColor.AQUA + ChatColor.UNDERLINE
+ "https://www.youtube.com/watch?v=dQw4w9WgXcQ"); + "https://www.youtube.com/watch?v=dQw4w9WgXcQ");
return; return;
} }
if (evt.getClickedBlock().getType().name().equals("LECTERN")) { }
if (plugin.getSettings().canAllowPranks()
&& evt.getPlayer().getInventory().getHelmet() != null
&& (evt.getPlayer().getInventory().getHelmet().getType().name().equals("PUMPKIN")
|| evt.getPlayer().getInventory().getHelmet().getType().name().equals("CARVED_PUMPKIN"))) {
if (!evt.getAction().equals(Action.RIGHT_CLICK_AIR)) {
evt.getPlayer().sendMessage(" " + ChatColor.AQUA + ChatColor.UNDERLINE
+ "https://www.youtube.com/watch?v=v4IC7qaNr7I");
}
evt.setCancelled(true); evt.setCancelled(true);
evt.getPlayer().sendMessage(ChatColor.RED + Lang.get(evt.getPlayer(), "journalDenied")
.replace("<journal>", Lang.get(evt.getPlayer(), "journalTitle")));
return; return;
} }
} }