Search in sources :

Example 6 with WorldBorder

use of org.bukkit.WorldBorder in project PyrCore by PYRRH4.

the class Compat_1_12 method copyWorldBorder.

@Override
public void copyWorldBorder(World oldWorld, World newWorld) {
    WorldBorder border = oldWorld.getWorldBorder();
    newWorld.getWorldBorder().setCenter(border.getCenter());
    newWorld.getWorldBorder().setDamageAmount(border.getDamageAmount());
    newWorld.getWorldBorder().setDamageBuffer(border.getDamageBuffer());
    newWorld.getWorldBorder().setSize(border.getSize());
    newWorld.getWorldBorder().setWarningDistance(border.getWarningDistance());
    newWorld.getWorldBorder().setWarningTime(border.getWarningTime());
}
Also used : WorldBorder(org.bukkit.WorldBorder)

Example 7 with WorldBorder

use of org.bukkit.WorldBorder in project PyrCore by PYRRH4.

the class Compat_1_9 method copyWorldBorder.

@Override
public void copyWorldBorder(World oldWorld, World newWorld) {
    WorldBorder border = oldWorld.getWorldBorder();
    newWorld.getWorldBorder().setCenter(border.getCenter());
    newWorld.getWorldBorder().setDamageAmount(border.getDamageAmount());
    newWorld.getWorldBorder().setDamageBuffer(border.getDamageBuffer());
    newWorld.getWorldBorder().setSize(border.getSize());
    newWorld.getWorldBorder().setWarningDistance(border.getWarningDistance());
    newWorld.getWorldBorder().setWarningTime(border.getWarningTime());
}
Also used : WorldBorder(org.bukkit.WorldBorder)

Example 8 with WorldBorder

use of org.bukkit.WorldBorder in project MagicPlugin by elBukkit.

the class Mage method debugPermissions.

