Merge branch 'master' into rankdescriptions

Conflicts:
	Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java
	Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java
This commit is contained in:
Teddy 2016-01-21 12:54:12 +00:00
commit 1e72ebcbe6
1072 changed files with 71129 additions and 10824 deletions

4
.gitignore vendored
View File

@ -51,3 +51,7 @@ zSotanna2
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/segments.gen /.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/segments.gen
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/segments_1 /.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/segments_1
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/write.lock /.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/write.lock
/Pocket
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_
/RemoteSystemsTempFiles
/.recommenders/caches

BIN
Art/BlackFriday.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

BIN
Art/ChristmasChaos.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 KiB

BIN
Art/ClansBanner.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1017 KiB

BIN
Art/TitanLogo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 KiB

BIN
Art/WinterTreasure.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
Art/WinterTreasureTrim.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
Art/y5O7WYh.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
Art/zKzkfLE.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

View File

@ -18,6 +18,9 @@
<element id="file-copy" path="$PROJECT_DIR$/Mineplex.Game.Clans/plugin.yml" /> <element id="file-copy" path="$PROJECT_DIR$/Mineplex.Game.Clans/plugin.yml" />
<element id="module-output" name="Mineplex.ServerData" /> <element id="module-output" name="Mineplex.ServerData" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.5.2.jar" path-in-jar="/" /> <element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.5.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-dbcp2-2.0.1.jar" path-in-jar="/" />
<element id="module-output" name="Mineplex.Game.Clans.Core" />
<element id="module-output" name="Mineplex.Cache" />
</root> </root>
</artifact> </artifact>
</component> </component>

View File

@ -20,7 +20,8 @@
<element id="module-output" name="Mineplex.Database" /> <element id="module-output" name="Mineplex.Database" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.5.2.jar" path-in-jar="/" /> <element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.5.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-dbcp2-2.0.1.jar" path-in-jar="/" /> <element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-dbcp2-2.0.1.jar" path-in-jar="/" />
<element id="module-output" name="Mineplex.PlayerCache" /> <element id="module-output" name="Mineplex.Game.Clans.Core" />
<element id="module-output" name="Mineplex.Cache" />
</root> </root>
</artifact> </artifact>
</component> </component>

View File

@ -1,9 +0,0 @@
<component name="ArtifactManager">
<artifact type="jar" name="Nautilus.Core.Craftbukkit:jar">
<output-path>$PROJECT_DIR$/bin</output-path>
<root id="archive" name="craftbukkit.jar">
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/craftbukkit_official.jar" path-in-jar="/" />
<element id="module-output" name="Nautilus.Core.CraftBukkit" />
</root>
</artifact>
</component>

View File

@ -19,7 +19,7 @@
<element id="module-output" name="Mineplex.Database" /> <element id="module-output" name="Mineplex.Database" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.5.2.jar" path-in-jar="/" /> <element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.5.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-dbcp2-2.0.1.jar" path-in-jar="/" /> <element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-dbcp2-2.0.1.jar" path-in-jar="/" />
<element id="module-output" name="Mineplex.PlayerCache" /> <element id="module-output" name="Mineplex.Cache" />
</root> </root>
</artifact> </artifact>
</component> </component>

View File

@ -7,6 +7,14 @@
<option name="STATIC_FIELD_NAME_PREFIX" value="_" /> <option name="STATIC_FIELD_NAME_PREFIX" value="_" />
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="20" /> <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="20" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="10" /> <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="10" />
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
<value>
<package name="java.awt" withSubpackages="false" static="false" />
<package name="org.jooq.impl.DSL" withSubpackages="false" static="true" />
<package name="mineplex.database.Tables" withSubpackages="false" static="true" />
<package name="javax.swing" withSubpackages="false" static="false" />
</value>
</option>
<option name="IMPORT_LAYOUT_TABLE"> <option name="IMPORT_LAYOUT_TABLE">
<value> <value>
<package name="javax" withSubpackages="true" static="false" /> <package name="javax" withSubpackages="true" static="false" />

View File

@ -5,7 +5,6 @@
<excludeFromCompile> <excludeFromCompile>
<directory url="file://$PROJECT_DIR$/Nautilus.Game.PvP" includeSubdirectories="true" /> <directory url="file://$PROJECT_DIR$/Nautilus.Game.PvP" includeSubdirectories="true" />
<directory url="file://$PROJECT_DIR$/Mineplex.ServerMonitor" includeSubdirectories="true" /> <directory url="file://$PROJECT_DIR$/Mineplex.ServerMonitor" includeSubdirectories="true" />
<directory url="file://$PROJECT_DIR$/Mineplex.Game.Clans" includeSubdirectories="true" />
</excludeFromCompile> </excludeFromCompile>
<resourceExtensions /> <resourceExtensions />
<wildcardResourcePatterns> <wildcardResourcePatterns>
@ -29,9 +28,7 @@
<processorPath useClasspath="true" /> <processorPath useClasspath="true" />
</profile> </profile>
</annotationProcessing> </annotationProcessing>
<bytecodeTargetLevel target="1.7"> <bytecodeTargetLevel target="1.8" />
<module name="bungee" target="1.7" />
</bytecodeTargetLevel>
</component> </component>
<component name="JavacSettings"> <component name="JavacSettings">
<option name="GENERATE_NO_WARNINGS" value="true" /> <option name="GENERATE_NO_WARNINGS" value="true" />

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="DataSourceManagerImpl" format="xml" hash="4268976312"> <component name="DataSourceManagerImpl" format="xml" hash="3221233088">
<data-source source="LOCAL" name="Mineplex" uuid="14dfc55d-5343-47c4-ab24-76a055b8059e"> <data-source source="LOCAL" name="Mineplex" uuid="14dfc55d-5343-47c4-ab24-76a055b8059e">
<driver-ref>mysql</driver-ref> <driver-ref>mysql</driver-ref>
<synchronize>true</synchronize> <synchronize>true</synchronize>
<jdbc-driver>com.mysql.jdbc.Driver</jdbc-driver> <jdbc-driver>com.mysql.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://db.mineplex.com:3306</jdbc-url> <jdbc-url>jdbc:mysql://db.mineplex.com:3306/Account</jdbc-url>
<driver-properties> <driver-properties>
<property name="zeroDateTimeBehavior" value="convertToNull" /> <property name="zeroDateTimeBehavior" value="convertToNull" />
<property name="tinyInt1isBit" value="false" /> <property name="tinyInt1isBit" value="false" />

View File

@ -4,7 +4,7 @@
<root url="jar://$PROJECT_DIR$/Libraries/craftbukkit.jar!/" /> <root url="jar://$PROJECT_DIR$/Libraries/craftbukkit.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="http://jd.bukkit.org/dev/apidocs/" /> <root url="https://hub.spigotmc.org/javadocs/spigot/" />
</JAVADOC> </JAVADOC>
<SOURCES> <SOURCES>
<root url="jar://$PROJECT_DIR$/Libraries/craftbukkit.jar!/" /> <root url="jar://$PROJECT_DIR$/Libraries/craftbukkit.jar!/" />

View File

@ -16,7 +16,7 @@
</set> </set>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

View File

@ -3,21 +3,23 @@
<component name="ProjectModuleManager"> <component name="ProjectModuleManager">
<modules> <modules>
<module fileurl="file://$PROJECT_DIR$/Classpath.Dummy/Classpath.Dummy.iml" filepath="$PROJECT_DIR$/Classpath.Dummy/Classpath.Dummy.iml" group="Core" /> <module fileurl="file://$PROJECT_DIR$/Classpath.Dummy/Classpath.Dummy.iml" filepath="$PROJECT_DIR$/Classpath.Dummy/Classpath.Dummy.iml" group="Core" />
<module fileurl="file://$PROJECT_DIR$/JedisTest/JedisTest.iml" filepath="$PROJECT_DIR$/JedisTest/JedisTest.iml" /> <module fileurl="file://$PROJECT_DIR$/JedisTest/JedisTest.iml" filepath="$PROJECT_DIR$/JedisTest/JedisTest.iml" group="Legacy" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Bungee.Mineplexer/Mineplex.Bungee.Mineplexer.iml" filepath="$PROJECT_DIR$/Mineplex.Bungee.Mineplexer/Mineplex.Bungee.Mineplexer.iml" group="Bungee" /> <module fileurl="file://$PROJECT_DIR$/Mineplex.Bungee.Mineplexer/Mineplex.Bungee.Mineplexer.iml" filepath="$PROJECT_DIR$/Mineplex.Bungee.Mineplexer/Mineplex.Bungee.Mineplexer.iml" group="Bungee" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Cache/Mineplex.Cache.iml" filepath="$PROJECT_DIR$/Mineplex.Cache/Mineplex.Cache.iml" group="Core" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Core/Mineplex.Core.iml" filepath="$PROJECT_DIR$/Mineplex.Core/Mineplex.Core.iml" group="Core" /> <module fileurl="file://$PROJECT_DIR$/Mineplex.Core/Mineplex.Core.iml" filepath="$PROJECT_DIR$/Mineplex.Core/Mineplex.Core.iml" group="Core" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Core.Common/Mineplex.Core.Common.iml" filepath="$PROJECT_DIR$/Mineplex.Core.Common/Mineplex.Core.Common.iml" group="Core" /> <module fileurl="file://$PROJECT_DIR$/Mineplex.Core.Common/Mineplex.Core.Common.iml" filepath="$PROJECT_DIR$/Mineplex.Core.Common/Mineplex.Core.Common.iml" group="Core" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Database/Mineplex.Database.iml" filepath="$PROJECT_DIR$/Mineplex.Database/Mineplex.Database.iml" group="Core" /> <module fileurl="file://$PROJECT_DIR$/Mineplex.Database/Mineplex.Database.iml" filepath="$PROJECT_DIR$/Mineplex.Database/Mineplex.Database.iml" group="Core" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Game.Clans/Mineplex.Game.Clans.iml" filepath="$PROJECT_DIR$/Mineplex.Game.Clans/Mineplex.Game.Clans.iml" group="Game" /> <module fileurl="file://$PROJECT_DIR$/Mineplex.Game.Clans/Mineplex.Game.Clans.iml" filepath="$PROJECT_DIR$/Mineplex.Game.Clans/Mineplex.Game.Clans.iml" group="Clans" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Hub/Mineplex.Hub.iml" filepath="$PROJECT_DIR$/Mineplex.Hub/Mineplex.Hub.iml" /> <module fileurl="file://$PROJECT_DIR$/Mineplex.Game.Clans.Core/Mineplex.Game.Clans.Core.iml" filepath="$PROJECT_DIR$/Mineplex.Game.Clans.Core/Mineplex.Game.Clans.Core.iml" group="Clans" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.MapParser/Mineplex.MapParser.iml" filepath="$PROJECT_DIR$/Mineplex.MapParser/Mineplex.MapParser.iml" /> <module fileurl="file://$PROJECT_DIR$/Mineplex.Hub/Mineplex.Hub.iml" filepath="$PROJECT_DIR$/Mineplex.Hub/Mineplex.Hub.iml" group="Other" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.MapParser/Mineplex.MapParser.iml" filepath="$PROJECT_DIR$/Mineplex.MapParser/Mineplex.MapParser.iml" group="Other" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml" group="Game" /> <module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml" group="Game" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml" group="Game" /> <module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml" group="Game" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.PlayerCache/Mineplex.PlayerCache.iml" filepath="$PROJECT_DIR$/Mineplex.PlayerCache/Mineplex.PlayerCache.iml" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.ServerData/Mineplex.ServerData.iml" filepath="$PROJECT_DIR$/Mineplex.ServerData/Mineplex.ServerData.iml" group="Core" /> <module fileurl="file://$PROJECT_DIR$/Mineplex.ServerData/Mineplex.ServerData.iml" filepath="$PROJECT_DIR$/Mineplex.ServerData/Mineplex.ServerData.iml" group="Core" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.ServerMonitor/Mineplex.ServerMonitor.iml" filepath="$PROJECT_DIR$/Mineplex.ServerMonitor/Mineplex.ServerMonitor.iml" group="Core" /> <module fileurl="file://$PROJECT_DIR$/Mineplex.ServerMonitor/Mineplex.ServerMonitor.iml" filepath="$PROJECT_DIR$/Mineplex.ServerMonitor/Mineplex.ServerMonitor.iml" group="Core" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Votifier/Mineplex.Votifier.iml" filepath="$PROJECT_DIR$/Mineplex.Votifier/Mineplex.Votifier.iml" /> <module fileurl="file://$PROJECT_DIR$/Mineplex.Votifier/Mineplex.Votifier.iml" filepath="$PROJECT_DIR$/Mineplex.Votifier/Mineplex.Votifier.iml" group="Other" />
<module fileurl="file://$PROJECT_DIR$/Nautilus.Game.Arcade/Nautilus.Game.Arcade.iml" filepath="$PROJECT_DIR$/Nautilus.Game.Arcade/Nautilus.Game.Arcade.iml" group="Game" /> <module fileurl="file://$PROJECT_DIR$/Nautilus.Game.Arcade/Nautilus.Game.Arcade.iml" filepath="$PROJECT_DIR$/Nautilus.Game.Arcade/Nautilus.Game.Arcade.iml" group="Game" />
<module fileurl="file://$PROJECT_DIR$/Nautilus.Game.PvP/Nautilus.Game.PvP.iml" filepath="$PROJECT_DIR$/Nautilus.Game.PvP/Nautilus.Game.PvP.iml" group="Legacy" />
</modules> </modules>
</component> </component>
</project> </project>

View File

@ -9,6 +9,7 @@
<jar jarfile="../bin/Mineplex.Core.Common.jar"> <jar jarfile="../bin/Mineplex.Core.Common.jar">
<fileset dir="../Mineplex.Core.Common/bin"> <fileset dir="../Mineplex.Core.Common/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
<include name="**/*.png"/>
</fileset> </fileset>
</jar> </jar>
<copy file="../bin/Mineplex.Core.Common.jar" todir="../Libraries"/> <copy file="../bin/Mineplex.Core.Common.jar" todir="../Libraries"/>
@ -66,10 +67,10 @@
</fileset> </fileset>
<fileset dir="../Mineplex.Core/bin"> <fileset dir="../Mineplex.Core/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
<include name="**/*.png"/>
</fileset> </fileset>
<fileset dir="../Mineplex.Core.Common/bin"> <fileset dir="../Mineplex.Core.Common/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
<include name="**/*.png"/>
</fileset> </fileset>
<fileset dir="../Mineplex.Minecraft.Game.ClassCombat/bin"> <fileset dir="../Mineplex.Minecraft.Game.ClassCombat/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
@ -86,7 +87,7 @@
<fileset dir="../Mineplex.ServerData/bin"> <fileset dir="../Mineplex.ServerData/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
</fileset> </fileset>
<fileset dir="../Mineplex.PlayerCache/bin"> <fileset dir="../Mineplex.Cache/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
</fileset> </fileset>
@ -110,6 +111,7 @@
<jar jarfile="../bin/Mineplex.Core.Common.jar"> <jar jarfile="../bin/Mineplex.Core.Common.jar">
<fileset dir="../Mineplex.Core.Common/bin"> <fileset dir="../Mineplex.Core.Common/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
<include name="**/*.png"/>
</fileset> </fileset>
</jar> </jar>
<copy file="../bin/Mineplex.Core.Common.jar" todir="../Libraries"/> <copy file="../bin/Mineplex.Core.Common.jar" todir="../Libraries"/>
@ -142,6 +144,7 @@
</fileset> </fileset>
<fileset dir="../Mineplex.Core.Common/bin"> <fileset dir="../Mineplex.Core.Common/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
<include name="**/*.png"/>
</fileset> </fileset>
<fileset dir="../Mineplex.Minecraft.Game.ClassCombat/bin"> <fileset dir="../Mineplex.Minecraft.Game.ClassCombat/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
@ -149,13 +152,16 @@
<fileset dir="../Mineplex.Minecraft.Game.Core/bin"> <fileset dir="../Mineplex.Minecraft.Game.Core/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
</fileset> </fileset>
<fileset dir="../Mineplex.Game.Clans.Core/bin">
<include name="**/*.class"/>
</fileset>
<fileset dir="../Mineplex.Hub"> <fileset dir="../Mineplex.Hub">
<include name="*.yml"/> <include name="*.yml"/>
</fileset> </fileset>
<fileset dir="../Mineplex.Database/bin"> <fileset dir="../Mineplex.Database/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
</fileset> </fileset>
<fileset dir="../Mineplex.PlayerCache/bin"> <fileset dir="../Mineplex.Cache/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
</fileset> </fileset>
<fileset dir="../Mineplex.ServerData/bin"> <fileset dir="../Mineplex.ServerData/bin">
@ -188,6 +194,10 @@
</fileset> </fileset>
<fileset dir="../Mineplex.Core.Common/bin"> <fileset dir="../Mineplex.Core.Common/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
<include name="**/*.png"/>
</fileset>
<fileset dir="../Mineplex.Game.Clans.Core/bin">
<include name="**/*.class"/>
</fileset> </fileset>
<fileset dir="../Mineplex.Minecraft.Game.ClassCombat/bin"> <fileset dir="../Mineplex.Minecraft.Game.ClassCombat/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
@ -204,7 +214,7 @@
<fileset dir="../Mineplex.ServerData/bin"> <fileset dir="../Mineplex.ServerData/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
</fileset> </fileset>
<fileset dir="../Mineplex.PlayerCache/bin"> <fileset dir="../Mineplex.Cache/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
</fileset> </fileset>
@ -233,6 +243,7 @@
</fileset> </fileset>
<fileset dir="../Mineplex.Core.Common/bin"> <fileset dir="../Mineplex.Core.Common/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
<include name="**/*.png"/>
</fileset> </fileset>
<fileset dir="../Mineplex.StaffServer"> <fileset dir="../Mineplex.StaffServer">
<include name="*.yml"/> <include name="*.yml"/>
@ -243,7 +254,7 @@
<fileset dir="../Mineplex.ServerData/bin"> <fileset dir="../Mineplex.ServerData/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
</fileset> </fileset>
<fileset dir="../Mineplex.PlayerCache/bin"> <fileset dir="../Mineplex.Cache/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
</fileset> </fileset>
@ -270,6 +281,7 @@
<fileset dir="../Mineplex.Core.Common/bin"> <fileset dir="../Mineplex.Core.Common/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
<include name="**/*.png"/>
</fileset> </fileset>
<fileset dir="../Mineplex.MapParser"> <fileset dir="../Mineplex.MapParser">
@ -323,7 +335,7 @@
<include name="**/*.class"/> <include name="**/*.class"/>
</fileset> </fileset>
<fileset dir="../Mineplex.PlayerCache/bin"> <fileset dir="../Mineplex.Cache/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
</fileset> </fileset>
@ -397,6 +409,7 @@
<jar jarfile="../bin/ServerMonitor.jar"> <jar jarfile="../bin/ServerMonitor.jar">
<fileset dir="../Mineplex.Core.Common/bin"> <fileset dir="../Mineplex.Core.Common/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
<include name="**/*.png"/>
</fileset> </fileset>
<fileset dir="../Mineplex.ServerMonitor/bin"> <fileset dir="../Mineplex.ServerMonitor/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
@ -429,6 +442,7 @@
<jar jarfile="../bin/TaskConverter.jar"> <jar jarfile="../bin/TaskConverter.jar">
<fileset dir="../Mineplex.Core.Common/bin"> <fileset dir="../Mineplex.Core.Common/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
<include name="**/*.png"/>
</fileset> </fileset>
<fileset dir="../Mineplex.ChestConverter/bin"> <fileset dir="../Mineplex.ChestConverter/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
@ -456,6 +470,7 @@
<jar jarfile="../bin/PetConverter.jar"> <jar jarfile="../bin/PetConverter.jar">
<fileset dir="../Mineplex.Core.Common/bin"> <fileset dir="../Mineplex.Core.Common/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
<include name="**/*.png"/>
</fileset> </fileset>
<fileset dir="../Mineplex.PetConverter/bin"> <fileset dir="../Mineplex.PetConverter/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
@ -484,6 +499,7 @@
<jar jarfile="../bin/Queuer.jar"> <jar jarfile="../bin/Queuer.jar">
<fileset dir="../Mineplex.Core.Common/bin"> <fileset dir="../Mineplex.Core.Common/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
<include name="**/*.png"/>
</fileset> </fileset>
<fileset dir="../Mineplex.Queuer/bin"> <fileset dir="../Mineplex.Queuer/bin">
<include name="**/*.class"/> <include name="**/*.class"/>

View File

@ -13,4 +13,3 @@
<orderEntry type="library" name="commons-logging" level="project" /> <orderEntry type="library" name="commons-logging" level="project" />
</component> </component>
</module> </module>

View File

