use of net.dzikoysk.funnyguilds.data.configs.PluginConfig in project FunnyGuilds by FunnyGuilds.
the class RegionUtils method isNear.
public static boolean isNear(Location center) {
if (center == null) {
return false;
}
PluginConfig s = Settings.getConfig();
int i = s.regionSize;
if (s.enlargeItems != null) {
i += (s.enlargeItems.size() * s.enlargeSize);
}
int requiredDistance = (2 * i) + s.regionMinDistance;
for (Region region : REGION_LIST) {
if (region.getCenter() == null) {
continue;
}
if (region.getCenter().equals(center)) {
continue;
}
if (!center.getWorld().equals(region.getCenter().getWorld())) {
continue;
}
if (center.distance(region.getCenter()) < requiredDistance) {
return true;
}
}
return false;
}
use of net.dzikoysk.funnyguilds.data.configs.PluginConfig in project FunnyGuilds by FunnyGuilds.
the class ExcBase method execute.
@Override
public void execute(CommandSender sender, String[] args) {
PluginConfig config = Settings.getConfig();
MessagesConfig messages = Messages.getInstance();
Player player = (Player) sender;
User user = User.get(player);
if (!config.regionsEnabled) {
player.sendMessage(messages.regionsDisabled);
return;
}
if (!config.baseEnable) {
player.sendMessage(messages.baseTeleportationDisabled);
return;
}
if (!user.hasGuild()) {
player.sendMessage(messages.generalHasNoGuild);
return;
}
Guild guild = user.getGuild();
if (user.getTeleportation() != null) {
player.sendMessage(messages.baseIsTeleportation);
return;
}
Collection<ItemStack> requiredItems = config.baseItems;
for (ItemStack requiredItem : requiredItems) {
if (player.getInventory().containsAtLeast(requiredItem, requiredItem.getAmount())) {
continue;
}
String msg = ItemUtils.translatePlaceholder(messages.baseItems, requiredItems, requiredItem);
player.sendMessage(msg);
return;
}
ItemStack[] items = ItemUtils.toArray(requiredItems);
player.getInventory().removeItem(items);
if (config.baseDelay < 1) {
player.teleport(guild.getHome());
player.sendMessage(messages.baseTeleport);
return;
}
int time = config.baseDelay;
Location before = player.getLocation();
AtomicInteger i = new AtomicInteger(1);
user.setTeleportation(Bukkit.getScheduler().runTaskTimer(FunnyGuilds.getInstance(), () -> {
if (!player.isOnline()) {
user.getTeleportation().cancel();
user.setTeleportation(null);
return;
}
if (!LocationUtils.equals(player.getLocation(), before)) {
user.getTeleportation().cancel();
player.sendMessage(messages.baseMove);
user.setTeleportation(null);
player.getInventory().addItem(items);
return;
}
if (i.getAndIncrement() > time) {
user.getTeleportation().cancel();
player.sendMessage(messages.baseTeleport);
player.teleport(guild.getHome());
user.setTeleportation(null);
}
}, 0L, 20L));
player.sendMessage(messages.baseDontMove.replace("{TIME}", Integer.toString(time)));
}
use of net.dzikoysk.funnyguilds.data.configs.PluginConfig in project FunnyGuilds by FunnyGuilds.
the class ExcPlayer method execute.
@Override
public void execute(CommandSender sender, String[] args) {
MessagesConfig messages = Messages.getInstance();
PluginConfig config = Settings.getConfig();
if (args.length == 0 && !(sender instanceof Player)) {
sender.sendMessage(messages.playerOnly);
return;
}
String name = args.length == 0 ? sender.getName() : args[0];
if (!UserUtils.playedBefore(name, config.playerLookupIgnorecase)) {
sender.sendMessage(messages.playerInfoExists);
return;
}
User user = UserUtils.get(name, config.playerLookupIgnorecase);
if (user == null) {
sender.sendMessage(messages.playerInfoExists);
return;
}
Rank rank = user.getRank();
for (String messageLine : messages.playerInfoList) {
if (user.hasGuild()) {
messageLine = StringUtils.replace(messageLine, "{GUILD}", user.getGuild().getName());
messageLine = StringUtils.replace(messageLine, "{TAG}", user.getGuild().getTag());
} else {
messageLine = StringUtils.replace(messageLine, "{GUILD}", messages.gNameNoValue);
messageLine = StringUtils.replace(messageLine, "{TAG}", messages.gTagNoValue);
}
messageLine = StringUtils.replace(messageLine, "{PLAYER}", user.getName());
messageLine = StringUtils.replace(messageLine, "{POINTS-FORMAT}", IntegerRange.inRange(rank.getPoints(), config.pointsFormat));
messageLine = StringUtils.replace(messageLine, "{POINTS}", Integer.toString(rank.getPoints()));
messageLine = StringUtils.replace(messageLine, "{KILLS}", Integer.toString(rank.getKills()));
messageLine = StringUtils.replace(messageLine, "{DEATHS}", Integer.toString(rank.getDeaths()));
messageLine = StringUtils.replace(messageLine, "{KDR}", String.format(Locale.US, "%.2f", rank.getKDR()));
messageLine = StringUtils.replace(messageLine, "{RANK}", Integer.toString(rank.getPosition()));
sender.sendMessage(messageLine);
}
}
use of net.dzikoysk.funnyguilds.data.configs.PluginConfig in project FunnyGuilds by FunnyGuilds.
the class ExcRankReset method execute.
@Override
public void execute(CommandSender sender, String[] args) {
PluginConfig config = Settings.getConfig();
MessagesConfig messages = Messages.getInstance();
Player player = (Player) sender;
List<ItemStack> requiredItems = config.rankResetItems;
for (ItemStack requiredItem : requiredItems) {
if (player.getInventory().containsAtLeast(requiredItem, requiredItem.getAmount())) {
continue;
}
String msg = ItemUtils.translatePlaceholder(messages.createItems, requiredItems, requiredItem);
player.sendMessage(msg);
return;
}
User user = User.get(player);
if (user != null) {
int lastRank = user.getRank().getPoints();
user.getRank().setPoints(config.rankStart);
player.getInventory().removeItem(ItemUtils.toArray(requiredItems));
String resetMessage = messages.rankResetMessage;
resetMessage = StringUtils.replace(resetMessage, "{LAST-RANK}", String.valueOf(lastRank));
resetMessage = StringUtils.replace(resetMessage, "{CURRENT-RANK}", String.valueOf(user.getRank().getPoints()));
player.sendMessage(resetMessage);
}
}
use of net.dzikoysk.funnyguilds.data.configs.PluginConfig in project FunnyGuilds by FunnyGuilds.
the class AxcName method execute.
@Override
public void execute(CommandSender sender, String[] args) {
MessagesConfig messages = Messages.getInstance();
PluginConfig config = Settings.getConfig();
if (args.length < 1) {
sender.sendMessage(messages.generalNoTagGiven);
return;
} else if (args.length < 2) {
sender.sendMessage(messages.adminNoNewNameGiven);
return;
}
Guild guild = GuildUtils.getByTag(args[0]);
if (guild == null) {
sender.sendMessage(messages.generalNoGuildFound);
return;
}
if (GuildUtils.nameExists(args[1])) {
sender.sendMessage(messages.createNameExists);
return;
}
User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
if (!SimpleEventHandler.handle(new GuildRenameEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, admin, guild, args[1]))) {
return;
}
Manager.getInstance().stop();
PluginConfig.DataType dataType = Settings.getConfig().dataType;
if (config.regionsEnabled) {
Region region = RegionUtils.get(guild.getRegion());
if (dataType.flat) {
Flat.getRegionFile(region).delete();
}
if (dataType.mysql) {
new DatabaseRegion(region).delete();
}
region.setName(args[1]);
}
if (dataType.flat) {
Flat.getGuildFile(guild).delete();
}
if (dataType.mysql) {
new DatabaseGuild(guild).delete();
}
guild.setName(args[1]);
Manager.getInstance().start();
sender.sendMessage(messages.adminNameChanged.replace("{GUILD}", guild.getName()));
}
Aggregations