@Override
public void debugPermissions(CommandSender sender, Spell spell) {
    com.elmakers.mine.bukkit.api.wand.Wand wand = getActiveWand();
    Location location = getLocation();
    if (spell == null && wand != null) {
        spell = wand.getActiveSpell();
    }
    sender.sendMessage(ChatColor.GOLD + "Permission check for " + ChatColor.AQUA + getDisplayName());
    sender.sendMessage(ChatColor.GOLD + "  id " + ChatColor.DARK_AQUA + getId());
    sender.sendMessage(ChatColor.GOLD + " at " + ChatColor.AQUA + ChatColor.BLUE + location.getBlockX() + " " + location.getBlockY() + " " + location.getBlockZ() + " " + ChatColor.DARK_BLUE + location.getWorld().getName());
    Player player = getPlayer();
    boolean hasBypass = false;
    boolean hasPVPBypass = false;
    boolean hasBuildBypass = false;
    boolean hasBreakBypass = false;
    if (player != null) {
        hasBypass = player.hasPermission("Magic.bypass");
        hasPVPBypass = player.hasPermission("Magic.bypass_pvp");
        hasBuildBypass = player.hasPermission("Magic.bypass_build");
        sender.sendMessage(ChatColor.AQUA + " Has bypass: " + formatBoolean(hasBypass, true, null));
        sender.sendMessage(ChatColor.AQUA + " Has PVP bypass: " + formatBoolean(hasPVPBypass, true, null));
        sender.sendMessage(ChatColor.AQUA + " Has Build bypass: " + formatBoolean(hasBuildBypass, true, null));
        sender.sendMessage(ChatColor.AQUA + " Has Break bypass: " + formatBoolean(hasBreakBypass, true, null));
    }
    boolean buildPermissionRequired = spell == null ? false : spell.requiresBuildPermission();
    boolean breakPermissionRequired = spell == null ? false : spell.requiresBreakPermission();
    boolean pvpRestricted = spell == null ? false : spell.isPvpRestricted();
    sender.sendMessage(ChatColor.AQUA + " Can build: " + formatBoolean(hasBuildPermission(location.getBlock()), hasBuildBypass || !buildPermissionRequired ? null : true));
    sender.sendMessage(ChatColor.AQUA + " Can break: " + formatBoolean(hasBreakPermission(location.getBlock()), hasBreakBypass || !breakPermissionRequired ? null : true));
    sender.sendMessage(ChatColor.AQUA + " Can pvp: " + formatBoolean(isPVPAllowed(location), hasPVPBypass || !pvpRestricted ? null : true));
    boolean isPlayer = player != null;
    boolean spellDisguiseRestricted = (spell == null) ? false : spell.isDisguiseRestricted();
    sender.sendMessage(ChatColor.AQUA + " Is disguised: " + formatBoolean(controller.isDisguised(getEntity()), null, isPlayer && spellDisguiseRestricted ? true : null));
    WorldBorder border = location.getWorld().getWorldBorder();
    double borderSize = border.getSize();
    // Kind of a hack, meant to prevent this from showing up when there's no border defined
    if (borderSize < 50000000) {
        borderSize = borderSize / 2 - border.getWarningDistance();
        Location offset = location.subtract(border.getCenter());
        boolean isOutsideBorder = (offset.getX() < -borderSize || offset.getX() > borderSize || offset.getZ() < -borderSize || offset.getZ() > borderSize);
        sender.sendMessage(ChatColor.AQUA + " Is in world border (" + ChatColor.GRAY + borderSize + ChatColor.AQUA + "): " + formatBoolean(!isOutsideBorder, true, false));
    }
    if (spell != null) {
        sender.sendMessage(ChatColor.AQUA + " Has pnode " + ChatColor.GOLD + spell.getPermissionNode() + ChatColor.AQUA + ": " + formatBoolean(spell.hasCastPermission(player), hasBypass ? null : true));
        sender.sendMessage(ChatColor.AQUA + " Region override: " + formatBoolean(controller.getRegionCastPermission(player, spell, location), hasBypass ? null : true));
        sender.sendMessage(ChatColor.AQUA + " Field override: " + formatBoolean(controller.getPersonalCastPermission(player, spell, location), hasBypass ? null : true));
        com.elmakers.mine.bukkit.api.block.MaterialBrush brush = spell.getBrush();
        if (brush != null) {
            sender.sendMessage(ChatColor.GOLD + " " + spell.getName() + ChatColor.AQUA + " is erase: " + formatBoolean(brush.isErase(), null));
        }
        sender.sendMessage(ChatColor.GOLD + " " + spell.getName() + ChatColor.AQUA + " requires build: " + formatBoolean(spell.requiresBuildPermission(), null, true, true));
        sender.sendMessage(ChatColor.GOLD + " " + spell.getName() + ChatColor.AQUA + " requires break: " + formatBoolean(spell.requiresBreakPermission(), null, true, true));
        sender.sendMessage(ChatColor.GOLD + " " + spell.getName() + ChatColor.AQUA + " requires pvp: " + formatBoolean(spell.isPvpRestricted(), null, true, true));
        sender.sendMessage(ChatColor.GOLD + " " + spell.getName() + ChatColor.AQUA + " allowed while disguised: " + formatBoolean(!spell.isDisguiseRestricted(), null, false, true));
        if (spell instanceof BaseSpell) {
            boolean buildPermission = ((BaseSpell) spell).hasBuildPermission(location.getBlock());
            sender.sendMessage(ChatColor.GOLD + " " + spell.getName() + ChatColor.AQUA + " has build: " + formatBoolean(buildPermission, hasBuildBypass || !spell.requiresBuildPermission() ? null : true));
            boolean breakPermission = ((BaseSpell) spell).hasBreakPermission(location.getBlock());
            sender.sendMessage(ChatColor.GOLD + " " + spell.getName() + ChatColor.AQUA + " has break: " + formatBoolean(breakPermission, hasBreakBypass || !spell.requiresBreakPermission() ? null : true));
        }
        sender.sendMessage(ChatColor.AQUA + " Can cast " + ChatColor.GOLD + spell.getName() + ChatColor.AQUA + ": " + formatBoolean(spell.canCast(location)));
    }
}
Also used : Player(org.bukkit.entity.Player) BaseSpell(com.elmakers.mine.bukkit.spell.BaseSpell) WorldBorder(org.bukkit.WorldBorder) Location(org.bukkit.Location) CastSourceLocation(com.elmakers.mine.bukkit.api.magic.CastSourceLocation)

Example 9 with WorldBorder

use of org.bukkit.WorldBorder in project FunnyGuilds by FunnyGuilds.

the class ExcCreate method execute.

