br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect Java Examples

The following examples show how to use br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect. 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: CommandHandlers.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
public static void handleKillWorld(CommandSender sender, World world, EntityType type) {
    int killed = 0;
    int total = 0;
    int living = 0;
    for (Entity e : world.getEntities().stream().filter(entity ->
            !(entity instanceof Player) &&
                    ((entity instanceof LivingEntity && type == null) || entity.getType().equals(type))
    ).collect(Collectors.toList())) {
        total++;
        if (RedProtect.get().rm.getTopRegion(e.getLocation()) == null) {
            e.remove();
            killed++;
        } else if (e instanceof LivingEntity && type == null) {
            living++;
        } else if (e.getType().equals(type)) {
            living++;
        }
    }
    RedProtect.get().lang.sendMessage(sender, "cmdmanager.kill", new Replacer[]{
            new Replacer("{total}", String.valueOf(total)),
            new Replacer("{living}", String.valueOf(living)),
            new Replacer("{killed}", String.valueOf(killed)),
            new Replacer("{world}", world.getName())
    });
}
 
Example #2
Source File: DynmapHook.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
DynmapHook(DynmapAPI dyn) {
    MApi = dyn.getMarkerAPI();
    MSet = MApi.getMarkerSet(RedProtect.get().config.configRoot().hooks.dynmap.marks_groupname);
    if (MSet == null) {
        MSet = MApi.createMarkerSet("RedProtect", RedProtect.get().config.configRoot().hooks.dynmap.marks_groupname, null, false);
    }
    MSet.setHideByDefault(RedProtect.get().config.configRoot().hooks.dynmap.hide_by_default);
    MSet.setLayerPriority(RedProtect.get().config.configRoot().hooks.dynmap.layer_priority);
    MSet.setLabelShow(RedProtect.get().config.configRoot().hooks.dynmap.show_label);
    MSet.setDefaultMarkerIcon(MApi.getMarkerIcon(RedProtect.get().config.configRoot().hooks.dynmap.marker.get("player").marker_icon));
    int minzoom = RedProtect.get().config.configRoot().hooks.dynmap.min_zoom;
    if (minzoom > 0) {
        MSet.setMinZoom(minzoom);
    } else {
        MSet.setMinZoom(0);
    }

    //start set markers
    for (World w : RedProtect.get().getServer().getWorlds()) {
        for (Region r : RedProtect.get().rm.getRegionsByWorld(w.getName())) {
            if (!r.allowDynmap()) continue;
            addMark(r);
        }
    }
}
 
Example #3
Source File: KillerProjectiles.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onDamagePlayer(ProjectileHitEvent event) {
    if (event.getHitEntity() instanceof Player) {

        Player player = (Player) event.getHitEntity();
        Projectile projectile = event.getEntity();
        Region r = RedProtect.get().rm.getTopRegion(projectile.getLocation());

        double damage;
        if (getConfig().getString("projectile-damage").endsWith("%")) {
            damage = (player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() / 100) * Double.valueOf(getConfig().getString("projectile-damage", "100%").replace("%", ""));
        } else {
            damage = getConfig().getInt("projectile-damage");
        }

        if (r != null && r.getFlagBool("killer-projectiles") && getConfig().getStringList("allowed-types").contains(projectile.getType().name())) {
            player.setHealth(damage);
        }
    }
}
 
Example #4
Source File: GlobalListener.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onPlayerFrostWalk(EntityBlockFormEvent e) {
    Region r = RedProtect.get().rm.getTopRegion(e.getBlock().getLocation());
    if (r != null) {
        return;
    }
    RedProtect.get().logger.debug(LogLevel.DEFAULT, "GlobalListener - EntityBlockFormEvent canceled? ");
    if (e.getEntity() instanceof Player) {
        Player p = (Player) e.getEntity();
        if (!RedProtect.get().config.globalFlagsRoot().worlds.get(p.getWorld().getName()).iceform_by.player && !p.hasPermission("redprotect.bypass.world")) {
            e.setCancelled(true);
        }
    } else if (!RedProtect.get().config.globalFlagsRoot().worlds.get(e.getEntity().getWorld().getName()).iceform_by.entity) {
        e.setCancelled(true);
    }
}
 
