Various fixes + pick block restriction

Block picking in other plots will now limit block contents ( @xion87 you
may be interested in this)

Fixes
- Cluster regeneration
- world creation + cauldron
- armor stand interaction in 1.8.0/1
This commit is contained in:
boy0001 2015-05-14 01:49:57 +10:00
parent 94fa119813
commit 710b62fbf5
7 changed files with 172 additions and 41 deletions

View File

@ -8,7 +8,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<artifactId>PlotSquared</artifactId> <artifactId>PlotSquared</artifactId>
<version>2.10.9</version> <version>2.10.10</version>
<name>PlotSquared</name> <name>PlotSquared</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<build> <build>

View File

@ -89,6 +89,7 @@ import com.intellectualcrafters.plot.listeners.ForceFieldListener;
import com.intellectualcrafters.plot.listeners.InventoryListener; import com.intellectualcrafters.plot.listeners.InventoryListener;
import com.intellectualcrafters.plot.listeners.PlayerEvents; import com.intellectualcrafters.plot.listeners.PlayerEvents;
import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8; import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8;
import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8_3;
import com.intellectualcrafters.plot.listeners.PlotListener; import com.intellectualcrafters.plot.listeners.PlotListener;
import com.intellectualcrafters.plot.listeners.PlotPlusListener; import com.intellectualcrafters.plot.listeners.PlotPlusListener;
import com.intellectualcrafters.plot.listeners.TNTListener; import com.intellectualcrafters.plot.listeners.TNTListener;
@ -346,6 +347,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
if (checkVersion(1, 8, 0)) { if (checkVersion(1, 8, 0)) {
getServer().getPluginManager().registerEvents(new PlayerEvents_1_8(), this); getServer().getPluginManager().registerEvents(new PlayerEvents_1_8(), this);
} }
if (checkVersion(1, 8, 3)) {
getServer().getPluginManager().registerEvents(new PlayerEvents_1_8_3(), this);
}
} }
@Override @Override

View File

