use of net.dzikoysk.funnyguilds.data.configs.PluginConfig in project FunnyGuilds by FunnyGuilds.
the class EntityInteract method onInteract.
@EventHandler
public void onInteract(PlayerInteractEntityEvent event) {
PluginConfig config = Settings.getConfig();
Player eventCaller = event.getPlayer();
Entity clickedEntity = event.getRightClicked();
if (clickedEntity instanceof Player) {
Player clickedPlayer = (Player) clickedEntity;
if (!config.infoPlayerEnabled || (config.infoPlayerSneaking && !eventCaller.isSneaking()) || informationMessageCooldowns.cooldown(eventCaller, TimeUnit.SECONDS, config.infoPlayerCooldown)) {
return;
}
new ExcPlayer().execute(eventCaller, new String[] { clickedPlayer.getName() });
}
}
use of net.dzikoysk.funnyguilds.data.configs.PluginConfig 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.data.configs.PluginConfig 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);
}
use of net.dzikoysk.funnyguilds.data.configs.PluginConfig 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.data.configs.PluginConfig 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);
}
}
Aggregations