Example #5
Source File: RedProtectUtil.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
private boolean checkTableExists(String tableName) {
    try {
        RedProtect.get().logger.debug(LogLevel.DEFAULT, "Checking if table exists... " + tableName);
        Connection con = DriverManager.getConnection("jdbc:mysql://" + RedProtect.get().config.configRoot().mysql.host + "/" + RedProtect.get().config.configRoot().mysql.db_name, RedProtect.get().config.configRoot().mysql.user_name, RedProtect.get().config.configRoot().mysql.user_pass);
        DatabaseMetaData meta = con.getMetaData();
        ResultSet rs = meta.getTables(null, null, tableName, null);
        if (rs.next()) {
            con.close();
            rs.close();
            return true;
        }
        con.close();
        rs.close();
    } catch (SQLException e) {
        printJarVersion();
        e.printStackTrace();
    }
    return false;
}
 
Example #6
Source File: RedProtectUtil.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
public int simuleTotalRegionSize(String player, Region r2) {
    int total = 0;
    int regs = 0;
    for (Location loc : r2.get4Points(r2.getCenterY())) {
        Map<Integer, Region> pregs = RedProtect.get().rm.getGroupRegion(loc);
        pregs.remove(r2.getPrior());
        Region other;
        if (pregs.size() > 0) {
            other = pregs.get(Collections.max(pregs.keySet()));
        } else {
            continue;
        }
        if (!r2.getID().equals(other.getID()) && r2.getPrior() > other.getPrior() && other.isLeader(player)) {
            regs++;
        }
    }
    if (regs != 4) {
        total += r2.getArea();
    }

    return total;
}
 
Example #7
Source File: Compat18.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onAttemptInteractAS(PlayerInteractAtEntityEvent e) {

    Entity ent = e.getRightClicked();
    Location l = ent.getLocation();
    Region r = RedProtect.get().rm.getTopRegion(l);
    Player p = e.getPlayer();
    if (r == null) {
        //global flags
        if (ent instanceof ArmorStand) {
            if (!RedProtect.get().config.globalFlagsRoot().worlds.get(l.getWorld().getName()).build) {
                e.setCancelled(true);
                return;
            }
        }
        return;
    }

    if (ent instanceof ArmorStand) {
        if (!r.canBuild(p)) {
            RedProtect.get().lang.sendMessage(p, "playerlistener.region.cantedit");
            e.setCancelled(true);
        }
    }
}
 
Example #8
Source File: RedProtectUtil.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Generate a friendly and unique name for a region based on player name.
 *
 * @param p     Player
 * @param World World
 * @return Name of region
 */
public String nameGen(String p, String World) {
    String rname;
    int i = 0;
    while (true) {
        int is = String.valueOf(i).length();
        if (p.length() > 13) {
            rname = p.substring(0, 14 - is) + "_" + i;
        } else {
            rname = p + "_" + i;
        }
        if (RedProtect.get().rm.getRegion(rname, World) == null) {
            break;
        }
        ++i;
    }
    return rname;
}
 
Example #9
Source File: GlobalListener.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void MonsterBlockBreak(EntityChangeBlockEvent event) {
    Entity e = event.getEntity();
    Block b = event.getBlock();
    Region r = RedProtect.get().rm.getTopRegion(event.getBlock().getLocation());
    if (r != null) {
        return;
    }

    if (b != null) {
        RedProtect.get().logger.debug(LogLevel.DEFAULT, "GlobalListener - Is EntityChangeBlockEvent event. Block: " + b.getType().name());
    }

    if (e instanceof Monster) {
        if (!RedProtect.get().config.globalFlagsRoot().worlds.get(e.getWorld().getName()).entity_block_damage) {
            event.setCancelled(true);
        }
    }
    if (e instanceof Player) {
        Player p = (Player) e;
        if (!bypassBuild(p, b, 2)) {
            event.setCancelled(true);
        }
    }
}
 
