Search in sources :

Example 6 with RedProtect

use of br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect in project RedProtect by FabioZumbi12.

the class RedProtect method onReloadPlugins.

@Listener
public void onReloadPlugins(GameReloadEvent event) {
    for (Player p : game.getServer().getOnlinePlayers()) {
        pvhelp.closeInventory(p);
    }
    reload();
    logger.sucess("RedProtect reloaded with success!");
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) RPGlobalListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPGlobalListener) RPWorldListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPWorldListener) RPEntityListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPEntityListener) RPBlockListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPBlockListener) RPPlayerListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPPlayerListener) Listener(org.spongepowered.api.event.Listener)

Example 7 with RedProtect

use of br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect in project RedProtect by FabioZumbi12.

the class RedProtect method initVars.

private void initVars() throws Exception {
    container = Sponge.getPluginManager().getPlugin("redprotect").get();
    serv = Sponge.getServer();
    cmdService = game.getCommandManager();
    cfgs = new RPConfig();
    RPLang.init();
    WE = checkWE();
    ph = new RPPermHandler();
    rm = new RegionManager();
}
Also used : RPConfig(br.net.fabiozumbi12.RedProtect.Sponge.config.RPConfig)

Example 8 with RedProtect

use of br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect in project RedProtect by FabioZumbi12.

the class RedProtect method onServerStart.

@Listener
public void onServerStart(GameStartedServerEvent event) {
    try {
        String v = Sponge.getGame().getPlatform().getContainer(Component.API).getVersion().get();
        instance = this;
        if (v.startsWith("5") || v.startsWith("6")) {
            pvhelp = (RPVHelper) Class.forName("br.net.fabiozumbi12.RedProtect.Sponge.RPVHelper56").newInstance();
        }
        if (v.startsWith("7")) {
            pvhelp = (RPVHelper) Class.forName("br.net.fabiozumbi12.RedProtect.Sponge.RPVHelper7").newInstance();
        }
        initVars();
        OnlineMode = serv.getOnlineMode();
        cmdService.register(container, new RPCommands(), Arrays.asList("redprotect", "rp", "regionp", "regp"));
        game.getEventManager().registerListeners(container, new RPGlobalListener());
        game.getEventManager().registerListeners(container, new RPBlockListener());
        game.getEventManager().registerListeners(container, new RPPlayerListener());
        game.getEventManager().registerListeners(container, new RPEntityListener());
        game.getEventManager().registerListeners(container, new RPWorldListener());
        game.getEventManager().registerListeners(container, new RPMine18());
        game.getEventManager().registerListeners(container, new RPAddProtection());
        loadRegions();
        logger.info("Loading API...");
        this.rpAPI = new RedProtectAPI();
        logger.info("API Loaded!");
        logger.clear("&4 _   _  _  &c _   _   _  _ _  _  _ _ _  __");
        logger.clear("&4|_| |_ | \\ &c|_| |_| | |  |  |_ |   |    / ");
        logger.clear("&4| \\ |_ |_/ &c|   | \\ |_|  |  |_ |_  |   /");
        logger.clear("&a¯ Redprotect " + container.getVersion().get() + " enabled");
        logger.clear("");
    } catch (Exception e) {
        e.printStackTrace();
        logger.severe("Error enabling RedProtect, plugin will shut down.");
    }
}
Also used : RPBlockListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPBlockListener) RPPlayerListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPPlayerListener) RPWorldListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPWorldListener) RPEntityListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPEntityListener) RedProtectAPI(br.net.fabiozumbi12.RedProtect.Sponge.API.RedProtectAPI) RPGlobalListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPGlobalListener) RPAddProtection(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPAddProtection) RPMine18(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPMine18) RPCommands(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPCommands) RPGlobalListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPGlobalListener) RPWorldListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPWorldListener) RPEntityListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPEntityListener) RPBlockListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPBlockListener) RPPlayerListener(br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPPlayerListener) Listener(org.spongepowered.api.event.Listener)

