22 Commits

Author SHA1 Message Date
7f89917e81 Updated version to 2.3.0. 2013-11-24 12:55:47 +01:00
a1cb0102f8 Changed the executing phase of deployment script. 2013-11-23 15:31:27 +01:00
5af520f8ea include mcstats in jar file when packaging with maven 2013-11-23 15:11:13 +01:00
28cacfdb19 Updated the changelog and other documents for the upcoming 2.3 release. 2013-11-16 17:54:33 +01:00
757d6b5a48 readme updated. 2013-11-16 15:40:53 +01:00
056b8896a6 Updated bukkit depency. 2013-11-16 15:40:45 +01:00
12a0bba6cc Print the names of nearby gates when executing /gate nb.
Fixed a serious bug when trying to print a very long title.
Made the info command work without a supplied gate id. It then will print information about the closest gate. (Issue #13)
2013-09-17 17:57:31 +02:00
e9a454182a Added the ability to change gate block types. Issue #26.
Refactoring: Added a ConfigurationUtil class. Moved all configuration keys into it.
2013-09-15 17:09:17 +02:00
260cabc509 Small typo fix. 2013-08-07 16:40:59 +02:00
0b29936958 Changed some text getting displayed while executing the info command. 2013-07-27 12:03:38 +02:00
efc30d0ae0 Added the nearby command. Issue #12 2013-07-24 10:39:37 +02:00
f4111fb34f Added a URL and license to the pom file. 2013-07-21 19:29:12 +02:00
37bce23e3d Updated a description inside the plugin.yml. 2013-07-18 12:09:50 +02:00
d5ff63c163 Added Plugin Metrics. 2013-07-16 12:09:20 +02:00
e60c735153 Removed the .settings folder. 2013-07-16 12:08:24 +02:00
013fad2b95 Added a license header to the exitopen command class. 2013-07-11 22:35:55 +02:00
5ace80e6d1 Added an exitopen command. This command will set the exit location of a gate and open it afterwards. 2013-07-11 22:35:01 +02:00
42b293e6bc Updated the pom file:
* Updated (craft-) bukkit dependencies to 1.6.2-R0.1-SNAPSHOT
* Bumped version 2.3.0-DEV
2013-07-11 22:33:38 +02:00
54545a9ee1 Updated the change log. 2013-07-10 22:14:55 +02:00
560bbf0394 Updated the pom file for version 2.2.1 2013-07-10 22:02:19 +02:00
2150cc66d0 Changed the event priority of the player teleport listener to MONITOR. 2013-07-10 22:02:05 +02:00
7673c3f674 Changed to event priority of the block break listener to MONITOR. This will resolve issues with third party protection plugins. See issue #25. 2013-07-10 20:43:52 +02:00
26 changed files with 615 additions and 102 deletions

View File

@ -1,12 +0,0 @@
#Wed Apr 06 16:59:25 CEST 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View File

@ -1,12 +1,12 @@
The following persons contributed to Craft Inc. Gates (previously named Ancient Gates):
CURRENT MAINTAINER
CURRENT MAINTAINERS
Tobias Ottenweller <mail@ottenweller.net>
Paul Schulze <info@paul-schulze.de>
FORMER CONTRIBUTOR (alphabetical order)
FORMER CONTRIBUTORS (alphabetical order)
Jacob Brunson <jacob@dimensionsmachine.com>
locutus <bladedpenguin@gmail.com>

View File

@ -75,15 +75,11 @@ allows players to build a replicator to replicate blocks and other items. (still
coming soon!
## Roadmap ##
* __Version 2.3__
* Info-Tools for gates. (Get the name of a gate you standing next to.)
* Search command for nearby gates. (Visually highlight nearby gates. Especially useful for hidden gates!)
* __Future__
* Optionally allow animals and mobs to travel via gates.
* Allow players to use gates while sitting inside a minecart or boat
* Dynmap integration.
* Per player permissions for using and managing gates.
* Horizontal gates.
* Optionally allow animals and mobs to travel via gates.
* Allow players to use gates while sitting inside a minecart or boat
* Dynmap integration.
* Per player permissions for using and managing gates.
* Horizontal gates.
## Bugs and other Problems ##
Please use our [_issue tracker_](https://github.com/craftinc/craftinc-gates/issues?state=open) on GitHub.

View File

@ -1,3 +1,13 @@
## 2.3.0 ##
* Added a command for setting the exit and opening a gate at once.
* Enabled the ability to change the gate block material.
* Added a command printing all nearby gates while highlighting them.
* Changed the info command to highlight gates.
* Updated the info command to print information about the nearest gate if no gate name got supplied.
## 2.2.1 ##
* Changed priority of some event listeners to solve problems with WorldGuard and other protection plugins.
## 2.2.0 ##
* Improved gate commands and shortcuts (have a look at the bukkit-dev page for more information).
* Improved overall performance.

View File

@ -7,6 +7,9 @@ Removes the gate from the game.
* __/gate exit, e [id]__
Changes the location where the gate will teleport players to your current location.
* __/gate exitopen, eo [id]__
Changes the location where the gate will teleport players to your current location. Also tries to open that gate afterwards.
* __/gate help, ? [page]__
Prints help pages.
@ -14,7 +17,7 @@ Prints help pages.
Makes a gate NOT consist of gate blocks while open.
* __/gate info, i [id]__
Prints details about a certain gate.
Prints details about a certain gate. Will print information about the nearest gate if no _id_ is supplied. Also highlights the gate you're requesting information about.
* __/gate list, ls [page]__
Prints all available gates.
@ -22,6 +25,9 @@ Prints all available gates.
* __/gate location, lo [id]__
Sets the entrance of the gate to your current location.
* __/gate nearby, nb__
Prints the name of nearby gates. Also highlights them.
* __/gate new, n [id]__
Creates a gate at your current location.

View File

@ -49,3 +49,7 @@ is set to _true_.
* __showTeleportNoPermissionMessage__
A boolean (_true_ or _false_) determining wether the _no permission message_ will
be displayed.
* __gateMaterial__
A String representing the material all gates will consist of. Have a look at our [_Gate Material Page_](http://dev.bukkit.org/bukkit-plugins/craftinc-gates/pages/gate-materials/) for all possible values.

27
doc/Gate Materials.md Normal file
View File

@ -0,0 +1,27 @@
Starting with version 2.3.0 different gate materials can be used. You can set them via the configuration file. The following Materials are currently defined:
* sapling
* water
* lava
* cobweb
* grass
* dead bush
* dandelion
* poppy
* brown mushroom
* red mushroom
* torch
* redstone torch (off)
* redstone torch (on)
* fence
* nether portal
* iron bars
* glass pane
* fence gate
* nether brick fence
* nether wart
* end portal
* cobblestone wall
Your favorite material is missing? Please contact us and we will see if we can add it.

View File

@ -16,7 +16,7 @@ commands:
permissions:
craftincgates.*:
description: Gives access to all ancient gates commands and lets you use open gates.
description: Gives access to all Craft Inc. Gates commands.
children:
craftincgates.info: true
craftincgates.use: true

66
pom.xml
View File

@ -5,13 +5,25 @@
<groupId>de.craftinc</groupId>
<artifactId>CraftIncGates</artifactId>
<name>Craft Inc. Gates</name>
<url>http://dev.bukkit.org/bukkit-plugins/craftinc-gates/</url>
<packaging>jar</packaging>
<version>2.2.0</version>
<version>2.3.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!-- License -->
<licenses>
<license>
<name>GNU Lesser General Public License Version 3</name>
<url>https://www.gnu.org/licenses/lgpl-3.0-standalone.html</url>
<distribution>repo</distribution>
</license>
</licenses>
<build>
<finalName>${project.name} ${project.version}</finalName>
<sourceDirectory>src</sourceDirectory>
@ -43,7 +55,7 @@
<executions>
<execution>
<id>Run Test Bukkit Server</id>
<phase>package</phase>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
@ -53,41 +65,73 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.7.1</version>
<configuration>
<artifactSet>
<includes>
<include>org.mcstats.bukkit:metrics</include>
</includes>
</artifactSet>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.5.2-R1.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.5.2-R1.0</version>
<version>1.6.4-R2.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>Vault</artifactId>
<version>1.2.26-SNAPSHOT</version>
<version>1.2.27-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mcstats.bukkit</groupId>
<artifactId>metrics</artifactId>
<version>R8-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public</url>
</repository>
<repository>
<id>vault-repo</id>
<url>http://ci.herocraftonline.com/plugin/repository/everything</url>
</repository>
<repository>
<id>Plugin Metrics</id>
<url>http://repo.mcstats.org/content/repositories/public</url>
</repository>
</repositories>
</project>

View File

@ -1,8 +1,10 @@
maxGateBlocks: 50
playerGateBlockUpdateRadius: 64
highlightDuration: 5
saveOnChanges: true
checkForBrokenGateFrames: true
gateTeleportMessage: "Thank you for traveling with Craft Inc. Gates."
showTeleportMessage: true
gateTeleportNoPermissionMessage: "You are not allowed to use this gate!"
showTeleportNoPermissionMessage: true
gateMaterial: "nether portal"

View File

@ -16,6 +16,7 @@
*/
package de.craftinc.gates;
import de.craftinc.gates.util.ConfigurationUtil;
import de.craftinc.gates.util.FloodUtil;
import de.craftinc.gates.persistence.LocationUtil;
import org.bukkit.Location;
@ -57,7 +58,7 @@ public class Gate implements ConfigurationSerializable
/**
*
* @return This method might return a 'null' value.
* @return This method might return a 'null' data.
*/
public Location getLocation()
{
@ -100,7 +101,7 @@ public class Gate implements ConfigurationSerializable
/**
*
* @param exit Supplying 'null' is permitted.
* @throws Exception An exception will be thrown if 'null' value is supplied and this gate is open. Note that the
* @throws Exception An exception will be thrown if 'null' data is supplied and this gate is open. Note that the
* supplied 'exit' will be set even if an exception is thrown. Note that this gate will be closed if an
* exception is thrown.
*/
@ -235,7 +236,7 @@ public class Gate implements ConfigurationSerializable
throw new Exception("Gate got closed. The frame is missing or broken. (no gate blocks)");
}
if (!isHidden() && Plugin.getPlugin().getConfig().getBoolean(Plugin.confCheckForBrokenGateFramesKey)) {
if (!isHidden() && Plugin.getPlugin().getConfig().getBoolean(ConfigurationUtil.confCheckForBrokenGateFramesKey)) {
for (Block b : gateFrameBlocks) {

View File

@ -24,6 +24,7 @@ import java.util.*;
import java.util.logging.Level;
import de.craftinc.gates.persistence.MigrationUtil;
import de.craftinc.gates.util.ConfigurationUtil;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.block.Block;
@ -67,6 +68,35 @@ public class GatesManager
}
/**
* Returns the closest gate.
* @param location The location at which to look for a gate.
* @return Might return null if there are no nearby gates.
*/
public Gate getNearestGate(final Location location)
{
Set<Gate> nearbyGates = getNearbyGates(location.getChunk());
if (nearbyGates == null) {
return null;
}
double minDist = Double.MAX_VALUE;
Gate nearestGate = null;
for (Gate g : nearbyGates) {
double dist = location.distance(g.getLocation());
if (dist < minDist) {
minDist = dist;
nearestGate = g;
}
}
return nearestGate;
}
public Gate getGateAtLocation(final Location location)
{
SimpleLocation simpleLocation = new SimpleLocation(location);
@ -193,7 +223,7 @@ public class GatesManager
protected int getChunkRadius()
{
if (this.chunkRadius == 0) {
this.chunkRadius = Plugin.getPlugin().getConfig().getInt(Plugin.confPlayerGateBlockUpdateRadiusKey);
this.chunkRadius = Plugin.getPlugin().getConfig().getInt(ConfigurationUtil.confPlayerGateBlockUpdateRadiusKey);
this.chunkRadius = this.chunkRadius >> 4;
}

View File

@ -16,12 +16,14 @@
*/
package de.craftinc.gates;
import java.io.IOException;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import de.craftinc.gates.listeners.*;
import de.craftinc.gates.util.ConfigurationUtil;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.ChatColor;
@ -33,6 +35,7 @@ import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import de.craftinc.gates.commands.*;
import org.mcstats.Metrics;
public class Plugin extends JavaPlugin
@ -41,15 +44,6 @@ public class Plugin extends JavaPlugin
public static final String permissionManage = "craftincgates.manage";
public static final String permissionUse = "craftincgates.use";
public static final String confMaxGateBlocksKey = "maxGateBlocks";
public static final String confPlayerGateBlockUpdateRadiusKey = "playerGateBlockUpdateRadius";
public static final String confCheckForBrokenGateFramesKey = "checkForBrokenGateFrames";
public static final String confGateTeleportMessageKey = "gateTeleportMessage";
public static final String confShowTeleportMessageKey = "showTeleportMessage";
public static final String confGateTeleportNoPermissionMessageKey = "gateTeleportNoPermissionMessage";
public static final String confShowTeleportNoPermissionMessageKey = "showTeleportNoPermissionMessage";
public static final String confSaveOnChangesKey = "saveOnChanges";
private static Plugin instance;
private static Permission permission;
@ -123,6 +117,15 @@ public class Plugin extends JavaPlugin
@Override
public void onEnable()
{
// Setup Metrics
try {
Metrics metrics = new Metrics(this);
metrics.start();
}
catch (IOException e) {
log("Failed to start metrics!");
}
// Setup configuration
this.saveDefaultConfig();
@ -142,6 +145,8 @@ public class Plugin extends JavaPlugin
commands.add(new CommandInfo());
commands.add(new CommandHide());
commands.add(new CommandUnhide());
commands.add(new CommandExitOpen());
commands.add(new CommandNearby());
// Register events
@ -170,7 +175,7 @@ public class Plugin extends JavaPlugin
pm.registerEvents(this.worldChangeListener, this);
pm.registerEvents(this.joinListener, this);
if (getConfig().getBoolean(confCheckForBrokenGateFramesKey)) {
if (getConfig().getBoolean(ConfigurationUtil.confCheckForBrokenGateFramesKey)) {
pm.registerEvents(this.blockBreakListener, this);
}
}

View File

@ -19,6 +19,7 @@ package de.craftinc.gates.commands;
import java.util.ArrayList;
import java.util.List;
import de.craftinc.gates.util.ConfigurationUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -69,7 +70,7 @@ public abstract class BaseCommand
this.perform();
if (this.shouldPersistToDisk && Plugin.getPlugin().getConfig().getBoolean(Plugin.confSaveOnChangesKey)) {
if (this.shouldPersistToDisk && Plugin.getPlugin().getConfig().getBoolean(ConfigurationUtil.confSaveOnChangesKey)) {
Plugin.getPlugin().getGatesManager().saveGatesToDisk();
}
}

View File

@ -0,0 +1,80 @@
/* Craft Inc. Gates
Copyright (C) 2011-2013 Craft Inc. Gates Team (see AUTHORS.txt)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program (LGPLv3). If not, see <http://www.gnu.org/licenses/>.
*/
package de.craftinc.gates.commands;
import de.craftinc.gates.Plugin;
import de.craftinc.gates.util.GateBlockChangeSender;
import org.bukkit.ChatColor;
import java.util.logging.Level;
public class CommandExitOpen extends BaseCommand
{
public CommandExitOpen()
{
aliases.add("exitopen");
aliases.add("eo");
requiredParameters.add("id");
helpDescription = "Change exit of location and open that gate afterwards.";
requiredPermission = Plugin.permissionManage;
needsPermissionAtCurrentLocation = true;
shouldPersistToDisk = true;
senderMustBePlayer = true;
}
public void perform()
{
try
{
gate.setExit(player.getLocation());
sendMessage(ChatColor.GREEN + "The exit of gate '" + gate.getId() + "' is now where you stand.");
try {
boolean needsGateManagerUpdate = false;
if (gate.getGateBlockLocations().isEmpty()) {
needsGateManagerUpdate = true;
}
gate.setOpen(true);
GateBlockChangeSender.updateGateBlocks(gate);
if (needsGateManagerUpdate) {
Plugin.getPlugin().getGatesManager().handleGateLocationChange(gate, null, null, null);
}
sendMessage(ChatColor.GREEN + "The gate was opened.");
}
catch (Exception e) {
sendMessage(ChatColor.RED + e.getMessage());
}
}
catch (Exception e) {
GateBlockChangeSender.updateGateBlocks(gate);
sendMessage(ChatColor.RED + "Setting the exit for the gate failed! This gate is now closed! (See server log for more information.)");
Plugin.log(Level.WARNING, e.getMessage());
e.printStackTrace();
}
}
}

View File

@ -44,6 +44,8 @@ public class CommandHelp extends BaseCommand
allUsageStrings.add( new CommandInfo().getUsageTemplate(true, true) );
allUsageStrings.add( new CommandHide().getUsageTemplate(true, true) );
allUsageStrings.add( new CommandUnhide().getUsageTemplate(true, true) );
allUsageStrings.add( new CommandExitOpen().getUsageTemplate(true, true) );
allUsageStrings.add( new CommandNearby().getUsageTemplate(true, true) );
Collections.sort(allUsageStrings);

View File

@ -17,10 +17,12 @@
package de.craftinc.gates.commands;
import de.craftinc.gates.util.GateBlockChangeSender;
import org.bukkit.ChatColor;
import de.craftinc.gates.Plugin;
import de.craftinc.gates.util.TextUtil;
import org.bukkit.entity.Player;
public class CommandInfo extends BaseCommand
@ -30,48 +32,82 @@ public class CommandInfo extends BaseCommand
aliases.add("info");
aliases.add("i");
requiredParameters.add("id");
optionalParameters.add("id");
helpDescription = "Print detailed information about a certain gate.";
helpDescription = "Print detailed information about a certain or the closest gate.";
requiredPermission = Plugin.permissionInfo;
needsPermissionAtCurrentLocation = false;
shouldPersistToDisk = false;
senderMustBePlayer = false;
hasGateParam = false;
}
public void perform()
{
sendMessage(TextUtil.titleize("Information about: '" + ChatColor.WHITE + gate.getId() + ChatColor.YELLOW + "'"));
if (this.parameters.size() > 0) {
String openHiddenMessage = ChatColor.DARK_AQUA + "This gate is";
if (!this.setGateUsingParameter(this.parameters.get(0))) {
sendMessage(ChatColor.RED + "You either provided a invalid gate or do not have permission to " + this.helpDescription.toLowerCase());
return;
}
if (gate.isOpen())
openHiddenMessage += ChatColor.AQUA + " open";
else
openHiddenMessage += ChatColor.AQUA + " closed";
sendMessage(TextUtil.titleize("Information about: '" + ChatColor.WHITE + gate.getId() + ChatColor.YELLOW + "'"));
}
else {
boolean senderIsPlayer = this.sender instanceof Player;
if (gate.isHidden())
openHiddenMessage += ChatColor.DARK_AQUA +" and" + ChatColor.AQUA + " hidden";
if (!senderIsPlayer) {
sendMessage(ChatColor.RED + "Only ingame players can perform this command without a supplied gate id!");
return;
}
openHiddenMessage += ".\n";
Player p = (Player)this.sender;
this.gate = Plugin.getPlugin().getGatesManager().getNearestGate(p.getLocation());
sendMessage(openHiddenMessage);
if (!this.hasPermission() || this.gate == null) {
sendMessage(ChatColor.RED + "There is either no gate nearby or you do not have permission to " + this.helpDescription.toLowerCase());
return;
}
if (gate.getLocation() != null)
sendMessage(ChatColor.DARK_AQUA + "from: " + ChatColor.AQUA + "( " + (int)gate.getLocation().getX() +
" | " + (int)gate.getLocation().getY() + " | " + (int)gate.getLocation().getZ() + " ) in " +
gate.getLocation().getWorld().getName());
else
sendMessage(ChatColor.DARK_AQUA + "NOTE: this gate has no location");
Plugin.log(this.gate.toString());
if (gate.getExit() != null)
sendMessage(ChatColor.DARK_AQUA + "to: " + ChatColor.AQUA + "( " + (int)gate.getExit().getX() + " | "
+ (int)gate.getExit().getY() + " | " + (int)gate.getExit().getZ() + " ) in " +
gate.getExit().getWorld().getName());
else
sendMessage(ChatColor.DARK_AQUA + "NOTE: this gate has no exit");
sendMessage(TextUtil.titleize("Information about closest gate: '" + ChatColor.WHITE + gate.getId() + ChatColor.YELLOW + "'"));
}
String openHiddenMessage = ChatColor.DARK_AQUA + "This gate is";
if (gate.isOpen())
openHiddenMessage += ChatColor.AQUA + " open";
else
openHiddenMessage += ChatColor.AQUA + " closed";
if (gate.isHidden())
openHiddenMessage += ChatColor.DARK_AQUA +" and" + ChatColor.AQUA + " hidden";
openHiddenMessage += ".\n";
sendMessage(openHiddenMessage);
if (gate.getLocation() != null)
sendMessage(ChatColor.DARK_AQUA + "location: " + ChatColor.AQUA + "( " + (int)gate.getLocation().getX() +
" | " + (int)gate.getLocation().getY() + " | " + (int)gate.getLocation().getZ() + " ) in " +
gate.getLocation().getWorld().getName());
else
sendMessage(ChatColor.DARK_AQUA + "NOTE: this gate has no location");
if (gate.getExit() != null)
sendMessage(ChatColor.DARK_AQUA + "exit: " + ChatColor.AQUA + "( " + (int)gate.getExit().getX() + " | "
+ (int)gate.getExit().getY() + " | " + (int)gate.getExit().getZ() + " ) in " +
gate.getExit().getWorld().getName());
else
sendMessage(ChatColor.DARK_AQUA + "NOTE: this gate has no exit");
if (this.sender instanceof Player) {
GateBlockChangeSender.temporaryHighlightGateFrame((Player)this.sender, this.gate);
}
}
}

View File

@ -29,7 +29,6 @@ import org.bukkit.block.Block;
public class CommandLocation extends BaseLocationCommand
{
public CommandLocation()
{
aliases.add("location");

View File

@ -0,0 +1,53 @@
package de.craftinc.gates.commands;
import de.craftinc.gates.Gate;
import de.craftinc.gates.GatesManager;
import de.craftinc.gates.Plugin;
import de.craftinc.gates.util.GateBlockChangeSender;
import de.craftinc.gates.util.TextUtil;
import java.util.ArrayList;
import java.util.Set;
public class CommandNearby extends BaseLocationCommand
{
public CommandNearby()
{
aliases.add("nearby");
aliases.add("nb");
helpDescription = "Highlight nearby gates";
requiredPermission = Plugin.permissionInfo;
needsPermissionAtCurrentLocation = true;
shouldPersistToDisk = false;
senderMustBePlayer = true;
hasGateParam = false;
}
public void perform()
{
GatesManager manager = Plugin.getPlugin().getGatesManager();
Set<Gate> nearbyGates = manager.getNearbyGates(player.getLocation().getChunk());
if (nearbyGates == null) {
player.sendMessage("There are no gates near you!");
}
else {
GateBlockChangeSender.temporaryHighlightGatesFrames(player, nearbyGates);
ArrayList<String> gateNames = new ArrayList<String>();
for (Gate g : nearbyGates) {
gateNames.add(g.getId());
}
player.sendMessage("Nearby gates: " + TextUtil.implode(gateNames, ", "));
}
}
}

View File

@ -27,7 +27,7 @@ import org.bukkit.event.block.BlockBreakEvent;
public class BlockBreakListener implements Listener
{
@EventHandler(priority = EventPriority.NORMAL)
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockBreak(BlockBreakEvent event)
{
if (event.isCancelled()) {

View File

@ -19,6 +19,7 @@ package de.craftinc.gates.listeners;
import java.util.Calendar;
import java.util.HashMap;
import de.craftinc.gates.util.ConfigurationUtil;
import de.craftinc.gates.util.GateBlockChangeSender;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@ -70,7 +71,7 @@ public class PlayerMoveListener implements Listener
// Check for permission
if (!hasPermission(event.getPlayer(), gateAtLocation)
&& Plugin.getPlugin().getConfig().getBoolean(Plugin.confShowTeleportNoPermissionMessageKey)) {
&& Plugin.getPlugin().getConfig().getBoolean(ConfigurationUtil.confShowTeleportNoPermissionMessageKey)) {
String playerName = event.getPlayer().getName();
@ -84,7 +85,7 @@ public class PlayerMoveListener implements Listener
// do not display messages more often than once per second
if (!this.lastNoPermissionMessages.containsKey(playerName) || this.lastNoPermissionMessages.get(playerName) < now - 10000L) {
String noPermissionString = Plugin.getPlugin().getConfig().getString(Plugin.confGateTeleportNoPermissionMessageKey);
String noPermissionString = Plugin.getPlugin().getConfig().getString(ConfigurationUtil.confGateTeleportNoPermissionMessageKey);
event.getPlayer().sendMessage(ChatColor.RED + noPermissionString);
this.lastNoPermissionMessages.put(playerName, now);
}
@ -114,8 +115,8 @@ public class PlayerMoveListener implements Listener
p.teleport(destLocation);
if (Plugin.getPlugin().getConfig().getBoolean(Plugin.confShowTeleportMessageKey)) {
String teleporMessage = Plugin.getPlugin().getConfig().getString(Plugin.confGateTeleportMessageKey);
if (Plugin.getPlugin().getConfig().getBoolean(ConfigurationUtil.confShowTeleportMessageKey)) {
String teleporMessage = Plugin.getPlugin().getConfig().getString(ConfigurationUtil.confGateTeleportMessageKey);
p.sendMessage(ChatColor.DARK_AQUA + teleporMessage);
}
}

View File

@ -25,7 +25,7 @@ import org.bukkit.event.player.PlayerTeleportEvent;
public class PlayerTeleportListener implements Listener
{
@EventHandler(priority = EventPriority.NORMAL)
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerTeleport(PlayerTeleportEvent event)
{
if (event.isCancelled()) {

View File

@ -0,0 +1,126 @@
/* Craft Inc. Gates
Copyright (C) 2011-2013 Craft Inc. Gates Team (see AUTHORS.txt)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program (LGPLv3). If not, see <http://www.gnu.org/licenses/>.
*/
package de.craftinc.gates.util;
import de.craftinc.gates.Plugin;
import org.bukkit.Material;
import java.util.logging.Level;
public class ConfigurationUtil
{
public static final String confMaxGateBlocksKey = "maxGateBlocks";
public static final String confPlayerGateBlockUpdateRadiusKey = "playerGateBlockUpdateRadius";
public static final String confCheckForBrokenGateFramesKey = "checkForBrokenGateFrames";
public static final String confGateTeleportMessageKey = "gateTeleportMessage";
public static final String confShowTeleportMessageKey = "showTeleportMessage";
public static final String confGateTeleportNoPermissionMessageKey = "gateTeleportNoPermissionMessage";
public static final String confShowTeleportNoPermissionMessageKey = "showTeleportNoPermissionMessage";
public static final String confSaveOnChangesKey = "saveOnChanges";
public static final String confHighlightDurationKey = "highlightDuration";
public static final String confGateMaterialKey = "gateMaterial";
public static GateMaterial getPortalMaterial()
{
String materialString = Plugin.getPlugin().getConfig().getString(confGateMaterialKey);
GateMaterial material = new GateMaterial();
if (materialString.equals("sapling")) {
material.material = Material.SAPLING;
}
else if (materialString.equals("water")) {
material.material = Material.STATIONARY_WATER;
}
else if (materialString.equals("lava")) {
material.material = Material.STATIONARY_LAVA;
}
else if (materialString.equals("cobweb")) {
material.material = Material.WEB;
}
else if (materialString.equals("grass")) {
material.material = Material.LONG_GRASS;
material.data = 1;
}
else if (materialString.equals("dead bush")) {
material.material = Material.DEAD_BUSH;
}
else if (materialString.equals("dandelion")) {
material.material = Material.YELLOW_FLOWER; // TODO: this will change with minecraft 1.7
}
else if (materialString.equals("poppy")) {
material.material = Material.RED_ROSE; // TODO: this will change with minecraft 1.7
}
else if (materialString.equals("brown mushroom")) {
material.material = Material.BROWN_MUSHROOM;
}
else if (materialString.equals("red mushroom")) {
material.material = Material.RED_MUSHROOM;
}
else if (materialString.equals("torch")) {
material.material = Material.TORCH;
}
else if (materialString.equals("redstone torch (off)")) {
material.material = Material.REDSTONE_TORCH_OFF;
}
else if (materialString.equals("redstone torch (on)")) {
material.material = Material.REDSTONE_TORCH_ON;
}
else if (materialString.equals("fence")) {
material.material = Material.FENCE;
}
else if (materialString.equals("nether portal")) {
material.material = Material.PORTAL;
}
else if (materialString.equals("iron bars")) {
material.material = Material.IRON_FENCE;
}
else if (materialString.equals("glass pane")) {
material.material = Material.THIN_GLASS;
}
else if (materialString.equals("fence gate")) {
material.material = Material.FENCE_GATE;
}
else if (materialString.equals("nether brick fence")) {
material.material = Material.NETHER_FENCE;
}
else if (materialString.equals("nether wart")) {
material.material = Material.NETHER_WARTS;
}
else if (materialString.equals("end portal")) {
material.material = Material.ENDER_PORTAL;
}
else if (materialString.equals("cobblestone wall")) {
material.material = Material.COBBLE_WALL;
}
else { // fallback!
material.material = Material.PORTAL;
Plugin.log(Level.WARNING, "Gate material invalid! Please check and correct your configuration file!");
}
return material;
}
}
class GateMaterial
{
public Material material = Material.PORTAL;
public byte data = 0;
}

View File

@ -148,7 +148,7 @@ public class FloodUtil
throw new IllegalArgumentException("'block' must not be 'null'");
}
int frameBlockSearchLimit = Plugin.getPlugin().getConfig().getInt(Plugin.confMaxGateBlocksKey);
int frameBlockSearchLimit = Plugin.getPlugin().getConfig().getInt(ConfigurationUtil.confMaxGateBlocksKey);
Set<Block> blocks1 = getAirFloodBlocks(block, new HashSet<Block>(), exp1, frameBlockSearchLimit);
Set<Block> blocks2 = getAirFloodBlocks(block, new HashSet<Block>(), exp2, frameBlockSearchLimit);

View File

@ -19,17 +19,108 @@ package de.craftinc.gates.util;
import de.craftinc.gates.Plugin;
import de.craftinc.gates.Gate;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Set;
import static de.craftinc.gates.util.ConfigurationUtil.*;
public class GateBlockChangeSender
{
/**
* Replaces gate frame blocks with glowstone for a short period of time.
* Uses the data stored in 'highlightDuration' inside the config file
* for determining when to de-highlight the frames.
* @param player The player for whom the frame should be highlighted.
* Must not be null!
*/
public static void temporaryHighlightGatesFrames(final Player player, final Set<Gate> gates)
{
if (player == null) {
throw new IllegalArgumentException("'player' must not be 'null'!");
}
if (gates == null) {
throw new IllegalArgumentException("'gate' must not be 'null!");
}
for (Gate g : gates) {
Set<Block> frameBlocks = g.getGateFrameBlocks();
for (Block b : frameBlocks) {
player.sendBlockChange(b.getLocation(), Material.GLOWSTONE, (byte)0);
}
}
Plugin plugin = Plugin.getPlugin();
long highlightDuration = 20 * plugin.getConfig().getLong(confHighlightDurationKey);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
dehighlightGatesFrames(player, gates);
}
}, highlightDuration);
}
public static void temporaryHighlightGateFrame(final Player player, final Gate gate)
{
if (gate == null) {
throw new IllegalArgumentException("'gate' must not be 'null!");
}
if (player == null) {
throw new IllegalArgumentException("'player' must not be 'null'!");
}
Set<Block> frameBlocks = gate.getGateFrameBlocks();
for (Block b : frameBlocks) {
player.sendBlockChange(b.getLocation(), Material.GLOWSTONE, (byte)0);
}
Plugin plugin = Plugin.getPlugin();
long highlightDuration = 20 * plugin.getConfig().getLong(confHighlightDurationKey);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
dehighlightGateFrame(player, gate);
}
}, highlightDuration);
}
protected static void dehighlightGatesFrames(final Player player, final Set<Gate> gates)
{
for (Gate g : gates) {
Set<Block> frameBlocks = g.getGateFrameBlocks();
for (Block b : frameBlocks) {
player.sendBlockChange(b.getLocation(), b.getType(), (byte)0);
}
}
}
protected static void dehighlightGateFrame(final Player player, final Gate gate)
{
Set<Block> frameBlocks = gate.getGateFrameBlocks();
for (Block b : frameBlocks) {
player.sendBlockChange(b.getLocation(), b.getType(), (byte)0);
}
}
/**
* Sends gate blocks to player at a given location. Will send the updates either immediately or
* immediately and after a short delay.
@ -49,6 +140,7 @@ public class GateBlockChangeSender
}
Set<Gate> gatesNearby = Plugin.getPlugin().getGatesManager().getNearbyGates(location.getChunk());
GateMaterial gateMaterial = getPortalMaterial();
if (gatesNearby == null) {
return; // no gates nearby
@ -63,7 +155,7 @@ public class GateBlockChangeSender
for (Location l : g.getGateBlockLocations()) {
if (l.getBlock().getType() == Material.AIR) {
player.sendBlockChange(l, Material.PORTAL, (byte)0);
player.sendBlockChange(l, gateMaterial.material, gateMaterial.data);
}
}
}
@ -126,7 +218,7 @@ public class GateBlockChangeSender
ArrayList<Player> playersNearby = new ArrayList<Player>();
int searchRadius = Plugin.getPlugin().getConfig().getInt(Plugin.confPlayerGateBlockUpdateRadiusKey);
int searchRadius = Plugin.getPlugin().getConfig().getInt(confPlayerGateBlockUpdateRadiusKey);
for (Player p : Plugin.getPlugin().getServer().getOnlinePlayers()) {
@ -135,10 +227,13 @@ public class GateBlockChangeSender
}
}
GateMaterial gateMaterial = getPortalMaterial();
Material material;
byte data = 0;
if (gate.isOpen() && !gate.isHidden() && !remove) {
material = Material.PORTAL;
material = gateMaterial.material;
data = gateMaterial.data;
}
else {
material = Material.AIR;
@ -149,7 +244,7 @@ public class GateBlockChangeSender
for (Location l : gate.getGateBlockLocations()) {
if (l.getBlock().getType() == Material.AIR) { // on server-side a gate is always made out of AIR
p.sendBlockChange(l, material, (byte)0);
p.sendBlockChange(l, material, data);
}
}
}

View File

@ -24,13 +24,20 @@ public class TextUtil
{
public static String titleize(String str)
{
String line = ChatColor.GOLD + repeat("_", 60);
String center = ".[ " + ChatColor.YELLOW + str + ChatColor.GOLD + " ].";
int pivot = line.length() / 2;
int eatLeft = center.length() / 2;
int eatRight = center.length() - eatLeft;
return line.substring(0, pivot - eatLeft) + center + line.substring(pivot + eatRight);
if (center.length() >= 60) {
return ChatColor.GOLD + center;
}
else {
String line = ChatColor.GOLD + repeat("_", 60);
int pivot = line.length() / 2;
int eatLeft = center.length() / 2;
int eatRight = center.length() - eatLeft;
return line.substring(0, pivot - eatLeft) + center + line.substring(pivot + eatRight);
}
}