Compare commits
25 Commits
version2.3
...
version2.4
Author | SHA1 | Date | |
---|---|---|---|
e2903514fe | |||
44e86059de | |||
fe0946117e | |||
43dd934f48 | |||
b37f1000ab | |||
c7a423ff20 | |||
b676af278d | |||
a579209037 | |||
ca74b2e3ed | |||
6924e36249 | |||
f8f31640ef | |||
c80b0f0f68 | |||
2bd8b0ff03 | |||
a613b1933a | |||
d8fff26c9e | |||
0c13d0d3e3 | |||
29592823b6 | |||
56c6af02b1 | |||
8b873a6d60 | |||
e36519c246 | |||
125d327a0d | |||
6c8658f7c5 | |||
14041f8cd7 | |||
bb4a41e782 | |||
82df684c22 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -31,3 +31,4 @@ bukkit/
|
||||
|
||||
# bukkit test-server
|
||||
bukkit-testserver/
|
||||
dependency-reduced-pom.xml
|
||||
|
16
README.md
16
README.md
@ -1,10 +1,5 @@
|
||||
|
||||
# Craft Inc. Gates #
|
||||
|
||||
<Logo here>
|
||||
|
||||
We are happy to finally announce __Craft Inc. Gates__.
|
||||
|
||||
This awesome plugin lets you _travel_ to far away places and worlds _faster than light_! Just create a gate at any location and set an exit somewhere else.
|
||||
|
||||
This has been made available by the hard work of the research and development department of the _Craft Inc. Corporation_. Under the lead of Professor Ddidderr Craftman scientists worked years to find a way to bend time and space inside the Minecraft universe to enable _ultra fast transportation_.
|
||||
@ -13,10 +8,12 @@ Now it is time for _you_ to try out this wonderful plugin. Simply install, creat
|
||||
|
||||
The key features of this are:
|
||||
|
||||
* Dynmap integration
|
||||
* Gates with and without frames
|
||||
* Gates consisting of portal blocks and gates made of air (so called hidden gates)
|
||||
* Gates with destinations in different worlds
|
||||
* Gates with custom shapes (gates can look any way you want)
|
||||
* Riding through gates
|
||||
|
||||
|
||||
*The Craft Inc. Corporation won't take any responsibility for seasickness, memory loss and sudden suffocation in walls while traveling with one of our gates!
|
||||
@ -57,8 +54,9 @@ Have a look at the [_Commands_](http://dev.bukkit.org/bukkit-plugins/craftinc-ga
|
||||
## Installing ##
|
||||
|
||||
1. Download the latest release _[here](http://dev.bukkit.org/bukkit-plugins/craftinc-gates/files/)_
|
||||
2. Extract the content of the zip file into the plugins folder of your Bukkit server.
|
||||
3. Start or reload the server.
|
||||
2. Delete any old versions of _Craft Inc. Gates_ (only the .jar files) including the extra dynmap-plugin of this plugin.
|
||||
3. Extract the content of the zip file into the plugins folder of your Bukkit server.
|
||||
4. Start or reload the server.
|
||||
|
||||
## Craft Inc. ##
|
||||
Check out our __[Craft Inc. Minecraft Server](http://www.craftinc.de)__. Everyone is welcome!
|
||||
@ -75,9 +73,6 @@ allows players to build a replicator to replicate blocks and other items. (still
|
||||
coming soon!
|
||||
|
||||
## Roadmap ##
|
||||
* 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.
|
||||
|
||||
@ -87,3 +82,4 @@ Please use our [_issue tracker_](https://github.com/craftinc/craftinc-gates/issu
|
||||
## Legal Information ##
|
||||
This project is a fork of the original [_Ancient Gates_](https://github.com/bladedpenguin/minecraft-ancient-gates). It is licensed under the [_LGPL_](http://www.gnu.org/licenses/lgpl-3.0.txt) just like the Bukkit project. Thanks to all current and previous [_contributors_](https://github.com/craftinc/craftinc-gates/blob/development/AUTHORS.txt).
|
||||
The font used for the Craft Inc. Gates logo is called [_MineCrafter 3_](http://www.minecraftforum.net/topic/892789-minecrafter-3-font-simply-easy/) and has been made available under the creative commons license. Thanks to Asherz08, MadPixel and Ashley Denham for this great font.
|
||||
This plugin utilizes [_Hidendra's plugin metrics system_](http://mcstats.org), which means that the following information is collected and sent to mcstats.org: a unique identifier, the server's version of Java, whether the server is in offline or online mode, the plugin's version, the server's version, the OS version/name and architecture, the core count for the CPU, the number of players online, the Metrics version. __You can disable the stat collection via /plugins/PluginMetrics/config.yml if you wish.__
|
@ -1,3 +1,8 @@
|
||||
## 2.4.0 ##
|
||||
* Resolved issues with closing gates (special thanks to THCFrosD)
|
||||
* Added support for riding through gates (with horses, mine carts, pigs and boats)
|
||||
* Dynmap integration (extra plugin)
|
||||
|
||||
## 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.
|
||||
|
@ -1,6 +1,12 @@
|
||||
* __/gate allowRiding, ar [id]__
|
||||
Update a gate so players can travel through it while riding.
|
||||
|
||||
* __/gate close, c [id]__
|
||||
Closes a gate to prevent players from using it.
|
||||
|
||||
* __/gate denyRiding, dr [id]__
|
||||
Update a gate so players can NOT travel through it while riding.
|
||||
|
||||
* __/gate delete, del, remove [id]__
|
||||
Removes the gate from the game.
|
||||
|
||||
|
@ -41,11 +41,13 @@ be displayed.
|
||||
|
||||
|
||||
* __gateTeleportNoPermissionMessage__
|
||||
A string value going to displayed every time when a player enters a gate and is not
|
||||
allowed to use that gate. Will only be displayed if _showTeleportNoPermissionMessage_
|
||||
A string value going to displayed every time when a player enters a gate and is not allowed to use that gate. Will only be displayed if _showTeleportNoPermissionMessage_
|
||||
is set to _true_.
|
||||
|
||||
|
||||
* __gateTeleportVehicleNotAllowedMessage__
|
||||
A string value being displayed when a player tries to go through a gate while riding when riding through this gate is disabled. Will only be displayed if _showTeleportNoPermissionMessage_ is set to _true_.
|
||||
|
||||
* __showTeleportNoPermissionMessage__
|
||||
A boolean (_true_ or _false_) determining wether the _no permission message_ will
|
||||
be displayed.
|
||||
|
@ -1,7 +1,7 @@
|
||||
name: ${project.name}
|
||||
version: ${project.version}
|
||||
description: A plugin to create gates for fast traveling.
|
||||
softdepend: [Vault]
|
||||
softdepend: [Vault, Multiverse-Core, MultiWorld, RoyalCommands]
|
||||
author: tomco, s1m0ne
|
||||
authors: [oloflarsson, locutus, DrAgonmoray, s1m0ne, tomco]
|
||||
website: http://dev.bukkit.org/bukkit-plugins/craftinc-gates/
|
||||
|
4
pom.xml
4
pom.xml
@ -7,7 +7,7 @@
|
||||
<name>Craft Inc. Gates</name>
|
||||
<url>http://dev.bukkit.org/bukkit-plugins/craftinc-gates/</url>
|
||||
<packaging>jar</packaging>
|
||||
<version>2.3.0</version>
|
||||
<version>2.4.0</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
@ -93,7 +93,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.6.4-R2.0</version>
|
||||
<version>1.7.2-R0.2-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
@ -7,4 +7,5 @@ gateTeleportMessage: "Thank you for traveling with Craft Inc. Gates."
|
||||
showTeleportMessage: true
|
||||
gateTeleportNoPermissionMessage: "You are not allowed to use this gate!"
|
||||
showTeleportNoPermissionMessage: true
|
||||
gateTeleportVehicleNotAllowedMessage: "You must not use that gate while riding!"
|
||||
gateMaterial: "nether portal"
|
@ -37,6 +37,8 @@ public class Gate implements ConfigurationSerializable
|
||||
|
||||
protected boolean isHidden = false;
|
||||
protected boolean isOpen = false;
|
||||
|
||||
protected boolean allowsVehicles = true;
|
||||
|
||||
protected String id;
|
||||
|
||||
@ -167,6 +169,18 @@ public class Gate implements ConfigurationSerializable
|
||||
}
|
||||
|
||||
|
||||
public void setAllowsVehicles(boolean allowsVehicles)
|
||||
{
|
||||
this.allowsVehicles = allowsVehicles;
|
||||
}
|
||||
|
||||
|
||||
public boolean getAllowsVehicles()
|
||||
{
|
||||
return this.allowsVehicles;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Will never return 'null' but might return an empty Set.
|
||||
@ -265,7 +279,8 @@ public class Gate implements ConfigurationSerializable
|
||||
static protected String locationPitchKey = "locationPitch";
|
||||
static protected String exitYawKey = "exitYaw";
|
||||
static protected String exitPitchKey = "exitPitch";
|
||||
|
||||
static protected String allowsVehiclesKey = "allowsVehiclesKey";
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Gate(Map<String, Object> map)
|
||||
@ -273,10 +288,6 @@ public class Gate implements ConfigurationSerializable
|
||||
try {
|
||||
id = map.get(idKey).toString().toLowerCase();
|
||||
|
||||
if (id == null) {
|
||||
throw new Exception("gates need to have an id");
|
||||
}
|
||||
|
||||
isHidden = (Boolean)map.get(isHiddenKey);
|
||||
isOpen = (Boolean)map.get(isOpenKey);
|
||||
|
||||
@ -292,6 +303,10 @@ public class Gate implements ConfigurationSerializable
|
||||
location.setPitch(((Number)map.get(locationPitchKey)).floatValue());
|
||||
location.setYaw(((Number)map.get(locationYawKey)).floatValue());
|
||||
}
|
||||
|
||||
if (map.containsKey(allowsVehiclesKey)) {
|
||||
allowsVehicles = (Boolean)map.get(allowsVehiclesKey);
|
||||
}
|
||||
|
||||
gateBlockLocations = new HashSet<Location>();
|
||||
List<Map<String, Object>> serializedGateBlocks = (List<Map<String, Object>>)map.get(gateBlocksKey);
|
||||
@ -327,6 +342,7 @@ public class Gate implements ConfigurationSerializable
|
||||
retVal.put(exitKey, LocationUtil.serializeLocation(exit));
|
||||
retVal.put(isHiddenKey, isHidden);
|
||||
retVal.put(isOpenKey, isOpen);
|
||||
retVal.put(allowsVehiclesKey, allowsVehicles);
|
||||
|
||||
if (exit != null) {
|
||||
retVal.put(exitPitchKey, exit.getPitch());
|
||||
|
31
src/de/craftinc/gates/GateChangeListener.java
Normal file
31
src/de/craftinc/gates/GateChangeListener.java
Normal file
@ -0,0 +1,31 @@
|
||||
/* Craft Inc. Gates
|
||||
Copyright (C) 2011-2014 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;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface GateChangeListener
|
||||
{
|
||||
public static final String newGate = "GateChangeListener-newGate"; // value will be null
|
||||
public static final String removedGate = "GateChangeListener-removedGate"; // value will be null
|
||||
public static final String changedID = "GateChangeListener-changedID"; // value will be the old ID
|
||||
public static final String changedLocation = "GateChangeListener-changedLocation"; // value will the old location
|
||||
public static final String changedExit = "GateChangeListener-changedExit"; // value will be the old exit
|
||||
|
||||
public void gateChangedHandler(final Gate g, final Map<String, Object>changeSet);
|
||||
}
|
@ -41,7 +41,7 @@ public class GatesManager
|
||||
protected FileConfiguration gatesConfig;
|
||||
protected static final String gatesPath = "gates"; // path to gates inside the yaml file
|
||||
protected static final String storageVersionPath = "version";
|
||||
protected static final int storageVersion = 1;
|
||||
protected static final int storageVersion = 2;
|
||||
|
||||
protected int chunkRadius;
|
||||
|
||||
@ -54,6 +54,20 @@ public class GatesManager
|
||||
|
||||
protected boolean storageFileIsInvalid = false;
|
||||
|
||||
protected Set<GateChangeListener> changeListeners = new HashSet<GateChangeListener>();
|
||||
|
||||
|
||||
public void addGateChangeListener(GateChangeListener listener)
|
||||
{
|
||||
this.changeListeners.add(listener);
|
||||
}
|
||||
|
||||
|
||||
public void removeGateChangeListener(GateChangeListener listener)
|
||||
{
|
||||
this.changeListeners.remove(listener);
|
||||
}
|
||||
|
||||
|
||||
public Gate getGateWithId(final String id)
|
||||
{
|
||||
@ -489,6 +503,13 @@ public class GatesManager
|
||||
{
|
||||
this.removeGateById(oldId);
|
||||
this.addGateWithId(g);
|
||||
|
||||
Map<String, Object> changeSet = new HashMap<String, Object>();
|
||||
changeSet.put(GateChangeListener.changedID, oldId);
|
||||
|
||||
for (GateChangeListener l : this.changeListeners) {
|
||||
l.gateChangedHandler(g, changeSet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -505,7 +526,27 @@ public class GatesManager
|
||||
|
||||
this.removeGateByFrameLocation(oldGateFrameBlocks);
|
||||
this.addGateByFrameLocations(g);
|
||||
|
||||
Map<String, Object> changeSet = new HashMap<String, Object>();
|
||||
changeSet.put(GateChangeListener.changedLocation, oldLocation);
|
||||
|
||||
for (GateChangeListener l : this.changeListeners) {
|
||||
l.gateChangedHandler(g, changeSet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void handleGateExitChange(final Gate g, final Location oldExit)
|
||||
{
|
||||
// nothing to do
|
||||
|
||||
Map<String, Object> changeSet = new HashMap<String, Object>();
|
||||
changeSet.put(GateChangeListener.changedExit, oldExit);
|
||||
|
||||
for (GateChangeListener l : this.changeListeners) {
|
||||
l.gateChangedHandler(g, changeSet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void handleNewGate(final Gate g)
|
||||
@ -516,6 +557,14 @@ public class GatesManager
|
||||
this.addGateByLocations(g);
|
||||
this.addGateWithId(g);
|
||||
this.addGateByFrameLocations(g);
|
||||
|
||||
|
||||
Map<String, Object> changeSet = new HashMap<String, Object>();
|
||||
changeSet.put(GateChangeListener.newGate, null);
|
||||
|
||||
for (GateChangeListener l : this.changeListeners) {
|
||||
l.gateChangedHandler(g, changeSet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -527,6 +576,13 @@ public class GatesManager
|
||||
this.removeGateFromChunk(g, g.getLocation());
|
||||
this.removeGateByLocation(g.getGateBlockLocations());
|
||||
this.removeGateByFrameLocation(g.getGateFrameBlocks());
|
||||
|
||||
Map<String, Object> changeSet = new HashMap<String, Object>();
|
||||
changeSet.put(GateChangeListener.removedGate, null);
|
||||
|
||||
for (GateChangeListener l : this.changeListeners) {
|
||||
l.gateChangedHandler(g, changeSet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -147,6 +147,8 @@ public class Plugin extends JavaPlugin
|
||||
commands.add(new CommandUnhide());
|
||||
commands.add(new CommandExitOpen());
|
||||
commands.add(new CommandNearby());
|
||||
commands.add(new CommandAllowRiding());
|
||||
commands.add(new CommandDenyRiding());
|
||||
|
||||
|
||||
// Register events
|
||||
|
48
src/de/craftinc/gates/commands/CommandAllowRiding.java
Normal file
48
src/de/craftinc/gates/commands/CommandAllowRiding.java
Normal file
@ -0,0 +1,48 @@
|
||||
/* 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 org.bukkit.ChatColor;
|
||||
|
||||
public class CommandAllowRiding extends BaseCommand
|
||||
{
|
||||
public CommandAllowRiding()
|
||||
{
|
||||
aliases.add("allowRiding");
|
||||
aliases.add("ar");
|
||||
|
||||
requiredParameters.add("id");
|
||||
|
||||
helpDescription = "Allow players to travel while riding.";
|
||||
|
||||
requiredPermission = Plugin.permissionManage;
|
||||
|
||||
needsPermissionAtCurrentLocation = false;
|
||||
shouldPersistToDisk = true;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void perform()
|
||||
{
|
||||
gate.setAllowsVehicles(true);
|
||||
sendMessage(ChatColor.GREEN + "Traveling while riding is now enabled for this gate.");
|
||||
}
|
||||
}
|
47
src/de/craftinc/gates/commands/CommandDenyRiding.java
Normal file
47
src/de/craftinc/gates/commands/CommandDenyRiding.java
Normal file
@ -0,0 +1,47 @@
|
||||
/* 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 org.bukkit.ChatColor;
|
||||
|
||||
public class CommandDenyRiding extends BaseCommand
|
||||
{
|
||||
public CommandDenyRiding()
|
||||
{
|
||||
aliases.add("denyRiding");
|
||||
aliases.add("dr");
|
||||
|
||||
requiredParameters.add("id");
|
||||
|
||||
helpDescription = "Deny players to travel while riding.";
|
||||
|
||||
requiredPermission = Plugin.permissionManage;
|
||||
|
||||
needsPermissionAtCurrentLocation = false;
|
||||
shouldPersistToDisk = true;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void perform()
|
||||
{
|
||||
gate.setAllowsVehicles(false);
|
||||
sendMessage(ChatColor.GREEN + "Traveling while riding is now disabled for this gate.");
|
||||
}
|
||||
}
|
@ -22,6 +22,7 @@ import de.craftinc.gates.util.GateBlockChangeSender;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import de.craftinc.gates.Plugin;
|
||||
import org.bukkit.Location;
|
||||
|
||||
|
||||
public class CommandExit extends BaseCommand
|
||||
@ -47,8 +48,10 @@ public class CommandExit extends BaseCommand
|
||||
{
|
||||
try
|
||||
{
|
||||
Location oldExit = gate.getExit();
|
||||
gate.setExit(player.getLocation());
|
||||
sendMessage(ChatColor.GREEN + "The exit of gate '" + gate.getId() + "' is now where you stand.");
|
||||
Plugin.getPlugin().getGatesManager().handleGateExitChange(gate, oldExit);
|
||||
}
|
||||
catch (Exception e) {
|
||||
GateBlockChangeSender.updateGateBlocks(gate);
|
||||
|
@ -20,6 +20,7 @@ package de.craftinc.gates.commands;
|
||||
import de.craftinc.gates.Plugin;
|
||||
import de.craftinc.gates.util.GateBlockChangeSender;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
@ -46,8 +47,10 @@ public class CommandExitOpen extends BaseCommand
|
||||
{
|
||||
try
|
||||
{
|
||||
Location oldExit = gate.getExit();
|
||||
gate.setExit(player.getLocation());
|
||||
sendMessage(ChatColor.GREEN + "The exit of gate '" + gate.getId() + "' is now where you stand.");
|
||||
Plugin.getPlugin().getGatesManager().handleGateExitChange(gate, oldExit);
|
||||
|
||||
try {
|
||||
boolean needsGateManagerUpdate = false;
|
||||
|
@ -106,6 +106,10 @@ public class CommandInfo extends BaseCommand
|
||||
sendMessage(ChatColor.DARK_AQUA + "NOTE: this gate has no exit");
|
||||
|
||||
|
||||
if (gate.getAllowsVehicles())
|
||||
sendMessage(ChatColor.DARK_AQUA + "You can ride through this gate.");
|
||||
|
||||
|
||||
if (this.sender instanceof Player) {
|
||||
GateBlockChangeSender.temporaryHighlightGateFrame((Player)this.sender, this.gate);
|
||||
}
|
||||
|
@ -21,9 +21,12 @@ import java.util.HashMap;
|
||||
|
||||
import de.craftinc.gates.util.ConfigurationUtil;
|
||||
import de.craftinc.gates.util.GateBlockChangeSender;
|
||||
import de.craftinc.gates.util.VehicleCloner;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -32,6 +35,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import de.craftinc.gates.Gate;
|
||||
import de.craftinc.gates.GatesManager;
|
||||
import de.craftinc.gates.Plugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
|
||||
public class PlayerMoveListener implements Listener
|
||||
@ -49,43 +53,30 @@ public class PlayerMoveListener implements Listener
|
||||
GateBlockChangeSender.updateGateBlocks(event.getPlayer(), event.getTo());
|
||||
}
|
||||
|
||||
GatesManager gateManager = Plugin.getPlugin().getGatesManager();
|
||||
Gate gateAtLocation = gateManager.getGateAtLocation(event.getTo());
|
||||
final GatesManager gateManager = Plugin.getPlugin().getGatesManager();
|
||||
final Gate gateAtLocation = gateManager.getGateAtLocation(event.getTo());
|
||||
|
||||
if (gateAtLocation == null) {
|
||||
// Location headTo = new Location(event.getTo().getWorld(),
|
||||
// event.getTo().getX(),
|
||||
// event.getTo().getY()+1.0,
|
||||
// event.getTo().getZ());
|
||||
//
|
||||
// gateAtLocation = gateManager.getGateAtLocation(headTo);
|
||||
|
||||
// if (gateAtLocation == null) {
|
||||
if ((gateAtLocation == null) || !gateAtLocation.isOpen()) {
|
||||
return;
|
||||
// }
|
||||
}
|
||||
|
||||
if (!gateAtLocation.isOpen()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for permission
|
||||
if (!hasPermission(event.getPlayer(), gateAtLocation)
|
||||
&& Plugin.getPlugin().getConfig().getBoolean(ConfigurationUtil.confShowTeleportNoPermissionMessageKey)) {
|
||||
|
||||
String playerName = event.getPlayer().getName();
|
||||
final String playerName = event.getPlayer().getName();
|
||||
|
||||
if (playerName == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// get the current time
|
||||
Long now = Calendar.getInstance().getTimeInMillis();
|
||||
final Long now = Calendar.getInstance().getTimeInMillis();
|
||||
|
||||
// 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(ConfigurationUtil.confGateTeleportNoPermissionMessageKey);
|
||||
final String noPermissionString = Plugin.getPlugin().getConfig().getString(ConfigurationUtil.confGateTeleportNoPermissionMessageKey);
|
||||
event.getPlayer().sendMessage(ChatColor.RED + noPermissionString);
|
||||
this.lastNoPermissionMessages.put(playerName, now);
|
||||
}
|
||||
@ -98,38 +89,79 @@ public class PlayerMoveListener implements Listener
|
||||
|
||||
/**
|
||||
* Teleports a player.
|
||||
* @param p The player to teleport.
|
||||
* @param g The gate to which exit the player will be teleported.
|
||||
* @param player The player to teleport.
|
||||
* @param gate The gate to which exit the player will be teleported.
|
||||
*/
|
||||
private void teleportPlayer(Player p, Gate g)
|
||||
private void teleportPlayer(final Player player, final Gate gate)
|
||||
{
|
||||
Float newYaw = g.getExit().getYaw() - g.getLocation().getYaw() + p.getLocation().getYaw();
|
||||
// Destination
|
||||
final Float newYaw = gate.getExit().getYaw() - gate.getLocation().getYaw() + player.getLocation().getYaw();
|
||||
final Location destLocation = new Location( gate.getExit().getWorld(),
|
||||
gate.getExit().getX(),
|
||||
gate.getExit().getY(),
|
||||
gate.getExit().getZ(),
|
||||
newYaw,
|
||||
player.getLocation().getPitch()
|
||||
);
|
||||
|
||||
Location destLocation = new Location( g.getExit().getWorld(),
|
||||
g.getExit().getX(),
|
||||
g.getExit().getY(),
|
||||
g.getExit().getZ(),
|
||||
newYaw,
|
||||
p.getLocation().getPitch()
|
||||
);
|
||||
// Riding
|
||||
final Entity vehicle = player.getVehicle();
|
||||
final boolean vehicleIsSuitable = (vehicle != null) && (vehicle instanceof Vehicle);
|
||||
|
||||
p.teleport(destLocation);
|
||||
if (vehicle != null && (!vehicleIsSuitable) || !gate.getAllowsVehicles()) {
|
||||
|
||||
if (!gate.getAllowsVehicles() && Plugin.getPlugin().getConfig().getBoolean(ConfigurationUtil.confShowTeleportNoPermissionMessageKey)) {
|
||||
final String notAllowedMessage = Plugin.getPlugin().getConfig().getString(ConfigurationUtil.confGateTeleportVehicleNotAllowedMessageKey);
|
||||
player.sendMessage(ChatColor.DARK_AQUA + notAllowedMessage);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// (eject player)
|
||||
if (vehicleIsSuitable) {
|
||||
vehicle.eject();
|
||||
vehicle.remove();
|
||||
}
|
||||
|
||||
// Teleport
|
||||
player.teleport(destLocation);
|
||||
|
||||
// Riding (mount player)
|
||||
if (vehicleIsSuitable) {
|
||||
final Plugin plugin = Plugin.getPlugin();
|
||||
final BukkitScheduler scheduler = plugin.getServer().getScheduler();
|
||||
|
||||
destLocation.getChunk().load(); // load the destination chunk, no new entity will be created otherwise
|
||||
|
||||
scheduler.scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run()
|
||||
{
|
||||
// FIXME: the code below should be executed after the chunk got loaded and not after a fixed time!
|
||||
|
||||
// create a new entity at the destination location
|
||||
final Vehicle newVehicle = VehicleCloner.clone((Vehicle)vehicle, destLocation);
|
||||
newVehicle.setPassenger(player);
|
||||
}
|
||||
}, 2);
|
||||
}
|
||||
|
||||
// Message
|
||||
if (Plugin.getPlugin().getConfig().getBoolean(ConfigurationUtil.confShowTeleportMessageKey)) {
|
||||
String teleporMessage = Plugin.getPlugin().getConfig().getString(ConfigurationUtil.confGateTeleportMessageKey);
|
||||
p.sendMessage(ChatColor.DARK_AQUA + teleporMessage);
|
||||
final String teleportMessage = Plugin.getPlugin().getConfig().getString(ConfigurationUtil.confGateTeleportMessageKey);
|
||||
player.sendMessage(ChatColor.DARK_AQUA + teleportMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected boolean hasPermission(Player player, Gate gate)
|
||||
protected boolean hasPermission(final Player player, final Gate gate)
|
||||
{
|
||||
if (Plugin.getPermission() == null) { // fallback: use the standard bukkit permission system
|
||||
return player.hasPermission(Plugin.permissionUse);
|
||||
}
|
||||
else {
|
||||
boolean permAtLocation = Plugin.getPermission().has(gate.getLocation().getWorld(), player.getName(), Plugin.permissionUse);
|
||||
boolean permAtExit = Plugin.getPermission().has(gate.getExit().getWorld(), player.getName(), Plugin.permissionUse);
|
||||
final boolean permAtLocation = Plugin.getPermission().has(gate.getLocation().getWorld(), player.getName(), Plugin.permissionUse);
|
||||
final boolean permAtExit = Plugin.getPermission().has(gate.getExit().getWorld(), player.getName(), Plugin.permissionUse);
|
||||
|
||||
return permAtLocation && permAtExit;
|
||||
}
|
||||
|
@ -31,18 +31,14 @@ public class MigrationUtil
|
||||
{
|
||||
public static boolean performMigration(int storageVersion, int currentVersion, List<Gate> gates)
|
||||
{
|
||||
if (currentVersion == 1 && storageVersion == 0) {
|
||||
if (storageVersion == 0 && currentVersion >= 2) {
|
||||
removePortalBlocks(gates);
|
||||
updateAllowVehicles(gates);
|
||||
|
||||
for (Gate g : gates) {
|
||||
|
||||
for (Location l : g.getGateBlockLocations()) {
|
||||
Block b = l.getBlock();
|
||||
|
||||
if (b.getType() == Material.PORTAL) {
|
||||
b.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (storageVersion == 1 && currentVersion >= 2) {
|
||||
updateAllowVehicles(gates);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -51,4 +47,28 @@ public class MigrationUtil
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected static void removePortalBlocks(List<Gate> gates)
|
||||
{
|
||||
for (Gate g : gates) {
|
||||
|
||||
for (Location l : g.getGateBlockLocations()) {
|
||||
Block b = l.getBlock();
|
||||
|
||||
if (b.getType() == Material.PORTAL) {
|
||||
b.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected static void updateAllowVehicles(List<Gate> gates)
|
||||
{
|
||||
for (Gate g : gates) {
|
||||
|
||||
g.setAllowsVehicles(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ public class ConfigurationUtil
|
||||
public static final String confPlayerGateBlockUpdateRadiusKey = "playerGateBlockUpdateRadius";
|
||||
public static final String confCheckForBrokenGateFramesKey = "checkForBrokenGateFrames";
|
||||
public static final String confGateTeleportMessageKey = "gateTeleportMessage";
|
||||
public static final String confGateTeleportVehicleNotAllowedMessageKey = "gateTeleportVehicleNotAllowedMessage";
|
||||
public static final String confShowTeleportMessageKey = "showTeleportMessage";
|
||||
public static final String confGateTeleportNoPermissionMessageKey = "gateTeleportNoPermissionMessage";
|
||||
public static final String confShowTeleportNoPermissionMessageKey = "showTeleportNoPermissionMessage";
|
||||
@ -62,10 +63,10 @@ public class ConfigurationUtil
|
||||
material.material = Material.DEAD_BUSH;
|
||||
}
|
||||
else if (materialString.equals("dandelion")) {
|
||||
material.material = Material.YELLOW_FLOWER; // TODO: this will change with minecraft 1.7
|
||||
material.material = Material.YELLOW_FLOWER;
|
||||
}
|
||||
else if (materialString.equals("poppy")) {
|
||||
material.material = Material.RED_ROSE; // TODO: this will change with minecraft 1.7
|
||||
material.material = Material.RED_ROSE;
|
||||
}
|
||||
else if (materialString.equals("brown mushroom")) {
|
||||
material.material = Material.BROWN_MUSHROOM;
|
||||
|
113
src/de/craftinc/gates/util/VehicleCloner.java
Normal file
113
src/de/craftinc/gates/util/VehicleCloner.java
Normal file
@ -0,0 +1,113 @@
|
||||
/* 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 org.bukkit.Location;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
|
||||
public class VehicleCloner
|
||||
{
|
||||
public static Vehicle clone(Vehicle parent, Location cloneLocation)
|
||||
{
|
||||
Vehicle clone = cloneLocation.getWorld().spawn(cloneLocation, parent.getClass());
|
||||
|
||||
clone.setFallDistance(parent.getFallDistance());
|
||||
clone.setFireTicks(parent.getFireTicks());
|
||||
clone.setVelocity(parent.getVelocity());
|
||||
clone.setTicksLived(parent.getTicksLived());
|
||||
clone.setLastDamageCause(parent.getLastDamageCause());
|
||||
|
||||
if (clone instanceof Boat) {
|
||||
Boat boat = (Boat)clone;
|
||||
Boat parentBoat = (Boat)parent;
|
||||
|
||||
boat.setMaxSpeed(parentBoat.getMaxSpeed());
|
||||
boat.setOccupiedDeceleration(parentBoat.getOccupiedDeceleration());
|
||||
boat.setUnoccupiedDeceleration(parentBoat.getUnoccupiedDeceleration());
|
||||
boat.setWorkOnLand(parentBoat.getWorkOnLand());
|
||||
boat.setVelocity(parentBoat.getVelocity());
|
||||
}
|
||||
else if (clone instanceof Animals) {
|
||||
Animals animal = (Animals)clone;
|
||||
Animals parentAnimal = (Animals)parent;
|
||||
|
||||
animal.setMaxHealth(parentAnimal.getMaxHealth());
|
||||
animal.setHealth(parentAnimal.getMaxHealth());
|
||||
animal.setRemainingAir(parentAnimal.getRemainingAir());
|
||||
animal.setMaximumAir(parentAnimal.getMaximumAir());
|
||||
animal.setMaximumNoDamageTicks(parentAnimal.getMaximumNoDamageTicks());
|
||||
animal.setLastDamage(parentAnimal.getLastDamage());
|
||||
animal.setNoDamageTicks(parentAnimal.getNoDamageTicks());
|
||||
animal.addPotionEffects(parentAnimal.getActivePotionEffects());
|
||||
animal.setRemoveWhenFarAway(parentAnimal.getRemoveWhenFarAway());
|
||||
animal.setCanPickupItems(parentAnimal.getCanPickupItems());
|
||||
animal.setCustomName(parentAnimal.getCustomName());
|
||||
animal.setCustomNameVisible(parentAnimal.isCustomNameVisible());
|
||||
animal.setTarget(parentAnimal.getTarget());
|
||||
animal.setAge(parentAnimal.getAge());
|
||||
animal.setAgeLock(parentAnimal.getAgeLock());
|
||||
|
||||
if (clone instanceof Horse) {
|
||||
Horse horse = (Horse)clone;
|
||||
Horse parentHorse = (Horse)parent;
|
||||
|
||||
horse.getInventory().setArmor(parentHorse.getInventory().getArmor());
|
||||
horse.getInventory().setSaddle(parentHorse.getInventory().getSaddle());
|
||||
horse.setCarryingChest(parentHorse.isCarryingChest());
|
||||
horse.getInventory().setContents(parentHorse.getInventory().getContents());
|
||||
horse.setTamed(parentHorse.isTamed());
|
||||
horse.setOwner(parentHorse.getOwner());
|
||||
horse.setJumpStrength(parentHorse.getJumpStrength());
|
||||
horse.setMaxDomestication(parentHorse.getMaxDomestication());
|
||||
horse.setDomestication(parentHorse.getDomestication());
|
||||
horse.setStyle(parentHorse.getStyle());
|
||||
horse.setColor(parentHorse.getColor());
|
||||
horse.setVariant(parentHorse.getVariant());
|
||||
|
||||
if (parentHorse.isAdult()) {
|
||||
horse.setAdult();
|
||||
}
|
||||
else {
|
||||
horse.setBaby();
|
||||
}
|
||||
|
||||
horse.setBreed(parentHorse.canBreed());
|
||||
}
|
||||
else if (clone instanceof Pig) {
|
||||
Pig pig = (Pig)clone;
|
||||
Pig parentPig = (Pig)parent;
|
||||
|
||||
pig.setSaddle(parentPig.hasSaddle());
|
||||
}
|
||||
}
|
||||
else if (clone instanceof Minecart) {
|
||||
Minecart minecart = (Minecart)clone;
|
||||
Minecart parentMinecart = (Minecart)parent;
|
||||
|
||||
minecart.setDerailedVelocityMod(parentMinecart.getDerailedVelocityMod());
|
||||
minecart.setFlyingVelocityMod(parentMinecart.getFlyingVelocityMod());
|
||||
minecart.setSlowWhenEmpty(parentMinecart.isSlowWhenEmpty());
|
||||
minecart.setMaxSpeed(parentMinecart.getMaxSpeed());
|
||||
minecart.setDamage(parentMinecart.getDamage());
|
||||
minecart.setVelocity(parentMinecart.getVelocity());
|
||||
}
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user