Update LWC protection and support more LWC forks (LWCX and Modern-LWC)
This commit is contained in:
parent
285b6b9089
commit
f90d23cfc3
21
pom.xml
21
pom.xml
|
@ -167,9 +167,26 @@
|
|||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.griefcraft.lwc</groupId>
|
||||
<groupId>com.griefcraft</groupId>
|
||||
<artifactId>lwc</artifactId>
|
||||
<version>4.3.1</version>
|
||||
<version>4.7.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.griefcraft.lwc</groupId>
|
||||
<artifactId>LWCX</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.Acrobot.ChestShop.Plugins;
|
||||
|
||||
import com.Acrobot.ChestShop.ChestShop;
|
||||
import com.Acrobot.ChestShop.Configuration.Messages;
|
||||
import com.Acrobot.ChestShop.Configuration.Properties;
|
||||
import com.Acrobot.ChestShop.Events.Protection.ProtectBlockEvent;
|
||||
|
@ -11,7 +12,6 @@ import com.griefcraft.lwc.LWC;
|
|||
import com.griefcraft.model.Protection;
|
||||
import com.griefcraft.scripting.event.LWCProtectionRegisterEvent;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.block.Container;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -99,8 +99,24 @@ public class LightweightChestProtection implements Listener {
|
|||
return;
|
||||
}
|
||||
|
||||
// TODO: Update to new API once LWC is updated
|
||||
Protection protection = lwc.getPhysicalDatabase().registerProtection(block.getType().getId(), Protection.Type.PRIVATE, worldName, player.getUniqueId().toString(), "", x, y, z);
|
||||
Protection protection = null;
|
||||
try {
|
||||
protection = lwc.getPhysicalDatabase().registerProtection(block.getType(), Protection.Type.PRIVATE, worldName, player.getUniqueId().toString(), "", x, y, z);
|
||||
} catch (LinkageError e) {
|
||||
try {
|
||||
int blockId = com.griefcraft.cache.BlockCache.getInstance().getBlockId(block);
|
||||
if (blockId < 0) {
|
||||
return;
|
||||
}
|
||||
protection = lwc.getPhysicalDatabase().registerProtection(blockId, Protection.Type.PRIVATE, worldName, player.getUniqueId().toString(), "", x, y, z);
|
||||
} catch (LinkageError e2) {
|
||||
ChestShop.getBukkitLogger().warning(
|
||||
"Incompatible LWC version installed! (" + lwc.getPlugin().getName() + " v" + lwc.getVersion() + ") \n" +
|
||||
"Material method error: " + e.getMessage() + "\n" +
|
||||
"Block cache/type id error: " + e2.getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (protection != null) {
|
||||
event.setProtected(true);
|
||||
|
|
Loading…
Reference in New Issue