@ -1,328 +0,0 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package org.bukkit.command;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Pattern;
import org.apache.commons.lang.Validate;
import org.bukkit.Server;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandMap;
import org.bukkit.command.CommandSender;
import org.bukkit.command.FormattedCommandAlias;
import org.bukkit.command.defaults.AchievementCommand;
import org.bukkit.command.defaults.BanCommand;
import org.bukkit.command.defaults.BanIpCommand;
import org.bukkit.command.defaults.BanListCommand;
import org.bukkit.command.defaults.ClearCommand;
import org.bukkit.command.defaults.DefaultGameModeCommand;
import org.bukkit.command.defaults.DeopCommand;
import org.bukkit.command.defaults.DifficultyCommand;
import org.bukkit.command.defaults.EffectCommand;
import org.bukkit.command.defaults.EnchantCommand;
import org.bukkit.command.defaults.ExpCommand;
import org.bukkit.command.defaults.GameModeCommand;
import org.bukkit.command.defaults.GameRuleCommand;
import org.bukkit.command.defaults.GiveCommand;
import org.bukkit.command.defaults.HelpCommand;
import org.bukkit.command.defaults.KickCommand;
import org.bukkit.command.defaults.KillCommand;
import org.bukkit.command.defaults.ListCommand;
import org.bukkit.command.defaults.MeCommand;
import org.bukkit.command.defaults.OpCommand;
import org.bukkit.command.defaults.PardonCommand;
import org.bukkit.command.defaults.PardonIpCommand;
import org.bukkit.command.defaults.PlaySoundCommand;
import org.bukkit.command.defaults.PluginsCommand;
import org.bukkit.command.defaults.ReloadCommand;
import org.bukkit.command.defaults.SaveCommand;
import org.bukkit.command.defaults.SaveOffCommand;
import org.bukkit.command.defaults.SaveOnCommand;
import org.bukkit.command.defaults.SayCommand;
import org.bukkit.command.defaults.ScoreboardCommand;
import org.bukkit.command.defaults.SeedCommand;
import org.bukkit.command.defaults.SetIdleTimeoutCommand;
import org.bukkit.command.defaults.SetWorldSpawnCommand;
import org.bukkit.command.defaults.SpawnpointCommand;
import org.bukkit.command.defaults.SpreadPlayersCommand;
import org.bukkit.command.defaults.StopCommand;
import org.bukkit.command.defaults.TeleportCommand;
import org.bukkit.command.defaults.TellCommand;
import org.bukkit.command.defaults.TestForCommand;
import org.bukkit.command.defaults.TimeCommand;
import org.bukkit.command.defaults.TimingsCommand;
import org.bukkit.command.defaults.ToggleDownfallCommand;
import org.bukkit.command.defaults.VanillaCommand;
import org.bukkit.command.defaults.VersionCommand;
import org.bukkit.command.defaults.WeatherCommand;
import org.bukkit.command.defaults.WhitelistCommand;
import org.bukkit.entity.Player;
import org.bukkit.event.TabCompleteEvent;
import org.bukkit.util.Java15Compat;
import org.bukkit.util.StringUtil;
public class SimpleCommandMap implements CommandMap {
private static final Pattern PATTERN_ON_SPACE = Pattern.compile(" ", 16);
protected final Map<String, Command> knownCommands = new HashMap<String, Command>();
private final Server server;
public SimpleCommandMap(Server server) {
this.server = server;
this.setDefaultCommands();
}
private void setDefaultCommands() {
this.register("bukkit", new SaveCommand());
this.register("bukkit", new SaveOnCommand());
this.register("bukkit", new SaveOffCommand());
this.register("bukkit", new StopCommand());
this.register("bukkit", new VersionCommand("version"));
this.register("bukkit", new ReloadCommand("reload"));
this.register("bukkit", new PluginsCommand("plugins"));
this.register("bukkit", new TimingsCommand("timings"));
}
public void setFallbackCommands() {
this.register("bukkit", new ListCommand());
this.register("bukkit", new OpCommand());
this.register("bukkit", new DeopCommand());
this.register("bukkit", new BanIpCommand());
this.register("bukkit", new PardonIpCommand());
this.register("bukkit", new BanCommand());
this.register("bukkit", new PardonCommand());
this.register("bukkit", new KickCommand());
this.register("bukkit", new TeleportCommand());
this.register("bukkit", new GiveCommand());
this.register("bukkit", new TimeCommand());
this.register("bukkit", new SayCommand());
this.register("bukkit", new WhitelistCommand());
this.register("bukkit", new TellCommand());
this.register("bukkit", new MeCommand());
this.register("bukkit", new KillCommand());
this.register("bukkit", new GameModeCommand());
this.register("bukkit", new HelpCommand());
this.register("bukkit", new ExpCommand());
this.register("bukkit", new ToggleDownfallCommand());
this.register("bukkit", new BanListCommand());
this.register("bukkit", new DefaultGameModeCommand());
this.register("bukkit", new SeedCommand());
this.register("bukkit", new DifficultyCommand());
this.register("bukkit", new WeatherCommand());
this.register("bukkit", new SpawnpointCommand());
this.register("bukkit", new ClearCommand());
this.register("bukkit", new GameRuleCommand());
this.register("bukkit", new EnchantCommand());
this.register("bukkit", new TestForCommand());
this.register("bukkit", new EffectCommand());
this.register("bukkit", new ScoreboardCommand());
this.register("bukkit", new PlaySoundCommand());
this.register("bukkit", new SpreadPlayersCommand());
this.register("bukkit", new SetWorldSpawnCommand());
this.register("bukkit", new SetIdleTimeoutCommand());
this.register("bukkit", new AchievementCommand());
}
public void registerAll(String fallbackPrefix, List<Command> commands) {
if(commands != null) {
Iterator var3 = commands.iterator();
while(var3.hasNext()) {
Command c = (Command)var3.next();
this.register(fallbackPrefix, c);
}
}
}
public boolean register(String fallbackPrefix, Command command) {
return this.register(command.getName(), fallbackPrefix, command);
}
public boolean register(String label, String fallbackPrefix, Command command) {
label = label.toLowerCase().trim();
fallbackPrefix = fallbackPrefix.toLowerCase().trim();
boolean registered = this.register(label, command, false, fallbackPrefix);
Iterator iterator = command.getAliases().iterator();
while(iterator.hasNext()) {
if(!this.register((String)iterator.next(), command, true, fallbackPrefix)) {
iterator.remove();
}
}
if(!registered) {
command.setLabel(fallbackPrefix + ":" + label);
}
command.register(this);
return registered;
}
private synchronized boolean register(String label, Command command, boolean isAlias, String fallbackPrefix) {
this.knownCommands.put(fallbackPrefix + ":" + label, command);
if((command instanceof VanillaCommand || isAlias) && this.knownCommands.containsKey(label)) {
return false;
} else {
boolean registered = true;
Command conflict = (Command)this.knownCommands.get(label);
if(conflict != null && conflict.getLabel().equals(label)) {
return false;
} else {
if(!isAlias) {
command.setLabel(label);
}
this.knownCommands.put(label, command);
return registered;
}
}
}
public boolean dispatch(CommandSender sender, String commandLine) throws CommandException {
String[] args = PATTERN_ON_SPACE.split(commandLine);
if(args.length == 0) {
return false;
} else {
String sentCommandLabel = args[0].toLowerCase();
Command target = this.getCommand(sentCommandLabel);
if(target == null) {
return false;
} else {
try {
target.timings.startTiming();
target.execute(sender, sentCommandLabel, (String[])Java15Compat.Arrays_copyOfRange(args, 1, args.length));
target.timings.stopTiming();
return true;
} catch (CommandException var7) {
target.timings.stopTiming();
throw var7;
} catch (Throwable var8) {
target.timings.stopTiming();
throw new CommandException("Unhandled exception executing \'" + commandLine + "\' in " + target, var8);
}
}
}
}
public synchronized void clearCommands() {
Iterator var1 = this.knownCommands.entrySet().iterator();
while(var1.hasNext()) {
Entry entry = (Entry)var1.next();
((Command)entry.getValue()).unregister(this);
}
this.knownCommands.clear();
this.setDefaultCommands();
}
public Command getCommand(String name) {
Command target = (Command)this.knownCommands.get(name.toLowerCase());
return target;
}
public List<String> tabComplete(CommandSender sender, String cmdLine) {
Validate.notNull(sender, "Sender cannot be null");
Validate.notNull(cmdLine, "Command line cannot null");
int spaceIndex = cmdLine.indexOf(32);
String argLine;
if(spaceIndex == -1) {
ArrayList commandName1 = new ArrayList();
Map target1 = this.knownCommands;
argLine = sender instanceof Player?"/":"";
Iterator args1 = target1.entrySet().iterator();
while(args1.hasNext()) {
Entry ex = (Entry)args1.next();
Command command = (Command)ex.getValue();
if(command.testPermissionSilent(sender)) {
String name = (String)ex.getKey();
if(StringUtil.startsWithIgnoreCase(name, cmdLine)) {
commandName1.add(argLine + name);
}
}
}
Collections.sort(commandName1, String.CASE_INSENSITIVE_ORDER);
return commandName1;
} else {
String commandName = cmdLine.substring(0, spaceIndex);
Command target = this.getCommand(commandName);
argLine = cmdLine.substring(spaceIndex + 1, cmdLine.length());
String[] args = PATTERN_ON_SPACE.split(argLine, -1);
TabCompleteEvent event = new TabCompleteEvent(sender, commandName, args);
if (target != null) {
try {
event.getSuggestions().addAll(target.tabComplete(sender, commandName, args));
} catch (CommandException var11) {
throw var11;
} catch (Throwable var12) {
throw new CommandException("Unhandled exception executing tab-completer for \'" + cmdLine + "\' in " + target, var12);
}
}
server.getPluginManager().callEvent(event);
return event.getSuggestions();
}
}
public Collection<Command> getCommands() {
return Collections.unmodifiableCollection(this.knownCommands.values());
}
public void registerServerAliases() {
Map values = this.server.getCommandAliases();
Iterator var2 = values.keySet().iterator();
while(var2.hasNext()) {
String alias = (String)var2.next();
if(!alias.contains(":") && !alias.contains(" ")) {
String[] commandStrings = (String[])values.get(alias);
ArrayList targets = new ArrayList();
StringBuilder bad = new StringBuilder();
String[] var7 = commandStrings;
int var8 = commandStrings.length;
for(int var9 = 0; var9 < var8; ++var9) {
String commandString = var7[var9];
String[] commandArgs = commandString.split(" ");
Command command = this.getCommand(commandArgs[0]);
if(command == null) {
if(bad.length() > 0) {
bad.append(", ");
}
bad.append(commandString);
} else {
targets.add(commandString);
}
}
if(bad.length() > 0) {
this.server.getLogger().warning("Could not register alias " + alias + " because it contains commands that do not exist: " + bad);
} else if(targets.size() > 0) {
this.knownCommands.put(alias.toLowerCase(), new FormattedCommandAlias(alias.toLowerCase(), (String[])targets.toArray(new String[targets.size()])));
} else {
this.knownCommands.remove(alias.toLowerCase());
}
} else {
this.server.getLogger().warning("Could not register alias " + alias + " because it contains illegal characters");
}
}
}
}

View File

@ -1,61 +0,0 @@
package org.bukkit.event;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.command.CommandSender;
public class TabCompleteEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private CommandSender _sender;
private String _command;
private String[] _args;
private List<String> _suggestions;
public TabCompleteEvent(CommandSender sender, String command, String[] args)
{
_sender = sender;
_command = command;
_args = args;
_suggestions = new ArrayList<String>();
}
public CommandSender getSender()
{
return _sender;
}
public String getCommand()
{
return _command;
}
public String[] getArgs()
{
return _args;
}
public List<String> getSuggestions()
{
return _suggestions;
}
public void setSuggestions(List<String> suggestions)
{
_suggestions = suggestions;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -1,77 +0,0 @@
package org.bukkit.scoreboard;
import java.util.Set;
import org.bukkit.OfflinePlayer;
public abstract interface Team
{
public abstract String getName()
throws IllegalStateException;
public abstract String getDisplayName()
throws IllegalStateException;
public abstract void setDisplayName(String paramString)
throws IllegalStateException, IllegalArgumentException;
public abstract String getPrefix()
throws IllegalStateException;
public abstract void setPrefix(String paramString)
throws IllegalStateException, IllegalArgumentException;
public abstract String getSuffix()
throws IllegalStateException;
public abstract void setSuffix(String paramString)
throws IllegalStateException, IllegalArgumentException;
public abstract boolean allowFriendlyFire()
throws IllegalStateException;
// Mineplex
public abstract void setNameTagVisibility(TeamNameTagVisibility visibility)
throws IllegalStateException;
public abstract void setAllowFriendlyFire(boolean paramBoolean)
throws IllegalStateException;
public abstract boolean canSeeFriendlyInvisibles()
throws IllegalStateException;
public abstract void setCanSeeFriendlyInvisibles(boolean paramBoolean)
throws IllegalStateException;
public abstract Set<OfflinePlayer> getPlayers()
throws IllegalStateException;
public abstract Set<String> getEntries()
throws IllegalStateException;
public abstract int getSize()
throws IllegalStateException;
public abstract Scoreboard getScoreboard();
public abstract void addPlayer(OfflinePlayer paramOfflinePlayer)
throws IllegalStateException, IllegalArgumentException;
public abstract void addEntry(String paramString)
throws IllegalStateException, IllegalArgumentException;
public abstract boolean removePlayer(OfflinePlayer paramOfflinePlayer)
throws IllegalStateException, IllegalArgumentException;
public abstract boolean removeEntry(String paramString)
throws IllegalStateException, IllegalArgumentException;
public abstract void unregister()
throws IllegalStateException;
public abstract boolean hasPlayer(OfflinePlayer paramOfflinePlayer)
throws IllegalArgumentException, IllegalStateException;
public abstract boolean hasEntry(String paramString)
throws IllegalArgumentException, IllegalStateException;
}

View File

@ -1,22 +0,0 @@
package org.bukkit.scoreboard;
/**
* Created by shaun on 14-10-05.
*/
public enum TeamNameTagVisibility
{
NEVER("never"), HIDE_FOR_OTHER_TEAMS("hideForOtherTeams"), HIDE_FOR_OWN_TEAM("hideForOwnTeam"), ALWAYS("always");
private String _keyword;
TeamNameTagVisibility(String keyword)
{
_keyword = keyword;
}
@Override
public String toString()
{
return _keyword;
}
}

View File

@ -8,6 +8,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.ServerData"/> <classpathentry combineaccessrules="false" kind="src" path="/Mineplex.ServerData"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpclient-4.2.jar"/> <classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpclient-4.2.jar"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpcore-4.2.jar"/> <classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpcore-4.2.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.PlayerCache"/> <classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Cache"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@ -1,11 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7

View File

@ -13,6 +13,6 @@
<orderEntry type="module" module-name="Mineplex.ServerData" /> <orderEntry type="module" module-name="Mineplex.ServerData" />
<orderEntry type="library" name="httpcore" level="project" /> <orderEntry type="library" name="httpcore" level="project" />
<orderEntry type="library" name="httpclient" level="project" /> <orderEntry type="library" name="httpclient" level="project" />
<orderEntry type="module" module-name="Mineplex.PlayerCache" /> <orderEntry type="module" module-name="Mineplex.Cache" />
</component> </component>
</module> </module>

View File

@ -56,11 +56,12 @@ public class MotdManager implements Listener, Runnable
//String motdLine = "§f§l◄ §c§lMaintenance§f§l ►"; //String motdLine = "§f§l◄ §c§lMaintenance§f§l ►";
//String motdLine = "§f§l◄ §a§lCarl the Creeper§f§l ►"; //String motdLine = "§f§l◄ §a§lCarl the Creeper§f§l ►";
// String motdLine = " §2§l§n M O N S T E R M A Z E B E T A §f"; // String motdLine = " §2§l§n M O N S T E R M A Z E B E T A §f";
String motdLine = " §f§l◄ §b§lNew Game§f§l ▬ §3§lChampions CTF§f§l ►"; String motdLine = " §f❄ §2§lMerry Christmas §f❄ §2§lElf Presents §f❄";
// String motdLine = " §f❄ §2§lServer Maintenance §f❄ §2§lBe Back Soon §f❄";
//String motdLine = " §d§lRank Sale §a§l40% Off"); //String motdLine = " §d§lRank Sale §a§l40% Off");
//String motdLine = " §f§l◄§c§lMAINTENANCE§f§l►"); //String motdLine = " §f§l◄§c§lMAINTENANCE§f§l►");
updateMainMotd(" §f§l§m §8§l§m[ §r §6§lMineplex§r §f§lGames§r §8§l§m ]§f§l§m §r", motdLine); updateMainMotd(" §c§m §f§m §c§m §f§m §2§l§m[ §r §c§lMineplex§r §f§lGames§r §2§l§m ]§f§m §c§m §f§m §c§m §r", motdLine);
System.out.println("Updated Bungee MOTD"); System.out.println("Updated Bungee MOTD");
} }
} }

View File

@ -5,8 +5,8 @@ import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import mineplex.bungee.playerStats.data.IpInfo; import mineplex.bungee.playerStats.data.IpInfo;
import mineplex.playerCache.PlayerCache; import mineplex.cache.player.PlayerCache;
import mineplex.playerCache.PlayerInfo; import mineplex.cache.player.PlayerInfo;
import net.md_5.bungee.api.event.PlayerDisconnectEvent; import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.PostLoginEvent; import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.api.plugin.Listener;

View File

