us.talabrek.ultimateskyblock.api.IslandInfo Java Examples

The following examples show how to use us.talabrek.ultimateskyblock.api.IslandInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpawnEvents.java    From uSkyBlock with GNU General Public License v3.0 6 votes vote down vote up
private void checkLimits(Cancellable event, EntityType entityType, Location location) {
    if (entityType == null) {
        return; // Only happens on "other-plugins", i.e. EchoPet
    }
    String islandName = WorldGuardHandler.getIslandNameAt(location);
    if (islandName == null) {
        event.setCancelled(true); // Only allow spawning on active islands...
        return;
    }
    if (entityType.getEntityClass().isAssignableFrom(Ghast.class) && location.getWorld().getEnvironment() != World.Environment.NETHER) {
        // Disallow ghasts for now...
        event.setCancelled(true);
        return;
    }
    us.talabrek.ultimateskyblock.api.IslandInfo islandInfo = plugin.getIslandInfo(islandName);
    if (islandInfo == null) {
        // Disallow spawns on inactive islands
        event.setCancelled(true);
        return;
    }
    if (!plugin.getLimitLogic().canSpawn(entityType, islandInfo)) {
        event.setCancelled(true);
    }
}
 
Example #2
Source File: SpawnEvents.java    From uSkyBlock with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (event == null || !plugin.getWorldManager().isSkyAssociatedWorld(event.getLocation().getWorld())) {
        return; // Bail out, we don't care
    }
    if (!event.isCancelled() && ADMIN_INITIATED.contains(event.getSpawnReason())) {
        return; // Allow it, the above method would have blocked it if it should be blocked.
    }
    checkLimits(event, event.getEntity().getType(), event.getLocation());
    if (event.getEntity() instanceof WaterMob) {
        Location loc = event.getLocation();
        if (isDeepOceanBiome(loc) && isPrismarineRoof(loc)) {
            loc.getWorld().spawnEntity(loc, EntityType.GUARDIAN);
            event.setCancelled(true);
        }
    }
    if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.BUILD_WITHER && event.getEntity() instanceof Wither) {
        IslandInfo islandInfo = plugin.getIslandInfo(event.getLocation());
        if (islandInfo != null && islandInfo.getLeader() != null) {
            event.getEntity().setCustomName(I18nUtil.tr("{0}''s Wither", islandInfo.getLeader()));
            event.getEntity().setMetadata("fromIsland", new FixedMetadataValue(plugin, islandInfo.getName()));
        }
    }
}
 
Example #3
Source File: HookUltimateSkyBlock.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
@Override
public IslandInfo getIslandFor(Player player) {
    if(player == null) return null;

    uSkyBlockAPI api = getAPI();
    return api.getIslandInfo(player);
}
 
Example #4
Source File: ChatLogic.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets a {@link List} containing {@link Player}'s with all the recipients that should receive the given message
 * {@link Type} from the sending {@link Player}. Returns an empty list when there are no recipients.
 * @param sender   Player sending the message.
 * @param chatType Message type that the player is sending.
 * @return List of all recipients, or an empty list if there are none.
 */
public @NotNull List<Player> getRecipients(Player sender, Type chatType) {
    if (chatType == Type.PARTY) {
        IslandInfo islandInfo = plugin.getIslandInfo(sender);
        return islandInfo != null ? islandInfo.getOnlineMembers() : Collections.singletonList(sender);
    } else if (chatType == Type.ISLAND) {
        if (plugin.getWorldManager().isSkyWorld(sender.getWorld())) {
            return WorldGuardHandler.getPlayersInRegion(plugin.getWorldManager().getWorld(),
                WorldGuardHandler.getIslandRegionAt(sender.getLocation()));
        }
        return Collections.emptyList();
    }
    return Collections.emptyList();
}
 
Example #5
Source File: IslandUnbanPlayerEvent.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
public IslandUnbanPlayerEvent(@NotNull final IslandInfo islandInfo,
                            @NotNull final OfflinePlayer target,
                            @Nullable final OfflinePlayer initializer)
{
    super(islandInfo);
    this.target = target;
    this.initializer = initializer;
}
 
Example #6
Source File: IslandTrustPlayerEvent.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
public IslandTrustPlayerEvent(@NotNull final IslandInfo islandInfo,
                              @NotNull final OfflinePlayer trustee,
                              @Nullable final OfflinePlayer initializer)
{
    super(islandInfo);
    this.trustee = trustee;
    this.initializer = initializer;
}
 
Example #7
Source File: IslandUntrustPlayerEvent.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
public IslandUntrustPlayerEvent(@NotNull final IslandInfo islandInfo,
                                @NotNull final OfflinePlayer trustee,
                                @Nullable final OfflinePlayer initializer)
{
    super(islandInfo);
    this.trustee = trustee;
    this.initializer = initializer;
}
 
