Some bugfixes related to slabs, half blocks and some improved messages

This commit is contained in:
Olof Larsson 2011-04-07 17:26:58 +02:00
parent efd1ea40dd
commit 1dcc0246a5
9 changed files with 32 additions and 4 deletions

View File

@ -1,5 +1,5 @@
name: AncientGates name: AncientGates
version: 1.0.0 version: 1.0.1
main: org.mcteam.ancientgates.Plugin main: org.mcteam.ancientgates.Plugin
commands: commands:
gate: gate:

View File

@ -30,6 +30,7 @@ public class CommandList extends BaseCommand {
return; return;
} }
sendMessage("There are currently "+ids.size()+" gates on this server: ");
sendMessage(TextUtil.implode(ids, Conf.colorSystem+", ")); sendMessage(TextUtil.implode(ids, Conf.colorSystem+", "));
} }

View File

@ -1,5 +1,7 @@
package org.mcteam.ancientgates.commands; package org.mcteam.ancientgates.commands;
import org.bukkit.Material;
public class CommandOpen extends BaseCommand { public class CommandOpen extends BaseCommand {
public CommandOpen() { public CommandOpen() {
@ -22,6 +24,11 @@ public class CommandOpen extends BaseCommand {
sendMessage("To fix that: " + new CommandSetTo().getUseageTemplate(true, true)); sendMessage("To fix that: " + new CommandSetTo().getUseageTemplate(true, true));
} }
if (gate.getFrom().getBlock().getType() != Material.AIR) {
sendMessage("The gate could not open. The from location is not air.");
return;
}
if (gate.open()) { if (gate.open()) {
sendMessage("The gate was opened."); sendMessage("The gate was opened.");
} else { } else {

View File

@ -1,5 +1,8 @@
package org.mcteam.ancientgates.commands; package org.mcteam.ancientgates.commands;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.mcteam.ancientgates.Gate; import org.mcteam.ancientgates.Gate;
public class CommandSetFrom extends BaseCommand { public class CommandSetFrom extends BaseCommand {
@ -13,7 +16,20 @@ public class CommandSetFrom extends BaseCommand {
} }
public void perform() { public void perform() {
gate.setFrom(player.getLocation()); // The player might stand in a halfblock or a sign or whatever
// Therefore we load som extra locations and blocks
Block playerBlock = player.getLocation().getBlock();
Block upBlock = playerBlock.getFace(BlockFace.UP);
if (playerBlock.getType() == Material.AIR) {
gate.setFrom(playerBlock.getLocation());
} else if (upBlock.getType() == Material.AIR) {
gate.setFrom(upBlock.getLocation());
} else {
sendMessage("There is not enough room for a gate to open here");
return;
}
sendMessage("From location for gate \""+gate.getId()+"\" is now where you stand."); sendMessage("From location for gate \""+gate.getId()+"\" is now where you stand.");
sendMessage("Build a frame around that block and:"); sendMessage("Build a frame around that block and:");
sendMessage(new CommandOpen().getUseageTemplate(true, true)); sendMessage(new CommandOpen().getUseageTemplate(true, true));

View File

@ -7,6 +7,7 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.mcteam.ancientgates.Conf; import org.mcteam.ancientgates.Conf;
@ -22,11 +23,14 @@ public class PluginPlayerListener extends PlayerListener {
return; return;
} }
if (event.getTo().getBlock().getType() != Material.PORTAL) { Block blockTo = event.getTo().getBlock();
Block blockToUp = blockTo.getFace(BlockFace.UP);
if (blockTo.getType() != Material.PORTAL && blockToUp.getType() != Material.PORTAL) {
return; return;
} }
// Ok so a player walks into a partal block // Ok so a player walks into a portal block
// Find the nearest gate! // Find the nearest gate!
Gate nearestGate = null; Gate nearestGate = null;
Location playerLocation = event.getPlayer().getLocation(); Location playerLocation = event.getPlayer().getLocation();