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:
Michael Fabian Dirks
2014-11-24 18:18:24 +01:00
parent 934da62076
commit 8f3114e377
170 changed files with 22028 additions and 3 deletions
+3
View File
@@ -0,0 +1,3 @@
# Binary Files
/ExtraGenerators (CraftBukkit)/target
/Inception (CraftBukkit)/target
@@ -0,0 +1,4 @@
/target/
# We shouldn't upload our private information.
/build.xml
+354
View File
@@ -0,0 +1,354 @@
Mozilla Public License, version 2.0
1. Definitions
1.1. “Contributor”
means each individual or legal entity that creates, contributes to the
creation of, or owns Covered Software.
1.2. “Contributor Version”
means the combination of the Contributions of others (if any) used by a
Contributor and that particular Contributors Contribution.
1.3. “Contribution”
means Covered Software of a particular Contributor.
1.4. “Covered Software”
means Source Code Form to which the initial Contributor has attached the
notice in Exhibit A, the Executable Form of such Source Code Form, and
Modifications of such Source Code Form, in each case including portions
thereof.
1.5. “Incompatible With Secondary Licenses”
means
a. that the initial Contributor has attached the notice described in
Exhibit B to the Covered Software; or
b. that the Covered Software was made available under the terms of version
1.1 or earlier of the License, but not also under the terms of a
Secondary License.
1.6. “Executable Form”
means any form of the work other than Source Code Form.
1.7. “Larger Work”
means a work that combines Covered Software with other material, in a separate
file or files, that is not Covered Software.
1.8. “License”
means this document.
1.9. “Licensable”
means having the right to grant, to the maximum extent possible, whether at the
time of the initial grant or subsequently, any and all of the rights conveyed by
this License.
1.10. “Modifications”
means any of the following:
a. any file in Source Code Form that results from an addition to, deletion
from, or modification of the contents of Covered Software; or
b. any new file in Source Code Form that contains any Covered Software.
1.11. “Patent Claims” of a Contributor
means any patent claim(s), including without limitation, method, process,
and apparatus claims, in any patent Licensable by such Contributor that
would be infringed, but for the grant of the License, by the making,
using, selling, offering for sale, having made, import, or transfer of
either its Contributions or its Contributor Version.
1.12. “Secondary License”
means either the GNU General Public License, Version 2.0, the GNU Lesser
General Public License, Version 2.1, the GNU Affero General Public
License, Version 3.0, or any later versions of those licenses.
1.13. “Source Code Form”
means the form of the work preferred for making modifications.
1.14. “You” (or “Your”)
means an individual or a legal entity exercising rights under this
License. For legal entities, “You” includes any entity that controls, is
controlled by, or is under common control with You. For purposes of this
definition, “control” means (a) the power, direct or indirect, to cause
the direction or management of such entity, whether by contract or
otherwise, or (b) ownership of more than fifty percent (50%) of the
outstanding shares or beneficial ownership of such entity.
2. License Grants and Conditions
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
a. under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or as
part of a Larger Work; and
b. under Patent Claims of such Contributor to make, use, sell, offer for
sale, have made, import, and otherwise transfer either its Contributions
or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution become
effective for each Contribution on the date the Contributor first distributes
such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under this
License. No additional rights or licenses will be implied from the distribution
or licensing of Covered Software under this License. Notwithstanding Section
2.1(b) above, no patent license is granted by a Contributor:
a. for any code that a Contributor has removed from Covered Software; or
b. for infringements caused by: (i) Your and any other third partys
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
c. under Patent Claims infringed by Covered Software in the absence of its
Contributions.
This License does not grant any rights in the trademarks, service marks, or
logos of any Contributor (except as may be necessary to comply with the
notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this License
(see Section 10.2) or under the terms of a Secondary License (if permitted
under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its Contributions
are its original creation(s) or it has sufficient rights to grant the
rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under applicable
copyright doctrines of fair use, fair dealing, or other equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
Section 2.1.
3. Responsibilities
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under the
terms of this License. You must inform recipients that the Source Code Form
of the Covered Software is governed by the terms of this License, and how
they can obtain a copy of this License. You may not attempt to alter or
restrict the recipients rights in the Source Code Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
a. such Covered Software must also be made available in Source Code Form,
as described in Section 3.1, and You must inform recipients of the
Executable Form how they can obtain a copy of such Source Code Form by
reasonable means in a timely manner, at a charge no more than the cost
of distribution to the recipient; and
b. You may distribute such Executable Form under the terms of this License,
or sublicense it under different terms, provided that the license for
the Executable Form does not attempt to limit or alter the recipients
rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for the
Covered Software. If the Larger Work is a combination of Covered Software
with a work governed by one or more Secondary Licenses, and the Covered
Software is not Incompatible With Secondary Licenses, this License permits
You to additionally distribute such Covered Software under the terms of
such Secondary License(s), so that the recipient of the Larger Work may, at
their option, further distribute the Covered Software under the terms of
either this License or such Secondary License(s).
3.4. Notices
You may not remove or alter the substance of any license notices (including
copyright notices, patent notices, disclaimers of warranty, or limitations
of liability) contained within the Source Code Form of the Covered
Software, except that You may alter any license notices to the extent
required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on behalf
of any Contributor. You must make it absolutely clear that any such
warranty, support, indemnity, or liability obligation is offered by You
alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
If it is impossible for You to comply with any of the terms of this License
with respect to some or all of the Covered Software due to statute, judicial
order, or regulation then You must: (a) comply with the terms of this License
to the maximum extent possible; and (b) describe the limitations and the code
they affect. Such description must be placed in a text file included with all
distributions of the Covered Software under this License. Except to the
extent prohibited by statute or regulation, such description must be
sufficiently detailed for a recipient of ordinary skill to be able to
understand it.
5. Termination
5.1. The rights granted under this License will terminate automatically if You
fail to comply with any of its terms. However, if You become compliant,
then the rights granted under this License from a particular Contributor
are reinstated (a) provisionally, unless and until such Contributor
explicitly and finally terminates Your grants, and (b) on an ongoing basis,
if such Contributor fails to notify You of the non-compliance by some
reasonable means prior to 60 days after You have come back into compliance.
Moreover, Your grants from a particular Contributor are reinstated on an
ongoing basis if such Contributor notifies You of the non-compliance by
some reasonable means, this is the first time You have received notice of
non-compliance with this License from such Contributor, and You become
compliant prior to 30 days after Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions, counter-claims,
and cross-claims) alleging that a Contributor Version directly or
indirectly infringes any patent, then the rights granted to You by any and
all Contributors for the Covered Software under Section 2.1 of this License
shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
license agreements (excluding distributors and resellers) which have been
validly granted by You or Your distributors under this License prior to
termination shall survive termination.
6. Disclaimer of Warranty
Covered Software is provided under this License on an “as is” basis, without
warranty of any kind, either expressed, implied, or statutory, including,
without limitation, warranties that the Covered Software is free of defects,
merchantable, fit for a particular purpose or non-infringing. The entire
risk as to the quality and performance of the Covered Software is with You.
Should any Covered Software prove defective in any respect, You (not any
Contributor) assume the cost of any necessary servicing, repair, or
correction. This disclaimer of warranty constitutes an essential part of this
License. No use of any Covered Software is authorized under this License
except under this disclaimer.
7. Limitation of Liability
Under no circumstances and under no legal theory, whether tort (including
negligence), contract, or otherwise, shall any Contributor, or anyone who
distributes Covered Software as permitted above, be liable to You for any
direct, indirect, special, incidental, or consequential damages of any
character including, without limitation, damages for lost profits, loss of
goodwill, work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses, even if such party shall have been
informed of the possibility of such damages. This limitation of liability
shall not apply to liability for death or personal injury resulting from such
partys negligence to the extent applicable law prohibits such limitation.
Some jurisdictions do not allow the exclusion or limitation of incidental or
consequential damages, so this exclusion and limitation may not apply to You.
8. Litigation
Any litigation relating to this License may be brought only in the courts of
a jurisdiction where the defendant maintains its principal place of business
and such litigation shall be governed by laws of that jurisdiction, without
reference to its conflict-of-law provisions. Nothing in this Section shall
prevent a partys ability to bring cross-claims or counter-claims.
9. Miscellaneous
This License represents the complete agreement concerning the subject matter
hereof. If any provision of this License is held to be unenforceable, such
provision shall be reformed only to the extent necessary to make it
enforceable. Any law or regulation which provides that the language of a
contract shall be construed against the drafter shall not be used to construe
this License against a Contributor.
10. Versions of the License
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version of
the License under which You originally received the Covered Software, or
under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a modified
version of this License if you rename the license and remove any
references to the name of the license steward (except to note that such
modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
If You choose to distribute Source Code Form that is Incompatible With
Secondary Licenses under the terms of this version of the License, the
notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular file, then
You may include the notice in a location (such as a LICENSE file in a relevant
directory) where a recipient would be likely to look for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - “Incompatible With Secondary Licenses” Notice
This Source Code Form is “Incompatible
With Secondary Licenses”, as defined by
the Mozilla Public License, v. 2.0.
@@ -0,0 +1,8 @@
ExtraGenerators (CraftBukkit)
==========
An attempt at combining all my generator plugins into one easily extendable plugin. Didn't work out, never saw the light of day, or rather the atmosphere of a server room.
License
=======
ExtraGenerators (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/.
Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

+129
View File
@@ -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>ExtraGenerators</artifactId>
<name>ExtraGenerators</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.0</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,41 @@
/* Authors: Xaymar
* Copyright: 2013 (c) RealityBends
* License: This file is part of Project Kube.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package de.RealityBends.ExtraGenerators.Generators;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.World;
public class Empty extends Generator {
private static String stName = "Empty";
//<editor-fold defaultstate="collapsed" desc="Generation: Spawn Location">
@Override
public Location getFixedSpawnLocation(World oWorld, Random oRandom) {
return new Location(oWorld, 0, 128, 0);
}
@Override
public boolean canSpawn(World oWorld, int iX, int iZ) {
return true;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Generation: Block Sections">
@Override
public byte[][] generateBlockSections(World poWorld, Random poRandom, int piX, int piZ, BiomeGrid poBiomeGrid) {
return super.generateBlockSections(poWorld, poRandom, piZ, piZ, poBiomeGrid);
}
@Override
public short[][] generateExtBlockSections(World poWorld, Random poRandom, int piX, int piZ, BiomeGrid poBiomeGrid) {
return super.generateExtBlockSections(poWorld, poRandom, piZ, piZ, poBiomeGrid);
}
//</editor-fold>
}
@@ -0,0 +1,69 @@
/* Authors: Xaymar
* Copyright: 2013 (c) RealityBends
* License: This file is part of Project Kube.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package de.RealityBends.ExtraGenerators.Generators;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
public abstract class Generator extends ChunkGenerator {
//<editor-fold defaultstate="collapsed" desc="Generator Name (Static)">
private static String stName = "Base Generator";
public static String getName() {
return stName;
}
//<editor-fold defaultstate="collapsed" desc="Constructor">
public Generator() {
this(null);
}
public Generator(ConfigurationSection oConfiguration) {
if (oConfiguration != null) {
}
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Default Populators">
@Override
public java.util.List<BlockPopulator> getDefaultPopulators(World oWorld) {
return super.getDefaultPopulators(oWorld);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Generation: Spawn Location">
@Override
public Location getFixedSpawnLocation(World oWorld, Random oRandom) {
return super.getFixedSpawnLocation(oWorld, oRandom);
}
@Override
public boolean canSpawn(World oWorld, int iX, int iZ) {
return super.canSpawn(oWorld, iZ, iZ);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Generation: Block Sections">
@Override
public byte[][] generateBlockSections(World poWorld, Random poRandom, int piX, int piZ, BiomeGrid poBiomeGrid) {
return super.generateBlockSections(poWorld, poRandom, piZ, piZ, poBiomeGrid);
}
@Override
public short[][] generateExtBlockSections(World poWorld, Random poRandom, int piX, int piZ, BiomeGrid poBiomeGrid) {
return super.generateExtBlockSections(poWorld, poRandom, piZ, piZ, poBiomeGrid);
}
//</editor-fold>
}
@@ -0,0 +1,151 @@
/* Authors: Xaymar
* Copyright: 2013 (c) RealityBends
* License: This file is part of Project Kube.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package de.RealityBends.ExtraGenerators;
import de.RealityBends.ExtraGenerators.World.Handler;
import java.io.File;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_6_R2.CraftWorld;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.event.world.WorldUnloadEvent;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.java.JavaPlugin;
public class Plugin extends JavaPlugin implements Listener {
private File oDataPath;
private HashMap<World, Handler> oWorldHandlerMap;
// <editor-fold defaultstate="collapsed" desc="Method: onEnable (Plugin Constructor)">
@Override
public void onEnable() {
// Create directory references and create nonexisting folders.
oDataPath = this.getDataFolder();
if (!oDataPath.exists()) {
getLogger().fine("Plugin directory is missing, creating...");
if (!oDataPath.mkdirs()) {
getLogger().severe("Failed to create plugin directory.");
}
}
// Bukkit: Change the accessibility of the CraftWorld.generator and CraftWorld.populators
try {
Field rfWorldGenerator = CraftWorld.class.getDeclaredField("generator");
rfWorldGenerator.setAccessible(true);
} catch (NoSuchFieldException | SecurityException ex) {
getLogger().warning("[Core] Unable to set generator field to accessible. Are you running CraftBukkit?");
getLogger().log(Level.FINEST, ex.getMessage(), ex);
}
try {
Field rfWorldPopulators = CraftWorld.class.getDeclaredField("populators");
rfWorldPopulators.setAccessible(true);
} catch (NoSuchFieldException | SecurityException ex) {
getLogger().warning("[Core] Unable to set populators field to accessible. Are you running CraftBukkit?");
getLogger().log(Level.FINEST, ex.getMessage(), ex);
}
// Create the WorldHandler HashMap for later use.
oWorldHandlerMap = new HashMap<>();
for (World oWorld : getServer().getWorlds()) {
Handler oHandler = new Handler(this, oWorld);
oWorldHandlerMap.put(oWorld, oHandler);
oHandler.onEnable();
}
// Register our global event handler
Bukkit.getPluginManager().registerEvents(this, this);
getLogger().info("[Core] Done.");
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Method: onDisable (Plugin Destructor)">
@Override
public void onDisable() {
// Delete and unload world handlers and destroy the list of world handlers.
for (World oWorld : getServer().getWorlds()) {
oWorldHandlerMap.remove(oWorld).onDisable();
}
oWorldHandlerMap = null;
// Bukkit: Change the accessibility of the CraftWorld.generator and CraftWorld.populators back to normal.
try {
Field rfWorldGenerator = CraftWorld.class.getDeclaredField("generator");
rfWorldGenerator.setAccessible(false);
} catch (NoSuchFieldException | SecurityException ex) {
getLogger().warning("[Core] Unable to set generator field to inaccessible. Are you running CraftBukkit?");
getLogger().log(Level.FINEST, ex.getMessage(), ex);
}
try {
Field rfWorldPopulators = CraftWorld.class.getDeclaredField("populators");
rfWorldPopulators.setAccessible(false);
} catch (NoSuchFieldException | SecurityException ex) {
getLogger().warning("[Core] Unable to set populators field to inaccessible. Are you running CraftBukkit?");
getLogger().log(Level.FINEST, ex.getMessage(), ex);
}
getLogger().info("[Core] Done.");
}
// </editor-fold>
//<editor-fold defaultstate="collapsed" desc="Event Handlers">
// Install a new WorldHandler when a world is loaded.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldLoad(WorldLoadEvent oEvent) {
World oWorld = oEvent.getWorld();
Handler oWorldHandler = oWorldHandlerMap.get(oWorld);
// If we don't have a Handler for this world, create and insert one.
if (oWorldHandler == null) {
oWorldHandler = new Handler(this, oWorld);
oWorldHandlerMap.put(oWorld, oWorldHandler);
}
// Enable the World Handler.
oWorldHandler.onEnable();
}
// Uninstall the installed WorldHandler when a world is unloaded.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldUnload(WorldUnloadEvent oEvent) {
World oWorld = oEvent.getWorld();
Handler oHandler = oWorldHandlerMap.get(oWorld);
// If we have a Handler for this world, disable it and remove the entry.
if (oHandler != null) {
oHandler.onDisable();
oWorldHandlerMap.remove(oWorld);
}
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Assign Generators">
@Override
public ChunkGenerator getDefaultWorldGenerator(String stWolrdName, String stId) {
World oWorld = Bukkit.getWorld(stWolrdName);
if (oWorld != null) {
Handler oHandler = oWorldHandlerMap.get(oWorld);
if (oHandler != null) {
return oHandler.getGenerator();
}
}
return null;
}
//</editor-fold>
}
@@ -0,0 +1,15 @@
/* Authors: Xaymar
* Copyright: 2013 (c) RealityBends
* License: This file is part of Project Kube.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package de.RealityBends.ExtraGenerators.Populators;
import org.bukkit.generator.BlockPopulator;
public abstract class Populator extends BlockPopulator {
}
@@ -0,0 +1,73 @@
/* Authors: Xaymar
* Copyright: 2013 (c) RealityBends
* License: This file is part of Project Kube.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package de.RealityBends.ExtraGenerators.Populators;
import java.util.Random;
import net.minecraft.server.v1_6_R2.ChunkSection;
import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_6_R2.CraftChunk;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.util.noise.NoiseGenerator;
import org.bukkit.util.noise.SimplexNoiseGenerator;
public class SkyIslands extends BlockPopulator {
public double dThreshold = 0.7;
public double d1XZ = 0.01;
public double d2XZ = 0.005;
public double d3XZ = 0.01;
@Override
public void populate(World oWorld, Random oRandom, Chunk oChunk) {
NoiseGenerator oSNG = new SimplexNoiseGenerator(oWorld);
// Get all Chunk Sections for speed reasons.
ChunkSnapshot oChunkSnapshot = oChunk.getChunkSnapshot();
net.minecraft.server.v1_6_R2.Chunk oMCChunk = ((CraftChunk) oChunk).getHandle();
ChunkSection[] oChunkSectionArr = oMCChunk.i();
boolean tInitializeLighting = false; // We may have to generate a ChunkSection.
for (byte bX = 0; bX < 16; bX++) {
for (byte bZ = 0; bZ < 16; bZ++) {
double dNoiseX = (oChunk.getX() << 4) | bX;
double dNoiseZ = (oChunk.getZ() << 4) | bZ;
double dNoise = oSNG.noise(dNoiseX * d1XZ, dNoiseZ * d1XZ)
+ oSNG.noise(dNoiseX * d2XZ, dNoiseZ * d2XZ)
- oSNG.noise(dNoiseX * d3XZ, dNoiseZ * d3XZ);
// Do we hit or pass through the threshold?
if (dNoise > dThreshold) {
// Get Highest Block Y at XZ
int iHighestBlockY = oChunkSnapshot.getHighestBlockYAt(bX, bZ);
//int iHeight = (int) ((dNoise - 0.7) * 64 * (0.75 + oSNG.noise(dNoiseX * 0.03, dNoiseZ * 0.03) / 2));
int iHeight = (int) ((dNoise - dThreshold) * 32);
for (int iPosY = iHighestBlockY; iPosY >= (iHighestBlockY - iHeight); iPosY--) {
int iOffsetY = iPosY + 64;
ChunkSection oChunkSection = oChunkSectionArr[iOffsetY >> 4];
if (oChunkSection == null) {
oChunkSection = oChunkSectionArr[iOffsetY >> 4] = new ChunkSection(iOffsetY >> 4 << 4, !oMCChunk.world.worldProvider.f);
tInitializeLighting = true;
}
oChunkSection.setTypeId(bX, iOffsetY & 15, bZ, oMCChunk.getTypeId(bX, iPosY, bZ));
oMCChunk.f(bX, iPosY, bZ);
oMCChunk.f(bX, iOffsetY, bZ);
}
}
}
}
if (tInitializeLighting) {
oMCChunk.initLighting();
}
}
}
@@ -0,0 +1,86 @@
/* Authors: Xaymar
* Copyright: 2013 (c) RealityBends
* License: This file is part of Project Kube.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package de.RealityBends.ExtraGenerators.World;
import de.RealityBends.ExtraGenerators.Generators.Empty;
import java.io.File;
import java.io.IOException;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
public class Configuration {
private File oFile;
private YamlConfiguration oConfiguration;
private long lTSCreated, lTSModified;
//<editor-fold defaultstate="collapsed" desc="Constructor">
public Configuration(File poFile) {
this.oFile = poFile;
this.oConfiguration = new YamlConfiguration();
this.lTSCreated = System.currentTimeMillis();
this.lTSModified = this.lTSCreated;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Loading and Saving">
public void load() throws IOException, InvalidConfigurationException {
if (oFile.exists()) {
oConfiguration.load(oFile);
} else {
initialize();
save();
}
}
public void save() throws IOException {
save(false);
}
public void save(boolean ptForce) throws IOException {
if ((this.lTSModified > this.lTSCreated) || (ptForce)) {
oConfiguration.save(oFile);
}
}
public void initialize() {
oConfiguration.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.");
setWorldGenerator("Empty");
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="World.Generator">
private String stWorldGenerator = null;
private void cacheWorldGenerator() {
this.stWorldGenerator = oConfiguration.getString("World.Generator");
}
public String getWorldGenerator() {
return stWorldGenerator;
}
public <T> void setWorldGenerator(T newGenerator) {
if (newGenerator instanceof Empty) {
oConfiguration.set("World.Generator", ((Empty)newGenerator).getClass().getName());
} else if (newGenerator instanceof String) {
oConfiguration.set("World.Generator", (String)newGenerator);
} else {
oConfiguration.set("World.Generator", null);
}
cacheWorldGenerator();
}
//</editor-fold>
}
@@ -0,0 +1,63 @@
/* Authors: Xaymar
* Copyright: 2013 (c) RealityBends
* License: This file is part of Project Kube.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package de.RealityBends.ExtraGenerators.World;
import de.RealityBends.ExtraGenerators.Generators.Generator;
import de.RealityBends.ExtraGenerators.Plugin;
import de.RealityBends.ExtraGenerators.Populators.Populator;
import java.io.File;
import java.io.IOException;
import java.util.LinkedList;
import org.bukkit.World;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.generator.ChunkGenerator;
public class Handler {
private Plugin oPlugin;
private World oWorld;
private Configuration oConfiguration;
private Generator oGenerator;
private LinkedList<Populator> oPopulator;
//<editor-fold defaultstate="collapsed" desc="Constructor">
public Handler(Plugin poPlugin, org.bukkit.World poWorld) {
oPlugin = poPlugin;
oWorld = poWorld;
oConfiguration = new Configuration(new File(poWorld.getWorldFolder() + File.separator + "ExtraGenerators.yml"));
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Enabling and Disabling">
public void onEnable() {
// Try and load Configuration.
try {
oConfiguration.load();
} catch (IOException | InvalidConfigurationException ex) {
oPlugin.getLogger().severe("Failed to load configuration: " + ex.toString() + ".");
}
}
public void onDisable() {
// Destroy Generator instance.
// Try and save Configuration.
try {
oConfiguration.save();
} catch (IOException ex) {
oPlugin.getLogger().severe("Failed to save configuration: " + ex.toString() + ".");
}
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="World Generator">
public Generator getGenerator() {
return oGenerator;
}
//</editor-fold>
}
@@ -0,0 +1,19 @@
# File: ExtraGenerators/src/main/resources/plugin.yml
# Provides: Plugin Descriptor File
# Authors: Xaymar
# Copyright: 2013 (c) ExtraGenerators Plugin Team.
# License: CC-BY-SA
# ExtraGenerators by ExtraGenerators Plugin Team is licensed under a
# Creative Commons Attribution-ShareAlike 3.0 Unported
# License.
name: ExtraGenerators
version: "1.6.2-R0.1 [R1]"
author: Xaymar
website: http://realitybends.de/ExtraGenerators
main: de.RealityBends.ExtraGenerators.Plugin
prefix: "ExtraGenerators"
load: STARTUP
softdepend:
commands:
permissions:
+4
View File
@@ -0,0 +1,4 @@
/target/
# We shouldn't upload our private information.
/build.xml
+8
View File
@@ -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>
+129
View File
@@ -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>
}
@@ -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);
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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);
}
}
}
@@ -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