@ -9,7 +9,7 @@ import java.sql.Statement;
import java.util.UUID; import java.util.UUID;
import mineplex.bungee.playerStats.data.IpInfo; import mineplex.bungee.playerStats.data.IpInfo;
import mineplex.playerCache.PlayerInfo; import mineplex.cache.player.PlayerInfo;
public class PlayerStatsRepository public class PlayerStatsRepository
{ {

View File

@ -1,11 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7

View File

@ -51,13 +51,13 @@ public abstract class DnsMadeEasyApiCallBase
try try
{ {
String timeStamp = getServerTime(); String timeStamp = getServerTime();
SecretKeySpec keySpec = new SecretKeySpec("35bb3b97-3815-4b63-b60b-eb1882c07b40".getBytes(), "HmacSHA1"); SecretKeySpec keySpec = new SecretKeySpec("9041bc01-5cbc-49cf-ae09-a23b98350c62".getBytes(), "HmacSHA1");
Mac mac = Mac.getInstance("HmacSHA1"); Mac mac = Mac.getInstance("HmacSHA1");
mac.init(keySpec); mac.init(keySpec);
byte[] hashBytes = mac.doFinal((timeStamp + "").getBytes()); byte[] hashBytes = mac.doFinal((timeStamp + "").getBytes());
Hex.encodeHexString(hashBytes); Hex.encodeHexString(hashBytes);
request.addHeader("x-dnsme-apiKey", "a9750980-b7df-4a7e-a047-2ade43628f0d"); request.addHeader("x-dnsme-apiKey", "2039c697-6ca9-412f-abda-0aef659a382a");
request.addHeader("x-dnsme-requestDate", timeStamp + ""); request.addHeader("x-dnsme-requestDate", timeStamp + "");
request.addHeader("x-dnsme-hmac", Hex.encodeHexString(hashBytes)); request.addHeader("x-dnsme-hmac", Hex.encodeHexString(hashBytes));
request.addHeader("Content-Type", "application/json"); request.addHeader("Content-Type", "application/json");

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>Mineplex.PlayerCache</name> <name>Mineplex.Cache</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>

View File

@ -1,4 +1,4 @@
package mineplex.playerCache; package mineplex.cache.player;
import java.util.UUID; import java.util.UUID;
@ -39,7 +39,7 @@ public class PlayerCache
catch (Exception exception) catch (Exception exception)
{ {
System.out.println("Error adding player info in PlayerCache : " + exception.getMessage()); System.out.println("Error adding player info in PlayerCache : " + exception.getMessage());
exception.printStackTrace(); // exception.printStackTrace();
} }
} }

View File

@ -1,4 +1,4 @@
package mineplex.playerCache; package mineplex.cache.player;
import java.util.UUID; import java.util.UUID;

View File

@ -1,11 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7

View File

@ -0,0 +1,57 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
/**
* The {@code TAG_Byte_Array} tag.
*/
public final class ByteArrayTag extends Tag {
private final byte[] value;
/**
* Creates the tag with an empty name.
*
* @param value the value of the tag
*/
public ByteArrayTag(byte[] value) {
super();
this.value = value;
}
@Override
public byte[] getValue() {
return value;
}
@Override
public String toString() {
StringBuilder hex = new StringBuilder();
for (byte b : value) {
String hexDigits = Integer.toHexString(b).toUpperCase();
if (hexDigits.length() == 1) {
hex.append("0");
}
hex.append(hexDigits).append(" ");
}
return "TAG_Byte_Array(" + hex + ")";
}
}

View File

@ -0,0 +1,49 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
/**
* The {@code TAG_Byte} tag.
*/
public final class ByteTag extends Tag {
private final byte value;
/**
* Creates the tag with an empty name.
*
* @param value the value of the tag
*/
public ByteTag(byte value) {
super();
this.value = value;
}
@Override
public Byte getValue() {
return value;
}
@Override
public String toString() {
return "TAG_Byte(" + value + ")";
}
}

View File

@ -0,0 +1,420 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* The {@code TAG_Compound} tag.
*/
public final class CompoundTag extends Tag {
private final Map<String, Tag> value;
/**
* Creates the tag with an empty name.
*
* @param value the value of the tag
*/
public CompoundTag(Map<String, Tag> value) {
super();
this.value = Collections.unmodifiableMap(value);
}
/**
* Returns whether this compound tag contains the given key.
*
* @param key the given key
* @return true if the tag contains the given key
*/
public boolean containsKey(String key) {
return value.containsKey(key);
}
@Override
public Map<String, Tag> getValue() {
return value;
}
/**
* Return a new compound tag with the given values.
*
* @param value the value
* @return the new compound tag
*/
public CompoundTag setValue(Map<String, Tag> value) {
return new CompoundTag(value);
}
/**
* Create a compound tag builder.
*
* @return the builder
*/
public CompoundTagBuilder createBuilder() {
return new CompoundTagBuilder(new HashMap<String, Tag>(value));
}
/**
* Get a byte array named with the given key.
*
* <p>If the key does not exist or its value is not a byte array tag,
* then an empty byte array will be returned.</p>
*
* @param key the key
* @return a byte array
*/
public byte[] getByteArray(String key) {
Tag tag = value.get(key);
if (tag instanceof ByteArrayTag) {
return ((ByteArrayTag) tag).getValue();
} else {
return new byte[0];
}
}
/**
* Get a byte named with the given key.
*
* <p>If the key does not exist or its value is not a byte tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a byte
*/
public byte getByte(String key) {
Tag tag = value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else {
return (byte) 0;
}
}
/**
* Get a double named with the given key.
*
* <p>If the key does not exist or its value is not a double tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a double
*/
public double getDouble(String key) {
Tag tag = value.get(key);
if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a double named with the given key, even if it's another
* type of number.
*
* <p>If the key does not exist or its value is not a number,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a double
*/
public double asDouble(String key) {
Tag tag = value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue();
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a float named with the given key.
*
* <p>If the key does not exist or its value is not a float tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a float
*/
public float getFloat(String key) {
Tag tag = value.get(key);
if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a {@code int[]} named with the given key.
*
* <p>If the key does not exist or its value is not an int array tag,
* then an empty array will be returned.</p>
*
* @param key the key
* @return an int array
*/
public int[] getIntArray(String key) {
Tag tag = value.get(key);
if (tag instanceof IntArrayTag) {
return ((IntArrayTag) tag).getValue();
} else {
return new int[0];
}
}
/**
* Get an int named with the given key.
*
* <p>If the key does not exist or its value is not an int tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return an int
*/
public int getInt(String key) {
Tag tag = value.get(key);
if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get an int named with the given key, even if it's another
* type of number.
*
* <p>If the key does not exist or its value is not a number,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return an int
*/
public int asInt(String key) {
Tag tag = value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue().intValue();
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().intValue();
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().intValue();
} else {
return 0;
}
}
/**
* Get a list of tags named with the given key.
*
* <p>If the key does not exist or its value is not a list tag,
* then an empty list will be returned.</p>
*
* @param key the key
* @return a list of tags
*/
public List<Tag> getList(String key) {
Tag tag = value.get(key);
if (tag instanceof ListTag) {
return ((ListTag) tag).getValue();
} else {
return Collections.emptyList();
}
}
/**
* Get a {@code TagList} named with the given key.
*
* <p>If the key does not exist or its value is not a list tag,
* then an empty tag list will be returned.</p>
*
* @param key the key
* @return a tag list instance
*/
public ListTag getListTag(String key) {
Tag tag = value.get(key);
if (tag instanceof ListTag) {
return (ListTag) tag;
} else {
return new ListTag(StringTag.class, Collections.<Tag>emptyList());
}
}
/**
* Get a list of tags named with the given key.
*
* <p>If the key does not exist or its value is not a list tag,
* then an empty list will be returned. If the given key references
* a list but the list of of a different type, then an empty
* list will also be returned.</p>
*
* @param key the key
* @param listType the class of the contained type
* @return a list of tags
* @param <T> the type of list
*/
@SuppressWarnings("unchecked")
public <T extends Tag> List<T> getList(String key, Class<T> listType) {
Tag tag = value.get(key);
if (tag instanceof ListTag) {
ListTag listTag = (ListTag) tag;
if (listTag.getType().equals(listType)) {
return (List<T>) listTag.getValue();
} else {
return Collections.emptyList();
}
} else {
return Collections.emptyList();
}
}
/**
* Get a long named with the given key.
*
* <p>If the key does not exist or its value is not a long tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a long
*/
public long getLong(String key) {
Tag tag = value.get(key);
if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
} else {
return 0L;
}
}
/**
* Get a long named with the given key, even if it's another
* type of number.
*
* <p>If the key does not exist or its value is not a number,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a long
*/
public long asLong(String key) {
Tag tag = value.get(key);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().longValue();
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().longValue();
} else {
return 0L;
}
}
/**
* Get a short named with the given key.
*
* <p>If the key does not exist or its value is not a short tag,
* then {@code 0} will be returned.</p>
*
* @param key the key
* @return a short
*/
public short getShort(String key) {
Tag tag = value.get(key);
if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a string named with the given key.
*
* <p>If the key does not exist or its value is not a string tag,
* then {@code ""} will be returned.</p>
*
* @param key the key
* @return a string
*/
public String getString(String key) {
Tag tag = value.get(key);
if (tag instanceof StringTag) {
return ((StringTag) tag).getValue();
} else {
return "";
}
}
@Override
public String toString() {
StringBuilder bldr = new StringBuilder();
bldr.append("TAG_Compound").append(": ").append(value.size()).append(" entries\r\n{\r\n");
for (Map.Entry<String, Tag> entry : value.entrySet()) {
bldr.append(" ").append(entry.getValue().toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
}
bldr.append("}");
return bldr.toString();
}
}

View File

@ -0,0 +1,204 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
import java.util.HashMap;
import java.util.Map;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Helps create compound tags.
*/
public class CompoundTagBuilder {
private final Map<String, Tag> entries;
/**
* Create a new instance.
*/
CompoundTagBuilder() {
this.entries = new HashMap<String, Tag>();
}
/**
* Create a new instance and use the given map (which will be modified).
*
* @param value the value
*/
CompoundTagBuilder(Map<String, Tag> value) {
checkNotNull(value);
this.entries = value;
}
/**
* Put the given key and tag into the compound tag.
*
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder put(String key, Tag value) {
checkNotNull(key);
checkNotNull(value);
entries.put(key, value);
return this;
}
/**
* Put the given key and value into the compound tag as a
* {@code ByteArrayTag}.
*
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putByteArray(String key, byte[] value) {
return put(key, new ByteArrayTag(value));
}
/**
* Put the given key and value into the compound tag as a
* {@code ByteTag}.
*
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putByte(String key, byte value) {
return put(key, new ByteTag(value));
}
/**
* Put the given key and value into the compound tag as a
* {@code DoubleTag}.
*
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putDouble(String key, double value) {
return put(key, new DoubleTag(value));
}
/**
* Put the given key and value into the compound tag as a
* {@code FloatTag}.
*
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putFloat(String key, float value) {
return put(key, new FloatTag(value));
}
/**
* Put the given key and value into the compound tag as a
* {@code IntArrayTag}.
*
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putIntArray(String key, int[] value) {
return put(key, new IntArrayTag(value));
}
/**
* Put the given key and value into the compound tag as an {@code IntTag}.
*
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putInt(String key, int value) {
return put(key, new IntTag(value));
}
/**
* Put the given key and value into the compound tag as a
* {@code LongTag}.
*
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putLong(String key, long value) {
return put(key, new LongTag(value));
}
/**
* Put the given key and value into the compound tag as a
* {@code ShortTag}.
*
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putShort(String key, short value) {
return put(key, new ShortTag(value));
}
/**
* Put the given key and value into the compound tag as a
* {@code StringTag}.
*
* @param key they key
* @param value the value
* @return this object
*/
public CompoundTagBuilder putString(String key, String value) {
return put(key, new StringTag(value));
}
/**
* Put all the entries from the given map into this map.
*
* @param value the map of tags
* @return this object
*/
public CompoundTagBuilder putAll(Map<String, ? extends Tag> value) {
checkNotNull(value);
for (Map.Entry<String, ? extends Tag> entry : value.entrySet()) {
put(entry.getKey(), entry.getValue());
}
return this;
}
/**
* Build an unnamed compound tag with this builder's entries.
*
* @return the new compound tag
*/
public CompoundTag build() {
return new CompoundTag(new HashMap<String, Tag>(entries));
}
/**
* Create a new builder instance.
*
* @return a new builder
*/
public static CompoundTagBuilder create() {
return new CompoundTagBuilder();
}
}

View File

@ -0,0 +1,50 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
/**
* The {@code TAG_Double} tag.
*
*/
public final class DoubleTag extends Tag {
private final double value;
/**
* Creates the tag with an empty name.
*
* @param value the value of the tag
*/
public DoubleTag(double value) {
super();
this.value = value;
}
@Override
public Double getValue() {
return value;
}
@Override
public String toString() {
return "TAG_Double(" + value + ")";
}
}

View File

@ -0,0 +1,37 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
/**
* The {@code TAG_End} tag.
*/
public final class EndTag extends Tag {
@Override
public Object getValue() {
return null;
}
@Override
public String toString() {
return "TAG_End";
}
}

View File

@ -0,0 +1,49 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
/**
* The {@code TAG_Float} tag.
*/
public final class FloatTag extends Tag {
private final float value;
/**
* Creates the tag with an empty name.
*
* @param value the value of the tag
*/
public FloatTag(float value) {
super();
this.value = value;
}
@Override
public Float getValue() {
return value;
}
@Override
public String toString() {
return "TAG_Float(" + value + ")";
}
}

View File

@ -0,0 +1,60 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* The {@code TAG_Int_Array} tag.
*/
public final class IntArrayTag extends Tag {
private final int[] value;
/**
* Creates the tag with an empty name.
*
* @param value the value of the tag
*/
public IntArrayTag(int[] value) {
super();
checkNotNull(value);
this.value = value;
}
@Override
public int[] getValue() {
return value;
}
@Override
public String toString() {
StringBuilder hex = new StringBuilder();
for (int b : value) {
String hexDigits = Integer.toHexString(b).toUpperCase();
if (hexDigits.length() == 1) {
hex.append("0");
}
hex.append(hexDigits).append(" ");
}
return "TAG_Int_Array(" + hex + ")";
}
}

View File

@ -0,0 +1,49 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
/**
* The {@code TAG_Int} tag.
*/
public final class IntTag extends Tag {
private final int value;
/**
* Creates the tag with an empty name.
*
* @param value the value of the tag
*/
public IntTag(int value) {
super();
this.value = value;
}
@Override
public Integer getValue() {
return value;
}
@Override
public String toString() {
return "TAG_Int(" + value + ")";
}
}

View File

@ -0,0 +1,431 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.NoSuchElementException;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* The {@code TAG_List} tag.
*/
public final class ListTag extends Tag {
private final Class<? extends Tag> type;
private final List<Tag> value;
/**
* Creates the tag with an empty name.
*
* @param type the type of tag
* @param value the value of the tag
*/
public ListTag(Class<? extends Tag> type, List<? extends Tag> value) {
super();
checkNotNull(value);
this.type = type;
this.value = Collections.unmodifiableList(value);
}
/**
* Gets the type of item in this list.
*
* @return The type of item in this list.
*/
public Class<? extends Tag> getType() {
return type;
}
@Override
public List<Tag> getValue() {
return value;
}
/**
* Create a new list tag with this tag's name and type.
*
* @param list the new list
* @return a new list tag
*/
public ListTag setValue(List<Tag> list) {
return new ListTag(getType(), list);
}
/**
* Get the tag if it exists at the given index.
*
* @param index the index
* @return the tag or null
*/
@Nullable
public Tag getIfExists(int index) {
try {
return value.get(index);
} catch (NoSuchElementException e) {
return null;
}
}
/**
* Get a byte array named with the given index.
*
* <p>If the index does not exist or its value is not a byte array tag,
* then an empty byte array will be returned.</p>
*
* @param index the index
* @return a byte array
*/
public byte[] getByteArray(int index) {
Tag tag = getIfExists(index);
if (tag instanceof ByteArrayTag) {
return ((ByteArrayTag) tag).getValue();
} else {
return new byte[0];
}
}
/**
* Get a byte named with the given index.
*
* <p>If the index does not exist or its value is not a byte tag,
* then {@code 0} will be returned.</p>
*
* @param index the index
* @return a byte
*/
public byte getByte(int index) {
Tag tag = getIfExists(index);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else {
return (byte) 0;
}
}
/**
* Get a double named with the given index.
*
* <p>If the index does not exist or its value is not a double tag,
* then {@code 0} will be returned.</p>
*
* @param index the index
* @return a double
*/
public double getDouble(int index) {
Tag tag = getIfExists(index);
if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a double named with the given index, even if it's another
* type of number.
*
* <p>If the index does not exist or its value is not a number,
* then {@code 0} will be returned.</p>
*
* @param index the index
* @return a double
*/
public double asDouble(int index) {
Tag tag = getIfExists(index);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue();
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a float named with the given index.
*
* <p>If the index does not exist or its value is not a float tag,
* then {@code 0} will be returned.</p>
*
* @param index the index
* @return a float
*/
public float getFloat(int index) {
Tag tag = getIfExists(index);
if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a {@code int[]} named with the given index.
*
* <p>If the index does not exist or its value is not an int array tag,
* then an empty array will be returned.</p>
*
* @param index the index
* @return an int array
*/
public int[] getIntArray(int index) {
Tag tag = getIfExists(index);
if (tag instanceof IntArrayTag) {
return ((IntArrayTag) tag).getValue();
} else {
return new int[0];
}
}
/**
* Get an int named with the given index.
*
* <p>If the index does not exist or its value is not an int tag,
* then {@code 0} will be returned.</p>
*
* @param index the index
* @return an int
*/
public int getInt(int index) {
Tag tag = getIfExists(index);
if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get an int named with the given index, even if it's another
* type of number.
*
* <p>If the index does not exist or its value is not a number,
* then {@code 0} will be returned.</p>
*
* @param index the index
* @return an int
*/
public int asInt(int index) {
Tag tag = getIfExists(index);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue().intValue();
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().intValue();
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().intValue();
} else {
return 0;
}
}
/**
* Get a list of tags named with the given index.
*
* <p>If the index does not exist or its value is not a list tag,
* then an empty list will be returned.</p>
*
* @param index the index
* @return a list of tags
*/
public List<Tag> getList(int index) {
Tag tag = getIfExists(index);
if (tag instanceof ListTag) {
return ((ListTag) tag).getValue();
} else {
return Collections.emptyList();
}
}
/**
* Get a {@code TagList} named with the given index.
*
* <p>If the index does not exist or its value is not a list tag,
* then an empty tag list will be returned.</p>
*
* @param index the index
* @return a tag list instance
*/
public ListTag getListTag(int index) {
Tag tag = getIfExists(index);
if (tag instanceof ListTag) {
return (ListTag) tag;
} else {
return new ListTag(StringTag.class, Collections.<Tag>emptyList());
}
}
/**
* Get a list of tags named with the given index.
*
* <p>If the index does not exist or its value is not a list tag,
* then an empty list will be returned. If the given index references
* a list but the list of of a different type, then an empty
* list will also be returned.</p>
*
* @param index the index
* @param listType the class of the contained type
* @return a list of tags
* @param <T> the NBT type
*/
@SuppressWarnings("unchecked")
public <T extends Tag> List<T> getList(int index, Class<T> listType) {
Tag tag = getIfExists(index);
if (tag instanceof ListTag) {
ListTag listTag = (ListTag) tag;
if (listTag.getType().equals(listType)) {
return (List<T>) listTag.getValue();
} else {
return Collections.emptyList();
}
} else {
return Collections.emptyList();
}
}
/**
* Get a long named with the given index.
*
* <p>If the index does not exist or its value is not a long tag,
* then {@code 0} will be returned.</p>
*
* @param index the index
* @return a long
*/
public long getLong(int index) {
Tag tag = getIfExists(index);
if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
} else {
return 0L;
}
}
/**
* Get a long named with the given index, even if it's another
* type of number.
*
* <p>If the index does not exist or its value is not a number,
* then {@code 0} will be returned.</p>
*
* @param index the index
* @return a long
*/
public long asLong(int index) {
Tag tag = getIfExists(index);
if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().longValue();
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().longValue();
} else {
return 0;
}
}
/**
* Get a short named with the given index.
*
* <p>If the index does not exist or its value is not a short tag,
* then {@code 0} will be returned.</p>
*
* @param index the index
* @return a short
*/
public short getShort(int index) {
Tag tag = getIfExists(index);
if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else {
return 0;
}
}
/**
* Get a string named with the given index.
*
* <p>If the index does not exist or its value is not a string tag,
* then {@code ""} will be returned.</p>
*
* @param index the index
* @return a string
*/
public String getString(int index) {
Tag tag = getIfExists(index);
if (tag instanceof StringTag) {
return ((StringTag) tag).getValue();
} else {
return "";
}
}
@Override
public String toString() {
StringBuilder bldr = new StringBuilder();
bldr.append("TAG_List").append(": ").append(value.size()).append(" entries of type ").append(NBTUtils.getTypeName(type)).append("\r\n{\r\n");
for (Tag t : value) {
bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
}
bldr.append("}");
return bldr.toString();
}
}

View File

@ -0,0 +1,119 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Helps create list tags.
*/
public class ListTagBuilder {
private final Class<? extends Tag> type;
private final List<Tag> entries;
/**
* Create a new instance.
*
* @param type of tag contained in this list
*/
ListTagBuilder(Class<? extends Tag> type) {
checkNotNull(type);
this.type = type;
this.entries = new ArrayList<Tag>();
}
/**
* Add the given tag.
*
* @param value the tag
* @return this object
*/
public ListTagBuilder add(Tag value) {
checkNotNull(value);
if (!type.isInstance(value)) {
throw new IllegalArgumentException(value.getClass().getCanonicalName() + " is not of expected type " + type.getCanonicalName());
}
entries.add(value);
return this;
}
/**
* Add all the tags in the given list.
*
* @param value a list of tags
* @return this object
*/
public ListTagBuilder addAll(Collection<? extends Tag> value) {
checkNotNull(value);
for (Tag v : value) {
add(v);
}
return this;
}
/**
* Build an unnamed list tag with this builder's entries.
*
* @return the new list tag
*/
public ListTag build() {
return new ListTag(type, new ArrayList<Tag>(entries));
}
/**
* Create a new builder instance.
*
* @return a new builder
*/
public static ListTagBuilder create(Class<? extends Tag> type) {
return new ListTagBuilder(type);
}
/**
* Create a new builder instance.
*
* @return a new builder
*/
public static <T extends Tag> ListTagBuilder createWith(T ... entries) {
checkNotNull(entries);
if (entries.length == 0) {
throw new IllegalArgumentException("This method needs an array of at least one entry");
}
Class<? extends Tag> type = entries[0].getClass();
for (int i = 1; i < entries.length; i++) {
if (!type.isInstance(entries[i])) {
throw new IllegalArgumentException("An array of different tag types was provided");
}
}
ListTagBuilder builder = new ListTagBuilder(type);
builder.addAll(Arrays.asList(entries));
return builder;
}
}

View File

@ -0,0 +1,50 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
/**
* The {@code TAG_Long} tag.
*
*/
public final class LongTag extends Tag {
private final long value;
/**
* Creates the tag with an empty name.
*
* @param value the value of the tag
*/
public LongTag(long value) {
super();
this.value = value;
}
@Override
public Long getValue() {
return value;
}
@Override
public String toString() {
return "TAG_Long(" + value + ")";
}
}

View File

@ -0,0 +1,81 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
import java.nio.charset.Charset;
/**
* A class which holds constant values.
*/
public final class NBTConstants {
public static final Charset CHARSET = Charset.forName("UTF-8");
public static final int TYPE_END = 0, TYPE_BYTE = 1, TYPE_SHORT = 2,
TYPE_INT = 3, TYPE_LONG = 4, TYPE_FLOAT = 5, TYPE_DOUBLE = 6,
TYPE_BYTE_ARRAY = 7, TYPE_STRING = 8, TYPE_LIST = 9,
TYPE_COMPOUND = 10, TYPE_INT_ARRAY = 11;
/**
* Default private constructor.
*/
private NBTConstants() {
}
/**
* Convert a type ID to its corresponding {@link Tag} class.
*
* @param id type ID
* @return tag class
* @throws IllegalArgumentException thrown if the tag ID is not valid
*/
public static Class<? extends Tag> getClassFromType(int id) {
switch (id) {
case TYPE_END:
return EndTag.class;
case TYPE_BYTE:
return ByteTag.class;
case TYPE_SHORT:
return ShortTag.class;
case TYPE_INT:
return IntTag.class;
case TYPE_LONG:
return LongTag.class;
case TYPE_FLOAT:
return FloatTag.class;
case TYPE_DOUBLE:
return DoubleTag.class;
case TYPE_BYTE_ARRAY:
return ByteArrayTag.class;
case TYPE_STRING:
return StringTag.class;
case TYPE_LIST:
return ListTag.class;
case TYPE_COMPOUND:
return CompoundTag.class;
case TYPE_INT_ARRAY:
return IntArrayTag.class;
default:
throw new IllegalArgumentException("Unknown tag type ID of " + id);
}
}
}

View File

@ -0,0 +1,171 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
import java.io.Closeable;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* This class reads <strong>NBT</strong>, or <strong>Named Binary Tag</strong>
* streams, and produces an object graph of subclasses of the {@code Tag}
* object.
*
* <p>The NBT format was created by Markus Persson, and the specification may be
* found at <a href="http://www.minecraft.net/docs/NBT.txt">
* http://www.minecraft.net/docs/NBT.txt</a>.</p>
*/
public final class NBTInputStream implements Closeable {
private final DataInputStream is;
/**
* Creates a new {@code NBTInputStream}, which will source its data
* from the specified input stream.
*
* @param is the input stream
* @throws IOException if an I/O error occurs
*/
public NBTInputStream(InputStream is) throws IOException {
this.is = new DataInputStream(is);
}
/**
* Reads an NBT tag from the stream.
*
* @return The tag that was read.
* @throws IOException if an I/O error occurs.
*/
public NamedTag readNamedTag() throws IOException {
return readNamedTag(0);
}
/**
* Reads an NBT from the stream.
*
* @param depth the depth of this tag
* @return The tag that was read.
* @throws IOException if an I/O error occurs.
*/
private NamedTag readNamedTag(int depth) throws IOException {
int type = is.readByte() & 0xFF;
String name;
if (type != NBTConstants.TYPE_END) {
int nameLength = is.readShort() & 0xFFFF;
byte[] nameBytes = new byte[nameLength];
is.readFully(nameBytes);
name = new String(nameBytes, NBTConstants.CHARSET);
} else {
name = "";
}
return new NamedTag(name, readTagPayload(type, depth));
}
/**
* Reads the payload of a tag given the type.
*
* @param type the type
* @param depth the depth
* @return the tag
* @throws IOException if an I/O error occurs.
*/
private Tag readTagPayload(int type, int depth) throws IOException {
switch (type) {
case NBTConstants.TYPE_END:
if (depth == 0) {
throw new IOException(
"TAG_End found without a TAG_Compound/TAG_List tag preceding it.");
} else {
return new EndTag();
}
case NBTConstants.TYPE_BYTE:
return new ByteTag(is.readByte());
case NBTConstants.TYPE_SHORT:
return new ShortTag(is.readShort());
case NBTConstants.TYPE_INT:
return new IntTag(is.readInt());
case NBTConstants.TYPE_LONG:
return new LongTag(is.readLong());
case NBTConstants.TYPE_FLOAT:
return new FloatTag(is.readFloat());
case NBTConstants.TYPE_DOUBLE:
return new DoubleTag(is.readDouble());
case NBTConstants.TYPE_BYTE_ARRAY:
int length = is.readInt();
byte[] bytes = new byte[length];
is.readFully(bytes);
return new ByteArrayTag(bytes);
case NBTConstants.TYPE_STRING:
length = is.readShort();
bytes = new byte[length];
is.readFully(bytes);
return new StringTag(new String(bytes, NBTConstants.CHARSET));
case NBTConstants.TYPE_LIST:
int childType = is.readByte();
length = is.readInt();
List<Tag> tagList = new ArrayList<Tag>();
for (int i = 0; i < length; ++i) {
Tag tag = readTagPayload(childType, depth + 1);
if (tag instanceof EndTag) {
throw new IOException("TAG_End not permitted in a list.");
}
tagList.add(tag);
}
return new ListTag(NBTUtils.getTypeClass(childType), tagList);
case NBTConstants.TYPE_COMPOUND:
Map<String, Tag> tagMap = new HashMap<String, Tag>();
while (true) {
NamedTag namedTag = readNamedTag(depth + 1);
Tag tag = namedTag.getTag();
if (tag instanceof EndTag) {
break;
} else {
tagMap.put(namedTag.getName(), tag);
}
}
return new CompoundTag(tagMap);
case NBTConstants.TYPE_INT_ARRAY:
length = is.readInt();
int[] data = new int[length];
for (int i = 0; i < length; i++) {
data[i] = is.readInt();
}
return new IntArrayTag(data);
default:
throw new IOException("Invalid tag type: " + type + ".");
}
}
@Override
public void close() throws IOException {
is.close();
}
}

View File

@ -0,0 +1,294 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
import java.io.Closeable;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* This class writes <strong>NBT</strong>, or <strong>Named Binary Tag</strong>
* {@code Tag} objects to an underlying {@code OutputStream}.
*
* <p>The NBT format was created by Markus Persson, and the specification may be
* found at <a href="http://www.minecraft.net/docs/NBT.txt">
* http://www.minecraft.net/docs/NBT.txt</a>.</p>
*/
public final class NBTOutputStream implements Closeable {
/**
* The output stream.
*/
private final DataOutputStream os;
/**
* Creates a new {@code NBTOutputStream}, which will write data to the
* specified underlying output stream.
*
* @param os
* The output stream.
* @throws IOException
* if an I/O error occurs.
*/
public NBTOutputStream(OutputStream os) throws IOException {
this.os = new DataOutputStream(os);
}
/**
* Writes a tag.
*
* @param tag
* The tag to write.
* @throws IOException
* if an I/O error occurs.
*/
public void writeNamedTag(String name, Tag tag) throws IOException {
checkNotNull(name);
checkNotNull(tag);
int type = NBTUtils.getTypeCode(tag.getClass());
byte[] nameBytes = name.getBytes(NBTConstants.CHARSET);
os.writeByte(type);
os.writeShort(nameBytes.length);
os.write(nameBytes);
if (type == NBTConstants.TYPE_END) {
throw new IOException("Named TAG_End not permitted.");
}
writeTagPayload(tag);
}
/**
* Writes tag payload.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
private void writeTagPayload(Tag tag) throws IOException {
int type = NBTUtils.getTypeCode(tag.getClass());
switch (type) {
case NBTConstants.TYPE_END:
writeEndTagPayload((EndTag) tag);
break;
case NBTConstants.TYPE_BYTE:
writeByteTagPayload((ByteTag) tag);
break;
case NBTConstants.TYPE_SHORT:
writeShortTagPayload((ShortTag) tag);
break;
case NBTConstants.TYPE_INT:
writeIntTagPayload((IntTag) tag);
break;
case NBTConstants.TYPE_LONG:
writeLongTagPayload((LongTag) tag);
break;
case NBTConstants.TYPE_FLOAT:
writeFloatTagPayload((FloatTag) tag);
break;
case NBTConstants.TYPE_DOUBLE:
writeDoubleTagPayload((DoubleTag) tag);
break;
case NBTConstants.TYPE_BYTE_ARRAY:
writeByteArrayTagPayload((ByteArrayTag) tag);
break;
case NBTConstants.TYPE_STRING:
writeStringTagPayload((StringTag) tag);
break;
case NBTConstants.TYPE_LIST:
writeListTagPayload((ListTag) tag);
break;
case NBTConstants.TYPE_COMPOUND:
writeCompoundTagPayload((CompoundTag) tag);
break;
case NBTConstants.TYPE_INT_ARRAY:
writeIntArrayTagPayload((IntArrayTag) tag);
break;
default:
throw new IOException("Invalid tag type: " + type + ".");
}
}
/**
* Writes a {@code TAG_Byte} tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
private void writeByteTagPayload(ByteTag tag) throws IOException {
os.writeByte(tag.getValue());
}
/**
* Writes a {@code TAG_Byte_Array} tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
private void writeByteArrayTagPayload(ByteArrayTag tag) throws IOException {
byte[] bytes = tag.getValue();
os.writeInt(bytes.length);
os.write(bytes);
}
/**
* Writes a {@code TAG_Compound} tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
private void writeCompoundTagPayload(CompoundTag tag) throws IOException {
for (Map.Entry<String, Tag> entry : tag.getValue().entrySet()) {
writeNamedTag(entry.getKey(), entry.getValue());
}
os.writeByte((byte) 0); // end tag - better way?
}
/**
* Writes a {@code TAG_List} tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
private void writeListTagPayload(ListTag tag) throws IOException {
Class<? extends Tag> clazz = tag.getType();
List<Tag> tags = tag.getValue();
int size = tags.size();
os.writeByte(NBTUtils.getTypeCode(clazz));
os.writeInt(size);
for (Tag tag1 : tags) {
writeTagPayload(tag1);
}
}
/**
* Writes a {@code TAG_String} tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
private void writeStringTagPayload(StringTag tag) throws IOException {
byte[] bytes = tag.getValue().getBytes(NBTConstants.CHARSET);
os.writeShort(bytes.length);
os.write(bytes);
}
/**
* Writes a {@code TAG_Double} tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
private void writeDoubleTagPayload(DoubleTag tag) throws IOException {
os.writeDouble(tag.getValue());
}
/**
* Writes a {@code TAG_Float} tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
private void writeFloatTagPayload(FloatTag tag) throws IOException {
os.writeFloat(tag.getValue());
}
/**
* Writes a {@code TAG_Long} tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
private void writeLongTagPayload(LongTag tag) throws IOException {
os.writeLong(tag.getValue());
}
/**
* Writes a {@code TAG_Int} tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
private void writeIntTagPayload(IntTag tag) throws IOException {
os.writeInt(tag.getValue());
}
/**
* Writes a {@code TAG_Short} tag.
*
* @param tag
* The tag.
* @throws IOException
* if an I/O error occurs.
*/
private void writeShortTagPayload(ShortTag tag) throws IOException {
os.writeShort(tag.getValue());
}
/**
* Writes a {@code TAG_Empty} tag.
*
* @param tag the tag
*/
private void writeEndTagPayload(EndTag tag) {
/* empty */
}
private void writeIntArrayTagPayload(IntArrayTag tag) throws IOException {
int[] data = tag.getValue();
os.writeInt(data.length);
for (int aData : data) {
os.writeInt(aData);
}
}
@Override
public void close() throws IOException {
os.close();
}
}

View File

@ -0,0 +1,170 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
import java.util.Map;
/**
* A class which contains NBT-related utility methods.
*
*/
public final class NBTUtils {
/**
* Default private constructor.
*/
private NBTUtils() {
}
/**
* Gets the type name of a tag.
*
* @param clazz the tag class
* @return The type name.
*/
public static String getTypeName(Class<? extends Tag> clazz) {
if (clazz.equals(ByteArrayTag.class)) {
return "TAG_Byte_Array";
} else if (clazz.equals(ByteTag.class)) {
return "TAG_Byte";
} else if (clazz.equals(CompoundTag.class)) {
return "TAG_Compound";
} else if (clazz.equals(DoubleTag.class)) {
return "TAG_Double";
} else if (clazz.equals(EndTag.class)) {
return "TAG_End";
} else if (clazz.equals(FloatTag.class)) {
return "TAG_Float";
} else if (clazz.equals(IntTag.class)) {
return "TAG_Int";
} else if (clazz.equals(ListTag.class)) {
return "TAG_List";
} else if (clazz.equals(LongTag.class)) {
return "TAG_Long";
} else if (clazz.equals(ShortTag.class)) {
return "TAG_Short";
} else if (clazz.equals(StringTag.class)) {
return "TAG_String";
} else if (clazz.equals(IntArrayTag.class)) {
return "TAG_Int_Array";
} else {
throw new IllegalArgumentException("Invalid tag classs ("
+ clazz.getName() + ").");
}
}
/**
* Gets the type code of a tag class.
*
* @param clazz the tag class
* @return The type code.
* @throws IllegalArgumentException if the tag class is invalid.
*/
public static int getTypeCode(Class<? extends Tag> clazz) {
if (clazz.equals(ByteArrayTag.class)) {
return NBTConstants.TYPE_BYTE_ARRAY;
} else if (clazz.equals(ByteTag.class)) {
return NBTConstants.TYPE_BYTE;
} else if (clazz.equals(CompoundTag.class)) {
return NBTConstants.TYPE_COMPOUND;
} else if (clazz.equals(DoubleTag.class)) {
return NBTConstants.TYPE_DOUBLE;
} else if (clazz.equals(EndTag.class)) {
return NBTConstants.TYPE_END;
} else if (clazz.equals(FloatTag.class)) {
return NBTConstants.TYPE_FLOAT;
} else if (clazz.equals(IntTag.class)) {
return NBTConstants.TYPE_INT;
} else if (clazz.equals(ListTag.class)) {
return NBTConstants.TYPE_LIST;
} else if (clazz.equals(LongTag.class)) {
return NBTConstants.TYPE_LONG;
} else if (clazz.equals(ShortTag.class)) {
return NBTConstants.TYPE_SHORT;
} else if (clazz.equals(StringTag.class)) {
return NBTConstants.TYPE_STRING;
} else if (clazz.equals(IntArrayTag.class)) {
return NBTConstants.TYPE_INT_ARRAY;
} else {
throw new IllegalArgumentException("Invalid tag classs ("
+ clazz.getName() + ").");
}
}
/**
* Gets the class of a type of tag.
*
* @param type the type
* @return The class.
* @throws IllegalArgumentException if the tag type is invalid.
*/
public static Class<? extends Tag> getTypeClass(int type) {
switch (type) {
case NBTConstants.TYPE_END:
return EndTag.class;
case NBTConstants.TYPE_BYTE:
return ByteTag.class;
case NBTConstants.TYPE_SHORT:
return ShortTag.class;
case NBTConstants.TYPE_INT:
return IntTag.class;
case NBTConstants.TYPE_LONG:
return LongTag.class;
case NBTConstants.TYPE_FLOAT:
return FloatTag.class;
case NBTConstants.TYPE_DOUBLE:
return DoubleTag.class;
case NBTConstants.TYPE_BYTE_ARRAY:
return ByteArrayTag.class;
case NBTConstants.TYPE_STRING:
return StringTag.class;
case NBTConstants.TYPE_LIST:
return ListTag.class;
case NBTConstants.TYPE_COMPOUND:
return CompoundTag.class;
case NBTConstants.TYPE_INT_ARRAY:
return IntArrayTag.class;
default:
throw new IllegalArgumentException("Invalid tag type : " + type
+ ".");
}
}
/**
* Get child tag of a NBT structure.
*
* @param items the map to read from
* @param key the key to look for
* @param expected the expected NBT class type
* @return child tag
* @throws IllegalArgumentException
*/
public static <T extends Tag> T getChildTag(Map<String, Tag> items, String key, Class<T> expected) throws IllegalArgumentException {
if (!items.containsKey(key)) {
throw new IllegalArgumentException("Missing a \"" + key + "\" tag");
}
Tag tag = items.get(key);
if (!expected.isInstance(tag)) {
throw new IllegalArgumentException(key + " tag is not of tag type " + expected.getName());
}
return expected.cast(tag);
}
}

View File

@ -0,0 +1,63 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* A tag that has a name.
*/
public class NamedTag {
private final String name;
private final Tag tag;
/**
* Create a new named tag.
*
* @param name the name
* @param tag the tag
*/
public NamedTag(String name, Tag tag) {
checkNotNull(name);
checkNotNull(tag);
this.name = name;
this.tag = tag;
}
/**
* Get the name of the tag.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Get the tag.
*
* @return the tag
*/
public Tag getTag() {
return tag;
}
}

View File

@ -0,0 +1,49 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
/**
* The {@code TAG_Short} tag.
*/
public final class ShortTag extends Tag {
private final short value;
/**
* Creates the tag with an empty name.
*
* @param value the value of the tag
*/
public ShortTag(short value) {
super();
this.value = value;
}
@Override
public Short getValue() {
return value;
}
@Override
public String toString() {
return "TAG_Short(" + value + ")";
}
}

View File

@ -0,0 +1,52 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* The {@code TAG_String} tag.
*/
public final class StringTag extends Tag {
private final String value;
/**
* Creates the tag with an empty name.
*
* @param value the value of the tag
*/
public StringTag(String value) {
super();
checkNotNull(value);
this.value = value;
}
@Override
public String getValue() {
return value;
}
@Override
public String toString() {
return "TAG_String(" + value + ")";
}
}

View File

@ -0,0 +1,34 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.java.sk89q.jnbt;
/**
* Represents a NBT tag.
*/
public abstract class Tag {
/**
* Gets the value of this tag.
*
* @return the value
*/
public abstract Object getValue();
}

View File

@ -5,8 +5,9 @@ import org.bukkit.Material;
public enum CurrencyType public enum CurrencyType
{ {
Tokens("Tokens", Material.EMERALD), Tokens("Tokens", Material.EMERALD),
Coins(" Coins", Material.DOUBLE_PLANT), Coins("Treasure Shards", Material.PRISMARINE_SHARD),
Gems(" Gems", Material.EMERALD); Gems("Gems", Material.EMERALD),
Gold("Gold", Material.GOLD_NUGGET);
private String _prefix; private String _prefix;
private Material _displayMaterial; private Material _displayMaterial;

View File

@ -9,50 +9,59 @@ import mineplex.core.common.util.UtilPlayer;
public enum Rank public enum Rank
{ {
//Staff //Staff
LT("Leader", ChatColor.GOLD), LT("Leader", ChatColor.GOLD, "Leaders are in charge of special teams\nsuch as the whole staff team or the support!"),
OWNER("Owner", ChatColor.GOLD), OWNER("Owner", ChatColor.GOLD, "Owners are the Founders of Mineplex\nand they all manage different parts of it!"),
DEVELOPER("Dev", ChatColor.GOLD), DEVELOPER("Dev", ChatColor.GOLD, "Developers make new games,\nand new features for you to enjoy"),
ADMIN("Admin", ChatColor.GOLD), ADMIN("Admin", ChatColor.GOLD, "Administrators have their own\nSenior Moderator team that they lead!"),
JNR_DEV("Jr.Dev", ChatColor.GOLD), JNR_DEV("Jr.Dev", ChatColor.GOLD, "Junior Developers make new games,\nand new features for you to enjoy"),
SUPPORT("Support", ChatColor.BLUE), SUPPORT("Support", ChatColor.BLUE, "Support Agents take care of all the tickets\nthat get sent to mineplex.com/support"),
SNR_MODERATOR("Sr.Mod", ChatColor.GOLD), CMOD("C.Mod", ChatColor.GOLD, "Clan Moderators are Senior Moderators in\nthe Clans Management team.\nThey mainly moderate only the Clans servers.\nThey are around to help you with any problems on Clans servers."),
MODERATOR("Mod", ChatColor.GOLD), SNR_MODERATOR("Sr.Mod", ChatColor.GOLD, "Senior Moderators are in a special\nSenior Moderator team where they have to fulfill team tasks.\nThey are similar to Moderators who you can always ask for help!\nIf you have any questions, just message them using /a"),
HELPER("Trainee", ChatColor.DARK_AQUA), MODERATOR("Mod", ChatColor.GOLD, "Moderators are here to moderate\nand help players with any concerns they have.\nIf you have any questions, just message them using /a"),
MAPLEAD("MapLead", ChatColor.BLUE), HELPER("Trainee", ChatColor.DARK_AQUA, "Trainees are staff in training,\nand are here to help players and moderate!\nIf you have any questions, just message them using /a"),
MAPDEV("Builder", ChatColor.BLUE), MAPLEAD("MapLead", ChatColor.BLUE, "Leader of the Official Build team"),
MEDIA("Media", ChatColor.BLUE), MAPDEV("Builder", ChatColor.BLUE, "Official Mineplex Map Builders"),
MEDIA("Media", ChatColor.BLUE, "Official Mineplex Artist and/or Designer"),
EVENT("Event", ChatColor.WHITE), EVENT("Event", ChatColor.WHITE, "???"),
//Media //Media
YOUTUBE("YouTube", ChatColor.RED), YOUTUBE("YouTube", ChatColor.RED, "Official Mineplex Youtuber"),
YOUTUBE_SMALL("MooTube", ChatColor.DARK_PURPLE), YOUTUBE_SMALL("YT", ChatColor.DARK_PURPLE, "Youtube Content Creators"),
TWITCH("Twitch", ChatColor.DARK_PURPLE), TWITCH("Twitch", ChatColor.DARK_PURPLE, "Official Twitch Live Streamer"),
//Player //Player
TITAN("Titan", ChatColor.RED, true), TITAN("Titan", ChatColor.RED, true, "Mineplex's fourth premium rank\nBuy Titan at mineplex.com/shop"),
LEGEND("Legend", ChatColor.GREEN, true), LEGEND("Legend", ChatColor.GREEN, true, "Mineplex's third premium rank\nBuy Legend at mineplex.com/shop"),
HERO("Hero", ChatColor.LIGHT_PURPLE, true), HERO("Hero", ChatColor.LIGHT_PURPLE, true, "Mineplex's second premium rank\nBuy Hero at mineplex.com/shop"),
ULTRA("Ultra", ChatColor.AQUA, true), ULTRA("Ultra", ChatColor.AQUA, true, "Mineplex's first premium rank\nBuy Ultra at mineplex.com/shop"),
ALL("", ChatColor.WHITE); ALL("", ChatColor.WHITE, null);
private ChatColor _color; private ChatColor _color;
private boolean _donor; private boolean _donor;
private String _info;
public String Name; public String Name;
Rank(String name, ChatColor color) Rank(String name, ChatColor color, String info)
{ {
_color = color; _color = color;
Name = name; Name = name;
_donor = false; _donor = false;
_info = info;
} }
Rank(String name, ChatColor color, boolean donor) Rank(String name, ChatColor color, boolean donor, String info)
{ {
_color = color; _color = color;
Name = name; Name = name;
_donor = donor; _donor = donor;
_info = info;
}
public String getInfo()
{
return _info;
} }
public boolean has(Rank rank) public boolean has(Rank rank)
@ -122,13 +131,13 @@ public enum Rank
switch(this) switch(this)
{ {
case ULTRA: case ULTRA:
return "Mineplexs first premium rank\n" return "Mineplexs first premium rank\n"
+ "Buy ULTRA at mineplex.com/shop!"; + "Buy ULTRA at mineplex.com/shop!";
case HERO: case HERO:
return "Mineplexs second premium rank\n" return "Mineplexs second premium rank\n"
+ "Buy HERO at mineplex.com/shop!"; + "Buy HERO at mineplex.com/shop!";
case LEGEND: case LEGEND:
return "Mineplexs third premium rank\n" return "Mineplexs third premium rank\n"
+ "Buy LEGEND at mineplex.com/shop!"; + "Buy LEGEND at mineplex.com/shop!";
case TITAN: case TITAN:
return "This is a special rank that can only be found in\n" return "This is a special rank that can only be found in\n"

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -1,4 +1,4 @@
package mineplex.core.data; package mineplex.core.common.block;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.Material; import org.bukkit.Material;

View File

@ -0,0 +1,104 @@
package mineplex.core.common.block.schematic;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
public class Schematic
{
private final short _width;
private final short _height;
private final short _length;
private final short[] _blocks;
private final byte[] _blockData;
public Schematic(short width, short height, short length, short[] blocks, byte[] blockData)
{
_width = width;
_height = height;
_length = length;
_blocks = blocks;
_blockData = blockData;
}
public void paste(Location originLocation)
{
int startX = originLocation.getBlockX();
int startY = originLocation.getBlockY();
int startZ = originLocation.getBlockZ();
for (int x = 0; x < _width; x++)
{
for (int y = 0; y < _height; y++)
{
for (int z = 0; z < _length; z++)
{
int index = getIndex(x, y, z);
Block block = originLocation.getWorld().getBlockAt(startX + x, startY + y, startZ + z);
// some blocks were giving me negative id's in the schematic (like stairs)
// not sure why but the math.abs is my simple fix
int materialId = Math.abs(_blocks[index]);
Material material = Material.getMaterial(materialId);
if (material == null)
{
System.out.println(materialId + " data: " + _blockData[index]);
continue;
}
block.setTypeIdAndData(materialId, _blockData[index], false);
}
}
}
}
public int getSize()
{
return _blocks.length;
}
public int getIndex(int x, int y, int z)
{
return y * _width * _length + z * _width + x;
}
public short getBlock(int x, int y, int z)
{
return _blocks[getIndex(x, y, z)];
}
public byte getData(int x, int y, int z)
{
return _blockData[getIndex(x, y, z)];
}
public short getWidth()
{
return _width;
}
public short getHeight()
{
return _height;
}
public short getLength()
{
return _length;
}
public short[] getBlocks()
{
return _blocks;
}
public byte[] getBlockData()
{
return _blockData;
}
@Override
public String toString()
{
return String.format("width: %d, length: %d, height: %d, blockLength: %d, blockDataLength: %d", _width, _length, _height, _blocks.length, _blockData.length);
}
}

View File

@ -0,0 +1,120 @@
package mineplex.core.common.block.schematic;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
import mineplex.core.common.block.BlockData;
import mineplex.core.common.util.Callback;
public class SchematicRunnable implements Runnable
{
private JavaPlugin _plugin;
private boolean _started;
private BukkitTask _task;
private List<BlockData> _changedBlocks;
private Callback<List<BlockData>> _callback;
private Schematic _schematic;
private Block _startBlock;
private int _currentX = 0;
private int _currentY = 0;
private int _currentZ = 0;
private int _blocksPerTick = 1000;
public SchematicRunnable(JavaPlugin plugin, Schematic schematic, Block startBlock, Callback<List<BlockData>> callback)
{
_plugin = plugin;
_changedBlocks = new ArrayList<BlockData>(schematic.getSize());
_started = false;
_callback = callback;
_schematic = schematic;
_startBlock = startBlock;
}
public void start()
{
if (!_started)
{
_task = Bukkit.getScheduler().runTaskTimer(_plugin, this, 1, 1);
_started = true;
}
}
public void pause()
{
if (_started)
{
_task.cancel();
_started = false;
}
}
public void setBlocksPerTick(int blocksPerTick)
{
_blocksPerTick = blocksPerTick;
}
@Override
public void run()
{
for (int i = 0; i < _blocksPerTick; i++)
{
setBlock(_startBlock.getRelative(_currentX, _currentY, _currentZ), _currentX, _currentY, _currentZ);
_currentX++;
if (_currentX >= _schematic.getWidth())
{
_currentX = 0;
_currentZ++;
if (_currentZ >= _schematic.getLength())
{
_currentZ = 0;
_currentY++;
if (_currentY >= _schematic.getHeight())
{
// We are done
System.out.println("Finished importing schematic with setblockrunnable!");
if (_callback != null)
_callback.run(_changedBlocks);
_task.cancel();
return;
}
}
}
}
}
private void setBlock(Block block, int x, int y, int z)
{
int materialId = _schematic.getBlock(x, y, z);
byte data = _schematic.getData(x, y, z);
Material material = Material.getMaterial(materialId);
if (material == null)
{
System.out.println("Failed to find material with id: " + materialId);
return;
}
if (block.getTypeId() == materialId && block.getData() == data)
return;
BlockData blockData = new BlockData(block);
_changedBlocks.add(blockData);
block.setTypeIdAndData(materialId, data, false);
}
}

View File

@ -0,0 +1,76 @@
package mineplex.core.common.block.schematic;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Map;
import java.util.zip.GZIPInputStream;
import com.java.sk89q.jnbt.ByteArrayTag;
import com.java.sk89q.jnbt.CompoundTag;
import com.java.sk89q.jnbt.NBTInputStream;
import com.java.sk89q.jnbt.NamedTag;
import com.java.sk89q.jnbt.ShortTag;
import com.java.sk89q.jnbt.Tag;
public class UtilSchematic
{
public static Schematic loadSchematic(File file) throws IOException
{
FileInputStream fis = new FileInputStream(file);
NBTInputStream nbtStream = new NBTInputStream(new GZIPInputStream(fis));
NamedTag rootTag = nbtStream.readNamedTag();
nbtStream.close();
if (!rootTag.getName().equals("Schematic"))
return null;
CompoundTag schematicTag = (CompoundTag) rootTag.getTag();
Map<String, Tag> schematic = schematicTag.getValue();
short width = getChildTag(schematic, "Width", ShortTag.class).getValue();
short height = getChildTag(schematic, "Height", ShortTag.class).getValue();
short length = getChildTag(schematic, "Length", ShortTag.class).getValue();
byte[] blockId = getChildTag(schematic, "Blocks", ByteArrayTag.class).getValue();
byte[] addId = new byte[0];
short[] blocks = new short[blockId.length];
byte[] blockData = getChildTag(schematic, "Data", ByteArrayTag.class).getValue();
if (schematic.containsKey("AddBlocks"))
{
addId = getChildTag(schematic, "AddBlocks", ByteArrayTag.class).getValue();
}
for (int index = 0; index < blockId.length; index++)
{
if ((index >> 1) >= addId.length)
blocks[index] = (short) (blockId[index] & 0xFF);
else
{
if ((index & 1) == 0)
blocks[index] = (short) (((addId[index >> 1] & 0x0F) << 8) + (blockId[index] & 0xFF));
else
blocks[index] = (short) (((addId[index >> 1] & 0xF0) << 4) + (blockId[index] & 0xFF));
}
}
return new Schematic(width, height, length, blocks, blockData);
}
private static <T extends Tag> T getChildTag(Map<String, Tag> items, String key, Class<T> expected)
{
Tag tag = items.get(key);
return expected.cast(tag);
}
public static void main(String[] args) throws IOException
{
File file = new File("test.schematic");
System.out.println(file.getAbsoluteFile());
Schematic m = UtilSchematic.loadSchematic(file);
System.out.println(m);
}
}

View File

@ -0,0 +1,33 @@
package mineplex.core.common.events;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin;
public class ServerShutdownEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private JavaPlugin _plugin;
public ServerShutdownEvent(JavaPlugin plugin)
{
_plugin = plugin;
}
public JavaPlugin getPlugin()
{
return _plugin;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -0,0 +1,78 @@
package mineplex.core.common.player;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
public class PlayerSnapshot
{
private Location _location;
private ItemStack[] _armor;
private ItemStack[] _items;
private double _health;
private int _hunger;
private float _saturation;
private float _exhaustion;
private int _experience;
private Vector _velocity;
private PlayerSnapshot(Location location, ItemStack[] armor, ItemStack[] items, double health, int hunger, float saturation, float exhaustion, int experience, Vector velocity)
{
_location = location;
_armor = armor;
_items = items;
_health = health;
_hunger = hunger;
_saturation = saturation;
_exhaustion = exhaustion;
_experience = experience;
_velocity = velocity;
}
public void applySnapshot(Player player)
{
player.teleport(_location);
player.getInventory().setArmorContents(_armor);
player.getInventory().setContents(_items);
player.setHealth(_health);
player.setFoodLevel(_hunger);
player.setSaturation(_saturation);
player.setExhaustion(_exhaustion);
player.setVelocity(_velocity);
player.setTotalExperience(_experience);
}
public static PlayerSnapshot getSnapshot(Player player)
{
Location location = player.getLocation();
// Inventory
ItemStack[] bArmor = player.getInventory().getArmorContents();
ItemStack[] armor = new ItemStack[bArmor.length];
for (int i = 0; i < bArmor.length; i++)
{
armor[i] = bArmor[i];
}
ItemStack[] bItems = player.getInventory().getContents();
ItemStack[] items = new ItemStack[bItems.length];
for (int i = 0; i < bItems.length; i++)
{
items[i] = bItems[i];
}
// Health
double health = player.getHealth();
int hunger = player.getFoodLevel();
float saturation = player.getSaturation();
float exhaustion = player.getExhaustion();
int experience = player.getTotalExperience();
Vector velocity = player.getVelocity();
return new PlayerSnapshot(location, armor, items, health, hunger, saturation, exhaustion, experience, velocity);
}
}

View File

@ -0,0 +1,97 @@
package mineplex.core.common.skin;
import java.util.List;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import net.minecraft.server.v1_8_R3.Item;
import net.minecraft.server.v1_8_R3.MinecraftKey;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.NBTTagList;
import net.minecraft.server.v1_8_R3.NBTTagString;
public class SkinData
{
private static long _nameCount = -99999999999999L;
public final static SkinData MOOSHROOM = new SkinData("eyJ0aW1lc3RhbXAiOjE0NDk4NzI0OTU0MTcsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzIxOWJlYTU0Y2FkN2Q1OGFiNWRhNDA2YjBhOTJhYjNhODI0MjI1MjY2Nzc3ZTUzNGI3ZGI2YzM3MmRkZmY3ZiJ9fX0=","UoSif81+UyvkcaanU8KAMYBpw9mefAmWehE2liDUFvk+y0X/9NovsxTYVpIDCltTSpLW3sNgamvbj4Ybs+s6DbudPiEkvh0ER7Bv2v29UJw7RzIdr6/1g548X12zcnh5iPGz/P75uNRnSfTFQx0ed8P/GNkPIjWpDuJFxEj6KcPzrCAGMx+BVw1VwryBIYf9cCDHky8z0bxR89rjiIvPTBFI6MRhqI3vgpEBTySHDS+Ki0Hwl5oa3PwS6+jgYx/4RSfFsb+BawcvDk2Xpkt5UimvqZ5BceYLIfCt4KbShYipgLXLfYUZrntjPemd3SxthjxUuA07i44UxRdiC8uqy1twLT/HUS28gpk68lA/id9tKFwu1CUzshgcmvQPt3ghtNViNziR/2t7D/+5D31Vzmhf6n7Pnpdirt/5frMi2BKMMs7pLa0EF8CrrDU7QCwPav+EZVGFvVZbxSkCDq+n3IQ3PUWSCzy6KPxpdOlUjD0pAfLoiNj0P8u4+puQtID76r/St8ExchYl2dodUImu1ZETWeFUClF3ZGat62evx8uRQEI2W4dsVwj40VUfjaAuvyDzuouaKTrCzJXLQZZjR1B8URvuK61fGX0nhW607mEi6DE+nxP2ZoBrROEX4e37Ap6+TQn9Q8tKDPdcxtwSOpPO4Qkncjn/mGtP9lZU/DQ=");
public final static SkinData SNOWMAN = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk4Nzk5NDIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzEzMTgxYWViODQzODk3NzM1ZDQwMmIyNDk2OTQxNmZkYjBjZTM0YTZiOTM3ODE2MjQzNzU2ZTlkYWU1OGUzIn19fQ==","NZvsNu+HQ5uvGWq6O8VNDGq9A145bmk2IkHiz916uRVPMRqqCI/zwhKWNLlFACE/feuLkhYAois29ec6sVVOtHIoNA+S5q1Mb/Vjc3TJQxzqmx2FZOhJiIttFwYuo9WomQKBqrPMSJ9tpQig4wzoqldeeTjWC3dLz7JeX+gkzinryVjG7NNN9L5hXK5/BBxRcrtwmXJfUlSANyrd8RZW7mEUgU8yxlzdqTu0w7bZLjQNd4vciwoF3NelXDorMIIqiHTkuQesG91Njtu25VCUDK3nXbqEnZw2ZtxB5fT5G2Omm/vkNSRXc0P7iqchVowdYQcMlQUsp65xpkBbFS4LwjzDkYIfLmF++hePb8z72Gz77FxhO5sRLGreSH227McyL/0CtWNKm9ZZIfQtZZjEZTj9+eiJMCloCMg3yWa1VBOiLHzz0wY6gGklccIImPyXEg7E0dIK8qYseJMhmmBNZ8pDOkbUDp3mRlrQ2iyClgQkbuR63j79IBUaCxmsa3NnrAtaJklzd9mzkHXfMBh2XT7Gl8AhJS6JK5kCvip1rBBI8yjrsjE/E+lyJFIbC4rXxyMDGZWkcdrd7U4ZFYKiLHbzdFRqX+11qs9xO2BvomGXkATCzYmOf2kQ86R6rNN0+JfE4QpKzj2WWt3C8ky2qpuXZz29p0816E3/qseYtgg=");
public final static SkinData SANTA = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk3OTM3NTgsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2MyNTM5ZGFkZDUxYmE5ZTg0YzFhOTE1OTY3NWUxZTJiYWM1NmFlNmFlNTMxNTQyZDI1YTlkM2Q1YzQ2ODZmNiJ9fX0=","gvLc0Vo6+1vl17vrFCbK1eNqa4/ix4xiwcWae7WOCvqiVIX4sdIPagOGUrKsDdEhuWCKkTWILGP1K3wYfC9v/0mXZvbu0sRln+APTOsswMkQmbKcA1zTFTMpwEI+nIMzYJSbIx5wjz28K5hDf/umtHH2GADTENdJGGUtU4CyEdeHTzcqIAEV3bcMLkfTKvwKUWqI5gZbbercqmDeGkmXVS9297a9paRX1NfEL9pFT0pjdH3tCjgvvKfAwGC6tYtvTFbfcJocqgI+PI2f5OFf62A4XjWwWFi4wxCHVYNpqs/XTbfF64K7KVE0d9gsLjJoB8DMZPxlNpMFA0R5OIW6Q7Qjyz9IKxUqEYRCQbuUKpHyNDcmVKcTJRwBpCHeqAbTbweZHd5tzrT/terWhLEMsK1+lH2KBfIRIRB9kd3epyShNjSEKoly6uRXVxU+IJtfcq0aFVZlwgG3c1Ds9jbsNJV158e1n6WCmvT00RLdvpcIekwUKODhi3zFeFkrVvV50tGYqXLRZenitLJvDzx4c0IGK4krALrUS0oybinBS7/GmW3Ktz3xbGKZSzzaDw0EKB7Y6XHdb4yqR1xS7lAWgv4cNDEIUSzUDJ7HpmDCIF2A5kPS4XVYFCclyR6qPGD5e+9apVhBMz4lfYlT1IfRAUQlucO4UpAlkXs7ho3pQXU=");
public final static SkinData PRESENT = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk3MDIxNjIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2U2YzRkZWQwNTdjMjhiMTU0NjVkYzQzNmFmODIyYTNkZTY4NzgyZTZjMzgyOGMzMmFhYWE4ZjRiOTIzOWVjIn19fQ==","rJNlxTqHHmOoWwbXdMQLcj0P9w/PIr/hWKXH0nbhm/S2CFo/zfefffZlnQmpKCgn1Y8tXvcRwLGQ4CLpm9m2ZrKprSWRhrnOtZWYabrhExQESEammS3TY81VoNt+4On0pAGBippz/bRfWLuDne2rDbhuljnqvxjROmxpky7gRCU06VMlm2WLFC5XYJkiAaOXBqzpiHMMRPNnCvtcbtpILKi/Luj302eyN8nRKjHHbbiDmttwvlshxZ8UxJHvALtM506IUHba10Q6QX2zCeDAU5/WYRKa6e19r8plROcgGbKYFSq8JW5cWuWT3/rveZM6FnU6ABn9DWsCyfQ5wr2jdBd+xaevGTAScRHA5J493GqL1bBZYKj9yhQFtxJHCAf0++raAVPCZgyPtwTth4TAQisn8gnhM5R+txnW6xK+oflLy0dwEN1YdPLN/h7yuDnyjSMDe9RZT2NKMjok2C6Kux4WBI0KFXKC5Gqwa3Htku4v3WEOWMaVoWOtchQ9BzpQ/etD0ylmzjALQLB+HtndEEm1Jd3tmob42X4hBE8hCce7C3EtGINB33dlx4CK1xBqyGTJEqi69DJRzVL99u98+7kJ1Db9+MaPOfI4B2RY3XbvnSYwecandY//A3bb19FGSdl299ZXbp4zpm8fivzeB1rUAhhmtaA3Iwu/nEQNMkU=");
public final static SkinData RUDOLPH = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk1NjgxODIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2IzZjdlMjhiNTJkZjJjZjhlZWM2NDk2ZmM0NWFlMGQ2NTM0Njc5OGIxYWRjNzM3ZDcxYzBmOTRlNDIyMSJ9fX0=","uUBOTe63CL+qRvtsb2g4AjB2YzxE3N6AUqIsTv8n0jYyPsuXpuOmZPSMEdgDVONywEJ1L4XRx05sjnGu56A8vuXmGI/uHQWuMZzbOSjiFfT3DkEm8zEl5AWpH9dz/t8nZ1WYUIwy0pN5VrZqIr1DAkF6AMh/Qy+FGDw1GG9ReRr80eJ0JiRskpkCpCZIGGjrgwNKAM8JOuNZ4gCQOTRC3etrcfls3qmUMFcVlhuB4bydxSR01i2w0A4b5KpufsJjLKw4InWn2+m/druo8hl9sYuusTeItW0MQmZqCAqXCc9YBnRPQ0hDXFgnPxOh3RwGWiZvL4MnWUVmLwZWh/Fk9QmyVbd7zVao0lxS8YNsKtP8j5B+hs4l9qNohhf0A07bt4oPeTtd5fQeOU5N87fUGuUAcpC4gP9U5WpVY5FFPBvLvGbXdV5jpuAQz4lLSoo1grsP9baR2IBvdN/0awjQWoPJfGOttegubkBHwz3LNcVqvZLtX/M13IDHZa6zQZEX0wsnMX60LeWgBWfTON1l2cSgaPTerHFS2EifJ2LvTBife3s9/4XR6Zth3FLFqxI3MSlqT2hVFRPLke6rBqfqPoWOj2MCykQ70IAwb3oTHcJDJ86V2DdNaU2bZ8V4TjaP+nRobsLJOImoPYEPq23MP36X8gbXEIjmuu8S5xRlrrc=");
public final static SkinData THE_GRINCH = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTYxNDMwMDQsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzg4ZWRlOTI3ZDQzOWVmMzliMzFhYzFkYzJhODM5NGZlNzlhY2U4NDMyNzBjYmUxMjg2ZGM3NTE3ZjMxYTk2In19fQ==","ELo594vTzPq9ZmPYOtVr4kim/k19gzmoxEIK1ehS87gwgag5HcgM+P1FMnHIyrmSvTVaMh0NxwXmNS+JETFL7OrmgRYNpkxkkO4VBA0pfSn3dA9ujnXpDnDiWEPxKdMgQspIOOI0Z3esNt3pj8qIj6dWPtGwtso48tjHl2o/kazfa82yvGORlFhGkeEJKQMno/Buc12C0foQw39XI8GjvlSkFN2eH4Fp16RLu8/hf7SqJQC3L1KacvzMW1d8BWEIgACCJDni29+YqxflSqSyYrV4Z+D66S0jYvUUL/vM4/q/p/YWX/vs/FtMtHQTj4PCpAmMNTgfkahuhb6rCvKHukbjA+WhUdwyxSqXU5YnpXCu1M2dzZgiXjIi+fnyn4CmXKindWCQtSwu+mCA2ILv/6vEHoYJgdlz+DXyRkFx+DH4Sl74HBCOXTOq5AGjq5h3LYfsre+UjCCUv8VgxbVprOyj35So7K0m+6faCFVSt35T3RgicDQfdiWUrW7kmHQVvJpvaq9Vu+63F/0X93cwqwaR0buMirxRx7qkFrRunSI4T+9fsN02t1fAieeu80lBSv83wr7BFneSsLsdVAND9xttTb6fClg7anr8/XVEVIkylB4B+ZcWQbH61XP1nn7oFP2VBg1h6XuuLp8FGSgYf/LW+54/KZci/MnanqQE6QQ=");
private Property _skinProperty;
public SkinData(String value, String signature)
{
_skinProperty = new Property("textures", value, signature);
}
public SkinData(GameProfile profile)
{
_skinProperty = profile.getProperties().get("textures").iterator().next();
}
public SkinData(Player player)
{
this(((CraftPlayer)player).getProfile());
}
public ItemStack getSkull()
{
NBTTagCompound arrayElement = new NBTTagCompound();
arrayElement.setString("Value", _skinProperty.getValue());
arrayElement.setString("Signature", _skinProperty.getSignature());
NBTTagList textures = new NBTTagList();
textures.add(arrayElement);
NBTTagCompound properties = new NBTTagCompound();
properties.set("textures", textures);
NBTTagCompound skullOwner = new NBTTagCompound();
skullOwner.set("Properties", properties);
skullOwner.set("Name", new NBTTagString(getUnusedSkullName()));
NBTTagCompound tag = new NBTTagCompound();
tag.set("SkullOwner", skullOwner);
net.minecraft.server.v1_8_R3.ItemStack nmsItem = new net.minecraft.server.v1_8_R3.ItemStack(Item.REGISTRY.get(new MinecraftKey("skull")), 1, 3);
nmsItem.setTag(tag);
return CraftItemStack.asBukkitCopy(nmsItem);
}
public ItemStack getSkull(String name, List<String> lore)
{
ItemStack stack = getSkull();
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(name);
meta.setLore(lore);
stack.setItemMeta(meta);
return stack;
}
public Property getProperty()
{
return new Property(_skinProperty.getName(), _skinProperty.getValue(), _skinProperty.getSignature());
}
public static String getUnusedSkullName()
{
_nameCount++;
return "_" + _nameCount;
}
}

View File

@ -4,12 +4,15 @@ import org.bukkit.ChatColor;
public class C public class C
{ {
public static final String blankLine = ChatColor.RESET + " ";
public static String Scramble = "§k"; public static String Scramble = "§k";
public static String Bold = "§l"; public static String Bold = "§l";
public static String Strike = "§m"; public static String Strike = "§m";
public static String BoldStrike = "§l§m"; public static String BoldStrike = "§l§m";
public static String Line = "§n"; public static String Line = "§n";
public static String Italics = "§o"; public static String Italics = "§o";
public static String Reset = "§r";
public static String cAqua = "" + ChatColor.AQUA; public static String cAqua = "" + ChatColor.AQUA;
public static String cBlack = "" + ChatColor.BLACK; public static String cBlack = "" + ChatColor.BLACK;
@ -87,22 +90,26 @@ public class C
public static String chat = "" + ChatColor.WHITE; public static String chat = "" + ChatColor.WHITE;
public static String xBorderlands = "" + ChatColor.GOLD; public static String xBorderlands = "" + ChatColor.GOLD;
public static String xWilderness = "" + ChatColor.YELLOW; public static String xWilderness = "" + ChatColor.GRAY;
public static String xMid = "" + ChatColor.WHITE; public static String xMid = "" + ChatColor.WHITE;
public static String xNone = "" + ChatColor.GRAY; public static ChatColor xNone = ChatColor.YELLOW;
public static ChatColor xAdmin = ChatColor.WHITE; public static ChatColor xAdmin = ChatColor.WHITE;
public static ChatColor xSafe = ChatColor.AQUA; public static ChatColor xSafe = ChatColor.AQUA;
public static ChatColor xNeutral = ChatColor.YELLOW;
public static ChatColor xSelf = ChatColor.AQUA; public static ChatColor xSelf = ChatColor.AQUA;
public static ChatColor xAlly = ChatColor.GREEN; public static ChatColor xAlly = ChatColor.GREEN;
public static ChatColor xEnemy = ChatColor.YELLOW; public static ChatColor xEnemy = ChatColor.RED;
public static ChatColor xWar = ChatColor.RED; public static ChatColor xWarWinning = ChatColor.LIGHT_PURPLE;
public static ChatColor xWarLosing = ChatColor.RED;
public static ChatColor xPillage = ChatColor.LIGHT_PURPLE; public static ChatColor xPillage = ChatColor.LIGHT_PURPLE;
public static ChatColor xdNeutral = ChatColor.GOLD;
public static ChatColor xdSelf = ChatColor.DARK_AQUA; public static ChatColor xdSelf = ChatColor.DARK_AQUA;
public static ChatColor xdAlly = ChatColor.DARK_GREEN; public static ChatColor xdAlly = ChatColor.DARK_GREEN;
public static ChatColor xdEnemy = ChatColor.GOLD; public static ChatColor xdEnemy = ChatColor.DARK_RED;
public static ChatColor xdWar = ChatColor.DARK_RED; public static ChatColor xdWarWinning = ChatColor.DARK_PURPLE;
public static ChatColor xdWarLosing = ChatColor.DARK_RED;
public static ChatColor xdPillage = ChatColor.DARK_PURPLE; public static ChatColor xdPillage = ChatColor.DARK_PURPLE;
} }

View File

@ -0,0 +1,62 @@
package mineplex.core.common.util;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
public class ColorFader {
private final int _loopsBetween;
private final List<RGBData> _colors;
private final LoopIterator<RGBData> _iterator;
private int _loopsSinceLast;
public ColorFader(int loopsBetweenColors, RGBData... colors)
{
this(loopsBetweenColors, Arrays.asList(colors));
}
public ColorFader(int loopsBetweenColors, List<RGBData> colors)
{
_loopsBetween = loopsBetweenColors;
_colors = new LinkedList<>(colors);
_iterator = new LoopIterator<>(_colors);
}
public RGBData next()
{
RGBData rgb;
if (_loopsSinceLast >= _loopsBetween)
{
rgb = _iterator.next();
_loopsSinceLast = 0;
}
else
{
int redStep = (_iterator.peekNext().getFullRed() - _iterator.current().getFullRed()) / _loopsBetween;
int greenStep = (_iterator.peekNext().getFullGreen() - _iterator.current().getFullGreen()) / _loopsBetween;
int blueStep = (_iterator.peekNext().getFullBlue() - _iterator.current().getFullBlue()) / _loopsBetween;
int red = _iterator.current().getFullRed();
int green = _iterator.current().getFullGreen();
int blue = _iterator.current().getFullBlue();
for (int i = 0; i < _loopsSinceLast; i++)
{
red += redStep;
green += greenStep;
blue += blueStep;
}
rgb = new RGBData(red, green, blue);
}
_loopsSinceLast++;
return rgb;
}
}

View File

@ -2,6 +2,8 @@ package mineplex.core.common.util;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import java.util.LinkedList;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
public class F public class F
@ -42,9 +44,9 @@ public class F
return C.sysHead + head + "> " + C.sysBody + body; return C.sysHead + head + "> " + C.sysBody + body;
} }
public static String elem(String elem) public static String elem(Object elem)
{ {
return C.mElem + elem + ChatColor.RESET + C.mBody; return C.mElem + elem.toString() + ChatColor.RESET + C.mBody;
} }
public static String name(String elem) public static String name(String elem)
@ -106,6 +108,11 @@ public class F
return rank.getTag(false, false); return rank.getTag(false, false);
} }
public static String value(String variable, int value)
{
return value(variable, "" + value);
}
public static String value(String variable, String value) public static String value(String variable, String value)
{ {
return value(0, variable, value); return value(0, variable, value);
@ -193,5 +200,19 @@ public class F
return out; return out;
} }
public static String vowelAN(String word)
{
return word.toLowerCase().startsWith("a")
|| word.toLowerCase().startsWith("A")
|| word.toLowerCase().startsWith("e")
|| word.toLowerCase().startsWith("E")
|| word.toLowerCase().startsWith("i")
|| word.toLowerCase().startsWith("I")
|| word.toLowerCase().startsWith("o")
|| word.toLowerCase().startsWith("O")
|| word.toLowerCase().startsWith("u")
|| word.toLowerCase().startsWith("U")
? "an" : "a";
}
} }

View File

@ -0,0 +1,18 @@
package mineplex.core.common.util;
public enum LineFormat
{
LORE(220), CHAT(319);
private int _length;
private LineFormat(int length)
{
_length = length;
}
public int getLength()
{
return _length;
}
}

View File

@ -0,0 +1,83 @@
package mineplex.core.common.util;
import java.util.List;
public class LoopIterator<T>
{
private List<T> _list;
private int _pointer;
public LoopIterator(List<T> list)
{
_list = list;
}
public T next()
{
if (_list.isEmpty())
{
return null;
}
if (++_pointer == _list.size())
{
_pointer = 0;
}
return _list.get(_pointer);
}
public T peekNext()
{
if (_list.isEmpty())
{
return null;
}
int pointer = _pointer;
if (++pointer == _list.size())
{
pointer = 0;
}
return _list.get(pointer);
}
public T peekPrev()
{
if (_list.isEmpty())
{
return null;
}
int pointer = _pointer;
if (--pointer < 0)
{
pointer = _list.size() - 1;
}
return _list.get(pointer);
}
public T prev()
{
if (_list.isEmpty())
{
return null;
}
if (--_pointer < 0)
{
_pointer = _list.size() - 1;
}
return _list.get(_pointer);
}
public T current()
{
return _list.get(_pointer);
}
}

View File

@ -0,0 +1,132 @@
package mineplex.core.common.util;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
public class NautArrayList<Elem>
{
private ArrayList<Elem> _wrappedArrayList = new ArrayList<Elem>();
public boolean add(Elem elem)
{
return _wrappedArrayList.add(elem);
}
public void add(int index, Elem elem)
{
_wrappedArrayList.add(index, elem);
}
public boolean addAll(Collection<? extends Elem> elements)
{
return _wrappedArrayList.addAll(elements);
}
public boolean addAll(int index, Collection<? extends Elem> elements)
{
return _wrappedArrayList.addAll(index, elements);
}
public void clear()
{
_wrappedArrayList.clear();
}
public boolean contains(Elem elem)
{
return _wrappedArrayList.contains(elem);
}
public boolean containsAll(Collection<? extends Elem> elements)
{
return _wrappedArrayList.containsAll(elements);
}
public Elem get(int index)
{
return _wrappedArrayList.get(index);
}
public boolean equals(Object o)
{
return _wrappedArrayList.equals(o);
}
public int hashCode()
{
return _wrappedArrayList.hashCode();
}
public int indexOf(Elem elem)
{
return _wrappedArrayList.indexOf(elem);
}
public boolean isEmpty()
{
return _wrappedArrayList.isEmpty();
}
public Iterator<Elem> iterator()
{
return _wrappedArrayList.iterator();
}
public int lastIndexOf(Elem elem)
{
return _wrappedArrayList.lastIndexOf(elem);
}
public ListIterator<Elem> listIterator()
{
return _wrappedArrayList.listIterator();
}
public ListIterator<Elem> listIterator(int index)
{
return _wrappedArrayList.listIterator(index);
}
public Elem remove(int index)
{
return _wrappedArrayList.remove(index);
}
public boolean remove(Elem element)
{
return _wrappedArrayList.remove(element);
}
public boolean removeAll(Collection<? extends Elem> elements)
{
return _wrappedArrayList.removeAll(elements);
}
public boolean retainAll(Collection<? extends Elem> elements)
{
return _wrappedArrayList.retainAll(elements);
}
public Elem set(int index, Elem element)
{
return _wrappedArrayList.set(index, element);
}
public int size()
{
return _wrappedArrayList.size();
}
public List<Elem> subList(int begin, int end)
{
return _wrappedArrayList.subList(begin, end);
}
public Object[] toArray()
{
return _wrappedArrayList.toArray();
}
}

View File

@ -0,0 +1,33 @@
package mineplex.core.common.util;
public class NonFinalInteger
{
private int _value;
public NonFinalInteger()
{
this(0);
}
public NonFinalInteger(int value)
{
_value = value;
}
public NonFinalInteger add(int value)
{
_value += value;
return this;
}
public NonFinalInteger subtract(int value)
{
_value -= value;
return this;
}
public int get()
{
return _value;
}
}

View File

@ -0,0 +1,42 @@
package mineplex.core.common.util;
public class NumericalPulser
{
private double _min;
private double _max;
private double _modifyPerCall;
private double _cur;
private boolean _up;
public NumericalPulser(double min, double max, double modify)
{
_min = min;
_max = max;
_modifyPerCall = modify;
}
public double pulse()
{
if (_up)
{
_cur = UtilMath.clamp(_cur += _modifyPerCall, _min, _max);
if (_cur >= _max)
{
_up = false;
}
}
else
{
_cur = UtilMath.clamp(_cur -= _modifyPerCall, _min, _max);
if (_cur <= _min)
{
_up = true;
}
}
return _cur;
}
}

View File

@ -0,0 +1,53 @@
package mineplex.core.common.util;
public class RGBData
{
private double _red;
private double _green;
private double _blue;
public RGBData(int red, int green, int blue)
{
_red = UtilMath.clamp(((double) red) / 255.d, 0, 1);
_green = UtilMath.clamp(((double) green) / 255.d, 0, 1);
_blue = UtilMath.clamp(((double) blue) / 255.d, 0, 1);
}
public int getFullRed()
{
return (int) (_red * 255);
}
public int getFullGreen()
{
return (int) (_green * 255);
}
public int getFullBlue()
{
return (int) (_blue * 255);
}
public double getRed()
{
return _red;
}
public double getGreen()
{
return _green;
}
public double getBlue()
{
return _blue;
}
public String toString()
{
return "RGB["
+ "red=" + (int) (_red * 255) + ", "
+ "green=" + (int) (_green * 255) + ", "
+ "blue=" + (int) (_blue * 255) + "]";
}
}

View File

@ -1,6 +1,8 @@
package mineplex.core.common.util; package mineplex.core.common.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
@ -8,16 +10,24 @@ import java.util.TreeSet;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.EulerAngle; import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
public class UtilAlg public class UtilAlg
{ {
public static TreeSet<String> sortKey(Set<String> toSort) public static TreeSet<String> sortKey(Set<String> toSort)
{ {
TreeSet<String> sortedSet = new TreeSet<String>(); return sortSet(toSort, null);
for (String cur : toSort) }
public static <T> TreeSet<T> sortSet(Collection<T> toSort, Comparator<T> comparator)
{
TreeSet<T> sortedSet = new TreeSet<T>(comparator);
for (T cur : toSort)
sortedSet.add(cur); sortedSet.add(cur);
return sortedSet; return sortedSet;
@ -40,7 +50,7 @@ public class UtilAlg
public static Vector getTrajectory(Vector from, Vector to) public static Vector getTrajectory(Vector from, Vector to)
{ {
return to.subtract(from).normalize(); return to.clone().subtract(from).normalize();
} }
public static Vector getTrajectory2d(Entity from, Entity to) public static Vector getTrajectory2d(Entity from, Entity to)
@ -55,7 +65,7 @@ public class UtilAlg
public static Vector getTrajectory2d(Vector from, Vector to) public static Vector getTrajectory2d(Vector from, Vector to)
{ {
return to.subtract(from).setY(0).normalize(); return to.clone().subtract(from).setY(0).normalize();
} }
public static boolean HasSight(Location from, Player to) public static boolean HasSight(Location from, Player to)
@ -408,6 +418,55 @@ public class UtilAlg
return bestLoc; return bestLoc;
} }
public static Vector calculateVelocity(Vector from, Vector to, double heightGain, Entity entity)
{
if (entity instanceof LivingEntity)
{
return calculateVelocity(from, to, heightGain, 1.15);
}
else
{
return calculateVelocity(from, to, heightGain, 0.115);
}
}
public static Vector calculateVelocity(Vector from, Vector to, double heightGain)
{
return calculateVelocity(from, to, heightGain, 0.115);
}
public static Vector calculateVelocity(Vector from, Vector to, double heightGain, double gravity)
{
// Block locations
int endGain = to.getBlockY() - from.getBlockY();
double dx1 = to.getBlockX() - from.getBlockX();
double dz1 = to.getBlockZ() - from.getBlockZ();
double horizDist = Math.sqrt(dx1 * dx1 + dz1 * dz1);
// Height gain
double maxGain = heightGain > (endGain + heightGain) ? heightGain : (endGain + heightGain);
// Solve quadratic equation for velocity
double a = -horizDist * horizDist / (4 * maxGain);
double b = horizDist;
double c = -endGain;
double slope = -b / (2 * a) - Math.sqrt(b * b - 4 * a * c) / (2 * a);
// Vertical velocity
double vy = Math.sqrt(maxGain * gravity);
// Horizontal velocity
double vh = vy / slope;
// Calculate horizontal direction
int dx = to.getBlockX() - from.getBlockX();
int dz = to.getBlockZ() - from.getBlockZ();
double mag = Math.sqrt(dx * dx + dz * dz);
double dirx = dx / mag;
double dirz = dz / mag;
// Horizontal velocity components
double vx = vh * dirx;
double vz = vh * dirz;
return new Vector(vx, vy, vz);
}
public static Location getNearestCornerLocation(Location near, Block block) public static Location getNearestCornerLocation(Location near, Block block)
{ {
ArrayList<Location> corners = new ArrayList<Location>(); ArrayList<Location> corners = new ArrayList<Location>();
@ -441,8 +500,19 @@ public class UtilAlg
return value; return value;
} }
public static EulerAngle vectorToEuler(Vector vector) public static EulerAngle vectorToEuler(Vector vector)
{ {
return new EulerAngle(Math.toRadians(GetPitch(vector)), Math.toRadians(GetYaw(vector)), 0); //JUST MAKE SURE THE ARMOR STAND ISNT ROTATED.
return new EulerAngle(
Math.toRadians(UtilAlg.GetPitch(vector)),
Math.toRadians(UtilAlg.GetYaw(vector)),
0);
}
public static AxisAlignedBB toBoundingBox(Location a, Location b)
{
return new AxisAlignedBB(a.getX(), a.getY(), a.getZ(), b.getX(), b.getY(), b.getZ());
} }
} }

View File

@ -7,6 +7,9 @@ import org.bukkit.ChatColor;
*/ */
public class UtilColor public class UtilColor
{ {
public static final RGBData RgbRed = hexToRgb(0xee0100);
public static final RGBData RgbGold = hexToRgb(0xffd014);
public static final RGBData RgbLightBlue = hexToRgb(0x61fff7);
public static byte chatColorToClayData(ChatColor chatColor) public static byte chatColorToClayData(ChatColor chatColor)
{ {
@ -66,4 +69,19 @@ public class UtilColor
return 0; return 0;
} }
} }
public static RGBData hexToRgb(int hex)
{
return new RGBData(hex >> 16, hex >> 8 & 0xFF, hex & 0xFF);
}
public static int rgbToHex(RGBData rgb)
{
return (rgb.getFullRed() << 16 | rgb.getFullGreen() << 8 | rgb.getFullBlue());
}
public static int rgbToHex(int red, int green, int blue)
{
return (red << 16 | green << 8 | blue);
}
} }

View File

@ -33,6 +33,7 @@ import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Creature; import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -531,10 +532,27 @@ public class UtilEnt
} }
public static boolean isGrounded(Entity ent) public static boolean isGrounded(Entity ent)
{
if(!(ent instanceof Player)) {
return ent.isOnGround();
}
AxisAlignedBB box = ((CraftEntity)ent).getHandle().getBoundingBox().shrink(0.05, 0, 0.05);
Location bottom_corner_1 = new Location(ent.getWorld(), box.a, ent.getLocation().getY()-0.05, box.c);
Location bottom_corner_2 = new Location(ent.getWorld(), box.d, ent.getLocation().getY()-0.05, box.f);
for(Block b : UtilBlock.getInBoundingBox(bottom_corner_1, bottom_corner_2)){
if(UtilBlock.solid(b)) return true;
}
return false;
}
public static boolean isGrounded(Entity ent, Location loc)
{ {
AxisAlignedBB box = ((CraftEntity)ent).getHandle().getBoundingBox(); AxisAlignedBB box = ((CraftEntity)ent).getHandle().getBoundingBox();
Location bottom_corner_1 = new Location(ent.getWorld(), box.a, ent.getLocation().getY()-0.1, box.c); Location bottom_corner_1 = new Location(ent.getWorld(), box.a, loc.getY()-0.1, box.c);
Location bottom_corner_2 = new Location(ent.getWorld(), box.d, ent.getLocation().getY()-0.1, box.f); Location bottom_corner_2 = new Location(ent.getWorld(), box.d, loc.getY()-0.1, box.f);
for(Block b : UtilBlock.getInBoundingBox(bottom_corner_1, bottom_corner_2)){ for(Block b : UtilBlock.getInBoundingBox(bottom_corner_1, bottom_corner_2)){
if(UtilBlock.solid(b)) return true; if(UtilBlock.solid(b)) return true;
@ -787,6 +805,20 @@ public class UtilEnt
return null; return null;
} }
public static void setAI(LivingEntity entity, boolean ai)
{
if(entity instanceof ArmorStand)
{
((ArmorStand)entity).setGravity(ai);
return;
}
CraftEntity e = (CraftEntity)entity;
if(e.getHandle() instanceof EntityInsentient)
{
((EntityInsentient)e.getHandle()).k(!ai);
}
}
public static boolean inWater(LivingEntity ent) public static boolean inWater(LivingEntity ent)
{ {
return ent.getLocation().getBlock().getTypeId() == 8 || ent.getLocation().getBlock().getTypeId() == 9; return ent.getLocation().getBlock().getTypeId() == 8 || ent.getLocation().getBlock().getTypeId() == 9;

View File

@ -16,7 +16,8 @@ public class UtilEvent
L_BLOCK, L_BLOCK,
R, R,
R_AIR, R_AIR,
R_BLOCK R_BLOCK,
ANY
} }
public static boolean isAction(PlayerInteractEvent event, ActionType action) public static boolean isAction(PlayerInteractEvent event, ActionType action)
@ -39,6 +40,9 @@ public class UtilEvent
if (action == ActionType.R_BLOCK) if (action == ActionType.R_BLOCK)
return (event.getAction() == Action.RIGHT_CLICK_BLOCK); return (event.getAction() == Action.RIGHT_CLICK_BLOCK);
if (action == ActionType.ANY)
return event.getAction() != Action.PHYSICAL;
return false; return false;
} }

View File

@ -0,0 +1,310 @@
package mineplex.core.common.util;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Paths;
public class UtilFile
{
public static void writePlainFile(File file, String text) throws FileNotFoundException
{
PrintWriter writer = new PrintWriter(file);
writer.print(text);
writer.close();
}
/**
* Will read the specified file, and return the contents, or a null value,
* if an exception is thrown. Will handle all exceptions, and simply ignore
* them and return null. No stack trace printed or anything.
*/
public static String readIgnoreErrors(File file)
{
try
{
return readToStr(file);
}
catch (IOException exception)
{
return null;
}
}
public static String readToStr(File file) throws IOException
{
return new String(readAllBytes(file));
}
public static byte[] readAllBytes(File file) throws IOException
{
return Files.readAllBytes(Paths.get(file.toURI()));
}
public static void writePlainFile(String file, String text) throws FileNotFoundException
{
writePlainFile(new File(file), text);
}
/**
* Will read the specified file, and return the contents, or a null value,
* if an exception is thrown. Will handle all exceptions, and simply ignore
* them and return null. No stack trace printed or anything.
*/
public static String readIgnoreErrors(String file)
{
return readIgnoreErrors(new File(file));
}
public static String readToStr(String file) throws IOException
{
return readToStr(new File(file));
}
public static byte[] readAllBytes(String file) throws IOException
{
return readAllBytes(new File(file));
}
public static void writeDataFile(File file, DataFileChunk... chunks) throws IOException
{
DataOutputStream stream = new DataOutputStream(new FileOutputStream(file));
for (DataFileChunk chunk : chunks)
{
chunk.writeTo(stream);
}
stream.close();
}
public static DataFileReader beginReading(String file) throws FileNotFoundException
{
return beginReading(new File(file));
}
public static DataFileReader beginReading(File file) throws FileNotFoundException
{
return new DataFileReader(file);
}
public static void writeDataFile(String file, DataFileChunk... chunks) throws IOException
{
writeDataFile(new File(file), chunks);
}
public static class DataFileChunk
{
private ChunkType _type;
private Object _value;
public DataFileChunk(ChunkType type, Object value)
{
if (type == null)
{
throw new RuntimeException("ChunkType can NOT be null.");
}
_type = type;
if (!_type.isValid(value))
{
throw new RuntimeException("Invalid value provided for the specified ChunkType.");
}
_value = value;
}
public void writeTo(DataOutputStream stream) throws IOException
{
_type.writeTo(stream, _value);
}
}
public static enum ChunkType
{
STRING(new ChunkImpl()
{
public void writeTo(DataOutputStream stream, Object value) throws IOException
{
String str = (String) value;
INTEGER.writeTo(stream, str.length());
for (char b : str.toCharArray())
{
CHAR.writeTo(stream, b);
}
}
public boolean isValid(Object value)
{
return value.getClass().equals(String.class);
}
public Object readFrom(DataInputStream stream) throws IOException
{
int length = (int) INTEGER.readFrom(stream);
StringBuilder string = new StringBuilder();
for (int i = 0; i < length; i++)
{
string.append(CHAR.readFrom(stream));
}
return string.toString();
}
}),
DOUBLE(new ChunkImpl()
{
public void writeTo(DataOutputStream stream, Object value) throws IOException
{
double number = (double) value;
stream.writeDouble(number);
}
public boolean isValid(Object value)
{
return value.getClass().equals(Double.class);
}
public Object readFrom(DataInputStream stream) throws IOException
{
return stream.readDouble();
}
}),
INTEGER(new ChunkImpl()
{
public void writeTo(DataOutputStream stream, Object value) throws IOException
{
int number = (int) value;
stream.writeInt(number);
}
public boolean isValid(Object value)
{
return value.getClass().equals(Integer.class);
}
public Object readFrom(DataInputStream stream) throws IOException
{
return stream.readInt();
}
}),
BYTE(new ChunkImpl()
{
public void writeTo(DataOutputStream stream, Object value) throws IOException
{
byte number = (byte) value;
stream.writeByte(number);
}
public boolean isValid(Object value)
{
return value.getClass().equals(Byte.class);
}
public Object readFrom(DataInputStream stream) throws IOException
{
return stream.readByte();
}
}),
CHAR(new ChunkImpl()
{
public void writeTo(DataOutputStream stream, Object value) throws IOException
{
char number = (char) value;
stream.writeChar(number);
}
public boolean isValid(Object value)
{
return value.getClass().equals(Character.class);
}
public Object readFrom(DataInputStream stream) throws IOException
{
return stream.readChar();
}
}),
LONG(new ChunkImpl()
{
public void writeTo(DataOutputStream stream, Object value) throws IOException
{
long number = (long) value;
stream.writeLong(number);
}
public boolean isValid(Object value)
{
return value.getClass().equals(Long.class);
}
public Object readFrom(DataInputStream stream) throws IOException
{
return stream.readLong();
}
});
private ChunkImpl _impl;
ChunkType(ChunkImpl impl)
{
_impl = impl;
}
protected void writeTo(DataOutputStream stream, Object value) throws IOException
{
_impl.writeTo(stream, value);
}
protected boolean isValid(Object value)
{
return value != null && _impl.isValid(value);
}
public Object readFrom(DataInputStream stream) throws IOException
{
return _impl.readFrom(stream);
}
}
public static class DataFileReader
{
private DataInputStream _stream;
public DataFileReader(File file) throws FileNotFoundException
{
_stream = new DataInputStream(new FileInputStream(file));
}
public Object readChunk(ChunkType type) throws IOException
{
return type.readFrom(_stream);
}
public void close() throws IOException
{
_stream.close();
}
}
protected interface ChunkImpl
{
void writeTo(DataOutputStream stream, Object value) throws IOException;
Object readFrom(DataInputStream stream) throws IOException;
boolean isValid(Object value);
}
}

View File

@ -13,6 +13,43 @@ public class UtilGear
private static HashSet<Material> pickSet = new HashSet<Material>(); private static HashSet<Material> pickSet = new HashSet<Material>();
private static HashSet<Material> diamondSet = new HashSet<Material>(); private static HashSet<Material> diamondSet = new HashSet<Material>();
private static HashSet<Material> goldSet = new HashSet<Material>(); private static HashSet<Material> goldSet = new HashSet<Material>();
private static HashSet<Material> _armorSet = new HashSet<Material>();
public static boolean isArmor(ItemStack item)
{
if (item == null)
return false;
if (_armorSet.isEmpty())
{
_armorSet.add(Material.LEATHER_HELMET);
_armorSet.add(Material.LEATHER_CHESTPLATE);
_armorSet.add(Material.LEATHER_LEGGINGS);
_armorSet.add(Material.LEATHER_BOOTS);
_armorSet.add(Material.GOLD_HELMET);
_armorSet.add(Material.GOLD_CHESTPLATE);
_armorSet.add(Material.GOLD_LEGGINGS);
_armorSet.add(Material.GOLD_BOOTS);
_armorSet.add(Material.CHAINMAIL_HELMET);
_armorSet.add(Material.CHAINMAIL_CHESTPLATE);
_armorSet.add(Material.CHAINMAIL_LEGGINGS);
_armorSet.add(Material.CHAINMAIL_BOOTS);
_armorSet.add(Material.IRON_HELMET);
_armorSet.add(Material.IRON_CHESTPLATE);
_armorSet.add(Material.IRON_LEGGINGS);
_armorSet.add(Material.IRON_BOOTS);
_armorSet.add(Material.DIAMOND_HELMET);
_armorSet.add(Material.DIAMOND_CHESTPLATE);
_armorSet.add(Material.DIAMOND_LEGGINGS);
_armorSet.add(Material.DIAMOND_BOOTS);
}
return _armorSet.contains(item.getType());
}
public static boolean isAxe(ItemStack item) public static boolean isAxe(ItemStack item)
{ {
@ -126,6 +163,10 @@ public class UtilGear
{ {
goldSet.add(Material.GOLD_SWORD); goldSet.add(Material.GOLD_SWORD);
goldSet.add(Material.GOLD_AXE); goldSet.add(Material.GOLD_AXE);
goldSet.add(Material.GOLD_HELMET);
goldSet.add(Material.GOLD_CHESTPLATE);
goldSet.add(Material.GOLD_LEGGINGS);
goldSet.add(Material.GOLD_BOOTS);
} }
return goldSet.contains(item.getType()); return goldSet.contains(item.getType());

View File

@ -2,7 +2,8 @@ package mineplex.core.common.util;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols; import java.text.DecimalFormatSymbols;
import java.text.NumberFormat; import java.util.ArrayList;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Random; import java.util.Random;
@ -24,13 +25,18 @@ public class UtilMath
return Double.valueOf(twoDForm.format(d)); return Double.valueOf(twoDForm.format(d));
} }
public static Random random = new Random(); public static Random random = new Random();
public static int r(int i) public static int r(int i)
{ {
return random.nextInt(i); return random.nextInt(i);
} }
public static int rRange(int min, int max)
{
return min + r(1 + max - min);
}
public static double offset2d(Entity a, Entity b) public static double offset2d(Entity a, Entity b)
{ {
return offset2d(a.getLocation().toVector(), b.getLocation().toVector()); return offset2d(a.getLocation().toVector(), b.getLocation().toVector());
@ -60,7 +66,7 @@ public class UtilMath
public static double offset(Vector a, Vector b) public static double offset(Vector a, Vector b)
{ {
return a.subtract(b).length(); return a.clone().subtract(b).length();
} }
public static double offsetSquared(Entity a, Entity b) public static double offsetSquared(Entity a, Entity b)
@ -80,16 +86,55 @@ public class UtilMath
public static double rr(double d, boolean bidirectional) public static double rr(double d, boolean bidirectional)
{ {
if (bidirectional) if (bidirectional) return Math.random() * (2 * d) - d;
return Math.random() * (2 * d) - d;
return Math.random() * d; return Math.random() * d;
} }
public static <T> T randomElement(T[] array) { public static <T> T randomElement(T[] array)
if (array.length == 0) {
return null; if (array.length == 0) return null;
return array[random.nextInt(array.length)]; return array[random.nextInt(array.length)];
} }
public static <T> T randomElement(List<T> list)
{
if (list.isEmpty()) return null;
return list.get(random.nextInt(list.size()));
} }
public static double clamp(double num, double min, double max)
{
return num < min ? min : (num > max ? max : num);
}
public static long clamp(long num, long min, long max)
{
return num < min ? min : (num > max ? max : num);
}
public static int clamp(int num, int min, int max)
{
return num < min ? min : (num > max ? max : num);
}
public static List<Integer> digits(int i) {
List<Integer> digits = new ArrayList<Integer>();
while(i > 0) {
digits.add(i % 10);
i /= 10;
}
return digits;
}
public static double random(double min, double max)
{
min = Math.abs(min);
int rand = -random.nextInt((int)(min * 100));
rand += random.nextInt((int)(max * 100));
return ((double) rand) / 100.d;
}
}

View File

@ -1,14 +1,12 @@
package mineplex.core.common.util; package mineplex.core.common.util;
import java.lang.reflect.Field;
import mineplex.core.common.util.UtilParticle.ViewDist;
import net.minecraft.server.v1_8_R3.EnumParticle;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldParticles;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import net.minecraft.server.v1_8_R3.EnumParticle;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldParticles;
public class UtilParticle public class UtilParticle
{ {
@ -243,6 +241,46 @@ public class UtilParticle
return packet; return packet;
} }
public static void PlayParticle(ParticleType type,Location location, float offsetX, float offsetY,
float offsetZ, float speed, int count, ViewDist dist)
{
PlayParticle(type, location, offsetX, offsetY, offsetZ, speed, count, dist, UtilServer.getPlayers());
}
public static void PlayParticleToAll(ParticleType type, Location location, Vector offset, float speed, int count, ViewDist dist)
{
float x = 0;
float y = 0;
float z = 0;
if(offset != null)
{
x = (float) offset.getX();
y = (float) offset.getY();
z = (float) offset.getZ();
}
PlayParticle(type, location, x, y, z, speed, count, dist, UtilServer.getPlayers());
}
public static void PlayParticle(ParticleType type, Location location, Vector offset, float speed, int count, ViewDist dist, Player... players)
{
float x = 0;
float y = 0;
float z = 0;
if(offset != null)
{
x = (float) offset.getX();
y = (float) offset.getY();
z = (float) offset.getZ();
}
PlayParticle(type, location, x, y, z, speed, count, dist, players);
}
public static void PlayParticleToAll(ParticleType type, Location location, float offsetX, float offsetY, float offsetZ,
float speed, int count, ViewDist dist)
{
PlayParticle(type.particleName, location, offsetX, offsetY, offsetZ, speed, count, dist, UtilServer.getPlayers());
}
public static void PlayParticle(ParticleType type, Location location, float offsetX, float offsetY, float offsetZ, public static void PlayParticle(ParticleType type, Location location, float offsetX, float offsetY, float offsetZ,
float speed, int count, ViewDist dist, Player... players) float speed, int count, ViewDist dist, Player... players)
{ {
@ -263,4 +301,26 @@ public class UtilParticle
UtilPlayer.sendPacket(player, packet); UtilPlayer.sendPacket(player, packet);
} }
} }
public static void PlayParticleToAll(String particle, Location location, Vector offset, float speed, int count, ViewDist dist)
{
float x = 0;
float y = 0;
float z = 0;
if(offset != null)
{
x = (float) offset.getX();
y = (float) offset.getY();
z = (float) offset.getZ();
}
PlayParticle(particle, location, x, y, z, speed, count, dist, UtilServer.getPlayers());
}
public static void PlayParticleToAll(String particle, Location location, float offsetX, float offsetY, float offsetZ,
float speed, int count, ViewDist dist)
{
PlayParticle(particle, location, offsetX, offsetY, offsetZ, speed, count, dist, UtilServer.getPlayers());
}
} }