@ -28,11 +28,13 @@ import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.generator.AugmentedPopulator; import com.intellectualcrafters.plot.generator.AugmentedPopulator;
import com.intellectualcrafters.plot.generator.HybridGen;
import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotCluster;
import com.intellectualcrafters.plot.object.PlotClusterId; import com.intellectualcrafters.plot.object.PlotClusterId;
import com.intellectualcrafters.plot.object.PlotGenerator;
import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.PlotWorld;
@ -134,10 +136,21 @@ public class Cluster extends SubCommand {
DBFunc.setInvited(world, cluster, plot.owner); DBFunc.setInvited(world, cluster, plot.owner);
} }
} }
if (!PlotSquared.isPlotWorld(world)) { PlotWorld plotworld = PlotSquared.getPlotWorld(world);
if (plotworld == null) {
PlotSquared.config.createSection("worlds." + world); PlotSquared.config.createSection("worlds." + world);
PlotSquared.loadWorld(world, null); PlotSquared.loadWorld(world, null);
} }
else {
final String gen_string = PlotSquared.config.getString("worlds." + world + "." + "generator.plugin");
PlotGenerator generator;
if (gen_string == null) {
generator = new HybridGen(world);
} else {
generator = (PlotGenerator) PlotSquared.IMP.getGenerator(world, gen_string);
}
new AugmentedPopulator(world, generator, cluster, plotworld.TERRAIN == 2, plotworld.TERRAIN != 2);
}
MainUtil.sendMessage(plr, C.CLUSTER_ADDED); MainUtil.sendMessage(plr, C.CLUSTER_ADDED);
return true; return true;
} }
@ -189,8 +202,6 @@ public class Cluster extends SubCommand {
if (plotworld.TYPE == 2) { if (plotworld.TYPE == 2) {
AugmentedPopulator.removePopulator(plr.getLocation().getWorld(), cluster); AugmentedPopulator.removePopulator(plr.getLocation().getWorld(), cluster);
} }
for (final String set : ClusterManager.clusters.keySet()) {
}
ClusterManager.last = null; ClusterManager.last = null;
ClusterManager.clusters.get(cluster.world).remove(cluster); ClusterManager.clusters.get(cluster.world).remove(cluster);
ClusterManager.regenCluster(cluster); ClusterManager.regenCluster(cluster);

View File

@ -83,6 +83,9 @@ public class HybridGen extends PlotGenerator {
* Initialize variables, and create plotworld object used in calculations * Initialize variables, and create plotworld object used in calculations
*/ */
public void init(PlotWorld plotworld) { public void init(PlotWorld plotworld) {
if (plotworld != null) {
this.plotworld = (HybridPlotWorld) plotworld;
}
this.plotsize = this.plotworld.PLOT_WIDTH; this.plotsize = this.plotworld.PLOT_WIDTH;
this.pathsize = this.plotworld.ROAD_WIDTH; this.pathsize = this.plotworld.ROAD_WIDTH;
this.roadblock = this.plotworld.ROAD_BLOCK.id; this.roadblock = this.plotworld.ROAD_BLOCK.id;

View File

@ -1,16 +1,28 @@
package com.intellectualcrafters.plot.listeners; package com.intellectualcrafters.plot.listeners;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import org.apache.commons.lang.StringUtils;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockExplodeEvent; import org.bukkit.event.block.BlockExplodeEvent;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType.SlotType;
import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;
import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
@ -24,6 +36,91 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
public class PlayerEvents_1_8 extends PlotListener implements Listener { public class PlayerEvents_1_8 extends PlotListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInventoryClick(InventoryClickEvent event) {
if (!event.isLeftClick() || event.getAction() != InventoryAction.PLACE_ALL || event.isShiftClick()) {
return;
}
HumanEntity entity = event.getWhoClicked();
if (!(entity instanceof Player) || !PlotSquared.isPlotWorld(entity.getWorld().getName())) {
return;
}
Player player = (Player) entity;
PlayerInventory inv = player.getInventory();
int slot = inv.getHeldItemSlot();
if (slot != event.getSlot() || slot > 8 || !event.getEventName().equals("InventoryCreativeEvent")) {
return;
}
ItemStack current = inv.getItemInHand();
ItemStack newItem = event.getCursor();
ItemMeta newMeta = newItem.getItemMeta();
ItemMeta oldMeta = newItem.getItemMeta();
String newLore = "";
if (newMeta != null) {
List<String> lore = newMeta.getLore();
if (lore != null) {
newLore = lore.toString();
}
}
String oldLore = "";
if (oldMeta != null) {
List<String> lore = oldMeta.getLore();
if (lore != null) {
oldLore = lore.toString();
}
}
if (!newLore.equals("[(+NBT)]") || (current.equals(newItem) && newLore.equals(oldLore))) {
return;
}
HashSet<Byte> blocks = null;
Block block = player.getTargetBlock(blocks, 7);
BlockState state = block.getState();
if (state == null) {
return;
}
if (state.getType() != newItem.getType()) {
return;
}
final Location l = BukkitUtil.getLocation(state.getLocation());
Plot plot = MainUtil.getPlot(l);
PlotPlayer pp = BukkitUtil.getPlayer(player);
boolean cancelled = false;
if (plot == null) {
if (!MainUtil.isPlotArea(l)) {
return;
}
if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road");
cancelled = true;
}
}
else {
if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.unowned");
cancelled = true;
}
}
else {
final UUID uuid = pp.getUUID();
if (!plot.isAdded(uuid)) {
if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.other");
cancelled = true;
}
}
}
}
if (cancelled) {
if (current.getTypeId() == newItem.getTypeId() && current.getDurability() == newItem.getDurability()) {
event.setCursor(new ItemStack(newItem.getTypeId(), newItem.getAmount(), newItem.getDurability()));
event.setCancelled(true);
return;
}
event.setCursor(new ItemStack(newItem.getTypeId(), newItem.getAmount(), newItem.getDurability()));
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInteract(final PlayerInteractAtEntityEvent e) { public void onInteract(final PlayerInteractAtEntityEvent e) {
Entity entity = e.getRightClicked(); Entity entity = e.getRightClicked();
@ -64,38 +161,4 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener {
} }
} }
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBigBoom(final BlockExplodeEvent event) {
Block block = event.getBlock();
Location loc = BukkitUtil.getLocation(block.getLocation());
final String world = loc.getWorld();
if (!PlotSquared.isPlotWorld(world)) {
return;
}
final Plot plot = MainUtil.getPlot(loc);
if ((plot != null) && plot.hasOwner()) {
if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
final Iterator<Block> iter = event.blockList().iterator();
while (iter.hasNext()) {
final Block b = iter.next();
if (!plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(b.getLocation())))) {
iter.remove();
}
}
return;
}
}
if (MainUtil.isPlotArea(loc)) {
event.setCancelled(true);
} else {
final Iterator<Block> iter = event.blockList().iterator();
while (iter.hasNext()) {
iter.next();
if (MainUtil.isPlotArea(loc)) {
iter.remove();
}
}
}
}
} }