@SuppressWarnings("deprecation")
@Override
public void execute(CommandSender sender, String[] args) {
    MessagesConfig messages = Messages.getInstance();
    PluginConfig config = Settings.getConfig();
    Player player = (Player) sender;
    User user = User.get(player);
    if (!config.guildsEnabled) {
        player.sendMessage(messages.adminGuildsDisabled);
        return;
    }
    boolean isBlockedWorld = this.checkWorld(player);
    if (isBlockedWorld) {
        player.sendMessage(messages.blockedWorld);
        return;
    }
    if (user.hasGuild()) {
        player.sendMessage(messages.generalHasGuild);
        return;
    }
    if (args.length != 2) {
        switch(args.length) {
            case 0:
                player.sendMessage(messages.generalNoTagGiven);
                return;
            case 1:
                player.sendMessage(messages.generalNoNameGiven);
                return;
            default:
                player.sendMessage(messages.createMore);
                return;
        }
    }
    String tag = args[0];
    if (!config.guildTagKeepCase) {
        tag = config.guildTagUppercase ? tag.toUpperCase() : tag.toLowerCase();
    }
    String name = args[1];
    if (tag.length() > config.createTagLength) {
        player.sendMessage(messages.createTagLength.replace("{LENGTH}", Integer.toString(config.createTagLength)));
        return;
    }
    if (tag.length() < config.createTagMinLength) {
        player.sendMessage(messages.createTagMinLength.replace("{LENGTH}", Integer.toString(config.createTagMinLength)));
        return;
    }
    if (name.length() > config.createNameLength) {
        player.sendMessage(messages.createNameLength.replace("{LENGTH}", Integer.toString(config.createNameLength)));
        return;
    }
    if (name.length() < config.createNameMinLength) {
        player.sendMessage(messages.createNameMinLength.replace("{LENGTH}", Integer.toString(config.createNameMinLength)));
        return;
    }
    if (!tag.matches(config.tagRegex.getPattern())) {
        player.sendMessage(messages.createOLTag);
        return;
    }
    if (!name.matches(config.nameRegex.getPattern())) {
        player.sendMessage(messages.createOLName);
        return;
    }
    if (GuildUtils.nameExists(name)) {
        player.sendMessage(messages.createNameExists);
        return;
    }
    if (GuildUtils.tagExists(tag)) {
        player.sendMessage(messages.createTagExists);
        return;
    }
    if (config.checkForRestrictedGuildNames) {
        if (!GuildUtils.isNameValid(name)) {
            player.sendMessage(messages.restrictedGuildName);
            return;
        } else if (!GuildUtils.isTagValid(tag)) {
            player.sendMessage(messages.restrictedGuildTag);
            return;
        }
    }
    Location guildLocation = player.getLocation().getBlock().getLocation();
    if (config.regionsEnabled) {
        if (config.createCenterY != 0) {
            guildLocation.setY(config.createCenterY);
        }
        int d = config.regionSize + config.createDistance;
        if (config.enlargeItems != null) {
            d += config.enlargeItems.size() * config.enlargeSize;
        }
        if (d > player.getWorld().getSpawnLocation().distance(guildLocation)) {
            player.sendMessage(messages.createSpawn.replace("{DISTANCE}", Integer.toString(d)));
            return;
        }
    }
    if (config.rankCreateEnable) {
        int requiredRank = player.hasPermission("funnyguilds.vip.rank") ? config.rankCreateVip : config.rankCreate;
        int points = user.getRank().getPoints();
        if (points < requiredRank) {
            String msg = messages.createRank;
            msg = StringUtils.replace(msg, "{REQUIRED-FORMAT}", IntegerRange.inRange(requiredRank, config.pointsFormat).replace("{POINTS}", "{REQUIRED}"));
            msg = StringUtils.replace(msg, "{REQUIRED}", String.valueOf(requiredRank));
            msg = StringUtils.replace(msg, "{POINTS-FORMAT}", IntegerRange.inRange(points, config.pointsFormat));
            msg = StringUtils.replace(msg, "{POINTS}", String.valueOf(points));
            player.sendMessage(msg);
            return;
        }
    }
    List<ItemStack> requiredItems = player.hasPermission("funnyguilds.vip.items") ? config.createItemsVip : config.createItems;
    int requiredExperience = player.hasPermission("funnyguilds.vip.items") ? config.requiredExperienceVip : config.requiredExperience;
    double requiredMoney = player.hasPermission("funnyguilds.vip.items") ? config.requiredMoneyVip : config.requiredMoney;
    if (!user.getBypass()) {
        if (player.getTotalExperience() < requiredExperience) {
            String msg = messages.createExperience;
            msg = StringUtils.replace(msg, "{EXP}", String.valueOf(requiredExperience));
            player.sendMessage(msg);
            return;
        }
        if (VaultHook.isHooked() && !VaultHook.canAfford(player, requiredMoney)) {
            String notEnoughMoneyMessage = messages.createMoney;
            notEnoughMoneyMessage = StringUtils.replace(notEnoughMoneyMessage, "{MONEY}", Double.toString(requiredMoney));
            player.sendMessage(notEnoughMoneyMessage);
            return;
        }
        for (ItemStack requiredItem : requiredItems) {
            if (player.getInventory().containsAtLeast(requiredItem, requiredItem.getAmount())) {
                continue;
            }
            String msg = ItemUtils.translatePlaceholder(messages.createItems, requiredItems, requiredItem);
            player.sendMessage(msg);
            return;
        }
    }
    if (config.regionsEnabled) {
        if (RegionUtils.isIn(guildLocation)) {
            player.sendMessage(messages.createIsNear);
            return;
        }
        if (RegionUtils.isNear(guildLocation)) {
            player.sendMessage(messages.createIsNear);
            return;
        }
        if (config.createMinDistanceFromBorder != -1) {
            WorldBorder border = player.getWorld().getWorldBorder();
            double borderSize = border.getSize() / 2;
            double borderX = border.getCenter().getX() + borderSize;
            double borderZ = border.getCenter().getZ() + borderSize;
            double distanceX = Math.abs(borderX) - Math.abs(player.getLocation().getX());
            double distanceZ = Math.abs(borderZ) - Math.abs(player.getLocation().getZ());
            if ((distanceX < config.createMinDistanceFromBorder) || (distanceZ < config.createMinDistanceFromBorder)) {
                String notEnoughDistanceMessage = messages.createNotEnoughDistanceFromBorder;
                notEnoughDistanceMessage = StringUtils.replace(notEnoughDistanceMessage, "{BORDER-MIN-DISTANCE}", Double.toString(config.createMinDistanceFromBorder));
                player.sendMessage(notEnoughDistanceMessage);
                return;
            }
        }
    }
    if (!SimpleEventHandler.handle(new GuildCreateEvent(EventCause.USER, user, name, tag, guildLocation))) {
        return;
    }
    if (user.getBypass()) {
        user.setBypass(false);
    } else {
        player.getInventory().removeItem(ItemUtils.toArray(requiredItems));
        player.setTotalExperience(player.getTotalExperience() - requiredExperience);
        if (VaultHook.isHooked()) {
            VaultHook.withdrawFromPlayerBank(player, requiredMoney);
        }
    }
    Manager.getInstance().stop();
    Guild guild = new Guild(name);
    guild.setTag(tag);
    guild.setOwner(user);
    guild.setLives(config.warLives);
    guild.setBorn(System.currentTimeMillis());
    guild.setValidity(System.currentTimeMillis() + config.validityStart);
    guild.setAttacked(System.currentTimeMillis() - config.warWait + config.warProtection);
    guild.setPvP(config.damageGuild);
    user.setGuild(guild);
    if (config.regionsEnabled) {
        Region region = new Region(guild, guildLocation, config.regionSize);
        guild.setRegion(region.getName());
        guild.addRegion(region.getName());
        if (config.pasteSchematicOnCreation) {
            if (!SchematicHelper.pasteSchematic(config.guildSchematicFile, guildLocation, config.pasteSchematicWithAir)) {
                player.sendMessage(messages.createGuildCouldNotPasteSchematic);
            }
        } else if (config.createCenterSphere) {
            for (Location l : SpaceUtils.sphere(guildLocation, 4, 4, false, true, 0)) {
                if (l.getBlock().getType() != Material.BEDROCK) {
                    l.getBlock().setType(Material.AIR);
                }
            }
            for (Location l : SpaceUtils.sphere(guildLocation, 4, 4, true, true, 0)) {
                if (l.getBlock().getType() != Material.BEDROCK) {
                    l.getBlock().setType(Material.OBSIDIAN);
                }
            }
        }
        if (config.createMaterialData != null && config.createMaterialData.getItemType() != Material.AIR) {
            Block heart = guildLocation.getBlock().getRelative(BlockFace.DOWN);
            heart.setType(config.createMaterialData.getItemType());
            heart.setData(config.createMaterialData.getData());
        } else if (config.createEntityType != null) {
            EntityUtil.spawn(guild);
        }
        player.teleport(guildLocation);
    }
    Manager.getInstance().start();
    /*
        IndependentThread.actions(ActionType.RANK_UPDATE_GUILD, guild);
        IndependentThread.actions(ActionType.PREFIX_GLOBAL_ADD_GUILD, guild);
        IndependentThread.action(ActionType.PREFIX_GLOBAL_ADD_PLAYER, user.getName());
        */
    ConcurrencyManager concurrencyManager = FunnyGuilds.getInstance().getConcurrencyManager();
    concurrencyManager.postRequests(new RankUpdateGuildRequest(guild), new PrefixGlobalAddGuildRequest(guild), new PrefixGlobalAddPlayerRequest(user.getName()));
    MessageTranslator translator = new MessageTranslator().register("{GUILD}", name).register("{TAG}", tag).register("{PLAYER}", player.getName());
    player.sendMessage(translator.translate(messages.createGuild));
    Bukkit.broadcastMessage(translator.translate(messages.broadcastCreate));
}
Also used : Player(org.bukkit.entity.Player) User(net.dzikoysk.funnyguilds.basic.User) GuildCreateEvent(net.dzikoysk.funnyguilds.event.guild.GuildCreateEvent) ConcurrencyManager(net.dzikoysk.funnyguilds.concurrency.ConcurrencyManager) Guild(net.dzikoysk.funnyguilds.basic.Guild) PluginConfig(net.dzikoysk.funnyguilds.data.configs.PluginConfig) RankUpdateGuildRequest(net.dzikoysk.funnyguilds.concurrency.requests.rank.RankUpdateGuildRequest) PrefixGlobalAddPlayerRequest(net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalAddPlayerRequest) WorldBorder(org.bukkit.WorldBorder) PrefixGlobalAddGuildRequest(net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalAddGuildRequest) Region(net.dzikoysk.funnyguilds.basic.Region) Block(org.bukkit.block.Block) MessagesConfig(net.dzikoysk.funnyguilds.data.configs.MessagesConfig) ItemStack(org.bukkit.inventory.ItemStack) MessageTranslator(net.dzikoysk.funnyguilds.data.util.MessageTranslator) Location(org.bukkit.Location)

