mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-11-27 20:46:31 +01:00
Rework LWC module
This commit is contained in:
parent
7d8c2d56b0
commit
86889b0ffc
@ -1,21 +0,0 @@
|
||||
package com.Acrobot.ChestShop.Listeners;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
/**
|
||||
* @author Acrobot
|
||||
*/
|
||||
public class TeleportFixListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public static void onTeleport(PlayerTeleportEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.getPlayer().closeInventory();
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ import com.Acrobot.ChestShop.Events.ShopCreatedEvent;
|
||||
import com.Acrobot.ChestShop.Security;
|
||||
import com.griefcraft.lwc.LWC;
|
||||
import com.griefcraft.model.Protection;
|
||||
import com.griefcraft.modules.limits.LimitsV2;
|
||||
import com.griefcraft.scripting.event.LWCProtectionRegisterEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Chest;
|
||||
@ -23,11 +23,9 @@ import org.bukkit.event.Listener;
|
||||
*/
|
||||
public class LightweightChestProtection implements Listener {
|
||||
private LWC lwc;
|
||||
private LimitsV2 limitsModule;
|
||||
|
||||
public LightweightChestProtection() {
|
||||
this.lwc = LWC.getInstance();
|
||||
limitsModule = new LimitsV2();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -76,7 +74,7 @@ public class LightweightChestProtection implements Listener {
|
||||
Block block = event.getBlock();
|
||||
Player player = Bukkit.getPlayerExact(event.getName());
|
||||
|
||||
if (player == null || limitsModule.hasReachedLimit(player, block.getType())) {
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -93,6 +91,13 @@ public class LightweightChestProtection implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
LWCProtectionRegisterEvent protectionEvent = new LWCProtectionRegisterEvent(player, block);
|
||||
lwc.getModuleLoader().dispatchEvent(protectionEvent);
|
||||
|
||||
if (protectionEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Protection protection = lwc.getPhysicalDatabase().registerProtection(block.getTypeId(), Protection.Type.PRIVATE, worldName, event.getName(), "", x, y, z);
|
||||
|
||||
if (protection != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user