There is the possibility this will cause issues with sponge

Signed-off-by: MattBDev <mattbdev@outlook.com>
This commit is contained in:
MattBDev 2016-09-14 19:27:30 -04:00
parent 8e7e5dcb25
commit a4363bdb27

View File

@ -103,7 +103,7 @@ public class MainListener {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@Listener @Listener
public void onChat(MessageEvent event) { public void onChat(MessageEvent event) {
// TODO // TODO
@ -126,7 +126,7 @@ public class MainListener {
return; return;
} }
Text message = event.getMessage(); Text message = event.getMessage();
// TODO use display name rather than username // TODO use display name rather than username
// - Getting displayname currently causes NPE, so wait until sponge fixes that // - Getting displayname currently causes NPE, so wait until sponge fixes that
@ -160,7 +160,7 @@ public class MainListener {
} }
//event.setMessage(null); //event.setMessage(null);
} }
@Listener @Listener
public void onBreedEntity(BreedEntityEvent.Breed event) { public void onBreedEntity(BreedEntityEvent.Breed event) {
Location loc = SpongeUtil.getLocation(event.getTargetEntity()); Location loc = SpongeUtil.getLocation(event.getTargetEntity());
@ -364,7 +364,7 @@ public class MainListener {
return; return;
} }
} }
@Listener @Listener
public void onExplosion(ExplosionEvent e) { public void onExplosion(ExplosionEvent e) {
if (e instanceof ExplosionEvent.Detonate) { if (e instanceof ExplosionEvent.Detonate) {
@ -376,7 +376,7 @@ public class MainListener {
} }
Optional<Explosive> source = event.getExplosion().getSourceExplosive(); Optional<Explosive> source = event.getExplosion().getSourceExplosive();
if (!source.isPresent()) { if (!source.isPresent()) {
event.filterAll(); event.setCancelled(true);
return; return;
} }
Explosive tnt = source.get(); Explosive tnt = source.get();
@ -385,25 +385,26 @@ public class MainListener {
Plot currentPlot = current.getPlot(); Plot currentPlot = current.getPlot();
if (currentPlot == null) { if (currentPlot == null) {
if (current.isPlotArea()) { if (current.isPlotArea()) {
event.filterAll(); event.setCancelled(true);
} }
return; return;
} }
if (creator != null) { if (creator != null) {
if (!currentPlot.isAdded(creator)) { if (!currentPlot.isAdded(creator)) {
event.filterAll(); event.setCancelled(true);
return; return;
} }
} }
if (!currentPlot.getFlag(Flags.EXPLOSION).or(false)) { if (!currentPlot.getFlag(Flags.EXPLOSION).or(false)) {
event.filterAll(); event.setCancelled(true);
return; return;
} }
event.filter(loc -> currentPlot.equals(SpongeUtil.getLocation(loc.getExtent().getName(), loc).getPlot()));
event.getAffectedLocations().removeIf(worldLocation -> currentPlot.equals(SpongeUtil.getLocation(worldLocation.getExtent().getName(), worldLocation).getPlot()));
event.filterEntities(entity -> currentPlot.equals(SpongeUtil.getLocation(entity).getPlot())); event.filterEntities(entity -> currentPlot.equals(SpongeUtil.getLocation(entity).getPlot()));
} }
} }
public void onChangeBlock(ChangeBlockEvent event) { public void onChangeBlock(ChangeBlockEvent event) {
World world = event.getTargetWorld(); World world = event.getTargetWorld();
String worldName = world.getName(); String worldName = world.getName();
@ -428,17 +429,17 @@ public class MainListener {
public void onBlockBreak(ChangeBlockEvent.Decay event) { public void onBlockBreak(ChangeBlockEvent.Decay event) {
onChangeBlock(event); onChangeBlock(event);
} }
@Listener @Listener
public void onBlockBreak(ChangeBlockEvent.Grow event) { public void onBlockBreak(ChangeBlockEvent.Grow event) {
onChangeBlock(event); onChangeBlock(event);
} }
@Listener @Listener
public void onBlockBreak(ChangeBlockEvent.Modify event) { public void onBlockBreak(ChangeBlockEvent.Modify event) {
onChangeBlock(event); onChangeBlock(event);
} }
@Listener @Listener
public void onBlockBreak(ChangeBlockEvent.Break event) { public void onBlockBreak(ChangeBlockEvent.Break event) {
Player player = SpongeUtil.getCause(event.getCause(), Player.class); Player player = SpongeUtil.getCause(event.getCause(), Player.class);
@ -512,7 +513,7 @@ public class MainListener {
} }
}); });
} }
@Listener @Listener
public void onBlockPlace(ChangeBlockEvent.Place event) { public void onBlockPlace(ChangeBlockEvent.Place event) {
Player player = SpongeUtil.getCause(event.getCause(), Player.class); Player player = SpongeUtil.getCause(event.getCause(), Player.class);
@ -591,7 +592,7 @@ public class MainListener {
} }
}); });
} }
@Listener @Listener
public void onJoin(ClientConnectionEvent.Join event) { public void onJoin(ClientConnectionEvent.Join event) {
Player player = event.getTargetEntity(); Player player = event.getTargetEntity();
@ -619,14 +620,14 @@ public class MainListener {
// Async // Async
TaskManager.runTaskLaterAsync(() -> EventUtil.manager.doJoinTask(pp), 20); TaskManager.runTaskLaterAsync(() -> EventUtil.manager.doJoinTask(pp), 20);
} }
@Listener @Listener
public void onQuit(ClientConnectionEvent.Disconnect event) { public void onQuit(ClientConnectionEvent.Disconnect event) {
Player player = event.getTargetEntity(); Player player = event.getTargetEntity();
PlotPlayer pp = SpongeUtil.getPlayer(player); PlotPlayer pp = SpongeUtil.getPlayer(player);
pp.unregister(); pp.unregister();
} }
@Listener @Listener
public void onMove(MoveEntityEvent event) { public void onMove(MoveEntityEvent event) {
if (!(event.getTargetEntity() instanceof Player)) { if (!(event.getTargetEntity() instanceof Player)) {