mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-11-30 05:53:23 +01:00
- Added support for OddItem 0.8
- Fixed getRetractBlock
This commit is contained in:
parent
06e02cbc3e
commit
4440101a3a
@ -4,6 +4,7 @@ import com.Acrobot.ChestShop.ChestShop;
|
||||
import com.Acrobot.ChestShop.Config.Config;
|
||||
import com.Acrobot.ChestShop.Config.Property;
|
||||
|
||||
import javax.persistence.OptimisticLockException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
@ -19,7 +20,8 @@ public class Queue implements Runnable {
|
||||
public void run() {
|
||||
ChestShop.getDB().delete(ChestShop.getDB().find(Transaction.class).where().lt("sec", System.currentTimeMillis() / 1000 - Config.getInteger(Property.RECORD_TIME_TO_LIVE)).findList());
|
||||
|
||||
ChestShop.getDB().save(queue);
|
||||
ArrayList<Transaction> queueCopy = queue;
|
||||
try { ChestShop.getDB().save(queueCopy); } catch (OptimisticLockException ignored) {}
|
||||
queue.clear();
|
||||
}
|
||||
}
|
||||
|
@ -7,15 +7,15 @@ import org.bukkit.inventory.ItemStack;
|
||||
* @author Acrobot
|
||||
*/
|
||||
public class Odd {
|
||||
public static OddItem oddItem;
|
||||
public static boolean isInitialized;
|
||||
|
||||
public static boolean isInitialized() {
|
||||
return oddItem != null;
|
||||
return isInitialized;
|
||||
}
|
||||
|
||||
public static ItemStack returnItemStack(String name) {
|
||||
try {
|
||||
return oddItem.getItemStack(name);
|
||||
return OddItem.getItemStack(name);
|
||||
} catch (Exception ignored) {
|
||||
return null;
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.material.PistonBaseMaterial;
|
||||
|
||||
/**
|
||||
* @author Acrobot
|
||||
@ -58,6 +57,6 @@ public class blockBreak extends BlockListener {
|
||||
}
|
||||
|
||||
private static Block getRetractBlock(BlockPistonRetractEvent event) {
|
||||
return event.getBlock().getState().getData() instanceof PistonBaseMaterial ? event.getRetractLocation().getBlock() : null;
|
||||
return (!uSign.isSign(event.getRetractLocation().getBlock()) ? event.getRetractLocation().getBlock() : null);
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ import com.Acrobot.ChestShop.Utils.uLongName;
|
||||
import com.Acrobot.ChestShop.Utils.uSign;
|
||||
import net.minecraft.server.IInventory;
|
||||
import net.minecraft.server.InventoryLargeChest;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Chest;
|
||||
|
@ -10,13 +10,11 @@ import com.Acrobot.ChestShop.Protection.Plugins.LockettePlugin;
|
||||
import com.Acrobot.ChestShop.Protection.Security;
|
||||
import com.Acrobot.ChestShop.Utils.uNumber;
|
||||
import com.Acrobot.ChestShop.Utils.uSign;
|
||||
import com.Acrobot.ChestShop.Utils.uTowny;
|
||||
import com.daemitus.deadbolt.Deadbolt;
|
||||
import com.griefcraft.lwc.LWCPlugin;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
import com.nijikokun.register.payment.forChestShop.Methods;
|
||||
import com.palmergames.bukkit.towny.Towny;
|
||||
import info.somethingodd.bukkit.OddItem.OddItem;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -59,17 +57,22 @@ public class pluginEnable extends ServerListener {
|
||||
DeadboltPlugin.deadbolt = (Deadbolt) plugin;
|
||||
Security.protection = new DeadboltPlugin();
|
||||
} else if (name.equals("OddItem")) {
|
||||
if (Odd.oddItem != null) return;
|
||||
Odd.oddItem = (OddItem) plugin;
|
||||
if (Odd.isInitialized()) return;
|
||||
if (plugin.getDescription().getVersion().startsWith("0.7")) { System.out.println(generateOutdatedVersion(name, plugin.getDescription().getVersion(), "0.8")); return; }
|
||||
Odd.isInitialized = true;
|
||||
} else if (name.equals("Towny")) {
|
||||
if (uSign.towny != null) return;
|
||||
int versionNumber = 0;
|
||||
String[] split = plugin.getDescription().getVersion().split("\\.");
|
||||
for (int i = 0; i < 4; i++) if (split.length >= i+1 && uNumber.isInteger(split[i])) versionNumber += (Math.pow(10, (3 - i) << 1) * Integer.parseInt(split[i])); //EPIC CODE RIGHT HERE
|
||||
if(versionNumber < 760047){ System.out.println(ChestShop.chatPrefix + "Your Towny version is outdated! Need version AT LEAST 0.76.0.47! - Your version is " + plugin.getDescription().getVersion()); return; }
|
||||
for (int i = 0; i < 4; i++) if (split.length >= i + 1 && uNumber.isInteger(split[i])) versionNumber += (Math.pow(10, (3 - i) << 1) * Integer.parseInt(split[i])); //EPIC CODE RIGHT HERE
|
||||
if (versionNumber < 760047) { System.out.println(generateOutdatedVersion(name, plugin.getDescription().getVersion(), "0.76.0.47")); return; }
|
||||
uSign.towny = (Towny) plugin;
|
||||
}
|
||||
PluginDescriptionFile description = plugin.getDescription();
|
||||
System.out.println(ChestShop.chatPrefix + description.getName() + " version " + description.getVersion() + " loaded.");
|
||||
}
|
||||
|
||||
private static String generateOutdatedVersion(String pluginName, String curVersion, String neededVersion){
|
||||
return (new StringBuilder(7).append(ChestShop.chatPrefix).append("Your ").append(pluginName).append(" is outdated! Need version AT LEAST ").append(neededVersion).append(" - Your version is ").append(curVersion).toString());
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public class signChange extends BlockListener {
|
||||
|
||||
Block chestBlock = chest.getBlock();
|
||||
|
||||
if(uSign.towny != null && !uTowny.canBuild(player, signBlock.getLocation(), chestBlock.getLocation())){
|
||||
if (uSign.towny != null && !uTowny.canBuild(player, signBlock.getLocation(), chestBlock.getLocation())) {
|
||||
player.sendMessage(Config.getLocal(Language.TOWNY_CANNOT_CREATE_SHOP_HERE));
|
||||
dropSign(event);
|
||||
return;
|
||||
|
@ -18,17 +18,17 @@ public class uTowny {
|
||||
return uSign.towny.getTownyUniverse().getTownBlock(chestlocation).getType() == TownBlockType.COMMERCIAL && uSign.towny.getTownyUniverse().getTownBlock(signLocation).getType() == TownBlockType.COMMERCIAL;
|
||||
}
|
||||
|
||||
public static boolean isPlotOwner(Player player, Location chestLocation, Location signLocation){
|
||||
public static boolean isPlotOwner(Player player, Location chestLocation, Location signLocation) {
|
||||
return isBlockOwner(player, chestLocation) && isBlockOwner(player, signLocation);
|
||||
}
|
||||
|
||||
public static boolean canBuild(Player player, Location chestLocation, Location signLocation){
|
||||
public static boolean canBuild(Player player, Location chestLocation, Location signLocation) {
|
||||
return !Config.getBoolean(Property.TOWNY_INTEGRATION) || (isInsideShopPlot(chestLocation, signLocation) && isPlotOwner(player, chestLocation, signLocation));
|
||||
}
|
||||
|
||||
private static boolean isBlockOwner(Player player, Location location){
|
||||
try{
|
||||
private static boolean isBlockOwner(Player player, Location location) {
|
||||
try {
|
||||
return uSign.towny.getTownyUniverse().getTownBlock(location).isOwner(uSign.towny.getTownyUniverse().getResident(player.getName()));
|
||||
} catch (NotRegisteredException ex){ return false; }
|
||||
} catch (NotRegisteredException ex) { return false; }
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ name: ChestShop
|
||||
|
||||
main: com.Acrobot.ChestShop.ChestShop
|
||||
|
||||
version: 3.2
|
||||
version: 3.21
|
||||
|
||||
|
||||
author: Acrobot
|
||||
|
Loading…
Reference in New Issue
Block a user