Example 9 with RedProtect

use of br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect in project RedProtect by FabioZumbi12.

the class RPPlayerListener method PlayerLogin.

@EventHandler
public void PlayerLogin(PlayerJoinEvent e) {
    Player p = e.getPlayer();
    // Adjust inside region
    p.teleport(new Location(p.getWorld(), p.getLocation().getBlockX(), p.getLocation().getBlockY() + 0.1, p.getLocation().getBlockZ()));
    if (p.hasPermission("redprotect.update") && RedProtect.get().Update && !RPConfig.getBool("update-check.auto-update")) {
        RPLang.sendMessage(p, ChatColor.AQUA + "An update is available for RedProtect: " + RedProtect.get().UptVersion);
        RPLang.sendMessage(p, ChatColor.AQUA + "Use /rp update to download and automatically install this update.");
    }
    if (RPConfig.getString("region-settings.record-player-visit-method").equalsIgnoreCase("ON-LOGIN")) {
        String uuid = p.getUniqueId().toString();
        if (!RedProtect.get().OnlineMode) {
            uuid = p.getName().toLowerCase();
        }
        for (Region r : RedProtect.get().rm.getMemberRegions(uuid)) {
            if (r.getDate() == null || !r.getDate().equals(RPUtil.DateNow())) {
                r.setDate(RPUtil.DateNow());
            }
        }
    }
    String worldneeded = RPConfig.getString("server-protection.teleport-player.on-join.need-world-to-teleport");
    if (RPConfig.getBool("server-protection.teleport-player.on-join.enable") && (worldneeded.equals("none") || worldneeded.equals(p.getWorld().getName()))) {
        String[] loc = RPConfig.getString("server-protection.teleport-player.on-join.location").split(",");
        e.getPlayer().teleport(new Location(Bukkit.getWorld(loc[0]), Double.parseDouble(loc[1]) + 0.500, Double.parseDouble(loc[2]), Double.parseDouble(loc[3]) + 0.500));
    }
    // Pvp check on join
    if (RedProtect.get().PvPm) {
        Region r = RedProtect.get().rm.getTopRegion(p.getLocation());
        if (!p.hasPermission("redprotect.forcepvp.bypass") && r != null && r.flagExists("forcepvp")) {
            PvPlayer pvpp = PvPlayer.get(p);
            if (r.forcePVP() != pvpp.hasPvPEnabled()) {
                PvPState.put(p.getName(), pvpp.hasPvPEnabled());
                pvpp.setPvP(r.forcePVP());
            }
        }
    }
}
Also used : Player(org.bukkit.entity.Player) PvPlayer(me.NoChance.PvPManager.PvPlayer) MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) PvPlayer(me.NoChance.PvPManager.PvPlayer) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Player (org.bukkit.entity.Player)4 Region (br.net.fabiozumbi12.RedProtect.Bukkit.Region)3 RPConfig (br.net.fabiozumbi12.RedProtect.Sponge.config.RPConfig)2 RPBlockListener (br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPBlockListener)2 RPEntityListener (br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPEntityListener)2 RPGlobalListener (br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPGlobalListener)2 RPPlayerListener (br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPPlayerListener)2 RPWorldListener (br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPWorldListener)2 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)2 ParseException (java.text.ParseException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 PvPlayer (me.NoChance.PvPManager.PvPlayer)2 ClanPlayer (net.sacredlabyrinth.phaed.simpleclans.ClanPlayer)2 Location (org.bukkit.Location)2 OfflinePlayer (org.bukkit.OfflinePlayer)2 Listener (org.spongepowered.api.event.Listener)2 RedProtectAPI (br.net.fabiozumbi12.RedProtect.Bukkit.API.RedProtectAPI)1 FancyMessage (br.net.fabiozumbi12.RedProtect.Bukkit.Fanciful.FancyMessage)1 RPGui (br.net.fabiozumbi12.RedProtect.Bukkit.RPGui)1 RedProtect (br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect)1