diff --git a/BlocksHub-PreciousStones/build.xml b/BlocksHub-PreciousStones/build.xml new file mode 100644 index 0000000..b42c7ee --- /dev/null +++ b/BlocksHub-PreciousStones/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project BlocksHub-PreciousStones. + + + diff --git a/BlocksHub-PreciousStones/nbproject/build-impl.xml b/BlocksHub-PreciousStones/nbproject/build-impl.xml new file mode 100644 index 0000000..12ab395 --- /dev/null +++ b/BlocksHub-PreciousStones/nbproject/build-impl.xml @@ -0,0 +1,1419 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BlocksHub-PreciousStones/nbproject/genfiles.properties b/BlocksHub-PreciousStones/nbproject/genfiles.properties new file mode 100644 index 0000000..5495127 --- /dev/null +++ b/BlocksHub-PreciousStones/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=e0c835c9 +build.xml.script.CRC32=50295ae7 +build.xml.stylesheet.CRC32=8064a381@1.79.1.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=e0c835c9 +nbproject/build-impl.xml.script.CRC32=967c7f3e +nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48 diff --git a/BlocksHub-PreciousStones/nbproject/project.properties b/BlocksHub-PreciousStones/nbproject/project.properties new file mode 100644 index 0000000..a079adc --- /dev/null +++ b/BlocksHub-PreciousStones/nbproject/project.properties @@ -0,0 +1,80 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=BlocksHub-PreciousStones +application.vendor=prime +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/BlocksHub-PreciousStones.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +file.reference.BlocksHub.jar=lib/BlocksHub.jar +file.reference.craftbukkit-1.10.jar=lib/craftbukkit-1.10.jar +file.reference.PreciousStones.jar=lib/PreciousStones.jar +includes=** +jar.compress=true +javac.classpath=\ + ${file.reference.BlocksHub.jar}:\ + ${file.reference.craftbukkit-1.10.jar}:\ + ${file.reference.PreciousStones.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.6 +javac.target=1.6 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=true +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/BlocksHub-PreciousStones/nbproject/project.xml b/BlocksHub-PreciousStones/nbproject/project.xml new file mode 100644 index 0000000..35863eb --- /dev/null +++ b/BlocksHub-PreciousStones/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + BlocksHub-PreciousStones + + + + + + + + + diff --git a/BlocksHub-PreciousStones/src/org/primesoft/blockshub/accessors/bukkit/preciousStones/BlocksHubPlugin.java b/BlocksHub-PreciousStones/src/org/primesoft/blockshub/accessors/bukkit/preciousStones/BlocksHubPlugin.java new file mode 100644 index 0000000..7ba33f8 --- /dev/null +++ b/BlocksHub-PreciousStones/src/org/primesoft/blockshub/accessors/bukkit/preciousStones/BlocksHubPlugin.java @@ -0,0 +1,65 @@ +/* + * BlocksHub a library plugin providing easy access to block loggers + * and block access controllers. + * Copyright (c) 2017, SBPrime + * Copyright (c) BlocksHub contributors + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted free of charge provided that the following + * conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution, + * 3. Redistributions of source code, with or without modification, in any form + * other then free of charge is not allowed, + * 4. Redistributions in binary form in any form other then free of charge is + * not allowed. + * 5. Any derived work based on or containing parts of this software must reproduce + * the above copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * derived work. + * 6. The original author of the software is allowed to change the license + * terms or the entire license of the software as he sees fit. + * 7. The original author of the software is allowed to sublicense the software + * or its parts using any license terms he sees fit. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.primesoft.blockshub.accessors.bukkit.preciousStones; + +import org.primesoft.blockshub.IBlocksHubApi; +import org.primesoft.blockshub.api.BaseAccessorEndpoint; +import org.primesoft.blockshub.api.IAccessController; +import org.primesoft.blockshub.platform.api.IPlatform; + + + +/** + * @author SBPrime + */ +public class BlocksHubPlugin extends BaseAccessorEndpoint { + + public BlocksHubPlugin() { + super("PreciousStones"); + } + + @Override + protected IAccessController createAccessor(IBlocksHubApi api, IPlatform platform, Object plugin) { + return PreciousStonesAc.create(this, plugin); + } +} \ No newline at end of file diff --git a/BlocksHub-PreciousStones/src/org/primesoft/blockshub/accessors/bukkit/preciousStones/PreciousStonesAc.java b/BlocksHub-PreciousStones/src/org/primesoft/blockshub/accessors/bukkit/preciousStones/PreciousStonesAc.java new file mode 100644 index 0000000..b4f82ab --- /dev/null +++ b/BlocksHub-PreciousStones/src/org/primesoft/blockshub/accessors/bukkit/preciousStones/PreciousStonesAc.java @@ -0,0 +1,132 @@ +/* + * BlocksHub a library plugin providing easy access to block loggers + * and block access controllers. + * Copyright (c) 2017, SBPrime + * Copyright (c) BlocksHub contributors + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted free of charge provided that the following + * conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution, + * 3. Redistributions of source code, with or without modification, in any form + * other then free of charge is not allowed, + * 4. Redistributions in binary form in any form other then free of charge is + * not allowed. + * 5. Any derived work based on or containing parts of this software must reproduce + * the above copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * derived work. + * 6. The original author of the software is allowed to change the license + * terms or the entire license of the software as he sees fit. + * 7. The original author of the software is allowed to sublicense the software + * or its parts using any license terms he sees fit. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.primesoft.blockshub.accessors.bukkit.preciousStones; + +import net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones; +import net.sacredlabyrinth.Phaed.PreciousStones.api.IApi; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.primesoft.blockshub.api.BlockData; +import org.primesoft.blockshub.api.IAccessController; +import org.primesoft.blockshub.api.ILog; +import org.primesoft.blockshub.api.IPlayer; +import org.primesoft.blockshub.api.IWorld; +import org.primesoft.blockshub.api.Vector; +import org.primesoft.blockshub.platform.bukkit.BukkitBaseEntity; +import org.primesoft.blockshub.platform.bukkit.BukkitPlayer; +import org.primesoft.blockshub.platform.bukkit.BukkitWorld; + +/** + * + * @author SBPrime + */ +public class PreciousStonesAc extends BukkitBaseEntity implements IAccessController { + + static IAccessController create(ILog logger, Object plugin) { + if (!(plugin instanceof PreciousStones)) { + logger.log("plugin not found."); + return null; + } + + return new PreciousStonesAc((PreciousStones) plugin); + } + + private final IApi m_psApi; + + private PreciousStonesAc(PreciousStones plugin) { + super(plugin); + + m_psApi = net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones.API(); + } + + @Override + public boolean hasAccess(IPlayer player, IWorld world, Vector location) { + BukkitPlayer bukkitPlayer = BukkitPlayer.getPlayer(player); + Player bPlayer = bukkitPlayer != null ? bukkitPlayer.getPlayer() : null; + if (bPlayer == null) { + return true; + } + + if (!(world instanceof BukkitWorld)) { + return true; + } + + Location l = new Location(((BukkitWorld) world).getWorld(), location.getX(), location.getY(), location.getZ()); + + + return m_psApi.canPlace(bPlayer, l); + } + + @Override + public boolean canPlace(IPlayer player, IWorld world, Vector location, + BlockData blockOld, BlockData blockNew) { + boolean airOld = blockOld.isAir(); + boolean airNew = blockNew.isAir(); + + if (airNew && airOld) { + return true; + } + + BukkitPlayer bukkitPlayer = BukkitPlayer.getPlayer(player); + Player bPlayer = bukkitPlayer != null ? bukkitPlayer.getPlayer() : null; + if (bPlayer == null) { + return true; + } + + if (!(world instanceof BukkitWorld)) { + return true; + } + + Location l = new Location(((BukkitWorld) world).getWorld(), location.getX(), location.getY(), location.getZ()); + + boolean allow = true; + + if (!airOld) { + allow &= m_psApi.canBreak(bPlayer, l); + } + if (!airNew) { + allow &= m_psApi.canPlace(bPlayer, l); + } + + return allow; + } +}