mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-23 00:21:30 +01:00
Made changes to fix events and support the FAWE addon.
This commit is contained in:
parent
9ce1dbf592
commit
475f9b1416
@ -5,15 +5,14 @@ import org.bukkit.event.HandlerList;
|
||||
|
||||
public abstract class PremadeEvent extends Event {
|
||||
|
||||
public static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandleList(){
|
||||
return handlers;
|
||||
}
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,10 @@ package us.tastybento.bskyblock.api.events.island;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.api.events.IslandBaseEvent;
|
||||
import us.tastybento.bskyblock.database.objects.Island;
|
||||
|
||||
@ -149,29 +151,51 @@ public class IslandEvent {
|
||||
public IslandBaseEvent build() {
|
||||
switch (reason) {
|
||||
case CREATE:
|
||||
return new IslandCreateEvent(island, player, admin, location);
|
||||
IslandCreateEvent create = new IslandCreateEvent(island, player, admin, location);
|
||||
BSkyBlock.getInstance().getServer().getPluginManager().callEvent(create);
|
||||
return create;
|
||||
case CREATED:
|
||||
return new IslandCreatedEvent(island, player, admin, location);
|
||||
IslandCreatedEvent created = new IslandCreatedEvent(island, player, admin, location);
|
||||
BSkyBlock.getInstance().getServer().getPluginManager().callEvent(created);
|
||||
return created;
|
||||
case DELETE:
|
||||
return new IslandDeleteEvent(island, player, admin, location);
|
||||
IslandDeleteEvent delete = new IslandDeleteEvent(island, player, admin, location);
|
||||
BSkyBlock.getInstance().getServer().getPluginManager().callEvent(delete);
|
||||
return delete;
|
||||
case DELETED:
|
||||
return new IslandDeletedEvent(island, player, admin, location);
|
||||
IslandDeletedEvent deleted = new IslandDeletedEvent(island, player, admin, location);
|
||||
BSkyBlock.getInstance().getServer().getPluginManager().callEvent(deleted);
|
||||
return deleted;
|
||||
case ENTER:
|
||||
return new IslandEnterEvent(island, player, admin, location);
|
||||
IslandEnterEvent enter = new IslandEnterEvent(island, player, admin, location);
|
||||
BSkyBlock.getInstance().getServer().getPluginManager().callEvent(enter);
|
||||
return enter;
|
||||
case EXIT:
|
||||
return new IslandExitEvent(island, player, admin, location);
|
||||
IslandExitEvent exit = new IslandExitEvent(island, player, admin, location);
|
||||
BSkyBlock.getInstance().getServer().getPluginManager().callEvent(exit);
|
||||
return exit;
|
||||
case LOCK:
|
||||
return new IslandLockEvent(island, player, admin, location);
|
||||
IslandLockEvent lock = new IslandLockEvent(island, player, admin, location);
|
||||
BSkyBlock.getInstance().getServer().getPluginManager().callEvent(lock);
|
||||
return lock;
|
||||
case RESET:
|
||||
return new IslandResetEvent(island, player, admin, location);
|
||||
IslandResetEvent reset = new IslandResetEvent(island, player, admin, location);
|
||||
BSkyBlock.getInstance().getServer().getPluginManager().callEvent(reset);
|
||||
return reset;
|
||||
case RESETTED:
|
||||
return new IslandResettedEvent(island, player, admin, location);
|
||||
IslandResettedEvent resetted = new IslandResettedEvent(island, player, admin, location);
|
||||
BSkyBlock.getInstance().getServer().getPluginManager().callEvent(resetted);
|
||||
return resetted;
|
||||
case UNLOCK:
|
||||
return new IslandUnlockEvent(island, player, admin, location);
|
||||
IslandUnlockEvent unlock = new IslandUnlockEvent(island, player, admin, location);
|
||||
BSkyBlock.getInstance().getServer().getPluginManager().callEvent(unlock);
|
||||
return unlock;
|
||||
default:
|
||||
return new IslandGeneralEvent(island, player, admin, location);
|
||||
|
||||
IslandGeneralEvent general = new IslandGeneralEvent(island, player, admin, location);
|
||||
BSkyBlock.getInstance().getServer().getPluginManager().callEvent(general);
|
||||
return general;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import us.tastybento.bskyblock.island.builders.IslandBuilder.IslandType;
|
||||
*
|
||||
*/
|
||||
public class NewIsland {
|
||||
private static final boolean DEBUG = false;
|
||||
private static final boolean DEBUG = true;
|
||||
private BSkyBlock plugin;
|
||||
private Island island;
|
||||
private final Player player;
|
||||
@ -123,13 +123,16 @@ public class NewIsland {
|
||||
plugin.getPlayers().setHomeLocation(playerUUID, next, 1);
|
||||
|
||||
// Fire event
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: firing event");
|
||||
IslandBaseEvent event = IslandEvent.builder()
|
||||
.involvedPlayer(player.getUniqueId())
|
||||
.reason(reason)
|
||||
.island(island)
|
||||
.location(island.getCenter())
|
||||
.build();
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: event cancelled status = " + event.isCancelled());
|
||||
if (!event.isCancelled()) {
|
||||
// Create island
|
||||
new IslandBuilder(plugin, island)
|
||||
@ -151,28 +154,27 @@ public class NewIsland {
|
||||
.setType(IslandType.END)
|
||||
.build();
|
||||
}
|
||||
// Teleport player to their island
|
||||
plugin.getIslands().homeTeleport(player);
|
||||
// Fire exit event
|
||||
Reason reasonDone = Reason.CREATED;
|
||||
switch (reason) {
|
||||
case CREATE:
|
||||
reasonDone = Reason.CREATED;
|
||||
break;
|
||||
case RESET:
|
||||
reasonDone = Reason.RESETTED;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
event = IslandEvent.builder()
|
||||
.involvedPlayer(player.getUniqueId())
|
||||
.reason(reasonDone)
|
||||
.island(island)
|
||||
.location(island.getCenter())
|
||||
.build();
|
||||
}
|
||||
// Teleport player to their island
|
||||
plugin.getIslands().homeTeleport(player);
|
||||
// Fire exit event
|
||||
Reason reasonDone = Reason.CREATED;
|
||||
switch (reason) {
|
||||
case CREATE:
|
||||
reasonDone = Reason.CREATED;
|
||||
break;
|
||||
case RESET:
|
||||
reasonDone = Reason.RESETTED;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
event = IslandEvent.builder()
|
||||
.involvedPlayer(player.getUniqueId())
|
||||
.reason(reasonDone)
|
||||
.island(island)
|
||||
.location(island.getCenter())
|
||||
.build();
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -444,16 +444,12 @@ public class Island implements DataObject {
|
||||
if(locked){
|
||||
// Lock the island
|
||||
IslandBaseEvent event = IslandEvent.builder().island(this).reason(Reason.LOCK).build();
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if(!event.isCancelled()){
|
||||
this.locked = locked;
|
||||
}
|
||||
} else {
|
||||
// Unlock the island
|
||||
IslandBaseEvent event = IslandEvent.builder().island(this).reason(Reason.UNLOCK).build();
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if(!event.isCancelled()){
|
||||
this.locked = locked;
|
||||
}
|
||||
|
@ -481,8 +481,8 @@ public class IslandBuilder {
|
||||
if (this.playerUUID != null) {
|
||||
Sign sign = (Sign) blockToChange.getState();
|
||||
User user = User.getInstance(playerUUID);
|
||||
for (int i = 1; i < 5; i++) {
|
||||
sign.setLine(i, user.getTranslation("new-island.sign.line" + i, "[player]", playerName));
|
||||
for (int i = 0; i < 4; i++) {
|
||||
sign.setLine(i, user.getTranslation("new-island.sign.line" + (i+1), "[player]", playerName));
|
||||
}
|
||||
((org.bukkit.material.Sign) sign.getData()).setFacingDirection(BlockFace.NORTH);
|
||||
sign.update();
|
||||
|
@ -27,7 +27,6 @@ public class DeleteIslandChunks {
|
||||
//plugin.getLogger().info("DEBUG: deleting the island");
|
||||
// Fire event
|
||||
IslandBaseEvent event = IslandEvent.builder().island(island).reason(Reason.DELETE).build();
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
final World world = island.getCenter().getWorld();
|
||||
@ -50,8 +49,7 @@ public class DeleteIslandChunks {
|
||||
}
|
||||
}
|
||||
// Fire event
|
||||
IslandBaseEvent event1 = IslandEvent.builder().island(island).reason(Reason.DELETED).build();
|
||||
plugin.getServer().getPluginManager().callEvent(event1);
|
||||
IslandEvent.builder().island(island).reason(Reason.DELETED).build();
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user