- Fixed towny integration (grr... java)
- (Tried to) - it shouldn't cause too long message error.
This commit is contained in:
parent
ad51a87175
commit
06e02cbc3e
|
@ -97,7 +97,7 @@ public class playerInteract extends PlayerListener {
|
||||||
IInventory inventory = ((CraftInventory) chest.getInventory()).getInventory();
|
IInventory inventory = ((CraftInventory) chest.getInventory()).getInventory();
|
||||||
chest = uBlock.findNeighbor(chest);
|
chest = uBlock.findNeighbor(chest);
|
||||||
|
|
||||||
if (chest != null) inventory = new InventoryLargeChest(player.getName() + "'s Shop", inventory, ((CraftInventory) chest.getInventory()).getInventory());
|
if (chest != null) inventory = new InventoryLargeChest("Large chest", inventory, ((CraftInventory) chest.getInventory()).getInventory());
|
||||||
|
|
||||||
((CraftPlayer) player).getHandle().a(inventory); //Show inventory on the screen
|
((CraftPlayer) player).getHandle().a(inventory); //Show inventory on the screen
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import com.Acrobot.ChestShop.Protection.Plugins.LWCplugin;
|
||||||
import com.Acrobot.ChestShop.Protection.Plugins.LockettePlugin;
|
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.uTowny;
|
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;
|
||||||
|
@ -61,12 +62,12 @@ public class pluginEnable extends ServerListener {
|
||||||
if (Odd.oddItem != null) return;
|
if (Odd.oddItem != null) return;
|
||||||
Odd.oddItem = (OddItem) plugin;
|
Odd.oddItem = (OddItem) plugin;
|
||||||
} else if (name.equals("Towny")) {
|
} else if (name.equals("Towny")) {
|
||||||
if (uTowny.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(ChestShop.chatPrefix + "Your Towny version is outdated! Need version AT LEAST 0.76.0.47! - Your version is " + plugin.getDescription().getVersion()); return; }
|
||||||
uTowny.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.");
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class signChange extends BlockListener {
|
||||||
|
|
||||||
Block chestBlock = chest.getBlock();
|
Block chestBlock = chest.getBlock();
|
||||||
|
|
||||||
if(!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;
|
||||||
|
@ -169,8 +169,7 @@ public class signChange extends BlockListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean formatFirstLine(String line1, Player player) {
|
private static boolean formatFirstLine(String line1, Player player) {
|
||||||
return line1.isEmpty() ||
|
return line1.isEmpty() || (!line1.equals(uLongName.stripName(player.getName())) && !Permission.has(player, Permission.ADMIN));
|
||||||
(!line1.equals(uLongName.stripName(player.getName())) && !Permission.has(player, Permission.ADMIN));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void dropSign(SignChangeEvent event) {
|
private static void dropSign(SignChangeEvent event) {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.Acrobot.ChestShop.Utils;
|
||||||
|
|
||||||
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 com.palmergames.bukkit.towny.Towny;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
|
|
||||||
|
@ -18,6 +19,8 @@ public class uSign {
|
||||||
Pattern.compile("[\\w :]+")
|
Pattern.compile("[\\w :]+")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static Towny towny; //Moved this here - somehow, java fails at try/catch
|
||||||
|
|
||||||
public static boolean isSign(Block block) {
|
public static boolean isSign(Block block) {
|
||||||
return block.getState() instanceof Sign;
|
return block.getState() instanceof Sign;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,8 @@ package com.Acrobot.ChestShop.Utils;
|
||||||
|
|
||||||
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 com.palmergames.bukkit.towny.Towny;
|
import com.palmergames.bukkit.towny.NotRegisteredException;
|
||||||
import com.palmergames.bukkit.towny.object.TownBlock;
|
|
||||||
import com.palmergames.bukkit.towny.object.TownBlockType;
|
import com.palmergames.bukkit.towny.object.TownBlockType;
|
||||||
import com.palmergames.bukkit.towny.object.TownyPermission;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -14,10 +12,10 @@ import org.bukkit.entity.Player;
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
*/
|
*/
|
||||||
public class uTowny {
|
public class uTowny {
|
||||||
public static Towny towny;
|
|
||||||
|
|
||||||
public static boolean isInsideShopPlot(Location chestlocation, Location signLocation) {
|
public static boolean isInsideShopPlot(Location chestlocation, Location signLocation) {
|
||||||
return towny.getTownyUniverse().getTownBlock(chestlocation).getType() == TownBlockType.COMMERCIAL && 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){
|
||||||
|
@ -25,12 +23,12 @@ public class uTowny {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canBuild(Player player, Location chestLocation, Location signLocation){
|
public static boolean canBuild(Player player, Location chestLocation, Location signLocation){
|
||||||
return towny == null || !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 towny.getTownyUniverse().getTownBlock(location).isOwner(towny.getTownyUniverse().getResident(player.getName()));
|
return uSign.towny.getTownyUniverse().getTownBlock(location).isOwner(uSign.towny.getTownyUniverse().getResident(player.getName()));
|
||||||
} catch (Exception ex){ return false; }
|
} catch (NotRegisteredException ex){ return false; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue