use of net.dzikoysk.funnyguilds.data.configs.MessagesConfig 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.MessagesConfig in project FunnyGuilds by FunnyGuilds.
the class WarUtils method message.
public static void message(Player player, int i, Object... values) {
MessagesConfig m = Messages.getInstance();
String message = null;
switch(i) {
case 0:
message = m.warHasNotGuild;
break;
case 1:
message = m.warAlly;
break;
case 2:
message = m.warWait;
message = StringUtils.replace(message, "{TIME}", TimeUtils.getDurationBreakdown((long) values[0]));
break;
case 3:
message = m.warAttacker;
message = StringUtils.replace(message, "{ATTACKED}", ((Guild) values[0]).getTag());
break;
case 4:
message = m.warAttacked;
message = StringUtils.replace(message, "{ATTACKER}", ((Guild) values[0]).getTag());
break;
}
player.sendMessage(message);
}
Aggregations