4 Commits

6 changed files with 24 additions and 11 deletions

View File

@ -386,6 +386,12 @@ portalInfoServer=Server: %server%
# Changes # Changes
#### \[Version 0.9.0.7] EpicKnarvik97 fork
- Stops registering the sign as a lookup block for stargates without a sign
- Only removes a stargate's button if it's actually a button-compatible block
- Only displays portal info if not placing a block
#### \[Version 0.9.0.6] EpicKnarvik97 fork #### \[Version 0.9.0.6] EpicKnarvik97 fork
- Makes containers no longer open when used as buttons - Makes containers no longer open when used as buttons

View File

@ -4,7 +4,7 @@
<groupId>net.knarcraft</groupId> <groupId>net.knarcraft</groupId>
<artifactId>Stargate</artifactId> <artifactId>Stargate</artifactId>
<version>0.9.0.6</version> <version>0.9.0.7</version>
<licenses> <licenses>
<license> <license>

View File

@ -28,6 +28,8 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
/** /**
* This listener listens to any player-related events related to stargates * This listener listens to any player-related events related to stargates
@ -186,7 +188,7 @@ public class PlayerEventListener implements Listener {
} }
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
handleRightClickBlock(event, player, block); handleRightClickBlock(event, player, block, event.getHand());
} else if (event.getAction() == Action.LEFT_CLICK_BLOCK && block.getBlockData() instanceof WallSign) { } else if (event.getAction() == Action.LEFT_CLICK_BLOCK && block.getBlockData() instanceof WallSign) {
//Handle left click of a wall sign //Handle left click of a wall sign
handleSignClick(event, player, block, true); handleSignClick(event, player, block, true);
@ -259,8 +261,9 @@ public class PlayerEventListener implements Listener {
* @param event <p>The event triggering the right-click</p> * @param event <p>The event triggering the right-click</p>
* @param player <p>The player doing the right-click</p> * @param player <p>The player doing the right-click</p>
* @param block <p>The block the player clicked</p> * @param block <p>The block the player clicked</p>
* @param hand <p>The hand the player used to interact with the stargate</p>
*/ */
private void handleRightClickBlock(PlayerInteractEvent event, Player player, Block block) { private void handleRightClickBlock(PlayerInteractEvent event, Player player, Block block, EquipmentSlot hand) {
if (block.getBlockData() instanceof WallSign) { if (block.getBlockData() instanceof WallSign) {
handleSignClick(event, player, block, false); handleSignClick(event, player, block, false);
return; return;
@ -272,7 +275,6 @@ public class PlayerEventListener implements Listener {
} }
if (MaterialHelper.isButtonCompatible(block.getType())) { if (MaterialHelper.isButtonCompatible(block.getType())) {
Portal portal = PortalHandler.getByBlock(block); Portal portal = PortalHandler.getByBlock(block);
if (portal == null) { if (portal == null) {
return; return;
@ -293,7 +295,10 @@ public class PlayerEventListener implements Listener {
} }
} else { } else {
//Display information about the portal if it has no sign //Display information about the portal if it has no sign
displayPortalInfo(block, player); ItemStack heldItem = player.getInventory().getItem(hand);
if (heldItem.getType().isAir() || !heldItem.getType().isBlock()) {
displayPortalInfo(block, player);
}
} }
} }
@ -315,9 +320,9 @@ public class PlayerEventListener implements Listener {
if (portal.getOptions().hasNoSign() && !portal.getOptions().isSilent()) { if (portal.getOptions().hasNoSign() && !portal.getOptions().isSilent()) {
MessageSender sender = Stargate.getMessageSender(); MessageSender sender = Stargate.getMessageSender();
sender.sendSuccessMessage(player, ChatColor.GOLD + Stargate.getString("portalInfoTitle")); sender.sendSuccessMessage(player, ChatColor.GOLD + Stargate.getString("portalInfoTitle"));
sender.sendSuccessMessage(player, Stargate.replaceVars(Stargate.getString("portalInfoName"), sender.sendSuccessMessage(player, Stargate.replaceVars(Stargate.getString("portalInfoName"),
"%name%", portal.getName())); "%name%", portal.getName()));
sender.sendSuccessMessage(player, Stargate.replaceVars(Stargate.getString("portalInfoDestination"), sender.sendSuccessMessage(player, Stargate.replaceVars(Stargate.getString("portalInfoDestination"),
"%destination%", portal.getDestinationName())); "%destination%", portal.getDestinationName()));
if (portal.getOptions().isBungee()) { if (portal.getOptions().isBungee()) {
sender.sendSuccessMessage(player, Stargate.replaceVars(Stargate.getString("portalInfoServer"), sender.sendSuccessMessage(player, Stargate.replaceVars(Stargate.getString("portalInfoServer"),

View File

@ -271,8 +271,10 @@ public class PortalRegistry {
lookupBlocks.put(block, portal); lookupBlocks.put(block, portal);
} }
//Register the sign and button to the lookup lists //Register the sign and button to the lookup lists
lookupBlocks.put(portal.getSignLocation(), portal); if (!portal.getOptions().hasNoSign()) {
lookupControls.put(portal.getSignLocation(), portal); lookupBlocks.put(portal.getSignLocation(), portal);
lookupControls.put(portal.getSignLocation(), portal);
}
BlockLocation button = portal.getStructure().getButton(); BlockLocation button = portal.getStructure().getButton();
if (button != null) { if (button != null) {

View File

@ -295,7 +295,7 @@ public final class PortalFileHelper {
BlockData buttonData = buttonLocation.getBlock().getBlockData(); BlockData buttonData = buttonLocation.getBlock().getBlockData();
if (portal.getOptions().isAlwaysOn()) { if (portal.getOptions().isAlwaysOn()) {
//Clear button if not already air or water //Clear button if not already air or water
if (buttonData.getMaterial() != Material.AIR && buttonData.getMaterial() != Material.WATER) { if (MaterialHelper.isButtonCompatible(buttonData.getMaterial())) {
Material newMaterial = decideRemovalMaterial(buttonLocation, portal); Material newMaterial = decideRemovalMaterial(buttonLocation, portal);
Stargate.addBlockChangeRequest(new BlockChangeRequest(buttonLocation, newMaterial, null)); Stargate.addBlockChangeRequest(new BlockChangeRequest(buttonLocation, newMaterial, null));
} }

View File

@ -1,6 +1,6 @@
name: Stargate name: Stargate
main: net.knarcraft.stargate.Stargate main: net.knarcraft.stargate.Stargate
version: 0.9.0.6 version: 0.9.0.7
description: Stargate mod for Bukkit Revived description: Stargate mod for Bukkit Revived
author: EpicKnarvik97 author: EpicKnarvik97
authors: [ Drakia, PseudoKnight, EpicKnarvik97 ] authors: [ Drakia, PseudoKnight, EpicKnarvik97 ]