Example #10
Source File: PurgeLimitCommand.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (sender instanceof ConsoleCommandSender || !RedProtect.get().config.configRoot().purge.enabled) {
        HandleHelpPage(sender, 1);
        return true;
    }

    Player player = (Player) sender;

    int limit = RedProtect.get().ph.getPurgeLimit(player);
    long amount = RedProtect.get().rm.getCanPurgePlayer(player.getUniqueId().toString(), player.getWorld().getName());
    RedProtect.get().lang.sendMessage(player, "playerlistener.region.purge-limit", new Replacer[]{
            new Replacer("{limit}", String.valueOf(limit)),
            new Replacer("{total}", String.valueOf(amount))
    });
    return true;
}
 
Example #11
Source File: Compat19.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onConsume(PlayerItemConsumeEvent e) {
    if (e.getItem() == null) {
        return;
    }

    Player p = e.getPlayer();
    //deny potion
    if (p == null) {
        return;
    }

    Region r = RedProtect.get().rm.getTopRegion(p.getLocation());
    if (r != null && e.getItem().getType().equals(Material.CHORUS_FRUIT) && !r.canTeleport(p)) {
        RedProtect.get().lang.sendMessage(p, "playerlistener.region.cantuse");
        e.setCancelled(true);
    }
}
 
Example #12
Source File: PermissionHandler.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
public int getPurgeLimit(Player player) {
    int limit = RedProtect.get().config.configRoot().purge.canpurge_limit;
    List<Integer> limits = new ArrayList<>();
    Set<PermissionAttachmentInfo> perms = player.getEffectivePermissions();
    if (limit > 0) {
        for (PermissionAttachmentInfo perm : perms) {
            if (perm.getPermission().startsWith("redprotect.canpurge-limit.")) {
                String pStr = perm.getPermission().replaceAll("[^-?0-9]+", "");
                if (!pStr.isEmpty()) {
                    limits.add(Integer.parseInt(pStr));
                }
            }
        }
    }
    if (limits.size() > 0) {
        limit = Collections.max(limits);
    }
    return limit;
}
 
Example #13
Source File: RegionManager.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Get the hight priority region in a group region. If no other regions, return the unique region on location.
 *
 * @param loc Location
 * @return {@code Region} - Or null if no regions on this location.
 */