Example #8
Source File: IslandBanPlayerEvent.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
public IslandBanPlayerEvent(@NotNull final IslandInfo islandInfo,
                              @NotNull final OfflinePlayer target,
                              @Nullable final OfflinePlayer initializer)
{
    super(islandInfo);
    this.target = target;
    this.initializer = initializer;
}
 
Example #9
Source File: HookUltimateSkyBlock.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean doesTeamMatch(Player player1, Player player2) {
    if(player1 == null || player2 == null) return false;

    UUID uuid1 = player1.getUniqueId();
    UUID uuid2 = player2.getUniqueId();
    if(uuid1.equals(uuid2)) return true;

    IslandInfo island = getIslandFor(player1);
    Set<String> memberNameSet = island.getMembers();

    String player2Name = player2.getName();
    return memberNameSet.contains(player2Name);
}
 
Example #10
Source File: HookUltimateSkyBlock.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
@Override
public IslandInfo getIslandAt(Location location) {
    if(location == null) return null;

    uSkyBlockAPI api = getAPI();
    return api.getIslandInfo(location);
}
 
Example #11
Source File: USkyBlockListener.java    From ShopChest with MIT License 5 votes vote down vote up
private boolean handleForLocation(Player player, Location loc, Cancellable e) {
    IslandInfo islandInfo = uSkyBlockAPI.getIslandInfo(loc);
    if (islandInfo == null) 
        return false;

    if (!player.getName().equals(islandInfo.getLeader()) && !islandInfo.getMembers().contains(player.getName())) {
        e.setCancelled(true);
        plugin.debug("Cancel Reason: uSkyBlock");
        return true;
    }
    return false;
}
 
Example #12
Source File: InviteEvent.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
public InviteEvent(Player who, IslandInfo islandInfo, Player guest) {
    super(who);
    this.islandInfo = islandInfo;
    this.guest = guest;
}
 
Example #13
Source File: MemberLeftEvent.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
public IslandInfo getIslandInfo() {
    return islandInfo;
}
 
Example #14
Source File: MemberLeftEvent.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
public MemberLeftEvent(IslandInfo islandInfo, PlayerInfo playerInfo) {
    super(true);
    this.islandInfo = islandInfo;
    this.playerInfo = playerInfo;
}
 
Example #15
Source File: IslandLeaderChangedEvent.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
public IslandInfo getIslandInfo() {
    return islandInfo;
}
 
Example #16
Source File: IslandLeaderChangedEvent.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
public IslandLeaderChangedEvent(IslandInfo islandInfo, PlayerInfo originalLeaderInfo, PlayerInfo newLeaderInfo) {
    super(true);
    this.islandInfo = islandInfo;
    this.originalLeaderInfo = originalLeaderInfo;
    this.newLeaderInfo = newLeaderInfo;
}
 
Example #17
Source File: IslandUnlockEvent.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
public IslandUnlockEvent(@NotNull IslandInfo islandInfo, @Nullable OfflinePlayer initializer) {
    super(islandInfo);
    this.initializer = initializer;
}
 
Example #18
Source File: MemberJoinedEvent.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
public IslandInfo getIslandInfo() {
    return islandInfo;
}
 
Example #19
Source File: InviteEvent.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
public IslandInfo getIslandInfo() {
    return islandInfo;
}
 
Example #20
Source File: MemberJoinedEvent.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
public MemberJoinedEvent(IslandInfo islandInfo, PlayerInfo playerInfo) {
    super(true);
    this.islandInfo = islandInfo;
    this.playerInfo = playerInfo;
}
 
Example #21
Source File: CancellableIslandEvent.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
CancellableIslandEvent(@NotNull final IslandInfo islandInfo, boolean async) {
    super(islandInfo, async);
}
 
Example #22
Source File: CancellableIslandEvent.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
public CancellableIslandEvent(@NotNull final IslandInfo islandInfo) {
    super(islandInfo);
}
 
Example #23
Source File: IslandEvent.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns the IslandInfo involved in this event.
 * @return IslandInfo involved in this event.
 */
@NotNull
public final IslandInfo getIslandInfo() {
    return islandInfo;
}
 
Example #24
Source File: IslandEvent.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
IslandEvent(@NotNull final IslandInfo islandInfo, boolean async) {
    super(async);
    this.islandInfo = islandInfo;
}
 
Example #25
Source File: IslandEvent.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
public IslandEvent(@NotNull final IslandInfo islandInfo) {
    this.islandInfo = islandInfo;
}
 
Example #26
Source File: IslandLockEvent.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
public IslandLockEvent(@NotNull IslandInfo islandInfo, @Nullable OfflinePlayer initializer) {
    super(islandInfo);
    this.initializer = initializer;
}