Special Signs Improvements
This commit is contained in:
parent
603db8079b
commit
4e6fdd9df4
@ -3,7 +3,9 @@ package com.massivecraft.massivecore.util;
|
|||||||
import java.security.InvalidParameterException;
|
import java.security.InvalidParameterException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -12,6 +14,7 @@ import org.bukkit.block.Block;
|
|||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.block.SignChangeEvent;
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
@ -201,17 +204,35 @@ public class SignUtil
|
|||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected final static Set<Action> VALID_INTERACT_ACTIONS = EnumSet.of(
|
||||||
|
// Action.LEFT_CLICK_BLOCK, // We must allow breaking the sign.
|
||||||
|
Action.RIGHT_CLICK_BLOCK
|
||||||
|
);
|
||||||
public static List<String> getSpecialPillarLines(PlayerInteractEvent event, String title)
|
public static List<String> getSpecialPillarLines(PlayerInteractEvent event, String title)
|
||||||
{
|
{
|
||||||
|
// Arguments
|
||||||
if (event == null) throw new NullPointerException("event");
|
if (event == null) throw new NullPointerException("event");
|
||||||
if (title == null) throw new NullPointerException("title");
|
if (title == null) throw new NullPointerException("title");
|
||||||
|
|
||||||
|
// Player
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
if (MUtil.isntPlayer(player)) return null;
|
||||||
|
|
||||||
|
// Action
|
||||||
|
if ( ! VALID_INTERACT_ACTIONS.contains(event.getAction())) return null;
|
||||||
|
|
||||||
|
// Block
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
if (block == null) return null;
|
if (block == null) return null;
|
||||||
|
|
||||||
|
// Lines
|
||||||
List<String> lines = getSpecialPillarLines(block, title);
|
List<String> lines = getSpecialPillarLines(block, title);
|
||||||
if (lines == null) return null;
|
if (lines == null) return null;
|
||||||
|
|
||||||
|
// Cancel
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
// Return
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,5 +308,4 @@ public class SignUtil
|
|||||||
return new ArrayList<String>(Arrays.asList(sign.getLines()));
|
return new ArrayList<String>(Arrays.asList(sign.getLines()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user