7 Commits

11 changed files with 97 additions and 43 deletions

View File

@ -1,3 +1,6 @@
## 2.1.2
* Fixed a bug where players got teleported one block beside the real portal.
* Fixed a bug where gates with no location caused multiply exceptions.
## 2.1.1 ## 2.1.1
* Made the list command more reliable. * Made the list command more reliable.
* Error messages will be displayed less frequent. * Error messages will be displayed less frequent.

View File

@ -1,5 +1,5 @@
name: Craft Inc. Gates name: Craft Inc. Gates
version: 2.1.1 version: 2.1.2
description: A plugin to create gates for fast traveling. description: A plugin to create gates for fast traveling.
softdepend: [Vault] softdepend: [Vault]
author: tomco, s1m0ne author: tomco, s1m0ne

68
pom.xml
View File

@ -5,41 +5,79 @@
<groupId>de.craftinc</groupId> <groupId>de.craftinc</groupId>
<artifactId>CraftIncGates</artifactId> <artifactId>CraftIncGates</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.1.1</version> <version>2.1.2</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<version>1.2.1</version>
<executions>
<execution>
<id>Run Test Bukkit Server</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${basedir}/scripts/test-deployment.sh</executable>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId> <artifactId>bukkit</artifactId>
<version>RELEASE</version> <version>1.5.2-R0.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.5.2-R0.1</version>
<type>jar</type> <type>jar</type>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.milkbowl.vault</groupId> <groupId>net.milkbowl.vault</groupId>
<artifactId>Vault</artifactId> <artifactId>Vault</artifactId>
<version>1.2.23-SNAPSHOT</version> <version>1.2.26-SNAPSHOT</version>
<type>jar</type> <type>jar</type>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<directory>target</directory>
<outputDirectory>target/classes</outputDirectory>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>resources</directory>
</resource>
</resources>
</build>
<repositories> <repositories>
<repository> <repository>
<id>bukkit-repo</id> <id>bukkit-repo</id>

View File

@ -177,7 +177,7 @@ public abstract class BaseGate
throw new Exception("Gate got closed. It has no exit."); throw new Exception("Gate got closed. It has no exit.");
} }
if (gateBlockLocations.size() == 0) { if (gateBlockLocations == null || gateBlockLocations.size() == 0) {
setOpen(false); setOpen(false);
throw new Exception("Gate got closed. The frame is missing or broken."); throw new Exception("Gate got closed. The frame is missing or broken.");
} }

View File

@ -142,8 +142,10 @@ public class Gate extends BaseGate implements ConfigurationSerializable
retVal.put(exitYawKey, exit.getYaw()); retVal.put(exitYawKey, exit.getYaw());
} }
retVal.put(locationPitchKey, location.getPitch()); if (location != null) {
retVal.put(locationYawKey, location.getYaw()); retVal.put(locationPitchKey, location.getPitch());
retVal.put(locationYawKey, location.getYaw());
}
List<Map<String, Object>> serializedGateBlocks = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> serializedGateBlocks = new ArrayList<Map<String, Object>>();

View File

@ -142,7 +142,7 @@ public abstract class BaseCommand
*/ */
protected boolean hasPermission() protected boolean hasPermission()
{ {
if (Plugin.permission == null) // fallback <20> use the standard bukkit permission system if (Plugin.permission == null) // fallback <20> use the standard bukkit permission system
{ {
return this.sender.hasPermission(this.requiredPermission); return this.sender.hasPermission(this.requiredPermission);
} }
@ -156,7 +156,7 @@ public abstract class BaseCommand
} }
else else
{ {
// sender is no player <20> there is no information about the senders locations // sender is no player <20> there is no information about the senders locations
return Plugin.permission.has(this.sender, this.requiredPermission); return Plugin.permission.has(this.sender, this.requiredPermission);
} }
@ -205,17 +205,23 @@ public abstract class BaseCommand
{ {
return false; return false;
} }
boolean permAtLocation = Plugin.permission.has(this.gate.getLocation().getWorld(), p.getName(), this.requiredPermission); boolean permAtLocation;
if (this.gate.getLocation() == null) {
permAtLocation = true;
}
else {
permAtLocation = Plugin.permission.has(this.gate.getLocation().getWorld(), p.getName(), this.requiredPermission);
}
boolean permAtExit; boolean permAtExit;
if (this.gate.getExit() == null) if (this.gate.getExit() == null) {
{
permAtExit = true; permAtExit = true;
} }
else else {
{
permAtExit = Plugin.permission.has(this.gate.getExit().getWorld(), p.getName(), this.requiredPermission); permAtExit = Plugin.permission.has(this.gate.getExit().getWorld(), p.getName(), this.requiredPermission);
} }

View File

