Skip to content

Commit

Permalink
[CI SKIP] Reordered the methods in the events bus
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Apr 23, 2022
1 parent 69cb451 commit fb1d57f
Showing 1 changed file with 98 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,42 +57,40 @@ public EventsBus(SuperiorSkyblockPlugin plugin) {
this.plugin = plugin;
}

public boolean callIslandEnterEvent(SuperiorPlayer superiorPlayer, Island island, IslandEnterEvent.EnterCause enterCause) {
if (plugin.getSettings().getDisabledEvents().contains("islandenterevent"))
public boolean callBlockStackEvent(Block block, Player player, int originalAmount, int newAmount) {
if (plugin.getSettings().getDisabledEvents().contains("blockstackevent"))
return true;

IslandEnterEvent islandEnterEvent = callEvent(new IslandEnterEvent(superiorPlayer, island, enterCause));

if (islandEnterEvent.isCancelled() && islandEnterEvent.getCancelTeleport() != null)
superiorPlayer.teleport(islandEnterEvent.getCancelTeleport());

return !islandEnterEvent.isCancelled();
return !callEvent(new BlockStackEvent(block, player, originalAmount, newAmount)).isCancelled();
}

public boolean callIslandEnterProtectedEvent(SuperiorPlayer superiorPlayer, Island island, IslandEnterEvent.EnterCause enterCause) {
if (plugin.getSettings().getDisabledEvents().contains("islandenterprotectedevent"))
public boolean callBlockUnstackEvent(Block block, Player player, int originalAmount, int newAmount) {
if (plugin.getSettings().getDisabledEvents().contains("blockunstackevent"))
return true;

IslandEnterProtectedEvent islandEnterProtectedEvent = callEvent(new IslandEnterProtectedEvent(superiorPlayer, island, enterCause));

if (islandEnterProtectedEvent.isCancelled() && islandEnterProtectedEvent.getCancelTeleport() != null)
superiorPlayer.teleport(islandEnterProtectedEvent.getCancelTeleport());
return !callEvent(new BlockUnstackEvent(block, player, originalAmount, newAmount)).isCancelled();
}

return !islandEnterProtectedEvent.isCancelled();
public void callIslandBanEvent(SuperiorPlayer superiorPlayer, SuperiorPlayer targetPlayer, Island island) {
if (!plugin.getSettings().getDisabledEvents().contains("islandbanevent")) {
callEvent(new IslandBanEvent(superiorPlayer, targetPlayer, island));
}
}

public boolean callIslandLeaveEvent(SuperiorPlayer superiorPlayer, Island island, IslandLeaveEvent.LeaveCause leaveCause, Location location) {
if (plugin.getSettings().getDisabledEvents().contains("islandleaveevent"))
return true;
public EventResult<String> callIslandBankDepositEvent(SuperiorPlayer superiorPlayer, Island island, BigDecimal amount) {
if (plugin.getSettings().getDisabledEvents().contains("islandbankdepositevent"))
return EventResult.of(false, null);

return !callEvent(new IslandLeaveEvent(superiorPlayer, island, leaveCause, location)).isCancelled();
IslandBankDepositEvent islandBankDepositEvent = callEvent(new IslandBankDepositEvent(superiorPlayer, island, amount));
return EventResult.of(islandBankDepositEvent.isCancelled(), islandBankDepositEvent.getFailureReason());
}

public boolean callIslandLeaveProtectedEvent(SuperiorPlayer superiorPlayer, Island island, IslandLeaveEvent.LeaveCause leaveCause, Location location) {
if (plugin.getSettings().getDisabledEvents().contains("islandleaveprotectedevent"))
return true;
public EventResult<String> callIslandBankWithdrawEvent(SuperiorPlayer superiorPlayer, Island island, BigDecimal amount) {
if (plugin.getSettings().getDisabledEvents().contains("islandbankwithdrawevent"))
return EventResult.of(false, null);

return !callEvent(new IslandLeaveProtectedEvent(superiorPlayer, island, leaveCause, location)).isCancelled();
IslandBankWithdrawEvent islandBankWithdrawEvent = callEvent(new IslandBankWithdrawEvent(superiorPlayer, island, amount));
return EventResult.of(islandBankWithdrawEvent.isCancelled(), islandBankWithdrawEvent.getFailureReason());
}

public EventResult<Biome> callIslandBiomeChangeEvent(SuperiorPlayer superiorPlayer, Island island, Biome biome) {
Expand All @@ -103,6 +101,28 @@ public EventResult<Biome> callIslandBiomeChangeEvent(SuperiorPlayer superiorPlay
return EventResult.of(islandBiomeChangeEvent.isCancelled(), islandBiomeChangeEvent.getBiome());
}

public EventResult<String> callIslandChatEvent(Island island, SuperiorPlayer superiorPlayer, String message) {
if (plugin.getSettings().getDisabledEvents().contains("islandchatevent"))
return EventResult.of(false, message);

IslandChatEvent islandChatEvent = callEvent(new IslandChatEvent(island, superiorPlayer, message));
return EventResult.of(islandChatEvent.isCancelled(), message);
}

public void callIslandChunkResetEvent(Island island, ChunkPosition chunkPosition) {
if (plugin.getSettings().getDisabledEvents().contains("islandchunkresetevent"))
return;

callEvent(new IslandChunkResetEvent(island, chunkPosition.getWorld(), chunkPosition.getX(), chunkPosition.getZ()));
}

public boolean callIslandCoopPlayerEvent(Island island, SuperiorPlayer player, SuperiorPlayer target) {
if (plugin.getSettings().getDisabledEvents().contains("islandcoopplayerevent"))
return true;

return !callEvent(new IslandCoopPlayerEvent(island, player, target)).isCancelled();
}

public EventResult<Boolean> callIslandCreateEvent(SuperiorPlayer superiorPlayer, Island island, String schemName) {
if (plugin.getSettings().getDisabledEvents().contains("islandcreateevent"))
return EventResult.of(false, true);
Expand All @@ -118,6 +138,30 @@ public boolean callIslandDisbandEvent(SuperiorPlayer superiorPlayer, Island isla
return !callEvent(new IslandDisbandEvent(superiorPlayer, island)).isCancelled();
}

public boolean callIslandEnterEvent(SuperiorPlayer superiorPlayer, Island island, IslandEnterEvent.EnterCause enterCause) {
if (plugin.getSettings().getDisabledEvents().contains("islandenterevent"))
return true;

IslandEnterEvent islandEnterEvent = callEvent(new IslandEnterEvent(superiorPlayer, island, enterCause));

if (islandEnterEvent.isCancelled() && islandEnterEvent.getCancelTeleport() != null)
superiorPlayer.teleport(islandEnterEvent.getCancelTeleport());

return !islandEnterEvent.isCancelled();
}

public boolean callIslandEnterProtectedEvent(SuperiorPlayer superiorPlayer, Island island, IslandEnterEvent.EnterCause enterCause) {
if (plugin.getSettings().getDisabledEvents().contains("islandenterprotectedevent"))
return true;

IslandEnterProtectedEvent islandEnterProtectedEvent = callEvent(new IslandEnterProtectedEvent(superiorPlayer, island, enterCause));

if (islandEnterProtectedEvent.isCancelled() && islandEnterProtectedEvent.getCancelTeleport() != null)
superiorPlayer.teleport(islandEnterProtectedEvent.getCancelTeleport());

return !islandEnterProtectedEvent.isCancelled();
}

public boolean callIslandInviteEvent(SuperiorPlayer superiorPlayer, SuperiorPlayer targetPlayer, Island island) {
if (plugin.getSettings().getDisabledEvents().contains("islandinviteevent"))
return true;
Expand All @@ -139,10 +183,18 @@ public void callIslandKickEvent(SuperiorPlayer superiorPlayer, SuperiorPlayer ta
}
}

public void callIslandBanEvent(SuperiorPlayer superiorPlayer, SuperiorPlayer targetPlayer, Island island) {
if (!plugin.getSettings().getDisabledEvents().contains("islandbanevent")) {
callEvent(new IslandBanEvent(superiorPlayer, targetPlayer, island));
}
public boolean callIslandLeaveEvent(SuperiorPlayer superiorPlayer, Island island, IslandLeaveEvent.LeaveCause leaveCause, Location location) {
if (plugin.getSettings().getDisabledEvents().contains("islandleaveevent"))
return true;

return !callEvent(new IslandLeaveEvent(superiorPlayer, island, leaveCause, location)).isCancelled();
}

public boolean callIslandLeaveProtectedEvent(SuperiorPlayer superiorPlayer, Island island, IslandLeaveEvent.LeaveCause leaveCause, Location location) {
if (plugin.getSettings().getDisabledEvents().contains("islandleaveprotectedevent"))
return true;

return !callEvent(new IslandLeaveProtectedEvent(superiorPlayer, island, leaveCause, location)).isCancelled();
}

public boolean callIslandQuitEvent(SuperiorPlayer superiorPlayer, Island island) {
Expand All @@ -152,6 +204,12 @@ public boolean callIslandQuitEvent(SuperiorPlayer superiorPlayer, Island island)
return !callEvent(new IslandQuitEvent(superiorPlayer, island)).isCancelled();
}

public void callIslandRestrictMoveEvent(SuperiorPlayer superiorPlayer, IslandRestrictMoveEvent.RestrictReason restrictReason) {
if (!plugin.getSettings().getDisabledEvents().contains("islandrestrictmoveevent")) {
callEvent(new IslandRestrictMoveEvent(superiorPlayer, restrictReason));
}
}

public void callIslandSchematicPasteEvent(Island island, String name, Location location) {
if (!plugin.getSettings().getDisabledEvents().contains("islandschematicpasteevent")) {
callEvent(new IslandSchematicPasteEvent(island, name, location));
Expand All @@ -165,6 +223,14 @@ public boolean callIslandTransferEvent(Island island, SuperiorPlayer previousOwn
return !callEvent(new IslandTransferEvent(island, previousOwner, superiorPlayer)).isCancelled();
}

public boolean callIslandUncoopPlayerEvent(Island island, SuperiorPlayer player, SuperiorPlayer target,
IslandUncoopPlayerEvent.UncoopReason uncoopReason) {
if (plugin.getSettings().getDisabledEvents().contains("islanduncoopplayerevent"))
return true;

return !callEvent(new IslandUncoopPlayerEvent(island, player, target, uncoopReason)).isCancelled();
}

public EventResult<UpgradeResult> callIslandUpgradeEvent(SuperiorPlayer superiorPlayer, Island island, String upgradeName, List<String> commands, UpgradeCost cost) {
if (plugin.getSettings().getDisabledEvents().contains("islandupgradeevent"))
return EventResult.of(false, new UpgradeResult(commands, cost));
Expand Down Expand Up @@ -197,85 +263,19 @@ public EventResult<MissionRewards> callMissionCompleteEvent(SuperiorPlayer super
MissionRewards.of(missionCompleteEvent.getItemRewards(), missionCompleteEvent.getCommandRewards()));
}

public boolean callPreIslandCreateEvent(SuperiorPlayer superiorPlayer, String islandName) {
if (plugin.getSettings().getDisabledEvents().contains("preislandcreateevent"))
return true;

return !callEvent(new PreIslandCreateEvent(superiorPlayer, islandName)).isCancelled();
}

public boolean callBlockStackEvent(Block block, Player player, int originalAmount, int newAmount) {
if (plugin.getSettings().getDisabledEvents().contains("blockstackevent"))
return true;

return !callEvent(new BlockStackEvent(block, player, originalAmount, newAmount)).isCancelled();
}

public boolean callBlockUnstackEvent(Block block, Player player, int originalAmount, int newAmount) {
if (plugin.getSettings().getDisabledEvents().contains("blockunstackevent"))
return true;

return !callEvent(new BlockUnstackEvent(block, player, originalAmount, newAmount)).isCancelled();
}

public EventResult<String> callIslandBankDepositEvent(SuperiorPlayer superiorPlayer, Island island, BigDecimal amount) {
if (plugin.getSettings().getDisabledEvents().contains("islandbankdepositevent"))
return EventResult.of(false, null);

IslandBankDepositEvent islandBankDepositEvent = callEvent(new IslandBankDepositEvent(superiorPlayer, island, amount));
return EventResult.of(islandBankDepositEvent.isCancelled(), islandBankDepositEvent.getFailureReason());
}

public EventResult<String> callIslandBankWithdrawEvent(SuperiorPlayer superiorPlayer, Island island, BigDecimal amount) {
if (plugin.getSettings().getDisabledEvents().contains("islandbankwithdrawevent"))
return EventResult.of(false, null);

IslandBankWithdrawEvent islandBankWithdrawEvent = callEvent(new IslandBankWithdrawEvent(superiorPlayer, island, amount));
return EventResult.of(islandBankWithdrawEvent.isCancelled(), islandBankWithdrawEvent.getFailureReason());
}

public void callIslandRestrictMoveEvent(SuperiorPlayer superiorPlayer, IslandRestrictMoveEvent.RestrictReason restrictReason) {
if (!plugin.getSettings().getDisabledEvents().contains("islandrestrictmoveevent")) {
callEvent(new IslandRestrictMoveEvent(superiorPlayer, restrictReason));
}
}

public void callPluginInitializeEvent(SuperiorSkyblock plugin) {
callEvent(new PluginInitializeEvent(plugin));
}

public void callPluginInitializedEvent(SuperiorSkyblock plugin) {
callEvent(new PluginInitializedEvent(plugin));
}

public boolean callIslandCoopPlayerEvent(Island island, SuperiorPlayer player, SuperiorPlayer target) {
if (plugin.getSettings().getDisabledEvents().contains("islandcoopplayerevent"))
return true;

return !callEvent(new IslandCoopPlayerEvent(island, player, target)).isCancelled();
public void callPluginInitializeEvent(SuperiorSkyblock plugin) {
callEvent(new PluginInitializeEvent(plugin));
}

public boolean callIslandUncoopPlayerEvent(Island island, SuperiorPlayer player, SuperiorPlayer target,
IslandUncoopPlayerEvent.UncoopReason uncoopReason) {
if (plugin.getSettings().getDisabledEvents().contains("islanduncoopplayerevent"))
public boolean callPreIslandCreateEvent(SuperiorPlayer superiorPlayer, String islandName) {
if (plugin.getSettings().getDisabledEvents().contains("preislandcreateevent"))
return true;

return !callEvent(new IslandUncoopPlayerEvent(island, player, target, uncoopReason)).isCancelled();
}

public void callIslandChunkResetEvent(Island island, ChunkPosition chunkPosition) {
if (plugin.getSettings().getDisabledEvents().contains("islandchunkresetevent"))
return;

callEvent(new IslandChunkResetEvent(island, chunkPosition.getWorld(), chunkPosition.getX(), chunkPosition.getZ()));
}

public EventResult<String> callIslandChatEvent(Island island, SuperiorPlayer superiorPlayer, String message) {
if (plugin.getSettings().getDisabledEvents().contains("islandchatevent"))
return EventResult.of(false, message);

IslandChatEvent islandChatEvent = callEvent(new IslandChatEvent(island, superiorPlayer, message));
return EventResult.of(islandChatEvent.isCancelled(), message);
return !callEvent(new PreIslandCreateEvent(superiorPlayer, islandName)).isCancelled();
}

private static <T extends Event> T callEvent(T event) {
Expand Down

0 comments on commit fb1d57f

Please sign in to comment.