use of net.dzikoysk.funnyguilds.basic.User in project FunnyGuilds by FunnyGuilds.
the class WarSystem method conquer.
public void conquer(Guild conqueror, Guild loser, User attacker) {
if (!SimpleEventHandler.handle(new GuildDeleteEvent(EventCause.SYSTEM, attacker, loser))) {
loser.addLive();
return;
}
String message = WarUtils.getWinMessage(conqueror, loser);
for (User user : conqueror.getMembers()) {
Player player = user.getPlayer();
if (player != null) {
player.sendMessage(message);
}
}
message = WarUtils.getLoseMessage(conqueror, loser);
for (User user : loser.getMembers()) {
Player player = user.getPlayer();
if (player != null) {
player.sendMessage(message);
}
}
GuildUtils.deleteGuild(loser);
conqueror.addLive();
message = WarUtils.getBroadcastMessage(conqueror, loser);
Bukkit.broadcastMessage(message);
}
use of net.dzikoysk.funnyguilds.basic.User 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());
}
}
use of net.dzikoysk.funnyguilds.basic.User in project FunnyGuilds by FunnyGuilds.
the class PlayerChat method onChat.
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
User user = User.get(player);
PluginConfig c = Settings.getConfig();
if (user.hasGuild()) {
Guild guild = user.getGuild();
String message = event.getMessage();
if (chat(event, message, c, player, guild)) {
return;
}
}
int points = user.getRank().getPoints();
String format = event.getFormat();
format = StringUtils.replace(format, "{RANK}", StringUtils.replace(c.chatRank, "{RANK}", String.valueOf(user.getRank().getPosition())));
format = StringUtils.replace(format, "{POINTS}", c.chatPoints);
format = StringUtils.replace(format, "{POINTS-FORMAT}", IntegerRange.inRange(points, c.pointsFormat));
format = StringUtils.replace(format, "{POINTS}", String.valueOf(points));
if (user.hasGuild()) {
format = StringUtils.replace(format, "{TAG}", StringUtils.replace(c.chatGuild, "{TAG}", user.getGuild().getTag()));
format = StringUtils.replace(format, "{POS}", StringUtils.replace(c.chatPosition, "{POS}", getPositionString(user, c)));
} else {
format = StringUtils.replace(format, "{TAG}", "");
format = StringUtils.replace(format, "{POS}", "");
}
event.setFormat(format);
}
use of net.dzikoysk.funnyguilds.basic.User in project FunnyGuilds by FunnyGuilds.
the class PlayerChat method ally.
private boolean ally(AsyncPlayerChatEvent event, String message, PluginConfig c, Player player, Guild guild) {
String ally = c.chatAlly;
int length = ally.length();
if (message.length() > length && message.substring(0, length).equals(ally)) {
String format = c.chatAllyDesign;
format = StringUtils.replace(format, "{PLAYER}", player.getName());
format = StringUtils.replace(format, "{TAG}", guild.getTag());
format = StringUtils.replace(format, "{POS}", StringUtils.replace(c.chatPosition, "{POS}", getPositionString(User.get(player), c)));
String subMessage = event.getMessage().substring(length);
this.spy(player, subMessage);
format = StringUtils.replace(format, "{MESSAGE}", subMessage);
for (User u : guild.getMembers()) {
Player p = u.getPlayer();
if (p != null) {
p.sendMessage(format);
}
}
for (Guild g : guild.getAllies()) {
this.sendMessageToGuild(g, player, format);
}
event.setCancelled(true);
return true;
}
return false;
}
use of net.dzikoysk.funnyguilds.basic.User in project FunnyGuilds by FunnyGuilds.
the class PlayerJoin method onJoin.
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
User user = User.get(player);
PluginConfig config = Settings.getConfig();
if (config.playerlistEnable && !AbstractTablist.hasTablist(player)) {
AbstractTablist.createTablist(config.playerList, config.playerListHeader, config.playerListFooter, config.playerListPing, player);
}
user.getScoreboard();
/*
IndependentThread.actions(ActionType.PREFIX_GLOBAL_UPDATE_PLAYER, player);
IndependentThread.actions(ActionType.DUMMY_GLOBAL_UPDATE_USER, user);
IndependentThread.actions(ActionType.RANK_UPDATE_USER, user);
*/
ConcurrencyManager concurrencyManager = FunnyGuilds.getInstance().getConcurrencyManager();
concurrencyManager.postRequests(new PrefixGlobalUpdatePlayer(player), new DummyGlobalUpdateUserRequest(user), new RankUpdateUserRequest(user));
this.plugin.getServer().getScheduler().runTaskLaterAsynchronously(this.plugin, () -> {
PacketExtension.registerPlayer(player);
Version.isNewAvailable(player, false);
Region region = RegionUtils.getAt(player.getLocation());
if (region == null || region.getGuild() == null) {
return;
}
if (config.createEntityType != null) {
EntityUtil.spawn(region.getGuild(), player);
}
}, 30L);
}
Aggregations