View File

@ -0,0 +1,52 @@
package com.intellectualcrafters.plot.listeners;
import java.util.Iterator;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockExplodeEvent;
import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
public class PlayerEvents_1_8_3 implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBigBoom(final BlockExplodeEvent event) {
Block block = event.getBlock();
Location loc = BukkitUtil.getLocation(block.getLocation());
final String world = loc.getWorld();
if (!PlotSquared.isPlotWorld(world)) {
return;
}
final Plot plot = MainUtil.getPlot(loc);
if ((plot != null) && plot.hasOwner()) {
if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
final Iterator<Block> iter = event.blockList().iterator();
while (iter.hasNext()) {
final Block b = iter.next();
if (!plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(b.getLocation())))) {
iter.remove();
}
}
return;
}
}
if (MainUtil.isPlotArea(loc)) {
event.setCancelled(true);
} else {
final Iterator<Block> iter = event.blockList().iterator();
while (iter.hasNext()) {
iter.next();
if (MainUtil.isPlotArea(loc)) {
iter.remove();
}
}
}
}
}

View File

@ -112,6 +112,7 @@ public class UUIDHandler {
} }
PlotSquared.log(C.PREFIX.s() + "&6Starting player data caching: " + world); PlotSquared.log(C.PREFIX.s() + "&6Starting player data caching: " + world);
UUIDHandler.CACHED = true; UUIDHandler.CACHED = true;
add(new StringWrapper("*"), DBFunc.everyone);
if (Settings.TWIN_MODE_UUID) { if (Settings.TWIN_MODE_UUID) {
HashSet<UUID> all = getAllUUIDS(); HashSet<UUID> all = getAllUUIDS();
final File playerdataFolder = new File(Bukkit.getWorldContainer(), world + File.separator + "playerdata"); final File playerdataFolder = new File(Bukkit.getWorldContainer(), world + File.separator + "playerdata");
@ -136,7 +137,6 @@ public class UUIDHandler {
} }
} }
} }
add(new StringWrapper("*"), DBFunc.everyone);
PlotSquared.log(C.PREFIX.s() + "&6Cached a total of: " + UUIDHandler.uuidMap.size() + " UUIDs"); PlotSquared.log(C.PREFIX.s() + "&6Cached a total of: " + UUIDHandler.uuidMap.size() + " UUIDs");
return; return;
} }
@ -207,8 +207,6 @@ public class UUIDHandler {
} }
} }
} }
// add the Everyone '*' UUID
add(new StringWrapper("*"), DBFunc.everyone);
PlotSquared.log(C.PREFIX.s() + "&6Cached a total of: " + UUIDHandler.uuidMap.size() + " UUIDs"); PlotSquared.log(C.PREFIX.s() + "&6Cached a total of: " + UUIDHandler.uuidMap.size() + " UUIDs");
} }