@ -42,12 +42,14 @@ public class CommandCreate extends BaseLocationCommand
} }
catch (Exception e) catch (Exception e)
{ {
sendMessage(ChatColor.RED + "Creating the gate failed!" + e.getMessage() + "See server log for more information"); sendMessage(ChatColor.RED + "Creating the gate failed!" + e.getMessage() + " See server log for more information");
return; return;
} }
Location playerLocation = getValidPlayerLocation(); Location playerLocation = getValidPlayerLocation();
Plugin.log("player location:" + playerLocation);
if (playerLocation != null) if (playerLocation != null)
{ {
try try
@ -62,8 +64,7 @@ public class CommandCreate extends BaseLocationCommand
} }
else else
{ {
sendMessage(ChatColor.GREEN + "Gate with id \"" + id + "\" was created."); sendMessage("Now you should build a frame and execute:");
sendMessage("Now you should build a frame and:");
sendMessage(new CommandSetLocation().getUsageTemplate(true, true)); sendMessage(new CommandSetLocation().getUsageTemplate(true, true));
} }
} }

View File

@ -18,7 +18,7 @@ public class CommandInfo extends BaseCommand
requiredParameters.add("id"); requiredParameters.add("id");
helpDescription = "Prints detailed informations about a certain gate."; helpDescription = "Print detailed informations about a certain gate.";
requiredPermission = Plugin.permissionInfo; requiredPermission = Plugin.permissionInfo;
@ -49,12 +49,12 @@ public class CommandInfo extends BaseCommand
if (gate.getLocation() != null) if (gate.getLocation() != null)
sendMessage(ChatColor.DARK_AQUA + "from: " + ChatColor.AQUA + "( " + gate.getLocation().getBlockX() + " | " + gate.getLocation().getBlockY() + " | " + gate.getLocation().getBlockZ() + " ) in " + gate.getLocation().getWorld().getName()); sendMessage(ChatColor.DARK_AQUA + "from: " + ChatColor.AQUA + "( " + gate.getLocation().getBlockX() + " | " + gate.getLocation().getBlockY() + " | " + gate.getLocation().getBlockZ() + " ) in " + gate.getLocation().getWorld().getName());
else else
sendMessage(ChatColor.DARK_AQUA + "NOTE: this gate has no 'from' location"); sendMessage(ChatColor.DARK_AQUA + "NOTE: this gate has no location");
if (gate.getExit() != null) if (gate.getExit() != null)
sendMessage(ChatColor.DARK_AQUA + "to: " + ChatColor.AQUA + "( " + gate.getExit().getBlockX() + " | " + gate.getExit().getBlockY() + " | " + gate.getExit().getBlockZ() + " ) in " + gate.getExit().getWorld().getName()); sendMessage(ChatColor.DARK_AQUA + "to: " + ChatColor.AQUA + "( " + gate.getExit().getBlockX() + " | " + gate.getExit().getBlockY() + " | " + gate.getExit().getBlockZ() + " ) in " + gate.getExit().getWorld().getName());
else else
sendMessage(ChatColor.DARK_AQUA + "NOTE: this gate has no 'to' location"); sendMessage(ChatColor.DARK_AQUA + "NOTE: this gate has no exit");
} }
} }

View File

@ -144,10 +144,12 @@ public class CommandList extends BaseCommand
for (Gate gate : gatesCopy) { for (Gate gate : gatesCopy) {
boolean permissionAtGateLocation = Plugin.permission.has(gate.getLocation().getWorld(), p.getName(), this.requiredPermission); if (gate.getLocation() != null) {
if (!permissionAtGateLocation) { boolean permissionAtGateLocation = Plugin.permission.has(gate.getLocation().getWorld(), p.getName(), this.requiredPermission);
gates.remove(gate); if (!permissionAtGateLocation) {
continue; gates.remove(gate);
continue;
}
} }
if (gate.getExit() != null) { if (gate.getExit() != null) {

View File

@ -51,10 +51,13 @@ public class GateUtil
} }
// Check if the gate is open and useable // Check if the gate is open and useable
if (g.getLocation() == null) {
continue;
}
World gateWorld = g.getLocation().getWorld(); World gateWorld = g.getLocation().getWorld();
if (!g.isOpen() || !gateWorld.equals(playerWorld)) if (!g.isOpen() || !gateWorld.equals(playerWorld)) {
{
continue; continue;
} }

View File

@ -2,7 +2,6 @@ package de.craftinc.gates.util;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -90,13 +89,13 @@ public class LocationUtil
if (l1.getWorld() != l2.getWorld() && (l1.getWorld() == null || !l1.getWorld().equals(l2.getWorld()))) { if (l1.getWorld() != l2.getWorld() && (l1.getWorld() == null || !l1.getWorld().equals(l2.getWorld()))) {
return false; return false;
} }
if (new Double(l1.getX()).longValue() != new Double(l2.getX()).longValue()) { if (l1.getBlockX() != l2.getBlockX()) {
return false; return false;
} }
if (new Double(l1.getY()).longValue() != new Double(l2.getY()).longValue()) { if (l1.getBlockY() != l2.getBlockY()) {
return false; return false;
} }
if (new Double(l1.getZ()).longValue() != new Double(l2.getZ()).longValue()) { if (l1.getBlockZ() != l2.getBlockZ()) {
return false; return false;
} }