- Added support for OddItem 0.8

- Fixed getRetractBlock
This commit is contained in:
Acrobot 2011-09-25 16:17:44 +02:00
parent 06e02cbc3e
commit 4440101a3a
8 changed files with 23 additions and 20 deletions

View File

@ -4,6 +4,7 @@ import com.Acrobot.ChestShop.ChestShop;
import com.Acrobot.ChestShop.Config.Config; import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Property; import com.Acrobot.ChestShop.Config.Property;
import javax.persistence.OptimisticLockException;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
@ -19,7 +20,8 @@ public class Queue implements Runnable {
public void run() { 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().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(); queue.clear();
} }
} }

View File

@ -7,15 +7,15 @@ import org.bukkit.inventory.ItemStack;
* @author Acrobot * @author Acrobot
*/ */
public class Odd { public class Odd {
public static OddItem oddItem; public static boolean isInitialized;
public static boolean isInitialized() { public static boolean isInitialized() {
return oddItem != null; return isInitialized;
} }
public static ItemStack returnItemStack(String name) { public static ItemStack returnItemStack(String name) {
try { try {
return oddItem.getItemStack(name); return OddItem.getItemStack(name);
} catch (Exception ignored) { } catch (Exception ignored) {
return null; return null;
} }

View File

@ -11,7 +11,6 @@ import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockListener; import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent; import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.material.PistonBaseMaterial;
/** /**
* @author Acrobot * @author Acrobot
@ -58,6 +57,6 @@ public class blockBreak extends BlockListener {
} }
private static Block getRetractBlock(BlockPistonRetractEvent event) { 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);
} }
} }

View File

@ -12,7 +12,6 @@ import com.Acrobot.ChestShop.Utils.uLongName;
import com.Acrobot.ChestShop.Utils.uSign; import com.Acrobot.ChestShop.Utils.uSign;
import net.minecraft.server.IInventory; import net.minecraft.server.IInventory;
import net.minecraft.server.InventoryLargeChest; import net.minecraft.server.InventoryLargeChest;
import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.Chest; import org.bukkit.block.Chest;

View File

@ -10,13 +10,11 @@ import com.Acrobot.ChestShop.Protection.Plugins.LockettePlugin;
import com.Acrobot.ChestShop.Protection.Security; import com.Acrobot.ChestShop.Protection.Security;
import com.Acrobot.ChestShop.Utils.uNumber; import com.Acrobot.ChestShop.Utils.uNumber;
import com.Acrobot.ChestShop.Utils.uSign; import com.Acrobot.ChestShop.Utils.uSign;
import com.Acrobot.ChestShop.Utils.uTowny;
import com.daemitus.deadbolt.Deadbolt; import com.daemitus.deadbolt.Deadbolt;
import com.griefcraft.lwc.LWCPlugin; import com.griefcraft.lwc.LWCPlugin;
import com.nijikokun.bukkit.Permissions.Permissions; import com.nijikokun.bukkit.Permissions.Permissions;
import com.nijikokun.register.payment.forChestShop.Methods; import com.nijikokun.register.payment.forChestShop.Methods;
import com.palmergames.bukkit.towny.Towny; import com.palmergames.bukkit.towny.Towny;
import info.somethingodd.bukkit.OddItem.OddItem;
import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener; import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -59,17 +57,22 @@ public class pluginEnable extends ServerListener {
DeadboltPlugin.deadbolt = (Deadbolt) plugin; DeadboltPlugin.deadbolt = (Deadbolt) plugin;
Security.protection = new DeadboltPlugin(); Security.protection = new DeadboltPlugin();
} else if (name.equals("OddItem")) { } else if (name.equals("OddItem")) {
if (Odd.oddItem != null) return; if (Odd.isInitialized()) return;
Odd.oddItem = (OddItem) plugin; 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")) { } else if (name.equals("Towny")) {
if (uSign.towny != null) return; if (uSign.towny != null) return;
int versionNumber = 0; int versionNumber = 0;
String[] split = plugin.getDescription().getVersion().split("\\."); 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 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; } if (versionNumber < 760047) { System.out.println(generateOutdatedVersion(name, plugin.getDescription().getVersion(), "0.76.0.47")); return; }
uSign.towny = (Towny) plugin; uSign.towny = (Towny) plugin;
} }
PluginDescriptionFile description = plugin.getDescription(); PluginDescriptionFile description = plugin.getDescription();
System.out.println(ChestShop.chatPrefix + description.getName() + " version " + description.getVersion() + " loaded."); 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());
}
} }

View File

@ -90,7 +90,7 @@ public class signChange extends BlockListener {
Block chestBlock = chest.getBlock(); 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)); player.sendMessage(Config.getLocal(Language.TOWNY_CANNOT_CREATE_SHOP_HERE));
dropSign(event); dropSign(event);
return; return;

View File

@ -18,17 +18,17 @@ public class uTowny {
return uSign.towny.getTownyUniverse().getTownBlock(chestlocation).getType() == TownBlockType.COMMERCIAL && uSign.towny.getTownyUniverse().getTownBlock(signLocation).getType() == TownBlockType.COMMERCIAL; 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); 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)); return !Config.getBoolean(Property.TOWNY_INTEGRATION) || (isInsideShopPlot(chestLocation, signLocation) && isPlotOwner(player, chestLocation, signLocation));
} }
private static boolean isBlockOwner(Player player, Location location){ private static boolean isBlockOwner(Player player, Location location) {
try{ try {
return uSign.towny.getTownyUniverse().getTownBlock(location).isOwner(uSign.towny.getTownyUniverse().getResident(player.getName())); return uSign.towny.getTownyUniverse().getTownBlock(location).isOwner(uSign.towny.getTownyUniverse().getResident(player.getName()));
} catch (NotRegisteredException ex){ return false; } } catch (NotRegisteredException ex) { return false; }
} }
} }

View File

@ -2,7 +2,7 @@ name: ChestShop
main: com.Acrobot.ChestShop.ChestShop main: com.Acrobot.ChestShop.ChestShop
version: 3.2 version: 3.21
author: Acrobot author: Acrobot