Aggregations

WorldBorder (org.bukkit.WorldBorder)9 Location (org.bukkit.Location)3 Player (org.bukkit.entity.Player)3 CastSourceLocation (com.elmakers.mine.bukkit.api.magic.CastSourceLocation)1 EffectPlayer (com.elmakers.mine.bukkit.effect.EffectPlayer)1 BaseSpell (com.elmakers.mine.bukkit.spell.BaseSpell)1 Guild (net.dzikoysk.funnyguilds.basic.Guild)1 Region (net.dzikoysk.funnyguilds.basic.Region)1 User (net.dzikoysk.funnyguilds.basic.User)1 ConcurrencyManager (net.dzikoysk.funnyguilds.concurrency.ConcurrencyManager)1 PrefixGlobalAddGuildRequest (net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalAddGuildRequest)1 PrefixGlobalAddPlayerRequest (net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalAddPlayerRequest)1 RankUpdateGuildRequest (net.dzikoysk.funnyguilds.concurrency.requests.rank.RankUpdateGuildRequest)1 MessagesConfig (net.dzikoysk.funnyguilds.data.configs.MessagesConfig)1 PluginConfig (net.dzikoysk.funnyguilds.data.configs.PluginConfig)1 MessageTranslator (net.dzikoysk.funnyguilds.data.util.MessageTranslator)1 GuildCreateEvent (net.dzikoysk.funnyguilds.event.guild.GuildCreateEvent)1 Block (org.bukkit.block.Block)1 Entity (org.bukkit.entity.Entity)1 LivingEntity (org.bukkit.entity.LivingEntity)1