Skip to content

Commit

Permalink
Use PaperLib for some performance enhancements.
Browse files Browse the repository at this point in the history
  • Loading branch information
wizjany committed Jul 27, 2019
1 parent 4044e2b commit 2e828e6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions config/checkstyle/import-control.xml
Expand Up @@ -22,6 +22,8 @@
<subpackage name="bukkit">
<allow pkg="org.bukkit"/>
<allow pkg="org.bstats.bukkit"/>
<allow pkg="io.papermc.lib"/>
<allow pkg="com.destroystokyo.paper"/>
</subpackage>

<subpackage name="sponge">
Expand Down
11 changes: 7 additions & 4 deletions worldguard-bukkit/build.gradle
Expand Up @@ -2,10 +2,8 @@ apply plugin: 'eclipse'
apply plugin: 'idea'

repositories {
maven {
name = 'bstats repo'
url = 'https://repo.codemc.org/repository/maven-public'
}
maven { url = 'https://repo.codemc.org/repository/maven-public' }
maven { url = 'https://papermc.io/repo/repository/maven-public/' }
}

dependencies {
Expand All @@ -14,6 +12,8 @@ dependencies {
api ('com.sk89q.worldedit:worldedit-bukkit:7.0.1-SNAPSHOT') {
exclude group: 'io.papermc', module: 'paperlib'
}
implementation 'io.papermc:paperlib:1.0.2'
compileOnly 'com.destroystokyo.paper:paper-api:1.13.2-R0.1-SNAPSHOT'
implementation ('com.sk89q:commandbook:2.3') {
exclude group: 'com.sk89q', module: 'worldedit'
exclude group: 'com.zachsthings.libcomponents'
Expand Down Expand Up @@ -46,6 +46,9 @@ shadowJar {
relocate ("org.bstats", "com.sk89q.worldguard.bukkit.bstats") {
include(dependency("org.bstats:bstats-bukkit:1.5"))
}
relocate ("io.papermc.lib", "com.sk89q.worldguard.bukkit.paperlib") {
include(dependency("io.papermc:paperlib:1.0.2"))
}
}

relocate('org.flywaydb', 'com.sk89q.worldguard.internal.flywaydb')
Expand Down
Expand Up @@ -419,8 +419,8 @@ public void onPlayerInteract(PlayerInteractEvent event) {
// Only fire events for blocks that are modified when right clicked
final boolean hasItemInteraction = item != null && isItemAppliedToBlock(item, clicked)
&& event.getAction() == Action.RIGHT_CLICK_BLOCK;
modifiesWorld = isBlockModifiedOnClick(clicked, event.getAction() == Action.RIGHT_CLICK_BLOCK)
|| hasItemInteraction;
modifiesWorld = hasItemInteraction
|| isBlockModifiedOnClick(clicked, event.getAction() == Action.RIGHT_CLICK_BLOCK);

if (Events.fireAndTestCancel(new UseBlockEvent(event, cause, clicked).setAllowed(!modifiesWorld))) {
event.setUseInteractedBlock(Result.DENY);
Expand Down
Expand Up @@ -19,6 +19,7 @@

package com.sk89q.worldguard.bukkit.util;

import io.papermc.lib.PaperLib;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
Expand All @@ -45,7 +46,7 @@ private Blocks() {
* @return a list of connected blocks, not including the given block
*/
public static List<Block> getConnected(Block block) {
BlockState state = block.getState();
BlockState state = PaperLib.getBlockState(block, false).getState();
BlockData data = state.getBlockData();

if (data instanceof Bed) {
Expand Down

0 comments on commit 2e828e6

Please sign in to comment.