use of net.dzikoysk.funnyguilds.basic.Guild in project FunnyGuilds by FunnyGuilds.
the class PlayerChat method global.
private boolean global(AsyncPlayerChatEvent event, String message, PluginConfig c, Player player, Guild guild) {
String global = c.chatGlobal;
int length = global.length();
if (message.length() > length && message.substring(0, length).equals(global)) {
String format = c.chatGlobalDesign;
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 (Guild g : GuildUtils.getGuilds()) {
this.sendMessageToGuild(g, player, format);
}
this.spy(player, message);
event.setCancelled(true);
return true;
}
return false;
}
use of net.dzikoysk.funnyguilds.basic.Guild in project FunnyGuilds by FunnyGuilds.
the class FlatGuild method deserialize.
public static Guild deserialize(File file) {
PluginConfig config = Settings.getConfig();
Yamler pc = new Yamler(file);
String id = pc.getString("uuid");
String name = pc.getString("name");
String tag = pc.getString("tag");
String os = pc.getString("owner");
String dp = pc.getString("deputy");
String hs = pc.getString("home");
String region = pc.getString("region");
List<String> ms = pc.getStringList("members");
List<String> rgs = pc.getStringList("regions");
List<String> als = pc.getStringList("allies");
List<String> ens = pc.getStringList("enemies");
boolean pvp = pc.getBoolean("pvp");
long born = pc.getLong("born");
long validity = pc.getLong("validity");
long attacked = pc.getLong("attacked");
long ban = pc.getLong("ban");
int lives = pc.getInt("lives");
if (name == null) {
FunnyLogger.error("[Deserialize] Cannot deserialize guild! Caused by: name is null");
return null;
} else if (tag == null) {
FunnyLogger.error("[Deserialize] Cannot deserialize guild: " + name + "! Caused by: tag is null");
return null;
} else if (os == null) {
FunnyLogger.error("[Deserialize] Cannot deserialize guild: " + name + "! Caused by: owner is null");
return null;
} else if (region == null && config.regionsEnabled) {
FunnyLogger.error("[Deserialize] Cannot deserialize guild: " + name + "! Caused by: region is null");
return null;
}
Region rg = RegionUtils.get(region);
if (rg == null && config.regionsEnabled) {
FunnyLogger.error("[Deserialize] Cannot deserialize guild: " + name + "! Caused by: region (object) is null");
return null;
}
UUID uuid = UUID.randomUUID();
if (id != null) {
uuid = UUID.fromString(id);
}
User owner = User.get(os);
List<User> deputies = new ArrayList<>();
if (dp != null && !dp.isEmpty()) {
deputies = UserUtils.getUsers(StringUtils.fromString(dp));
}
Location home = null;
if (rg != null) {
home = rg.getCenter();
if (hs != null) {
home = Parser.parseLocation(hs);
}
}
if (ms == null || ms.isEmpty()) {
ms = new ArrayList<>();
ms.add(os);
}
List<User> members = UserUtils.getUsers(ms);
List<String> regions = new ArrayList<>();
if (rgs != null) {
for (String n : rgs) {
if (RegionUtils.get(n) != null) {
regions.add(n);
}
}
}
List<Guild> allies = new ArrayList<>();
if (als != null) {
for (String s : als) {
Guild guild = GuildUtils.getByName(s);
if (guild != null) {
allies.add(guild);
}
}
}
List<Guild> enemies = new ArrayList<>();
if (ens != null) {
for (String s : ens) {
Guild guild = GuildUtils.getByName(s);
if (guild != null) {
enemies.add(guild);
}
}
}
if (born == 0) {
born = System.currentTimeMillis();
}
if (validity == 0) {
validity = System.currentTimeMillis() + config.validityStart;
}
if (lives == 0) {
lives = config.warLives;
}
Object[] values = new Object[17];
values[0] = uuid;
values[1] = name;
values[2] = tag;
values[3] = owner;
values[4] = home;
values[5] = region;
values[6] = members;
values[7] = regions;
values[8] = allies;
values[9] = enemies;
values[10] = born;
values[11] = validity;
values[12] = attacked;
values[13] = lives;
values[14] = ban;
values[15] = deputies;
values[16] = pvp;
return DeserializationUtils.deserializeGuild(values);
}
use of net.dzikoysk.funnyguilds.basic.Guild in project FunnyGuilds by FunnyGuilds.
the class PlayerInteract method onInteract.
@EventHandler
public void onInteract(PlayerInteractEvent event) {
Action eventAction = event.getAction();
Player p = event.getPlayer();
if (eventAction == Action.RIGHT_CLICK_BLOCK || eventAction == Action.LEFT_CLICK_BLOCK) {
Block clicked = event.getClickedBlock();
if (RegionUtils.isIn(clicked.getLocation())) {
Region region = RegionUtils.getAt(clicked.getLocation());
Block heart = region.getCenter().getBlock().getRelative(BlockFace.DOWN);
if (clicked.equals(heart)) {
Guild g = region.getGuild();
if (SecuritySystem.getSecurity().checkPlayer(p, g)) {
return;
}
if (eventAction == Action.LEFT_CLICK_BLOCK) {
WarSystem.getInstance().attack(p, g);
event.setCancelled(true);
return;
} else if (eventAction == Action.RIGHT_CLICK_BLOCK) {
PluginConfig config = Settings.getConfig();
if (config.informationMessageCooldowns.cooldown(p, TimeUnit.SECONDS, config.infoPlayerCooldown)) {
return;
}
new ExcInfo().execute(p, new String[] { g.getTag() });
event.setCancelled(true);
return;
}
}
}
}
if (ProtectionUtils.action(eventAction, event.getClickedBlock())) {
event.setCancelled(false);
}
}
use of net.dzikoysk.funnyguilds.basic.Guild in project FunnyGuilds by FunnyGuilds.
the class IndividualPrefix method initialize.
private void initialize() {
if (getUser() == null) {
return;
}
List<Guild> guilds = GuildUtils.getGuilds();
Scoreboard scoreboard = getUser().getScoreboard();
Guild guild = getUser().getGuild();
if (guild != null) {
guilds.remove(guild);
PluginConfig config = Settings.getConfig();
String our = config.prefixOur;
String ally = config.prefixAllies;
String enemy = config.prefixEnemies;
String other = config.prefixOther;
Team team = scoreboard.getTeam(guild.getTag());
if (team == null) {
team = scoreboard.registerNewTeam(guild.getTag());
}
for (User u : guild.getMembers()) {
if (u.getName() == null) {
continue;
}
if (!team.hasEntry(u.getName())) {
team.addEntry(u.getName());
}
}
team.setPrefix(replace(our, "{TAG}", guild.getTag()));
for (Guild one : guilds) {
if (one == null || one.getTag() == null) {
continue;
}
team = scoreboard.getTeam(one.getTag());
if (team == null) {
team = scoreboard.registerNewTeam(one.getTag());
}
for (User u : one.getMembers()) {
if (u.getName() == null) {
continue;
}
if (!team.hasEntry(u.getName())) {
team.addEntry(u.getName());
}
}
if (guild.getAllies().contains(one)) {
team.setPrefix(replace(ally, "{TAG}", one.getTag()));
} else if (guild.getEnemies().contains(one)) {
team.setPrefix(replace(enemy, "{TAG}", one.getTag()));
} else {
team.setPrefix(replace(other, "{TAG}", one.getTag()));
}
}
} else {
String other = Settings.getConfig().prefixOther;
for (Guild one : guilds) {
if (one == null || one.getTag() == null) {
continue;
}
Team team = scoreboard.getTeam(one.getTag());
if (team == null) {
team = scoreboard.registerNewTeam(one.getTag());
}
for (User u : one.getMembers()) {
if (u.getName() == null) {
continue;
}
if (!team.hasEntry(u.getName())) {
team.addEntry(u.getName());
}
}
team.setPrefix(replace(other, "{TAG}", one.getTag()));
}
}
}
Aggregations