Compare commits
22 Commits
version2.2
...
version2.3
Author | SHA1 | Date | |
---|---|---|---|
7f89917e81 | |||
a1cb0102f8 | |||
5af520f8ea | |||
28cacfdb19 | |||
757d6b5a48 | |||
056b8896a6 | |||
12a0bba6cc | |||
e9a454182a | |||
260cabc509 | |||
0b29936958 | |||
efc30d0ae0 | |||
f4111fb34f | |||
37bce23e3d | |||
d5ff63c163 | |||
e60c735153 | |||
013fad2b95 | |||
5ace80e6d1 | |||
42b293e6bc | |||
54545a9ee1 | |||
560bbf0394 | |||
2150cc66d0 | |||
7673c3f674 |
@ -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
|
@ -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>
|
||||
|
@ -75,10 +75,6 @@ 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.
|
||||
|
10
changelog.md
10
changelog.md
@ -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.
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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
27
doc/Gate Materials.md
Normal 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.
|
@ -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
66
pom.xml
@ -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>
|
||||
|
@ -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"
|
@ -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) {
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
80
src/de/craftinc/gates/commands/CommandExitOpen.java
Normal file
80
src/de/craftinc/gates/commands/CommandExitOpen.java
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
||||
|
@ -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,21 +32,50 @@ 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()
|
||||
{
|
||||
if (this.parameters.size() > 0) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
sendMessage(TextUtil.titleize("Information about: '" + ChatColor.WHITE + gate.getId() + ChatColor.YELLOW + "'"));
|
||||
}
|
||||
else {
|
||||
boolean senderIsPlayer = this.sender instanceof Player;
|
||||
|
||||
if (!senderIsPlayer) {
|
||||
sendMessage(ChatColor.RED + "Only ingame players can perform this command without a supplied gate id!");
|
||||
return;
|
||||
}
|
||||
|
||||
Player p = (Player)this.sender;
|
||||
this.gate = Plugin.getPlugin().getGatesManager().getNearestGate(p.getLocation());
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Plugin.log(this.gate.toString());
|
||||
|
||||
sendMessage(TextUtil.titleize("Information about closest gate: '" + ChatColor.WHITE + gate.getId() + ChatColor.YELLOW + "'"));
|
||||
}
|
||||
|
||||
String openHiddenMessage = ChatColor.DARK_AQUA + "This gate is";
|
||||
|
||||
@ -61,17 +92,22 @@ public class CommandInfo extends BaseCommand
|
||||
sendMessage(openHiddenMessage);
|
||||
|
||||
if (gate.getLocation() != null)
|
||||
sendMessage(ChatColor.DARK_AQUA + "from: " + ChatColor.AQUA + "( " + (int)gate.getLocation().getX() +
|
||||
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 + "to: " + ChatColor.AQUA + "( " + (int)gate.getExit().getX() + " | "
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ import org.bukkit.block.Block;
|
||||
|
||||
public class CommandLocation extends BaseLocationCommand
|
||||
{
|
||||
|
||||
public CommandLocation()
|
||||
{
|
||||
aliases.add("location");
|
||||
|
53
src/de/craftinc/gates/commands/CommandNearby.java
Normal file
53
src/de/craftinc/gates/commands/CommandNearby.java
Normal 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, ", "));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -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()) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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()) {
|
||||
|
126
src/de/craftinc/gates/util/ConfigurationUtil.java
Normal file
126
src/de/craftinc/gates/util/ConfigurationUtil.java
Normal 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;
|
||||
}
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,14 +24,21 @@ public class TextUtil
|
||||
{
|
||||
public static String titleize(String str)
|
||||
{
|
||||
String line = ChatColor.GOLD + repeat("_", 60);
|
||||
String center = ".[ " + ChatColor.YELLOW + str + ChatColor.GOLD + " ].";
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String repeat(String s, int times)
|
||||
|
Reference in New Issue
Block a user