Compare commits
25 Commits
version2.3
...
master
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 test-server
|
||||||
bukkit-testserver/
|
bukkit-testserver/
|
||||||
|
dependency-reduced-pom.xml
|
||||||
|
16
README.md
16
README.md
@ -1,10 +1,5 @@
|
|||||||
|
|
||||||
# Craft Inc. Gates #
|
# 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 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_.
|
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:
|
The key features of this are:
|
||||||
|
|
||||||
|
* Dynmap integration
|
||||||
* Gates with and without frames
|
* Gates with and without frames
|
||||||
* Gates consisting of portal blocks and gates made of air (so called hidden gates)
|
* Gates consisting of portal blocks and gates made of air (so called hidden gates)
|
||||||
* Gates with destinations in different worlds
|
* Gates with destinations in different worlds
|
||||||
* Gates with custom shapes (gates can look any way you want)
|
* 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!
|
*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 ##
|
## Installing ##
|
||||||
|
|
||||||
1. Download the latest release _[here](http://dev.bukkit.org/bukkit-plugins/craftinc-gates/files/)_
|
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.
|
2. Delete any old versions of _Craft Inc. Gates_ (only the .jar files) including the extra dynmap-plugin of this plugin.
|
||||||
3. Start or reload the server.
|
3. Extract the content of the zip file into the plugins folder of your Bukkit server.
|
||||||
|
4. Start or reload the server.
|
||||||
|
|
||||||
## Craft Inc. ##
|
## Craft Inc. ##
|
||||||
Check out our __[Craft Inc. Minecraft Server](http://www.craftinc.de)__. Everyone is welcome!
|
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!
|
coming soon!
|
||||||
|
|
||||||
## Roadmap ##
|
## 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.
|
* Per player permissions for using and managing gates.
|
||||||
* Horizontal gates.
|
* Horizontal gates.
|
||||||
|
|
||||||
@ -87,3 +82,4 @@ Please use our [_issue tracker_](https://github.com/craftinc/craftinc-gates/issu
|
|||||||
## Legal Information ##
|
## 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).
|
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.
|
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 ##
|
## 2.3.0 ##
|
||||||
* Added a command for setting the exit and opening a gate at once.
|
* Added a command for setting the exit and opening a gate at once.
|
||||||
* Enabled the ability to change the gate block material.
|
* 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]__
|
* __/gate close, c [id]__
|
||||||
Closes a gate to prevent players from using it.
|
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]__
|
* __/gate delete, del, remove [id]__
|
||||||
Removes the gate from the game.
|
Removes the gate from the game.
|
||||||
|
|
||||||
|
@ -41,11 +41,13 @@ be displayed.
|
|||||||
|
|
||||||
|
|
||||||
* __gateTeleportNoPermissionMessage__
|
* __gateTeleportNoPermissionMessage__
|
||||||
A string value going to displayed every time when a player enters a gate and is not
|
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_
|
||||||
allowed to use that gate. Will only be displayed if _showTeleportNoPermissionMessage_
|
|
||||||
is set to _true_.
|
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__
|
* __showTeleportNoPermissionMessage__
|
||||||
A boolean (_true_ or _false_) determining wether the _no permission message_ will
|
A boolean (_true_ or _false_) determining wether the _no permission message_ will
|
||||||
be displayed.
|
be displayed.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: ${project.name}
|
name: ${project.name}
|
||||||
version: ${project.version}
|
version: ${project.version}
|
||||||
description: A plugin to create gates for fast traveling.
|
description: A plugin to create gates for fast traveling.
|
||||||
softdepend: [Vault]
|
softdepend: [Vault, Multiverse-Core, MultiWorld, RoyalCommands]
|
||||||
author: tomco, s1m0ne
|
author: tomco, s1m0ne
|
||||||
authors: [oloflarsson, locutus, DrAgonmoray, s1m0ne, tomco]
|
authors: [oloflarsson, locutus, DrAgonmoray, s1m0ne, tomco]
|
||||||
website: http://dev.bukkit.org/bukkit-plugins/craftinc-gates/
|
website: http://dev.bukkit.org/bukkit-plugins/craftinc-gates/
|
||||||
|
4
pom.xml
4
pom.xml
@ -7,7 +7,7 @@
|
|||||||
<name>Craft Inc. Gates</name>
|
<name>Craft Inc. Gates</name>
|
||||||
<url>http://dev.bukkit.org/bukkit-plugins/craftinc-gates/</url>
|
<url>http://dev.bukkit.org/bukkit-plugins/craftinc-gates/</url>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>2.3.0</version>
|
<version>2.4.0</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
@ -93,7 +93,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.6.4-R2.0</version>
|
<version>1.7.2-R0.2-SNAPSHOT</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -7,4 +7,5 @@ gateTeleportMessage: "Thank you for traveling with Craft Inc. Gates."
|
|||||||
showTeleportMessage: true
|
showTeleportMessage: true
|
||||||
gateTeleportNoPermissionMessage: "You are not allowed to use this gate!"
|
gateTeleportNoPermissionMessage: "You are not allowed to use this gate!"
|
||||||
showTeleportNoPermissionMessage: true
|
showTeleportNoPermissionMessage: true
|
||||||
|
gateTeleportVehicleNotAllowedMessage: "You must not use that gate while riding!"
|
||||||
gateMaterial: "nether portal"
|
gateMaterial: "nether portal"
|
@ -38,6 +38,8 @@ public class Gate implements ConfigurationSerializable
|
|||||||
protected boolean isHidden = false;
|
protected boolean isHidden = false;
|
||||||
protected boolean isOpen = false;
|
protected boolean isOpen = false;
|
||||||
|
|
||||||
|
protected boolean allowsVehicles = true;
|
||||||
|
|
||||||
protected String id;
|
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.
|
* @return Will never return 'null' but might return an empty Set.
|
||||||
@ -265,6 +279,7 @@ public class Gate implements ConfigurationSerializable
|
|||||||
static protected String locationPitchKey = "locationPitch";
|
static protected String locationPitchKey = "locationPitch";
|
||||||
static protected String exitYawKey = "exitYaw";
|
static protected String exitYawKey = "exitYaw";
|
||||||
static protected String exitPitchKey = "exitPitch";
|
static protected String exitPitchKey = "exitPitch";
|
||||||
|
static protected String allowsVehiclesKey = "allowsVehiclesKey";
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@ -273,10 +288,6 @@ public class Gate implements ConfigurationSerializable
|
|||||||
try {
|
try {
|
||||||
id = map.get(idKey).toString().toLowerCase();
|
id = map.get(idKey).toString().toLowerCase();
|
||||||
|
|
||||||
if (id == null) {
|
|
||||||
throw new Exception("gates need to have an id");
|
|
||||||
}
|
|
||||||
|
|
||||||
isHidden = (Boolean)map.get(isHiddenKey);
|
isHidden = (Boolean)map.get(isHiddenKey);
|
||||||
isOpen = (Boolean)map.get(isOpenKey);
|
isOpen = (Boolean)map.get(isOpenKey);
|
||||||
|
|
||||||
@ -293,6 +304,10 @@ public class Gate implements ConfigurationSerializable
|
|||||||
location.setYaw(((Number)map.get(locationYawKey)).floatValue());
|
location.setYaw(((Number)map.get(locationYawKey)).floatValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (map.containsKey(allowsVehiclesKey)) {
|
||||||
|
allowsVehicles = (Boolean)map.get(allowsVehiclesKey);
|
||||||
|
}
|
||||||
|
|
||||||
gateBlockLocations = new HashSet<Location>();
|
gateBlockLocations = new HashSet<Location>();
|
||||||
List<Map<String, Object>> serializedGateBlocks = (List<Map<String, Object>>)map.get(gateBlocksKey);
|
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(exitKey, LocationUtil.serializeLocation(exit));
|
||||||
retVal.put(isHiddenKey, isHidden);
|
retVal.put(isHiddenKey, isHidden);
|
||||||
retVal.put(isOpenKey, isOpen);
|
retVal.put(isOpenKey, isOpen);
|
||||||
|
retVal.put(allowsVehiclesKey, allowsVehicles);
|
||||||
|
|
||||||
if (exit != null) {
|
if (exit != null) {
|
||||||
retVal.put(exitPitchKey, exit.getPitch());
|
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 FileConfiguration gatesConfig;
|
||||||
protected static final String gatesPath = "gates"; // path to gates inside the yaml file
|
protected static final String gatesPath = "gates"; // path to gates inside the yaml file
|
||||||
protected static final String storageVersionPath = "version";
|
protected static final String storageVersionPath = "version";
|
||||||
protected static final int storageVersion = 1;
|
protected static final int storageVersion = 2;
|
||||||
|
|
||||||
protected int chunkRadius;
|
protected int chunkRadius;
|
||||||
|
|
||||||
@ -54,6 +54,20 @@ public class GatesManager
|
|||||||
|
|
||||||
protected boolean storageFileIsInvalid = false;
|
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)
|
public Gate getGateWithId(final String id)
|
||||||
{
|
{
|
||||||
@ -489,6 +503,13 @@ public class GatesManager
|
|||||||
{
|
{
|
||||||
this.removeGateById(oldId);
|
this.removeGateById(oldId);
|
||||||
this.addGateWithId(g);
|
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,6 +526,26 @@ public class GatesManager
|
|||||||
|
|
||||||
this.removeGateByFrameLocation(oldGateFrameBlocks);
|
this.removeGateByFrameLocation(oldGateFrameBlocks);
|
||||||
this.addGateByFrameLocations(g);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -516,6 +557,14 @@ public class GatesManager
|
|||||||
this.addGateByLocations(g);
|
this.addGateByLocations(g);
|
||||||
this.addGateWithId(g);
|
this.addGateWithId(g);
|
||||||
this.addGateByFrameLocations(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.removeGateFromChunk(g, g.getLocation());
|
||||||
this.removeGateByLocation(g.getGateBlockLocations());
|
this.removeGateByLocation(g.getGateBlockLocations());
|
||||||
this.removeGateByFrameLocation(g.getGateFrameBlocks());
|
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 CommandUnhide());
|
||||||
commands.add(new CommandExitOpen());
|
commands.add(new CommandExitOpen());
|
||||||
commands.add(new CommandNearby());
|
commands.add(new CommandNearby());
|
||||||
|
commands.add(new CommandAllowRiding());
|
||||||
|
commands.add(new CommandDenyRiding());
|
||||||
|
|
||||||
|
|
||||||
// Register events
|
// 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 org.bukkit.ChatColor;
|
||||||
|
|
||||||
import de.craftinc.gates.Plugin;
|
import de.craftinc.gates.Plugin;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
|
||||||
public class CommandExit extends BaseCommand
|
public class CommandExit extends BaseCommand
|
||||||
@ -47,8 +48,10 @@ public class CommandExit extends BaseCommand
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Location oldExit = gate.getExit();
|
||||||
gate.setExit(player.getLocation());
|
gate.setExit(player.getLocation());
|
||||||
sendMessage(ChatColor.GREEN + "The exit of gate '" + gate.getId() + "' is now where you stand.");
|
sendMessage(ChatColor.GREEN + "The exit of gate '" + gate.getId() + "' is now where you stand.");
|
||||||
|
Plugin.getPlugin().getGatesManager().handleGateExitChange(gate, oldExit);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
GateBlockChangeSender.updateGateBlocks(gate);
|
GateBlockChangeSender.updateGateBlocks(gate);
|
||||||
|
@ -20,6 +20,7 @@ package de.craftinc.gates.commands;
|
|||||||
import de.craftinc.gates.Plugin;
|
import de.craftinc.gates.Plugin;
|
||||||
import de.craftinc.gates.util.GateBlockChangeSender;
|
import de.craftinc.gates.util.GateBlockChangeSender;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@ -46,8 +47,10 @@ public class CommandExitOpen extends BaseCommand
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Location oldExit = gate.getExit();
|
||||||
gate.setExit(player.getLocation());
|
gate.setExit(player.getLocation());
|
||||||
sendMessage(ChatColor.GREEN + "The exit of gate '" + gate.getId() + "' is now where you stand.");
|
sendMessage(ChatColor.GREEN + "The exit of gate '" + gate.getId() + "' is now where you stand.");
|
||||||
|
Plugin.getPlugin().getGatesManager().handleGateExitChange(gate, oldExit);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
boolean needsGateManagerUpdate = false;
|
boolean needsGateManagerUpdate = false;
|
||||||
|
@ -106,6 +106,10 @@ public class CommandInfo extends BaseCommand
|
|||||||
sendMessage(ChatColor.DARK_AQUA + "NOTE: this gate has no exit");
|
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) {
|
if (this.sender instanceof Player) {
|
||||||
GateBlockChangeSender.temporaryHighlightGateFrame((Player)this.sender, this.gate);
|
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.ConfigurationUtil;
|
||||||
import de.craftinc.gates.util.GateBlockChangeSender;
|
import de.craftinc.gates.util.GateBlockChangeSender;
|
||||||
|
import de.craftinc.gates.util.VehicleCloner;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Vehicle;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -32,6 +35,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
|||||||
import de.craftinc.gates.Gate;
|
import de.craftinc.gates.Gate;
|
||||||
import de.craftinc.gates.GatesManager;
|
import de.craftinc.gates.GatesManager;
|
||||||
import de.craftinc.gates.Plugin;
|
import de.craftinc.gates.Plugin;
|
||||||
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
|
|
||||||
|
|
||||||
public class PlayerMoveListener implements Listener
|
public class PlayerMoveListener implements Listener
|
||||||
@ -49,23 +53,10 @@ public class PlayerMoveListener implements Listener
|
|||||||
GateBlockChangeSender.updateGateBlocks(event.getPlayer(), event.getTo());
|
GateBlockChangeSender.updateGateBlocks(event.getPlayer(), event.getTo());
|
||||||
}
|
}
|
||||||
|
|
||||||
GatesManager gateManager = Plugin.getPlugin().getGatesManager();
|
final GatesManager gateManager = Plugin.getPlugin().getGatesManager();
|
||||||
Gate gateAtLocation = gateManager.getGateAtLocation(event.getTo());
|
final Gate gateAtLocation = gateManager.getGateAtLocation(event.getTo());
|
||||||
|
|
||||||
if (gateAtLocation == null) {
|
if ((gateAtLocation == null) || !gateAtLocation.isOpen()) {
|
||||||
// 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) {
|
|
||||||
return;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!gateAtLocation.isOpen()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,19 +64,19 @@ public class PlayerMoveListener implements Listener
|
|||||||
if (!hasPermission(event.getPlayer(), gateAtLocation)
|
if (!hasPermission(event.getPlayer(), gateAtLocation)
|
||||||
&& Plugin.getPlugin().getConfig().getBoolean(ConfigurationUtil.confShowTeleportNoPermissionMessageKey)) {
|
&& Plugin.getPlugin().getConfig().getBoolean(ConfigurationUtil.confShowTeleportNoPermissionMessageKey)) {
|
||||||
|
|
||||||
String playerName = event.getPlayer().getName();
|
final String playerName = event.getPlayer().getName();
|
||||||
|
|
||||||
if (playerName == null) {
|
if (playerName == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the current time
|
// 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
|
// do not display messages more often than once per second
|
||||||
if (!this.lastNoPermissionMessages.containsKey(playerName) || this.lastNoPermissionMessages.get(playerName) < now - 10000L) {
|
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);
|
event.getPlayer().sendMessage(ChatColor.RED + noPermissionString);
|
||||||
this.lastNoPermissionMessages.put(playerName, now);
|
this.lastNoPermissionMessages.put(playerName, now);
|
||||||
}
|
}
|
||||||
@ -98,38 +89,79 @@ public class PlayerMoveListener implements Listener
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Teleports a player.
|
* Teleports a player.
|
||||||
* @param p The player to teleport.
|
* @param player The player to teleport.
|
||||||
* @param g The gate to which exit the player will be teleported.
|
* @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();
|
||||||
Location destLocation = new Location( g.getExit().getWorld(),
|
final Location destLocation = new Location( gate.getExit().getWorld(),
|
||||||
g.getExit().getX(),
|
gate.getExit().getX(),
|
||||||
g.getExit().getY(),
|
gate.getExit().getY(),
|
||||||
g.getExit().getZ(),
|
gate.getExit().getZ(),
|
||||||
newYaw,
|
newYaw,
|
||||||
p.getLocation().getPitch()
|
player.getLocation().getPitch()
|
||||||
);
|
);
|
||||||
|
|
||||||
p.teleport(destLocation);
|
// Riding
|
||||||
|
final Entity vehicle = player.getVehicle();
|
||||||
|
final boolean vehicleIsSuitable = (vehicle != null) && (vehicle instanceof Vehicle);
|
||||||
|
|
||||||
|
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)) {
|
if (Plugin.getPlugin().getConfig().getBoolean(ConfigurationUtil.confShowTeleportMessageKey)) {
|
||||||
String teleporMessage = Plugin.getPlugin().getConfig().getString(ConfigurationUtil.confGateTeleportMessageKey);
|
final String teleportMessage = Plugin.getPlugin().getConfig().getString(ConfigurationUtil.confGateTeleportMessageKey);
|
||||||
p.sendMessage(ChatColor.DARK_AQUA + teleporMessage);
|
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
|
if (Plugin.getPermission() == null) { // fallback: use the standard bukkit permission system
|
||||||
return player.hasPermission(Plugin.permissionUse);
|
return player.hasPermission(Plugin.permissionUse);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
boolean permAtLocation = Plugin.getPermission().has(gate.getLocation().getWorld(), player.getName(), Plugin.permissionUse);
|
final 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 permAtExit = Plugin.getPermission().has(gate.getExit().getWorld(), player.getName(), Plugin.permissionUse);
|
||||||
|
|
||||||
return permAtLocation && permAtExit;
|
return permAtLocation && permAtExit;
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,26 @@ public class MigrationUtil
|
|||||||
{
|
{
|
||||||
public static boolean performMigration(int storageVersion, int currentVersion, List<Gate> gates)
|
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);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (storageVersion == 1 && currentVersion >= 2) {
|
||||||
|
updateAllowVehicles(gates);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Plugin.log(Level.SEVERE, "Supplied storage version is currently not supported! Make sure you have the latest version of Craft Inc. Gates installed. Plugin will be disabled!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected static void removePortalBlocks(List<Gate> gates)
|
||||||
|
{
|
||||||
for (Gate g : gates) {
|
for (Gate g : gates) {
|
||||||
|
|
||||||
for (Location l : g.getGateBlockLocations()) {
|
for (Location l : g.getGateBlockLocations()) {
|
||||||
@ -43,12 +61,14 @@ public class MigrationUtil
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
Plugin.log(Level.SEVERE, "Supplied storage version is currently not supported! Make sure you have the latest version of Craft Inc. Gates installed. Plugin will be disabled!");
|
|
||||||
return false;
|
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 confPlayerGateBlockUpdateRadiusKey = "playerGateBlockUpdateRadius";
|
||||||
public static final String confCheckForBrokenGateFramesKey = "checkForBrokenGateFrames";
|
public static final String confCheckForBrokenGateFramesKey = "checkForBrokenGateFrames";
|
||||||
public static final String confGateTeleportMessageKey = "gateTeleportMessage";
|
public static final String confGateTeleportMessageKey = "gateTeleportMessage";
|
||||||
|
public static final String confGateTeleportVehicleNotAllowedMessageKey = "gateTeleportVehicleNotAllowedMessage";
|
||||||
public static final String confShowTeleportMessageKey = "showTeleportMessage";
|
public static final String confShowTeleportMessageKey = "showTeleportMessage";
|
||||||
public static final String confGateTeleportNoPermissionMessageKey = "gateTeleportNoPermissionMessage";
|
public static final String confGateTeleportNoPermissionMessageKey = "gateTeleportNoPermissionMessage";
|
||||||
public static final String confShowTeleportNoPermissionMessageKey = "showTeleportNoPermissionMessage";
|
public static final String confShowTeleportNoPermissionMessageKey = "showTeleportNoPermissionMessage";
|
||||||
@ -62,10 +63,10 @@ public class ConfigurationUtil
|
|||||||
material.material = Material.DEAD_BUSH;
|
material.material = Material.DEAD_BUSH;
|
||||||
}
|
}
|
||||||
else if (materialString.equals("dandelion")) {
|
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")) {
|
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")) {
|
else if (materialString.equals("brown mushroom")) {
|
||||||
material.material = Material.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