Use PaperLib for some performance enhancements.

This commit is contained in:
wizjany 2019-06-14 23:12:31 -04:00
parent 93dae282b2
commit c5bfdcb0e6
4 changed files with 31 additions and 4 deletions

View File

@ -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">

View File

@ -1,4 +1,5 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.api.internal.HasConvention
plugins {
id("java-library")
@ -14,6 +15,10 @@
name = "spigot"
url = uri("https://hub.spigotmc.org/nexus/content/groups/public")
}
maven {
name = "paper"
url = uri("https://papermc.io/repo/repository/maven-public/")
}
maven {
name = "bstats"
url = uri("https://repo.codemc.org/repository/maven-public")
@ -23,12 +28,28 @@
dependencies {
"compile"(project(":worldguard-core"))
//"compile"(project(":worldguard-libs:bukkit"))
"api"("org.bukkit:bukkit:1.14.2-R0.1-SNAPSHOT")
"api"("com.destroystokyo.paper:paper-api:1.14.4-R0.1-SNAPSHOT")
"implementation"("io.papermc:paperlib:1.0.2")
"api"("com.sk89q.worldedit:worldedit-bukkit:7.0.1-SNAPSHOT") { isTransitive = false }
"implementation"("com.sk89q:commandbook:2.3") { isTransitive = false }
"implementation"("org.bstats:bstats-bukkit:1.5")
}
tasks.named<Upload>("install") {
(repositories as HasConvention).convention.getPlugin<MavenRepositoryHandlerConvention>().mavenInstaller {
pom.whenConfigured {
dependencies.firstOrNull { dep ->
dep!!.withGroovyBuilder {
getProperty("groupId") == "com.destroystokyo.paper" && getProperty("artifactId") == "paper-api"
}
}?.withGroovyBuilder {
setProperty("groupId", "org.bukkit")
setProperty("artifactId", "bukkit")
}
}
}
}
tasks.named<Copy>("processResources") {
filesMatching("plugin.yml") {
expand("internalVersion" to project.ext["internalVersion"])
@ -46,6 +67,9 @@
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"))
}
}
}

View File

@ -421,8 +421,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);

View File

@ -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;
@ -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) {