Skip to content

Commit

Permalink
1.13 log block
Browse files Browse the repository at this point in the history
  • Loading branch information
SBPrime committed Mar 3, 2019
1 parent ce75e6c commit 1ed56b3
Show file tree
Hide file tree
Showing 10 changed files with 171 additions and 109 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@
/BlocksHub_Accessors/BlocksHub-WorldGuard/build/
/BlocksHub_Accessors/BlocksHub-WorldGuard/dist/
/BlocksHub_Accessors/BlocksHub-Accessor-GriefPrevention/build/
/BlocksHub_Accessors/BlocksHub-Accessor-GriefPrevention/target/
/BlocksHub_Accessors/BlocksHub-Accessor-GriefPrevention/target/
/BlocksHub_Loggers/BlocksHub-Logger-LogBlock/build/
/BlocksHub_Loggers/BlocksHub-Logger-LogBlock/target/
6 changes: 6 additions & 0 deletions BlocksHub-Deploy-Bukkit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
<version>[3.1.0, 4.0.0)</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.primesoft.blockshub.loggers</groupId>
<artifactId>BlocksHub-Logger-LogBlock</artifactId>
<version>[3.1.0, 4.0.0)</version>
<scope>compile</scope>
</dependency>
<!-- Accessord -->
<dependency>
<groupId>org.primesoft.blockshub.accessors</groupId>
Expand Down
45 changes: 45 additions & 0 deletions BlocksHub_Loggers/BlocksHub-Logger-LogBlock/licenseheader.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<#if licenseFirst??>
${licenseFirst}
</#if>
${licensePrefix}BlocksHub a library plugin providing easy access to block loggers
${licensePrefix}and block access controllers.
${licensePrefix}Copyright (c) ${date?date?string("yyyy")}, SBPrime <https://github.com/SBPrime/>
${licensePrefix}Copyright (c) BlocksHub contributors
${licensePrefix?replace(" +$", "", "r")}
${licensePrefix}All rights reserved.
${licensePrefix?replace(" +$", "", "r")}
${licensePrefix}Redistribution and use in source and binary forms, with or without
${licensePrefix}modification, are permitted free of charge provided that the following
${licensePrefix}conditions are met:
${licensePrefix?replace(" +$", "", "r")}
${licensePrefix}1. Redistributions of source code must retain the above copyright notice, this
${licensePrefix} list of conditions and the following disclaimer.
${licensePrefix}2. Redistributions in binary form must reproduce the above copyright notice,
${licensePrefix} this list of conditions and the following disclaimer in the documentation
${licensePrefix} and/or other materials provided with the distribution,
${licensePrefix}3. Redistributions of source code, with or without modification, in any form
${licensePrefix} other then free of charge is not allowed,
${licensePrefix}4. Redistributions in binary form in any form other then free of charge is
${licensePrefix} not allowed.
${licensePrefix}5. Any derived work based on or containing parts of this software must reproduce
${licensePrefix} the above copyright notice, this list of conditions and the following
${licensePrefix} disclaimer in the documentation and/or other materials provided with the
${licensePrefix} derived work.
${licensePrefix}6. The original author of the software is allowed to change the license
${licensePrefix} terms or the entire license of the software as he sees fit.
${licensePrefix}7. The original author of the software is allowed to sublicense the software
${licensePrefix} or its parts using any license terms he sees fit.
${licensePrefix?replace(" +$", "", "r")}
${licensePrefix}THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
${licensePrefix}ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
${licensePrefix}WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
${licensePrefix}DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
${licensePrefix}ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
${licensePrefix}(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
${licensePrefix}LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
${licensePrefix}ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
${licensePrefix}(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
${licensePrefix}SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<#if licenseLast??>
${licenseLast}
</#if>
18 changes: 18 additions & 0 deletions BlocksHub_Loggers/BlocksHub-Logger-LogBlock/nb-configuration.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<netbeans.hint.licensePath>${project.basedir}/licenseheader.txt</netbeans.hint.licensePath>
</properties>
</project-shared-configuration>
64 changes: 64 additions & 0 deletions BlocksHub_Loggers/BlocksHub-Logger-LogBlock/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.primesoft.blockshub.loggers</groupId>
<artifactId>BlocksHub-Logger-LogBlock</artifactId>

<packaging>jar</packaging>

<parent>
<groupId>org.primesoft.blockshub</groupId>
<artifactId>BlocksHub_Loggers</artifactId>
<version>${global.bh.version}</version>
<relativePath>..</relativePath>
</parent>

<repositories>
<repository>
<name>LogBlock</name>
<id>log-block</id>
<url>https://repo.md-5.net/content/repositories/snapshots/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>[1.13, 1.14)</version>
<type>jar</type>
</dependency>

<dependency>
<groupId>de.diddiz</groupId>
<artifactId>logblock</artifactId>
<version>[1.13.2-SNAPSHOT, 1.13.3-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.primesoft</groupId>
<artifactId>BlocksHubBukkitApi</artifactId>
<version>[3.1.0, 4.0.0)</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.primesoft.blockshub</groupId>
<artifactId>BlocksHub-Base</artifactId>
<version>[3.1.0, 4.0.0)</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.primesoft.blockshub</groupId>
<artifactId>BlocksHub-BaseBukkit</artifactId>
<version>[3.1.0, 4.0.0)</version>
<type>jar</type>
</dependency>
</dependencies>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
package org.primesoft.blockshub.logger.bukkit.logBlock;

import org.primesoft.blockshub.IBlocksHubApi;
import org.primesoft.blockshub.api.BaseLoggerEndpoint;
import org.primesoft.blockshub.api.IBlockLogger;
import org.primesoft.blockshub.platform.api.IPlatform;
import org.primesoft.blockshub.api.IPlatform;
import org.primesoft.blockshub.api.base.BaseLoggerEndpoint;

/**
* @author SBPrime
Expand All @@ -58,7 +58,7 @@ public BlocksHubPlugin() {

@Override
protected IBlockLogger createLogger(IBlocksHubApi api, IPlatform platform, Object plugin) {
return LogBlockLogger.create(this, plugin);
return LogBlockLogger.create(this, platform, plugin);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,92 +39,95 @@
* (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.logger.bukkit.logBlock;

import de.diddiz.LogBlock.Actor;
import de.diddiz.LogBlock.Consumer;
import de.diddiz.LogBlock.LogBlock;
import org.bukkit.Location;
import org.bukkit.World;
import org.primesoft.blockshub.api.BlockData;
import org.bukkit.block.data.BlockData;
import org.primesoft.blockshub.api.IBlockData;
import org.primesoft.blockshub.api.IBlockLogger;
import org.primesoft.blockshub.api.ILog;
import org.primesoft.blockshub.api.IPlatform;
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.BukkitWorld;
import org.primesoft.blockshub.api.platform.base.BukkitBaseEntity;

/**
*
* @author SBPrime
*/
public class LogBlockLogger extends BukkitBaseEntity implements IBlockLogger {

static IBlockLogger create(ILog logger, Object plugin) {
static IBlockLogger create(ILog logger, IPlatform platform, Object plugin) {
if (!(plugin instanceof LogBlock)) {
logger.log("plugin not found.");
return null;
return null;
}
LogBlock logBlock = (LogBlock)plugin;

LogBlock logBlock = (LogBlock) plugin;
Consumer consumer = logBlock.getConsumer();
if (consumer == null) {
logger.log("unable to get the Consumer");
return null;
}


return new LogBlockLogger(logBlock, consumer);

return new LogBlockLogger(logBlock, consumer, platform);
}

/**
* The log block consumer
*/
private final Consumer m_consumer;


private LogBlockLogger(LogBlock plugin, Consumer consumer) {
private final IPlatform m_platform;

private LogBlockLogger(LogBlock plugin, Consumer consumer, IPlatform platform) {
super(plugin);
m_consumer = consumer;
m_platform = platform;
}

/**
* Get actor
*
* @param player
* @return
* @return
*/
private static Actor getActor(IPlayer player) {
return new Actor(player.getName(), player.getUUID());
}

@Override
public void logBlock(Vector location, IPlayer player, IWorld world, BlockData blockOld, BlockData blockNew) {
public void logBlock(IPlayer player, IWorld world, double x, double y, double z, IBlockData blockOld, IBlockData blockNew) {
boolean airOld = blockOld.isAir();
boolean airNew = blockNew.isAir();

World bWorld = ((BukkitWorld) world).getWorld();

if (world == null) {
return;
}
World bWorld = m_platform.getPlatformWorld(world, World.class);
if (bWorld == null) {
return;
}

Location l = new Location(bWorld, location.getX(), location.getY(), location.getZ());
Location l = m_platform.getPlatformLocation(world, x, y, z, Location.class);
Actor actor = getActor(player);

if (airOld && airNew) {
return;
}

if (airOld) {
m_consumer.queueBlockPlace(actor, l, blockNew.getType(), (byte)blockNew.getData());
}
else if (airNew) {
m_consumer.queueBlockBreak(actor, l, blockOld.getType(), (byte)blockOld.getData());
m_consumer.queueBlockPlace(actor, l, blockNew.getData(BlockData.class));
} else if (airNew) {
m_consumer.queueBlockBreak(actor, l, blockOld.getData(BlockData.class));
} else {
m_consumer.queueBlockReplace(actor, l, blockOld.getType(), (byte)blockOld.getData(),
blockNew.getType(), (byte)blockNew.getData());
m_consumer.queueBlockReplace(actor, l,
blockOld.getData(BlockData.class),
blockNew.getData(BlockData.class));
}
}
}
1 change: 1 addition & 0 deletions BlocksHub_Loggers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
<name>BlocksHub_Loggers</name>
<modules>
<module>BlocksHub-Logger-CoreProtect</module>
<module>BlocksHub-Logger-LogBlock</module>
</modules>
</project>
73 changes: 0 additions & 73 deletions notPorted/BlocksHub-LogBlock/build.xml

This file was deleted.

4 changes: 0 additions & 4 deletions notPorted/BlocksHub-LogBlock/build/built-jar.properties

This file was deleted.

0 comments on commit 1ed56b3

Please sign in to comment.