use of net.dzikoysk.funnyguilds.data.configs.PluginConfig in project FunnyGuilds by FunnyGuilds.
the class FunnyGuilds method onLoad.
@Override
public void onLoad() {
if (!this.getDataFolder().exists()) {
this.getDataFolder().mkdir();
}
DescriptionManager descriptionManager = new DescriptionManager(super.getDescription());
version = descriptionManager.extractVersion();
PluginConfig settings = Settings.getConfig();
descriptionManager.rename(settings.pluginName);
this.concurrencyManager = new ConcurrencyManager(settings.concurrencyThreads);
this.concurrencyManager.printStatus();
this.reloadHandler = new ReloadHandler();
this.reloadHandler.init();
Commands commands = new Commands();
commands.register();
this.eventManager = new EventManager();
this.eventManager.load();
}
use of net.dzikoysk.funnyguilds.data.configs.PluginConfig in project FunnyGuilds by FunnyGuilds.
the class FunnyGuilds method onEnable.
@Override
public void onEnable() {
new ScoreboardStack(this).start();
new Manager().start();
new MetricsCollector(this).start();
AsynchronouslyRepeater repeater = AsynchronouslyRepeater.getInstance();
repeater.start();
PluginManager pluginManager = Bukkit.getPluginManager();
PluginConfig config = Settings.getConfig();
pluginManager.registerEvents(new GuiActionHandler(), this);
pluginManager.registerEvents(new EntityDamage(), this);
pluginManager.registerEvents(new EntityInteract(), this);
pluginManager.registerEvents(new PlayerChat(), this);
pluginManager.registerEvents(new PlayerDeath(), this);
pluginManager.registerEvents(new PlayerJoin(this), this);
pluginManager.registerEvents(new PlayerKick(), this);
pluginManager.registerEvents(new PlayerLogin(), this);
pluginManager.registerEvents(new PlayerQuit(), this);
if (config.regionsEnabled) {
pluginManager.registerEvents(new BlockBreak(), this);
pluginManager.registerEvents(new BlockIgnite(), this);
pluginManager.registerEvents(new BlockPlace(), this);
pluginManager.registerEvents(new BucketAction(), this);
pluginManager.registerEvents(new EntityExplode(), this);
pluginManager.registerEvents(new HangingBreak(), this);
pluginManager.registerEvents(new HangingPlace(), this);
pluginManager.registerEvents(new PlayerCommand(), this);
pluginManager.registerEvents(new PlayerInteract(), this);
if (config.eventMove) {
pluginManager.registerEvents(new PlayerMove(), this);
}
if (config.eventPhysics) {
pluginManager.registerEvents(new BlockPhysics(), this);
}
}
this.eventManager.enable();
this.patch();
Version.isNewAvailable(getServer().getConsoleSender(), true);
PluginHook.init();
FunnyLogger.info("~ Created by FunnyGuilds Team ~");
}
use of net.dzikoysk.funnyguilds.data.configs.PluginConfig in project FunnyGuilds by FunnyGuilds.
the class PlayerMove method onMove.
@EventHandler
public void onMove(PlayerMoveEvent event) {
final Location from = event.getFrom();
final Location to = event.getTo();
final Player player = event.getPlayer();
PluginConfig config = Settings.getConfig();
MessagesConfig messages = Messages.getInstance();
Bukkit.getScheduler().runTaskAsynchronously(FunnyGuilds.getInstance(), () -> {
if (from == null || to == null) {
return;
}
if (from.getBlockX() == to.getBlockX() && from.getBlockZ() == to.getBlockZ()) {
return;
}
User user = User.get(player);
Region region = RegionUtils.getAt(to);
if (region == null && user.getEnter()) {
user.setEnter(false);
region = RegionUtils.getAt(from);
if (region != null) {
Guild guild = region.getGuild();
FunnyGuilds.getInstance().getServer().getScheduler().runTaskLaterAsynchronously(FunnyGuilds.getInstance(), () -> {
if (config.createEntityType != null) {
EntityUtil.despawn(guild, player);
}
}, 40L);
MessageTranslator translator = new MessageTranslator().register("{GUILD}", guild.getName()).register("{TAG}", guild.getTag());
if (config.regionEnterNotificationStyle.contains(NotificationStyle.ACTIONBAR)) {
PacketSender.sendPacket(player, NotificationUtil.createActionbarNotification(translator.translate(messages.notificationActionbarLeaveGuildRegion)));
}
if (config.regionEnterNotificationStyle.contains(NotificationStyle.BOSSBAR)) {
NotificationBar.set(player, translator.translate(messages.notificationBossbarLeaveGuildRegion), 1, config.regionNotificationTime);
}
if (config.regionEnterNotificationStyle.contains(NotificationStyle.CHAT)) {
player.sendMessage(translator.translate(messages.notificationChatLeaveGuildRegion));
}
if (config.regionEnterNotificationStyle.contains(NotificationStyle.TITLE)) {
PacketSender.sendPacket(player, NotificationUtil.createTitleNotification(translator.translate(messages.notificationTitleLeaveGuildRegion), translator.translate(messages.notificationSubtitleLeaveGuildRegion), config.notificationTitleFadeIn, config.notificationTitleStay, config.notificationTitleFadeOut));
}
}
} else if (!user.getEnter() && region != null) {
Guild guild = region.getGuild();
if (guild == null || guild.getName() == null) {
return;
}
user.setEnter(true);
FunnyGuilds.getInstance().getServer().getScheduler().runTaskLaterAsynchronously(FunnyGuilds.getInstance(), () -> {
if (config.createEntityType != null) {
EntityUtil.spawn(guild, player);
}
}, 40L);
MessageTranslator translator = new MessageTranslator().register("{GUILD}", guild.getName()).register("{TAG}", guild.getTag());
if (config.regionEnterNotificationStyle.contains(NotificationStyle.ACTIONBAR)) {
PacketSender.sendPacket(player, NotificationUtil.createActionbarNotification(translator.translate(messages.notificationActionbarEnterGuildRegion)));
}
if (config.regionEnterNotificationStyle.contains(NotificationStyle.BOSSBAR)) {
NotificationBar.set(player, translator.translate(messages.notificationBossbarEnterGuildRegion), 1, config.regionNotificationTime);
}
if (config.regionEnterNotificationStyle.contains(NotificationStyle.CHAT)) {
player.sendMessage(translator.translate(messages.notificationChatEnterGuildRegion));
}
if (config.regionEnterNotificationStyle.contains(NotificationStyle.TITLE)) {
PacketSender.sendPacket(player, NotificationUtil.createTitleNotification(translator.translate(messages.notificationTitleEnterGuildRegion), translator.translate(messages.notificationSubtitleEnterGuildRegion), config.notificationTitleFadeIn, config.notificationTitleStay, config.notificationTitleFadeOut));
}
if (player.hasPermission("funnyguilds.admin.notification")) {
return;
}
if (user.getNotificationTime() > 0 && System.currentTimeMillis() < user.getNotificationTime()) {
return;
}
if (!config.regionEnterNotificationGuildMember && user.getGuild() != null && guild.getTag().equals(user.getGuild().getTag())) {
return;
}
translator = new MessageTranslator().register("{PLAYER}", player.getName());
for (User u : guild.getOnlineMembers()) {
if (u == null) {
continue;
}
Player member = u.getPlayer();
if (member == null || !member.isOnline()) {
continue;
}
if (config.regionEnterNotificationStyle.contains(NotificationStyle.ACTIONBAR)) {
PacketSender.sendPacket(member, NotificationUtil.createActionbarNotification(translator.translate(messages.notificationActionbarIntruderEnterGuildRegion)));
}
if (config.regionEnterNotificationStyle.contains(NotificationStyle.BOSSBAR)) {
NotificationBar.set(member, translator.translate(messages.notificationBossbarIntruderEnterGuildRegion), 1, config.regionNotificationTime);
}
if (config.regionEnterNotificationStyle.contains(NotificationStyle.CHAT)) {
member.sendMessage(translator.translate(messages.notificationChatIntruderEnterGuildRegion));
}
if (config.regionEnterNotificationStyle.contains(NotificationStyle.TITLE)) {
PacketSender.sendPacket(member, NotificationUtil.createTitleNotification(translator.translate(messages.notificationTitleIntruderEnterGuildRegion), translator.translate(messages.notificationSubtitleIntruderEnterGuildRegion), config.notificationTitleFadeIn, config.notificationTitleStay, config.notificationTitleFadeOut));
}
}
user.setNotificationTime(System.currentTimeMillis() + 1000 * config.regionNotificationCooldown);
}
});
}
use of net.dzikoysk.funnyguilds.data.configs.PluginConfig in project FunnyGuilds by FunnyGuilds.
the class Parser method parseRank.
public static String parseRank(String var) {
if (!var.contains("TOP-")) {
return null;
}
int i = getIndex(var);
if (i <= 0) {
FunnyLogger.error("Index in TOP- must be greater or equal to 1!");
return null;
}
PluginConfig c = Settings.getConfig();
List<Guild> rankedGuilds = new ArrayList<>();
for (int in = 1; in <= RankManager.getInstance().guilds(); in++) {
Guild guild = RankManager.getInstance().getGuild(in);
if (guild != null && guild.getMembers().size() >= c.minMembersToInclude) {
rankedGuilds.add(guild);
}
}
if (var.contains("GTOP")) {
if (rankedGuilds.isEmpty() || i - 1 >= rankedGuilds.size()) {
return StringUtils.replace(var, "{GTOP-" + i + '}', Messages.getInstance().gtopNoValue);
} else {
Guild guild = rankedGuilds.get(i - 1);
int points = guild.getRank().getPoints();
String pointsFormat = c.gtopPoints;
if (!pointsFormat.isEmpty()) {
pointsFormat = pointsFormat.replace("{POINTS-FORMAT}", IntegerRange.inRange(points, c.pointsFormat));
pointsFormat = pointsFormat.replace("{POINTS}", String.valueOf(points));
}
return StringUtils.replace(var, "{GTOP-" + i + '}', guild.getTag() + pointsFormat);
}
} else if (var.contains("PTOP")) {
User user = RankManager.getInstance().getUser(i);
if (user != null) {
int points = user.getRank().getPoints();
String pointsFormat = c.ptopPoints;
if (!pointsFormat.isEmpty()) {
pointsFormat = pointsFormat.replace("{POINTS-FORMAT}", IntegerRange.inRange(points, c.pointsFormat));
pointsFormat = pointsFormat.replace("{POINTS}", String.valueOf(points));
}
return StringUtils.replace(var, "{PTOP-" + i + '}', (user.isOnline() ? c.ptopOnline : c.ptopOffline) + user.getName() + pointsFormat);
} else {
return StringUtils.replace(var, "{PTOP-" + i + '}', Messages.getInstance().ptopNoValue);
}
}
return null;
}
use of net.dzikoysk.funnyguilds.data.configs.PluginConfig in project FunnyGuilds by FunnyGuilds.
the class EntityDamage method onDamage.
@EventHandler(priority = EventPriority.HIGHEST)
public void onDamage(EntityDamageByEntityEvent event) {
Entity entity = event.getEntity();
Entity damager = event.getDamager();
if (!(entity instanceof Player)) {
return;
}
Player attacker = null;
if (damager instanceof Player) {
attacker = (Player) damager;
} else if (damager instanceof Projectile) {
ProjectileSource shooter = ((Projectile) damager).getShooter();
if (shooter instanceof Player) {
attacker = (Player) shooter;
}
}
if (attacker == null) {
return;
}
PluginConfig config = Settings.getConfig();
User victimUser = User.get((Player) event.getEntity());
User attackerUser = User.get(attacker);
if (victimUser.hasGuild() && attackerUser.hasGuild()) {
if (victimUser.getUUID().equals(attackerUser.getUUID())) {
return;
}
if (victimUser.getGuild().equals(attackerUser.getGuild())) {
if (!victimUser.getGuild().getPvP()) {
event.setCancelled(true);
return;
}
}
if (victimUser.getGuild().getAllies().contains(attackerUser.getGuild())) {
if (!config.damageAlly) {
event.setCancelled(true);
return;
}
}
}
if (config.assistEnable && !event.isCancelled()) {
victimUser.addDamage(attackerUser, event.getDamage());
}
}
Aggregations