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!");
}
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();
}
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.");
}
}
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());
}
}
}
}
Aggregations