public
Region getTopRegion(Location loc) {
    if (bLoc.containsKey(loc.getBlock().getLocation())) {
        RedProtect.get().logger.debug(LogLevel.DEFAULT, "Get from cache");
        return bLoc.get(loc.getBlock().getLocation());
    } else {
        if (!this.regionManagers.containsKey(loc.getWorld().getName())) {
            return null;
        }

        WorldRegionManager rm = this.regionManagers.get(loc.getWorld().getName());
        Region r = rm.getTopRegion(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
        try {
            bLoc.entrySet().removeIf(k -> k.getValue().equals(r));

            if (r != null) {
                bLoc.put(loc.getBlock().getLocation(), r);
                RedProtect.get().logger.debug(LogLevel.DEFAULT, "Get from DB");
            }
        } catch (Exception ignored) {
        }
        return r;
    }
}
 
Example #14
Source File: Compat19.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onLingerPotion(LingeringPotionSplashEvent e) {
    if (!(RedProtect.get().getVersionHelper().getPlayerLingPot(e) instanceof Player)) {
        return;
    }

    Player p = (Player) RedProtect.get().getVersionHelper().getPlayerLingPot(e);
    Entity ent = RedProtect.get().getVersionHelper().getEntLingPot(e);

    RedProtect.get().logger.debug(LogLevel.DEFAULT, "Is LingeringPotionSplashEvent event.");

    Region r = RedProtect.get().rm.getTopRegion(ent.getLocation());
    if (r != null && !r.canGetEffects(p)) {
        RedProtect.get().lang.sendMessage(p, "playerlistener.region.cantuse");
        e.setCancelled(true);
        return;
    }

    if (RedProtect.get().getVersionHelper().denyEntLingPot(e, e.getEntity().getWorld())) {
        e.setCancelled(true);
        RedProtect.get().lang.sendMessage(p, RedProtect.get().lang.get("playerlistener.denypotion"));
    }
}
 
Example #15
Source File: CommandHandlers.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
public static void handleInfoTop(Player p) {
    Region r = RedProtect.get().rm.getTopRegion(p.getLocation());
    if (r == null) {
        RedProtect.get().lang.sendMessage(p, "cmdmanager.region.doesntexist");
        return;
    }
    Map<Integer, Region> groupr = RedProtect.get().rm.getGroupRegion(p.getLocation());
    if (RedProtect.get().ph.hasRegionPermAdmin(p, "info", r)) {
        p.sendMessage(RedProtect.get().lang.get("general.color") + "--------------- [" + ChatColor.GOLD + r.getName() + RedProtect.get().lang.get("general.color") + "] ---------------");
        p.sendMessage(r.info());
        p.sendMessage(RedProtect.get().lang.get("general.color") + "----------------------------------");
        if (groupr.size() > 1) {
            p.sendMessage(RedProtect.get().lang.get("cmdmanager.moreregions"));
            for (Region regs : groupr.values()) {
                if (regs != r) {
                    p.sendMessage(RedProtect.get().lang.get("region.name") + " " + regs.getName() + " " + RedProtect.get().lang.get("region.priority") + " " + regs.getPrior());
                }
            }
        }
    } else {
        RedProtect.get().lang.sendMessage(p, "no.permission");
    }
}
 
Example #16
Source File: McMMOHook.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onPlayerExperience(McMMOPlayerXpGainEvent event) {
    if (event.isCancelled()) {
        return;
    }

    RedProtect.get().logger.debug(LogLevel.DEFAULT, "McMMO McMMOPlayerXpGainEvent event. Skill " + event.getSkill().name());

    Player player = event.getPlayer();
    Region region = RedProtect.get().rm.getTopRegion(player.getLocation());
    if (region == null) {
        return;
    }

    if (!region.canSkill(player)) {
        event.setCancelled(true);
    }

    if (RedProtect.get().config.configRoot().hooks.mcmmo.fix_acrobatics_fire_leveling && event.getSkill().equals(PrimarySkillType.ACROBATICS) && (!region.canFire() || !region.canDeath())) {
        event.setCancelled(true);
    }
}
 
Example #17
Source File: BlockListener.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onBlockBurn(BlockBurnEvent e) {
    RedProtect.get().logger.debug(LogLevel.BLOCKS, "BlockListener - Is BlockBurnEvent event");

    Block b = e.getBlock();

    Region r = RedProtect.get().rm.getTopRegion(b.getLocation());
    if (r != null && !r.canFire()) {
        e.setCancelled(true);
        return;
    }

    if (!cont.canWorldBreak(b)) {
        e.setCancelled(true);
    }
}
 
Example #18
Source File: CommandHandlers.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
private static void tpWait(final Player p, final Location loc, final String rname) {
    if (p.hasPermission("redprotect.command.admin.teleport")) {
        p.teleport(loc);
        return;
    }
    if (!RedProtect.get().tpWait.contains(p.getName())) {
        RedProtect.get().tpWait.add(p.getName());
        RedProtect.get().lang.sendMessage(p, "cmdmanager.region.tpdontmove");
        Bukkit.getScheduler().scheduleSyncDelayedTask(RedProtect.get(), () -> {
            if (RedProtect.get().tpWait.contains(p.getName())) {
                RedProtect.get().tpWait.remove(p.getName());
                if (RedProtect.get().hooks.essentials) {
                    RedProtect.get().hooks.pless.getUser(p).setLastLocation();
                }
                p.teleport(loc);
                RedProtect.get().lang.sendMessage(p, RedProtect.get().lang.get("cmdmanager.region.teleport") + " " + rname);
            }
        }, RedProtect.get().config.configRoot().region_settings.teleport_time * 20);
    } else {
        RedProtect.get().lang.sendMessage(p, "cmdmanager.region.tpneedwait");
    }
}
 
Example #19
Source File: RenameCommand.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (sender instanceof ConsoleCommandSender) {
        HandleHelpPage(sender, 1);
        return true;
    }

    Player player = (Player) sender;

    if (args.length == 1) {
        handleRename(player, args[0]);
        return true;
    }

    RedProtect.get().lang.sendCommandHelp(sender, "rename", true);
    return true;
}
 
