mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-08 19:51:05 +00:00
Changed the way LWC is loaded (if available)
This commit is contained in:
parent
380705fe29
commit
3ff0b4c556
@ -1,9 +1,5 @@
|
||||
package de.epiceric.shopchest;
|
||||
|
||||
import com.griefcraft.lwc.LWC;
|
||||
import com.griefcraft.lwc.LWCPlugin;
|
||||
import com.griefcraft.scripting.JavaModule;
|
||||
import com.griefcraft.scripting.event.LWCMagnetPullEvent;
|
||||
import de.epiceric.shopchest.config.Config;
|
||||
import de.epiceric.shopchest.event.*;
|
||||
import de.epiceric.shopchest.interfaces.JsonBuilder;
|
||||
@ -26,7 +22,6 @@ import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@ -39,8 +34,8 @@ public class ShopChest extends JavaPlugin {
|
||||
public static Logger logger;
|
||||
public static Economy econ = null;
|
||||
public static Permission perm = null;
|
||||
public static LWC lwc = null;
|
||||
public static boolean lockette = false;
|
||||
public static boolean lwc = false;
|
||||
public static Database database;
|
||||
public static boolean isUpdateNeeded = false;
|
||||
public static String latestVersion = "";
|
||||
@ -158,18 +153,8 @@ public class ShopChest extends JavaPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
if (getServer().getPluginManager().getPlugin("LWC") != null) {
|
||||
Plugin lwcp = getServer().getPluginManager().getPlugin("LWC");
|
||||
lwc = ((LWCPlugin) lwcp).getLWC();
|
||||
} else {
|
||||
lwc = null;
|
||||
}
|
||||
|
||||
if (getServer().getPluginManager().getPlugin("Lockette") != null) {
|
||||
lockette = true;
|
||||
} else {
|
||||
lockette = false;
|
||||
}
|
||||
lockette = getServer().getPluginManager().getPlugin("Lockette") != null;
|
||||
lwc = getServer().getPluginManager().getPlugin("LWC") != null;
|
||||
|
||||
setupPermissions();
|
||||
|
||||
@ -257,26 +242,8 @@ public class ShopChest extends JavaPlugin {
|
||||
if (getServer().getPluginManager().getPlugin("ClearLag") != null)
|
||||
getServer().getPluginManager().registerEvents(new RegenerateShopItemAfterRemove(), this);
|
||||
|
||||
if (getServer().getPluginManager().getPlugin("LWC") != null){
|
||||
try {
|
||||
Class.forName("com.griefcraft.scripting.event.LWCMagnetPullEvent");
|
||||
|
||||
LWC.getInstance().getModuleLoader().registerModule(this, new JavaModule() {
|
||||
|
||||
@Override
|
||||
public void onMagnetPull(LWCMagnetPullEvent event) {
|
||||
if (event.getItem().hasMetadata("shopItem")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
} catch (ClassNotFoundException ex) {
|
||||
getLogger().warning("Shop items can be sucked up by the magnet flag of a protected chest of LWC.");
|
||||
getLogger().warning("Use 'LWC Unofficial - Entity locking' v1.7.3 or later by 'Me_Goes_RAWR' to prevent this.");
|
||||
};
|
||||
}
|
||||
if (getServer().getPluginManager().getPlugin("LWC") != null)
|
||||
new LWCMagnetListener().initializeListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,6 @@
|
||||
package de.epiceric.shopchest.event;
|
||||
|
||||
import com.griefcraft.lwc.LWC;
|
||||
import com.griefcraft.model.Protection;
|
||||
import de.epiceric.shopchest.ShopChest;
|
||||
import de.epiceric.shopchest.config.Config;
|
||||
@ -72,9 +73,9 @@ public class InteractShop implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (ShopChest.lwc != null) {
|
||||
if (ShopChest.lwc.getPhysicalDatabase().loadProtection(b.getLocation().getWorld().getName(), b.getX(), b.getY(), b.getZ()) != null) {
|
||||
Protection protection = ShopChest.lwc.getPhysicalDatabase().loadProtection(b.getLocation().getWorld().getName(), b.getX(), b.getY(), b.getZ());
|
||||
if (ShopChest.lwc) {
|
||||
if (LWC.getInstance().getPhysicalDatabase().loadProtection(b.getLocation().getWorld().getName(), b.getX(), b.getY(), b.getZ()) != null) {
|
||||
Protection protection = LWC.getInstance().getPhysicalDatabase().loadProtection(b.getLocation().getWorld().getName(), b.getX(), b.getY(), b.getZ());
|
||||
if (!protection.isOwner(p) || !protection.isRealOwner(p)) {
|
||||
ClickType.removePlayerClickType(p);
|
||||
break;
|
||||
|
32
src/de/epiceric/shopchest/event/LWCMagnetListener.java
Normal file
32
src/de/epiceric/shopchest/event/LWCMagnetListener.java
Normal file
@ -0,0 +1,32 @@
|
||||
package de.epiceric.shopchest.event;
|
||||
|
||||
import com.griefcraft.lwc.LWC;
|
||||
import com.griefcraft.scripting.JavaModule;
|
||||
import com.griefcraft.scripting.event.LWCMagnetPullEvent;
|
||||
import de.epiceric.shopchest.ShopChest;
|
||||
|
||||
public class LWCMagnetListener {
|
||||
|
||||
public void initializeListener() {
|
||||
try {
|
||||
Class.forName("com.griefcraft.scripting.event.LWCMagnetPullEvent");
|
||||
|
||||
LWC.getInstance().getModuleLoader().registerModule(ShopChest.getInstance(), new JavaModule() {
|
||||
|
||||
@Override
|
||||
public void onMagnetPull(LWCMagnetPullEvent event) {
|
||||
if (event.getItem().hasMetadata("shopItem")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
} catch (ClassNotFoundException ex) {
|
||||
ShopChest.logger.warning("Shop items can be sucked up by the magnet flag of a protected chest of LWC.");
|
||||
ShopChest.logger.warning("Use 'LWC Unofficial - Entity locking' v1.7.3 or later by 'Me_Goes_RAWR' to prevent this.");
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user