We should fix up the event system

Some of it is my fault. Half the events don't get called properly, or
aren't cancellable when they say they are.

Tell me your ideas for how we should sort out this mess.
This commit is contained in:
boy0001 2014-10-02 22:54:49 +10:00
parent 560921ebc5
commit aa81704f80
4 changed files with 78 additions and 4 deletions

View File

@ -2,6 +2,8 @@ package com.intellectualcrafters.plot;
import static com.intellectualcrafters.plot.ReflectionUtils.getRefClass; import static com.intellectualcrafters.plot.ReflectionUtils.getRefClass;
import org.bukkit.Bukkit;
import com.intellectualcrafters.plot.ReflectionUtils.RefClass; import com.intellectualcrafters.plot.ReflectionUtils.RefClass;
import com.intellectualcrafters.plot.ReflectionUtils.RefMethod; import com.intellectualcrafters.plot.ReflectionUtils.RefMethod;
@ -40,8 +42,9 @@ public class SetBlockFast {
} }
public static void update(org.bukkit.entity.Player player) { public static void update(org.bukkit.entity.Player player) {
for (int cx = -8; cx < 8; cx++) { int distance = Bukkit.getViewDistance()+1;
for (int cz = -8; cz < 8; cz++) { for (int cx = -distance; cx < distance; cx++) {
for (int cz = -distance; cz < distance; cz++) {
player.getWorld().refreshChunk(player.getLocation().getChunk().getX() + cx, player.getLocation().getChunk().getZ() + cz); player.getWorld().refreshChunk(player.getLocation().getChunk().getX() + cx, player.getLocation().getChunk().getZ() + cz);
} }
} }

View File

@ -0,0 +1,71 @@
/*
* Copyright (c) IntellectualCrafters - 2014.
* You are not allowed to distribute and/or monetize any of our intellectual property.
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
*
* >> File = PlotClearEvent.java
* >> Generated by: Citymonstret at 2014-08-09 15:21
*/
package com.intellectualcrafters.plot.events;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import com.intellectualcrafters.plot.PlotId;
/**
* Called when a plot is cleared
*/
public class PlotClearEvent extends Event implements Cancellable {
private static HandlerList handlers = new HandlerList();
private boolean cancelled;
private PlotId id;
private String world;
/**
* PlotDeleteEvent: Called when a plot is cleared
* @param world
* @param id
*/
public PlotClearEvent(String world, PlotId id) {
this.id = id;
this.world = world;
}
/**
* Get the PlotId
* @return PlotId
*/
public PlotId getPlotId() {
return this.id;
}
/**
* Get the world name
* @return String
*/
public String getWorld() {
return this.world;
}
public static HandlerList getHandlerList() {
return handlers;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
@Override
public boolean isCancelled() {
return this.cancelled;
}
@Override
public void setCancelled(boolean b) {
this.cancelled = b;
}
}

View File

@ -3,7 +3,7 @@
* You are not allowed to distribute and/or monetize any of our intellectual property. * You are not allowed to distribute and/or monetize any of our intellectual property.
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = PlayerClaimPlotEvent.java * >> File = PlotDeleteEvent.java
* >> Generated by: Citymonstret at 2014-08-09 15:21 * >> Generated by: Citymonstret at 2014-08-09 15:21
*/ */

View File

@ -57,7 +57,7 @@ public class WorldEditListener implements Listener {
} }
Plot plot = PlotHelper.getCurrentPlot(b.getLocation()); Plot plot = PlotHelper.getCurrentPlot(b.getLocation());
if (plot != null) { if (plot != null) {
if ((plot != null) && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) { if ((plot != null) && plot.hasOwner() && plot.helpers!=null && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) {
PWE.setMask(p, l); PWE.setMask(p, l);
} }
} }