Example #20
Source File: WorldMySQLRegionManager.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@Override
public int getTotalRegionNum() {
    int total = 0;
    try {
        PreparedStatement st = this.dbcon.prepareStatement("SELECT COUNT(*) FROM `" + tableName + "`");
        ResultSet rs = st.executeQuery();
        if (rs.next()) {
            total = rs.getInt("COUNT(*)");
        }
        st.close();
        rs.close();
    } catch (SQLException e) {
        RedProtect.get().logger.severe("Error on get total of regions for " + tableName + "!");
        CoreUtil.printJarVersion();
        e.printStackTrace();
    }
    return total;
}
 
Example #21
Source File: EntityListener.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onPotionSplash(PotionSplashEvent event) {
    RedProtect.get().logger.debug(LogLevel.ENTITY, "EntityListener - Is PotionSplashEvent");

    ProjectileSource thrower = event.getPotion().getShooter();
    for (PotionEffect e : event.getPotion().getEffects()) {
        PotionEffectType t = e.getType();
        if (!t.equals(PotionEffectType.BLINDNESS) && !t.equals(PotionEffectType.CONFUSION) && !t.equals(PotionEffectType.HARM) && !t.equals(PotionEffectType.HUNGER) && !t.equals(PotionEffectType.POISON) && !t.equals(PotionEffectType.SLOW) && !t.equals(PotionEffectType.SLOW_DIGGING) && !t.equals(PotionEffectType.WEAKNESS) && !t.equals(PotionEffectType.WITHER)) {
            return;
        }
    }
    Player shooter;
    if (thrower instanceof Player) {
        shooter = (Player) thrower;
    } else {
        return;
    }
    for (Entity e2 : event.getAffectedEntities()) {
        Region r = RedProtect.get().rm.getTopRegion(e2.getLocation());
        if (event.getEntity() instanceof Player) {
            if (r != null && r.flagExists("pvp") && !r.canPVP((Player) event.getEntity(), shooter)) {
                event.setCancelled(true);
                return;
            }
        } else {
            if (r != null && !r.canInteractPassives(shooter)) {
                event.setCancelled(true);
                return;
            }
        }
    }
}
 
Example #22
Source File: WorldListener.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.NORMAL)
public void onWorldLoad(WorldLoadEvent e) {
    World w = e.getWorld();
    try {
        RedProtect.get().rm.load(w.getName());
        // RedProtect.get().config.addWorldProperties(w);

        RedProtect.get().reloadConfigs();
        RedProtect.get().logger.warning("World loaded: " + w.getName());
    } catch (Exception ex) {
        RedProtect.get().logger.severe("RedProtect problem on load world:");
        ex.printStackTrace();
    }
}
 
Example #23
Source File: RegionManager.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
public void load(String w) throws Exception {
    if (this.regionManagers.containsKey(w) && this.regionManagers.get(w) != null) {
        return;
    }
    WorldRegionManager mgr;
    if (RedProtect.get().config.configRoot().file_type.equalsIgnoreCase("mysql")) {
        mgr = new WorldMySQLRegionManager(w);
    } else {
        mgr = new WorldFlatFileRegionManager(w);
    }
    mgr.load();
    this.regionManagers.put(w, mgr);
}
 
