Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d473ac3f78 | ||
|
|
093e01d865 | ||
|
|
2d7626684f | ||
|
|
698671c700 | ||
|
|
0d06fb8a0d | ||
|
|
6e6c40bd3b | ||
|
|
4067d0cd28 | ||
|
|
5b19404c13 | ||
|
|
e6f81b01d6 | ||
|
|
25d9231d30 | ||
|
|
3284670153 | ||
|
|
ea920c1252 | ||
|
|
987e2eff51 | ||
|
|
67c165ff25 | ||
|
|
e7aa563352 | ||
|
|
56926dc14c | ||
|
|
2d0eb7e7bb | ||
|
|
54e7bc454a | ||
|
|
01bed7cc4b | ||
|
|
5d11e27eb0 | ||
|
|
fbc5c6f0d2 | ||
|
|
b867df7315 | ||
|
|
a8068a5669 | ||
|
|
ab17064006 | ||
|
|
d3c1538083 | ||
|
|
b2ef10a699 | ||
|
|
fba3f71238 | ||
|
|
af3dcf049d | ||
|
|
a30222bec7 | ||
|
|
86af11b662 | ||
|
|
750adcf376 | ||
|
|
c200d43f51 | ||
|
|
f4093cbe51 | ||
|
|
4366b16a74 | ||
|
|
cfdd1ac38c | ||
|
|
3e10f18079 | ||
|
|
c7c73e7094 | ||
|
|
c7e5816b2e | ||
|
|
50a89b7b1a | ||
|
|
1aad872333 | ||
|
|
73b42b5430 | ||
|
|
e93fec45ac | ||
|
|
23933c4706 | ||
|
|
9e14daac1f | ||
|
|
aa079b2920 | ||
|
|
bac24e1c97 | ||
|
|
c72f602045 | ||
|
|
c22a8a9d18 | ||
|
|
2759d75125 | ||
|
|
980381194b | ||
|
|
8370a72776 | ||
|
|
e0f9344d20 | ||
|
|
3fde98049f | ||
|
|
40c04a1f4e | ||
|
|
5386aadbb7 | ||
|
|
5e0903086e | ||
|
|
ff47610424 | ||
|
|
84e178d12e | ||
|
|
f2a263f86c | ||
|
|
3c750104a5 | ||
|
|
f69c85e6b0 | ||
|
|
6e4de79bfb | ||
|
|
2d112edee5 | ||
|
|
4a634e8418 | ||
|
|
e31f2c79ac | ||
|
|
cc3889b166 | ||
|
|
7bbdac9012 | ||
|
|
d04a42ee92 | ||
|
|
fa80b66ac2 | ||
|
|
ae19604eab | ||
|
|
6e7daf4e85 | ||
|
|
86d3628b1c | ||
|
|
9be14a2a0c | ||
|
|
091c5a9621 | ||
|
|
c566ead9ef | ||
|
|
d97bbfb1b1 | ||
|
|
ea6e94d99d | ||
|
|
f0ae8cbb8e | ||
|
|
1a6e93f0df | ||
|
|
8fe128ec0f | ||
|
|
f3cd433e80 | ||
|
|
0964f461eb | ||
|
|
fa409ac4f5 | ||
|
|
3753256611 | ||
|
|
b378b0cf79 | ||
|
|
e5646bbbfd | ||
|
|
66538ccd02 | ||
|
|
d63c043368 | ||
|
|
65dce752d4 | ||
|
|
268b272f4d | ||
|
|
eb0b83c507 | ||
|
|
f009ad6dd6 | ||
|
|
6b543a793a | ||
|
|
05de5055ab | ||
|
|
688ea7a1d3 | ||
|
|
fc02efd90f | ||
|
|
6039009e3f | ||
|
|
a9cb378eab | ||
|
|
fcfa45717c | ||
|
|
9333f70add | ||
|
|
30704338e6 | ||
|
|
17a519f961 | ||
|
|
74aba9d6e8 | ||
|
|
43fcbc9af9 | ||
|
|
fa3e0d6186 | ||
|
|
20ce518d33 | ||
|
|
f9481db5a6 | ||
|
|
1b42a25ccb | ||
|
|
e3edcb88df | ||
|
|
bef22ba534 | ||
|
|
10d6a7e1dc | ||
|
|
b39098a592 | ||
|
|
a2c6dad243 | ||
|
|
b76da91013 | ||
|
|
e7f97a8ae7 | ||
|
|
e792c338aa | ||
|
|
133810550f | ||
|
|
97168043ff | ||
|
|
40c4ce0a37 | ||
|
|
318564ccf2 | ||
|
|
9c1a9769b2 | ||
|
|
89ea09fba2 | ||
|
|
9384f96549 | ||
|
|
69b143ada6 | ||
|
|
a97b6f80d2 | ||
|
|
ad47ce7d1b | ||
|
|
d09d340e0f | ||
|
|
751ed5a8e8 | ||
|
|
a0667d49b8 | ||
|
|
8c45d0b76a | ||
|
|
319567eb67 | ||
|
|
7a38806134 | ||
|
|
b6755a1047 | ||
|
|
69360a49ec | ||
|
|
3876c0f47f | ||
|
|
5fe8f76c34 | ||
|
|
e556261e84 | ||
|
|
8d09c19988 | ||
|
|
4fd0150945 | ||
|
|
f96f3151f9 | ||
|
|
047e0d8001 | ||
|
|
5f88247810 | ||
|
|
d12725ca0e | ||
|
|
dc9f2fc360 | ||
|
|
2c865aa0ff | ||
|
|
f11f3dd88e | ||
|
|
c503849107 | ||
|
|
ce8b042919 | ||
|
|
92a762e5e4 | ||
|
|
eb4f9700bc | ||
|
|
49e3a42550 | ||
|
|
1ab56096f8 | ||
|
|
afc388637f | ||
|
|
93fab486ff | ||
|
|
e36210b99a | ||
|
|
f6299c60a0 | ||
|
|
06bc0dea02 | ||
|
|
11ce604938 |
No files matched your search
+4
-1
@@ -30,4 +30,7 @@
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
.idea/
|
||||
|
||||
# Fern's utils
|
||||
uploadtoserver.sh
|
||||
+1
-1
Submodule lib/allpay updated: b6b450e8b6...18c55a9070.
+1
-1
Submodule lib/commandhandler updated: ac9d8c94e4...50ecf6af45.
@@ -1,160 +1,196 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.onarandombox.multiversecore</groupId>
|
||||
<artifactId>Multiverse-Core</artifactId>
|
||||
<version>2.0</version>
|
||||
<name>Multiverse-Core</name>
|
||||
<description>World Management Plugin</description>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.build.number>UNKNOWN</project.build.number>
|
||||
</properties>
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.onarandombox.multiversecore</groupId>
|
||||
<artifactId>Multiverse-Core</artifactId>
|
||||
<version>2.1</version>
|
||||
<name>Multiverse-Core</name>
|
||||
<description>World Management Plugin</description>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.build.number>UNKNOWN</project.build.number>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>OnARandomBox</id>
|
||||
<url>http://repo.onarandombox.com/artifactory/repo</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>OnARandomBox</id>
|
||||
<url>http://repo.onarandombox.com/artifactory/repo</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean package</defaultGoal>
|
||||
<plugins>
|
||||
<!-- Compiler -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Build Helper - Additional Source Folders -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>1.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-wsdl-source</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>${project.basedir}/lib/allpay/src</source>
|
||||
<source>${project.basedir}/lib/commandhandler/src</source>
|
||||
<source>${project.basedir}/lib/commandhandler/lib/ShellParser/src</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
||||
<artifactId>maven-replacer-plugin</artifactId>
|
||||
<version>1.3.8</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<file>target/classes/plugin.yml</file>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>maven-version-number</token>
|
||||
<value>${project.version}-${project.build.number}</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Jar Plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<!-- Bukkit Dependency -->
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- Bukkit Dependency -->
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>doodleproject-repo</id>
|
||||
<name>DoodleProject Maven 2 Repository</name>
|
||||
<url>http://doodleproject.sourceforge.net/maven2/release</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<!-- Start of Economy Dependencies -->
|
||||
<dependency>
|
||||
<groupId>cosine.boseconomy</groupId>
|
||||
<artifactId>BOSEconomy</artifactId>
|
||||
<version>0.6.2</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<ciManagement>
|
||||
<system>jenkins</system>
|
||||
<url>http://ci.onarandombox.com</url>
|
||||
</ciManagement>
|
||||
|
||||
<dependency>
|
||||
<groupId>fr.crafter.tickleman.RealShop</groupId>
|
||||
<artifactId>RealShop</artifactId>
|
||||
<version>0.63</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<build>
|
||||
<defaultGoal>clean package</defaultGoal>
|
||||
<plugins>
|
||||
<!-- Compiler -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Build Helper - Additional Source Folders -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>1.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-wsdl-source</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>${project.basedir}/lib/allpay/src</source>
|
||||
<source>${project.basedir}/lib/commandhandler/src</source>
|
||||
<source>${project.basedir}/lib/commandhandler/lib/ShellParser/src</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
||||
<artifactId>maven-replacer-plugin</artifactId>
|
||||
<version>1.3.8</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<file>target/classes/plugin.yml</file>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>maven-version-number</token>
|
||||
<value>${project.version}-${project.build.number}</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Jar Plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Maven Source Plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.1.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.iConomy</groupId>
|
||||
<artifactId>iConomy</artifactId>
|
||||
<version>5.0</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependencies>
|
||||
<!-- Bukkit Dependency -->
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- Bukkit Dependency -->
|
||||
<!-- Start of Spout -->
|
||||
<dependency>
|
||||
<groupId>org.getspout</groupId>
|
||||
<artifactId>spoutapi</artifactId>
|
||||
<version>dev-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- End of Spout -->
|
||||
<!-- Start of Economy Dependencies -->
|
||||
<dependency>
|
||||
<groupId>cosine.boseconomy</groupId>
|
||||
<artifactId>BOSEconomy</artifactId>
|
||||
<version>0.6.2</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.nijiko.coelho.iConomy</groupId>
|
||||
<artifactId>iConomy</artifactId>
|
||||
<version>4.65</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.crafter.tickleman.RealShop</groupId>
|
||||
<artifactId>RealShop</artifactId>
|
||||
<version>0.63</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.earth2me.essentials</groupId>
|
||||
<artifactId>Essentials</artifactId>
|
||||
<version>2.4.2</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- End of Economy Dependencies -->
|
||||
<dependency>
|
||||
<groupId>com.iCo6</groupId>
|
||||
<artifactId>iConomy</artifactId>
|
||||
<version>6.0</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Start of Permissions Dependencies -->
|
||||
<dependency>
|
||||
<groupId>com.nijikokun.bukkit</groupId>
|
||||
<artifactId>Permissions</artifactId>
|
||||
<version>3.2</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.8.2</version>
|
||||
</dependency>
|
||||
<!-- End of Permissions Dependencies -->
|
||||
</dependencies>
|
||||
<dependency>
|
||||
<groupId>com.iConomy</groupId>
|
||||
<artifactId>iConomy</artifactId>
|
||||
<version>5.0</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.nijiko.coelho.iConomy</groupId>
|
||||
<artifactId>iConomy</artifactId>
|
||||
<version>4.65</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.earth2me.essentials</groupId>
|
||||
<artifactId>Essentials</artifactId>
|
||||
<version>2.4.2</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.ashtheking.currency</groupId>
|
||||
<artifactId>MultiCurrency</artifactId>
|
||||
<version>0.09</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- End of Economy Dependencies -->
|
||||
<!-- Start of JUnit Dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.8.2</version>
|
||||
</dependency>
|
||||
<!-- End of JUnit Dependencies -->
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,11 +1,17 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Server;
|
||||
|
||||
public interface LoggablePlugin {
|
||||
public void log(Level level, String msg);
|
||||
|
||||
public Server getServer();
|
||||
/**
|
||||
* Dummy class to make old MV Plugins not explode.
|
||||
* If this loads, the user WILL get a severe telling them to update said plugin!
|
||||
* WILL BE DELETED ON 11/1/11
|
||||
*/
|
||||
@Deprecated
|
||||
public interface LoggablePlugin extends com.onarandombox.MultiverseCore.api.LoggablePlugin {
|
||||
}
|
||||
@@ -1,176 +1,20 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.nijiko.permissions.PermissionHandler;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
import com.onarandombox.utils.MVDestination;
|
||||
import com.pneumaticraft.commandhandler.PermissionsInterface;
|
||||
|
||||
public class MVPermissions implements PermissionsInterface {
|
||||
|
||||
private MultiverseCore plugin;
|
||||
private PermissionHandler permissions = null;
|
||||
|
||||
/**
|
||||
* Constructor FTW
|
||||
*
|
||||
* @param plugin Pass along the Core Plugin.
|
||||
*/
|
||||
/**
|
||||
* Dummy class to make old MV Plugins not explode.
|
||||
* If this loads, the user WILL get a severe telling them to update said plugin!
|
||||
* WILL BE DELETED ON 11/1/11
|
||||
*/
|
||||
@Deprecated
|
||||
public class MVPermissions extends com.onarandombox.MultiverseCore.utils.MVPermissions {
|
||||
public MVPermissions(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
// We have to see if permissions was loaded before MV was
|
||||
if (this.plugin.getServer().getPluginManager().getPlugin("Permissions") != null) {
|
||||
this.setPermissions(((Permissions) this.plugin.getServer().getPluginManager().getPlugin("Permissions")).getHandler());
|
||||
this.plugin.log(Level.INFO, "- Attached to Permissions");
|
||||
}
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a Player can teleport to the Destination world from there current world.
|
||||
*
|
||||
* @param p
|
||||
* @param w
|
||||
* @return
|
||||
*/
|
||||
public Boolean canTravelFromWorld(Player p, MVWorld w) {
|
||||
List<String> blackList = w.getWorldBlacklist();
|
||||
|
||||
boolean returnValue = true;
|
||||
|
||||
for (String s : blackList) {
|
||||
if (s.equalsIgnoreCase(p.getWorld().getName())) {
|
||||
returnValue = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
public boolean canTravelFromLocation(Player teleporter, Location location) {
|
||||
if (!this.plugin.isMVWorld(location.getWorld().getName())) {
|
||||
return false;
|
||||
}
|
||||
return canTravelFromWorld(teleporter, this.plugin.getMVWorld(location.getWorld().getName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the Player has the permissions to enter this world.
|
||||
*
|
||||
* @param p
|
||||
* @param w
|
||||
* @return
|
||||
*/
|
||||
public Boolean canEnterWorld(Player p, MVWorld w) {
|
||||
return this.hasPermission(p, "multiverse.access." + w.getName(), false);
|
||||
}
|
||||
|
||||
public Boolean canEnterLocation(Player p, Location l) {
|
||||
if (l == null) {
|
||||
return false;
|
||||
}
|
||||
String worldName = l.getWorld().getName();
|
||||
if (!this.plugin.isMVWorld(worldName)) {
|
||||
return false;
|
||||
}
|
||||
return this.hasPermission(p, "multiverse.access." + worldName, false);
|
||||
}
|
||||
|
||||
public Boolean canEnterDestination(Player p, MVDestination d) {
|
||||
if (d == null || d.getLocation(p) == null) {
|
||||
return false;
|
||||
}
|
||||
String worldName = d.getLocation(p).getWorld().getName();
|
||||
if (!this.plugin.isMVWorld(worldName)) {
|
||||
return false;
|
||||
}
|
||||
if(!canEnterLocation(p, d.getLocation(p))) {
|
||||
return false;
|
||||
}
|
||||
return this.hasPermission(p, d.getRequiredPermission(), false);
|
||||
}
|
||||
|
||||
public void setPermissions(PermissionHandler handler) {
|
||||
this.permissions = handler;
|
||||
}
|
||||
|
||||
public boolean hasPermission(CommandSender sender, String node, boolean isOpRequired) {
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// NO one can access a null permission (mainly used for destinations):w
|
||||
if(node == null) {
|
||||
return false;
|
||||
}
|
||||
// Everyone can access an empty permission
|
||||
// Currently used for the PlayerDestination
|
||||
if(node.equals("")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
boolean opFallback = this.plugin.getConfig().getBoolean("opfallback", true);
|
||||
if (this.permissions != null && this.permissions.has(player, node)) {
|
||||
// If Permissions is enabled we check against them.
|
||||
// this.plugin.log(Level.WARNING, "Allowed by P3/P2 ");
|
||||
return true;
|
||||
} else if (sender.hasPermission(node)) {
|
||||
// If Now check the bukkit permissions
|
||||
// this.plugin.log(Level.WARNING, "Allowed by BukkitPerms");
|
||||
return true;
|
||||
} else if (player.isOp() && opFallback) {
|
||||
// If Player is Op we always let them use it if they have the fallback enabled!
|
||||
// this.plugin.log(Level.WARNING, "Allowed by OP");
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the Player doesn't have Permissions and isn't an Op then
|
||||
// we return true if OP is not required, otherwise we return false
|
||||
// This allows us to act as a default permission guidance
|
||||
|
||||
// If they have the op fallback disabled, NO commands will work without a permissions plugin.
|
||||
return !isOpRequired && opFallback;
|
||||
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
String opsfallback = "";
|
||||
if(this.plugin.getConfig().getBoolean("opfallback", true)) {
|
||||
opsfallback = " WITH OPs.txt fallback";
|
||||
}
|
||||
if (this.permissions != null) {
|
||||
return "Permissions " + this.plugin.getServer().getPluginManager().getPlugin("Permissions").getDescription().getVersion() + opsfallback;
|
||||
}
|
||||
|
||||
return "Bukkit Permissions" + opsfallback;
|
||||
}
|
||||
|
||||
public boolean hasAnyPermission(CommandSender sender, List<String> nodes, boolean isOpRequired) {
|
||||
for (String node : nodes) {
|
||||
if (this.hasPermission(sender, node, isOpRequired)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAllPermission(CommandSender sender, List<String> nodes, boolean isOpRequired) {
|
||||
for (String node : nodes) {
|
||||
if (!this.hasPermission(sender, node, isOpRequired)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
public class MVPlayerSession {
|
||||
|
||||
private Player player; // Player holder, may be unnecessary.
|
||||
|
||||
private Long teleportLast = 0L; // Timestamp for the Players last Portal Teleportation.
|
||||
private Long messageLast = 0L; // Timestamp for the Players last Alert Message.
|
||||
|
||||
// private Location bedSpawn;
|
||||
//
|
||||
// // Beds are 2 blocks, thus we need to store both places
|
||||
// private Location bedA;
|
||||
// private Location bedB;
|
||||
|
||||
private Configuration config; // Configuration file to find out Cooldown Timers.
|
||||
|
||||
public MVPlayerSession(Player player, Configuration config, MultiverseCore multiVerseCore) {
|
||||
this.player = player;
|
||||
this.config = config;
|
||||
// this.bedSpawn = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Teleport time.
|
||||
*/
|
||||
public void teleport() {
|
||||
this.teleportLast = (new Date()).getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Grab whether the cooldown on Portal use has expired or not.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean getTeleportable() {
|
||||
Long time = (new Date()).getTime();
|
||||
if ((time - this.teleportLast) > this.config.getInt("portalcooldown", 5000)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a Message to the Player as long as enough time has passed since the last message.
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
public void message(String msg) {
|
||||
Long time = (new Date()).getTime();
|
||||
if ((time - this.messageLast) > this.config.getInt("messagecooldown", 2000)) {
|
||||
this.player.sendMessage(msg);
|
||||
this.messageLast = time;
|
||||
}
|
||||
}
|
||||
|
||||
// Commented out bed code, i'll get rid of it soon.
|
||||
// --FF
|
||||
|
||||
// public void setRespawnLocation(Location location) {
|
||||
// this.bedSpawn = location;
|
||||
// }
|
||||
|
||||
// // This one simply spawns the player closer to the bed.
|
||||
// public Location getBedRespawnLocation() {
|
||||
// // There is a bedrespawn set
|
||||
// if (this.bedSpawn != null) {
|
||||
// if (!this.bs.playerCanSpawnHereSafely(this.bedSpawn) || !bedStillExists(this.bedSpawn)) {
|
||||
// this.bedSpawn = null;
|
||||
// return this.bedSpawn;
|
||||
// }
|
||||
// Location actualRespawn = this.bedSpawn;
|
||||
// Location bedRespawn = new Location(actualRespawn.getWorld(), actualRespawn.getX(), actualRespawn.getY(), actualRespawn.getZ());
|
||||
// bedRespawn.setY(bedRespawn.getY() - .25);
|
||||
// return bedRespawn;
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// private boolean bedStillExists(Location bedSpawn) {
|
||||
// //System.out.print("Dangers:");
|
||||
// //this.bs.showDangers(bedSpawn);
|
||||
// Location locationDown = new Location(bedSpawn.getWorld(), bedSpawn.getX(), bedSpawn.getY(), bedSpawn.getZ());
|
||||
// locationDown.setY(locationDown.getY() - 1);
|
||||
// if (locationDown.getBlock().getType() != Material.BED_BLOCK) {
|
||||
// return false;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
}
|
||||
@@ -1,7 +1,17 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
public interface MVPlugin extends LoggablePlugin {
|
||||
public String dumpVersionInfo(String buffer);
|
||||
public MultiverseCore getCore();
|
||||
public void setCore(MultiverseCore core);
|
||||
/**
|
||||
* Dummy class to make old MV Plugins not explode.
|
||||
* If this loads, the user WILL get a severe telling them to update said plugin!
|
||||
* WILL BE DELETED ON 11/1/11
|
||||
*/
|
||||
@Deprecated
|
||||
public interface MVPlugin extends com.onarandombox.MultiverseCore.api.MVPlugin {
|
||||
}
|
||||
@@ -1,216 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
|
||||
import com.onarandombox.utils.BlockSafety;
|
||||
|
||||
public class MVTeleport {
|
||||
|
||||
MultiverseCore plugin;
|
||||
|
||||
BlockSafety bs = new BlockSafety();
|
||||
|
||||
public MVTeleport(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be specific to beds, and check on top of the bed then around it.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Location getSafeBedDestination(Location bedLocation) {
|
||||
// System.out.print(bedLocation);
|
||||
Location idealLocation = bedLocation;
|
||||
idealLocation.setY(idealLocation.getY() + 1);
|
||||
idealLocation.setX(idealLocation.getX() + .5);
|
||||
idealLocation.setZ(idealLocation.getZ() + .5);
|
||||
// System.out.print(idealLocation);
|
||||
if (this.bs.playerCanSpawnHereSafely(idealLocation)) {
|
||||
// System.out.print(idealLocation);
|
||||
return bedLocation;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Location getSafeLocation(Location l) {
|
||||
|
||||
// Check around the player first in a configurable radius:
|
||||
// TODO: Make this configurable
|
||||
Location safe = checkAboveAndBelowLocation(l, 6, 9);
|
||||
if (safe != null) {
|
||||
safe.setX(safe.getBlockX() + .5);
|
||||
safe.setZ(safe.getBlockZ() + .5);
|
||||
}
|
||||
return safe;
|
||||
}
|
||||
|
||||
private Location checkAboveAndBelowLocation(Location l, int tolerance, int radius) {
|
||||
// Tolerance must be an even number:
|
||||
if (tolerance % 2 != 0) {
|
||||
tolerance += 1;
|
||||
}
|
||||
// We want half of it, so we can go up and down
|
||||
tolerance /= 2;
|
||||
|
||||
// For now this will just do a straight up block.
|
||||
Location locToCheck = l.clone();
|
||||
// Check the main level
|
||||
Location safe = this.checkAroundLocation(locToCheck, radius);
|
||||
if (safe != null) {
|
||||
return safe;
|
||||
}
|
||||
// We've already checked zero right above this.
|
||||
int currentLevel = 1;
|
||||
while (currentLevel <= tolerance) {
|
||||
// Check above
|
||||
locToCheck = l.clone();
|
||||
locToCheck.add(0, currentLevel, 0);
|
||||
safe = this.checkAroundLocation(locToCheck, radius);
|
||||
if (safe != null) {
|
||||
return safe;
|
||||
}
|
||||
|
||||
// Check below
|
||||
locToCheck = l.clone();
|
||||
locToCheck.subtract(0, currentLevel, 0);
|
||||
safe = this.checkAroundLocation(locToCheck, radius);
|
||||
if (safe != null) {
|
||||
return safe;
|
||||
}
|
||||
currentLevel++;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* For my crappy algorithm, radius MUST be odd
|
||||
*
|
||||
* @param l
|
||||
* @param radius
|
||||
* @return
|
||||
*/
|
||||
private Location checkAroundLocation(Location l, int diameter) {
|
||||
if (diameter % 2 == 0) {
|
||||
diameter += 1;
|
||||
}
|
||||
Location checkLoc = l.clone();
|
||||
|
||||
// Start at 3, the min diameter around a block
|
||||
int loopcounter = 3;
|
||||
while (loopcounter <= diameter) {
|
||||
boolean foundSafeArea = checkAroundSpecificDiameter(checkLoc, loopcounter);
|
||||
// If a safe area was found:
|
||||
if (foundSafeArea) {
|
||||
// Return the checkLoc, it is the safe location.
|
||||
return checkLoc;
|
||||
}
|
||||
// Otherwise, let's reset our location
|
||||
checkLoc = l.clone();
|
||||
// And increment the radius
|
||||
loopcounter += 2;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean checkAroundSpecificDiameter(Location checkLoc, int circle) {
|
||||
// Adjust the circle to get how many blocks to step out.
|
||||
// A radius of 3 makes the block step 1
|
||||
// A radius of 5 makes the block step 2
|
||||
// A radius of 7 makes the block step 3
|
||||
// ...
|
||||
int adjustedCircle = ((circle - 1) / 2);
|
||||
checkLoc.add(adjustedCircle, 0, 0);
|
||||
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
|
||||
return true;
|
||||
}
|
||||
// Now we go to the right that adjustedCircle many
|
||||
for (int i = 0; i < adjustedCircle; i++) {
|
||||
checkLoc.add(0, 0, 1);
|
||||
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Then down adjustedCircle *2
|
||||
for (int i = 0; i < adjustedCircle * 2; i++) {
|
||||
checkLoc.add(-1, 0, 0);
|
||||
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Then left adjustedCircle *2
|
||||
for (int i = 0; i < adjustedCircle * 2; i++) {
|
||||
checkLoc.add(0, 0, -1);
|
||||
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Then up Then left adjustedCircle *2
|
||||
for (int i = 0; i < adjustedCircle * 2; i++) {
|
||||
checkLoc.add(1, 0, 0);
|
||||
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Then finish up by doing adjustedCircle - 1
|
||||
for (int i = 0; i < adjustedCircle - 1; i++) {
|
||||
checkLoc.add(0, 0, 1);
|
||||
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean safelyTeleport(Entity e, Location l) {
|
||||
if (this.bs.playerCanSpawnHereSafely(l)) {
|
||||
e.teleport(l);
|
||||
//this.plugin.log(Level.WARNING, "The first location you gave me was safe.");
|
||||
return true;
|
||||
}
|
||||
if(e instanceof Minecart) {
|
||||
Minecart m = (Minecart)e;
|
||||
if(!this.bs.canSpawnCartSafely(m)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(e instanceof Vehicle) {
|
||||
Vehicle v = (Vehicle)e;
|
||||
if(!this.bs.canSpawnVehicleSafely(v)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Location safeLocation = this.getSafeLocation(l);
|
||||
if (safeLocation != null) {
|
||||
// Add offset to account for a vehicle on dry land!
|
||||
if (!this.bs.isEntitiyOnTrack(e, safeLocation)) {
|
||||
safeLocation.setY(safeLocation.getBlockY() + .5);
|
||||
}
|
||||
e.teleport(safeLocation);
|
||||
//this.plugin.log(Level.WARNING, "Had to look for a bit, but I found a safe place for ya!");
|
||||
return true;
|
||||
}
|
||||
if (e instanceof Player) {
|
||||
Player p = (Player) e;
|
||||
p.sendMessage("No safe locations found!");
|
||||
}
|
||||
else if (e.getPassenger() instanceof Player) {
|
||||
Player p = (Player) e.getPassenger();
|
||||
p.sendMessage("No safe locations found!");
|
||||
}
|
||||
this.plugin.log(Level.WARNING, "Sorry champ, you're basically trying to teleport into a minefield. I should just kill you now.");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,101 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import com.fernferret.allpay.GenericBank;
|
||||
import com.onarandombox.MultiverseCore.destination.DestinationFactory;
|
||||
import com.onarandombox.MultiverseCore.utils.*;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Multiverse 2 Core API
|
||||
* <p/>
|
||||
* This API contains a bunch of useful things you can get out of Multiverse in general!
|
||||
*/
|
||||
public interface Core {
|
||||
|
||||
/**
|
||||
* Gets the Multiverse config file.
|
||||
*
|
||||
* @return The Multiverse config file.
|
||||
*/
|
||||
public FileConfiguration getMVConfiguration();
|
||||
|
||||
/**
|
||||
* Gets the Banking system that Multiverse-Core has hooked into.
|
||||
*
|
||||
* @return A {@link GenericBank} that can be used for payments.
|
||||
*/
|
||||
public GenericBank getBank();
|
||||
|
||||
/**
|
||||
* Reloads the Multiverse Configuration files:
|
||||
* worlds.yml and config.yml.
|
||||
*/
|
||||
public void loadConfigs();
|
||||
|
||||
/**
|
||||
* Gets the Multiverse message system. This allows you to send messages
|
||||
* to users at specified intervals.
|
||||
*
|
||||
* @return The loaded {@link MVMessaging}.
|
||||
*/
|
||||
public MVMessaging getMessaging();
|
||||
|
||||
/**
|
||||
* Gets the {@link MVPlayerSession} for the given player.
|
||||
* This will also create a player session if one does not exist
|
||||
* for a player.
|
||||
*
|
||||
* @param player The player's session to grab.
|
||||
*
|
||||
* @return The corresponding {@link MVPlayerSession}.
|
||||
*/
|
||||
public MVPlayerSession getPlayerSession(Player player);
|
||||
|
||||
/**
|
||||
* Gets the instantiated Safe-T-Teleporter for performing
|
||||
* safe teleports.
|
||||
*
|
||||
* @return A non-null {@link SafeTTeleporter}.
|
||||
*/
|
||||
public SafeTTeleporter getTeleporter();
|
||||
|
||||
/**
|
||||
* Multiverse uses an advanced permissions setup, this object
|
||||
* simplifies getting/setting permissions.
|
||||
*
|
||||
* @return A non-null {@link MVPermissions}.
|
||||
*/
|
||||
public MVPermissions getMVPerms();
|
||||
|
||||
/**
|
||||
* Multiverse uses {@link CommandHandler} to make adding and using commands
|
||||
* a piece of cake.
|
||||
*
|
||||
* @return A non-null {@link CommandHandler}.
|
||||
*/
|
||||
public CommandHandler getCommandHandler();
|
||||
|
||||
/**
|
||||
* Gets the factory class responsible for loading many different destinations
|
||||
* on demand.
|
||||
*
|
||||
* @return A valid {@link DestinationFactory}.
|
||||
*/
|
||||
public DestinationFactory getDestFactory();
|
||||
|
||||
/**
|
||||
* Gets the primary class responsible for managing Multiverse Worlds.
|
||||
*
|
||||
* @return {@link WorldManager}.
|
||||
*/
|
||||
public WorldManager getMVWorldManager();
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
public interface FancyText {
|
||||
/**
|
||||
* TODO: Write something useful here.
|
||||
*
|
||||
* @return And Here.
|
||||
*/
|
||||
public String getFancyText();
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
/** A simple API to require plugins to have a log method. */
|
||||
public interface LoggablePlugin {
|
||||
/**
|
||||
* Logs a message at the specified level.
|
||||
*
|
||||
* @param level The severity of the log.
|
||||
* @param msg The message to log.
|
||||
*/
|
||||
public void log(Level level, String msg);
|
||||
|
||||
/**
|
||||
* Gets the server instance that this plugin is attached to.
|
||||
*
|
||||
* @return A {@link Server} instance.
|
||||
*/
|
||||
public Server getServer();
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
/**
|
||||
* A destination API for Multiverse
|
||||
* Any plugin can add these to MV and when they are, any action that uses them (portals, MVTP, etc.) can use them!
|
||||
*
|
||||
* @author fernferret
|
||||
*/
|
||||
public interface MVDestination {
|
||||
/**
|
||||
* Returns the identifier or prefix that is required for this destination.
|
||||
* <p/>
|
||||
* Portals have a prefix of "p" for example and OpenWarp (third party plugin) uses "ow". This is derived from a
|
||||
* hash and cannot have duplicate values. Read that as your plugin cannot use 'p' because it's already used.
|
||||
* Please check the wiki when adding a custom destination!
|
||||
*
|
||||
* @return The identifier or prefix that is required for this destination.
|
||||
*/
|
||||
public String getIdentifier();
|
||||
|
||||
/**
|
||||
* Allows you to determine if a Destination is valid for the type it thinks it is.
|
||||
* <p/>
|
||||
* An example of this would be the exact destination. A valid string would be: e:0,0,0 where an invalid one would
|
||||
* be e:1:2:3. The first string would return true the second would return false. This is simply a convenience
|
||||
* method
|
||||
* and does not even NEED to be called, but it's highly recommended if you're teleporting, but it's mainly for
|
||||
* Multiverse Internal use.
|
||||
*
|
||||
* @param plugin The plugin who the type belongs to.
|
||||
* @param destination The destination string. ex: p:MyPortal:nw
|
||||
*
|
||||
* @return True if the destination is valid, false if not.
|
||||
*/
|
||||
public boolean isThisType(JavaPlugin plugin, String destination);
|
||||
|
||||
/**
|
||||
* Returns the location a specific entity will spawn at.
|
||||
* <p/>
|
||||
* To just retrieve the location as it is stored you can just pass null, but be warned some destinations may return
|
||||
* null back to you if you do this. It is always safer to pass an actual entity. This is used so things like
|
||||
* minecarts can be teleported.
|
||||
* <p/>
|
||||
* Do not forget to use {@link #getVelocity()} as destinations can use this too!
|
||||
*
|
||||
* @param entity The entity to be teleported.
|
||||
*
|
||||
* @return The location of the entity.
|
||||
*/
|
||||
public Location getLocation(Entity entity);
|
||||
|
||||
/**
|
||||
* Returns the velocity vector for this destination.
|
||||
* <p/>
|
||||
* Plugins wishing to fully support MVDestinations MUST implement this.
|
||||
*
|
||||
* @return A vector representing the speed/direction the player should travel when arriving
|
||||
*/
|
||||
public Vector getVelocity();
|
||||
|
||||
/**
|
||||
* Sets the destination string.
|
||||
* <p/>
|
||||
* This should be used when you want to tell this destination object about a change in where it should take people.
|
||||
* The destination param should be match the result from {@link #getIdentifier()}. A valid example would be that if
|
||||
* {@link #getIdentifier()} returned "ow" our destination string could be "ow:TownCenter" but could not be
|
||||
* "p:HomePortal"
|
||||
*
|
||||
* @param plugin The plugin who the type belongs to.
|
||||
* @param destination The destination string. ex: p:MyPortal:nw
|
||||
*/
|
||||
public void setDestination(JavaPlugin plugin, String destination);
|
||||
|
||||
/**
|
||||
* Returns true if the destination is valid and players will be taken to it.
|
||||
* <p/>
|
||||
* Even if destinations are in the correct format (p:MyPortal) MyPortal may not exist, and therefore this would
|
||||
* return false.
|
||||
*
|
||||
* @return True if the destination is valid; false if not.
|
||||
*/
|
||||
public boolean isValid();
|
||||
|
||||
/**
|
||||
* Gives you a general friendly description of the type of destination.
|
||||
* <p/>
|
||||
* For example, the PlayerDestination sets this to "Player". You can use this to show where a player will be taken.
|
||||
*
|
||||
* @return A friendly string description of the type of destination.
|
||||
*/
|
||||
public String getType();
|
||||
|
||||
/**
|
||||
* Gives you a specific name of the destination.
|
||||
* <p/>
|
||||
* For example, the PlayerDestination sets this to The Player's Name.
|
||||
*
|
||||
* @return A friendly string stating the name of the destination.
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Returns a string that can easily be saved in the config that contains all the details needed to rebuild this
|
||||
* destination.
|
||||
* <p/>
|
||||
* ex: e:0,0,0:50:50
|
||||
*
|
||||
* @return The savable config string.
|
||||
*/
|
||||
public String toString();
|
||||
|
||||
/**
|
||||
* Returns the permissions string required to go here.
|
||||
* <p/>
|
||||
* ex: multiverse.access.world
|
||||
* <p/>
|
||||
* NOTE: This is NOT the permission to use the teleport command.
|
||||
*
|
||||
* @return the permissions string required to go here.
|
||||
*/
|
||||
public String getRequiredPermission();
|
||||
|
||||
/**
|
||||
* Should the Multiverse SafeTeleporter be used?
|
||||
* <p/>
|
||||
* If not, MV will blindly take people to the location specified.
|
||||
*
|
||||
* @return True if the SafeTeleporter will be used, false if not.
|
||||
*/
|
||||
public boolean useSafeTeleporter();
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
public interface MVPlugin extends LoggablePlugin {
|
||||
/**
|
||||
* Adds This plugin's version information to the buffer and returns the new string.
|
||||
*
|
||||
* @param buffer The string that contains Core and all other MV plugins' versions.
|
||||
*
|
||||
* @return A modified buffer that contains this MVPlugin's version information.
|
||||
*/
|
||||
public String dumpVersionInfo(String buffer);
|
||||
|
||||
/**
|
||||
* Gets the reference to MultiverseCore.
|
||||
*
|
||||
* @return A valid {@link MultiverseCore}.
|
||||
*/
|
||||
public MultiverseCore getCore();
|
||||
|
||||
/**
|
||||
* Sets the reference to MultiverseCore.
|
||||
*
|
||||
* @param core A valid {@link MultiverseCore}.
|
||||
*/
|
||||
public void setCore(MultiverseCore core);
|
||||
|
||||
/**
|
||||
* Allows Multiverse or a plugin to query another Multiverse plugin to see what version its protocol is. This
|
||||
* number
|
||||
* should change when something will break the code.
|
||||
*
|
||||
* @return The Integer protocol version.
|
||||
*/
|
||||
public int getProtocolVersion();
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import com.onarandombox.MultiverseCore.utils.PurgeWorlds;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Multiverse 2 World Manager API
|
||||
* <p/>
|
||||
* This API contains all of the world managing
|
||||
* functions that your heart desires!
|
||||
*/
|
||||
public interface MVWorldManager {
|
||||
/**
|
||||
* Add a new World to the Multiverse Setup.
|
||||
*
|
||||
* @param name World Name
|
||||
* @param env Environment Type
|
||||
* @param seedString The seed in the form of a string.
|
||||
* If the seed is a Long,
|
||||
* it will be interpreted as such.
|
||||
* @param generator The Custom generator plugin to use.
|
||||
*
|
||||
* @return True if the world is added, false if not.
|
||||
*/
|
||||
public boolean addWorld(String name, Environment env, String seedString, String generator);
|
||||
|
||||
/**
|
||||
* Remove the world from the Multiverse list, from the
|
||||
* config and deletes the folder
|
||||
*
|
||||
* @param name The name of the world to remove
|
||||
*
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
public Boolean deleteWorld(String name);
|
||||
|
||||
/**
|
||||
* Unload a world from Multiverse
|
||||
*
|
||||
* @param name Name of the world to unload
|
||||
*
|
||||
* @return True if the world was unloaded, false if not.
|
||||
*/
|
||||
public boolean unloadWorld(String name);
|
||||
|
||||
/**
|
||||
* Loads the world. Only use this if the world has been
|
||||
* unloaded with {@link #unloadWorld(String)}.
|
||||
*
|
||||
* @param name The name of the world to load
|
||||
*
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
public boolean loadWorld(String name);
|
||||
|
||||
/**
|
||||
* Removes all players from the specified world.
|
||||
*
|
||||
* @param name World to remove players from.
|
||||
*/
|
||||
public void removePlayersFromWorld(String name);
|
||||
|
||||
/**
|
||||
* Test if a given chunk generator is valid.
|
||||
*
|
||||
* @param generator The generator name.
|
||||
* @param generatorID The generator id.
|
||||
* @param worldName The worldName to use as the default.
|
||||
*
|
||||
* @return A {@link ChunkGenerator} or null
|
||||
*/
|
||||
public ChunkGenerator getChunkGenerator(String generator, String generatorID, String worldName);
|
||||
|
||||
/**
|
||||
* Returns a list of all the worlds Multiverse knows about.
|
||||
*
|
||||
* @return A list of {@link MultiverseWorld}.
|
||||
*/
|
||||
public Collection<MultiverseWorld> getMVWorlds();
|
||||
|
||||
|
||||
/**
|
||||
* Returns a {@link MultiverseWorld} if it exists, and null if it does not.
|
||||
* This will search name AND alias.
|
||||
*
|
||||
* @param name The name or alias of the world to get.
|
||||
*
|
||||
* @return A {@link MultiverseWorld} or null.
|
||||
*/
|
||||
public MultiverseWorld getMVWorld(String name);
|
||||
|
||||
/**
|
||||
* Returns a {@link MultiverseWorld} if it exists, and null if it does not.
|
||||
*
|
||||
* @param world The Bukkit world to check.
|
||||
*
|
||||
* @return A {@link MultiverseWorld} or null.
|
||||
*/
|
||||
public MultiverseWorld getMVWorld(World world);
|
||||
|
||||
/**
|
||||
* Checks to see if the given name is a valid {@link MultiverseWorld}
|
||||
*
|
||||
* @param name The name or alias of the world to check.
|
||||
*
|
||||
* @return True if the world exists, false if not.
|
||||
*/
|
||||
public boolean isMVWorld(String name);
|
||||
|
||||
/**
|
||||
* Checks to see if the given world is a valid {@link MultiverseWorld}
|
||||
*
|
||||
* @param world The Bukkit world to check.
|
||||
*
|
||||
* @return True if the world has been loaded into MV2, false if not.
|
||||
*/
|
||||
public boolean isMVWorld(World world);
|
||||
|
||||
/**
|
||||
* Load the Worlds & Settings from the configuration file.
|
||||
*
|
||||
* @param forceLoad If set to true, this will perform a total
|
||||
* reset and not just load new worlds.
|
||||
*/
|
||||
public void loadWorlds(boolean forceLoad);
|
||||
|
||||
/**
|
||||
* Return the World Purger.
|
||||
*
|
||||
* @return A valid {@link PurgeWorlds}.
|
||||
*/
|
||||
public PurgeWorlds getWorldPurger();
|
||||
}
|
||||
@@ -0,0 +1,441 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.permissions.Permission;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The API for a Multiverse Handled World.
|
||||
* <p/>
|
||||
* Currently INCOMPLETE
|
||||
*/
|
||||
public interface MultiverseWorld {
|
||||
|
||||
/**
|
||||
* Returns the Bukkit world object that this world describes.
|
||||
*
|
||||
* @return A {@link World}
|
||||
*/
|
||||
public World getCBWorld();
|
||||
|
||||
/**
|
||||
* Adds the property to the given value. The property must be a {@link com.onarandombox.MultiverseCore.enums.SetProperties}.
|
||||
*
|
||||
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.SetProperties} to set.
|
||||
* @param value A value in string representation, it will be parsed to the correct type.
|
||||
*
|
||||
* @return True if the value was set, false if not.
|
||||
*/
|
||||
public boolean setVariable(String property, String value);
|
||||
|
||||
/**
|
||||
* Removes all values from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
|
||||
*
|
||||
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to clear.
|
||||
*
|
||||
* @return True if it was cleared, false if not.
|
||||
*/
|
||||
public boolean clearVariable(String property);
|
||||
|
||||
/**
|
||||
* Adds a value to the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
|
||||
*
|
||||
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to add a value to.
|
||||
* @param value A value in string representation, it will be parsed to the correct type.
|
||||
*
|
||||
* @return True if the value was added, false if not.
|
||||
*/
|
||||
public boolean addToVariable(String property, String value);
|
||||
|
||||
/**
|
||||
* Removes a value from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
|
||||
*
|
||||
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to remove a value
|
||||
* from.
|
||||
* @param value A value in string representation, it will be parsed to the correct type.
|
||||
*
|
||||
* @return True if the value was removed, false if not.
|
||||
*/
|
||||
public boolean removeFromVariable(String property, String value);
|
||||
|
||||
/**
|
||||
* Gets the environment of this world.
|
||||
*
|
||||
* @return A {@link org.bukkit.World.Environment}.
|
||||
*/
|
||||
public World.Environment getEnvironment();
|
||||
|
||||
/**
|
||||
* Sets the environment of a world.
|
||||
* <p/>
|
||||
* Note: This will ONLY take effect once the world is unloaded/reloaded.
|
||||
*
|
||||
* @param environment A {@link org.bukkit.World.Environment}.
|
||||
*/
|
||||
public void setEnvironment(World.Environment environment);
|
||||
|
||||
/**
|
||||
* Gets the world seed of this world.
|
||||
*
|
||||
* @return The Long version of the seed.
|
||||
*/
|
||||
public Long getSeed();
|
||||
|
||||
/**
|
||||
* Sets the seed of this world.
|
||||
*
|
||||
* @param seed A Long that is the seed.
|
||||
*/
|
||||
public void setSeed(Long seed);
|
||||
|
||||
/**
|
||||
* Gets the name of this world. This cannot be changed.
|
||||
*
|
||||
* @return The name of the world as a String.
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Gets the alias of this world.
|
||||
* <p/>
|
||||
* This alias allows users to have a world named "world" but show up in the list as "FernIsland"
|
||||
*
|
||||
* @return The alias of the world as a String.
|
||||
*/
|
||||
public String getAlias();
|
||||
|
||||
/**
|
||||
* Sets the alias of the world.
|
||||
*
|
||||
* @param alias A string that is the new alias.
|
||||
*/
|
||||
public void setAlias(String alias);
|
||||
|
||||
/**
|
||||
* Sets the color that this world's name/alias will display as.
|
||||
*
|
||||
* @param color A valid color name.
|
||||
*
|
||||
* @return True if the color was set, false if not.
|
||||
*/
|
||||
public boolean setColor(String color);
|
||||
|
||||
/**
|
||||
* Gets the color that this world's name/alias will display as.
|
||||
*
|
||||
* @return The color of this world.
|
||||
*/
|
||||
public ChatColor getColor();
|
||||
|
||||
/**
|
||||
* Tells you if someone entered a valid color.
|
||||
*
|
||||
* @param color A string that may translate to a color.
|
||||
*
|
||||
* @return True if it is a color, false if not.
|
||||
*/
|
||||
public boolean isValidAliasColor(String color);
|
||||
|
||||
/**
|
||||
* Returns a very nicely colored string (using Alias and Color if they are set).
|
||||
*
|
||||
* @return A nicely colored string.
|
||||
*/
|
||||
public String getColoredWorldString();
|
||||
|
||||
/**
|
||||
* Gets whether or not animals are allowed to spawn in this world.
|
||||
*
|
||||
* @return True if ANY animal can, false if no animals can spawn.
|
||||
*/
|
||||
public boolean canAnimalsSpawn();
|
||||
|
||||
/**
|
||||
* Gets whether or not monsters are allowed to spawn in this world.
|
||||
*
|
||||
* @return True if ANY monster can, false if no monsters can spawn.
|
||||
*/
|
||||
public boolean canMonstersSpawn();
|
||||
|
||||
/**
|
||||
* Turn pvp on or off. This setting is used to set the world's PVP mode, and thus relies on fakePVP
|
||||
*
|
||||
* @param pvpMode True to enable PVP damage, false to disable it.
|
||||
*/
|
||||
public void setPVPMode(boolean pvpMode);
|
||||
|
||||
/**
|
||||
* Turn pvp on or off. This setting is used to set the world's PVP mode, and thus relies on fakePVP
|
||||
*
|
||||
* @return True if this world has fakepvp on
|
||||
*/
|
||||
public boolean getFakePVP();
|
||||
|
||||
/**
|
||||
* Gets whether or not PVP is enabled in this world in some form (fake or not).
|
||||
*
|
||||
* @return True if players can take damage from other players.
|
||||
*/
|
||||
public boolean isPVPEnabled();
|
||||
|
||||
/**
|
||||
* Gets whether or not this world will display in chat, mvw and mvl regardless if a user has the
|
||||
* access permissions to go to this world.
|
||||
*
|
||||
* @return True if the world will be hidden, false if not.
|
||||
*/
|
||||
public boolean isHidden();
|
||||
|
||||
/**
|
||||
* Sets whether or not this world will display in chat, mvw and mvl regardless if a user has the
|
||||
* access permissions to go to this world.
|
||||
*
|
||||
* @param hidden Set
|
||||
*/
|
||||
public void setHidden(boolean hidden);
|
||||
|
||||
/**
|
||||
* Sets whether or not there will be weather events in a given world.
|
||||
* If set to false, Multiverse will disable the weather in the world immediately.
|
||||
*
|
||||
* @param enableWeather True if weather events should occur in a world, false if not.
|
||||
*/
|
||||
public void setEnableWeather(boolean enableWeather);
|
||||
|
||||
/**
|
||||
* Gets whether weather is enabled in this world.
|
||||
*
|
||||
* @return True if weather events will occur, false if not.
|
||||
*/
|
||||
public boolean isWeatherEnabled();
|
||||
|
||||
/**
|
||||
* If true, tells Craftbukkit to keep a worlds spawn chunks loaded in memory (default: true)
|
||||
* If not, CraftBukkit will attempt to free memory when players have not used that world.
|
||||
* This will not happen immediately.
|
||||
*
|
||||
* @param keepSpawnInMemory If true, CraftBukkit will keep the spawn chunks loaded in memory.
|
||||
*/
|
||||
public void setKeepSpawnInMemory(boolean keepSpawnInMemory);
|
||||
|
||||
/**
|
||||
* Gets whether or not CraftBukkit is keeping the chunks for this world in memory.
|
||||
*
|
||||
* @return True if CraftBukkit is keeping spawn chunks in memory.
|
||||
*/
|
||||
public boolean isKeepingSpawnInMemory();
|
||||
|
||||
/**
|
||||
* Sets the difficulty of this world and returns true if success.
|
||||
* Valid string values are either an integer of difficulty(0-3) or
|
||||
* the name that resides in the Bukkit enum, ex. PEACEFUL
|
||||
*
|
||||
* @param difficulty The difficulty to set the world to as a string.
|
||||
*
|
||||
* @return True if success, false if the provided string
|
||||
* could not be translated to a difficulty.
|
||||
*/
|
||||
public boolean setDifficulty(String difficulty);
|
||||
|
||||
/**
|
||||
* Gets the difficulty of this world.
|
||||
*
|
||||
* @return The difficulty of this world.
|
||||
*/
|
||||
public Difficulty getDifficulty();
|
||||
|
||||
/**
|
||||
* Sets the spawn location for a world.
|
||||
*
|
||||
* @param spawnLocation The spawn location for a world.
|
||||
*/
|
||||
public void setSpawnLocation(Location spawnLocation);
|
||||
|
||||
/**
|
||||
* Gets the spawn location of this world.
|
||||
*
|
||||
* @return The spawn location of this world.
|
||||
*/
|
||||
public Location getSpawnLocation();
|
||||
|
||||
/**
|
||||
* Sets whether or not the hunger level of players will go down in a world.
|
||||
*
|
||||
* @param hungerEnabled True if hunger will go down, false to keep it at
|
||||
* the level they entered a world with.
|
||||
*/
|
||||
public void setHunger(boolean hungerEnabled);
|
||||
|
||||
/**
|
||||
* Gets whether or not the hunger level of players will go down in a world.
|
||||
*
|
||||
* @return True if it will go down, false if it will remain steady.
|
||||
*/
|
||||
public boolean getHunger();
|
||||
|
||||
/**
|
||||
* Sets the game mode of this world
|
||||
*
|
||||
* @param gameMode A valid game mode string (either
|
||||
* an int ex. 0 or a string ex. creative).
|
||||
*
|
||||
* @return True if the game mode was successfully changed, false if not.
|
||||
*/
|
||||
public boolean setGameMode(String gameMode);
|
||||
|
||||
/**
|
||||
* Gets the GameMode of this world.
|
||||
*
|
||||
* @return The GameMode of this world.
|
||||
*/
|
||||
public GameMode getGameMode();
|
||||
|
||||
/**
|
||||
* Gets the permission required to enter this world.
|
||||
*
|
||||
* @return The permission required to be exempt from charges to/from this world.
|
||||
*/
|
||||
public Permission getAccessPermission();
|
||||
|
||||
/**
|
||||
* Gets the permission required to be exempt when entering.
|
||||
*
|
||||
* @return The permission required to be exempt when entering.
|
||||
*/
|
||||
public Permission getExemptPermission();
|
||||
|
||||
/**
|
||||
* Sets the price for entry to this world.
|
||||
* You can think of this like an amount.
|
||||
* The type can be set with {@link #setCurrency(int)}
|
||||
*
|
||||
* @param price The Amount of money/item to enter the world.
|
||||
*/
|
||||
public void setPrice(double price);
|
||||
|
||||
/**
|
||||
* Gets the amount of currency it requires to enter this world.
|
||||
*
|
||||
* @return The amount it costs to enter this world.
|
||||
*/
|
||||
public double getPrice();
|
||||
|
||||
/**
|
||||
* Sets the type of item that will be required given the price is not 0.
|
||||
* Use -1 to use an AllPay economy, or any valid itemid
|
||||
*
|
||||
* @param item The Type of currency that will be used when users enter this world.
|
||||
*/
|
||||
public void setCurrency(int item);
|
||||
|
||||
/**
|
||||
* Gets the Type of currency that will be used when users enter this world.
|
||||
*
|
||||
* @return The Type of currency that will be used when users enter this world.
|
||||
*/
|
||||
public int getCurrency();
|
||||
|
||||
/**
|
||||
* Sets the world players will respawn in if they die in this one.
|
||||
* Returns true upon success, false upon failure.
|
||||
*
|
||||
* @param respawnWorld The name of a world that exists on the server.
|
||||
*
|
||||
* @return True if respawnWorld existed, false if not.
|
||||
*/
|
||||
public boolean setRespawnToWorld(String respawnWorld);
|
||||
|
||||
/**
|
||||
* Gets the world players will respawn in if they die in this one.
|
||||
*
|
||||
* @return A world that exists on the server.
|
||||
*/
|
||||
public World getRespawnToWorld();
|
||||
|
||||
/**
|
||||
* Sets the scale of this world. Really only has an effect if you use
|
||||
* Multiverse-NetherPortals.
|
||||
*
|
||||
* @param scaling A scaling value, cannot be negative or 0.
|
||||
*/
|
||||
public boolean setScaling(double scaling);
|
||||
|
||||
/**
|
||||
* Gets the scaling value of this world.Really only has an effect if you use
|
||||
* Multiverse-NetherPortals.
|
||||
*
|
||||
* @return This world's non-negative, non-zero scale.
|
||||
*/
|
||||
public double getScaling();
|
||||
|
||||
/**
|
||||
* Gets a list of all the worlds that players CANNOT travel to from this world,
|
||||
* regardless of their access permissions.
|
||||
*
|
||||
* @return A List of world names.
|
||||
*/
|
||||
public List<String> getWorldBlacklist();
|
||||
|
||||
/**
|
||||
* Returns a list of animals. This list always negates the {@link #canAnimalsSpawn()} result.
|
||||
*
|
||||
* @return A list of animals that will spawn if {@link #canAnimalsSpawn()} is false.
|
||||
*/
|
||||
public List<String> getAnimalList();
|
||||
|
||||
/**
|
||||
* Sets whether or not animals can spawn.
|
||||
* If there are values in {@link #getAnimalList()} and this is false,
|
||||
* those animals become the exceptions, and will spawn
|
||||
*
|
||||
* @param allowAnimalSpawn True to allow spawning of monsters, false to prevent.
|
||||
*/
|
||||
public void setAllowAnimalSpawn(boolean allowAnimalSpawn);
|
||||
|
||||
/**
|
||||
* Returns a list of monsters. This list always negates the {@link #canMonstersSpawn()} ()} result.
|
||||
*
|
||||
* @return A list of monsters that will spawn if {@link #canMonstersSpawn()} is false.
|
||||
*/
|
||||
public List<String> getMonsterList();
|
||||
|
||||
/**
|
||||
* Sets whether or not monsters can spawn.
|
||||
* If there are values in {@link #getMonsterList()} and this is false,
|
||||
* those monsters become the exceptions, and will spawn
|
||||
*
|
||||
* @param allowMonsterSpawn True to allow spawning of monsters, false to prevent.
|
||||
*/
|
||||
public void setAllowMonsterSpawn(boolean allowMonsterSpawn);
|
||||
|
||||
/**
|
||||
* TODO: Write these docs.
|
||||
*
|
||||
* @param property
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean clearList(String property);
|
||||
|
||||
/**
|
||||
* Sets whether or not a world will autoheal players if the difficulty is on peaceful.
|
||||
*
|
||||
* @param heal True if the world will heal.
|
||||
*/
|
||||
public void setAutoHeal(boolean heal);
|
||||
|
||||
/**
|
||||
* Gets whether or not a world will autoheal players if the difficulty is on peaceful.
|
||||
*
|
||||
* @return True if the world should heal (default), false if not.
|
||||
*/
|
||||
public boolean getAutoHeal();
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
|
||||
import com.onarandombox.MultiverseCore.utils.MVPermissions;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CheckCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
|
||||
public CheckCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Help you validate your multiverse settings");
|
||||
this.setCommandUsage("/mv check " + ChatColor.GREEN + "{PLAYER} {DESTINATION}");
|
||||
this.setArgRange(2, 2);
|
||||
this.addKey("mv check");
|
||||
this.addKey("mvcheck");
|
||||
this.addCommandExample("/mv check " + ChatColor.GREEN + "fernferret " + ChatColor.LIGHT_PURPLE + "w:MyWorld");
|
||||
this.addCommandExample("/mv check " + ChatColor.GREEN + "Rigby90 " + ChatColor.LIGHT_PURPLE + "p:MyPortal");
|
||||
this.addCommandExample("/mv check " + ChatColor.GREEN + "lithium3141 " + ChatColor.LIGHT_PURPLE + "ow:WarpName");
|
||||
this.setPermission("multiverse.core.debug", "Checks to see if a player can go to a destination. Prints debug if false.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
Player p = this.plugin.getServer().getPlayer(args.get(0));
|
||||
if (p == null) {
|
||||
sender.sendMessage("Could not find player " + ChatColor.GREEN + args.get(0));
|
||||
sender.sendMessage("Are they online?");
|
||||
return;
|
||||
}
|
||||
MVDestination dest = this.plugin.getDestFactory().getDestination(args.get(1));
|
||||
if (dest instanceof InvalidDestination) {
|
||||
sender.sendMessage("You asked if '" + args.get(0) + "' could go to " + ChatColor.GREEN + args.get(0) + ChatColor.WHITE + ",");
|
||||
sender.sendMessage("but I couldn't find a Destination of that name? Did you type it correctly?");
|
||||
return;
|
||||
}
|
||||
|
||||
MVPermissions perms = this.plugin.getMVPerms();
|
||||
if (perms.canEnterDestination(p, dest)) {
|
||||
sender.sendMessage(ChatColor.GREEN + args.get(0) + ChatColor.WHITE + " can travel to " + ChatColor.GREEN + args.get(1));
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.AQUA + args.get(0) + ChatColor.RED + " CANNOT travel to " + ChatColor.AQUA + args.get(1));
|
||||
sender.sendMessage("Please turn debug mode to 3 then watch the console to find out why!");
|
||||
sender.sendMessage("Use: " + ChatColor.GREEN + "/mv debug 3");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.enums.ConfigProperty;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ConfigCommand extends MultiverseCommand {
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public ConfigCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Configuration");
|
||||
this.setCommandUsage("/mv config " + ChatColor.GREEN + "{PROPERTY} {VALUE}");
|
||||
this.setArgRange(1, 2);
|
||||
this.addKey("mv config");
|
||||
this.addKey("mvconfig");
|
||||
this.addKey("mv conf");
|
||||
this.addKey("mvconf");
|
||||
this.addCommandExample("All values: " + ConfigProperty.getAllValues());
|
||||
this.addCommandExample("/mv config show");
|
||||
this.addCommandExample("/mv config " + ChatColor.GREEN + "debug" + ChatColor.AQUA + " 3");
|
||||
this.addCommandExample("/mv config " + ChatColor.GREEN + "enforceaccess" + ChatColor.AQUA + " false");
|
||||
this.addCommandExample("/mv config " + ChatColor.GREEN + "bedrespawn" + ChatColor.AQUA + " true");
|
||||
this.setPermission("multiverse.core.config", "Allows you to set Global MV Variables.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
if (args.size() <= 1) {
|
||||
String[] allProps = ConfigProperty.getAllValues().split(" ");
|
||||
String currentvals = "";
|
||||
for (String prop : allProps) {
|
||||
currentvals += ChatColor.GREEN;
|
||||
currentvals += prop;
|
||||
currentvals += ChatColor.WHITE;
|
||||
currentvals += " = ";
|
||||
currentvals += ChatColor.GOLD;
|
||||
currentvals += this.plugin.getMVConfiguration().get(prop, "NOT SET");
|
||||
currentvals += ChatColor.WHITE;
|
||||
currentvals += ", ";
|
||||
}
|
||||
sender.sendMessage(currentvals.substring(0, currentvals.length() - 2));
|
||||
return;
|
||||
}
|
||||
if (args.get(0).equalsIgnoreCase("messagecooldown") || args.get(0).equalsIgnoreCase("teleportcooldown") || args.get(0).equalsIgnoreCase("debug")) {
|
||||
try {
|
||||
this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), Integer.parseInt(args.get(1)));
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE + " must be an integer!");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
ConfigProperty property = null;
|
||||
try {
|
||||
property = ConfigProperty.valueOf(args.get(0).toLowerCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE + " you can't set " + ChatColor.AQUA + args.get(0));
|
||||
sender.sendMessage(ChatColor.GREEN + "Valid values are:");
|
||||
sender.sendMessage(ConfigProperty.getAllValues());
|
||||
return;
|
||||
}
|
||||
|
||||
if (property != null) {
|
||||
try {
|
||||
this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), Boolean.parseBoolean(args.get(1)));
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE + " must be true or false!");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (this.plugin.saveMVConfigs()) {
|
||||
sender.sendMessage(ChatColor.GREEN + "SUCCESS!" + ChatColor.WHITE + " Values were updated successfully!");
|
||||
this.plugin.loadConfigs();
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "FAIL!" + ChatColor.WHITE + " Check your console for details!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,17 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.List;
|
||||
|
||||
public class ConfirmCommand extends MultiverseCommand {
|
||||
|
||||
@@ -17,8 +23,9 @@ public class ConfirmCommand extends MultiverseCommand {
|
||||
this.setArgRange(0, 0);
|
||||
this.addKey("mvconfirm");
|
||||
this.addKey("mv confirm");
|
||||
this.addCommandExample("/mv confirm");
|
||||
this.setPermission("multiverse.core.confirm", "If you have not been prompted to use this, it will not do anything.", PermissionDefault.OP);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@@ -9,13 +18,11 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.LocationManipulation;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
public class CoordCommand extends MultiverseCommand {
|
||||
|
||||
private LocationManipulation locMan = new LocationManipulation();
|
||||
private WorldManager worldManager;
|
||||
|
||||
public CoordCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
@@ -25,7 +32,9 @@ public class CoordCommand extends MultiverseCommand {
|
||||
this.addKey("mv coord");
|
||||
this.addKey("mvcoord");
|
||||
this.addKey("mvco");
|
||||
this.addCommandExample("/mv coord");
|
||||
this.setPermission("multiverse.core.coord", "Returns detailed information on the Players where abouts.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -34,20 +43,22 @@ public class CoordCommand extends MultiverseCommand {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
World world = p.getWorld();
|
||||
|
||||
if(!this.plugin.isMVWorld(world.getName())) {
|
||||
|
||||
if (!this.worldManager.isMVWorld(world.getName())) {
|
||||
this.plugin.showNotMVWorldMessage(sender, world.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
MVWorld mvworld = this.plugin.getMVWorld(world.getName());
|
||||
// TODO: Convert to fancy stuff
|
||||
|
||||
|
||||
MultiverseWorld mvworld = this.worldManager.getMVWorld(world.getName());
|
||||
|
||||
p.sendMessage(ChatColor.AQUA + "--- Location Information ---");
|
||||
p.sendMessage(ChatColor.AQUA + "World: " + ChatColor.WHITE + world.getName());
|
||||
p.sendMessage(ChatColor.AQUA + "Alias: " + mvworld.getColoredWorldString());
|
||||
p.sendMessage(ChatColor.AQUA + "World Scale: " + ChatColor.WHITE + mvworld.getScaling());
|
||||
p.sendMessage(ChatColor.AQUA + "Coordinates: " + ChatColor.WHITE + this.locMan.strCoords(p.getLocation()));
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
df.setMinimumFractionDigits(0);
|
||||
df.setMaximumFractionDigits(2);
|
||||
p.sendMessage(ChatColor.AQUA + "Coordinates: " + ChatColor.WHITE + LocationManipulation.strCoords(p.getLocation()));
|
||||
p.sendMessage(ChatColor.AQUA + "Direction: " + ChatColor.WHITE + LocationManipulation.getDirection(p.getLocation()));
|
||||
p.sendMessage(ChatColor.AQUA + "Block: " + ChatColor.WHITE + Material.getMaterial(world.getBlockTypeIdAt(p.getLocation())));
|
||||
} else {
|
||||
|
||||
@@ -1,17 +1,25 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class CreateCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
|
||||
public CreateCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
@@ -27,6 +35,7 @@ public class CreateCommand extends MultiverseCommand {
|
||||
this.addCommandExample("/mv create " + ChatColor.GOLD + "starwars" + ChatColor.AQUA + " skylands");
|
||||
this.addCommandExample("/mv create " + ChatColor.GOLD + "gargamel" + ChatColor.GREEN + " normal" + ChatColor.DARK_AQUA + " -s gargamel");
|
||||
this.addCommandExample("/mv create " + ChatColor.GOLD + "moonworld" + ChatColor.GREEN + " normal" + ChatColor.DARK_AQUA + " -g BukkitFullOfMoon");
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,7 +49,7 @@ public class CreateCommand extends MultiverseCommand {
|
||||
String seed = CommandHandler.getFlag("-s", args);
|
||||
String generator = CommandHandler.getFlag("-g", args);
|
||||
|
||||
if (new File(worldName).exists() || this.plugin.isMVWorld(worldName)) {
|
||||
if (new File(worldName).exists() || this.worldManager.isMVWorld(worldName)) {
|
||||
sender.sendMessage(ChatColor.RED + "A Folder/World already exists with this name!");
|
||||
sender.sendMessage(ChatColor.RED + "If you are confident it is a world you can import with /mvimport");
|
||||
return;
|
||||
@@ -53,11 +62,10 @@ public class CreateCommand extends MultiverseCommand {
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(ChatColor.AQUA + "Starting world creation...");
|
||||
if (this.plugin.addWorld(worldName, environment, seed, generator)) {
|
||||
if (this.worldManager.addWorld(worldName, environment, seed, generator)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Complete!");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "FAILED.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class DebugCommand extends MultiverseCommand {
|
||||
|
||||
public DebugCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Turn Debug on/off?");
|
||||
this.setCommandUsage("/mv debug" + ChatColor.GOLD + " [1|2|3|off]");
|
||||
this.setArgRange(0, 1);
|
||||
this.addKey("mv debug");
|
||||
this.addKey("mv d");
|
||||
this.addKey("mvdebug");
|
||||
this.addCommandExample("/mv debug " + ChatColor.GOLD + "2");
|
||||
this.setPermission("multiverse.core.debug", "Spams the console a bunch.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
if (args.size() == 1) {
|
||||
if (args.get(0).equalsIgnoreCase("off")) {
|
||||
MultiverseCore.GlobalDebug = 0;
|
||||
} else {
|
||||
try {
|
||||
int debugLevel = Integer.parseInt(args.get(0));
|
||||
if (debugLevel > 3 || debugLevel < 0) {
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
MultiverseCore.GlobalDebug = debugLevel;
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Error" + ChatColor.WHITE + " setting debug level. Please use a number 0-3 " + ChatColor.AQUA + "(3 being many many messages!)");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
this.displayDebugMode(sender);
|
||||
}
|
||||
|
||||
private void displayDebugMode(CommandSender sender) {
|
||||
if (MultiverseCore.GlobalDebug == 0) {
|
||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
|
||||
} else {
|
||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + MultiverseCore.GlobalDebug);
|
||||
this.plugin.log(Level.FINE, "Multiverse Debug ENABLED");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,19 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DeleteCommand extends MultiverseCommand {
|
||||
|
||||
@@ -18,12 +24,13 @@ public class DeleteCommand extends MultiverseCommand {
|
||||
this.setArgRange(1, 1);
|
||||
this.addKey("mvdelete");
|
||||
this.addKey("mv delete");
|
||||
this.addCommandExample("/mv create " + ChatColor.GOLD + "MyWorld");
|
||||
this.setPermission("multiverse.core.delete", "Deletes a world on your server. " + ChatColor.RED + "PERMANENTLY.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
Class<?> paramTypes[] = { String.class };
|
||||
Class<?> paramTypes[] = {String.class};
|
||||
List<Object> objectArgs = new ArrayList<Object>(args);
|
||||
this.plugin.getCommandHandler().queueCommand(sender, "mvdelete", "deleteWorld", objectArgs, paramTypes, ChatColor.GREEN + "World Deleted!", ChatColor.RED + "World could NOT be deleted!");
|
||||
}
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EnvironmentCommand extends MultiverseCommand {
|
||||
|
||||
@@ -20,10 +25,10 @@ public class EnvironmentCommand extends MultiverseCommand {
|
||||
this.addKey("mv env");
|
||||
this.addKey("mv environment");
|
||||
this.addKey("mv environments");
|
||||
this.addCommandExample("/mv env");
|
||||
this.setPermission("multiverse.core.list.environments", "Lists valid known environments.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
|
||||
public static void showEnvironments(CommandSender sender) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "Valid Environments are:");
|
||||
sender.sendMessage(ChatColor.GREEN + "NORMAL");
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class GeneratorCommand extends MultiverseCommand {
|
||||
|
||||
public GeneratorCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("World Information");
|
||||
this.setCommandUsage("/mv generators");
|
||||
this.setArgRange(0, 0);
|
||||
this.addKey("mv generators");
|
||||
this.addKey("mvgenerators");
|
||||
this.addKey("mv gens");
|
||||
this.addKey("mvgens");
|
||||
this.addCommandExample("/mv generators");
|
||||
this.setPermission("multiverse.core.generator", "Returns a list of Loaded Generator Plugins.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
this.plugin.log(Level.INFO, "PLEASE IGNORE the 'Plugin X does not contain any generators' message below!");
|
||||
Plugin[] plugins = this.plugin.getServer().getPluginManager().getPlugins();
|
||||
List<String> generators = new ArrayList<String>();
|
||||
for (Plugin p : plugins) {
|
||||
if (p.isEnabled() && p.getDefaultWorldGenerator("world", "") != null) {
|
||||
generators.add(p.getDescription().getName());
|
||||
}
|
||||
}
|
||||
sender.sendMessage(ChatColor.AQUA + "--- Loaded Generator Plugins ---");
|
||||
String loadedGens = "";
|
||||
boolean altColor = false;
|
||||
for (String s : generators) {
|
||||
if (altColor) {
|
||||
altColor = false;
|
||||
loadedGens += ChatColor.YELLOW + s + "";
|
||||
} else {
|
||||
altColor = true;
|
||||
loadedGens += ChatColor.WHITE + s + "";
|
||||
}
|
||||
}
|
||||
if (loadedGens.length() == 0) {
|
||||
loadedGens = ChatColor.RED + "No Generator Plugins found.";
|
||||
}
|
||||
sender.sendMessage(loadedGens);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,22 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
// This file is no longer licensed under that silly CC license. I have blanked it out and will start implementaiton of my own in a few days. For now there is no help.
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.pneumaticraft.commandhandler.Command;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.pneumaticraft.commandhandler.Command;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HelpCommand extends MultiverseCommand {
|
||||
private static final int CMDS_PER_PAGE = 7;
|
||||
@@ -26,6 +32,7 @@ public class HelpCommand extends MultiverseCommand {
|
||||
this.addKey("mv help");
|
||||
this.addKey("mvsearch");
|
||||
this.addKey("mv search");
|
||||
this.addCommandExample("/mv help ?");
|
||||
this.setPermission("multiverse.help", "Displays a nice help menu.", PermissionDefault.TRUE);
|
||||
}
|
||||
|
||||
@@ -37,8 +44,7 @@ public class HelpCommand extends MultiverseCommand {
|
||||
|
||||
String filter = "";
|
||||
|
||||
if (args.size() == 0)
|
||||
{
|
||||
if (args.size() == 0) {
|
||||
filter = "";
|
||||
page = 1;
|
||||
} else if (args.size() == 1) {
|
||||
@@ -97,8 +103,8 @@ public class HelpCommand extends MultiverseCommand {
|
||||
filtered.add(c);
|
||||
} else if (c.getCommandDesc().matches("(?i).*" + filter + ".*")) {
|
||||
filtered.add(c);
|
||||
}else if (c.getCommandUsage().matches("(?i).*" + filter + ".*")) {
|
||||
filtered.add(c);
|
||||
} else if (c.getCommandUsage().matches("(?i).*" + filter + ".*")) {
|
||||
filtered.add(c);
|
||||
}
|
||||
}
|
||||
return filtered;
|
||||
|
||||
@@ -1,16 +1,24 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class ImportCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
|
||||
public ImportCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
@@ -20,13 +28,17 @@ public class ImportCommand extends MultiverseCommand {
|
||||
this.addKey("mvimport");
|
||||
this.addKey("mvim");
|
||||
this.addKey("mv import");
|
||||
this.addCommandExample("/mv import " + ChatColor.GOLD + "gargamel" + ChatColor.GREEN + " normal");
|
||||
this.addCommandExample("/mv import " + ChatColor.GOLD + "hell_world" + ChatColor.GREEN + " nether");
|
||||
this.addCommandExample("/mv import " + ChatColor.GOLD + "CleanRoom" + ChatColor.GREEN + " normal" + ChatColor.DARK_AQUA + " CleanRoomGenerator");
|
||||
this.setPermission("multiverse.core.import", "Imports a new world of the specified type.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
String worldName = args.get(0);
|
||||
if (this.plugin.isMVWorld(worldName) && new File(worldName).exists()) {
|
||||
if (this.worldManager.isMVWorld(worldName) && new File(worldName).exists()) {
|
||||
sender.sendMessage(ChatColor.RED + "Multiverse already knows about this world!");
|
||||
return;
|
||||
}
|
||||
@@ -46,7 +58,7 @@ public class ImportCommand extends MultiverseCommand {
|
||||
|
||||
if (new File(worldName).exists() && env != null) {
|
||||
sender.sendMessage(ChatColor.AQUA + "Starting world import...");
|
||||
this.plugin.addWorld(worldName, environment, null, generator);
|
||||
this.worldManager.addWorld(worldName, environment, null, generator);
|
||||
sender.sendMessage(ChatColor.GREEN + "Complete!");
|
||||
return;
|
||||
} else if (env == null) {
|
||||
|
||||
@@ -1,22 +1,30 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.FancyText;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.utils.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.FancyColorScheme;
|
||||
import com.onarandombox.utils.FancyHeader;
|
||||
import com.onarandombox.utils.FancyMessage;
|
||||
import com.onarandombox.utils.FancyText;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// Will use when we can compile with JDK 6
|
||||
//import com.sun.xml.internal.ws.util.StringUtils;
|
||||
|
||||
public class InfoCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
|
||||
public InfoCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
@@ -26,7 +34,10 @@ public class InfoCommand extends MultiverseCommand {
|
||||
this.addKey("mvinfo");
|
||||
this.addKey("mvi");
|
||||
this.addKey("mv info");
|
||||
this.addCommandExample("/mv info " + ChatColor.GOLD + "1");
|
||||
this.addCommandExample("/mv info " + ChatColor.GOLD + "3");
|
||||
this.setPermission("multiverse.core.info", "Returns detailed information on the world.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,9 +54,8 @@ public class InfoCommand extends MultiverseCommand {
|
||||
sender.sendMessage("You must enter a" + ChatColor.LIGHT_PURPLE + " world" + ChatColor.WHITE + " from the console!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (args.size() == 1) {
|
||||
if (this.plugin.getMVWorld(args.get(0)) != null) {
|
||||
} else if (args.size() == 1) {
|
||||
if (this.worldManager.getMVWorld(args.get(0)) != null) {
|
||||
// then we have a world!
|
||||
worldName = args.get(0);
|
||||
} else {
|
||||
@@ -62,8 +72,7 @@ public class InfoCommand extends MultiverseCommand {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (args.size() == 2) {
|
||||
} else if (args.size() == 2) {
|
||||
worldName = args.get(0);
|
||||
try {
|
||||
pageNum = Integer.parseInt(args.get(1)) - 1;
|
||||
@@ -72,8 +81,12 @@ public class InfoCommand extends MultiverseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.plugin.isMVWorld(worldName)) {
|
||||
showPage(pageNum, sender, this.buildEntireCommand(this.plugin.getMVWorld(worldName)));
|
||||
if (this.worldManager.isMVWorld(worldName)) {
|
||||
Player p = null;
|
||||
if (sender instanceof Player) {
|
||||
p = (Player) sender;
|
||||
}
|
||||
showPage(pageNum, sender, this.buildEntireCommand(this.worldManager.getMVWorld(worldName), p));
|
||||
} else if (this.plugin.getServer().getWorld(worldName) != null) {
|
||||
sender.sendMessage("That world exists, but multiverse does not know about it!");
|
||||
sender.sendMessage("You can import it with" + ChatColor.AQUA + "/mv import " + ChatColor.GREEN + worldName + ChatColor.LIGHT_PURPLE + "{ENV}");
|
||||
@@ -81,7 +94,7 @@ public class InfoCommand extends MultiverseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private List<List<FancyText>> buildEntireCommand(MVWorld world) {
|
||||
private List<List<FancyText>> buildEntireCommand(MultiverseWorld world, Player p) {
|
||||
List<FancyText> message = new ArrayList<FancyText>();
|
||||
List<List<FancyText>> worldInfo = new ArrayList<List<FancyText>>();
|
||||
// Page 1
|
||||
@@ -89,18 +102,23 @@ public class InfoCommand extends MultiverseCommand {
|
||||
message.add(new FancyHeader("General Info", colors));
|
||||
message.add(new FancyMessage("World Name: ", world.getName(), colors));
|
||||
message.add(new FancyMessage("World Alias: ", world.getColoredWorldString(), colors));
|
||||
message.add(new FancyMessage("Seed: ", world.getCBWorld().getSeed() + "", colors));
|
||||
Location spawn = world.getCBWorld().getSpawnLocation();
|
||||
message.add(new FancyMessage("Spawn Location: ", "(" + spawn.getBlockX() + ", " + spawn.getBlockY() + ", " + spawn.getBlockZ() + ")", colors));
|
||||
message.add(new FancyMessage("World Scale: ", world.getScaling().toString(), colors));
|
||||
String enforced = "";
|
||||
if (!MultiverseCore.EnforceGameModes) {
|
||||
enforced = ChatColor.RED + " Not Enforced!";
|
||||
}
|
||||
message.add(new FancyMessage("Game Mode: ", world.getGameMode() + enforced, colors));
|
||||
//message.add(new FancyMessage("Game Mode: ", StringUtils.capitalize(world.getGameMode().toString()), colors));
|
||||
Location spawn = world.getSpawnLocation();
|
||||
message.add(new FancyMessage("Spawn Location: ", LocationManipulation.strCoords(spawn), colors));
|
||||
message.add(new FancyMessage("World Scale: ", world.getScaling() + "", colors));
|
||||
if (world.getPrice() > 0) {
|
||||
message.add(new FancyMessage("Price to enter this world: ", this.plugin.getBank().getFormattedAmount(world.getPrice(), world.getCurrency()), colors));
|
||||
message.add(new FancyMessage("Price to enter this world: ", this.plugin.getBank().getFormattedAmount(p, world.getPrice(), world.getCurrency()), colors));
|
||||
} else {
|
||||
message.add(new FancyMessage("Price to enter this world: ", ChatColor.GREEN + "FREE!", colors));
|
||||
}
|
||||
|
||||
if (world.getRespawnToWorld() != null) {
|
||||
MVWorld respawn = this.plugin.getMVWorld(world.getRespawnToWorld());
|
||||
MultiverseWorld respawn = this.worldManager.getMVWorld(world.getRespawnToWorld());
|
||||
if (respawn != null) {
|
||||
message.add(new FancyMessage("Players will respawn in: ", respawn.getColoredWorldString(), colors));
|
||||
} else {
|
||||
@@ -112,44 +130,49 @@ public class InfoCommand extends MultiverseCommand {
|
||||
worldInfo.add(message);
|
||||
// Page 2
|
||||
message = new ArrayList<FancyText>();
|
||||
message.add(new FancyHeader("More World Settings", colors));
|
||||
message.add(new FancyMessage("Difficulty: ", world.getDifficulty().toString(), colors));
|
||||
message.add(new FancyMessage("Weather: ", world.isWeatherEnabled() + "", colors));
|
||||
message.add(new FancyMessage("Players will get hungry: ", world.getHunger() + "", colors));
|
||||
message.add(new FancyMessage("Keep spawn in memory: ", world.isKeepingSpawnInMemory() + "", colors));
|
||||
message.add(new FancyHeader("PVP Settings", colors));
|
||||
message.add(new FancyMessage("Multiverse Setting: ", world.getPvp().toString(), colors));
|
||||
message.add(new FancyMessage("Multiverse Setting: ", world.isPVPEnabled() + "", colors));
|
||||
message.add(new FancyMessage("Bukkit Setting: ", world.getCBWorld().getPVP() + "", colors));
|
||||
message.add(new FancyMessage("Fake PVP Enabled: ", world.getFakePVP() + "", colors));
|
||||
worldInfo.add(message);
|
||||
// Page 3
|
||||
message = new ArrayList<FancyText>();
|
||||
message.add(new FancyHeader("Monster Settings", colors));
|
||||
message.add(new FancyMessage("Multiverse Setting: ", world.allowMonsterSpawning().toString(), colors));
|
||||
message.add(new FancyMessage("Multiverse Setting: ", world.canMonstersSpawn() + "", colors));
|
||||
message.add(new FancyMessage("Bukkit Setting: ", world.getCBWorld().getAllowMonsters() + "", colors));
|
||||
if (MultiverseCore.MobsDisabledInDefaultWorld) {
|
||||
message.add(new FancyMessage(ChatColor.RED + "WARNING: ", "Monsters WILL NOT SPAWN IN THIS WORLD.", colors));
|
||||
message.add(new FancyMessage(ChatColor.RED + "WARNING: ", "Check your server log for more details.", colors));
|
||||
}
|
||||
if (world.getMonsterList().size() > 0) {
|
||||
if (world.allowMonsterSpawning()) {
|
||||
if (world.canMonstersSpawn()) {
|
||||
message.add(new FancyMessage("Monsters that" + ChatColor.RED + " CAN NOT " + ChatColor.GREEN + "spawn: ", toCommaSeperated(world.getMonsterList()), colors));
|
||||
} else {
|
||||
message.add(new FancyMessage("Monsters that" + ChatColor.GREEN + " CAN SPAWN: ", toCommaSeperated(world.getMonsterList()), colors));
|
||||
}
|
||||
} else {
|
||||
message.add(new FancyMessage("Monsters that CAN spawn: ", world.allowMonsterSpawning() ? "ALL" : "NONE", colors));
|
||||
message.add(new FancyMessage("Monsters that CAN spawn: ", world.canMonstersSpawn() ? "ALL" : "NONE", colors));
|
||||
}
|
||||
worldInfo.add(message);
|
||||
|
||||
// Page 4
|
||||
message = new ArrayList<FancyText>();
|
||||
message.add(new FancyHeader("Animal Settings", colors));
|
||||
message.add(new FancyMessage("Multiverse Setting: ", world.allowAnimalSpawning().toString(), colors));
|
||||
message.add(new FancyMessage("Multiverse Setting: ", world.canAnimalsSpawn() + "", colors));
|
||||
message.add(new FancyMessage("Bukkit Setting: ", world.getCBWorld().getAllowAnimals() + "", colors));
|
||||
if (world.getMonsterList().size() > 0) {
|
||||
if (world.allowMonsterSpawning()) {
|
||||
if (world.canMonstersSpawn()) {
|
||||
message.add(new FancyMessage("Animals that" + ChatColor.RED + " CAN NOT " + ChatColor.GREEN + "spawn: ", toCommaSeperated(world.getAnimalList()), colors));
|
||||
} else {
|
||||
message.add(new FancyMessage("Animals that" + ChatColor.GREEN + " CAN SPAWN: ", toCommaSeperated(world.getAnimalList()), colors));
|
||||
}
|
||||
} else {
|
||||
message.add(new FancyMessage("Animals that CAN spawn: ", world.allowAnimalSpawning() ? "ALL" : "NONE", colors));
|
||||
message.add(new FancyMessage("Animals that CAN spawn: ", world.canAnimalsSpawn() ? "ALL" : "NONE", colors));
|
||||
}
|
||||
worldInfo.add(message);
|
||||
|
||||
@@ -157,10 +180,10 @@ public class InfoCommand extends MultiverseCommand {
|
||||
}
|
||||
|
||||
private String toCommaSeperated(List<String> list) {
|
||||
if(list == null || list.size() == 0) {
|
||||
if (list == null || list.size() == 0) {
|
||||
return "";
|
||||
}
|
||||
if(list.size() == 1) {
|
||||
if (list.size() == 1) {
|
||||
return list.get(0);
|
||||
}
|
||||
String result = list.get(0);
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.List;
|
||||
|
||||
public class ListCommand extends MultiverseCommand {
|
||||
|
||||
@@ -32,9 +38,9 @@ public class ListCommand extends MultiverseCommand {
|
||||
}
|
||||
|
||||
String output = ChatColor.LIGHT_PURPLE + "Worlds which you can view:\n";
|
||||
for (MVWorld world : this.plugin.getMVWorlds()) {
|
||||
for (MultiverseWorld world : this.plugin.getMVWorldManager().getMVWorlds()) {
|
||||
|
||||
if (p != null && (!this.plugin.getPermissions().canEnterWorld(p, world))) {
|
||||
if (p != null && (!this.plugin.getMVPerms().canEnterWorld(p, world))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -47,8 +53,17 @@ public class ListCommand extends MultiverseCommand {
|
||||
} else if (env == Environment.SKYLANDS) {
|
||||
color = ChatColor.AQUA;
|
||||
}
|
||||
output += world.getColoredWorldString() + ChatColor.WHITE + " - " + color + world.getEnvironment() + " \n";
|
||||
|
||||
String outputCache = world.getColoredWorldString() + ChatColor.WHITE + " - " + color + world.getEnvironment() + " \n";
|
||||
if (world.isHidden()) {
|
||||
// TODO: Add an actual permission for this.
|
||||
if (p == null || p.isOp()) {
|
||||
// Prefix hidden worlds with an "[H]"
|
||||
outputCache = ChatColor.GRAY + "[H]" + outputCache;
|
||||
output += outputCache;
|
||||
}
|
||||
} else {
|
||||
output += outputCache;
|
||||
}
|
||||
}
|
||||
String[] response = output.split("\n");
|
||||
for (String msg : response) {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LoadCommand extends MultiverseCommand {
|
||||
|
||||
public LoadCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Load World");
|
||||
this.setCommandUsage("/mv load" + ChatColor.GREEN + " {WORLD}");
|
||||
this.setArgRange(1, 1);
|
||||
this.addKey("mvload");
|
||||
this.addKey("mv load");
|
||||
this.addCommandExample("/mv load " + ChatColor.GREEN + "MyUnloadedWorld");
|
||||
this.setPermission("multiverse.core.load", "Loads a world into Multiverse.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
if (this.plugin.getMVWorldManager().loadWorld(args.get(0))) {
|
||||
sender.sendMessage("World Loaded!");
|
||||
} else {
|
||||
sender.sendMessage("Error trying to load world!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,28 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.enums.Action;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.List;
|
||||
|
||||
// This will contain all the properties that support the ADD/REMOVE
|
||||
// Anything not in here will only support the SET action
|
||||
|
||||
public class ModifyAddCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
|
||||
public ModifyAddCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
@@ -24,7 +33,11 @@ public class ModifyAddCommand extends MultiverseCommand {
|
||||
this.addKey("mvmadd");
|
||||
this.addKey("mv modify add");
|
||||
this.addKey("mvmodify add");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "add " + ChatColor.GREEN + "sheep " + ChatColor.RED + "animals");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "add " + ChatColor.GREEN + "creeper " + ChatColor.RED + "monsters");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "add " + ChatColor.GREEN + "MyWorld " + ChatColor.RED + "worldblacklist");
|
||||
this.setPermission("multiverse.core.modify.add", "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,14 +56,14 @@ public class ModifyAddCommand extends MultiverseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
MVWorld world;
|
||||
MultiverseWorld world;
|
||||
String value = args.get(0);
|
||||
String property = args.get(1);
|
||||
|
||||
if (args.size() == 2) {
|
||||
world = this.plugin.getMVWorld(p.getWorld().getName());
|
||||
world = this.worldManager.getMVWorld(p.getWorld().getName());
|
||||
} else {
|
||||
world = this.plugin.getMVWorld(args.get(2));
|
||||
world = this.worldManager.getMVWorld(args.get(2));
|
||||
}
|
||||
|
||||
if (world == null) {
|
||||
@@ -64,7 +77,7 @@ public class ModifyAddCommand extends MultiverseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (world.addToList(property, value)) {
|
||||
if (world.addToVariable(property, value)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + value + ChatColor.WHITE + " was " + ChatColor.GREEN + "added to " + ChatColor.GREEN + property);
|
||||
} else {
|
||||
sender.sendMessage(value + " could not be added to " + property);
|
||||
|
||||
@@ -1,16 +1,25 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.enums.Action;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.List;
|
||||
|
||||
public class ModifyClearCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
|
||||
public ModifyClearCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
@@ -21,7 +30,11 @@ public class ModifyClearCommand extends MultiverseCommand {
|
||||
this.addKey("mvmclear");
|
||||
this.addKey("mv modify clear");
|
||||
this.addKey("mvmodify clear");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "clear " + ChatColor.RED + "animals");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "clear " + ChatColor.RED + "monsters");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "clear " + ChatColor.RED + "worldblacklist");
|
||||
this.setPermission("multiverse.core.modify.clear", "Removes all values from a property. This will work on properties that contain lists.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,13 +52,13 @@ public class ModifyClearCommand extends MultiverseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
MVWorld world;
|
||||
MultiverseWorld world;
|
||||
String property = args.get(0);
|
||||
|
||||
if (args.size() == 1) {
|
||||
world = this.plugin.getMVWorld(p.getWorld().getName());
|
||||
world = this.worldManager.getMVWorld(p.getWorld().getName());
|
||||
} else {
|
||||
world = this.plugin.getMVWorld(args.get(1));
|
||||
world = this.worldManager.getMVWorld(args.get(1));
|
||||
}
|
||||
|
||||
if (world == null) {
|
||||
|
||||
@@ -1,28 +1,24 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.enums.Action;
|
||||
import com.onarandombox.MultiverseCore.enums.AddProperties;
|
||||
import com.onarandombox.MultiverseCore.enums.SetProperties;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
enum AddProperties {
|
||||
blockblacklist, playerwhitelist, playerblacklist, worldblacklist, animals, monsters
|
||||
}
|
||||
|
||||
enum Action {
|
||||
Set, Add, Remove, Clear
|
||||
}
|
||||
|
||||
// Color == Aliascolor
|
||||
enum SetProperties {
|
||||
alias, animals, monsters, pvp, scaling, aliascolor, color, respawn, currency, curr, price, scale, spawnmemory, memory, weather, storm
|
||||
}
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ModifyCommand extends MultiverseCommand {
|
||||
|
||||
|
||||
@@ -1,16 +1,25 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.enums.Action;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.List;
|
||||
|
||||
public class ModifyRemoveCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
|
||||
public ModifyRemoveCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
@@ -25,7 +34,11 @@ public class ModifyRemoveCommand extends MultiverseCommand {
|
||||
this.addKey("mvmdelete");
|
||||
this.addKey("mv modify delete");
|
||||
this.addKey("mvmodify delete");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "remove " + ChatColor.GREEN + "sheep " + ChatColor.RED + "animals");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "remove " + ChatColor.GREEN + "creeper " + ChatColor.RED + "monsters");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "remove " + ChatColor.GREEN + "MyWorld " + ChatColor.RED + "worldblacklist");
|
||||
this.setPermission("multiverse.core.modify.remove", "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,14 +57,14 @@ public class ModifyRemoveCommand extends MultiverseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
MVWorld world;
|
||||
MultiverseWorld world;
|
||||
String value = args.get(0);
|
||||
String property = args.get(1);
|
||||
|
||||
if (args.size() == 2) {
|
||||
world = this.plugin.getMVWorld(p.getWorld().getName());
|
||||
world = this.worldManager.getMVWorld(p.getWorld().getName());
|
||||
} else {
|
||||
world = this.plugin.getMVWorld(args.get(2));
|
||||
world = this.worldManager.getMVWorld(args.get(2));
|
||||
}
|
||||
|
||||
if (world == null) {
|
||||
@@ -64,7 +77,7 @@ public class ModifyRemoveCommand extends MultiverseCommand {
|
||||
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/4W8cY");
|
||||
return;
|
||||
}
|
||||
if (world.removeFromList(property, value)) {
|
||||
if (world.removeFromVariable(property, value)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + value + ChatColor.WHITE + " was " + ChatColor.RED + "removed from " + ChatColor.GREEN + property);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "There was an error removing " + ChatColor.GRAY + value + ChatColor.WHITE + " from " + ChatColor.GOLD + property);
|
||||
|
||||
@@ -1,31 +1,68 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.enums.Action;
|
||||
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.List;
|
||||
|
||||
public class ModifySetCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
|
||||
public ModifySetCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Modify a World (Set a value)");
|
||||
this.setCommandUsage("/mv modify" + ChatColor.GREEN + " set {PROPERTY} {VALUE}" + ChatColor.GOLD + " [WORLD]");
|
||||
this.setArgRange(2, 3);
|
||||
this.setArgRange(1, 3);
|
||||
this.addKey("mvm set");
|
||||
this.addKey("mvmset");
|
||||
this.addKey("mv modify set");
|
||||
this.addKey("mvmodify set");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "mode " + ChatColor.RED + "creative");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "animals " + ChatColor.RED + "false");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "monsters " + ChatColor.RED + "false");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "alias " + ChatColor.RED + "MyWorld");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "color " + ChatColor.RED + "green");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "curr " + ChatColor.RED + "3");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "price " + ChatColor.RED + "5");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "scale " + ChatColor.RED + "1.2");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "memory " + ChatColor.RED + "true");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "diff " + ChatColor.RED + "hard");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "hunger " + ChatColor.RED + "false");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "hidden " + ChatColor.RED + "true");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "pvp " + ChatColor.RED + "false");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "spawn");
|
||||
this.setPermission("multiverse.core.modify.set", "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
// Special case for spawn:
|
||||
if (args.size() == 1) {
|
||||
if (args.get(0).equalsIgnoreCase("spawn")) {
|
||||
SetSpawnCommand c = new SetSpawnCommand(this.plugin);
|
||||
c.setWorldSpawn(sender);
|
||||
|
||||
} else {
|
||||
sender.sendMessage("Spawn is the only param with no" + ChatColor.GREEN + " VALUE");
|
||||
sender.sendMessage("Type " + ChatColor.GREEN + "/mv modify ?" + ChatColor.WHITE + " For help.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
// We NEED a world from the command line
|
||||
Player p = null;
|
||||
if (sender instanceof Player) {
|
||||
@@ -40,14 +77,14 @@ public class ModifySetCommand extends MultiverseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
MVWorld world;
|
||||
MultiverseWorld world;
|
||||
String value = args.get(1);
|
||||
String property = args.get(0);
|
||||
|
||||
if (args.size() == 2) {
|
||||
world = this.plugin.getMVWorld(p.getWorld().getName());
|
||||
world = this.worldManager.getMVWorld(p.getWorld().getName());
|
||||
} else {
|
||||
world = this.plugin.getMVWorld(args.get(2));
|
||||
world = this.worldManager.getMVWorld(args.get(2));
|
||||
}
|
||||
|
||||
if (world == null) {
|
||||
@@ -61,7 +98,8 @@ public class ModifySetCommand extends MultiverseCommand {
|
||||
return;
|
||||
}
|
||||
if ((property.equalsIgnoreCase("aliascolor") || property.equalsIgnoreCase("color")) && !world.isValidAliasColor(value)) {
|
||||
sender.sendMessage(value + " is not a valid color. Please see our Github Wiki for the complete color list.");
|
||||
sender.sendMessage(value + " is not a valid color. Please pick one of the following:");
|
||||
sender.sendMessage(EnglishChatColor.getAllColors());
|
||||
} else if (world.setVariable(property, value)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Property " + ChatColor.AQUA + property + ChatColor.WHITE + " was set to " + ChatColor.GREEN + value);
|
||||
} else {
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.pneumaticraft.commandhandler.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class MultiverseCommand extends Command {
|
||||
|
||||
protected MultiverseCore plugin;
|
||||
|
||||
public MultiverseCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.plugin = plugin;
|
||||
|
||||
@@ -1,19 +1,27 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.utils.PurgeWorlds;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.PurgeWorlds;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PurgeCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
|
||||
public PurgeCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
@@ -22,7 +30,14 @@ public class PurgeCommand extends MultiverseCommand {
|
||||
this.setArgRange(1, 2);
|
||||
this.addKey("mvpurge");
|
||||
this.addKey("mv purge");
|
||||
this.addCommandExample("/mv purge " + ChatColor.GREEN + "all");
|
||||
this.addCommandExample("/mv purge " + ChatColor.GOLD + "all " + ChatColor.GREEN + "all");
|
||||
this.addCommandExample("/mv purge " + ChatColor.GREEN + "monsters");
|
||||
this.addCommandExample("/mv purge " + ChatColor.GOLD + "all " + ChatColor.GREEN + "animals");
|
||||
this.addCommandExample("/mv purge " + ChatColor.GOLD + "MyWorld " + ChatColor.GREEN + "squid");
|
||||
this.addCommandExample("/mv purge " + ChatColor.GOLD + "MyWorld_nether " + ChatColor.GREEN + "ghast");
|
||||
this.setPermission("multiverse.core.purge", "Removed the specified type of mob from the specified world.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,28 +61,28 @@ public class PurgeCommand extends MultiverseCommand {
|
||||
deathName = args.get(1);
|
||||
}
|
||||
|
||||
if (!worldName.equalsIgnoreCase("all") && !this.plugin.isMVWorld(worldName)) {
|
||||
((MultiverseCore)this.plugin).showNotMVWorldMessage(sender, worldName);
|
||||
if (!worldName.equalsIgnoreCase("all") && !this.worldManager.isMVWorld(worldName)) {
|
||||
((MultiverseCore) this.plugin).showNotMVWorldMessage(sender, worldName);
|
||||
sender.sendMessage("It cannot be purged.");
|
||||
return;
|
||||
}
|
||||
|
||||
List<MVWorld> worldsToRemoveEntitiesFrom = new ArrayList<MVWorld>();
|
||||
List<MultiverseWorld> worldsToRemoveEntitiesFrom = new ArrayList<MultiverseWorld>();
|
||||
// Handle all case any user who names a world "all" should know better...
|
||||
if (worldName.equalsIgnoreCase("all")) {
|
||||
worldsToRemoveEntitiesFrom.addAll(this.plugin.getMVWorlds());
|
||||
worldsToRemoveEntitiesFrom.addAll(this.worldManager.getMVWorlds());
|
||||
} else {
|
||||
worldsToRemoveEntitiesFrom.add(this.plugin.getMVWorld(worldName));
|
||||
worldsToRemoveEntitiesFrom.add(this.worldManager.getMVWorld(worldName));
|
||||
}
|
||||
|
||||
PurgeWorlds purger = this.plugin.getWorldPurger();
|
||||
PurgeWorlds purger = this.worldManager.getWorldPurger();
|
||||
ArrayList<String> thingsToKill = new ArrayList<String>();
|
||||
if (deathName.equalsIgnoreCase("all") || deathName.equalsIgnoreCase("animals") || deathName.equalsIgnoreCase("monsters")) {
|
||||
thingsToKill.add(deathName.toUpperCase());
|
||||
} else {
|
||||
Collections.addAll(thingsToKill, deathName.toUpperCase().split(","));
|
||||
}
|
||||
for (MVWorld w : worldsToRemoveEntitiesFrom) {
|
||||
for (MultiverseWorld w : worldsToRemoveEntitiesFrom) {
|
||||
purger.purgeWorld(sender, w, thingsToKill, false, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.event.MVConfigReloadEvent;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.event.MVConfigReloadEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ReloadCommand extends MultiverseCommand {
|
||||
|
||||
@@ -19,6 +25,7 @@ public class ReloadCommand extends MultiverseCommand {
|
||||
this.setArgRange(0, 0);
|
||||
this.addKey("mvreload");
|
||||
this.addKey("mv reload");
|
||||
this.addCommandExample("/mv reload");
|
||||
this.setPermission("multiverse.core.reload", "Reloads worlds.yml and config.yml.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@@ -26,18 +33,19 @@ public class ReloadCommand extends MultiverseCommand {
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
sender.sendMessage(ChatColor.GOLD + "Reloading all Multiverse Plugin configs...");
|
||||
this.plugin.loadConfigs();
|
||||
this.plugin.loadWorlds(true);
|
||||
|
||||
// Create the event
|
||||
this.plugin.getMVWorldManager().loadWorlds(true);
|
||||
|
||||
List<String> configsLoaded = new ArrayList<String>();
|
||||
configsLoaded.add("Multiverse-Core - config.yml");
|
||||
configsLoaded.add("Multiverse-Core - worlds.yml");
|
||||
// Create the event
|
||||
MVConfigReloadEvent configReload = new MVConfigReloadEvent(configsLoaded);
|
||||
// Fire it off
|
||||
this.plugin.getServer().getPluginManager().callEvent(configReload);
|
||||
for(String s : configReload.getAllConfigsLoaded()) {
|
||||
for (String s : configReload.getAllConfigsLoaded()) {
|
||||
sender.sendMessage(s);
|
||||
}
|
||||
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Reload Complete!");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.List;
|
||||
|
||||
public class RemoveCommand extends MultiverseCommand {
|
||||
|
||||
@@ -17,12 +23,13 @@ public class RemoveCommand extends MultiverseCommand {
|
||||
this.setArgRange(1, 1);
|
||||
this.addKey("mvremove");
|
||||
this.addKey("mv remove");
|
||||
this.setPermission("multiverse.core.remove", "Unloads a world from Multiverse and removes it from worlds.yml, this does NOT remove the world folder.", PermissionDefault.OP);
|
||||
this.addCommandExample("/mv remove " + ChatColor.GREEN + "MyWorld");
|
||||
this.setPermission("multiverse.core.remove", "Unloads a world from Multiverse and removes it from worlds.yml, this does NOT DELETE the world folder.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
if (this.plugin.removeWorldFromConfig(args.get(0))) {
|
||||
if (this.plugin.getMVWorldManager().removeWorldFromConfig(args.get(0))) {
|
||||
sender.sendMessage("World removed from config!");
|
||||
} else {
|
||||
sender.sendMessage("Error trying to remove world from config!");
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.List;
|
||||
|
||||
public class SetSpawnCommand extends MultiverseCommand {
|
||||
|
||||
@@ -22,17 +30,29 @@ public class SetSpawnCommand extends MultiverseCommand {
|
||||
this.addKey("mv set spawn");
|
||||
this.addKey("mv setspawn");
|
||||
this.addKey("mvset spawn");
|
||||
this.addCommandExample("/mv set spawn");
|
||||
this.setPermission("multiverse.core.spawn.set", "Sets the spawn for the current world.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
setWorldSpawn(sender);
|
||||
}
|
||||
|
||||
protected void setWorldSpawn(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
Location l = p.getLocation();
|
||||
World w = p.getWorld();
|
||||
w.setSpawnLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
p.sendMessage(w.getName() + " - Spawn set to X: " + l.getBlockX() + " Y: " + l.getBlockY() + " Z: " + l.getBlockZ());
|
||||
MultiverseWorld foundWorld = this.plugin.getMVWorldManager().getMVWorld(w.getName());
|
||||
if (foundWorld != null) {
|
||||
foundWorld.setSpawnLocation(p.getLocation());
|
||||
sender.sendMessage("Spawn was set to: " + LocationManipulation.strCoords(p.getLocation()));
|
||||
} else {
|
||||
w.setSpawnLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
sender.sendMessage("Multiverse does not know about this world, only X,Y and Z set. Please import it to set the spawn fully (Pitch/Yaws).");
|
||||
}
|
||||
|
||||
} else {
|
||||
sender.sendMessage("You cannot use this command from the console.");
|
||||
}
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.List;
|
||||
|
||||
public class SleepCommand extends MultiverseCommand {
|
||||
|
||||
@@ -29,13 +35,5 @@ public class SleepCommand extends MultiverseCommand {
|
||||
if (p == null) {
|
||||
return;
|
||||
}
|
||||
// MVPlayerSession session = this.plugin.getPlayerSession(p);
|
||||
// if (session.getBedRespawnLocation() != null) {
|
||||
// p.teleport(session.getBedRespawnLocation());
|
||||
// } else {
|
||||
// sender.sendMessage("Hmm this is awkward...");
|
||||
// sender.sendMessage("Something is wrong with your bed.");
|
||||
// sender.sendMessage("It has either been destroyed or obstructed.");
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,22 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.List;
|
||||
|
||||
public class SpawnCommand extends MultiverseCommand {
|
||||
|
||||
@@ -23,7 +31,7 @@ public class SpawnCommand extends MultiverseCommand {
|
||||
this.addKey("mvs");
|
||||
this.setPermission("multiverse.core.spawn.self", "Teleports you to the Spawn Point of the world you are in.", PermissionDefault.OP);
|
||||
this.addAdditonalPermission(otherPerm);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -34,14 +42,15 @@ public class SpawnCommand extends MultiverseCommand {
|
||||
}
|
||||
// If a persons name was passed in, you must be A. the console, or B have permissions
|
||||
if (args.size() == 1) {
|
||||
if (player != null && !this.plugin.getPermissions().hasPermission(player, "multiverse.core.spawn.other", true)) {
|
||||
if (player != null && !this.plugin.getMVPerms().hasPermission(player, "multiverse.core.spawn.other", true)) {
|
||||
sender.sendMessage("You don't have permission to teleport another player to spawn. (multiverse.core.spawn.other)");
|
||||
return;
|
||||
}
|
||||
Player target = this.plugin.getServer().getPlayer(args.get(0));
|
||||
if (target != null) {
|
||||
target.sendMessage("Teleporting to this world's spawn...");
|
||||
target.teleport(target.getWorld().getSpawnLocation());
|
||||
spawnAccurately(target);
|
||||
|
||||
if (player != null) {
|
||||
target.sendMessage("You were teleported by: " + ChatColor.YELLOW + player.getName());
|
||||
} else {
|
||||
@@ -51,16 +60,27 @@ public class SpawnCommand extends MultiverseCommand {
|
||||
sender.sendMessage(args.get(0) + " is not logged on right now!");
|
||||
}
|
||||
} else {
|
||||
if (player != null && !this.plugin.getPermissions().hasPermission(player, "multiverse.core.spawn.self", true)) {
|
||||
if (player != null && !this.plugin.getMVPerms().hasPermission(player, "multiverse.core.spawn.self", true)) {
|
||||
sender.sendMessage("You don't have permission to teleport yourself to spawn. (multiverse.core.spawn.self)");
|
||||
return;
|
||||
}
|
||||
if (player != null) {
|
||||
player.sendMessage("Teleporting to this world's spawn...");
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
spawnAccurately(player);
|
||||
} else {
|
||||
sender.sendMessage("From the console, you must provide a PLAYER.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnAccurately(Player player) {
|
||||
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(player.getWorld().getName());
|
||||
Location spawnLocation;
|
||||
if (world != null) {
|
||||
spawnLocation = world.getSpawnLocation();
|
||||
} else {
|
||||
spawnLocation = player.getWorld().getSpawnLocation();
|
||||
}
|
||||
this.plugin.getTeleporter().safelyTeleport(player, player, spawnLocation, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.getspout.spoutapi.gui.GenericButton;
|
||||
import org.getspout.spoutapi.gui.GenericPopup;
|
||||
import org.getspout.spoutapi.gui.PopupScreen;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SpoutCommand extends MultiverseCommand {
|
||||
|
||||
public SpoutCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Edit World with Spout");
|
||||
this.setCommandUsage("/mv spout");
|
||||
this.setArgRange(0, 0);
|
||||
this.addKey("mv spout");
|
||||
this.setPermission("multiverse.core.spout", "Edit a world with spout.", PermissionDefault.OP);
|
||||
this.addCommandExample("/mv spout");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command must be run as a player!");
|
||||
return;
|
||||
}
|
||||
if (plugin.getSpout() == null) {
|
||||
sender.sendMessage(ChatColor.RED + "You need spout installed on this server to use it with Multiverse!");
|
||||
return;
|
||||
}
|
||||
SpoutPlayer p = (SpoutPlayer) sender;
|
||||
if (!p.isSpoutCraftEnabled()) {
|
||||
sender.sendMessage(ChatColor.RED + p.getName() + "You need to be using the Spoutcraft client to run this command!");
|
||||
return;
|
||||
}
|
||||
PopupScreen pop = new GenericPopup();
|
||||
GenericButton button = new GenericButton("Fish");
|
||||
button.setX(50);
|
||||
button.setY(50);
|
||||
button.setWidth(100);
|
||||
button.setHeight(40);
|
||||
pop.attachWidget(this.plugin, button);
|
||||
sender.sendMessage(ChatColor.GREEN + "YAY!");
|
||||
p.getMainScreen().attachPopupScreen(pop);
|
||||
}
|
||||
}
|
||||
@@ -1,44 +1,53 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.DestinationFactory;
|
||||
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.WorldDestination;
|
||||
import com.onarandombox.MultiverseCore.event.MVTeleportEvent;
|
||||
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
|
||||
import com.onarandombox.MultiverseCore.utils.MVMessaging;
|
||||
import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVTeleport;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.MVDestination;
|
||||
import com.onarandombox.utils.DestinationFactory;
|
||||
import com.onarandombox.utils.InvalidDestination;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class TeleportCommand extends MultiverseCommand {
|
||||
private MVTeleport playerTeleporter;
|
||||
private SafeTTeleporter playerTeleporter;
|
||||
|
||||
public TeleportCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
Permission self = new Permission("multiverse.core.tp.self", "Allows you to teleport yourself to other worlds.", PermissionDefault.OP);
|
||||
Permission other = new Permission("multiverse.core.tp.other", "Allows you to teleport others to other worlds.", PermissionDefault.OP);
|
||||
Permission menu = new Permission("multiverse.teleport.*", "Allows you to display the teleport menu.", PermissionDefault.OP);
|
||||
|
||||
this.setName("Teleport");
|
||||
this.setCommandUsage("/mv tp " + ChatColor.GOLD + "[PLAYER]" + ChatColor.GREEN + " {WORLD}");
|
||||
this.setArgRange(1, 2);
|
||||
this.addKey("mvtp");
|
||||
this.addKey("mv tp");
|
||||
this.playerTeleporter = new MVTeleport(this.plugin);
|
||||
// setPermission in some for is REQUIRED
|
||||
this.setPermission(self);
|
||||
this.addAdditonalPermission(other);
|
||||
this.playerTeleporter = new SafeTTeleporter(this.plugin);
|
||||
this.setPermission(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
// Check if the command was sent from a Player.
|
||||
Player teleporter = null;
|
||||
CommandSender teleporter = sender;
|
||||
Player teleportee = null;
|
||||
if (sender instanceof Player) {
|
||||
teleporter = (Player) sender;
|
||||
@@ -47,10 +56,6 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
String destinationName;
|
||||
|
||||
if (args.size() == 2) {
|
||||
if (teleporter != null && !this.plugin.getPermissions().hasPermission(sender, "multiverse.core.tp.other", true)) {
|
||||
sender.sendMessage("You don't have permission to teleport another player. (multiverse.core.tp.other)");
|
||||
return;
|
||||
}
|
||||
teleportee = this.plugin.getServer().getPlayer(args.get(0));
|
||||
if (teleportee == null) {
|
||||
sender.sendMessage("Sorry, I couldn't find player: " + args.get(0));
|
||||
@@ -60,51 +65,93 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
|
||||
} else {
|
||||
destinationName = args.get(0);
|
||||
if (teleporter != null && !this.plugin.getPermissions().hasPermission(sender, "multiverse.core.tp.self", true)) {
|
||||
sender.sendMessage("You don't have permission to teleport yourself between worlds. (multiverse.core.tp.self)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("From the console, you must specifiy a player to teleport");
|
||||
sender.sendMessage("From the console, you must specify a player to teleport");
|
||||
return;
|
||||
}
|
||||
teleporter = (Player) sender;
|
||||
teleportee = (Player) sender;
|
||||
}
|
||||
// Special case for cannons:
|
||||
if (destinationName.matches("(?i)cannon-[\\d]+(\\.[\\d]+)?")) {
|
||||
String[] cannonSpeed = destinationName.split("-");
|
||||
try {
|
||||
double speed = Double.parseDouble(cannonSpeed[1]);
|
||||
destinationName = "ca:" + teleportee.getWorld().getName() + ":" + teleportee.getLocation().getX() + "," + teleportee.getLocation().getY() + "," + teleportee.getLocation().getZ() + ":" + teleportee.getLocation().getPitch() + ":" + teleportee.getLocation().getYaw() + ":" + speed;
|
||||
} catch (Exception e) {
|
||||
destinationName = "i:invalid";
|
||||
}
|
||||
|
||||
DestinationFactory df = this.plugin.getDestinationFactory();// .parseDestination(worldName, (MultiverseCore) this.plugin);
|
||||
}
|
||||
DestinationFactory df = this.plugin.getDestFactory();
|
||||
MVDestination d = df.getDestination(destinationName);
|
||||
|
||||
|
||||
MVTeleportEvent teleportEvent = new MVTeleportEvent(d, teleportee, teleporter, true);
|
||||
this.plugin.getServer().getPluginManager().callEvent(teleportEvent);
|
||||
if (teleportEvent.isCancelled()) {
|
||||
this.plugin.log(Level.FINE, "Someone else cancelled the MVTeleport Event!!!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (d != null && d instanceof InvalidDestination) {
|
||||
sender.sendMessage("Multiverse does not know how to take you to: " + ChatColor.RED + destinationName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (teleporter != null && !this.plugin.getPermissions().canEnterDestination(teleporter, d)) {
|
||||
if (!this.checkSendPermissions(teleporter, teleportee, d)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (MultiverseCore.EnforceAccess && teleporter != null && !this.plugin.getMVPerms().canEnterDestination(teleporter, d)) {
|
||||
if (teleportee.equals(teleporter)) {
|
||||
teleporter.sendMessage("Doesn't look like you're allowed to go " + ChatColor.RED + "there...");
|
||||
} else {
|
||||
teleporter.sendMessage("Doesn't look like you're allowed to send " + ChatColor.GOLD + teleportee.getName() + ChatColor.WHITE + " to " + ChatColor.RED + "there...");
|
||||
}
|
||||
return;
|
||||
} else if (teleporter != null && !this.plugin.getPermissions().canTravelFromLocation(teleporter, d.getLocation(teleportee))) {
|
||||
} else if (teleporter != null && !this.plugin.getMVPerms().canTravelFromLocation(teleporter, d.getLocation(teleportee))) {
|
||||
if (teleportee.equals(teleporter)) {
|
||||
teleporter.sendMessage("DOH! Doesn't look like you can get to " + ChatColor.RED + "THERE from " + ChatColor.GREEN + teleporter.getWorld().getName());
|
||||
teleporter.sendMessage("DOH! Doesn't look like you can get to " + ChatColor.RED + "THERE from " + ChatColor.GREEN + ((Player) teleporter).getWorld().getName());
|
||||
} else {
|
||||
teleporter.sendMessage("DOH! Doesn't look like " + ChatColor.GREEN + teleporter.getWorld().getName() + " can get to " + ChatColor.RED + "THERE from where they are...");
|
||||
teleporter.sendMessage("DOH! Doesn't look like " + ChatColor.GREEN + ((Player) teleporter).getWorld().getName() + " can get to " + ChatColor.RED + "THERE from where they are...");
|
||||
}
|
||||
return;
|
||||
}
|
||||
Location l = d.getLocation(teleportee);
|
||||
if (l == null) {
|
||||
|
||||
// Special check to verify if players are tryint to teleport to the same
|
||||
// WORLDDestination as the world they're in, that they ALSO have multiverse.core.spawn.self
|
||||
|
||||
if (d instanceof WorldDestination) {
|
||||
World w = d.getLocation(teleportee).getWorld();
|
||||
if (teleportee.getWorld().equals(w)) {
|
||||
if (teleporter.equals(teleportee)) {
|
||||
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.core.spawn.self", true)) {
|
||||
teleporter.sendMessage("Sorry you don't have permission to go to the world spawn!");
|
||||
teleporter.sendMessage(ChatColor.RED + " (multiverse.core.spawn.self)");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.core.spawn.other", true)) {
|
||||
teleporter.sendMessage("Sorry you don't have permission to send " + teleportee.getDisplayName() + "to the world spawn!");
|
||||
teleporter.sendMessage(ChatColor.RED + " (multiverse.core.spawn.other)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (d.getLocation(teleportee) == null) {
|
||||
teleporter.sendMessage("Sorry Boss, I tried everything, but just couldn't teleport ya there!");
|
||||
return;
|
||||
}
|
||||
if (!this.playerTeleporter.safelyTeleport(teleportee, l)) {
|
||||
Class<?> paramTypes[] = { Player.class, Location.class };
|
||||
if (!this.playerTeleporter.safelyTeleport(teleporter, teleportee, d)) {
|
||||
this.plugin.log(Level.FINE, "Could not teleport " + teleportee.getName() + " to " + LocationManipulation.strCoordsRaw(d.getLocation(teleportee)));
|
||||
this.plugin.log(Level.FINE, "Queueing Command");
|
||||
Class<?> paramTypes[] = {CommandSender.class, Player.class, Location.class};
|
||||
List<Object> items = new ArrayList<Object>();
|
||||
items.add(teleporter);
|
||||
items.add(teleportee);
|
||||
items.add(l);
|
||||
items.add(d.getLocation(teleportee));
|
||||
String player = "you";
|
||||
if (!teleportee.equals(teleporter)) {
|
||||
player = teleportee.getName();
|
||||
@@ -112,7 +159,24 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
String message = ChatColor.GREEN + "Multiverse" + ChatColor.WHITE + " did not teleport " + ChatColor.AQUA + player + ChatColor.WHITE + " to " + ChatColor.DARK_AQUA + d.getName() + ChatColor.WHITE + " because it was unsafe.";
|
||||
this.plugin.getCommandHandler().queueCommand(sender, "mvteleport", "teleportPlayer", items, paramTypes, message, "Would you like to try anyway?", "", "", 15);
|
||||
} else {
|
||||
teleportee.setVelocity(d.getVelocity());
|
||||
// Player was teleported successfully (or the tp event was fired I should say);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkSendPermissions(CommandSender teleporter, Player teleportee, MVDestination destination) {
|
||||
MVMessaging message = this.plugin.getMessaging();
|
||||
if (teleporter.equals(teleportee)) {
|
||||
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.teleport.self." + destination.getIdentifier(), true)) {
|
||||
message.sendMessages(teleporter, new String[]{"You don't have permission to teleport yourself to a " + ChatColor.GREEN + destination.getType() + " Destination.", ChatColor.RED + " (multiverse.teleport.self." + destination.getIdentifier() + ")"});
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.teleport.other." + destination.getIdentifier(), true)) {
|
||||
message.sendMessages(teleporter, new String[]{"You don't have permission to teleport another player to a " + ChatColor.GREEN + destination.getType() + " Destination.", ChatColor.RED + " (multiverse.teleport.other." + destination.getIdentifier() + ")"});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,18 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.List;
|
||||
|
||||
public class UnloadCommand extends MultiverseCommand {
|
||||
|
||||
@@ -22,7 +28,7 @@ public class UnloadCommand extends MultiverseCommand {
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
if (this.plugin.removeWorldFromList(args.get(0))) {
|
||||
if (this.plugin.getMVWorldManager().unloadWorld(args.get(0))) {
|
||||
sender.sendMessage("World Unloaded!");
|
||||
} else {
|
||||
sender.sendMessage("Error trying to unload world!");
|
||||
|
||||
@@ -1,22 +1,31 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.event.MVVersionRequestEvent;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.event.MVVersionRequestEvent;
|
||||
|
||||
public class VersionCommand extends MultiverseCommand {
|
||||
|
||||
public VersionCommand(MultiverseCore plugin) {
|
||||
@@ -41,23 +50,24 @@ public class VersionCommand extends MultiverseCommand {
|
||||
|
||||
logAndAddToPasteBinBuffer("Multiverse-Core Version: " + this.plugin.getDescription().getVersion());
|
||||
logAndAddToPasteBinBuffer("Bukkit Version: " + this.plugin.getServer().getVersion());
|
||||
logAndAddToPasteBinBuffer("Loaded Worlds: " + this.plugin.getMVWorlds().size());
|
||||
logAndAddToPasteBinBuffer("Loaded Worlds: " + this.plugin.getMVWorldManager().getMVWorlds().size());
|
||||
logAndAddToPasteBinBuffer("Multiverse Plugins Loaded: " + this.plugin.getPluginCount());
|
||||
logAndAddToPasteBinBuffer("Economy being used: " + this.plugin.getBank().getEconUsed());
|
||||
logAndAddToPasteBinBuffer("Permissions Plugin: " + this.plugin.getPermissions().getType());
|
||||
logAndAddToPasteBinBuffer("Dumping Config Values: (version " + this.plugin.getConfig().getString("version", "NOT SET") + ")");
|
||||
logAndAddToPasteBinBuffer("messagecooldown: " + this.plugin.getConfig().getString("messagecooldown", "NOT SET"));
|
||||
logAndAddToPasteBinBuffer("teleportcooldown: " + this.plugin.getConfig().getString("teleportcooldown", "NOT SET"));
|
||||
logAndAddToPasteBinBuffer("worldnameprefix: " + this.plugin.getConfig().getString("worldnameprefix", "NOT SET"));
|
||||
logAndAddToPasteBinBuffer("opfallback: " + this.plugin.getConfig().getString("opfallback", "NOT SET"));
|
||||
logAndAddToPasteBinBuffer("disableautoheal: " + this.plugin.getConfig().getString("disableautoheal", "NOT SET"));
|
||||
logAndAddToPasteBinBuffer("fakepvp: " + this.plugin.getConfig().getString("fakepvp", "NOT SET"));
|
||||
logAndAddToPasteBinBuffer("Special Code: FRN001");
|
||||
|
||||
logAndAddToPasteBinBuffer("Permissions Plugin: " + this.plugin.getMVPerms().getType());
|
||||
logAndAddToPasteBinBuffer("Dumping Config Values: (version " + this.plugin.getMVConfiguration().getString("version", "NOT SET") + ")");
|
||||
logAndAddToPasteBinBuffer("messagecooldown: " + "Not yet IMPLEMENTED");
|
||||
logAndAddToPasteBinBuffer("teleportcooldown: " + "Not yet IMPLEMENTED");
|
||||
logAndAddToPasteBinBuffer("worldnameprefix: " + MultiverseCore.PrefixChat);
|
||||
logAndAddToPasteBinBuffer("enforceaccess: " + MultiverseCore.EnforceAccess);
|
||||
logAndAddToPasteBinBuffer("enforcegamemodes: " + MultiverseCore.EnforceGameModes);
|
||||
logAndAddToPasteBinBuffer("bedrespawn: " + MultiverseCore.BedRespawn);
|
||||
logAndAddToPasteBinBuffer("debug: " + MultiverseCore.GlobalDebug);
|
||||
logAndAddToPasteBinBuffer("Special Code: FRN002");
|
||||
|
||||
MVVersionRequestEvent versionEvent = new MVVersionRequestEvent(pasteBinBuffer);
|
||||
this.plugin.getServer().getPluginManager().callEvent(versionEvent);
|
||||
pasteBinBuffer = versionEvent.getPasteBinBuffer();
|
||||
|
||||
|
||||
if (args.size() == 1 && args.get(0).equalsIgnoreCase("-p")) {
|
||||
String pasteBinUrl = postToPasteBin();
|
||||
sender.sendMessage("Version info dumped here: " + ChatColor.GREEN + pasteBinUrl);
|
||||
@@ -72,10 +82,15 @@ public class VersionCommand extends MultiverseCommand {
|
||||
|
||||
private String postToPasteBin() {
|
||||
try {
|
||||
String data = URLEncoder.encode("api_dev_key", "UTF-8") + "=" + URLEncoder.encode("33ab32380506d99d872b69d35dc9d007", "UTF-8");
|
||||
String data = URLEncoder.encode("api_dev_key", "UTF-8") + "=" + URLEncoder.encode("d61d68d31e8e0392b59b50b277411c71", "UTF-8");
|
||||
data += "&" + URLEncoder.encode("api_option", "UTF-8") + "=" + URLEncoder.encode("paste", "UTF-8");
|
||||
data += "&" + URLEncoder.encode("api_paste_code", "UTF-8") + "=" + URLEncoder.encode(this.pasteBinBuffer, "UTF-8");
|
||||
|
||||
data += "&" + URLEncoder.encode("api_paste_private", "UTF-8") + "=" + URLEncoder.encode("1", "UTF-8");
|
||||
data += "&" + URLEncoder.encode("api_paste_format", "UTF-8") + "=" + URLEncoder.encode("yaml", "UTF-8");
|
||||
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
||||
Date date = new Date();
|
||||
data += "&" + URLEncoder.encode("api_paste_name", "UTF-8") + "=" + URLEncoder.encode("Multiverse 2 Dump " + dateFormat.format(date), "UTF-8");
|
||||
data += "&" + URLEncoder.encode("api_user_key", "UTF-8") + "=" + URLEncoder.encode("c052ac52d2b0db88d36cc32ca462d151", "UTF-8");
|
||||
URL url = new URL("http://pastebin.com/api/api_post.php");
|
||||
URLConnection conn = url.openConnection();
|
||||
conn.setDoOutput(true);
|
||||
|
||||
@@ -1,18 +1,27 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WhoCommand extends MultiverseCommand {
|
||||
|
||||
private WorldManager worldManager;
|
||||
|
||||
public WhoCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Who?");
|
||||
@@ -22,6 +31,7 @@ public class WhoCommand extends MultiverseCommand {
|
||||
this.addKey("mvw");
|
||||
this.addKey("mvwho");
|
||||
this.setPermission("multiverse.core.list.who", "States who is in what world.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -35,36 +45,39 @@ public class WhoCommand extends MultiverseCommand {
|
||||
showAll = false;
|
||||
}
|
||||
|
||||
List<MVWorld> worlds = new ArrayList<MVWorld>();
|
||||
List<MultiverseWorld> worlds = new ArrayList<MultiverseWorld>();
|
||||
|
||||
if (args.size() > 0) {
|
||||
MultiverseWorld world = this.worldManager.getMVWorld(args.get(0));
|
||||
if (args.get(0).equalsIgnoreCase("--all") || args.get(0).equalsIgnoreCase("-a")) {
|
||||
showAll = true;
|
||||
worlds = new ArrayList<MVWorld>(this.plugin.getMVWorlds());
|
||||
} else if (this.plugin.isMVWorld(args.get(0))) {
|
||||
worlds.add(this.plugin.getMVWorld(args.get(0)));
|
||||
worlds = new ArrayList<MultiverseWorld>(this.worldManager.getMVWorlds());
|
||||
} else if (world != null) {
|
||||
if (!world.isHidden()) {
|
||||
worlds.add(world);
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "World does not exist");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
worlds = new ArrayList<MVWorld>(this.plugin.getMVWorlds());
|
||||
worlds = new ArrayList<MultiverseWorld>(this.worldManager.getMVWorlds());
|
||||
}
|
||||
|
||||
if (worlds.size() == 0) {
|
||||
sender.sendMessage("Multiverse does not know about any of your worlds :(");
|
||||
} else if (worlds.size() == 1) {
|
||||
sender.sendMessage(ChatColor.AQUA + "--- " + "Players in" + ChatColor.YELLOW + worlds.get(0) + ChatColor.AQUA + " ---");
|
||||
sender.sendMessage(ChatColor.AQUA + "--- Players in" + worlds.get(0).getColoredWorldString() + ChatColor.AQUA + " ---");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.AQUA + "--- There are players in ---");
|
||||
}
|
||||
|
||||
for (MVWorld world : worlds) {
|
||||
if (!(this.plugin.isMVWorld(world.getName()))) {
|
||||
for (MultiverseWorld world : worlds) {
|
||||
if (!(this.worldManager.isMVWorld(world.getName()))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (p != null && (!this.plugin.getPermissions().canEnterWorld(p, world))) {
|
||||
if (p != null && (!this.plugin.getMVPerms().canEnterWorld(p, world))) {
|
||||
continue;
|
||||
}
|
||||
List<Player> players = world.getCBWorld().getPlayers();
|
||||
@@ -78,7 +91,7 @@ public class WhoCommand extends MultiverseCommand {
|
||||
result = "Empty";
|
||||
} else {
|
||||
for (Player player : players) {
|
||||
result += player.getName() + " ";
|
||||
result += player.getDisplayName() + " ";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.configuration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class DefaultConfig {
|
||||
|
||||
public DefaultConfig(File folder, String name, MVConfigMigrator migrator) {
|
||||
File actual = new File(folder, name);
|
||||
if (actual.exists() && migrator.createdDefaults.contains(name)) {
|
||||
actual.delete();
|
||||
}
|
||||
// If defaults have been created, and we're being called again, we should try to migrate
|
||||
if (!actual.exists() && !migrator.migrate(name, folder)) {
|
||||
|
||||
InputStream defConfig = this.getClass().getResourceAsStream("/defaults/" + name);
|
||||
if (defConfig != null) {
|
||||
FileOutputStream newConfig = null;
|
||||
|
||||
try {
|
||||
newConfig = new FileOutputStream(actual);
|
||||
byte[] buf = new byte[8192];
|
||||
int length = 0;
|
||||
|
||||
while ((length = defConfig.read(buf)) > 0) {
|
||||
newConfig.write(buf, 0, length);
|
||||
}
|
||||
migrator.createdDefaults.add(name);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (defConfig != null)
|
||||
defConfig.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
try {
|
||||
if (newConfig != null)
|
||||
newConfig.close();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,25 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.configuration;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.LoggablePlugin;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
import com.onarandombox.MultiverseCore.LoggablePlugin;
|
||||
|
||||
public abstract class MVConfigMigrator {
|
||||
public List<String> createdDefaults = new ArrayList<String>();
|
||||
|
||||
public abstract boolean migrate(String name, File folder);
|
||||
|
||||
protected final void migrateListItem(Configuration newConfig, Configuration oldConfig, String key, String oldProperty, String newProperty) {
|
||||
@@ -24,7 +31,7 @@ public abstract class MVConfigMigrator {
|
||||
}
|
||||
newConfig.setProperty("worlds." + key + newProperty, list);
|
||||
}
|
||||
|
||||
|
||||
protected final File detectMultiverseFolders(File folder, LoggablePlugin mvPlugin) {
|
||||
File oldFolder = null;
|
||||
mvPlugin.log(Level.INFO, "Starting Multiverse Configuration Migrator(MVCM)!");
|
||||
|
||||
+10
-4
@@ -1,13 +1,19 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.configuration;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
public class MVCoreConfigMigrator extends MVConfigMigrator {
|
||||
private MultiverseCore core;
|
||||
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.destination;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
/**
|
||||
* Multiverse 2
|
||||
*
|
||||
* @author fernferret
|
||||
*/
|
||||
public class BedDestination implements MVDestination {
|
||||
|
||||
private boolean isValid;
|
||||
private Location knownBedLoc;
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "b";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isThisType(JavaPlugin plugin, String destination) {
|
||||
String[] split = destination.split(":");
|
||||
this.isValid = split.length >= 1 && split.length <= 2 && split[0].equals(this.getIdentifier());
|
||||
return this.isValid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation(Entity entity) {
|
||||
if (entity instanceof Player) {
|
||||
this.knownBedLoc = ((Player) entity).getBedSpawnLocation();
|
||||
return this.knownBedLoc;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getVelocity() {
|
||||
return new Vector();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDestination(JavaPlugin plugin, String destination) {
|
||||
// Not needed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return this.isValid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "Bed";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Bed";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequiredPermission() {
|
||||
if (knownBedLoc != null) {
|
||||
return "multiverse.access." + knownBedLoc.getWorld().getName();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useSafeTeleporter() {
|
||||
// Bukkit should have already checked this.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "b:playerbed";
|
||||
}
|
||||
}
|
||||
+23
-11
@@ -1,14 +1,21 @@
|
||||
package com.onarandombox.utils;
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
package com.onarandombox.MultiverseCore.destination;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CannonDestination implements MVDestination {
|
||||
private final String coordRegex = "(-?[\\d]+\\.?[\\d]*),(-?[\\d]+\\.?[\\d]*),(-?[\\d]+\\.?[\\d]*)";
|
||||
@@ -29,7 +36,7 @@ public class CannonDestination implements MVDestination {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifer() {
|
||||
public String getIdentifier() {
|
||||
return "ca";
|
||||
}
|
||||
|
||||
@@ -50,7 +57,7 @@ public class CannonDestination implements MVDestination {
|
||||
}
|
||||
|
||||
// If it's not a MV world
|
||||
if (!((MultiverseCore) plugin).isMVWorld(parsed.get(1))) {
|
||||
if (!((MultiverseCore) plugin).getMVWorldManager().isMVWorld(parsed.get(1))) {
|
||||
return false;
|
||||
}
|
||||
// Verify X,Y,Z are numbers
|
||||
@@ -79,11 +86,11 @@ public class CannonDestination implements MVDestination {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDestination(JavaPlugin plugin, String dest) {
|
||||
public void setDestination(JavaPlugin plugin, String destination) {
|
||||
if (!(plugin instanceof MultiverseCore)) {
|
||||
return;
|
||||
}
|
||||
List<String> parsed = Arrays.asList(dest.split(":"));
|
||||
List<String> parsed = Arrays.asList(destination.split(":"));
|
||||
// Need at least: e:world:x,y,z
|
||||
// OR e:world:x,y,z:pitch:yaw
|
||||
// so basically 3 or 5
|
||||
@@ -91,17 +98,17 @@ public class CannonDestination implements MVDestination {
|
||||
this.isValid = false;
|
||||
return;
|
||||
}
|
||||
if (!parsed.get(0).equalsIgnoreCase(this.getIdentifer())) {
|
||||
if (!parsed.get(0).equalsIgnoreCase(this.getIdentifier())) {
|
||||
this.isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!((MultiverseCore) plugin).isMVWorld(parsed.get(1))) {
|
||||
if (!((MultiverseCore) plugin).getMVWorldManager().isMVWorld(parsed.get(1))) {
|
||||
this.isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this.location = new Location(((MultiverseCore) plugin).getMVWorld(parsed.get(1)).getCBWorld(), 0, 0, 0);
|
||||
this.location = new Location(((MultiverseCore) plugin).getMVWorldManager().getMVWorld(parsed.get(1)).getCBWorld(), 0, 0, 0);
|
||||
|
||||
if (!parsed.get(2).matches(this.coordRegex)) {
|
||||
this.isValid = false;
|
||||
@@ -167,4 +174,9 @@ public class CannonDestination implements MVDestination {
|
||||
public String getRequiredPermission() {
|
||||
return "multiverse.access." + this.location.getWorld().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useSafeTeleporter() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.destination;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.commands.TeleportCommand;
|
||||
import com.onarandombox.MultiverseCore.utils.PermissionTools;
|
||||
import com.pneumaticraft.commandhandler.Command;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/** A factory class that will create destinations from specific strings. */
|
||||
public class DestinationFactory {
|
||||
private MultiverseCore plugin;
|
||||
private Map<String, Class<? extends MVDestination>> destList;
|
||||
private Command teleportCommand;
|
||||
|
||||
public DestinationFactory(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
this.destList = new HashMap<String, Class<? extends MVDestination>>();
|
||||
List<Command> cmds = this.plugin.getCommandHandler().getAllCommands();
|
||||
for (Command c : cmds) {
|
||||
if (c instanceof TeleportCommand) {
|
||||
this.teleportCommand = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a new destination from a string.
|
||||
* Returns a new InvalidDestination if the string could not be parsed.
|
||||
*
|
||||
* @param destination The destination in string format.
|
||||
*
|
||||
* @return A non-null MVDestination
|
||||
*/
|
||||
public MVDestination getDestination(String destination) {
|
||||
String idenChar = "";
|
||||
if (destination.split(":").length > 1) {
|
||||
idenChar = destination.split(":")[0];
|
||||
}
|
||||
|
||||
if (this.destList.containsKey(idenChar)) {
|
||||
Class<? extends MVDestination> myClass = this.destList.get(idenChar);
|
||||
try {
|
||||
MVDestination mydest = myClass.newInstance();
|
||||
if (!mydest.isThisType((MultiverseCore) this.plugin, destination)) {
|
||||
return new InvalidDestination();
|
||||
}
|
||||
mydest.setDestination(this.plugin, destination);
|
||||
return mydest;
|
||||
} catch (InstantiationException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
}
|
||||
}
|
||||
return new InvalidDestination();
|
||||
}
|
||||
|
||||
public boolean registerDestinationType(Class<? extends MVDestination> c, String identifier) {
|
||||
if (this.destList.containsKey(identifier)) {
|
||||
return false;
|
||||
}
|
||||
this.destList.put(identifier, c);
|
||||
// Special case for world defaults:
|
||||
if (identifier.equals("")) {
|
||||
identifier = "w";
|
||||
}
|
||||
Permission self = this.plugin.getServer().getPluginManager().getPermission("multiverse.teleport.self." + identifier);
|
||||
Permission other = this.plugin.getServer().getPluginManager().getPermission("multiverse.teleport.other." + identifier);
|
||||
PermissionTools pt = new PermissionTools(this.plugin);
|
||||
if (self == null) {
|
||||
self = new Permission("multiverse.teleport.self." + identifier, "Permission to teleport yourself for the " + identifier + " destination.", PermissionDefault.OP);
|
||||
this.plugin.getServer().getPluginManager().addPermission(self);
|
||||
pt.addToParentPerms("multiverse.teleport.self." + identifier);
|
||||
}
|
||||
if (other == null) {
|
||||
other = new Permission("multiverse.teleport.other." + identifier, "Permission to teleport others for the " + identifier + " destination.", PermissionDefault.OP);
|
||||
this.plugin.getServer().getPluginManager().addPermission(other);
|
||||
pt.addToParentPerms("multiverse.teleport.other." + identifier);
|
||||
}
|
||||
this.teleportCommand.addAdditonalPermission(self);
|
||||
this.teleportCommand.addAdditonalPermission(other);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+26
-13
@@ -1,14 +1,21 @@
|
||||
package com.onarandombox.utils;
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
package com.onarandombox.MultiverseCore.destination;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ExactDestination implements MVDestination {
|
||||
private final String coordRegex = "(-?[\\d]+\\.?[\\d]*),(-?[\\d]+\\.?[\\d]*),(-?[\\d]+\\.?[\\d]*)";
|
||||
@@ -16,12 +23,12 @@ public class ExactDestination implements MVDestination {
|
||||
private Location location;
|
||||
|
||||
@Override
|
||||
public String getIdentifer() {
|
||||
public String getIdentifier() {
|
||||
return "e";
|
||||
}
|
||||
|
||||
|
||||
public Vector getVelocity() {
|
||||
return new Vector(0,0,0);
|
||||
return new Vector(0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -42,7 +49,7 @@ public class ExactDestination implements MVDestination {
|
||||
}
|
||||
|
||||
// If it's not a MV world
|
||||
if (!((MultiverseCore) plugin).isMVWorld(parsed.get(1))) {
|
||||
if (!((MultiverseCore) plugin).getMVWorldManager().isMVWorld(parsed.get(1))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -74,11 +81,11 @@ public class ExactDestination implements MVDestination {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDestination(JavaPlugin plugin, String dest) {
|
||||
public void setDestination(JavaPlugin plugin, String destination) {
|
||||
if (!(plugin instanceof MultiverseCore)) {
|
||||
return;
|
||||
}
|
||||
List<String> parsed = Arrays.asList(dest.split(":"));
|
||||
List<String> parsed = Arrays.asList(destination.split(":"));
|
||||
// Need at least: e:world:x,y,z
|
||||
// OR e:world:x,y,z:pitch:yaw
|
||||
// so basically 3 or 5
|
||||
@@ -87,16 +94,16 @@ public class ExactDestination implements MVDestination {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!parsed.get(0).equalsIgnoreCase(this.getIdentifer())) {
|
||||
if (!parsed.get(0).equalsIgnoreCase(this.getIdentifier())) {
|
||||
this.isValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!((MultiverseCore) plugin).isMVWorld(parsed.get(1))) {
|
||||
if (!((MultiverseCore) plugin).getMVWorldManager().isMVWorld(parsed.get(1))) {
|
||||
this.isValid = false;
|
||||
return;
|
||||
}
|
||||
this.location = new Location(((MultiverseCore) plugin).getMVWorld(parsed.get(1)).getCBWorld(), 0, 0, 0);
|
||||
this.location = new Location(((MultiverseCore) plugin).getMVWorldManager().getMVWorld(parsed.get(1)).getCBWorld(), 0, 0, 0);
|
||||
|
||||
if (!parsed.get(2).matches(this.coordRegex)) {
|
||||
this.isValid = false;
|
||||
@@ -162,4 +169,10 @@ public class ExactDestination implements MVDestination {
|
||||
public String getRequiredPermission() {
|
||||
return "multiverse.access." + this.location.getWorld().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useSafeTeleporter() {
|
||||
// This is an EXACT destination, don't safely teleport here.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.destination;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class InvalidDestination implements MVDestination {
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "i";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isThisType(JavaPlugin plugin, String destination) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation(Entity e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDestination(JavaPlugin plugin, String destination) {
|
||||
// Nothing needed, it's invalid.
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return ChatColor.RED + "Invalid Destination";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return ChatColor.RED + "Invalid Destination";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "i:Invalid Destination";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequiredPermission() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Vector getVelocity() {
|
||||
return new Vector(0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useSafeTeleporter() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+21
-7
@@ -1,5 +1,13 @@
|
||||
package com.onarandombox.utils;
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.destination;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -12,13 +20,13 @@ public class PlayerDestination implements MVDestination {
|
||||
private JavaPlugin plugin;
|
||||
|
||||
@Override
|
||||
public String getIdentifer() {
|
||||
public String getIdentifier() {
|
||||
return "pl";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isThisType(JavaPlugin plugin, String dest) {
|
||||
String[] items = dest.split(":");
|
||||
public boolean isThisType(JavaPlugin plugin, String destination) {
|
||||
String[] items = destination.split(":");
|
||||
if (items.length != 2) {
|
||||
return false;
|
||||
}
|
||||
@@ -50,8 +58,8 @@ public class PlayerDestination implements MVDestination {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDestination(JavaPlugin plugin, String dest) {
|
||||
String[] items = dest.split(":");
|
||||
public void setDestination(JavaPlugin plugin, String destination) {
|
||||
String[] items = destination.split(":");
|
||||
if (items.length != 2) {
|
||||
this.isValid = false;
|
||||
}
|
||||
@@ -82,8 +90,14 @@ public class PlayerDestination implements MVDestination {
|
||||
public String getRequiredPermission() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public Vector getVelocity() {
|
||||
return new Vector(0,0,0);
|
||||
return new Vector(0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useSafeTeleporter() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.destination;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class WorldDestination implements MVDestination {
|
||||
private boolean isValid;
|
||||
private MultiverseWorld world;
|
||||
float yaw = -1;
|
||||
String direction = "";
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "w";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isThisType(JavaPlugin plugin, String destination) {
|
||||
String[] items = destination.split(":");
|
||||
if (items.length > 3) {
|
||||
return false;
|
||||
}
|
||||
if (items.length == 1 && ((MultiverseCore) plugin).getMVWorldManager().isMVWorld(items[0])) {
|
||||
// This case is: world
|
||||
return true;
|
||||
}
|
||||
if (items.length == 2 && ((MultiverseCore) plugin).getMVWorldManager().isMVWorld(items[0])) {
|
||||
// This case is: world:n
|
||||
return true;
|
||||
} else if (items[0].equalsIgnoreCase("w") && ((MultiverseCore) plugin).getMVWorldManager().isMVWorld(items[1])) {
|
||||
// This case is: w:world
|
||||
// and w:world:ne
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation(Entity e) {
|
||||
Location spawnLoc = getAcurateSpawnLocation(e, this.world);
|
||||
if (this.yaw >= 0) {
|
||||
// Only modify the yaw if its set.
|
||||
spawnLoc.setYaw(this.yaw);
|
||||
}
|
||||
return spawnLoc;
|
||||
}
|
||||
|
||||
private Location getAcurateSpawnLocation(Entity e, MultiverseWorld world) {
|
||||
if (world != null) {
|
||||
return world.getSpawnLocation();
|
||||
} else {
|
||||
return e.getWorld().getSpawnLocation().add(.5, 0, .5);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return this.isValid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDestination(JavaPlugin plugin, String destination) {
|
||||
String[] items = destination.split(":");
|
||||
if (items.length > 3) {
|
||||
isValid = false;
|
||||
return;
|
||||
}
|
||||
if (items.length == 1 && ((MultiverseCore) plugin).getMVWorldManager().isMVWorld(items[0])) {
|
||||
isValid = true;
|
||||
this.world = ((MultiverseCore) plugin).getMVWorldManager().getMVWorld(items[0]);
|
||||
return;
|
||||
}
|
||||
if (items.length == 2 && ((MultiverseCore) plugin).getMVWorldManager().isMVWorld(items[0])) {
|
||||
this.world = ((MultiverseCore) plugin).getMVWorldManager().getMVWorld(items[0]);
|
||||
this.yaw = LocationManipulation.getYaw(items[1]);
|
||||
return;
|
||||
}
|
||||
if (items[0].equalsIgnoreCase("w") && ((MultiverseCore) plugin).getMVWorldManager().isMVWorld(items[1])) {
|
||||
this.world = ((MultiverseCore) plugin).getMVWorldManager().getMVWorld(items[1]);
|
||||
isValid = true;
|
||||
if (items.length == 3) {
|
||||
this.yaw = LocationManipulation.getYaw(items[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "World";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.world.getColoredWorldString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (direction.length() > 0 && yaw >= 0) {
|
||||
return this.world.getCBWorld().getName() + ":" + this.direction;
|
||||
}
|
||||
return this.world.getCBWorld().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequiredPermission() {
|
||||
// TODO: Potenitally replace spaces wiht tabs for friendlier yaml.
|
||||
// this.world.getName().replace(" ","_");
|
||||
return "multiverse.access." + this.world.getName();
|
||||
}
|
||||
|
||||
public Vector getVelocity() {
|
||||
return new Vector(0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useSafeTeleporter() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.enums;
|
||||
|
||||
/**
|
||||
* Multiverse 2
|
||||
*
|
||||
* @author fernferret
|
||||
*/
|
||||
public enum Action {
|
||||
Set, Add, Remove, Clear
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.enums;
|
||||
|
||||
/**
|
||||
* Multiverse 2
|
||||
*
|
||||
* @author fernferret
|
||||
*/
|
||||
public enum AddProperties {
|
||||
worldblacklist, animals, monsters
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.enums;
|
||||
|
||||
/** Multiverse 2 */
|
||||
public enum ConfigProperty {
|
||||
messagecooldown, teleportcooldown, worldnameprefix, bedrespawn, enforcegamemodes, enforceaccess, debug;
|
||||
|
||||
|
||||
public static String getAllValues() {
|
||||
String buffer = "";
|
||||
for (ConfigProperty c : ConfigProperty.values()) {
|
||||
// All values will NOT Contain spaces.
|
||||
buffer += c.toString() + " ";
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.enums;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
/**
|
||||
* Multiverse 2
|
||||
*
|
||||
* @author fernferret
|
||||
*/
|
||||
public enum EnglishChatColor {
|
||||
AQUA("AQUA", ChatColor.AQUA),
|
||||
BLACK("BLACK", ChatColor.BLACK),
|
||||
BLUE("BLUE", ChatColor.BLUE),
|
||||
DARKAQUA("DARKAQUA", ChatColor.DARK_AQUA),
|
||||
DARKBLUE("DARKBLUE", ChatColor.DARK_BLUE),
|
||||
DARKGRAY("DARKGRAY", ChatColor.DARK_GRAY),
|
||||
DARKGREEN("DARKGREEN", ChatColor.DARK_GREEN),
|
||||
DARKPURPLE("DARKPURPLE", ChatColor.DARK_PURPLE),
|
||||
DARKRED("DARKRED", ChatColor.DARK_RED),
|
||||
GOLD("GOLD", ChatColor.GOLD),
|
||||
GRAY("GRAY", ChatColor.GRAY),
|
||||
GREEN("GREEN", ChatColor.GREEN),
|
||||
LIGHTPURPLE("LIGHTPURPLE", ChatColor.LIGHT_PURPLE),
|
||||
RED("RED", ChatColor.RED),
|
||||
YELLOW("YELLOW", ChatColor.YELLOW),
|
||||
WHITE("WHITE", ChatColor.WHITE);
|
||||
private ChatColor color;
|
||||
private String text;
|
||||
|
||||
EnglishChatColor(String name, ChatColor color) {
|
||||
this.color = color;
|
||||
this.text = name;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public ChatColor getColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public static String getAllColors() {
|
||||
String buffer = "";
|
||||
for (EnglishChatColor c : EnglishChatColor.values()) {
|
||||
buffer += c.getColor() + c.getText() + " ";
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static EnglishChatColor fromString(String text) {
|
||||
if (text != null) {
|
||||
for (EnglishChatColor c : EnglishChatColor.values()) {
|
||||
if (text.equalsIgnoreCase(c.text)) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.enums;
|
||||
|
||||
/**
|
||||
* Multiverse 2
|
||||
*
|
||||
* @author fernferret
|
||||
*/ // Color == Aliascolor
|
||||
public enum SetProperties {
|
||||
alias, animals, monsters, pvp, scaling, aliascolor, color, respawn,
|
||||
currency, curr, price, scale, spawnmemory, memory, weather, storm,
|
||||
gamemode, mode, hunger, difficulty, diff, hidden, spawn
|
||||
}
|
||||
@@ -1,9 +1,16 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.event;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MVConfigMigrateEvent extends Event {
|
||||
private static final long serialVersionUID = 3647950355746345397L;
|
||||
private List<String> configsLoaded;
|
||||
@@ -12,11 +19,11 @@ public class MVConfigMigrateEvent extends Event {
|
||||
super("MVConfigMigrate");
|
||||
this.configsLoaded = configsLoaded;
|
||||
}
|
||||
|
||||
|
||||
public void addConfig(String config) {
|
||||
this.configsLoaded.add(config);
|
||||
}
|
||||
|
||||
|
||||
public List<String> getAllConfigsLoaded() {
|
||||
return this.configsLoaded;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.event;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MVConfigReloadEvent extends Event {
|
||||
private static final long serialVersionUID = 3647950355746345397L;
|
||||
private List<String> configsLoaded;
|
||||
@@ -12,11 +19,11 @@ public class MVConfigReloadEvent extends Event {
|
||||
super("MVConfigReload");
|
||||
this.configsLoaded = configsLoaded;
|
||||
}
|
||||
|
||||
|
||||
public void addConfig(String config) {
|
||||
this.configsLoaded.add(config);
|
||||
}
|
||||
|
||||
|
||||
public List<String> getAllConfigsLoaded() {
|
||||
return this.configsLoaded;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.event;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
@@ -1,33 +1,82 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.event;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
import com.onarandombox.utils.MVDestination;
|
||||
|
||||
public class MVTeleportEvent extends Event {
|
||||
private static final long serialVersionUID = 854826818438649269L;
|
||||
private Player player;
|
||||
/**
|
||||
* Event that gets called when a player use the /mvtp command
|
||||
*
|
||||
* @author fernferret
|
||||
*/
|
||||
public class MVTeleportEvent extends Event implements Cancellable {
|
||||
private Player teleportee;
|
||||
private CommandSender teleporter;
|
||||
private MVDestination dest;
|
||||
private String teleportString;
|
||||
private boolean useSafeTeleport;
|
||||
private boolean isCancelled;
|
||||
|
||||
|
||||
public MVTeleportEvent(MVDestination dest, Player p, String teleportString) {
|
||||
super("MVTeleport");
|
||||
this.player = p;
|
||||
public MVTeleportEvent(MVDestination dest, Player teleportee, CommandSender teleporter, boolean safeTeleport) {
|
||||
super("SafeTTeleporter");
|
||||
this.teleportee = teleportee;
|
||||
this.teleporter = teleporter;
|
||||
this.dest = dest;
|
||||
this.teleportString = teleportString;
|
||||
this.useSafeTeleport = safeTeleport;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
/**
|
||||
* Returns the player who will be teleported by this event.
|
||||
*
|
||||
* @return The player who will be teleported by this event.
|
||||
*/
|
||||
public Player getTeleportee() {
|
||||
return this.teleportee;
|
||||
}
|
||||
|
||||
public String getDestString() {
|
||||
return this.teleportString;
|
||||
/**
|
||||
* Returns the location the player was before the teleport.
|
||||
*
|
||||
* @return The location the player was before the teleport.
|
||||
*/
|
||||
public Location getFrom() {
|
||||
return this.teleportee.getLocation();
|
||||
}
|
||||
|
||||
public Class<? extends MVDestination> getDestType() {
|
||||
return this.dest.getClass();
|
||||
/**
|
||||
* Returns the player who requested the Teleport
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CommandSender getTeleporter() {
|
||||
return this.teleporter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the destination that the player will spawn at.
|
||||
*
|
||||
* @return The destination the player will spawn at.
|
||||
*/
|
||||
public MVDestination getDestination() {
|
||||
return this.dest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.isCancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.isCancelled = cancel;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,10 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.event;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
@@ -5,6 +12,7 @@ import org.bukkit.event.Event;
|
||||
public class MVVersionRequestEvent extends Event {
|
||||
|
||||
private String pasteBinBuffer;
|
||||
|
||||
public MVVersionRequestEvent(String pasteBinBuffer) {
|
||||
super("MVVersion");
|
||||
this.pasteBinBuffer = pasteBinBuffer;
|
||||
@@ -13,6 +21,7 @@ public class MVVersionRequestEvent extends Event {
|
||||
public String getPasteBinBuffer() {
|
||||
return this.pasteBinBuffer;
|
||||
}
|
||||
|
||||
public void setPasteBinBuffer(String buffer) {
|
||||
this.pasteBinBuffer = buffer;
|
||||
}
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
//import org.bukkit.event.block.BlockRightClickEvent;
|
||||
|
||||
public class MVBlockListener extends BlockListener {
|
||||
|
||||
MultiverseCore plugin;
|
||||
|
||||
public MVBlockListener(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
// public void onBlockRightClicked(BlockRightClickEvent event){
|
||||
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void onBlockDamage(BlockDamageEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int id = event.getChangedTypeId();
|
||||
|
||||
if (id == 90) { // && config.getBoolean("portalanywhere", false)
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void onBlockPlaced(BlockPlaceEvent event) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,47 +1,66 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Ghast;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
//import org.bukkit.event.entity.ExplosionPrimedEvent;
|
||||
|
||||
public class MVEntityListener extends EntityListener {
|
||||
|
||||
MultiverseCore plugin;
|
||||
private MultiverseCore plugin;
|
||||
private WorldManager worldManager;
|
||||
|
||||
public MVEntityListener(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
this.worldManager = plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player p = (Player) event.getEntity();
|
||||
MultiverseWorld w = this.plugin.getMVWorldManager().getMVWorld(p.getWorld().getName());
|
||||
if (w != null && !w.getHunger()) {
|
||||
// If the world has hunger set to false, do not let the level go down
|
||||
if (event.getFoodLevel() < ((Player) event.getEntity()).getFoodLevel()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event - When a Entity is Damaged, we first sort out whether it is of importance to us, such as EntityVSEntity or EntityVSProjectile. Then we grab the attacked and defender and check if its a player. Then deal with the PVP Aspect.
|
||||
* Event - When a Entity is Damaged, we first sort out whether it is of importance to us, such as EntityVSEntity or
|
||||
* EntityVSProjectile. Then we grab the attacked and defender and check if its a player. Then deal with the PVP
|
||||
* Aspect.
|
||||
*/
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
Entity attacker = null;
|
||||
Entity defender = null;
|
||||
Entity attacker;
|
||||
Entity defender;
|
||||
if (event instanceof EntityDamageByEntityEvent) {
|
||||
EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event;
|
||||
attacker = sub.getDamager();
|
||||
@@ -56,19 +75,16 @@ public class MVEntityListener extends EntityListener {
|
||||
Player player = (Player) defender;
|
||||
World w = player.getWorld();
|
||||
|
||||
if (!this.plugin.isMVWorld(w.getName())) {
|
||||
if (!this.worldManager.isMVWorld(w.getName())) {
|
||||
// if the world is not handled, we don't care
|
||||
return;
|
||||
}
|
||||
MVWorld world = this.plugin.getMVWorld(w.getName());
|
||||
MultiverseWorld world = this.worldManager.getMVWorld(w.getName());
|
||||
|
||||
if (attacker != null && attacker instanceof Player) {
|
||||
Player pattacker = (Player) attacker;
|
||||
|
||||
if (!world.getPvp() && this.plugin.getConfig().getBoolean("fakepvp", false)) {
|
||||
pattacker.sendMessage(ChatColor.RED + "PVP is disabled in this World.");
|
||||
if (attacker instanceof Player) {
|
||||
if (!world.isPVPEnabled() && world.getFakePVP()) {
|
||||
((Player) attacker).sendMessage(ChatColor.RED + "PVP is disabled in this World.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,15 +96,13 @@ public class MVEntityListener extends EntityListener {
|
||||
return;
|
||||
}
|
||||
RegainReason reason = event.getRegainReason();
|
||||
if (reason == RegainReason.REGEN && this.plugin.getConfig().getBoolean("disableautoheal", false)) {
|
||||
MultiverseWorld world = this.worldManager.getMVWorld(event.getEntity().getLocation().getWorld());
|
||||
if (world != null && reason == RegainReason.REGEN && !world.getAutoHeal()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Animal/Monster Spawn settings, seems like a more concrete method than using CraftBukkit.
|
||||
*/
|
||||
/** Handle Animal/Monster Spawn settings, seems like a more concrete method than using CraftBukkit. */
|
||||
@Override
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
|
||||
@@ -102,24 +116,32 @@ public class MVEntityListener extends EntityListener {
|
||||
return;
|
||||
|
||||
// Check if it's a world which we are meant to be managing.
|
||||
if (!(this.plugin.isMVWorld(world.getName())))
|
||||
if (!(this.worldManager.isMVWorld(world.getName())))
|
||||
return;
|
||||
|
||||
CreatureType creature = event.getCreatureType();
|
||||
|
||||
MVWorld mvworld = this.plugin.getMVWorld(world.getName());
|
||||
MultiverseWorld mvworld = this.worldManager.getMVWorld(world.getName());
|
||||
|
||||
/**
|
||||
* Handle people with non-standard animals: ie a patched craftbukkit.
|
||||
*/
|
||||
if (creature == null) {
|
||||
this.plugin.log(Level.FINER, "Found a null typed creature.");
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Animal Handling
|
||||
*/
|
||||
if (event.getEntity() instanceof Animals) {
|
||||
event.setCancelled(this.shouldWeKillThisCreature(mvworld.getAnimalList(), mvworld.allowAnimalSpawning(), creature.toString().toUpperCase()));
|
||||
if (event.getEntity() instanceof Animals || event.getEntity() instanceof Squid) {
|
||||
event.setCancelled(this.shouldWeKillThisCreature(mvworld.getAnimalList(), mvworld.canAnimalsSpawn(), creature.toString().toUpperCase()));
|
||||
}
|
||||
/**
|
||||
* Monster Handling
|
||||
*/
|
||||
if (event.getEntity() instanceof Monster || event.getEntity() instanceof Ghast || event.getEntity() instanceof Slime) {
|
||||
event.setCancelled(this.shouldWeKillThisCreature(mvworld.getMonsterList(), mvworld.allowMonsterSpawning(), creature.toString().toUpperCase()));
|
||||
event.setCancelled(this.shouldWeKillThisCreature(mvworld.getMonsterList(), mvworld.canMonstersSpawn(), creature.toString().toUpperCase()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,13 +155,13 @@ public class MVEntityListener extends EntityListener {
|
||||
} else if (creatureList.contains(creature) && allowCreatureSpawning) {
|
||||
// 3. There ARE exceptions and animals ARE allowed. Kill it.
|
||||
return true;
|
||||
} else if (!creatureList.contains(creature.toString().toUpperCase()) && allowCreatureSpawning) {
|
||||
} else if (!creatureList.contains(creature.toUpperCase()) && allowCreatureSpawning) {
|
||||
// 4. There ARE exceptions and animals ARE NOT allowed. SAVE it.
|
||||
return false;
|
||||
} else if (creatureList.contains(creature.toString().toUpperCase()) && !allowCreatureSpawning) {
|
||||
} else if (creatureList.contains(creature.toUpperCase()) && !allowCreatureSpawning) {
|
||||
// 5. No animals are allowed to be spawned, BUT this one can stay...
|
||||
return false;
|
||||
} else if (!creatureList.contains(creature.toString().toUpperCase()) && !allowCreatureSpawning) {
|
||||
} else if (!creatureList.contains(creature.toUpperCase()) && !allowCreatureSpawning) {
|
||||
// 6. Animals are NOT allowed to spawn, and this creature is not in the save list... KILL IT
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,53 +1,53 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
import com.fernferret.allpay.GenericBank;
|
||||
import com.onarandombox.MultiverseCore.MVTeleport;
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.event.MVRespawnEvent;
|
||||
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
|
||||
import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.*;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MVPlayerListener extends PlayerListener {
|
||||
MultiverseCore plugin;
|
||||
MVTeleport mvteleporter;
|
||||
SafeTTeleporter mvteleporter;
|
||||
WorldManager worldManager;
|
||||
|
||||
public MVPlayerListener(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
worldManager = plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
// Taken out until we do persistance.
|
||||
// @Override
|
||||
// public void onPlayerBedLeave(PlayerBedLeaveEvent event) {
|
||||
// Location bedLoc = event.getBed().getLocation();
|
||||
// bedLoc = this.plugin.getTeleporter().getSafeBedDestination(bedLoc);
|
||||
// this.plugin.getPlayerSession(event.getPlayer()).setRespawnLocation(bedLoc);
|
||||
// event.getPlayer().sendMessage("You should come back here when you type '/mv sleep'!");
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void onPlayerChat(PlayerChatEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
// Check whether the Server is set to prefix the chat with the World name. If not we do nothing, if so we need to check if the World has an Alias.
|
||||
if (this.plugin.getConfig().getBoolean("worldnameprefix", true)) {
|
||||
this.plugin.getConfig().save();
|
||||
// Check whether the Server is set to prefix the chat with the World name.
|
||||
// If not we do nothing, if so we need to check if the World has an Alias.
|
||||
if (MultiverseCore.PrefixChat) {
|
||||
String world = event.getPlayer().getWorld().getName();
|
||||
String prefix = "";
|
||||
// If we're not a MV world, don't do anything
|
||||
if (!this.plugin.isMVWorld(world)) {
|
||||
if (!this.worldManager.isMVWorld(world)) {
|
||||
return;
|
||||
}
|
||||
MultiverseWorld mvworld = this.worldManager.getMVWorld(world);
|
||||
if (mvworld.isHidden()) {
|
||||
return;
|
||||
}
|
||||
MVWorld mvworld = this.plugin.getMVWorld(world);
|
||||
prefix = mvworld.getColoredWorldString();
|
||||
String format = event.getFormat();
|
||||
event.setFormat("[" + prefix + "]" + format);
|
||||
@@ -56,43 +56,67 @@ public class MVPlayerListener extends PlayerListener {
|
||||
|
||||
@Override
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
// TODO: Reimplement bed respawning, needs to be a way to persist the bed location or something otherwise it's not very effective.
|
||||
|
||||
World world = event.getPlayer().getWorld();
|
||||
|
||||
// If it's not a World MV manages we stop.
|
||||
if (!this.plugin.isMVWorld(world.getName())) {
|
||||
if (!this.worldManager.isMVWorld(world.getName())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the MVWorld
|
||||
MVWorld mvWorld = this.plugin.getMVWorld(world.getName());
|
||||
if (MultiverseCore.BedRespawn) {
|
||||
this.plugin.log(Level.FINE, "Spawning " + event.getPlayer().getName() + " at their bed");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the MultiverseWorld
|
||||
MultiverseWorld mvWorld = this.worldManager.getMVWorld(world.getName());
|
||||
// Get the instance of the World the player should respawn at.
|
||||
MVWorld respawnWorld = null;
|
||||
if (this.plugin.isMVWorld(mvWorld.getRespawnToWorld())) {
|
||||
respawnWorld = this.plugin.getMVWorld(mvWorld.getRespawnToWorld());
|
||||
MultiverseWorld respawnWorld = null;
|
||||
if (this.worldManager.isMVWorld(mvWorld.getRespawnToWorld())) {
|
||||
respawnWorld = this.worldManager.getMVWorld(mvWorld.getRespawnToWorld());
|
||||
}
|
||||
|
||||
// If it's null then it either means the World doesn't exist or the value is blank, so we don't handle it.
|
||||
if (respawnWorld == null) {
|
||||
return;
|
||||
// NOW: We'll always handle it to get more accurate spawns
|
||||
if (respawnWorld != null) {
|
||||
world = respawnWorld.getCBWorld();
|
||||
}
|
||||
|
||||
Location respawnLocation = respawnWorld.getCBWorld().getSpawnLocation();
|
||||
// World has been set to the appropriate world
|
||||
Location respawnLocation = getMostAccurateRespawnLocation(world);
|
||||
|
||||
MVRespawnEvent respawnEvent = new MVRespawnEvent(respawnLocation, event.getPlayer(), "compatability");
|
||||
this.plugin.getServer().getPluginManager().callEvent(respawnEvent);
|
||||
event.setRespawnLocation(respawnEvent.getPlayersRespawnLocation());
|
||||
}
|
||||
|
||||
private Location getMostAccurateRespawnLocation(World w) {
|
||||
MultiverseWorld mvw = this.worldManager.getMVWorld(w.getName());
|
||||
if (mvw != null) {
|
||||
return mvw.getSpawnLocation();
|
||||
}
|
||||
return w.getSpawnLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
if (this.plugin.getMVWorlds().size() == 0 && this.plugin.getPermissions().hasPermission(event.getPlayer(), "multiverse.core.import", true)) {
|
||||
if (this.worldManager.getMVWorlds().size() == 0 && this.plugin.getMVPerms().hasPermission(event.getPlayer(), "multiverse.core.import", true)) {
|
||||
event.getPlayer().sendMessage("You don't have any worlds imported into Multiverse!");
|
||||
event.getPlayer().sendMessage("You can import your current worlds with " + ChatColor.AQUA + "/mvimport");
|
||||
event.getPlayer().sendMessage("or you can create new ones with " + ChatColor.GOLD + "/mvcreate");
|
||||
event.getPlayer().sendMessage("If you just wanna see all of the Multiverse Help, type: " + ChatColor.GREEN + "/mv");
|
||||
}
|
||||
// Handle the Players GameMode setting for the new world.
|
||||
if (MultiverseCore.EnforceGameModes) {
|
||||
this.handleGameMode(event.getPlayer(), event.getPlayer().getWorld());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
|
||||
// Handle the Players GameMode setting for the new world.
|
||||
if (MultiverseCore.EnforceGameModes) {
|
||||
this.handleGameMode(event.getPlayer(), event.getPlayer().getWorld());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,33 +126,131 @@ public class MVPlayerListener extends PlayerListener {
|
||||
|
||||
@Override
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
MVWorld fromWorld = this.plugin.getMVWorld(event.getTo().getWorld().getName());
|
||||
MVWorld toWorld = this.plugin.getMVWorld(event.getTo().getWorld().getName());
|
||||
if (toWorld != null) {
|
||||
if (!this.plugin.getPermissions().canEnterWorld(event.getPlayer(), toWorld)) {
|
||||
event.getPlayer().sendMessage("You don't have access to go here...");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
MultiverseWorld fromWorld = this.worldManager.getMVWorld(event.getFrom().getWorld().getName());
|
||||
MultiverseWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName());
|
||||
if (event.getFrom().getWorld().equals(event.getTo().getWorld())) {
|
||||
// The player is Teleporting to the same world.
|
||||
this.plugin.log(Level.FINER, "Player '" + event.getPlayer().getName() + "' is teleporting to the same world.");
|
||||
return;
|
||||
}
|
||||
if (MultiverseCore.EnforceAccess) {
|
||||
event.setCancelled(!playerCanGoFromTo(fromWorld, toWorld, event.getPlayer()));
|
||||
if (event.isCancelled()) {
|
||||
this.plugin.log(Level.FINE, "Player '" + event.getPlayer().getName() + "' was DENIED ACCESS to '" + event.getTo().getWorld().getName() +
|
||||
"' because they don't have: multiverse.access." + event.getTo().getWorld().getName());
|
||||
}
|
||||
} else {
|
||||
this.plugin.log(Level.FINE, "Player '" + event.getPlayer().getName() + "' was allowed to go to '" + event.getTo().getWorld().getName() + "' because enforceaccess is off.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerPortal(PlayerPortalEvent event) {
|
||||
// If the player was actually outside of the portal, adjust the from location
|
||||
if (event.getFrom().getWorld().getBlockAt(event.getFrom()).getType() != Material.PORTAL) {
|
||||
event.setFrom(SafeTTeleporter.findPortalBlockNextTo(event.getFrom()));
|
||||
}
|
||||
if (event.isCancelled() || event.getTo() == null || event.getFrom() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
MultiverseWorld fromWorld = this.worldManager.getMVWorld(event.getFrom().getWorld().getName());
|
||||
MultiverseWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName());
|
||||
if (event.getFrom().getWorld().equals(event.getTo().getWorld())) {
|
||||
// The player is Portaling to the same world.
|
||||
this.plugin.log(Level.FINER, "Player '" + event.getPlayer().getName() + "' is portaling to the same world.");
|
||||
return;
|
||||
}
|
||||
if (MultiverseCore.EnforceAccess) {
|
||||
event.setCancelled(!playerCanGoFromTo(fromWorld, toWorld, event.getPlayer()));
|
||||
if (event.isCancelled()) {
|
||||
this.plugin.log(Level.FINE, "Player '" + event.getPlayer().getName() + "' was DENIED ACCESS to '" + event.getTo().getWorld().getName() +
|
||||
"' because they don't have: multiverse.access." + event.getTo().getWorld().getName());
|
||||
}
|
||||
} else {
|
||||
this.plugin.log(Level.FINE, "Player '" + event.getPlayer().getName() + "' was allowed to go to '" + event.getTo().getWorld().getName() + "' because enforceaccess is off.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if player can go to a world given their current status.
|
||||
* <p/>
|
||||
* The return is a little backwards, and will return a value safe for event.setCancelled.
|
||||
*
|
||||
* @param fromWorld The MultiverseWorld they are in.
|
||||
* @param toWorld The MultiverseWorld they want to go to.
|
||||
* @param player The player that wants to travel.
|
||||
*
|
||||
* @return True if they can't go to the world, False if they can.
|
||||
*/
|
||||
private boolean playerCanGoFromTo(MultiverseWorld fromWorld, MultiverseWorld toWorld, Player player) {
|
||||
|
||||
if (toWorld != null) {
|
||||
if (!this.plugin.getMVPerms().canEnterWorld(player, toWorld)) {
|
||||
player.sendMessage("You don't have access to go here...");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
//TODO: Determine if this value is false because a world didn't exist
|
||||
// or if it was because a world wasn't imported.
|
||||
return true;
|
||||
}
|
||||
if (fromWorld != null) {
|
||||
if (fromWorld.getWorldBlacklist().contains(toWorld.getName())) {
|
||||
event.getPlayer().sendMessage("You don't have access to go to " + toWorld.getColoredWorldString() + " from " + fromWorld.getColoredWorldString());
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
player.sendMessage("You don't have access to go to " + toWorld.getColoredWorldString() + " from " + fromWorld.getColoredWorldString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Only check payments if it's a different world:
|
||||
if (!event.getTo().getWorld().equals(event.getFrom().getWorld())) {
|
||||
if (!toWorld.equals(fromWorld)) {
|
||||
// If the player does not have to pay, return now.
|
||||
if(toWorld.isExempt(event.getPlayer())) {
|
||||
return;
|
||||
if (this.plugin.getMVPerms().hasPermission(player, toWorld.getExemptPermission().getName(), true)) {
|
||||
return true;
|
||||
}
|
||||
GenericBank bank = plugin.getBank();
|
||||
if (!bank.hasEnough(event.getPlayer(), toWorld.getPrice(), toWorld.getCurrency(), "You need " + bank.getFormattedAmount(toWorld.getPrice(), toWorld.getCurrency()) + " to enter " + toWorld.getColoredWorldString())) {
|
||||
event.setCancelled(true);
|
||||
if (!bank.hasEnough(player, toWorld.getPrice(), toWorld.getCurrency(), "You need " + bank.getFormattedAmount(player, toWorld.getPrice(), toWorld.getCurrency()) + " to enter " + toWorld.getColoredWorldString())) {
|
||||
return false;
|
||||
} else {
|
||||
bank.pay(event.getPlayer(), toWorld.getPrice(), toWorld.getCurrency());
|
||||
bank.pay(player, toWorld.getPrice(), toWorld.getCurrency());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// FOLLOWING 2 Methods and Private class handle Per Player GameModes.
|
||||
private void handleGameMode(Player player, World world) {
|
||||
MultiverseWorld mvWorld = this.worldManager.getMVWorld(world.getName());
|
||||
if (mvWorld != null) {
|
||||
this.handleGameMode(player, mvWorld);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleGameMode(Player player, MultiverseWorld world) {
|
||||
// We perform this task one tick later to MAKE SURE that the player actually reaches the
|
||||
// destination world, otherwise we'd be changing the player mode if they havent moved anywhere.
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new HandleGameMode(player, world), 1L);
|
||||
}
|
||||
|
||||
/** The following private class is used to handle player game mode changes within a scheduler. */
|
||||
private class HandleGameMode implements Runnable {
|
||||
|
||||
private Player player;
|
||||
private MultiverseWorld world;
|
||||
|
||||
private HandleGameMode(Player player, MultiverseWorld world) {
|
||||
this.player = player;
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// Check that the player is in the new world and they haven't been teleported elsewhere or the event cancelled.
|
||||
if (player.getWorld().getName().equals(world.getCBWorld().getName())) {
|
||||
player.setGameMode(world.getGameMode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.fernferret.allpay.AllPay;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
|
||||
import com.fernferret.allpay.AllPay;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MVPluginListener extends ServerListener {
|
||||
|
||||
@@ -19,17 +24,16 @@ public class MVPluginListener extends ServerListener {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep an eye out for Plugins which we can utilize.
|
||||
*/
|
||||
/** Keep an eye out for Plugins which we can utilize. */
|
||||
@Override
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
/**
|
||||
* Check to see if Permissions was just enabled
|
||||
*/
|
||||
if (event.getPlugin().getDescription().getName().equals("Permissions")) {
|
||||
this.plugin.getPermissions().setPermissions(((Permissions) this.plugin.getServer().getPluginManager().getPlugin("Permissions")).getHandler());
|
||||
this.plugin.log(Level.INFO, "- Attached to Permissions");
|
||||
if (event.getPlugin() instanceof com.onarandombox.MultiverseCore.MVPlugin) {
|
||||
this.plugin.log(Level.SEVERE, "Your version of '" + event.getPlugin() + "' is OUT OF DATE.");
|
||||
this.plugin.log(Level.SEVERE, "Please grab the latest version from:");
|
||||
this.plugin.log(Level.SEVERE, "http://bukkit.onarandombox.com/?dir=" + event.getPlugin().getDescription().getName().toLowerCase());
|
||||
this.plugin.log(Level.SEVERE, "I'm going to disable " + event.getPlugin().getDescription().getName() + " now.");
|
||||
this.plugin.log(Level.SEVERE, "IF YOU DO NOT UPDATE, YOUR SERVER WILL **NOT** FUNCTION PROPERLY!!!");
|
||||
this.plugin.getServer().getPluginManager().disablePlugin(event.getPlugin());
|
||||
}
|
||||
// Let AllPay handle all econ plugin loadings, only go for econ plugins we support
|
||||
if (Arrays.asList(AllPay.validEconPlugins).contains(event.getPlugin().getDescription().getName())) {
|
||||
@@ -41,20 +45,15 @@ public class MVPluginListener extends ServerListener {
|
||||
this.plugin.log(Level.WARNING, "I just disabled the old version of Multiverse for you. You should remove the JAR now, your configs have been migrated.");
|
||||
}
|
||||
}
|
||||
if (event.getPlugin().getDescription().getName().equals("Spout")) {
|
||||
this.plugin.setSpout();
|
||||
this.plugin.log(Level.INFO, "Spout integration enabled.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We'll check if any of the plugins we rely on decide to Disable themselves.
|
||||
*/
|
||||
/** We'll check if any of the plugins we rely on decide to Disable themselves. */
|
||||
@Override
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
/**
|
||||
* Check to see if Permissions just disabled.
|
||||
*/
|
||||
if (event.getPlugin().getDescription().getName().equals("Permissions")) {
|
||||
this.plugin.log(Level.INFO, "Permissions disabled");
|
||||
this.plugin.getPermissions().setPermissions(null);
|
||||
}
|
||||
// TODO: Disable econ when it disables.
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import org.bukkit.event.weather.ThunderChangeEvent;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
import org.bukkit.event.weather.WeatherListener;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
public class MVWeatherListener extends WeatherListener {
|
||||
private MultiverseCore plugin;
|
||||
|
||||
@@ -17,20 +23,20 @@ public class MVWeatherListener extends WeatherListener {
|
||||
@Override
|
||||
public void onWeatherChange(WeatherChangeEvent event) {
|
||||
|
||||
MVWorld world = this.plugin.getMVWorld(event.getWorld().getName());
|
||||
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getWorld().getName());
|
||||
if (world != null) {
|
||||
// If it's going to start raining and we have weather disabled
|
||||
event.setCancelled((event.toWeatherState() && !world.getWeatherEnabled()));
|
||||
event.setCancelled((event.toWeatherState() && !world.isWeatherEnabled()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onThunderChange(ThunderChangeEvent event) {
|
||||
|
||||
MVWorld world = this.plugin.getMVWorld(event.getWorld().getName());
|
||||
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getWorld().getName());
|
||||
if (world != null) {
|
||||
// If it's going to start raining and we have weather disabled
|
||||
event.setCancelled((event.toThunderState() && !world.getWeatherEnabled()));
|
||||
event.setCancelled((event.toThunderState() && !world.isWeatherEnabled()));
|
||||
}
|
||||
}
|
||||
}
|
||||
+55
-15
@@ -1,5 +1,13 @@
|
||||
package com.onarandombox.utils;
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@@ -7,14 +15,22 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class BlockSafety {
|
||||
|
||||
public BlockSafety() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks whether the block at the given coordinates are above air or not.
|
||||
*
|
||||
*
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isBlockAboveAir(Location l) {
|
||||
@@ -28,13 +44,20 @@ public class BlockSafety {
|
||||
return !playerCanSpawnHereSafely(l);
|
||||
}
|
||||
|
||||
public boolean playerCanSpawnHereSafely(World world, double x, double y, double z) {
|
||||
Location l = new Location(world, x, y, z);
|
||||
return playerCanSpawnHereSafely(l);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks whether the block at the coordinates given is safe or not by checking for Laval/Fire/Air etc. This also ensures there is enough space for a player to spawn!
|
||||
*
|
||||
* This function checks whether the block at the coordinates given is safe or not by checking for Laval/Fire/Air
|
||||
* etc. This also ensures there is enough space for a player to spawn!
|
||||
*
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean playerCanSpawnHereSafely(Location l) {
|
||||
@@ -45,18 +68,25 @@ public class BlockSafety {
|
||||
downOne.setY(downOne.getY() - 1);
|
||||
|
||||
if (this.isSolidBlock(actual.getBlock().getType()) || this.isSolidBlock(upOne.getBlock().getType())) {
|
||||
MultiverseCore.staticLog(Level.FINER, "Error Here? (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
|
||||
MultiverseCore.staticLog(Level.FINER, "Error Here? (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (downOne.getBlock().getType() == Material.LAVA || downOne.getBlock().getType() == Material.STATIONARY_LAVA) {
|
||||
MultiverseCore.staticLog(Level.FINER, "Error Here? (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
|
||||
MultiverseCore.staticLog(Level.FINER, "Error Here? (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (downOne.getBlock().getType() == Material.FIRE) {
|
||||
MultiverseCore.staticLog(Level.FINER, "There's fire below! (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isBlockAboveAir(actual)) {
|
||||
MultiverseCore.staticLog(Level.FINER, "Is block above air [" + isBlockAboveAir(actual) + "]");
|
||||
MultiverseCore.staticLog(Level.FINER, "Has 2 blocks of water below [" + this.hasTwoBlocksofWaterBelow(actual) + "]");
|
||||
return this.hasTwoBlocksofWaterBelow(actual);
|
||||
}
|
||||
return true;
|
||||
@@ -64,8 +94,9 @@ public class BlockSafety {
|
||||
|
||||
/**
|
||||
* If someone has a better way of this... Please either tell us, or submit a pull request!
|
||||
*
|
||||
*
|
||||
* @param type
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean isSolidBlock(Material type) {
|
||||
@@ -122,6 +153,12 @@ public class BlockSafety {
|
||||
return false;
|
||||
case SIGN_POST:
|
||||
return false;
|
||||
case WOODEN_DOOR:
|
||||
return false;
|
||||
case STATIONARY_WATER:
|
||||
return false;
|
||||
case WATER:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -145,41 +182,44 @@ public class BlockSafety {
|
||||
System.out.print("Location Down: " + downOne.getBlock().getType());
|
||||
System.out.print(" " + downOne);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks recursively below location L for 2 blocks of water
|
||||
*
|
||||
* @param l
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean hasTwoBlocksofWaterBelow(Location l) {
|
||||
if(l.getBlockY() < 0) {
|
||||
if (l.getBlockY() < 0) {
|
||||
return false;
|
||||
}
|
||||
Location oneBelow = l.clone();
|
||||
oneBelow.subtract(0, 1, 0);
|
||||
if(oneBelow.getBlock().getType() == Material.WATER || oneBelow.getBlock().getType() == Material.STATIONARY_WATER) {
|
||||
if (oneBelow.getBlock().getType() == Material.WATER || oneBelow.getBlock().getType() == Material.STATIONARY_WATER) {
|
||||
Location twoBelow = oneBelow.clone();
|
||||
twoBelow.subtract(0, 1, 0);
|
||||
return (oneBelow.getBlock().getType() == Material.WATER || oneBelow.getBlock().getType() == Material.STATIONARY_WATER);
|
||||
}
|
||||
if(oneBelow.getBlock().getType() != Material.AIR) {
|
||||
if (oneBelow.getBlock().getType() != Material.AIR) {
|
||||
return false;
|
||||
}
|
||||
return hasTwoBlocksofWaterBelow(oneBelow);
|
||||
}
|
||||
|
||||
|
||||
public boolean canSpawnCartSafely(Minecart cart) {
|
||||
|
||||
if(this.isBlockAboveAir(cart.getLocation())) {
|
||||
|
||||
if (this.isBlockAboveAir(cart.getLocation())) {
|
||||
return true;
|
||||
}
|
||||
if(this.isEntitiyOnTrack(cart, LocationManipulation.getNextBlock(cart))) {
|
||||
return true;
|
||||
if (this.isEntitiyOnTrack(cart, LocationManipulation.getNextBlock(cart))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean canSpawnVehicleSafely(Vehicle vehicle) {
|
||||
if(this.isBlockAboveAir(vehicle.getLocation())) {
|
||||
if (this.isBlockAboveAir(vehicle.getLocation())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -0,0 +1,84 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.logging.*;
|
||||
|
||||
public class DebugLog {
|
||||
|
||||
private FileHandler fh;
|
||||
private Logger log;
|
||||
|
||||
/**
|
||||
* Creates a new debug logger.
|
||||
*
|
||||
* @param logger The name of the logger.
|
||||
* @param file The file to log to.
|
||||
*/
|
||||
public DebugLog(String logger, String file) {
|
||||
this.log = Logger.getLogger(logger);
|
||||
|
||||
try {
|
||||
this.fh = new FileHandler(file, true);
|
||||
this.log.setUseParentHandlers(false);
|
||||
for (Handler handler : this.log.getHandlers()) {
|
||||
this.log.removeHandler(handler);
|
||||
}
|
||||
this.log.addHandler(this.fh);
|
||||
this.log.setLevel(Level.ALL);
|
||||
this.fh.setFormatter(new LogFormatter());
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a message at a certain level
|
||||
*
|
||||
* @param level
|
||||
* @param msg
|
||||
*/
|
||||
public void log(Level level, String msg) {
|
||||
this.log.log(level, msg);
|
||||
}
|
||||
|
||||
private class LogFormatter extends Formatter {
|
||||
private final SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@Override
|
||||
public String format(LogRecord record) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Throwable ex = record.getThrown();
|
||||
|
||||
builder.append(this.date.format(record.getMillis()));
|
||||
builder.append(" [");
|
||||
builder.append(record.getLevel().getLocalizedName().toUpperCase());
|
||||
builder.append("] ");
|
||||
builder.append(record.getMessage());
|
||||
builder.append('\n');
|
||||
|
||||
if (ex != null) {
|
||||
StringWriter writer = new StringWriter();
|
||||
ex.printStackTrace(new PrintWriter(writer));
|
||||
builder.append(writer);
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
this.fh.close();
|
||||
}
|
||||
}
|
||||
+14
-7
@@ -1,4 +1,11 @@
|
||||
package com.onarandombox.utils;
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
@@ -7,30 +14,30 @@ public class FancyColorScheme {
|
||||
private ChatColor mainColor;
|
||||
private ChatColor altColor;
|
||||
private ChatColor defContentColor;
|
||||
|
||||
|
||||
public FancyColorScheme(ChatColor header, ChatColor main, ChatColor alt, ChatColor defaultColor) {
|
||||
this.headerColor = header;
|
||||
this.mainColor = main;
|
||||
this.altColor = alt;
|
||||
this.defContentColor = defaultColor;
|
||||
}
|
||||
|
||||
|
||||
public ChatColor getHeader() {
|
||||
return this.headerColor;
|
||||
}
|
||||
|
||||
|
||||
public ChatColor getMain() {
|
||||
return this.mainColor;
|
||||
}
|
||||
|
||||
|
||||
public ChatColor getAlt() {
|
||||
return this.altColor;
|
||||
}
|
||||
|
||||
|
||||
public ChatColor getDefault() {
|
||||
return this.defContentColor;
|
||||
}
|
||||
|
||||
|
||||
public ChatColor getMain(boolean main) {
|
||||
return main ? this.getMain() : this.getAlt();
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.FancyText;
|
||||
|
||||
public class FancyHeader implements FancyText {
|
||||
|
||||
private FancyColorScheme colors;
|
||||
private String text;
|
||||
|
||||
public FancyHeader(String text, FancyColorScheme scheme) {
|
||||
this.colors = scheme;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFancyText() {
|
||||
return colors.getHeader() + "--- " + text + colors.getHeader() + " ---";
|
||||
}
|
||||
|
||||
public void appendText(String string) {
|
||||
this.text += string;
|
||||
}
|
||||
|
||||
}
|
||||
+17
-1
@@ -1,12 +1,23 @@
|
||||
package com.onarandombox.utils;
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.FancyText;
|
||||
|
||||
public class FancyMessage implements FancyText {
|
||||
private String title;
|
||||
private String message;
|
||||
private boolean main = true;
|
||||
private FancyColorScheme colors;
|
||||
|
||||
/**
|
||||
* Allows easy creation of an alternating colored list
|
||||
*
|
||||
* @param title
|
||||
* @param message
|
||||
*/
|
||||
@@ -15,19 +26,24 @@ public class FancyMessage implements FancyText {
|
||||
this.message = message;
|
||||
this.colors = scheme;
|
||||
}
|
||||
|
||||
public void setColorMain() {
|
||||
this.main = true;
|
||||
}
|
||||
|
||||
public void setColorAlt() {
|
||||
this.main = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFancyText() {
|
||||
return this.colors.getMain(this.main) + this.title + this.colors.getDefault() + message;
|
||||
}
|
||||
|
||||
public void setAltColor(boolean altColor) {
|
||||
this.main = !altColor;
|
||||
}
|
||||
|
||||
public void setMainColor(boolean mainColor) {
|
||||
this.main = mainColor;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class FileUtils {
|
||||
/*
|
||||
* Delete a folder Courtesy of: lithium3141
|
||||
*
|
||||
* @param file The folder to delete
|
||||
*
|
||||
* @return true if success
|
||||
*/
|
||||
public static boolean deleteFolder(File file) {
|
||||
if (file.exists()) {
|
||||
// If the file exists, and it has more than one file in it.
|
||||
if (file.isDirectory()) {
|
||||
for (File f : file.listFiles()) {
|
||||
if (!FileUtils.deleteFolder(f)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
file.delete();
|
||||
return !file.exists();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+77
-14
@@ -1,15 +1,25 @@
|
||||
package com.onarandombox.utils;
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class LocationManipulation {
|
||||
private static Map<String, Integer> orientationInts = new HashMap<String, Integer>();
|
||||
|
||||
static {
|
||||
orientationInts.put("n", 180);
|
||||
orientationInts.put("ne", 225);
|
||||
@@ -24,11 +34,12 @@ public class LocationManipulation {
|
||||
|
||||
/**
|
||||
* Convert a Location into a Colon separated string to allow us to store it in text.
|
||||
*
|
||||
*
|
||||
* @param location
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String locationToString(Location location) {
|
||||
public static String locationToString(Location location) {
|
||||
StringBuilder l = new StringBuilder();
|
||||
l.append(location.getBlockX() + ":");
|
||||
l.append(location.getBlockY() + ":");
|
||||
@@ -40,13 +51,14 @@ public class LocationManipulation {
|
||||
|
||||
/**
|
||||
* Convert a String to a Location.
|
||||
*
|
||||
*
|
||||
* @param world
|
||||
* @param xStr
|
||||
* @param yStr
|
||||
* @param zStr
|
||||
* @param yawStr
|
||||
* @param pitchStr
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Location stringToLocation(World world, String xStr, String yStr, String zStr, String yawStr, String pitchStr) {
|
||||
@@ -60,23 +72,50 @@ public class LocationManipulation {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a Location to XYZ Coordinates.
|
||||
*
|
||||
* Returns a colored string with the coords
|
||||
*
|
||||
* @param l
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String strCoords(Location l) {
|
||||
public static String strCoords(Location l) {
|
||||
String result = "";
|
||||
result += "X: " + l.getBlockX() + " ";
|
||||
result += "Y: " + l.getBlockY() + " ";
|
||||
result += "Z: " + l.getBlockZ() + " ";
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
df.setMinimumFractionDigits(0);
|
||||
df.setMaximumFractionDigits(2);
|
||||
result += ChatColor.WHITE + "X: " + ChatColor.AQUA + df.format(l.getX()) + " ";
|
||||
result += ChatColor.WHITE + "Y: " + ChatColor.AQUA + df.format(l.getY()) + " ";
|
||||
result += ChatColor.WHITE + "Z: " + ChatColor.AQUA + df.format(l.getZ()) + " ";
|
||||
result += ChatColor.WHITE + "P: " + ChatColor.GOLD + df.format(l.getPitch()) + " ";
|
||||
result += ChatColor.WHITE + "Y: " + ChatColor.GOLD + df.format(l.getYaw()) + " ";
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a location to a printable readable formatted string including pitch/yaw
|
||||
*
|
||||
* @param l
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String strCoordsRaw(Location l) {
|
||||
String result = "";
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
df.setMinimumFractionDigits(0);
|
||||
df.setMaximumFractionDigits(2);
|
||||
result += "X: " + df.format(l.getX()) + " ";
|
||||
result += "Y: " + df.format(l.getY()) + " ";
|
||||
result += "Z: " + df.format(l.getZ()) + " ";
|
||||
result += "P: " + df.format(l.getPitch()) + " ";
|
||||
result += "Y: " + df.format(l.getYaw()) + " ";
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the NESW Direction a Location is facing.
|
||||
*
|
||||
*
|
||||
* @param location
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getDirection(Location location) {
|
||||
@@ -105,6 +144,13 @@ public class LocationManipulation {
|
||||
return dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the float yaw position for the given cardianl direction
|
||||
*
|
||||
* @param orientation
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static float getYaw(String orientation) {
|
||||
if (orientation == null) {
|
||||
return 0;
|
||||
@@ -115,12 +161,28 @@ public class LocationManipulation {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a speed float from a given vector.
|
||||
*
|
||||
* @param v
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static float getSpeed(Vector v) {
|
||||
return (float) Math.sqrt(v.getX() * v.getX() + v.getZ() * v.getZ());
|
||||
}
|
||||
|
||||
// X, Y, Z
|
||||
// -W/+E,0, -N/+S
|
||||
|
||||
/**
|
||||
* Returns a translated vector from the given direction
|
||||
*
|
||||
* @param v
|
||||
* @param direction
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Vector getTranslatedVector(Vector v, String direction) {
|
||||
if (direction == null) {
|
||||
return v;
|
||||
@@ -150,8 +212,9 @@ public class LocationManipulation {
|
||||
|
||||
/**
|
||||
* Returns the next Location that an entity is traveling at
|
||||
*
|
||||
*
|
||||
* @param v
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Location getNextBlock(Vehicle v) {
|
||||
@@ -0,0 +1,96 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Multiverse 2
|
||||
*
|
||||
* @author fernferret
|
||||
*/
|
||||
public class MVMessaging {
|
||||
private MultiverseCore plugin;
|
||||
private Map<String, Date> sentList;
|
||||
private int cooldown = 0;
|
||||
|
||||
public MVMessaging(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
this.sentList = new HashMap<String, Date>();
|
||||
}
|
||||
|
||||
public void setCooldown(int milliseconds) {
|
||||
this.cooldown = milliseconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message to the specified sender if the cooldown has passed.
|
||||
*
|
||||
* @param sender The person/console to send the message to.
|
||||
* @param message The message to send.
|
||||
* @param ignoreCooldown If true this message will always be sent. Useful for things like menus
|
||||
*
|
||||
* @return true if the message was sent, false if not.
|
||||
*/
|
||||
public boolean sendMessage(CommandSender sender, String message, boolean ignoreCooldown) {
|
||||
if (!(sender instanceof Player) || ignoreCooldown) {
|
||||
sender.sendMessage(message);
|
||||
return true;
|
||||
}
|
||||
if (!this.sentList.containsKey(sender.getName())) {
|
||||
sender.sendMessage(message);
|
||||
this.sentList.put(sender.getName(), new Date());
|
||||
return true;
|
||||
} else {
|
||||
if (this.sentList.get(sender.getName()).after(new Date((new Date()).getTime() + this.cooldown))) {
|
||||
sender.sendMessage(message);
|
||||
this.sentList.put(sender.getName(), new Date());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean sendMessages(CommandSender sender, String[] messages, boolean ignoreCooldown) {
|
||||
if (!(sender instanceof Player) || ignoreCooldown) {
|
||||
|
||||
this.sendMessages(sender, messages);
|
||||
return true;
|
||||
}
|
||||
if (!this.sentList.containsKey(sender.getName())) {
|
||||
this.sendMessages(sender, messages);
|
||||
this.sentList.put(sender.getName(), new Date());
|
||||
return true;
|
||||
} else {
|
||||
if (this.sentList.get(sender.getName()).after(new Date((new Date()).getTime() + this.cooldown))) {
|
||||
this.sendMessages(sender, messages);
|
||||
this.sentList.put(sender.getName(), new Date());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean sendMessage(CommandSender sender, String message) {
|
||||
return this.sendMessage(sender, message, true);
|
||||
}
|
||||
|
||||
public boolean sendMessages(CommandSender sender, String[] messages) {
|
||||
boolean success = true;
|
||||
for (String s : messages) {
|
||||
success = (!(!this.sendMessage(sender, s, true) && success));
|
||||
}
|
||||
return success;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.pneumaticraft.commandhandler.PermissionsInterface;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MVPermissions implements PermissionsInterface {
|
||||
|
||||
private MultiverseCore plugin;
|
||||
private WorldManager worldMgr;
|
||||
|
||||
/**
|
||||
* Constructor FTW
|
||||
*
|
||||
* @param plugin Pass along the Core Plugin.
|
||||
*/
|
||||
public MVPermissions(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
this.worldMgr = plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a Player can teleport to the Destination world from there current world.
|
||||
*
|
||||
* @param p The player to check.
|
||||
* @param w
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean canTravelFromWorld(Player p, MultiverseWorld w) {
|
||||
List<String> blackList = w.getWorldBlacklist();
|
||||
|
||||
boolean returnValue = true;
|
||||
|
||||
for (String s : blackList) {
|
||||
if (s.equalsIgnoreCase(p.getWorld().getName())) {
|
||||
returnValue = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
public boolean canTravelFromLocation(CommandSender sender, Location location) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
Player teleporter = (Player) sender;
|
||||
if (!this.worldMgr.isMVWorld(location.getWorld().getName())) {
|
||||
return false;
|
||||
}
|
||||
return canTravelFromWorld(teleporter, this.worldMgr.getMVWorld(location.getWorld().getName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the Player has the permissions to enter this world.
|
||||
*
|
||||
* @param p
|
||||
* @param w
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean canEnterWorld(Player p, MultiverseWorld w) {
|
||||
// If we're not enforcing access, anyone can enter.
|
||||
if (!MultiverseCore.EnforceAccess) {
|
||||
return true;
|
||||
}
|
||||
return this.hasPermission(p, "multiverse.access." + w.getName(), false);
|
||||
}
|
||||
|
||||
public boolean canEnterLocation(Player p, Location l) {
|
||||
if (l == null) {
|
||||
return false;
|
||||
}
|
||||
String worldName = l.getWorld().getName();
|
||||
if (!this.plugin.getMVWorldManager().isMVWorld(worldName)) {
|
||||
return false;
|
||||
}
|
||||
return this.hasPermission(p, "multiverse.access." + worldName, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if a sender can enter a destination.
|
||||
* The reason this is not a player, is it can be used to simply check permissions
|
||||
* The console should, for exmaple, always see all worlds
|
||||
*
|
||||
* @param sender The CommandSender to check.
|
||||
* @param d The destination they are requesting.
|
||||
*
|
||||
* @return True if that sender can go to that destination
|
||||
*/
|
||||
public boolean canEnterDestination(CommandSender sender, MVDestination d) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
if (d == null || d.getLocation(p) == null) {
|
||||
return false;
|
||||
}
|
||||
String worldName = d.getLocation(p).getWorld().getName();
|
||||
if (!this.worldMgr.isMVWorld(worldName)) {
|
||||
return false;
|
||||
}
|
||||
if (!canEnterLocation(p, d.getLocation(p))) {
|
||||
return false;
|
||||
}
|
||||
return this.hasPermission(p, d.getRequiredPermission(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if a player has a permission.
|
||||
*
|
||||
* @param sender Who is requesting the permission.
|
||||
* @param node The permission node in string format; multiverse.core.list.worlds for example.
|
||||
* @param isOpRequired @Deprecated. This is not used for anything anymore.
|
||||
*
|
||||
* @return True if they have that permission or any parent.
|
||||
*/
|
||||
public boolean hasPermission(CommandSender sender, String node, boolean isOpRequired) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
// NO one can access a null permission (mainly used for destinations):w
|
||||
if (node == null) {
|
||||
return false;
|
||||
}
|
||||
// Everyone can access an empty permission
|
||||
// Currently used for the PlayerDestination
|
||||
if (node.equals("")) {
|
||||
return true;
|
||||
}
|
||||
boolean hasPermission = checkActualPermission(sender, node);
|
||||
|
||||
// I consider this a workaround. At the moment, when we add a node AND recalc the permissions, until the perms
|
||||
// plugin reloads, when MV asks the API if a player has a perm, it reports that they do NOT.
|
||||
// For the moment, we're going to check all of this node's parents to see if the user has those. It stops
|
||||
// when if finds a true or there are no more parents. --FF
|
||||
if (!hasPermission) {
|
||||
hasPermission = this.hasAnyParentPermission(sender, node);
|
||||
}
|
||||
|
||||
return hasPermission;
|
||||
}
|
||||
|
||||
// TODO: Better player checks, most likely not needed, but safer.
|
||||
private boolean checkActualPermission(CommandSender sender, String node) {
|
||||
Player player = (Player) sender;
|
||||
this.plugin.log(Level.FINEST, "Checking to see if player [" + player.getName() + "] has permission [" + node + "]");
|
||||
boolean hasPermission = sender.hasPermission(node);
|
||||
if (hasPermission) {
|
||||
this.plugin.log(Level.FINER, "Player [" + player.getName() + "] HAS PERMISSION [" + node + "]!");
|
||||
}
|
||||
return hasPermission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the sender has any parent perms.
|
||||
* Stops when it finds one or when there are no more parents.
|
||||
* This method is recursive.
|
||||
*
|
||||
* @param sender Who is asking for the permission.
|
||||
* @param node The permission node to check (possibly already a parent).
|
||||
*
|
||||
* @return True if they have any parent perm, false if none.
|
||||
*/
|
||||
private boolean hasAnyParentPermission(CommandSender sender, String node) {
|
||||
String parentPerm = this.pullOneLevelOff(node);
|
||||
// Base case
|
||||
if (parentPerm == null) {
|
||||
return false;
|
||||
}
|
||||
// If they have a parent, they're good
|
||||
if (this.checkActualPermission(sender, parentPerm + ".*")) {
|
||||
return true;
|
||||
}
|
||||
return hasAnyParentPermission(sender, parentPerm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pulls one level off of a yaml style node.
|
||||
* Given multiverse.core.list.worlds will return multiverse.core.list
|
||||
*
|
||||
* @param node The root node to check.
|
||||
*
|
||||
* @return The parent of the node
|
||||
*/
|
||||
private String pullOneLevelOff(String node) {
|
||||
if (node == null) {
|
||||
return null;
|
||||
}
|
||||
int index = node.lastIndexOf(".");
|
||||
if (index > 0) {
|
||||
return node.substring(0, index);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public String getType() {
|
||||
return "Bukkit Permissions (SuperPerms)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAnyPermission(CommandSender sender, List<String> nodes, boolean isOpRequired) {
|
||||
for (String node : nodes) {
|
||||
if (this.hasPermission(sender, node, isOpRequired)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAllPermission(CommandSender sender, List<String> nodes, boolean isOpRequired) {
|
||||
for (String node : nodes) {
|
||||
if (!this.hasPermission(sender, node, isOpRequired)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Permission addPermission(String string, PermissionDefault defaultValue) {
|
||||
if (this.plugin.getServer().getPluginManager().getPermission(string) == null) {
|
||||
Permission permission = new Permission(string, defaultValue);
|
||||
this.plugin.getServer().getPluginManager().addPermission(permission);
|
||||
this.addToParentPerms(string);
|
||||
}
|
||||
return this.plugin.getServer().getPluginManager().getPermission(string);
|
||||
}
|
||||
|
||||
private void addToParentPerms(String permString) {
|
||||
String permStringChopped = permString.replace(".*", "");
|
||||
|
||||
String[] seperated = permStringChopped.split("\\.");
|
||||
String parentPermString = getParentPerm(seperated);
|
||||
if (parentPermString == null) {
|
||||
addToRootPermission("*", permStringChopped);
|
||||
addToRootPermission("*.*", permStringChopped);
|
||||
return;
|
||||
}
|
||||
Permission parentPermission = this.plugin.getServer().getPluginManager().getPermission(parentPermString);
|
||||
// Creat parent and grandparents
|
||||
if (parentPermission == null) {
|
||||
parentPermission = new Permission(parentPermString);
|
||||
this.plugin.getServer().getPluginManager().addPermission(parentPermission);
|
||||
|
||||
this.addToParentPerms(parentPermString);
|
||||
}
|
||||
// Create actual perm.
|
||||
Permission actualPermission = this.plugin.getServer().getPluginManager().getPermission(permString);
|
||||
// Extra check just to make sure the actual one is added
|
||||
if (actualPermission == null) {
|
||||
|
||||
actualPermission = new Permission(permString);
|
||||
this.plugin.getServer().getPluginManager().addPermission(actualPermission);
|
||||
}
|
||||
if (!parentPermission.getChildren().containsKey(permString)) {
|
||||
parentPermission.getChildren().put(actualPermission.getName(), true);
|
||||
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(parentPermission);
|
||||
}
|
||||
}
|
||||
|
||||
private void addToRootPermission(String rootPerm, String permStringChopped) {
|
||||
Permission rootPermission = this.plugin.getServer().getPluginManager().getPermission(rootPerm);
|
||||
if (rootPermission == null) {
|
||||
rootPermission = new Permission(rootPerm);
|
||||
this.plugin.getServer().getPluginManager().addPermission(rootPermission);
|
||||
}
|
||||
rootPermission.getChildren().put(permStringChopped + ".*", true);
|
||||
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(rootPermission);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the given permission was 'multiverse.core.tp.self', this would return 'multiverse.core.tp.*'.
|
||||
*
|
||||
* @param seperated
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getParentPerm(String[] seperated) {
|
||||
if (seperated.length == 1) {
|
||||
return null;
|
||||
}
|
||||
String returnString = "";
|
||||
for (int i = 0; i < seperated.length - 1; i++) {
|
||||
returnString += seperated[i] + ".";
|
||||
}
|
||||
return returnString + "*";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class MVPlayerSession {
|
||||
|
||||
private Player player; // Player holder, may be unnecessary.
|
||||
|
||||
private Long teleportLast = 0L; // Timestamp for the Players last Portal Teleportation.
|
||||
private Long messageLast = 0L; // Timestamp for the Players last Alert Message.
|
||||
|
||||
private Configuration config; // Configuration file to find out Cooldown Timers.
|
||||
|
||||
public MVPlayerSession(Player player, Configuration config, MultiverseCore multiVerseCore) {
|
||||
this.player = player;
|
||||
this.config = config;
|
||||
// this.bedSpawn = null;
|
||||
}
|
||||
|
||||
/** Update the Teleport time. */
|
||||
public void teleport() {
|
||||
this.teleportLast = (new Date()).getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Grab whether the cooldown on Portal use has expired or not.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean getTeleportable() {
|
||||
Long time = (new Date()).getTime();
|
||||
if ((time - this.teleportLast) > this.config.getInt("portalcooldown", 5000)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.CannonDestination;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.TravelAgent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MVTravelAgent implements TravelAgent {
|
||||
private MVDestination destination;
|
||||
private MultiverseCore core;
|
||||
private Player player;
|
||||
|
||||
public MVTravelAgent(MultiverseCore multiverseCore, MVDestination d, Player p) {
|
||||
this.destination = d;
|
||||
this.core = multiverseCore;
|
||||
this.player = p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TravelAgent setSearchRadius(int radius) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSearchRadius() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TravelAgent setCreationRadius(int radius) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCreationRadius() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getCanCreatePortal() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCanCreatePortal(boolean create) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location findOrCreate(Location location) {
|
||||
return this.getSafeLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location findPortal(Location location) {
|
||||
return this.getSafeLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPortal(Location location) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private Location getSafeLocation() {
|
||||
// At this time, these can never use the velocity.
|
||||
if (this.destination instanceof CannonDestination) {
|
||||
this.core.log(Level.FINE, "Using Stock TP method. This cannon will have 0 velocity");
|
||||
}
|
||||
SafeTTeleporter teleporter = new SafeTTeleporter(this.core);
|
||||
Location newLoc = this.destination.getLocation(this.player);
|
||||
if (this.destination.useSafeTeleporter()) {
|
||||
newLoc = teleporter.getSafeLocation(this.player, this.destination);
|
||||
}
|
||||
if (newLoc == null) {
|
||||
return this.player.getLocation();
|
||||
}
|
||||
return newLoc;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.permissions.Permission;
|
||||
|
||||
public class PermissionTools {
|
||||
private MultiverseCore plugin;
|
||||
|
||||
public PermissionTools(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void addToParentPerms(String permString) {
|
||||
String permStringChopped = permString.replace(".*", "");
|
||||
|
||||
String[] seperated = permStringChopped.split("\\.");
|
||||
String parentPermString = getParentPerm(seperated);
|
||||
if (parentPermString == null) {
|
||||
addToRootPermission("*", permStringChopped);
|
||||
addToRootPermission("*.*", permStringChopped);
|
||||
return;
|
||||
}
|
||||
Permission parentPermission = this.plugin.getServer().getPluginManager().getPermission(parentPermString);
|
||||
// Creat parent and grandparents
|
||||
if (parentPermission == null) {
|
||||
parentPermission = new Permission(parentPermString);
|
||||
this.plugin.getServer().getPluginManager().addPermission(parentPermission);
|
||||
|
||||
this.addToParentPerms(parentPermString);
|
||||
}
|
||||
// Create actual perm.
|
||||
Permission actualPermission = this.plugin.getServer().getPluginManager().getPermission(permString);
|
||||
// Extra check just to make sure the actual one is added
|
||||
if (actualPermission == null) {
|
||||
|
||||
actualPermission = new Permission(permString);
|
||||
this.plugin.getServer().getPluginManager().addPermission(actualPermission);
|
||||
}
|
||||
if (!parentPermission.getChildren().containsKey(permString)) {
|
||||
parentPermission.getChildren().put(actualPermission.getName(), true);
|
||||
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(parentPermission);
|
||||
}
|
||||
}
|
||||
|
||||
private void addToRootPermission(String rootPerm, String permStringChopped) {
|
||||
Permission rootPermission = this.plugin.getServer().getPluginManager().getPermission(rootPerm);
|
||||
if (rootPermission == null) {
|
||||
rootPermission = new Permission(rootPerm);
|
||||
this.plugin.getServer().getPluginManager().addPermission(rootPermission);
|
||||
}
|
||||
rootPermission.getChildren().put(permStringChopped + ".*", true);
|
||||
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(rootPermission);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the given permission was 'multiverse.core.tp.self', this would return 'multiverse.core.tp.*'.
|
||||
*
|
||||
* @param separatedPermissionString The array of a dot separated perm string.
|
||||
*
|
||||
* @return The dot separated parent permission string.
|
||||
*/
|
||||
private String getParentPerm(String[] separatedPermissionString) {
|
||||
if (separatedPermissionString.length == 1) {
|
||||
return null;
|
||||
}
|
||||
String returnString = "";
|
||||
for (int i = 0; i < separatedPermissionString.length - 1; i++) {
|
||||
returnString += separatedPermissionString[i] + ".";
|
||||
}
|
||||
return returnString + "*";
|
||||
}
|
||||
}
|
||||
+24
-17
@@ -1,15 +1,21 @@
|
||||
package com.onarandombox.utils;
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class PurgeWorlds {
|
||||
|
||||
@@ -19,14 +25,12 @@ public class PurgeWorlds {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronizes the given world with it's settings
|
||||
*/
|
||||
public void purgeWorlds(CommandSender sender, List<MVWorld> worlds) {
|
||||
/** Synchronizes the given world with it's settings */
|
||||
public void purgeWorlds(CommandSender sender, List<MultiverseWorld> worlds) {
|
||||
if (worlds == null || worlds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (MVWorld world : worlds) {
|
||||
for (MultiverseWorld world : worlds) {
|
||||
this.purgeWorld(sender, world);
|
||||
}
|
||||
}
|
||||
@@ -37,16 +41,16 @@ public class PurgeWorlds {
|
||||
* @param sender
|
||||
* @param world
|
||||
*/
|
||||
public void purgeWorld(CommandSender sender, MVWorld world) {
|
||||
public void purgeWorld(CommandSender sender, MultiverseWorld world) {
|
||||
if (world == null) {
|
||||
return;
|
||||
}
|
||||
ArrayList<String> allMobs = new ArrayList<String>(world.getAnimalList());
|
||||
allMobs.addAll(world.getMonsterList());
|
||||
purgeWorld(sender, world, allMobs, !world.allowAnimalSpawning(), !world.allowMonsterSpawning());
|
||||
purgeWorld(sender, world, allMobs, !world.canAnimalsSpawn(), !world.canMonstersSpawn());
|
||||
}
|
||||
|
||||
public void purgeWorld(CommandSender sender, MVWorld mvworld, List<String> thingsToKill, boolean negateAnimals, boolean negateMonsters) {
|
||||
public void purgeWorld(CommandSender sender, MultiverseWorld mvworld, List<String> thingsToKill, boolean negateAnimals, boolean negateMonsters) {
|
||||
if (mvworld == null) {
|
||||
return;
|
||||
}
|
||||
@@ -65,7 +69,6 @@ public class PurgeWorlds {
|
||||
// Check against Animals
|
||||
if (this.killCreature(mvworld, e, thingsToKill, negateAnimals)) {
|
||||
entitiesKilled++;
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -74,7 +77,7 @@ public class PurgeWorlds {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean killCreature(MVWorld mvworld, Entity e, List<String> creaturesToKill, boolean negate) {
|
||||
private boolean killCreature(MultiverseWorld mvworld, Entity e, List<String> creaturesToKill, boolean negate) {
|
||||
String entityName = e.toString().replaceAll("Craft", "").toUpperCase();
|
||||
if (e instanceof Squid || e instanceof Animals) {
|
||||
if (creaturesToKill.contains(entityName) || creaturesToKill.contains("ALL") || creaturesToKill.contains("ANIMALS")) {
|
||||
@@ -99,18 +102,22 @@ public class PurgeWorlds {
|
||||
* @param e
|
||||
* @param creaturesToKill
|
||||
* @param negate
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean killMonster(MVWorld mvworld, Entity e, List<String> creaturesToKill, boolean negate) {
|
||||
private boolean killMonster(MultiverseWorld mvworld, Entity e, List<String> creaturesToKill, boolean negate) {
|
||||
String entityName = e.toString().replaceAll("Craft", "").toUpperCase();
|
||||
if (e instanceof Slime || e instanceof Monster || e instanceof Ghast) {
|
||||
this.plugin.log(Level.FINER, "Looking at a monster: " + e);
|
||||
if (creaturesToKill.contains(entityName) || creaturesToKill.contains("ALL") || creaturesToKill.contains("MONSTERS")) {
|
||||
if (!negate) {
|
||||
this.plugin.log(Level.FINEST, "Removing a monster: " + e);
|
||||
e.remove();
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (negate) {
|
||||
this.plugin.log(Level.FINEST, "Removing a monster: " + e);
|
||||
e.remove();
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,327 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class SafeTTeleporter {
|
||||
|
||||
MultiverseCore plugin;
|
||||
|
||||
BlockSafety bs;
|
||||
|
||||
public SafeTTeleporter(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
this.bs = new BlockSafety();
|
||||
}
|
||||
|
||||
public Location getSafeLocation(Location l) {
|
||||
return this.getSafeLocation(l, 6, 9);
|
||||
}
|
||||
|
||||
public Location getSafeLocation(Location l, int tolerance, int radius) {
|
||||
|
||||
// Check around the player first in a configurable radius:
|
||||
// TODO: Make this configurable
|
||||
Location safe = checkAboveAndBelowLocation(l, tolerance, radius);
|
||||
if (safe != null) {
|
||||
safe.setX(safe.getBlockX() + .5);
|
||||
safe.setZ(safe.getBlockZ() + .5);
|
||||
this.plugin.log(Level.FINE, "Hey! I found one: " + LocationManipulation.strCoordsRaw(safe));
|
||||
} else {
|
||||
this.plugin.log(Level.FINE, "Uh oh! No safe place found!");
|
||||
}
|
||||
return safe;
|
||||
}
|
||||
|
||||
private Location checkAboveAndBelowLocation(Location l, int tolerance, int radius) {
|
||||
|
||||
// Tolerance must be an even number:
|
||||
if (tolerance % 2 != 0) {
|
||||
tolerance += 1;
|
||||
}
|
||||
// We want half of it, so we can go up and down
|
||||
tolerance /= 2;
|
||||
this.plugin.log(Level.FINER, "Given Location of: " + LocationManipulation.strCoordsRaw(l));
|
||||
this.plugin.log(Level.FINER, "Checking +-" + tolerance + " with a radius of " + radius);
|
||||
|
||||
// For now this will just do a straight up block.
|
||||
Location locToCheck = l.clone();
|
||||
// Check the main level
|
||||
Location safe = this.checkAroundLocation(locToCheck, radius);
|
||||
if (safe != null) {
|
||||
return safe;
|
||||
}
|
||||
// We've already checked zero right above this.
|
||||
int currentLevel = 1;
|
||||
while (currentLevel <= tolerance) {
|
||||
// Check above
|
||||
locToCheck = l.clone();
|
||||
locToCheck.add(0, currentLevel, 0);
|
||||
safe = this.checkAroundLocation(locToCheck, radius);
|
||||
if (safe != null) {
|
||||
return safe;
|
||||
}
|
||||
|
||||
// Check below
|
||||
locToCheck = l.clone();
|
||||
locToCheck.subtract(0, currentLevel, 0);
|
||||
safe = this.checkAroundLocation(locToCheck, radius);
|
||||
if (safe != null) {
|
||||
return safe;
|
||||
}
|
||||
currentLevel++;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* For my crappy algorithm, radius MUST be odd
|
||||
*
|
||||
* @param l
|
||||
* @param diameter
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private Location checkAroundLocation(Location l, int diameter) {
|
||||
if (diameter % 2 == 0) {
|
||||
diameter += 1;
|
||||
}
|
||||
Location checkLoc = l.clone();
|
||||
|
||||
// Start at 3, the min diameter around a block
|
||||
int loopcounter = 3;
|
||||
while (loopcounter <= diameter) {
|
||||
boolean foundSafeArea = checkAroundSpecificDiameter(checkLoc, loopcounter);
|
||||
// If a safe area was found:
|
||||
if (foundSafeArea) {
|
||||
// Return the checkLoc, it is the safe location.
|
||||
return checkLoc;
|
||||
}
|
||||
// Otherwise, let's reset our location
|
||||
checkLoc = l.clone();
|
||||
// And increment the radius
|
||||
loopcounter += 2;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean checkAroundSpecificDiameter(Location checkLoc, int circle) {
|
||||
// Adjust the circle to get how many blocks to step out.
|
||||
// A radius of 3 makes the block step 1
|
||||
// A radius of 5 makes the block step 2
|
||||
// A radius of 7 makes the block step 3
|
||||
// ...
|
||||
int adjustedCircle = ((circle - 1) / 2);
|
||||
checkLoc.add(adjustedCircle, 0, 0);
|
||||
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
|
||||
return true;
|
||||
}
|
||||
// Now we go to the right that adjustedCircle many
|
||||
for (int i = 0; i < adjustedCircle; i++) {
|
||||
checkLoc.add(0, 0, 1);
|
||||
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Then down adjustedCircle *2
|
||||
for (int i = 0; i < adjustedCircle * 2; i++) {
|
||||
checkLoc.add(-1, 0, 0);
|
||||
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Then left adjustedCircle *2
|
||||
for (int i = 0; i < adjustedCircle * 2; i++) {
|
||||
checkLoc.add(0, 0, -1);
|
||||
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Then up Then left adjustedCircle *2
|
||||
for (int i = 0; i < adjustedCircle * 2; i++) {
|
||||
checkLoc.add(1, 0, 0);
|
||||
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Then finish up by doing adjustedCircle - 1
|
||||
for (int i = 0; i < adjustedCircle - 1; i++) {
|
||||
checkLoc.add(0, 0, 1);
|
||||
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely teleport the entity to the MVDestination. This will perform checks to see if the place is safe, and if
|
||||
* it's not, will adjust the final destination accordingly.
|
||||
*
|
||||
* @param teleporter Person who performed the teleport command.
|
||||
* @param teleportee Entity to teleport
|
||||
* @param d Destination to teleport them to
|
||||
*
|
||||
* @return true for success, false for failure
|
||||
*/
|
||||
public boolean safelyTeleport(CommandSender teleporter, Entity teleportee, MVDestination d) {
|
||||
if (d instanceof InvalidDestination) {
|
||||
this.plugin.log(Level.FINER, "Entity tried to teleport to an invalid destination");
|
||||
return false;
|
||||
}
|
||||
|
||||
Location safeLoc = d.getLocation(teleportee);
|
||||
if (d.useSafeTeleporter()) {
|
||||
safeLoc = this.getSafeLocation(teleportee, d);
|
||||
}
|
||||
|
||||
if (safeLoc != null) {
|
||||
if (teleportee.teleport(safeLoc)) {
|
||||
if (!d.getVelocity().equals(new Vector(0, 0, 0))) {
|
||||
teleportee.setVelocity(d.getVelocity());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely teleport the entity to the Location. This may perform checks to
|
||||
* see if the place is safe, and if
|
||||
* it's not, will adjust the final destination accordingly.
|
||||
*
|
||||
* @param teleporter Person who issued the teleport command.
|
||||
* @param teleportee Entity to teleport.
|
||||
* @param location Location to teleport them to.
|
||||
* @param safely Should the destination be checked for safety before teleport?
|
||||
*
|
||||
* @return true for success, false for failure.
|
||||
*/
|
||||
public boolean safelyTeleport(CommandSender teleporter, Entity teleportee, Location location, boolean safely) {
|
||||
if (safely) {
|
||||
location = this.getSafeLocation(location);
|
||||
}
|
||||
|
||||
if (location != null) {
|
||||
if (teleportee.teleport(location)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a safe location for the entity to spawn at.
|
||||
*
|
||||
* @param e The entity to spawn
|
||||
* @param d The MVDestination to take the entity to.
|
||||
*
|
||||
* @return A new location to spawn the entity at.
|
||||
*/
|
||||
public Location getSafeLocation(Entity e, MVDestination d) {
|
||||
Location l = d.getLocation(e);
|
||||
if (this.bs.playerCanSpawnHereSafely(l)) {
|
||||
plugin.log(Level.FINE, "The first location you gave me was safe.");
|
||||
return l;
|
||||
}
|
||||
if (e instanceof Minecart) {
|
||||
Minecart m = (Minecart) e;
|
||||
if (!this.bs.canSpawnCartSafely(m)) {
|
||||
return null;
|
||||
}
|
||||
} else if (e instanceof Vehicle) {
|
||||
Vehicle v = (Vehicle) e;
|
||||
if (!this.bs.canSpawnVehicleSafely(v)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Location safeLocation = this.getSafeLocation(l);
|
||||
if (safeLocation != null) {
|
||||
// Add offset to account for a vehicle on dry land!
|
||||
if (e instanceof Minecart && !this.bs.isEntitiyOnTrack(e, safeLocation)) {
|
||||
safeLocation.setY(safeLocation.getBlockY() + .5);
|
||||
this.plugin.log(Level.FINER, "Player was inside a minecart. Offsetting Y location.");
|
||||
}
|
||||
this.plugin.log(Level.FINE, "Had to look for a bit, but I found a safe place for ya!");
|
||||
return safeLocation;
|
||||
}
|
||||
if (e instanceof Player) {
|
||||
Player p = (Player) e;
|
||||
this.plugin.getMessaging().sendMessage(p, "No safe locations found!");
|
||||
this.plugin.log(Level.FINER, "No safe location found for " + p.getName());
|
||||
} else if (e.getPassenger() instanceof Player) {
|
||||
Player p = (Player) e.getPassenger();
|
||||
this.plugin.getMessaging().sendMessage(p, "No safe locations found!");
|
||||
this.plugin.log(Level.FINER, "No safe location found for " + p.getName());
|
||||
}
|
||||
this.plugin.log(Level.FINE, "Sorry champ, you're basically trying to teleport into a minefield. I should just kill you now.");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static Location findPortalBlockNextTo(Location l) {
|
||||
Block b = l.getWorld().getBlockAt(l);
|
||||
Location foundLocation = null;
|
||||
|
||||
if (b.getRelative(BlockFace.NORTH).getType() == Material.PORTAL) {
|
||||
foundLocation = getCloserBlock(l, b.getRelative(BlockFace.NORTH).getLocation(), foundLocation);
|
||||
}
|
||||
if (b.getRelative(BlockFace.SOUTH).getType() == Material.PORTAL) {
|
||||
foundLocation = getCloserBlock(l, b.getRelative(BlockFace.SOUTH).getLocation(), foundLocation);
|
||||
}
|
||||
if (b.getRelative(BlockFace.EAST).getType() == Material.PORTAL) {
|
||||
foundLocation = getCloserBlock(l, b.getRelative(BlockFace.EAST).getLocation(), foundLocation);
|
||||
}
|
||||
if (b.getRelative(BlockFace.WEST).getType() == Material.PORTAL) {
|
||||
foundLocation = getCloserBlock(l, b.getRelative(BlockFace.WEST).getLocation(), foundLocation);
|
||||
}
|
||||
return foundLocation;
|
||||
}
|
||||
|
||||
private static Location getCloserBlock(Location source, Location blockA, Location blockB) {
|
||||
// If B wasn't given, return a.
|
||||
if (blockB == null) {
|
||||
return blockA;
|
||||
}
|
||||
// Center our calculations
|
||||
blockA.add(.5,0,.5);
|
||||
blockB.add(.5,0,.5);
|
||||
|
||||
// Retrieve the distance to the normalized blocks
|
||||
double testA = source.distance(blockA);
|
||||
double testB = source.distance(blockB);
|
||||
|
||||
// Compare and return
|
||||
if(testA <= testB) {
|
||||
return blockA;
|
||||
}
|
||||
return blockB;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
|
||||
public class SpoutInterface {
|
||||
private SpoutManager spoutManager;
|
||||
|
||||
public SpoutInterface() {
|
||||
this.spoutManager = SpoutManager.getInstance();
|
||||
}
|
||||
|
||||
public SpoutManager getManager() {
|
||||
return this.spoutManager;
|
||||
}
|
||||
}
|
||||
+9
-1
@@ -1,4 +1,11 @@
|
||||
package com.onarandombox.utils;
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -81,6 +88,7 @@ public class UpdateChecker {
|
||||
* Convert the given Version String to a Normalised Version String so we can compare it.
|
||||
*
|
||||
* @param version
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String normalisedVersion(String version) {
|
||||
@@ -0,0 +1,423 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Public facing API to add/remove Multiverse worlds.
|
||||
*
|
||||
* @author fernferret, Rigby90
|
||||
*/
|
||||
public class WorldManager implements MVWorldManager {
|
||||
private MultiverseCore plugin;
|
||||
private PurgeWorlds worldPurger;
|
||||
private HashMap<String, MultiverseWorld> worlds;
|
||||
private FileConfiguration configWorlds = null;
|
||||
|
||||
public WorldManager(MultiverseCore core) {
|
||||
|
||||
this.plugin = core;
|
||||
this.worlds = new HashMap<String, MultiverseWorld>();
|
||||
this.worldPurger = new PurgeWorlds(this.plugin);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean addWorld(String name, Environment env, String seedString, String generator) {
|
||||
plugin.log(Level.FINE, "Adding world with: " + name + ", " + env.toString() + ", " + seedString + ", " + generator);
|
||||
Long seed = null;
|
||||
WorldCreator c = new WorldCreator(name);
|
||||
if (seedString != null && seedString.length() > 0) {
|
||||
try {
|
||||
seed = Long.parseLong(seedString);
|
||||
} catch (NumberFormatException numberformatexception) {
|
||||
seed = (long) seedString.hashCode();
|
||||
}
|
||||
c.seed(seed);
|
||||
}
|
||||
|
||||
|
||||
// TODO: Use the fancy kind with the commandSender
|
||||
c.generator(generator);
|
||||
c.environment(env);
|
||||
|
||||
World world = null;
|
||||
if (seed != null) {
|
||||
if (generator != null) {
|
||||
this.plugin.log(Level.INFO, "Loading World & Settings - '" + name + "' - " + env + " with seed: " + seed + " & Custom Generator: " + generator);
|
||||
} else {
|
||||
this.plugin.log(Level.INFO, "Loading World & Settings - '" + name + "' - " + env + " with seed: " + seed);
|
||||
}
|
||||
} else {
|
||||
if (generator != null) {
|
||||
this.plugin.log(Level.INFO, "Loading World & Settings - '" + name + "' - " + env + " & Custom Generator: " + generator);
|
||||
} else {
|
||||
this.plugin.log(Level.INFO, "Loading World & Settings - '" + name + "' - " + env);
|
||||
}
|
||||
}
|
||||
try {
|
||||
world = c.createWorld();
|
||||
} catch (Exception e) {
|
||||
this.plugin.log(Level.SEVERE, "The world '" + name + "' could NOT be loaded because it contains errors!");
|
||||
this.plugin.log(Level.SEVERE, "Try using Chukster to repair your world! '" + name + "'");
|
||||
this.plugin.log(Level.SEVERE, "http://forums.bukkit.org/threads/admin-chunkster.8186/");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (world == null) {
|
||||
this.plugin.log(Level.SEVERE, "Failed to Create/Load the world '" + name + "'");
|
||||
return false;
|
||||
}
|
||||
|
||||
MultiverseWorld mvworld = new MVWorld(world, this.configWorlds, this.plugin, seed, generator);
|
||||
this.worldPurger.purgeWorld(null, mvworld);
|
||||
this.worlds.put(name, mvworld);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a given Plugin generator string exists.
|
||||
*
|
||||
* @param generator The name of the generator plugin. This should be something like CleanRoomGenerator.
|
||||
*
|
||||
* @return True if the plugin exists and is enabled, false if not.
|
||||
*/
|
||||
private boolean pluginExists(String generator) {
|
||||
Plugin plugin = this.plugin.getServer().getPluginManager().getPlugin(generator);
|
||||
return plugin != null && plugin.isEnabled();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public ChunkGenerator getChunkGenerator(String generator, String generatorID, String worldName) {
|
||||
if (generator == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Plugin plugin = this.plugin.getServer().getPluginManager().getPlugin(generator);
|
||||
if (plugin == null) {
|
||||
return null;
|
||||
} else {
|
||||
return plugin.getDefaultWorldGenerator(worldName, generatorID);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the world from the Multiverse list and from the config
|
||||
*
|
||||
* @param name The name of the world to remove
|
||||
*
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
public boolean removeWorldFromConfig(String name) {
|
||||
if (this.configWorlds.get("worlds." + name) != null) {
|
||||
unloadWorld(name);
|
||||
this.plugin.log(Level.INFO, "World '" + name + "' was removed from config.yml");
|
||||
this.configWorlds.set("worlds." + name, null);
|
||||
|
||||
this.saveWorldsConfig();
|
||||
return true;
|
||||
} else {
|
||||
this.plugin.log(Level.INFO, "World '" + name + "' was already removed from config.yml");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean unloadWorld(String name) {
|
||||
|
||||
if (this.worlds.containsKey(name)) {
|
||||
this.worlds.remove(name);
|
||||
this.plugin.log(Level.INFO, "World '" + name + "' was unloaded from memory.");
|
||||
this.unloadWorldFromBukkit(name, true);
|
||||
return true;
|
||||
} else if (this.plugin.getServer().getWorld(name) != null) {
|
||||
this.plugin.log(Level.WARNING, "Hmm Multiverse does not know about this world but it's still loaded in memory.");
|
||||
this.plugin.log(Level.WARNING, "To be on the safe side, you should import it then try unloading again...");
|
||||
} else {
|
||||
this.plugin.log(Level.INFO, "The world " + name + " was already unloaded/did not exist.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean loadWorld(String name) {
|
||||
// Check if the World is already loaded
|
||||
if (this.worlds.containsKey(name)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Grab all the Worlds from the Config.
|
||||
Set<String> worldKeys = this.configWorlds.getConfigurationSection("worlds").getKeys(false);
|
||||
|
||||
// Check that the list is not null and that the config contains the world
|
||||
if ((worldKeys != null) && (worldKeys.contains(name))) {
|
||||
// Grab the initial values from the config file.
|
||||
String environment = this.configWorlds.getString("worlds." + name + ".environment", "NORMAL"); // Grab the Environment as a String.
|
||||
String seedString = this.configWorlds.getString("worlds." + name + ".seed", "");
|
||||
String generatorString = this.configWorlds.getString("worlds." + name + ".generator");
|
||||
|
||||
addWorld(name, this.plugin.getEnvFromString(environment), seedString, generatorString);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Boolean deleteWorld(String name) {
|
||||
|
||||
if (this.plugin.getServer().getWorld(name) == null) {
|
||||
// We can only delete loaded worlds
|
||||
return false;
|
||||
}
|
||||
removeWorldFromConfig(name);
|
||||
try {
|
||||
File serverFolder = new File(this.plugin.getDataFolder().getAbsolutePath()).getParentFile().getParentFile();
|
||||
File worldFile = new File(serverFolder.getAbsolutePath() + File.separator + name);
|
||||
if (name.equalsIgnoreCase("plugins")) {
|
||||
this.plugin.log(Level.SEVERE, "Really? Are you high? This would delete your plugins folder. Luckily the MV2 devs are crazy smart or you're server would be ended...");
|
||||
return false;
|
||||
} else if (name.toLowerCase().contains("plugins")) {
|
||||
this.plugin.log(Level.SEVERE, "I'm sorry, did you mean to type: 'rm plugins" + File.separator + "Essential*'? I could do that for you if you'd like...");
|
||||
return false;
|
||||
} else if (name.contains("..")) {
|
||||
this.plugin.log(Level.SEVERE, "Uh yea... No way i'm going to delete a parent directory for you. You can go do 'rm -rf *.*' on your own time...");
|
||||
return false;
|
||||
} else if (name.equals(".")) {
|
||||
this.plugin.log(Level.SEVERE, "Why on earth would you want to use Multiverse-Core to delete your Bukkit Server! How many beers have you had tonight... Give the keys to a friend.");
|
||||
return false;
|
||||
} else if (!worldFile.isDirectory()) {
|
||||
this.plugin.log(Level.SEVERE, "C'mon man... Really?!?! Multiverse-Core is a great way to get players from A to B, but not to manage your files. To delete this file type:");
|
||||
this.plugin.log(Level.SEVERE, "stop");
|
||||
this.plugin.log(Level.SEVERE, "rm " + worldFile.getAbsolutePath());
|
||||
return false;
|
||||
}
|
||||
plugin.log(Level.FINER, "deleteWorld(): worldFile: " + worldFile.getAbsolutePath());
|
||||
boolean deletedWorld = FileUtils.deleteFolder(worldFile);
|
||||
if (deletedWorld) {
|
||||
this.plugin.log(Level.INFO, "World " + name + " was DELETED.");
|
||||
} else {
|
||||
this.plugin.log(Level.SEVERE, "World " + name + " was NOT deleted.");
|
||||
this.plugin.log(Level.SEVERE, "Are you sure the folder " + name + " exists?");
|
||||
this.plugin.log(Level.SEVERE, "Please check your file permissions on " + name);
|
||||
}
|
||||
return deletedWorld;
|
||||
} catch (Exception e) {
|
||||
this.plugin.log(Level.SEVERE, "Hrm, something didn't go as planned. Here's an exception for ya.");
|
||||
this.plugin.log(Level.SEVERE, "You can go politely explain your situation in #multiverse on esper.net");
|
||||
this.plugin.log(Level.SEVERE, "But from here, it looks like your folder is oddly named.");
|
||||
this.plugin.log(Level.SEVERE, "This world has been removed from Multiverse-Core so your best bet is to go delete the folder by hand. Sorry.");
|
||||
System.out.print(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload a world from Bukkit
|
||||
*
|
||||
* @param name Name of the world to unload
|
||||
* @param safely Perform this safely. Set to True to save world files before unloading.
|
||||
*
|
||||
* @return True if the world was unloaded, false if not.
|
||||
*/
|
||||
private boolean unloadWorldFromBukkit(String name, boolean safely) {
|
||||
this.removePlayersFromWorld(name);
|
||||
return this.plugin.getServer().unloadWorld(name, safely);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void removePlayersFromWorld(String name) {
|
||||
World w = this.plugin.getServer().getWorld(name);
|
||||
if (w != null) {
|
||||
World safeWorld = this.plugin.getServer().getWorlds().get(0);
|
||||
List<Player> ps = w.getPlayers();
|
||||
SafeTTeleporter teleporter = this.plugin.getTeleporter();
|
||||
for (Player p : ps) {
|
||||
// We're removing players forcefully from a world, they'd BETTER spawn safely.
|
||||
teleporter.safelyTeleport(null, p, safeWorld.getSpawnLocation(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Collection<MultiverseWorld> getMVWorlds() {
|
||||
return this.worlds.values();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public MultiverseWorld getMVWorld(String name) {
|
||||
if (this.worlds.containsKey(name)) {
|
||||
return this.worlds.get(name);
|
||||
}
|
||||
return this.getMVWorldByAlias(name);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public MultiverseWorld getMVWorld(World world) {
|
||||
if (world != null) {
|
||||
return this.getMVWorld(world.getName());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link MVWorld} if it exists, and null if it does not. This will search ONLY alias.
|
||||
*
|
||||
* @param alias The alias of the world to get.
|
||||
*
|
||||
* @return A {@link MVWorld} or null.
|
||||
*/
|
||||
private MultiverseWorld getMVWorldByAlias(String alias) {
|
||||
for (MultiverseWorld w : this.worlds.values()) {
|
||||
if (w.getAlias().equalsIgnoreCase(alias)) {
|
||||
return w;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean isMVWorld(String name) {
|
||||
return (this.worlds.containsKey(name) || isMVWorldAlias(name));
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean isMVWorld(World world) {
|
||||
return world != null && this.isMVWorld(world.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* This method ONLY checks the alias of each world.
|
||||
*
|
||||
* @param alias The alias of the world to check.
|
||||
*
|
||||
* @return True if the world exists, false if not.
|
||||
*/
|
||||
private boolean isMVWorldAlias(String alias) {
|
||||
for (MultiverseWorld w : this.worlds.values()) {
|
||||
if (w.getAlias().equalsIgnoreCase(alias)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void loadWorlds(boolean forceLoad) {
|
||||
// Basic Counter to count how many Worlds we are loading.
|
||||
int count = 0;
|
||||
// Grab all the Worlds from the Config.
|
||||
if (this.configWorlds.getConfigurationSection("worlds") == null) {
|
||||
this.configWorlds.createSection("worlds");
|
||||
try {
|
||||
this.configWorlds.save(new File(this.plugin.getDataFolder(), "worlds.yml"));
|
||||
} catch (IOException e) {
|
||||
this.plugin.log(Level.SEVERE, "Failed to save worlds.yml. Please check your file permissions.");
|
||||
}
|
||||
}
|
||||
Set<String> worldKeys = this.configWorlds.getConfigurationSection("worlds").getKeys(false);
|
||||
|
||||
// Force the worlds to be loaded, ie don't just load new worlds.
|
||||
if (forceLoad) {
|
||||
// Remove all world permissions.
|
||||
Permission allAccess = this.plugin.getServer().getPluginManager().getPermission("multiverse.access.*");
|
||||
Permission allExempt = this.plugin.getServer().getPluginManager().getPermission("multiverse.exempt.*");
|
||||
for (MultiverseWorld w : this.worlds.values()) {
|
||||
// Remove this world from the master list
|
||||
if (allAccess != null) {
|
||||
allAccess.getChildren().remove(w.getAccessPermission().getName());
|
||||
}
|
||||
if (allExempt != null) {
|
||||
allExempt.getChildren().remove(w.getAccessPermission().getName());
|
||||
}
|
||||
this.plugin.getServer().getPluginManager().removePermission(w.getAccessPermission().getName());
|
||||
this.plugin.getServer().getPluginManager().removePermission(w.getExemptPermission().getName());
|
||||
}
|
||||
// Recalc the all permission
|
||||
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(allAccess);
|
||||
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(allExempt);
|
||||
this.worlds.clear();
|
||||
}
|
||||
|
||||
// Check that the list is not null.
|
||||
if (worldKeys != null) {
|
||||
for (String worldKey : worldKeys) {
|
||||
// Check if the World is already loaded within the Plugin.
|
||||
if (this.worlds.containsKey(worldKey)) {
|
||||
continue;
|
||||
}
|
||||
// Grab the initial values from the config file.
|
||||
String environment = this.configWorlds.getString("worlds." + worldKey + ".environment", "NORMAL"); // Grab the Environment as a String.
|
||||
String seedString = this.configWorlds.getString("worlds." + worldKey + ".seed", "");
|
||||
|
||||
String generatorString = this.configWorlds.getString("worlds." + worldKey + ".generator");
|
||||
|
||||
addWorld(worldKey, this.plugin.getEnvFromString(environment), seedString, generatorString);
|
||||
|
||||
// Increment the world count
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
// Simple Output to the Console to show how many Worlds were loaded.
|
||||
this.plugin.log(Level.INFO, count + " - World(s) loaded.");
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public PurgeWorlds getWorldPurger() {
|
||||
return this.worldPurger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the config from a file.
|
||||
*
|
||||
* @param file The file to load.
|
||||
*
|
||||
* @return A loaded configuration.
|
||||
*/
|
||||
public FileConfiguration loadWorldConfig(File file) {
|
||||
this.configWorlds = YamlConfiguration.loadConfiguration(file);
|
||||
return this.configWorlds;
|
||||
}
|
||||
|
||||
public boolean saveWorldsConfig() {
|
||||
try {
|
||||
this.configWorlds.save(new File(this.plugin.getDataFolder(), "worlds.yml"));
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
this.plugin.log(Level.SEVERE, "Could not save worlds.yml. Please check your settings.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
/**
|
||||
* Multiverse 2
|
||||
* Currently Unused
|
||||
*/
|
||||
|
||||
public class WorldProperty<T> {
|
||||
private Class<T> type;
|
||||
private Object value;
|
||||
|
||||
public WorldProperty(Class<T> type, Object two, String propertyLocation) {
|
||||
this.type = type;
|
||||
this.value = two;
|
||||
}
|
||||
|
||||
public Class<T> getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public boolean setValue(Object value) {
|
||||
if (value.getClass().equals(this.type)) {
|
||||
this.value = value;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,82 +1,21 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.util.logging.Formatter;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
/**
|
||||
* Dummy class to make old MV Plugins not explode.
|
||||
* If this loads, the user WILL get a severe telling them to update said plugin!
|
||||
* WILL BE DELETED ON 11/1/11
|
||||
*/
|
||||
|
||||
public class DebugLog {
|
||||
|
||||
private FileHandler fh;
|
||||
private Logger log;
|
||||
|
||||
/**
|
||||
* Creates a new debug logger.
|
||||
*
|
||||
* @param logger The name of the logger.
|
||||
* @param file The file to log to.
|
||||
*/
|
||||
@Deprecated
|
||||
public class DebugLog extends com.onarandombox.MultiverseCore.utils.DebugLog {
|
||||
public DebugLog(String logger, String file) {
|
||||
this.log = Logger.getLogger(logger);
|
||||
|
||||
try {
|
||||
this.fh = new FileHandler(file, true);
|
||||
this.log.setUseParentHandlers(false);
|
||||
for (Handler handler : this.log.getHandlers()) {
|
||||
this.log.removeHandler(handler);
|
||||
}
|
||||
this.log.addHandler(this.fh);
|
||||
this.log.setLevel(Level.ALL);
|
||||
this.fh.setFormatter(new LogFormatter());
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a message at a certain level
|
||||
*
|
||||
* @param level
|
||||
* @param msg
|
||||
*/
|
||||
public void log(Level level, String msg) {
|
||||
this.log.log(level, msg);
|
||||
}
|
||||
|
||||
private class LogFormatter extends Formatter {
|
||||
private final SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@Override
|
||||
public String format(LogRecord record) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Throwable ex = record.getThrown();
|
||||
|
||||
builder.append(this.date.format(record.getMillis()));
|
||||
builder.append(" [");
|
||||
builder.append(record.getLevel().getLocalizedName().toUpperCase());
|
||||
builder.append("] ");
|
||||
builder.append(record.getMessage());
|
||||
builder.append('\n');
|
||||
|
||||
if (ex != null) {
|
||||
StringWriter writer = new StringWriter();
|
||||
ex.printStackTrace(new PrintWriter(writer));
|
||||
builder.append(writer);
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
this.fh.close();
|
||||
super(logger, file);
|
||||
}
|
||||
}
|
||||
@@ -1,46 +1,28 @@
|
||||
package com.onarandombox.utils;
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
package com.onarandombox.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
public class DestinationFactory {
|
||||
private MultiverseCore plugin;
|
||||
private Map<String, Class<? extends MVDestination>> destList;
|
||||
/**
|
||||
* Dummy class to make old MV Plugins not explode.
|
||||
* If this loads, the user WILL get a severe telling them to update said plugin!
|
||||
* WILL BE DELETED ON 11/1/11
|
||||
*/
|
||||
|
||||
@Deprecated
|
||||
public class DestinationFactory extends com.onarandombox.MultiverseCore.destination.DestinationFactory {
|
||||
public DestinationFactory(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
this.destList = new HashMap<String, Class<? extends MVDestination>>();
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
public MVDestination getDestination(String dest) {
|
||||
String idenChar = "";
|
||||
if (dest.split(":").length > 1) {
|
||||
idenChar = dest.split(":")[0];
|
||||
}
|
||||
|
||||
if (this.destList.containsKey(idenChar)) {
|
||||
Class<? extends MVDestination> myClass = this.destList.get(idenChar);
|
||||
try {
|
||||
MVDestination mydest = myClass.newInstance();
|
||||
if (!mydest.isThisType((MultiverseCore) this.plugin, dest)) {
|
||||
return new InvalidDestination();
|
||||
}
|
||||
mydest.setDestination(this.plugin, dest);
|
||||
return mydest;
|
||||
} catch (InstantiationException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public MVDestination getDestination(String destination) {
|
||||
return new InvalidDestination();
|
||||
}
|
||||
|
||||
public boolean registerDestinationType(Class<? extends MVDestination> c, String identifier) {
|
||||
if (this.destList.containsKey(identifier)) {
|
||||
return false;
|
||||
}
|
||||
this.destList.put(identifier, c);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.onarandombox.utils;
|
||||
|
||||
public class FancyHeader implements FancyText {
|
||||
|
||||
private FancyColorScheme colors;
|
||||
private String text;
|
||||
|
||||
public FancyHeader(String text, FancyColorScheme scheme) {
|
||||
this.colors = scheme;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFancyText() {
|
||||
return colors.getHeader() + "--- " + text + colors.getHeader() + " ---";
|
||||
}
|
||||
|
||||
public void appendText(String string) {
|
||||
this.text += string;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.onarandombox.utils;
|
||||
|
||||
public interface FancyText {
|
||||
public String getFancyText();
|
||||
}
|
||||
@@ -1,59 +1,164 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.utils;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class InvalidDestination implements MVDestination {
|
||||
/**
|
||||
* Dummy class to make old MV Plugins not explode.
|
||||
* If this loads, the user WILL get a severe telling them to update said plugin!
|
||||
* WILL BE DELETED ON 11/1/11
|
||||
*/
|
||||
|
||||
@Deprecated
|
||||
public class InvalidDestination implements com.onarandombox.utils.MVDestination {
|
||||
/**
|
||||
* Returns the identifier or prefix that is required for this destination.
|
||||
* <p/>
|
||||
* Portals have a prefix of "p" for example and OpenWarp (third party plugin) uses "ow". This is derived from a
|
||||
* hash and cannot have duplicate values. Read that as your plugin cannot use 'p' because it's already used.
|
||||
* Please check the wiki when adding a custom destination!
|
||||
*
|
||||
* @return The identifier or prefix that is required for this destination.
|
||||
*/
|
||||
@Override
|
||||
public String getIdentifer() {
|
||||
return "i";
|
||||
public String getIdentifier() {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows you to determine if a Destination is valid for the type it thinks it is.
|
||||
* <p/>
|
||||
* An example of this would be the exact destination. A valid string would be: e:0,0,0 where an invalid one would
|
||||
* be e:1:2:3. The first string would return true the second would return false. This is simply a convenience
|
||||
* method
|
||||
* and does not even NEED to be called, but it's highly recommended if you're teleporting, but it's mainly for
|
||||
* Multiverse Internal use.
|
||||
*
|
||||
* @param plugin The plugin who the type belongs to.
|
||||
* @param destination The destination string. ex: p:MyPortal:nw
|
||||
*
|
||||
* @return True if the destination is valid, false if not.
|
||||
*/
|
||||
@Override
|
||||
public boolean isThisType(JavaPlugin plugin, String dest) {
|
||||
return false;
|
||||
public boolean isThisType(JavaPlugin plugin, String destination) {
|
||||
return false; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the location a specific entity will spawn at.
|
||||
* <p/>
|
||||
* To just retrieve the location as it is stored you can just pass null, but be warned some destinations may return
|
||||
* null back to you if you do this. It is always safer to pass an actual entity. This is used so things like
|
||||
* minecarts can be teleported.
|
||||
* <p/>
|
||||
* Do not forget to use {@link #getVelocity()} as destinations can use this too!
|
||||
*
|
||||
* @param entity The entity to be teleported.
|
||||
*
|
||||
* @return The location of the entity.
|
||||
*/
|
||||
@Override
|
||||
public Location getLocation(Entity e) {
|
||||
return null;
|
||||
public Location getLocation(Entity entity) {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the velocity vector for this destination.
|
||||
* <p/>
|
||||
* Plugins wishing to fully support MVDestinations MUST implement this.
|
||||
*
|
||||
* @return A vector representing the speed/direction the player should travel when arriving
|
||||
*/
|
||||
@Override
|
||||
public Vector getVelocity() {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the destination string.
|
||||
* <p/>
|
||||
* This should be used when you want to tell this destination object about a change in where it should take people.
|
||||
* The destination param should be match the result from {@link #getIdentifier()}. A valid example would be that if
|
||||
* {@link #getIdentifier()} returned "ow" our destination string could be "ow:TownCenter" but could not be
|
||||
* "p:HomePortal"
|
||||
*
|
||||
* @param plugin The plugin who the type belongs to.
|
||||
* @param destination The destination string. ex: p:MyPortal:nw
|
||||
*/
|
||||
@Override
|
||||
public void setDestination(JavaPlugin plugin, String destination) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the destination is valid and players will be taken to it.
|
||||
* <p/>
|
||||
* Even if destinations are in the correct format (p:MyPortal) MyPortal may not exist, and therefore this would
|
||||
* return false.
|
||||
*
|
||||
* @return True if the destination is valid; false if not.
|
||||
*/
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDestination(JavaPlugin plugin, String dest) {
|
||||
// Nothing needed, it's invalid.
|
||||
return false; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives you a general friendly description of the type of destination.
|
||||
* <p/>
|
||||
* For example, the PlayerDestination sets this to "Player". You can use this to show where a player will be taken.
|
||||
*
|
||||
* @return A friendly string description of the type of destination.
|
||||
*/
|
||||
@Override
|
||||
public String getType() {
|
||||
return ChatColor.RED + "Invalid Destination";
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives you a specific name of the destination.
|
||||
* <p/>
|
||||
* For example, the PlayerDestination sets this to The Player's Name.
|
||||
*
|
||||
* @return A friendly string stating the name of the destination.
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return ChatColor.RED + "Invalid Destination";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "i:Invalid Destination";
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the permissions string required to go here.
|
||||
* <p/>
|
||||
* ex: multiverse.access.world
|
||||
* <p/>
|
||||
* NOTE: This is NOT the permission to use the teleport command.
|
||||
*
|
||||
* @return the permissions string required to go here.
|
||||
*/
|
||||
@Override
|
||||
public String getRequiredPermission() {
|
||||
return null;
|
||||
}
|
||||
public Vector getVelocity() {
|
||||
return new Vector(0,0,0);
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the Multiverse SafeTeleporter be used?
|
||||
* <p/>
|
||||
* If not, MV will blindly take people to the location specified.
|
||||
*
|
||||
* @return True if the SafeTeleporter will be used, false if not.
|
||||
*/
|
||||
@Override
|
||||
public boolean useSafeTeleporter() {
|
||||
return false; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,18 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.utils;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
/**
|
||||
* Dummy class to make old MV Plugins not explode.
|
||||
* If this loads, the user WILL get a severe telling them to update said plugin!
|
||||
* WILL BE DELETED ON 11/1/11
|
||||
*/
|
||||
|
||||
public interface MVDestination {
|
||||
public String getIdentifer();
|
||||
public boolean isThisType(JavaPlugin plugin, String dest);
|
||||
public Location getLocation(Entity e);
|
||||
public boolean isValid();
|
||||
public void setDestination(JavaPlugin plugin, String dest);
|
||||
public String getType();
|
||||
public String getName();
|
||||
public String toString();
|
||||
public String getRequiredPermission();
|
||||
public Vector getVelocity();
|
||||
@Deprecated
|
||||
public interface MVDestination extends com.onarandombox.MultiverseCore.api.MVDestination {
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
package com.onarandombox.utils;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
public class WorldDestination implements MVDestination {
|
||||
private boolean isValid;
|
||||
private MVWorld world;
|
||||
float yaw = -1;
|
||||
String direction = "";
|
||||
|
||||
@Override
|
||||
public String getIdentifer() {
|
||||
return "w";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isThisType(JavaPlugin plugin, String destination) {
|
||||
String[] items = destination.split(":");
|
||||
if (items.length > 3) {
|
||||
return false;
|
||||
}
|
||||
if (items.length == 1 && ((MultiverseCore) plugin).isMVWorld(items[0])) {
|
||||
// This case is: world
|
||||
return true;
|
||||
}
|
||||
if (items.length == 2 && ((MultiverseCore) plugin).isMVWorld(items[0])) {
|
||||
// This case is: world:n
|
||||
return true;
|
||||
} else if (items[0].equalsIgnoreCase("w") && ((MultiverseCore) plugin).isMVWorld(items[1])) {
|
||||
// This case is: w:world
|
||||
// and w:world:ne
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation(Entity e) {
|
||||
Location spawnLoc = this.world.getCBWorld().getSpawnLocation();
|
||||
if (this.yaw >= 0) {
|
||||
// Only modify the yaw if its set.
|
||||
spawnLoc.setYaw(this.yaw);
|
||||
|
||||
}
|
||||
spawnLoc.add(.5, 0, .5);
|
||||
return spawnLoc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return this.isValid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDestination(JavaPlugin plugin, String dest) {
|
||||
String[] items = dest.split(":");
|
||||
if (items.length > 3) {
|
||||
isValid = false;
|
||||
return;
|
||||
}
|
||||
if (items.length == 1 && ((MultiverseCore) plugin).isMVWorld(items[0])) {
|
||||
isValid = true;
|
||||
this.world = ((MultiverseCore) plugin).getMVWorld(items[0]);
|
||||
return;
|
||||
}
|
||||
if (items.length == 2 && ((MultiverseCore) plugin).isMVWorld(items[0])) {
|
||||
this.world = ((MultiverseCore) plugin).getMVWorld(items[0]);
|
||||
this.yaw = LocationManipulation.getYaw(items[1]);
|
||||
return;
|
||||
}
|
||||
if (items[0].equalsIgnoreCase("w") && ((MultiverseCore) plugin).isMVWorld(items[1])) {
|
||||
this.world = ((MultiverseCore) plugin).getMVWorld(items[1]);
|
||||
isValid = true;
|
||||
if (items.length == 3) {
|
||||
this.yaw = LocationManipulation.getYaw(items[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "World";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.world.getColoredWorldString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if(direction.length() > 0 && yaw >= 0) {
|
||||
return this.world.getCBWorld().getName() + ":"+this.direction;
|
||||
}
|
||||
return this.world.getCBWorld().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequiredPermission() {
|
||||
return "multiverse.access."+this.world.getName();
|
||||
}
|
||||
public Vector getVelocity() {
|
||||
return new Vector(0,0,0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
/**
|
||||
* Dummy class to make old MV Plugins not explode.
|
||||
* If this loads, the user WILL get a severe telling them to update said plugin!
|
||||
* WILL BE DELETED ON 11/1/11
|
||||
*/
|
||||
@Deprecated
|
||||
public class WorldManager extends com.onarandombox.MultiverseCore.utils.WorldManager {
|
||||
public WorldManager(MultiverseCore core) {
|
||||
super(core);
|
||||
}
|
||||
}
|
||||
Loaded 100 of 103 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user