Skip to content

Commit

Permalink
Overlooked a cleanup I did
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleBigBug committed Jul 6, 2020
1 parent f38fd9f commit ee6b488
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/main/java/net/TheDgtl/Stargate/Stargate.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,9 @@ public static void sendMessage(CommandSender player, String message) {

public static void sendMessage(CommandSender player, String message, boolean error) {
if (message.isEmpty()) return;

message = message.replaceAll("(&([a-f0-9]))", "\u00A7$2");

if (error)
player.sendMessage(ChatColor.RED + Stargate.getString("prefix") + ChatColor.WHITE + message);
else
Expand Down Expand Up @@ -918,18 +920,17 @@ public void onPlayerMove(PlayerMoveEvent event) {

@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
Block block = event.getClickedBlock();
if (block == null) return;

Player player = event.getPlayer();
BlockData blockData = block.getBlockData();
Action action = event.getAction();

if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (action == Action.RIGHT_CLICK_BLOCK) {
Material blockMat = block.getType();

if (blockData instanceof WallSign
|| blockMat == Material.STONE_BUTTON || blockMat == Material.DEAD_TUBE_CORAL_WALL_FAN) {

if (blockMat == Material.STONE_BUTTON || blockMat == Material.DEAD_TUBE_CORAL_WALL_FAN) {
Portal portal = Portal.getByBlock(block);
if (portal == null) return;

Expand All @@ -956,7 +957,10 @@ public void onPlayerInteract(PlayerInteractEvent event) {
return;
}

if (event.getAction() == Action.LEFT_CLICK_BLOCK && blockData instanceof WallSign) {
if (blockData instanceof WallSign
&& (action == Action.LEFT_CLICK_BLOCK
|| action == Action.RIGHT_CLICK_BLOCK)) {

Portal portal = Portal.getByBlock(block);
if (portal == null) return;

Expand All @@ -978,7 +982,7 @@ public void onPlayerInteract(PlayerInteractEvent event) {
}

if ((!portal.isOpen()) && (!portal.isFixed())) {
portal.cycleDestination(player, -1);
portal.cycleDestination(player, action == Action.RIGHT_CLICK_BLOCK ? 1 : -1);
}
}
}
Expand Down

0 comments on commit ee6b488

Please sign in to comment.