Example #24
Source File: RedProtectLogger.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
public void saveLogs() {
    if (!RedProtect.get().config.configRoot().log_actions) {
        return;
    }

    final StringBuilder sb = new StringBuilder();
    mainLog.forEach((key, entry) -> sb.append(entry).append('\n'));

    if (RedProtect.get().getUtil().genFileName(RedProtect.get().getDataFolder() + File.separator + "logs" + File.separator, false) != null) {
        RedProtect.get().getUtil().saveSBToZip(RedProtect.get().getUtil().genFileName(RedProtect.get().getDataFolder() + File.separator + "logs" + File.separator, false), sb);
    }
}
 
Example #25
Source File: RedProtectLogger.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
public void addLog(String logLine) {
    // If log is not enabled return
    if (!RedProtect.get().config.configRoot().log_actions) {
        return;
    }
    int key = mainLog.keySet().size() + 1;
    mainLog.put(key, key + " - " + RedProtect.get().getUtil().hourNow() + ": " + translateAlternateColorCodes('&', logLine));
    if (key == 500) {
        saveLogs();
        mainLog.clear();
    }
}
 
Example #26
Source File: RemoveAllCommand.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (args.length == 1) {
        int removed = RedProtect.get().rm.removeAll(args[0]);
        if (removed <= 0) {
            RedProtect.get().lang.sendMessage(sender, RedProtect.get().lang.get("cmdmanager.region.noneremoved"));
        } else {
            RedProtect.get().lang.sendMessage(sender, RedProtect.get().lang.get("cmdmanager.region.removed").replace("{regions}", removed + "").replace("{player}", args[0]));
        }
        return true;
    }

    RedProtect.get().lang.sendCommandHelp(sender, "removeall", true);
    return true;
}
 
Example #27
Source File: ItemFlagGui.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
void onPluginDisable(PluginDisableEvent event) {
    RedProtect.get().logger.debug(LogLevel.DEFAULT, "Is PluginDisableEvent event.");
    for (Player play : event.getPlugin().getServer().getOnlinePlayers()) {
        play.closeInventory();
    }
}
 
Example #28
Source File: BlockLimitCommand.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
    if (args.length == 1 && RedProtect.get().ph.hasPerm(sender, "redprotect.command.admin.blocklimit"))
        if (args[0].isEmpty())
            return Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
        else
            return Bukkit.getOnlinePlayers().stream().filter(p -> p.getName().toLowerCase().startsWith(args[0].toLowerCase())).map(Player::getName).collect(Collectors.toList());
    return new ArrayList<>();
}
 
Example #29
Source File: GlobalListener.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onFireSpread(BlockSpreadEvent e) {
    Block b = e.getSource();
    Region r = RedProtect.get().rm.getTopRegion(b.getLocation());
    if (r != null) {
        return;
    }

    if ((b.getType().equals(Material.FIRE) || b.getType().name().contains("LAVA")) && !RedProtect.get().config.globalFlagsRoot().worlds.get(b.getWorld().getName()).fire_spread) {
        e.setCancelled(true);
    }
}
 
Example #30
Source File: BlockListener.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
private boolean canPlaceList(World w, String type) {
    //blacklist
    List<String> blt = RedProtect.get().config.globalFlagsRoot().worlds.get(w.getName()).if_build_false.place_blocks.blacklist;
    if (blt.stream().anyMatch(type::matches)) return false;

    //whitelist
    List<String> wlt = RedProtect.get().config.globalFlagsRoot().worlds.get(w.getName()).if_build_false.place_blocks.whitelist;
    if (!wlt.isEmpty() && wlt.stream().noneMatch(type::matches)) {
        return false;
    }
    return RedProtect.get().config.globalFlagsRoot().worlds.get(w.getName()).build;
}