View File

@ -1,18 +1,20 @@
package mineplex.core.common.util; package mineplex.core.common.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID; import java.util.UUID;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PlayerConnection;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory; import org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory;
@ -21,10 +23,23 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.InventoryView;
import org.bukkit.potion.PotionEffect;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PlayerConnection;
public class UtilPlayer public class UtilPlayer
{ {
private static Random RANDOM = new Random();
// A mapping of player names (Keys) to the system time when they last changed active Hotbar Slot
private static Map<String, Long> _hotbarUpdates = new HashMap<String, Long>();
// The amount of time (in milliseconds) after changin hotbars that you can block
public static final long BLOCKING_HOTBAR_DELAY = 100;
private static boolean hasIntersection(Vector3D p1, Vector3D p2, Vector3D min, Vector3D max) private static boolean hasIntersection(Vector3D p1, Vector3D p2, Vector3D min, Vector3D max)
{ {
final double epsilon = 0.0001f; final double epsilon = 0.0001f;
@ -154,6 +169,30 @@ public class UtilPlayer
return hit; return hit;
} }
/**
* @param player - the player to be checked for blocking status
* @return true, if the {@code player} is blocking and has not recently
* changed hotbar slots (within {@value BLOCKING_HOTBAR_DELAY} milliseconds), false otherwise.
*/
public static boolean isBlocking(Player player)
{
String name = player.getName();
long lastUpdate = _hotbarUpdates.containsKey(name) ? _hotbarUpdates.get(name) : 0;;
long duration = System.currentTimeMillis() - lastUpdate;
return player.isBlocking();// && UtilItem.isSword(player.getItemInHand())
//&& duration >= BLOCKING_HOTBAR_DELAY;
}
/**
* Mark the {@code player} as having changed hotbar slots.
* @param player - the player to be marked
*/
public static void onHotbarChange(Player player)
{
_hotbarUpdates.put(player.getName(), System.currentTimeMillis());
}
/** /**
* AviodAllies doesn't work. Leaving as a param as it sounds like something you may want in the future. * AviodAllies doesn't work. Leaving as a param as it sounds like something you may want in the future.
*/ */
@ -392,7 +431,12 @@ public class UtilPlayer
return matchList; return matchList;
} }
public static LinkedList<Player> getNearby(Location loc, double maxDist) public static List<Player> getNearby(Location loc, double maxDist)
{
return getNearby(loc, maxDist, false);
}
public static List<Player> getNearby(Location loc, double maxDist, boolean onlySurvival)
{ {
LinkedList<Player> nearbyMap = new LinkedList<Player>(); LinkedList<Player> nearbyMap = new LinkedList<Player>();
@ -404,8 +448,10 @@ public class UtilPlayer
if (cur.isDead()) if (cur.isDead())
continue; continue;
double dist = loc.toVector().subtract(cur.getLocation().toVector()).length(); if (onlySurvival && cur.getGameMode() != GameMode.SURVIVAL)
continue;
double dist = loc.distance(cur.getLocation());
if (dist > maxDist) if (dist > maxDist)
continue; continue;
@ -453,7 +499,7 @@ public class UtilPlayer
return best; return best;
} }
public static Player getClosest(Location loc, Entity ignore) public static Player getClosest(Location loc, Entity... ignore)
{ {
Player best = null; Player best = null;
double bestDist = 0; double bestDist = 0;
@ -466,8 +512,22 @@ public class UtilPlayer
if (cur.isDead()) if (cur.isDead())
continue; continue;
if (ignore != null && ignore.equals(cur)) //Ignore Check
if (ignore != null)
{
boolean shouldIgnore = false;
for (Entity ent : ignore)
{
if (cur.equals(ent))
{
shouldIgnore = true;
break;
}
}
if (shouldIgnore)
continue; continue;
}
double dist = UtilMath.offset(cur.getLocation(), loc); double dist = UtilMath.offset(cur.getLocation(), loc);
@ -499,6 +559,14 @@ public class UtilPlayer
System.out.println("Kicked Client [" + player.getName() + "] for [" + module + " - " + message + "]"); System.out.println("Kicked Client [" + player.getName() + "] for [" + module + " - " + message + "]");
} }
public static void kick(Collection<Player> players, String module, String message, boolean log)
{
for (Player player : players)
{
kick(player, module, message, log);
}
}
public static HashMap<Player, Double> getInRadius(Location loc, double dR) public static HashMap<Player, Double> getInRadius(Location loc, double dR)
{ {
HashMap<Player, Double> players = new HashMap<Player, Double>(); HashMap<Player, Double> players = new HashMap<Player, Double>();
@ -590,6 +658,23 @@ public class UtilPlayer
return (((CraftEntity) player).getHandle().getDataWatcher().getByte(0) & 1 << 4) != 0; return (((CraftEntity) player).getHandle().getDataWatcher().getByte(0) & 1 << 4) != 0;
} }
public static void clearInventory(Player player)
{
player.getInventory().clear();
player.getInventory().setHelmet(null);
player.getInventory().setChestplate(null);
player.getInventory().setLeggings(null);
player.getInventory().setBoots(null);
}
public static void clearPotionEffects(Player player)
{
for (PotionEffect effect : player.getActivePotionEffects())
{
player.removePotionEffect(effect.getType());
}
}
public static void sendPacket(Player player, Packet... packets) public static void sendPacket(Player player, Packet... packets)
{ {
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection; PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
@ -603,6 +688,18 @@ public class UtilPlayer
} }
} }
/**
* Get a random player within maxDist of the target location
* @param location The center location to look for the player
* @param maxDist The max distance from location that the player can be
* @return A random player that is within maxDist of location, or null if no players apply
*/
public static Player getRandomTarget(Location location, double maxDist)
{
List<Player> nearby = getNearby(location, maxDist, true);
return nearby.size() > 0 ? nearby.get(RANDOM.nextInt(nearby.size())) : null;
}
public static boolean isSpectator(Entity player) public static boolean isSpectator(Entity player)
{ {
if (player instanceof Player) if (player instanceof Player)

View File

@ -1,5 +1,13 @@
package mineplex.core.common.util; package mineplex.core.common.util;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Stream;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -12,6 +20,30 @@ public class UtilServer
return getServer().getOnlinePlayers().toArray(new Player[0]); return getServer().getOnlinePlayers().toArray(new Player[0]);
} }
public static Collection<? extends Player> getPlayersCollection()
{
return getServer().getOnlinePlayers();
}
public static List<Player> getSortedPlayers()
{
return getSortedPlayers(new Comparator<Player>()
{
@Override
public int compare(Player o1, Player o2)
{
return o1.getName().compareTo(o2.getName());
}
});
}
public static List<Player> getSortedPlayers(Comparator<Player> comparator)
{
ArrayList<Player> players = new ArrayList<Player>(getServer().getOnlinePlayers());
Collections.sort(players, comparator);
return players;
}
public static Server getServer() public static Server getServer()
{ {
return Bukkit.getServer(); return Bukkit.getServer();
@ -23,6 +55,12 @@ public class UtilServer
UtilPlayer.message(cur, message); UtilPlayer.message(cur, message);
} }
public static void broadcast(LinkedList<String> messages)
{
for (Player cur : getPlayers())
UtilPlayer.message(cur, messages);
}
public static void broadcastSpecial(String event, String message) public static void broadcastSpecial(String event, String message)
{ {
for (Player cur : getPlayers()) for (Player cur : getPlayers())

View File

@ -1,6 +1,13 @@
package mineplex.core.common.util; package mineplex.core.common.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
public class UtilSkull public class UtilSkull
{ {
@ -25,6 +32,19 @@ public class UtilSkull
return 3; return 3;
} }
public static ItemStack getPlayerHead(String playerName, String itemName, List<String> itemLore)
{
boolean displayHead = !playerName.isEmpty();
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 0, displayHead ? (byte) 3 : 0);
SkullMeta meta = ((SkullMeta) skull.getItemMeta());
if (displayHead)
meta.setOwner(playerName);
meta.setDisplayName(itemName);
meta.setLore(itemLore);
skull.setItemMeta(meta);
return skull;
}
public static boolean isPlayerHead(byte data) public static boolean isPlayerHead(byte data)
{ {
return data == 3; return data == 3;

View File

@ -1,51 +1,517 @@
package mineplex.core.common.util; package mineplex.core.common.util;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import javax.imageio.ImageIO;
import mineplex.core.common.CurrencyType;
import org.apache.commons.lang.WordUtils; import org.apache.commons.lang.WordUtils;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
public class UtilText { public class UtilText
public static <T> String listToString(Collection<T> inputList, boolean comma) { {
String out = ""; private static HashMap<Character, Integer> _characters = new HashMap<Character, Integer>();
private static HashMap<Character, BufferedImage> _characterImages = new HashMap<Character, BufferedImage>();
for (T cur : inputList) { static
out += cur.toString() + (comma ? ", " : " "); {
try
{
InputStream inputStream = CurrencyType.class.getResourceAsStream("ascii.png");
BufferedImage image = ImageIO.read(inputStream);
char[] text = new char[]
{
' ',
'!',
'"',
'#',
'$',
'%',
'&',
'\'',
'(',
')',
'*',
'+',
',',
'-',
'.',
'/',
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
':',
';',
'<',
'=',
'>',
'?',
'@',
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
'[',
'\\',
']',
'^',
'_',
'`',
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
'{',
'|',
'}',
'~'
};
int x = 0;
int y = 16;
for (char c : text)
{
grab(c, image, x, y);
if (x < 15 * 8)
{
x += 8;
}
else
{
x = 0;
y += 8;
}
} }
if (out.length() > 0) { inputStream.close();
out = out.substring(0, out.length() - (comma ? 2 : 1)); }
catch (IOException e)
{
e.printStackTrace();
}
} }
return out; public static String center(String string, LineFormat lineFormat)
{
int length = getLength(string);
if (length > lineFormat.getLength())
{
return string;
} }
public static int upperCaseCount(String input) { // Get the number of empty pixels on both sides of the string
int count = 0; int div = (int) Math.floor((lineFormat.getLength() - length) / 2D);
for (int k = 0; k < input.length(); k++) { div -= 2; // For the gap between the strings
char ch = input.charAt(k);
if (Character.isUpperCase(ch))
count++;
return fillLine(" ", div) + string + fillLine(" ", div);
} }
return count; public static String alignRight(String string, LineFormat lineFormat)
} {
public static int lowerCaseCount(String input) { int length = getLength(string);
int count = 0;
for (int k = 0; k < input.length(); k++) {
char ch = input.charAt(k);
if (Character.isLowerCase(ch))
count++;
if (length > lineFormat.getLength())
{
return string;
} }
return count; // Get the number of empty pixels on both sides of the string
int div = lineFormat.getLength() - length;
div -= 1; // For the gap between the strings
return fillLine(" ", div) + string;
}
public static String centerChat(String string, LineFormat lineFormat)
{
int length = getLength(string);
if (length > lineFormat.getLength())
{
return string;
}
// Get the number of empty pixels on both sides of the string
int div = (int) Math.floor(((lineFormat.getLength() + 10) - length) / 2D);
div -= 2; // For the gap between the strings
return fillLine(" ", div) + string;
}
public static String substringPixels(String string, int cutoff)
{
int len = 0;
char[] array = string.toCharArray();
boolean bold = false;
for (int i = 0; i < array.length; i++)
{
char c = array[i];
if (c == '<27>')
{
if (++i < array.length)
{
ChatColor color = ChatColor.getByChar(array[i]);
if (color != null)
{
if (color.equals(ChatColor.BOLD))
{
bold = true;
}
else if (color.equals(ChatColor.RESET) || color.isColor())
{
bold = false;
}
}
}
continue;
}
if (!_characters.containsKey(c))
{
continue;
}
int toAdd = _characters.get(c);
if (bold)
{
toAdd++;
}
if (len + toAdd > cutoff)
{
return string.substring(0, Math.max(0, i - 1));
}
if (i + 1 < array.length)
{
len++;
}
}
return string;
}
public static String[] splitLinesToArray(String[] strings, LineFormat lineFormat)
{
ArrayList<String> lineList = splitLines(strings, lineFormat);
String[] lineArray = new String[lineList.size()];
lineArray = lineList.toArray(lineArray);
return lineArray;
}
public static ArrayList<String> splitLines(String[] strings, LineFormat lineFormat)
{
ArrayList<String> lines = new ArrayList<String>();
for (String s : strings)
{
lines.addAll(splitLine(s, lineFormat));
}
return lines;
}
public static String[] splitLineToArray(String string, LineFormat lineFormat)
{
ArrayList<String> lineList = splitLine(string, lineFormat);
String[] lineArray = new String[lineList.size()];
lineArray = lineList.toArray(lineArray);
return lineArray;
}
public static ArrayList<String> splitLine(String string, LineFormat lineFormat)
{
ArrayList<String> strings = new ArrayList<String>();
// Ignore lines with #
if (string.startsWith("#"))
{
strings.add(string.substring(1, string.length()));
return strings;
}
// Empty
if (string.equals("") || string.equals(" "))
{
strings.add(string);
return strings;
}
String current = "";
int currentLength = 0;
String[] split = string.split(" ");
String colors = "";
for (int i = 0; i < split.length; i++)
{
String word = split[i];
int wordLength = getLength(colors + word);
if (currentLength + wordLength + 4 > lineFormat.getLength() && !current.isEmpty())
{
strings.add(current);
current = colors + word;
currentLength = wordLength + 1;
continue;
}
if (i != 0)
{
current += " ";
currentLength += 4;
}
current += word;
currentLength += wordLength;
colors = ChatColor.getLastColors(current);
}
if (!current.isEmpty())
{
strings.add(current);
}
return strings;
}
public static String fillLine(String filler, int maxPixels)
{
int pixels = getLength(filler);
if (pixels <= 0)
{
return "";
}
String toReturn = "";
int currentLen = 0;
int offset = maxPixels % 4;
boolean isOffset = false;
if (offset > 0)
{
toReturn += C.Bold;
}
while (currentLen + pixels <= maxPixels)
{
currentLen += pixels + 1;
toReturn += filler;
if (offset-- > 0)
{
currentLen++;
if (offset == 0)
{
isOffset = false;
toReturn += ChatColor.RESET;
}
}
}
if (isOffset)
{
toReturn += ChatColor.RESET;
}
return toReturn;
}
public static boolean fitsOneLine(String string, LineFormat lineFormat)
{
return getLength(string) <= lineFormat.getLength();
}
public static int getLength(String string)
{
int len = 0;
char[] array = string.toCharArray();
boolean bold = false;
for (int i = 0; i < array.length; i++)
{
char c = array[i];
if (c == '<27>')
{
if (++i < array.length)
{
ChatColor color = ChatColor.getByChar(array[i]);
if (color != null)
{
if (color.equals(ChatColor.BOLD))
{
bold = true;
}
else if (color.equals(ChatColor.RESET) || color.isColor())
{
bold = false;
}
}
}
continue;
}
if (!_characters.containsKey(c))
{
continue;
}
len += _characters.get(c);
if (bold)
{
len++;
}
if (i + 1 < array.length)
{
len++;
}
}
return len;
}
private static void grab(Character character, BufferedImage image, int imageX, int imageY)
{
BufferedImage newImage = image.getSubimage(imageX, imageY, 8, 8);
int width = 8;
if (character == ' ')
{
width = 3;
}
else
{
for (int x = 0; x < 8; x++)
{
boolean isTransparentLine = true;
for (int y = 0; y < 8; y++)
{
int pixel = image.getRGB(imageX + x, imageY + y);
if ((pixel >> 24) != 0x00)
{
isTransparentLine = false;
break;
}
}
if (isTransparentLine)
{
width = x + 1;
break;
}
}
}
newImage = newImage.getSubimage(0, 0, width, 8);
_characterImages.put(character, newImage);
_characters.put(character, width);
}
public static int getLength(char character)
{
if (!_characters.containsKey(character))
{
return 16;
}
return _characters.get(character);
}
public static BufferedImage getImage(char character)
{
if (!_characterImages.containsKey(character))
{
character = '?';
}
return _characterImages.get(character);
} }
public static boolean isStringSimilar(String newString, String oldString, float matchRequirement) public static boolean isStringSimilar(String newString, String oldString, float matchRequirement)
@ -87,12 +553,126 @@ public class UtilText {
return false; return false;
} }
public static <T> String listToString(Collection<T> inputList, boolean comma)
{
String out = "";
for (T cur : inputList)
{
out += cur.toString() + (comma ? ", " : " ");
}
if (out.length() > 0)
{
out = out.substring(0, out.length() - (comma ? 2 : 1));
}
return out;
}
public static int lowerCaseCount(String input)
{
int count = 0;
for (int k = 0; k < input.length(); k++)
{
char ch = input.charAt(k);
if (Character.isLowerCase(ch))
count++;
}
return count;
}
public static int upperCaseCount(String input)
{
int count = 0;
for (int k = 0; k < input.length(); k++)
{
char ch = input.charAt(k);
if (Character.isUpperCase(ch))
count++;
}
return count;
}
public static String[] wrap(String text, int lineLength) public static String[] wrap(String text, int lineLength)
{ {
return wrap(text, lineLength, true); return wrap(text, lineLength, true);
} }
public static String[] wrap(String text, int lineLength, boolean wrapLongerWords) { public static String[] wrap(String text, int lineLength, boolean wrapLongerWords)
{
return WordUtils.wrap(text, lineLength, "\00D0", wrapLongerWords).split("\00D0"); return WordUtils.wrap(text, lineLength, "\00D0", wrapLongerWords).split("\00D0");
} }
public static String repeat(String txt, int times)
{
return new String(new byte[times]).replace("\0", txt);
}
public static boolean plural(int x)
{
return x <= 0 ? true : x > 1;
}
public static String trim(int maxLength, String s)
{
return s.length() <= maxLength ? s : s.substring(0, maxLength);
}
public static <X> String arrayToString(X[] array, String delimiter)
{
StringBuilder string = new StringBuilder();
int index = 0;
for (X x : array)
{
string.append(x.toString());
if (index != array.length - 1)
{
string.append(delimiter);
}
index++;
}
return string.toString();
}
public static <X> String arrayToString(X[] array)
{
return arrayToString(array, null);
}
public static String getProgress(String prefix, double amount, String suffix, boolean progressDirectionSwap)
{
if (progressDirectionSwap)
amount = 1 - amount;
//Generate Bar
int bars = 24;
String progressBar = C.cGreen + "";
boolean colorChange = false;
for (int i=0 ; i<bars ; i++)
{
if (!colorChange && (float)i/(float)bars >= amount)
{
progressBar += C.cRed;
colorChange = true;
}
progressBar += "";
}
return(prefix == null ? "" : prefix + ChatColor.RESET + " ") + progressBar + (suffix == null ? "" : ChatColor.RESET + " " + suffix);
}
} }

View File

@ -3,6 +3,8 @@ package mineplex.core.common.util;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import net.minecraft.server.v1_8_R3.MinecraftServer;
public class UtilTime public class UtilTime
{ {
public static final String DATE_FORMAT_NOW = "MM-dd-yyyy HH:mm:ss"; public static final String DATE_FORMAT_NOW = "MM-dd-yyyy HH:mm:ss";
@ -29,6 +31,12 @@ public class UtilTime
return sdf.format(cal.getTime()); return sdf.format(cal.getTime());
} }
public static String date(long date)
{
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_DAY);
return sdf.format(date);
}
public static String getDayOfMonthSuffix(final int n) public static String getDayOfMonthSuffix(final int n)
{ {
if (n >= 11 && n <= 13) { if (n >= 11 && n <= 13) {
@ -42,14 +50,44 @@ public class UtilTime
} }
} }
/**
*
* @return Returns the current global server tick. Is reset on server restart. Starts out negative. Counts upwards.
*/
public static int getServerTick()
{
return MinecraftServer.currentTick;
}
public enum TimeUnit public enum TimeUnit
{ {
FIT, FIT(1),
DAYS, DAYS(86400000),
HOURS, HOURS(3600000),
MINUTES, MINUTES(60000),
SECONDS, SECONDS(1000),
MILLISECONDS MILLISECONDS(1);
private long _ms;
TimeUnit(long ms)
{
_ms = ms;
}
public long getMilliseconds()
{
return _ms;
}
}
/**
* Convert from one TimeUnit to a different one
*/
public static long convert(long time, TimeUnit from, TimeUnit to)
{
long milleseconds = time * from.getMilliseconds();
return milleseconds / to.getMilliseconds();
} }
public static String since(long epoch) public static String since(long epoch)

View File

@ -0,0 +1,36 @@
package mineplex.core.common.util;
public class UtilUI
{
public static int[] getIndicesFor(int items, int startingLine, int newLinePadding)
{
return getIndicesFor(items, startingLine, 5, newLinePadding);
}
public static int[] getIndicesFor(int items, int startingLine)
{
return getIndicesFor(items, startingLine, 5, 0);
}
public static int[] getIndicesFor(int items, int startingLine, int itemsPerLine, int newLinePadding)
{
itemsPerLine = UtilMath.clamp(itemsPerLine, 1, 5);
int[] indices = new int[items];
int lines = (int) Math.ceil(items / ((double) itemsPerLine));
for (int line = 0; line < lines; line++)
{
int itemsInCurLine = line == lines - 1 ? items - (line * itemsPerLine) : itemsPerLine;
int startIndex = (startingLine * 9) + ((newLinePadding * 9) * line) + 9 * line - itemsInCurLine + 5;
for (int item = 0; item < itemsInCurLine; item++)
{
indices[(line * itemsPerLine) + item] = startIndex + (item * 2);
}
}
return indices;
}
}

View File

@ -7,6 +7,7 @@ import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.block.Block;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
public class UtilWorld public class UtilWorld
@ -46,6 +47,54 @@ public class UtilWorld
} }
} }
public static String blockToStr(Block block)
{
if (block == null)
return "";
return block.getWorld().getName() + "," +
block.getX() + "," +
block.getY() + "," +
block.getZ();
}
public static String blockToStrClean(Block block)
{
if (block == null)
return "";
return "(" + block.getX() + "," +
block.getY() + "," +
block.getZ() + ")";
}
public static Block strToBlock(String string)
{
if (string.length() == 0)
return null;
String[] parts = string.split(",");
try
{
for (World cur : UtilServer.getServer().getWorlds())
{
if (cur.getName().equalsIgnoreCase(parts[0]))
{
int x = Integer.parseInt(parts[1]);
int y = Integer.parseInt(parts[2]);
int z = Integer.parseInt(parts[3]);
return cur.getBlockAt(x, y, z);
}
}
}
catch (Exception e)
{
}
return null;
}
public static String locToStr(Location loc) public static String locToStr(Location loc)
{ {
if (loc == null) if (loc == null)
@ -65,6 +114,14 @@ public class UtilWorld
return "(" + loc.getBlockX() + ", " + loc.getBlockY() + ", " + loc.getBlockZ() + ")"; return "(" + loc.getBlockX() + ", " + loc.getBlockY() + ", " + loc.getBlockZ() + ")";
} }
public static String vecToStrClean(Vector loc)
{
if (loc == null)
return "Null";
return "(" + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ")";
}
public static Location strToLoc(String string) public static Location strToLoc(String string)
{ {
if (string.length() == 0) if (string.length() == 0)

View File

@ -0,0 +1,19 @@
package mineplex.core.common.weight;
public class Weight<T>
{
private int _weight;
public int getWeight() { return _weight; }
private T _value;
public T getValue() { return _value; }
public Weight(int weight, T value)
{
_weight = weight;
_value = value;
}
}

View File

@ -0,0 +1,99 @@
package mineplex.core.common.weight;
import java.util.Collection;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
public class WeightSet<T>
{
private static Random random = new Random();
private Set<Weight<T>> _weights;
public WeightSet()
{
_weights = new HashSet<Weight<T>>();
}
@SafeVarargs
public WeightSet(Weight<T>... weights)
{
this();
for (Weight<T> weight : weights)
{
_weights.add(weight);
}
}
@SafeVarargs
public WeightSet(T... elements)
{
this();
for (T element : elements)
{
_weights.add(new Weight<T>(1, element)); // Constant weight of 1 means all elements are equally likely
}
}
public WeightSet(Collection<T> elements)
{
this();
for (T element : elements)
{
_weights.add(new Weight<T>(1, element)); // Constant weight of 1 means all elements are equally likely
}
}
public void add(int weight, T element)
{
_weights.add(new Weight<T>(weight, element));
}
private int getTotalWeight()
{
int total = 0;
for (Weight<T> weight : _weights)
{
total += weight.getWeight();
}
return total;
}
public T generateRandom()
{
int totalWeight = getTotalWeight();
int roll = random.nextInt(totalWeight);
for (Weight<T> weight : _weights)
{
roll -= weight.getWeight();
if (roll < 0)
{
return weight.getValue();
}
}
// Should never reach here.
return null;
}
public Set<T> elements()
{
Set<T> elements = new HashSet<T>();
for (Weight<T> weight : _weights)
{
elements.add(weight.getValue());
}
return elements;
}
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpcore-4.2.jar"/> <classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpcore-4.2.jar"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpclient-4.2.jar"/> <classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpclient-4.2.jar"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/commons-codec-1.6.jar"/> <classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/commons-codec-1.6.jar"/>
@ -13,7 +13,7 @@
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jooq-3.5.2.jar"/> <classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jooq-3.5.2.jar"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar"/> <classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/NoCheatPlus.jar"/> <classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/NoCheatPlus.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.PlayerCache"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/> <classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Cache"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@ -1,12 +1,12 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7 org.eclipse.jdt.core.compiler.source=1.8

View File

@ -13,13 +13,13 @@
<orderEntry type="library" name="jedis" level="project" /> <orderEntry type="library" name="jedis" level="project" />
<orderEntry type="library" name="commons-pool2" level="project" /> <orderEntry type="library" name="commons-pool2" level="project" />
<orderEntry type="module" module-name="Mineplex.Core.Common" /> <orderEntry type="module" module-name="Mineplex.Core.Common" />
<orderEntry type="module" module-name="Classpath.Dummy" />
<orderEntry type="module" module-name="Mineplex.ServerData" /> <orderEntry type="module" module-name="Mineplex.ServerData" />
<orderEntry type="library" name="craftbukkit" level="project" /> <orderEntry type="library" name="craftbukkit" level="project" />
<orderEntry type="module" module-name="Mineplex.Database" /> <orderEntry type="module" module-name="Mineplex.Database" />
<orderEntry type="library" name="jooq" level="project" /> <orderEntry type="library" name="jooq" level="project" />
<orderEntry type="library" name="commons-dbcp2" level="project" /> <orderEntry type="library" name="commons-dbcp2" level="project" />
<orderEntry type="module" module-name="Classpath.Dummy" />
<orderEntry type="library" name="NoCheatPlus" level="project" /> <orderEntry type="library" name="NoCheatPlus" level="project" />
<orderEntry type="module" module-name="Mineplex.PlayerCache" /> <orderEntry type="module" module-name="Mineplex.Cache" />
</component> </component>
</module> </module>

Some files were not shown because too many files have changed in this diff Show More