Add projects including README.md(s), .gitignore(s) and the actual project files.
Signed-off-by: Michael Fabian Dirks <michael.dirks@project-kube.de>
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
/target/
|
||||
|
||||
# We shouldn't upload our private information.
|
||||
/build.xml
|
||||
@@ -0,0 +1,8 @@
|
||||
Inception (CraftBukkit)
|
||||
==========
|
||||
|
||||
A plugin for the CraftBukkit Minecraft server software, allowing you to virtually make worlds higher than 256 blocks. It does this by mirroring changes in one world to the other, caching them if the chunk in the other world is not loaded.
|
||||
|
||||
License
|
||||
=======
|
||||
Inception (CraftBukkit) by Michael Fabian Dirks is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/.
|
||||
@@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.RealityBends</groupId>
|
||||
<artifactId>Inception</artifactId>
|
||||
<name>Inception</name>
|
||||
<version>1.6.2-R0.1</version>
|
||||
<url>http://realitybends.de/</url>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Creative Commons BY-NC-SA</name>
|
||||
<url>http://creativecommons.org/licenses/by-nc-sa/3.0/de/</url>
|
||||
</license>
|
||||
</licenses>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/Xaymar/${project.name}.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:Xaymar/${project.name}.git</developerConnection>
|
||||
<url>https://github.com/Xaymar/${project.name}</url>
|
||||
</scm>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>org.mcstats.bukkit:metrics:R7</artifact>
|
||||
<includes>
|
||||
<include>**/*.class</include>
|
||||
<include>**/*.xml</include>
|
||||
</includes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<configuration>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>bukkit-repo</id>
|
||||
<url>http://repo.bukkit.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>Plugin Metrics</id>
|
||||
<url>http://repo.mcstats.org/content/repositories/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.6.2-R0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.6.2-R0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project-shared-configuration>
|
||||
<!--
|
||||
This file contains additional configuration written by modules in the NetBeans IDE.
|
||||
The configuration is intended to be shared among all the users of project and
|
||||
therefore it is assumed to be part of version control checkout.
|
||||
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
|
||||
-->
|
||||
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
|
||||
<!--
|
||||
Properties that influence various parts of the IDE, especially code formatting and the like.
|
||||
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
|
||||
That way multiple projects can share the same settings (useful for formatting rules for example).
|
||||
Any value defined here will override the pom.xml file value but is only applicable to the current project.
|
||||
-->
|
||||
<org-netbeans-modules-editor-indent.CodeStyle.usedProfile>project</org-netbeans-modules-editor-indent.CodeStyle.usedProfile>
|
||||
<org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab>4</org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab>
|
||||
<org-netbeans-modules-editor-indent.CodeStyle.project.tab-size>4</org-netbeans-modules-editor-indent.CodeStyle.project.tab-size>
|
||||
<org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width>4</org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width>
|
||||
<org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs>true</org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs>
|
||||
<org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width>80</org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width>
|
||||
<org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap>none</org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapExtendsImplementsKeyword>WRAP_ALWAYS</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapExtendsImplementsKeyword>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLineAfterJavadocReturnTag>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLineAfterJavadocReturnTag>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLineAfterJavadocParameterDescriptions>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLineAfterJavadocParameterDescriptions>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAssignment>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAssignment>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignJavadocExceptionDescriptions>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignJavadocExceptionDescriptions>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineParenthesized>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineParenthesized>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.allowConvertToStaticStarImport>false</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.allowConvertToStaticStarImport>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineThrows>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineThrows>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTernaryOp>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTernaryOp>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineArrayInit>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineArrayInit>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapThrowsKeyword>WRAP_ALWAYS</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapThrowsKeyword>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignJavadocParameterDescriptions>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignJavadocParameterDescriptions>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineDisjunctiveCatchTypes>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineDisjunctiveCatchTypes>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.allowConvertToStarImport>false</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.allowConvertToStarImport>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineImplements>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineImplements>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineCallArgs>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineCallArgs>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineBinaryOp>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineBinaryOp>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAnnotationArgs>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAnnotationArgs>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.preserveNewLinesInComments>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.preserveNewLinesInComments>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignJavadocReturnDescription>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignJavadocReturnDescription>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTryResources>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTryResources>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineFor>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineFor>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.generateParagraphTagOnBlankLines>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.generateParagraphTagOnBlankLines>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineMethodParams>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineMethodParams>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.importGroupsOrder>*</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.importGroupsOrder>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesAfterMethods>1</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesAfterMethods>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapOneLineComment>false</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapOneLineComment>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapCommentText>false</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapCommentText>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaces-per-tab>4</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaces-per-tab>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapEnumConstants>WRAP_ALWAYS</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapEnumConstants>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.tab-size>4</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.tab-size>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width>4</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.expand-tabs>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.expand-tabs>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.absoluteLabelIndent>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.absoluteLabelIndent>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.text-limit-width>80</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.text-limit-width>
|
||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.text-line-wrap>none</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.text-line-wrap>
|
||||
</properties>
|
||||
</project-shared-configuration>
|
||||
@@ -0,0 +1,129 @@
|
||||
<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>
|
||||
|
||||
<!-- Project information -->
|
||||
<groupId>de.RealityBends</groupId>
|
||||
<artifactId>Inception</artifactId>
|
||||
<name>Inception</name>
|
||||
<version>1.6.2-R0.1</version>
|
||||
<url>http://realitybends.de/</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<!-- License -->
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Creative Commons BY-NC-SA</name>
|
||||
<url>http://creativecommons.org/licenses/by-nc-sa/3.0/de/</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<!-- Source code -->
|
||||
<scm>
|
||||
<developerConnection>scm:git:git@github.com:Xaymar/${project.name}.git</developerConnection>
|
||||
<connection>scm:git:git://github.com/Xaymar/${project.name}.git</connection>
|
||||
<url>https://github.com/Xaymar/${project.name}</url>
|
||||
</scm>
|
||||
|
||||
<!-- Repositories -->
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>bukkit-repo</id>
|
||||
<url>http://repo.bukkit.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>Plugin Metrics</id>
|
||||
<url>http://repo.mcstats.org/content/repositories/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<!-- Dependencies -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.6.2-R0.1</version>
|
||||
<scope>provided</scope>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.6.2-R0.1</version>
|
||||
<scope>provided</scope>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mcstats.bukkit</groupId>
|
||||
<artifactId>metrics</artifactId>
|
||||
<version>R7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- Build -->
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Compile plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Resources plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Shade plugin-->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>org.mcstats.bukkit:metrics:R7</artifact>
|
||||
<includes>
|
||||
<include>**/*.class</include>
|
||||
<include>**/*.xml</include>
|
||||
</includes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- JAR creation plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<configuration>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
</project>
|
||||
@@ -0,0 +1,784 @@
|
||||
/* Authors: Xaymar
|
||||
* Copyright: 2012-2013 (c) Inception Plugin Team.
|
||||
* License: CC BY-SA 3.0
|
||||
* Inception by Inception Plugin Team is licensed under a
|
||||
* Creative Commons Attribution-ShareAlike 3.0 Unported
|
||||
* License.
|
||||
*/
|
||||
package de.RealityBends.Inception;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
import de.RealityBends.Inception.World.Handler;
|
||||
import de.RealityBends.Inception.World.OverlapEvents;
|
||||
import de.RealityBends.Inception.World.OverlapDelayBlocks;
|
||||
import de.RealityBends.Inception.World.Cache;
|
||||
import de.RealityBends.Inception.World.CacheQueries;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class Plugin
|
||||
extends JavaPlugin
|
||||
implements Listener {
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Variables">
|
||||
private File oDataDirectory;
|
||||
private File oWorldDirectory;
|
||||
private HashMap<World, Handler> oWorldHandlerMap;
|
||||
private FixedMetadataValue oNoFallDamageMetadata = new FixedMetadataValue(this, true);
|
||||
private boolean[] tOverlappingDelayedActionArr = new boolean[256];
|
||||
private PluginMetrics oPluginMetrics;
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Enable and Disable">
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getLogger().info("[Core] Enabling...");
|
||||
|
||||
// Create directory references and create nonexisting folders.
|
||||
oDataDirectory = this.getDataFolder();
|
||||
if (!oDataDirectory.exists()) {
|
||||
getLogger().fine("Plugin directory is missing, creating...");
|
||||
if (!oDataDirectory.mkdirs()) {
|
||||
getLogger().severe("Failed to create plugin directory.");
|
||||
}
|
||||
}
|
||||
|
||||
oWorldDirectory = new File(oDataDirectory + File.separator + "per-world");
|
||||
if (!oWorldDirectory.exists()) {
|
||||
getLogger().fine("Per-world directory is missing, creating...");
|
||||
if (!oWorldDirectory.mkdirs()) {
|
||||
getLogger().severe("Failed to create per-world directory.");
|
||||
}
|
||||
}
|
||||
|
||||
// Create configuration file references and load the configuration.
|
||||
oPluginConfigurationFile = new File(oDataDirectory + File.separator + "config.yml");
|
||||
oPluginConfiguration = new YamlConfiguration();
|
||||
oDefaultConfigurationFile = new File(oDataDirectory + File.separator + "default.yml");
|
||||
oDefaultConfiguration = new YamlConfiguration();
|
||||
try {
|
||||
loadConfiguration();
|
||||
} catch (IOException | InvalidConfigurationException ex) {
|
||||
getLogger().log(Level.SEVERE, "Failed to load configuration:", ex);
|
||||
}
|
||||
try {
|
||||
loadDefaultConfiguration();
|
||||
} catch (IOException | InvalidConfigurationException ex) {
|
||||
getLogger().log(Level.SEVERE, "Failed to load default configuration:", ex);
|
||||
}
|
||||
|
||||
// Register our global event handler
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
|
||||
// Create and fill the array of blocks that need delayed action.
|
||||
for (OverlapDelayBlocks oDCB : OverlapDelayBlocks.values()) {
|
||||
tOverlappingDelayedActionArr[oDCB.getTypeId()] = true;
|
||||
}
|
||||
|
||||
// Enable the Cache Database.
|
||||
if (tCacheEnabled) {
|
||||
enableCache();
|
||||
}
|
||||
|
||||
// Create a World <-> WorldHandler HashMap for later use.
|
||||
oWorldHandlerMap = new HashMap<>();
|
||||
for (World oWorld : getServer().getWorlds()) {
|
||||
Handler oNewHandler = new Handler(this, oWorld);
|
||||
oWorldHandlerMap.put(oWorld, oNewHandler);
|
||||
oNewHandler.onEnable();
|
||||
}
|
||||
|
||||
// Initialize Plugin Metrics
|
||||
oPluginMetrics = new PluginMetrics(this);
|
||||
oPluginMetrics.onEnable();
|
||||
|
||||
getLogger().info("[Core] Done.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getLogger().info("[Core] Disabling...");
|
||||
|
||||
// Deinitialize Plugin Metrics
|
||||
oPluginMetrics.onDisable();
|
||||
oPluginMetrics = null;
|
||||
|
||||
// Unregister global event handler.
|
||||
org.bukkit.event.HandlerList.unregisterAll((Listener) this);
|
||||
|
||||
// Delete and unload world handlers and destroy the list of world handlers.
|
||||
for (World oWorld : getServer().getWorlds()) {
|
||||
oWorldHandlerMap.remove(oWorld).onDisable();
|
||||
}
|
||||
oWorldHandlerMap = null;
|
||||
|
||||
// Disable the OverlapEventsCache Database.
|
||||
disableCache();
|
||||
|
||||
// Cancel any remaining tasks.
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
|
||||
// Null remaining references.
|
||||
oDefaultConfiguration = null;
|
||||
oDefaultConfigurationFile = null;
|
||||
oPluginConfiguration = null;
|
||||
oPluginConfigurationFile = null;
|
||||
oWorldDirectory = null;
|
||||
oDataDirectory = null;
|
||||
|
||||
getLogger().info("[Core] Done.");
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Plugin Configuration">
|
||||
private File oPluginConfigurationFile;
|
||||
private YamlConfiguration oPluginConfiguration;
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Loading and Saving">
|
||||
private void loadConfiguration()
|
||||
throws IOException, InvalidConfigurationException {
|
||||
if (oPluginConfigurationFile.exists()) {
|
||||
oPluginConfiguration.load(oPluginConfigurationFile);
|
||||
}
|
||||
|
||||
tGeneralPredictPosition = oPluginConfiguration.getBoolean("General.PredictPosition", tGeneralPredictPosition);
|
||||
iGeneralTaskWaitTime = oPluginConfiguration.getInt("General.TaskWaitTime", iGeneralTaskWaitTime);
|
||||
tCacheEnabled = oPluginConfiguration.getBoolean("Cache.Enabled", tCacheEnabled);
|
||||
stCacheFile = oPluginConfiguration.getString("Cache.File", stCacheFile);
|
||||
iCacheRetryLimit = oPluginConfiguration.getInt("Cache.RetryLimit", iCacheRetryLimit);
|
||||
for (CacheQueries oQueryType : CacheQueries.values()) {
|
||||
oCacheQueryMap.put(oQueryType, oPluginConfiguration.getString("Cache.Query." + oQueryType.getName(), oQueryType.getDefaultQuery()));
|
||||
}
|
||||
|
||||
if (!oPluginConfigurationFile.exists()) {
|
||||
saveConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
private void saveConfiguration()
|
||||
throws IOException {
|
||||
oPluginConfiguration.options().header("Authors: Xaymar\n"
|
||||
+ "Copyright: 2012-2013 (c) Inception Plugin Team.\n"
|
||||
+ "License: CC BY-SA 3.0\n"
|
||||
+ " Inception by Inception Plugin Team is licensed under a\n"
|
||||
+ " Creative Commons Attribution-ShareAlike 3.0 Unported\n"
|
||||
+ " License.\n"
|
||||
+ "\n"
|
||||
+ "Node Explanation\n"
|
||||
+ "-------------------------------------------------------------------------------\n"
|
||||
+ "General: Container for general options.\n"
|
||||
+ " PredictPosition: Predict position of entities TaskWaitTime ticks ahead, so that Inception can run on high TaskWaitTime?\n"
|
||||
+ " TaskWaitTime: How long should the task wait before reprocessing?\n"
|
||||
+ "Cache: Things related to caching.\n"
|
||||
+ " Enabled: Enable caching of actions?\n"
|
||||
+ " File: Where should we store the cache?\n"
|
||||
+ " RetryLimit: How often should we retry to place a block if it failed?\n"
|
||||
+ " Query: Queries used in caching actions.\n"
|
||||
+ " CreateWorld: Query to create the table for a single world.\n"
|
||||
+ " DeleteWorld: Query to delete the table for a single world.\n"
|
||||
+ " PlaceEvent: Query to add a cached event.\n"
|
||||
+ " GetEvents: Query to get all events in a single chunk.\n"
|
||||
+ " RemoveEvent: Query to remove a cached event that has been processed.\n");
|
||||
|
||||
oPluginConfiguration.set("General.PredictPosition", tGeneralPredictPosition);
|
||||
oPluginConfiguration.set("General.TaskWaitTime", iGeneralTaskWaitTime);
|
||||
oPluginConfiguration.set("Cache.Enabled", tCacheEnabled);
|
||||
oPluginConfiguration.set("Cache.File", stCacheFile);
|
||||
oPluginConfiguration.set("Cache.RetryLimit", iCacheRetryLimit);
|
||||
for (CacheQueries oQueryType : CacheQueries.values()) {
|
||||
oPluginConfiguration.set("Cache.Query." + oQueryType.getName(), oQueryType.getDefaultQuery());
|
||||
}
|
||||
|
||||
oPluginConfiguration.save(oPluginConfigurationFile);
|
||||
}
|
||||
|
||||
//</editor-fold>
|
||||
//<editor-fold defaultstate="collapsed" desc="General.PredictPosition">
|
||||
private boolean tGeneralPredictPosition = true;
|
||||
|
||||
public boolean isGeneralPredictPositionEnabled() {
|
||||
return tGeneralPredictPosition;
|
||||
}
|
||||
|
||||
public void setGeneralPredictPositionEnabled(boolean ptGeneralPredictPosition) {
|
||||
tGeneralPredictPosition = ptGeneralPredictPosition;
|
||||
}
|
||||
//</editor-fold>
|
||||
//<editor-fold defaultstate="collapsed" desc="General.TaskWaitTime">
|
||||
|
||||
private int iGeneralTaskWaitTime = 5;
|
||||
|
||||
public int getGeneralTaskWaitTime() {
|
||||
return iGeneralTaskWaitTime;
|
||||
}
|
||||
|
||||
public void setGeneralTaskWaitTime(int piGeneralTaskWaitTime) {
|
||||
iGeneralTaskWaitTime = piGeneralTaskWaitTime;
|
||||
}
|
||||
//</editor-fold>
|
||||
//<editor-fold defaultstate="collapsed" desc="Cache.Enabled">
|
||||
|
||||
private boolean tCacheEnabled = true;
|
||||
|
||||
public boolean getCacheEnabled() {
|
||||
return tCacheEnabled;
|
||||
}
|
||||
|
||||
public void setCacheEnabled(boolean ptCacheEnabled) {
|
||||
tCacheEnabled = ptCacheEnabled;
|
||||
}
|
||||
//</editor-fold>
|
||||
//<editor-fold defaultstate="collapsed" desc="Cache.File">
|
||||
|
||||
private String stCacheFile = "." + File.separator + "Cache.db";
|
||||
|
||||
public String getCacheFile() {
|
||||
return stCacheFile;
|
||||
}
|
||||
|
||||
public void setCacheFile(String pstCacheFile) {
|
||||
stCacheFile = pstCacheFile;
|
||||
}
|
||||
//</editor-fold>
|
||||
//<editor-fold defaultstate="collapsed" desc="Cache.RetryLimit">
|
||||
|
||||
private int iCacheRetryLimit = 5;
|
||||
|
||||
public int getCacheRetryLimit() {
|
||||
return iCacheRetryLimit;
|
||||
}
|
||||
|
||||
public void setCacheRetryLimit(int piCacheRetryLimit) {
|
||||
iCacheRetryLimit = piCacheRetryLimit;
|
||||
}
|
||||
//</editor-fold>
|
||||
//<editor-fold defaultstate="collapsed" desc="Cache.Query.*">
|
||||
|
||||
private EnumMap<CacheQueries, String> oCacheQueryMap = new EnumMap<>(CacheQueries.class);
|
||||
|
||||
public String getCacheQuery(CacheQueries poQueryType) {
|
||||
return oCacheQueryMap.get(poQueryType);
|
||||
}
|
||||
|
||||
public void setCacheQuery(CacheQueries poQueryType, String pstQuery) {
|
||||
oCacheQueryMap.put(poQueryType, pstQuery);
|
||||
}
|
||||
//</editor-fold>
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Default Configuration">
|
||||
private File oDefaultConfigurationFile;
|
||||
private YamlConfiguration oDefaultConfiguration;
|
||||
|
||||
public void loadDefaultConfiguration()
|
||||
throws IOException, InvalidConfigurationException {
|
||||
if (oDefaultConfigurationFile.exists()) {
|
||||
oDefaultConfiguration.load(oDefaultConfigurationFile);
|
||||
initDefaultConfiguration();
|
||||
} else {
|
||||
saveDefaultConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
private void initDefaultConfiguration() {
|
||||
oDefaultConfiguration.set("World.Enabled", oDefaultConfiguration.getBoolean("World.Enabled", false));
|
||||
oDefaultConfiguration.set("World.SynchronizeWith", oDefaultConfiguration.getString("World.SynchronizeWith", ""));
|
||||
for (OverlapEvents oBlockEvent : OverlapEvents.values()) {
|
||||
oDefaultConfiguration.set("World.OverlapEvents." + oBlockEvent.getName(), oDefaultConfiguration.getBoolean("World.OverlapEvents." + oBlockEvent.getName(), false));
|
||||
}
|
||||
oDefaultConfiguration.set("Above.World", oDefaultConfiguration.getString("Above.World", ""));
|
||||
oDefaultConfiguration.set("Above.Teleport.Enabled", oDefaultConfiguration.getBoolean("Above.Teleport.Enabled", false));
|
||||
oDefaultConfiguration.set("Above.Teleport.From", oDefaultConfiguration.getInt("Above.Teleport.From", 247));
|
||||
oDefaultConfiguration.set("Above.Teleport.To", oDefaultConfiguration.getInt("Above.Teleport.To", 24));
|
||||
oDefaultConfiguration.set("Above.Teleport.Safe", oDefaultConfiguration.getBoolean("Above.Teleport.Safe", false));
|
||||
oDefaultConfiguration.set("Above.Teleport.Platform", oDefaultConfiguration.getBoolean("Above.Teleport.Platform", false));
|
||||
oDefaultConfiguration.set("Above.Teleport.EntityFilter", oDefaultConfiguration.getString("Above.Teleport.EntityFilter", "(Painting|EnderDragon|Lightning|Weather|ComplexEntityPart)"));
|
||||
oDefaultConfiguration.set("Above.Overlap.Enabled", oDefaultConfiguration.getBoolean("Above.Overlap.Enabled", false));
|
||||
oDefaultConfiguration.set("Above.Overlap.From", oDefaultConfiguration.getInt("Above.Overlap.From", 255));
|
||||
oDefaultConfiguration.set("Above.Overlap.To", oDefaultConfiguration.getInt("Above.Overlap.To", 0));
|
||||
oDefaultConfiguration.set("Above.Overlap.Layers", oDefaultConfiguration.getInt("Above.Overlap.Layers", 32));
|
||||
oDefaultConfiguration.set("Above.Overlap.SourceFilter", oDefaultConfiguration.getString("Above.Overlap.SourceFilter", ""));
|
||||
oDefaultConfiguration.set("Above.Overlap.TargetFilter", oDefaultConfiguration.getString("Above.Overlap.TargetFilter", ""));
|
||||
oDefaultConfiguration.set("Below.World", oDefaultConfiguration.getString("Below.World", ""));
|
||||
oDefaultConfiguration.set("Below.Teleport.Enabled", oDefaultConfiguration.getBoolean("Below.Teleport.Enabled", false));
|
||||
oDefaultConfiguration.set("Below.Teleport.From", oDefaultConfiguration.getInt("Below.Teleport.From", 8));
|
||||
oDefaultConfiguration.set("Below.Teleport.To", oDefaultConfiguration.getInt("Below.Teleport.To", 231));
|
||||
oDefaultConfiguration.set("Below.Teleport.Safe", oDefaultConfiguration.getBoolean("Below.Teleport.Safe", false));
|
||||
oDefaultConfiguration.set("Below.Teleport.PreventFalldamage", oDefaultConfiguration.getBoolean("Below.Teleport.PreventFalldamage", false));
|
||||
oDefaultConfiguration.set("Below.Teleport.EntityFilter", oDefaultConfiguration.getString("Below.Teleport.EntityFilter", "(Painting|EnderDragon|Lightning|Weather|ComplexEntityPart)"));
|
||||
oDefaultConfiguration.set("Below.Overlap.Enabled", oDefaultConfiguration.getBoolean("Below.Overlap.Enabled", false));
|
||||
oDefaultConfiguration.set("Below.Overlap.From", oDefaultConfiguration.getInt("Below.Overlap.From", 0));
|
||||
oDefaultConfiguration.set("Below.Overlap.To", oDefaultConfiguration.getInt("Below.Overlap.To", 255));
|
||||
oDefaultConfiguration.set("Below.Overlap.Layers", oDefaultConfiguration.getInt("Below.Overlap.Layers", 32));
|
||||
oDefaultConfiguration.set("Below.Overlap.SourceFilter", oDefaultConfiguration.getString("Below.Overlap.SourceFilter", ""));
|
||||
oDefaultConfiguration.set("Below.Overlap.TargetFilter", oDefaultConfiguration.getString("Below.Overlap.TargetFilter", ""));
|
||||
}
|
||||
|
||||
public void saveDefaultConfiguration()
|
||||
throws IOException {
|
||||
oDefaultConfiguration.options().header("Authors: Xaymar\n"
|
||||
+ "Copyright: 2012-2013 (c) Inception Plugin Team.\n"
|
||||
+ "License: CC BY-SA 3.0\n"
|
||||
+ " Inception by Inception Plugin Team is licensed under a\n"
|
||||
+ " Creative Commons Attribution-ShareAlike 3.0 Unported\n"
|
||||
+ " License.\n"
|
||||
+ "\n"
|
||||
+ "Title Address\n"
|
||||
+ "-------------------------------------------------------------------------------\n"
|
||||
+ "Entity Names: http://jd.bukkit.org/apidocs/org/bukkit/entity/EntityType.html\n"
|
||||
+ "Material Names: http://jd.bukkit.org/apidocs/org/bukkit/Material.html\n"
|
||||
+ "Regular Expressions: http://www.regular-expressions.info/refflavors.html\n"
|
||||
+ "\n"
|
||||
+ "Node Explanation\n"
|
||||
+ "-------------------------------------------------------------------------------\n"
|
||||
+ "World: \n"
|
||||
+ " Enabled: Is this WorldHandler enabled?\n"
|
||||
+ " SynchronizeWith: Should this world be time synchronized to another world?\n"
|
||||
+ " OverlapEvents: Events on which Overlapping can react.\n"
|
||||
+ " BlockPlace: Trigger when a block is placed.\n"
|
||||
+ " BlockBreak: Trigger when a block is broken.\n"
|
||||
+ " BlockBurn: Trigger when a block burns away.\n"
|
||||
+ " BlockFade: Trigger when a block fades away.\n"
|
||||
+ " BlockForm: Trigger when a block forms.\n"
|
||||
+ " BlockGrow: Trigger when a block grows.\n"
|
||||
+ " BlockSpread: Trigger when a block spreads.\n"
|
||||
+ " BlockFromTo: Trigger when a block 'moves' (liquids, buggy).\n"
|
||||
+ "Above: \n"
|
||||
+ " World: What world is above this one?\n"
|
||||
+ " Teleport: \n"
|
||||
+ " Enabled: Is teleporting enabled?\n"
|
||||
+ " From: From what layer (and above) should we teleport players?\n"
|
||||
+ " To: To what layer (and above) should we teleport players?\n"
|
||||
+ " Safe: Make the teleport upwards safe for players to breathe?\n"
|
||||
+ " Platform: Make the teleport upwards safe for players to stand?\n"
|
||||
+ " EntityFilter: A Regular Expression that matches all entities to be disallowed from teleporting. Matches by Class Name.\n"
|
||||
+ " Overlap: \n"
|
||||
+ " Enabled: Is overlapping enabled?\n"
|
||||
+ " From: From what layer in the above world should we start from?\n"
|
||||
+ " To: To what layer should these get copied?\n"
|
||||
+ " Layers: How many layers should get copied?\n"
|
||||
+ " SourceFilter: A Regular Expression that matches all unplacable materials while Overlapping. Matches by ID.\n"
|
||||
+ " TargetFilter: A Regular Expression that matches all unreplacable materials while Overlapping. Matches by ID.\n"
|
||||
+ "Below: \n"
|
||||
+ " World: What world is below this one?\n"
|
||||
+ " Teleport: \n"
|
||||
+ " Enabled: Is teleporting enabled?\n"
|
||||
+ " From: From what layer (and below) should we teleport players?\n"
|
||||
+ " To: To what layer (and below) should we teleport players?\n"
|
||||
+ " Safe: Make the teleport downwards safe for players?\n"
|
||||
+ " PreventFalldamage: Should Inception prevent falldamage for players?\n"
|
||||
+ " EntityFilter: A Regular Expression that matches all entities to be disallowed from teleporting. Matches by Class Name.\n"
|
||||
+ " Overlap: \n"
|
||||
+ " Enabled: Is overlapping enabled?\n"
|
||||
+ " From: From what layer in the above world should we start from?\n"
|
||||
+ " To: To what layer should these get copied?\n"
|
||||
+ " Layers: How many layers should get copied?\n"
|
||||
+ " SourceFilter: A Regular Expression that matches all unplacable materials while Overlapping. Matches by ID.\n"
|
||||
+ " TargetFilter: A Regular Expression that matches all unreplacable materials while Overlapping. Matches by ID.\n");
|
||||
|
||||
initDefaultConfiguration();
|
||||
|
||||
oDefaultConfiguration.save(oDefaultConfigurationFile);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Cache Database">
|
||||
protected boolean tCacheAvailable = false;
|
||||
private Cache oCacheDatabase;
|
||||
private HashMap<World, EnumMap<CacheQueries, PreparedStatement>> oCachePreparedQueryMap;
|
||||
|
||||
private void enableCache() {
|
||||
if (oCacheDatabase == null) {
|
||||
getLogger().fine("[Cache] Enabling...");
|
||||
|
||||
String stRealCacheFile = stCacheFile;
|
||||
if (stCacheFile.substring(0, 2).equals("." + File.separator)) {
|
||||
stRealCacheFile = oDataDirectory.getAbsolutePath() + File.separator + stCacheFile.substring(2);
|
||||
}
|
||||
|
||||
try {
|
||||
oCacheDatabase = new Cache(new File(stRealCacheFile));
|
||||
} catch (ClassNotFoundException ex) {
|
||||
getLogger().log(Level.SEVERE, "[Cache] No SQLite JDBC Driver available:", ex);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
oCacheDatabase.open();
|
||||
tCacheAvailable = true;
|
||||
|
||||
// Create a World <-> EnumMap<QueryTypes, PreparedStatement> Map for later use.
|
||||
oCachePreparedQueryMap = new HashMap<>();
|
||||
for (World oWorld : Bukkit.getWorlds()) {
|
||||
cacheInitializeWorld(oWorld);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
getLogger().severe("[Cache] Unexpected error while opening Database, see log file.");
|
||||
getLogger().finest("[Cache] " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
getLogger().info("[Cache] Enabled.");
|
||||
}
|
||||
|
||||
private void disableCache() {
|
||||
if (oCacheDatabase != null) {
|
||||
getLogger().fine("[Cache] Disabling...");
|
||||
|
||||
tCacheAvailable = false;
|
||||
oCachePreparedQueryMap.clear();
|
||||
oCachePreparedQueryMap = null;
|
||||
try {
|
||||
oCacheDatabase.close();
|
||||
} catch (SQLException ex) {
|
||||
getLogger().log(Level.SEVERE, "[Cache] Unexpected error while closing Database:", ex);
|
||||
}
|
||||
oCacheDatabase = null;
|
||||
|
||||
getLogger().info("[Cache] Disabled.");
|
||||
}
|
||||
}
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Prepared Statements">
|
||||
private void cacheInitializeWorld(World poWorld) {
|
||||
if (tCacheEnabled && tCacheAvailable) {
|
||||
String stEscapedWorldName = Utility.escapeForSQL(poWorld.getName());
|
||||
|
||||
// CreateWorld
|
||||
try {
|
||||
oCacheDatabase.execute(oCacheQueryMap.get(CacheQueries.CreateWorld).replace("{0}", stEscapedWorldName));
|
||||
} catch (SQLException ex) {
|
||||
getLogger().warning(" Failed to create Table, see log.");
|
||||
getLogger().finest("[Cache] [" + poWorld.getName() + "] " + ex.getMessage());
|
||||
}
|
||||
|
||||
EnumMap<CacheQueries, PreparedStatement> oCachePreparedStatementMap = new EnumMap<>(CacheQueries.class);
|
||||
for (CacheQueries oQueryType : CacheQueries.values()) {
|
||||
if (oQueryType.isPreparable()) {
|
||||
String stProperQuery = oCacheQueryMap.get(oQueryType).replace("{0}", stEscapedWorldName);
|
||||
|
||||
try {
|
||||
oCachePreparedStatementMap.put(oQueryType, oCacheDatabase.prepareStatement(stProperQuery));
|
||||
} catch (SQLException ex) {
|
||||
getLogger().warning("[Cache] [" + poWorld.getName() + "] Failed to create " + oQueryType.getName() + " Query, see log.");
|
||||
getLogger().finest("[Cache] [" + poWorld.getName() + "] " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
oCachePreparedQueryMap.put(poWorld, oCachePreparedStatementMap);
|
||||
}
|
||||
}
|
||||
|
||||
private PreparedStatement cacheGetPreparedStatement(World poWorld, CacheQueries oQueryType) {
|
||||
if (tCacheEnabled && tCacheAvailable) {
|
||||
EnumMap<CacheQueries, PreparedStatement> oCachePreparedStatementMap = oCachePreparedQueryMap.get(poWorld);
|
||||
|
||||
if (oCachePreparedStatementMap != null) {
|
||||
return oCachePreparedStatementMap.get(oQueryType);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void cacheDeinitializeWorld(World poWorld) {
|
||||
if (tCacheEnabled && tCacheAvailable) {
|
||||
if (oCachePreparedQueryMap.containsKey(poWorld)) {
|
||||
EnumMap<CacheQueries, PreparedStatement> oCachePreparedStatementMap = oCachePreparedQueryMap.get(poWorld);
|
||||
for (Map.Entry<CacheQueries, PreparedStatement> oMapEntry : oCachePreparedStatementMap.entrySet()) {
|
||||
try {
|
||||
oMapEntry.getValue().close();
|
||||
} catch (SQLException ex) {
|
||||
getLogger().warning("[Cache] [" + poWorld.getName() + "] Failed to close " + oMapEntry.getKey().getName() + " Query, see log.");
|
||||
getLogger().finest("[Cache] [" + poWorld.getName() + "] " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
oCachePreparedQueryMap.remove(poWorld);
|
||||
}
|
||||
}
|
||||
}
|
||||
//</editor-fold>
|
||||
//<editor-fold defaultstate="collapsed" desc="Queue Events">
|
||||
|
||||
public boolean cacheEvent(World poWorld, int piWorldX, int piWorldZ, short psWorldY, short psTypeId, byte pbData) {
|
||||
if (tCacheEnabled && tCacheAvailable) {
|
||||
try {
|
||||
PreparedStatement oWorldPS = cacheGetPreparedStatement(poWorld, CacheQueries.AddEvent);
|
||||
if (oWorldPS != null) {
|
||||
oWorldPS.setInt(1, (int) Math.floor(piWorldX / 16.0d));
|
||||
oWorldPS.setInt(2, (int) Math.floor(piWorldZ / 16.0d));
|
||||
oWorldPS.setByte(3, (byte) (piWorldX & 15));
|
||||
oWorldPS.setByte(4, (byte) (piWorldZ & 15));
|
||||
oWorldPS.setShort(5, psWorldY);
|
||||
oWorldPS.setByte(6, (byte) 0); // 0 = Block Event, 1 = Sign Event, 2 = Inventory Event
|
||||
oWorldPS.setString(7, String.valueOf(psTypeId) + "," + String.valueOf(pbData));
|
||||
return oWorldPS.execute();
|
||||
} else {
|
||||
getLogger().log(Level.SEVERE, "[Cache] Failed to queue Event: No PreparedStatement available.");
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
getLogger().warning("[Cache] Failed to cache Event.");
|
||||
getLogger().finest("[Cache] [" + poWorld.getName() + "] " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean cacheEvent(World poWorld, int piWorldX, int piWorldZ, short psWorldY, String pstSignLine0, String pstSignLine1, String pstSignLine2, String pstSignLine3) {
|
||||
if (tCacheEnabled && tCacheAvailable) {
|
||||
try {
|
||||
StringBuilder oSignData = new StringBuilder();
|
||||
oSignData.append(DatatypeConverter.printBase64Binary(pstSignLine0.getBytes())).append(",");
|
||||
oSignData.append(DatatypeConverter.printBase64Binary(pstSignLine1.getBytes())).append(",");
|
||||
oSignData.append(DatatypeConverter.printBase64Binary(pstSignLine2.getBytes())).append(",");
|
||||
oSignData.append(DatatypeConverter.printBase64Binary(pstSignLine3.getBytes()));
|
||||
|
||||
PreparedStatement oWorldPS = cacheGetPreparedStatement(poWorld, CacheQueries.AddEvent);
|
||||
oWorldPS.setInt(1, (int) Math.floor(piWorldX / 16.0d));
|
||||
oWorldPS.setInt(2, (int) Math.floor(piWorldZ / 16.0d));
|
||||
oWorldPS.setByte(3, (byte) (piWorldX & 15));
|
||||
oWorldPS.setByte(4, (byte) (piWorldZ & 15));
|
||||
oWorldPS.setShort(5, psWorldY);
|
||||
oWorldPS.setByte(6, (byte) 1); // 0 = Block Event, 1 = Sign Event, 2 = Inventory Event
|
||||
oWorldPS.setString(7, oSignData.toString());
|
||||
return oWorldPS.execute();
|
||||
} catch (SQLException ex) {
|
||||
getLogger().warning("[Cache] Failed to cache Event.");
|
||||
getLogger().finest("[Cache] [" + poWorld.getName() + "] " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//</editor-fold>
|
||||
//<editor-fold defaultstate="collapsed" desc="Event Workers">
|
||||
|
||||
class BlockEventWorker
|
||||
implements Runnable {
|
||||
|
||||
private JavaPlugin oPlugin;
|
||||
private World oWorld;
|
||||
private Chunk oChunk;
|
||||
private byte bX, bZ, bData;
|
||||
private short sY, sTypeId;
|
||||
private int iTries = 1, iMaxTries = 1;
|
||||
|
||||
public BlockEventWorker(JavaPlugin poPlugin, World poWorld, Chunk poChunk, byte pbX, byte pbZ, short psY, short psTypeId, byte pbData, int piMaxTries) {
|
||||
oPlugin = poPlugin;
|
||||
oWorld = poWorld;
|
||||
oChunk = poChunk;
|
||||
bX = pbX;
|
||||
bZ = pbZ;
|
||||
sY = psY;
|
||||
sTypeId = psTypeId;
|
||||
bData = pbData;
|
||||
iMaxTries = piMaxTries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Block oBlock = oChunk.getBlock(bX, sY, bZ);
|
||||
oBlock.setTypeIdAndData(sTypeId, bData, false);
|
||||
|
||||
// Retry iMaxTries times.
|
||||
if (iTries < iMaxTries && (oBlock.getTypeId() != sTypeId || oBlock.getData() != bData)) {
|
||||
iTries++; // Increase try counter.
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(oPlugin, this, 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SignEventWorker
|
||||
implements Runnable {
|
||||
|
||||
private JavaPlugin oPlugin;
|
||||
private World oWorld;
|
||||
private Chunk oChunk;
|
||||
private byte bX, bZ;
|
||||
private short sY;
|
||||
private String stLine0, stLine1, stLine2, stLine3;
|
||||
private int iTries = 1, iMaxTries = 1;
|
||||
|
||||
public SignEventWorker(JavaPlugin poPlugin, World poWorld, Chunk poChunk, byte pbX, byte pbZ, short psY, String pstLine0, String pstLine1, String pstLine2, String pstLine3, int piMaxTries) {
|
||||
oPlugin = poPlugin;
|
||||
oWorld = poWorld;
|
||||
oChunk = poChunk;
|
||||
bX = pbX;
|
||||
bZ = pbZ;
|
||||
sY = psY;
|
||||
stLine0 = pstLine0;
|
||||
stLine1 = pstLine1;
|
||||
stLine2 = pstLine2;
|
||||
stLine3 = pstLine3;
|
||||
iMaxTries = piMaxTries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
BlockState oBlockState = oChunk.getBlock(bX, sY, bZ).getState();
|
||||
if (oBlockState instanceof Sign) {
|
||||
Sign oSign = (Sign) oBlockState;
|
||||
|
||||
oSign.setLine(0, stLine0);
|
||||
oSign.setLine(1, stLine1);
|
||||
oSign.setLine(2, stLine2);
|
||||
oSign.setLine(3, stLine3);
|
||||
|
||||
// Retry iMaxTries times.
|
||||
if (iTries < iMaxTries && (stLine0.equals(oSign.getLine(0)) && stLine1.equals(oSign.getLine(1)) && stLine2.equals(oSign.getLine(2)) && stLine3.equals(oSign.getLine(3)))) {
|
||||
iTries++; // Increase try counter.
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(oPlugin, this, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//</editor-fold>
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Event Handlers">
|
||||
// Handle Inception command.
|
||||
@Override
|
||||
public boolean onCommand(CommandSender oSender, Command oCommand, String stLabel, String[] args) {
|
||||
Utility.SendMessage(oSender, "Running v" + getDescription().getVersion());
|
||||
return true;
|
||||
}
|
||||
|
||||
// Install a new WorldHandler when a world is loaded.
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onWorldLoad(WorldLoadEvent oEvent) {
|
||||
if (!oWorldHandlerMap.containsKey(oEvent.getWorld())) {
|
||||
World oWorld = oEvent.getWorld();
|
||||
|
||||
// Initialize the caching for this world.
|
||||
if (tCacheEnabled && tCacheAvailable) {
|
||||
cacheInitializeWorld(oWorld);
|
||||
}
|
||||
|
||||
// Create and enable a new WorldHandler.
|
||||
Handler oNewHandler = new Handler(this, oWorld);
|
||||
oNewHandler.onEnable();
|
||||
|
||||
// Put it into the World <-> WorldHandler map.
|
||||
oWorldHandlerMap.put(oWorld, oNewHandler);
|
||||
}
|
||||
}
|
||||
|
||||
// Uninstall the installed WorldHandler when a world is unloaded.
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onWorldUnload(WorldUnloadEvent oEvent) {
|
||||
if (oWorldHandlerMap.containsKey(oEvent.getWorld())) {
|
||||
// Deinitialize the caching for this world.
|
||||
cacheDeinitializeWorld(oEvent.getWorld());
|
||||
|
||||
// Disable and remove the existing WorldHandler.
|
||||
oWorldHandlerMap.get(oEvent.getWorld()).onDisable();
|
||||
oWorldHandlerMap.remove(oEvent.getWorld());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Find and execute cached Actions for this Chunk.
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onChunkLoad(ChunkLoadEvent oEvent) {
|
||||
PreparedStatement oGetEventsPS = cacheGetPreparedStatement(oEvent.getWorld(), CacheQueries.GetEvents);
|
||||
final PreparedStatement oRemoveEventPS = cacheGetPreparedStatement(oEvent.getWorld(), CacheQueries.RemoveEvent);
|
||||
|
||||
if (oGetEventsPS != null && oRemoveEventPS != null) {
|
||||
World oWorld = oEvent.getWorld();
|
||||
Chunk oChunk = oEvent.getChunk();
|
||||
|
||||
// Retrieve cached events.
|
||||
try {
|
||||
oGetEventsPS.setInt(1, oChunk.getX());
|
||||
oGetEventsPS.setInt(2, oChunk.getZ());
|
||||
ResultSet oCacheResult = oGetEventsPS.executeQuery();
|
||||
if (oCacheResult != null) {
|
||||
while (oCacheResult.next()) {
|
||||
byte bX = oCacheResult.getByte("X"), bZ = oCacheResult.getByte("Z");
|
||||
short sY = oCacheResult.getShort("Y");
|
||||
byte bType = oCacheResult.getByte("Type");
|
||||
String[] stData = oCacheResult.getString("Data").split(",");
|
||||
|
||||
switch (bType) {
|
||||
case 0: // Block Event
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new BlockEventWorker(this, oWorld, oChunk, bX, bZ, sY, Short.valueOf(stData[0]), Byte.valueOf(stData[1]), iCacheRetryLimit), 1);
|
||||
break;
|
||||
case 1: // Sign Event
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new SignEventWorker(this, oWorld, oChunk, bX, bZ, sY, DatatypeConverter.parseBase64Binary(stData[0]).toString(), DatatypeConverter.parseBase64Binary(stData[1]).toString(), DatatypeConverter.parseBase64Binary(stData[2]).toString(), DatatypeConverter.parseBase64Binary(stData[3]).toString(), iCacheRetryLimit), 1);
|
||||
break;
|
||||
case 2: // Inventory Event
|
||||
break;
|
||||
}
|
||||
}
|
||||
oCacheResult.close();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
getLogger().log(Level.SEVERE, "[Cache] <" + oWorld.getName() + "> Failed to retrieve cached events:", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Prevent fall damage for some entities when the metadata is given and make sure other plugins can override this.
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onEntityDamage(EntityDamageEvent oEvent) {
|
||||
if (oEvent.getCause() == EntityDamageEvent.DamageCause.FALL) {
|
||||
if (oEvent.getEntityType().isAlive()) {
|
||||
if (oEvent.getEntity().hasMetadata("takeFallDamage")) {
|
||||
oEvent.setCancelled(true);
|
||||
oEvent.getEntity().removeMetadata("takeFallDamage", this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Accessor Functions">
|
||||
public File getWorldDirectory() {
|
||||
return oWorldDirectory;
|
||||
}
|
||||
|
||||
public YamlConfiguration getDefaultConfiguration() {
|
||||
return oDefaultConfiguration;
|
||||
}
|
||||
|
||||
public HashMap<World, Handler> getWorldHandlerMap() {
|
||||
return oWorldHandlerMap;
|
||||
}
|
||||
|
||||
public FixedMetadataValue getNoFalldamageMetadata() {
|
||||
return oNoFallDamageMetadata;
|
||||
}
|
||||
|
||||
public boolean[] getOverlappingDelayedActionArray() {
|
||||
return tOverlappingDelayedActionArr;
|
||||
}
|
||||
//</editor-fold>
|
||||
}
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
/* Authors: Xaymar
|
||||
* Copyright: 2012-2013 (c) Inception Plugin Team.
|
||||
* License: CC BY-SA 3.0
|
||||
* Inception by Inception Plugin Team is licensed under a
|
||||
* Creative Commons Attribution-ShareAlike 3.0 Unported
|
||||
* License.
|
||||
*/
|
||||
package de.RealityBends.Inception;
|
||||
|
||||
import de.RealityBends.Inception.World.Handler;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import org.mcstats.Metrics;
|
||||
import org.mcstats.Metrics.Graph;
|
||||
import org.mcstats.Metrics.Plotter;
|
||||
|
||||
public class PluginMetrics {
|
||||
|
||||
private Plugin oPlugin;
|
||||
private Metrics oMetrics;
|
||||
private Graph gModulesEnabled;
|
||||
private Graph gWorldStatus;
|
||||
|
||||
public PluginMetrics(Plugin poPlugin) {
|
||||
oPlugin = poPlugin;
|
||||
try {
|
||||
oMetrics = new Metrics(oPlugin);
|
||||
} catch (Exception ex) {
|
||||
oPlugin.getLogger().warning("[Metrics] Unable to initialize.");
|
||||
oPlugin.getLogger().log(Level.FINEST, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
final Plugin foPlugin = oPlugin;
|
||||
oPlugin.getLogger().info("[Metrics] Starting Metrics...");
|
||||
|
||||
// Track which modules are enabled.
|
||||
gModulesEnabled = oMetrics.createGraph("Modules");
|
||||
gModulesEnabled.addPlotter(new Plotter("Cache") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return foPlugin.getCacheEnabled() ? 1 : 0;
|
||||
}
|
||||
|
||||
});
|
||||
gModulesEnabled.addPlotter(new Plotter("Overlap") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
boolean tOverlapEnabled = false;
|
||||
|
||||
for (Handler oHandler : foPlugin.getWorldHandlerMap().values()) {
|
||||
if (oHandler.getWorldEnabled() && ((!oHandler.getAboveWorld().isEmpty() && oHandler.getAboveOverlapEnabled()) || (!oHandler.getBelowWorld().isEmpty() && oHandler.getBelowOverlapEnabled()))) {
|
||||
tOverlapEnabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return tOverlapEnabled ? 1 : 0;
|
||||
}
|
||||
});
|
||||
gModulesEnabled.addPlotter(new Plotter("Teleport") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
boolean tTeleportEnabled = false;
|
||||
|
||||
for (Handler oHandler : foPlugin.getWorldHandlerMap().values()) {
|
||||
if (oHandler.getWorldEnabled() && ((!oHandler.getAboveWorld().isEmpty() && oHandler.getAboveTeleportEnabled()) || (!oHandler.getBelowWorld().isEmpty() && oHandler.getBelowTeleportEnabled()))) {
|
||||
tTeleportEnabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return tTeleportEnabled ? 1 : 0;
|
||||
}
|
||||
});
|
||||
gModulesEnabled.addPlotter(new Plotter("Time Synchronization") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
boolean tTimeSyncEnabled = false;
|
||||
|
||||
for (Handler oHandler : foPlugin.getWorldHandlerMap().values()) {
|
||||
if (oHandler.getWorldEnabled() && !oHandler.getWorldSynchronizeWith().isEmpty()) {
|
||||
tTimeSyncEnabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return tTimeSyncEnabled ? 1 : 0;
|
||||
}
|
||||
});
|
||||
|
||||
// Track how many worlds are enabled and disabled.
|
||||
gWorldStatus = oMetrics.createGraph("Worlds");
|
||||
gWorldStatus.addPlotter(new Plotter("Enabled") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
int iWorlds = 0;
|
||||
for (Handler oHandler : foPlugin.getWorldHandlerMap().values()) {
|
||||
iWorlds += oHandler.getWorldEnabled() ? 1 : 0;
|
||||
}
|
||||
return iWorlds;
|
||||
}
|
||||
|
||||
});
|
||||
gWorldStatus.addPlotter(new Plotter("Disabled") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
int iWorlds = 0;
|
||||
for (Handler oHandler : foPlugin.getWorldHandlerMap().values()) {
|
||||
iWorlds += oHandler.getWorldEnabled() ? 0 : 1;
|
||||
}
|
||||
return iWorlds;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
oMetrics.start();
|
||||
oPlugin.getLogger().info("[Metrics] Done.");
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
try {
|
||||
oMetrics.disable();
|
||||
} catch (IOException ex) {
|
||||
oPlugin.getLogger().warning("[Metrics] Unable to deinitialize.");
|
||||
oPlugin.getLogger().log(Level.FINEST, ex.getMessage(), ex);
|
||||
}
|
||||
oMetrics = null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
/* Authors: Xaymar
|
||||
* Copyright: 2012-2013 (c) Inception Plugin Team.
|
||||
* License: CC BY-SA 3.0
|
||||
* Inception by Inception Plugin Team is licensed under a
|
||||
* Creative Commons Attribution-ShareAlike 3.0 Unported
|
||||
* License.
|
||||
*/
|
||||
package de.RealityBends.Inception;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.xml.bind.TypeConstraintException;
|
||||
import net.minecraft.server.v1_6_R2.WorldServer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.v1_6_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_6_R2.CraftWorld;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftEntity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public class Utility {
|
||||
// <editor-fold defaultstate="collapsed" desc="Array Operations">
|
||||
|
||||
public static String[] ArraySplit(String split, String delimiter) {
|
||||
return split.split(delimiter);
|
||||
}
|
||||
|
||||
public static String ArrayCombine(String[] array, String delimiter) {
|
||||
String output = "";
|
||||
for (String word : array) {
|
||||
output += (output.isEmpty() ? "" : delimiter) + word;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
// </editor-fold>
|
||||
// <editor-fold defaultstate="collapsed" desc="String Operations">
|
||||
|
||||
public static String[] SmartSplit(String[] args) {
|
||||
return SmartSplit(ArrayCombine(args, " "));
|
||||
}
|
||||
|
||||
public static String[] SmartSplit(String text) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
Matcher match = Pattern.compile("[^\\s\"']+|\"([^\"]*)\"|'([^']*)'").matcher(text);
|
||||
while (match.find()) {
|
||||
list.add(match.group(1) != null ? match.group(1) : match.group(2) != null ? match.group(2) : match.group());
|
||||
}
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
public static String[] ReparseArguments(String[] args) {
|
||||
return SmartSplit(args);
|
||||
}
|
||||
|
||||
public static String Substitude(String On, String[] What, String[] With) {
|
||||
if (What.length != With.length) {
|
||||
throw new java.lang.ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
String Out = On;
|
||||
|
||||
for (int count = 0; count < What.length; count++) {
|
||||
if (What[count].contains(",")) {
|
||||
String[] WhatArgs = What[count].split(",");
|
||||
for (String arg : WhatArgs) {
|
||||
Out = Out.replaceAll(arg, With[count]);
|
||||
}
|
||||
} else {
|
||||
Out = Out.replaceAll(What[count], With[count]);
|
||||
}
|
||||
}
|
||||
|
||||
return Out;
|
||||
}
|
||||
|
||||
public static String Colorize(String On) {
|
||||
return ChatColor.translateAlternateColorCodes("&".charAt(0), On);
|
||||
}
|
||||
// </editor-fold>
|
||||
// <editor-fold defaultstate="collapsed" desc="Player Operations">
|
||||
|
||||
public static <T> CommandSender SenderFromName(T player) {
|
||||
if (player instanceof CommandSender) {
|
||||
return (CommandSender) player;
|
||||
} else if (player instanceof Player) {
|
||||
return (Player) player;
|
||||
} else if (player instanceof String) {
|
||||
return Bukkit.getPlayerExact((String) player);
|
||||
} else {
|
||||
throw new TypeConstraintException("'player' must be CommandSender, Player or String");
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> void SendMessage(final T reciever, final String msg, final Object... args) {
|
||||
SendMessage(true, reciever, msg, args);
|
||||
}
|
||||
|
||||
public static <T> void SendMessage(final boolean prefix, final T reciever, final String msg, final Object... args) {
|
||||
SendMessage(true, "[Inception] ", reciever, msg, args);
|
||||
}
|
||||
|
||||
public static <T> void SendMessage(final boolean addprefix, final String prefix, final T reciever, final String msg, final Object... args) {
|
||||
if (reciever != null) {
|
||||
if (reciever instanceof List) {
|
||||
for (Object entry : (List<?>) reciever) {
|
||||
SendMessage(addprefix, prefix, entry, msg, args);
|
||||
}
|
||||
} else {
|
||||
for (String line : String.format(msg, args).split("\n")) {
|
||||
Utility.SenderFromName(reciever).sendMessage(Utility.Colorize(
|
||||
(addprefix ? prefix + " " + line : line)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// </editor-fold>
|
||||
// <editor-fold defaultstate="collapsed" desc="Entity Operations">
|
||||
|
||||
public static void EntityTeleportEx(final Entity poEntity, final Location poLocation, final Plugin poPlugin) {
|
||||
final net.minecraft.server.v1_6_R2.Entity oMCEntity = ((CraftEntity) poEntity).getHandle();
|
||||
|
||||
// Check if we are teleporting a player, since they need special handling.
|
||||
if (poEntity.getType() == EntityType.PLAYER) { //Players need a packet for teleportation first.
|
||||
poEntity.teleport(poLocation);
|
||||
} else {
|
||||
WorldServer oWorldSource = (WorldServer) oMCEntity.world;
|
||||
WorldServer oWorldTarget = ((CraftWorld) poLocation.getWorld()).getHandle();
|
||||
|
||||
// Change world that has this entity
|
||||
oWorldSource.removeEntity(oMCEntity);
|
||||
oWorldTarget.addEntity(oMCEntity);
|
||||
|
||||
// Check if the entity is actually tracked in the other world.
|
||||
if (oWorldTarget.getTracker().trackedEntities.b(oMCEntity.id) == false) {
|
||||
oWorldSource.getTracker().untrackEntity(oMCEntity);
|
||||
oWorldTarget.getTracker().track(oMCEntity);
|
||||
}
|
||||
|
||||
// Update the Entity
|
||||
oMCEntity.world = ((CraftWorld) poLocation.getWorld()).getHandle();
|
||||
oMCEntity.setLocation(poLocation.getX(), poLocation.getY(), poLocation.getZ(), poLocation.getYaw(), poLocation.getPitch());
|
||||
|
||||
//((CraftEntity) poEntity).getHandle().teleportTo(poLocation, false);
|
||||
}
|
||||
|
||||
//Teleport the passenger.
|
||||
if (poEntity.getPassenger() != null) { //The teleporting entity is being driven.
|
||||
|
||||
final Entity oPassenger = poEntity.getPassenger();
|
||||
|
||||
poEntity.eject(); //Eject the passenger.
|
||||
oPassenger.leaveVehicle(); //Leave the vehicle.
|
||||
|
||||
//Delay teleporting of passenger by one tick each.
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(poPlugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Utility.EntityTeleportEx(oPassenger, poLocation, poPlugin);
|
||||
|
||||
poEntity.setPassenger(oPassenger);
|
||||
oMCEntity.passenger = ((CraftEntity) oPassenger).getHandle();
|
||||
((CraftEntity) oPassenger).getHandle().vehicle = oMCEntity;
|
||||
}
|
||||
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
// </editor-fold>
|
||||
//<editor-fold defaultstate="collapsed" desc="SQL Operations">
|
||||
|
||||
public static String escapeForSQL(String pstInput) {
|
||||
return pstInput.replaceAll("\\(\\[^a-zA-Z_\\-0-9\\]\\)", "\\$1");
|
||||
}
|
||||
//</editor-fold>
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/* Authors: Xaymar
|
||||
* Copyright: 2012-2013 (c) Inception Plugin Team.
|
||||
* License: CC BY-SA 3.0
|
||||
* Inception by Inception Plugin Team is licensed under a
|
||||
* Creative Commons Attribution-ShareAlike 3.0 Unported
|
||||
* License.
|
||||
*/
|
||||
package de.RealityBends.Inception.World;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
public class Cache {
|
||||
private String oDatabaseURL;
|
||||
private Connection oConnection;
|
||||
|
||||
public Cache(File poDatabaseFile) throws ClassNotFoundException {
|
||||
oDatabaseURL = "jdbc:sqlite:" + poDatabaseFile.getAbsolutePath();
|
||||
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
}
|
||||
|
||||
public void open() throws SQLException {
|
||||
oConnection = DriverManager.getConnection(oDatabaseURL);
|
||||
}
|
||||
|
||||
public void close() throws SQLException {
|
||||
if (oConnection != null) {
|
||||
oConnection.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void execute(String pstQuery) throws SQLException {
|
||||
oConnection.createStatement().execute(pstQuery);
|
||||
}
|
||||
|
||||
public ResultSet executeQuery(String pstQuery) throws SQLException {
|
||||
Statement oStatement = oConnection.createStatement();
|
||||
ResultSet oResult = oStatement.executeQuery(pstQuery);
|
||||
oStatement.close();
|
||||
return oResult;
|
||||
//return oConnection.createStatement().executeQuery(pstQuery);
|
||||
}
|
||||
|
||||
public PreparedStatement prepareStatement(String pstQuery) throws SQLException {
|
||||
return oConnection.prepareStatement(pstQuery);
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/* Authors: Xaymar
|
||||
* Copyright: 2012-2013 (c) Inception Plugin Team.
|
||||
* License: CC BY-SA 3.0
|
||||
* Inception by Inception Plugin Team is licensed under a
|
||||
* Creative Commons Attribution-ShareAlike 3.0 Unported
|
||||
* License.
|
||||
*/
|
||||
package de.RealityBends.Inception.World;
|
||||
|
||||
public enum CacheQueries {
|
||||
CreateWorld("CreateWorld", false, "CREATE TABLE IF NOT EXISTS 'main'.'{0}' ('ChunkX' INTEGER NOT NULL, 'ChunkZ' INTEGER NOT NULL, 'X' INTEGER NOT NULL, 'Z' INTEGER NOT NULL, 'Y' INTEGER NOT NULL, 'Type' INTEGER NOT NULL, 'Data' TEXT NOT NULL, PRIMARY KEY ('ChunkX', 'ChunkZ', 'X', 'Z', 'Y', 'Type') ON CONFLICT REPLACE);"),
|
||||
DeleteWorld("DeleteWorld", false, "DROP TABLE IF EXISTS 'main'.'{0}'"),
|
||||
AddEvent("AddEvent", true, "INSERT OR REPLACE INTO 'main'.'{0}' VALUES(?1, ?2, ?3, ?4, ?5, ?6, ?7);"),
|
||||
GetEvents("GetEvents", true, "SELECT X, Z, Y, Type, Data FROM 'main'.'{0}' WHERE ChunkX = ?1 AND ChunkZ = ?2;"),
|
||||
RemoveEvent("RemoveEvent", true, "DELETE FROM 'main'.'{0}' WHERE ChunkX = ?1 AND ChunkZ = ?2 AND X = ?3 AND Z = ?4 AND Y = ?5 AND Type = ?6;");
|
||||
|
||||
private String stName;
|
||||
private String stDefaultQuery;
|
||||
private boolean tIsPreparable;
|
||||
|
||||
private CacheQueries(String pstName, boolean ptIsPreparable, String pstDefaultQuery) {
|
||||
stName = pstName;
|
||||
tIsPreparable = ptIsPreparable;
|
||||
stDefaultQuery = pstDefaultQuery;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return stName;
|
||||
}
|
||||
|
||||
public boolean isPreparable() {
|
||||
return tIsPreparable;
|
||||
}
|
||||
|
||||
public String getDefaultQuery() {
|
||||
return stDefaultQuery;
|
||||
}
|
||||
}
|
||||
+1413
File diff suppressed because it is too large
Load Diff
+65
@@ -0,0 +1,65 @@
|
||||
/* Authors: Xaymar
|
||||
* Copyright: 2012-2013 (c) Inception Plugin Team.
|
||||
* License: CC BY-SA 3.0
|
||||
* Inception by Inception Plugin Team is licensed under a
|
||||
* Creative Commons Attribution-ShareAlike 3.0 Unported
|
||||
* License.
|
||||
*/
|
||||
package de.RealityBends.Inception.World;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public enum OverlapDelayBlocks {
|
||||
Torch(Material.TORCH.getId()),
|
||||
Ladder(Material.LADDER.getId()),
|
||||
RedstoneTorch(Material.REDSTONE_TORCH_ON.getId()),
|
||||
RedstoneRepeater(Material.DIODE_BLOCK_OFF.getId()),
|
||||
RedstoneComparator(Material.REDSTONE_COMPARATOR_OFF.getId()),
|
||||
Lever(Material.LEVER.getId()),
|
||||
WoodButton(Material.WOOD_BUTTON.getId()),
|
||||
StoneButton(Material.STONE_BUTTON.getId()),
|
||||
Dispenser(Material.DISPENSER.getId()),
|
||||
Dropper(Material.DROPPER.getId()),
|
||||
Hopper(Material.HOPPER.getId()),
|
||||
Piston(Material.PISTON_BASE.getId()),
|
||||
StickyPiston(Material.PISTON_STICKY_BASE.getId()),
|
||||
Furnace(Material.FURNACE.getId()),
|
||||
Chest(Material.CHEST.getId()),
|
||||
TrappedChest(Material.TRAPPED_CHEST.getId()),
|
||||
EnderChest(Material.ENDER_CHEST.getId()),
|
||||
StoneSlab(Material.STEP.getId()),
|
||||
WoodedSlab(Material.WOOD_STEP.getId()),
|
||||
OakWoodStairs(Material.WOOD_STAIRS.getId()),
|
||||
CobblestoneStairs(Material.COBBLESTONE_STAIRS.getId()),
|
||||
BrickStairs(Material.BRICK_STAIRS.getId()),
|
||||
StoneBrickStairs(Material.SMOOTH_STAIRS.getId()),
|
||||
NetherBrickStairs(Material.NETHER_BRICK_STAIRS.getId()),
|
||||
SandstoneStairs(Material.SANDSTONE_STAIRS.getId()),
|
||||
SpruceWoodStairs(Material.SPRUCE_WOOD_STAIRS.getId()),
|
||||
JungleWoodStairs(Material.JUNGLE_WOOD_STAIRS.getId()),
|
||||
QuartzStairs(Material.QUARTZ_STAIRS.getId()),
|
||||
Vines(Material.VINE.getId()),
|
||||
TripwireHook(Material.TRIPWIRE_HOOK.getId()),
|
||||
WallSign(Material.WALL_SIGN.getId()),
|
||||
SignPost(Material.SIGN_POST.getId()),
|
||||
Skull(Material.SKULL.getId()),
|
||||
Pumpkin(Material.PUMPKIN.getId()),
|
||||
JackOLantern(Material.JACK_O_LANTERN.getId()),
|
||||
HugeBrownMushroom(Material.HUGE_MUSHROOM_1.getId()),
|
||||
HugeRedMushroom(Material.HUGE_MUSHROOM_2.getId()),
|
||||
WoodenDoor(Material.WOODEN_DOOR.getId()),
|
||||
IronDoor(Material.IRON_DOOR_BLOCK.getId()),
|
||||
TrapDoor(Material.TRAP_DOOR.getId()),
|
||||
FenceGate(Material.FENCE_GATE.getId()),
|
||||
Jukebox(Material.JUKEBOX.getId());
|
||||
|
||||
private int sTypeId;
|
||||
|
||||
private OverlapDelayBlocks(int sTypeId) {
|
||||
this.sTypeId = sTypeId;
|
||||
}
|
||||
|
||||
public int getTypeId() {
|
||||
return sTypeId;
|
||||
}
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
/* Authors: Xaymar
|
||||
* Copyright: 2012-2013 (c) Inception Plugin Team.
|
||||
* License: CC BY-SA 3.0
|
||||
* Inception by Inception Plugin Team is licensed under a
|
||||
* Creative Commons Attribution-ShareAlike 3.0 Unported
|
||||
* License.
|
||||
*/
|
||||
package de.RealityBends.Inception.World;
|
||||
|
||||
import de.RealityBends.Inception.World.OverlapEvents;
|
||||
import de.RealityBends.Inception.World.Handler;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventException;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockEvent;
|
||||
import org.bukkit.plugin.EventExecutor;
|
||||
|
||||
public class OverlapEventExecutor
|
||||
implements EventExecutor {
|
||||
|
||||
private World oWorld;
|
||||
private OverlapEvents oOverlapEvent;
|
||||
private short sBoundsBelow, sBoundsAbove;
|
||||
|
||||
// Reflection
|
||||
private Class cOverlapEventClass;
|
||||
private Method rmWorldHandler_onOverlapEvent;
|
||||
|
||||
public OverlapEventExecutor(World oWorld, OverlapEvents oOverlapEvent, short sBoundsAbove, short sBoundsBelow) {
|
||||
this.oWorld = oWorld;
|
||||
this.oOverlapEvent = oOverlapEvent;
|
||||
this.sBoundsAbove = sBoundsAbove;
|
||||
this.sBoundsBelow = sBoundsBelow;
|
||||
|
||||
// Reflection
|
||||
this.cOverlapEventClass = oOverlapEvent.getEventClass();
|
||||
try {
|
||||
this.rmWorldHandler_onOverlapEvent = Handler.class.getMethod("onOverlapEvent", cOverlapEventClass);
|
||||
} catch (Throwable ex) {
|
||||
Logger.getLogger(OverlapEventExecutor.class.getName()).log(Level.SEVERE, "Event is not handled by WorldHandler! Open a ticket immediately!", ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Listener listener, Event event)
|
||||
throws EventException {
|
||||
try {
|
||||
// Check if this Executor should even consider this event.
|
||||
if (cOverlapEventClass.isInstance(event)) {
|
||||
// Check if the event is cancellable, and if it is, if it has been cancelled.
|
||||
boolean tIsCancellable = Cancellable.class.isInstance(event);
|
||||
if (!tIsCancellable || (tIsCancellable && !Cancellable.class.cast(event).isCancelled())) {
|
||||
// Check if the event was raised in the world we were assigned to.
|
||||
BlockEvent oBlockEvent = (BlockEvent) cOverlapEventClass.cast(event);
|
||||
Block oBlock = oBlockEvent.getBlock();
|
||||
Location oLocation = oBlock.getLocation();
|
||||
if (oBlock.getWorld() == oWorld && (oLocation.getBlockY() < sBoundsBelow || oLocation.getBlockY() > sBoundsAbove)) {
|
||||
rmWorldHandler_onOverlapEvent.invoke(listener, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
|
||||
throw new EventException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/* Authors: Xaymar
|
||||
* Copyright: 2012-2013 (c) Inception Plugin Team.
|
||||
* License: CC BY-SA 3.0
|
||||
* Inception by Inception Plugin Team is licensed under a
|
||||
* Creative Commons Attribution-ShareAlike 3.0 Unported
|
||||
* License.
|
||||
*/
|
||||
package de.RealityBends.Inception.World;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.block.BlockFormEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockGrowEvent;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.BlockSpreadEvent;
|
||||
import org.bukkit.event.block.LeavesDecayEvent;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
public enum OverlapEvents {
|
||||
|
||||
BlockPlace("BlockPlace", BlockPlaceEvent.class),
|
||||
BlockBreak("BlockBreak", BlockBreakEvent.class),
|
||||
BlockBurn("BlockBurn", BlockBurnEvent.class),
|
||||
BlockFade("BlockFade", BlockFadeEvent.class),
|
||||
BlockForm("BlockForm", BlockFormEvent.class),
|
||||
BlockGrow("BlockGrow", BlockGrowEvent.class),
|
||||
BlockSpread("BlockSpread", BlockSpreadEvent.class),
|
||||
BlockFromTo("BlockFromTo", BlockFromToEvent.class),
|
||||
BlockPhysics("BlockPhysics", BlockPhysicsEvent.class),
|
||||
LeavesDecay("LeavesDecay", LeavesDecayEvent.class),
|
||||
SignChange("SignChange", SignChangeEvent.class);
|
||||
|
||||
// Enum Values
|
||||
private String stName;
|
||||
private Class<? extends Event> rcEventClass;
|
||||
|
||||
private OverlapEvents(String stName) {
|
||||
this(stName, null);
|
||||
}
|
||||
|
||||
private OverlapEvents(String stName, Class<? extends Event> rcEventClass) {
|
||||
this.stName = stName;
|
||||
this.rcEventClass = rcEventClass;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return stName;
|
||||
}
|
||||
|
||||
public Class<? extends Event> getEventClass() {
|
||||
return rcEventClass;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
# Authors: Xaymar
|
||||
# Copyright: 2012-2013 (c) Inception Plugin Team.
|
||||
# License: CC BY-SA 3.0
|
||||
# Inception by Inception Plugin Team is licensed under a
|
||||
# Creative Commons Attribution-ShareAlike 3.0 Unported
|
||||
# License.
|
||||
|
||||
name: Inception
|
||||
version: "1.6.2-R0.1 [R3]"
|
||||
author: Xaymar
|
||||
website: http://plugins.realitybends.de/?p=Inception/
|
||||
main: de.RealityBends.Inception.Plugin
|
||||
prefix: "Inception"
|
||||
load: POSTWORLD
|
||||
softdepend: [ Multiverse-Core, MyWorlds ]
|
||||
commands:
|
||||
inception:
|
||||
description: Control Inception with this command
|
||||
aliases: [ic, inc]
|
||||
permission: inception.command
|
||||
permissions:
|
||||
inception.overlap:
|
||||
description: Allow the player to be recognized by overlapping.
|
||||
default: true
|
||||
inception.teleport:
|
||||
description: Allow the player to be recognized by teleporting.
|
||||
default: true
|
||||
Reference in New Issue
Block a user