use of net.dzikoysk.funnyguilds.basic.User in project FunnyGuilds by FunnyGuilds.
the class ExcEscape method execute.
@Override
public void execute(CommandSender sender, String[] args) {
PluginConfig config = Settings.getConfig();
MessagesConfig messages = Messages.getInstance();
Player player = (Player) sender;
if (!config.regionsEnabled) {
player.sendMessage(messages.regionsDisabled);
return;
}
if (!config.escapeEnable || !config.baseEnable) {
player.sendMessage(messages.escapeDisabled);
return;
}
User user = User.get(player);
if (!user.hasGuild()) {
player.sendMessage(messages.escapeNoUserGuild);
return;
}
if (user.getTeleportation() != null) {
player.sendMessage(messages.escapeInProgress);
return;
}
Location playerLocation = player.getLocation();
Region region = RegionUtils.getAt(playerLocation);
if (region == null) {
player.sendMessage(messages.escapeNoNeedToRun);
return;
}
Guild guild = user.getGuild();
if (guild.equals(region.getGuild())) {
player.sendMessage(messages.escapeOnYourRegion);
return;
}
int time = Settings.getConfig().escapeDelay;
if (time < 1) {
player.teleport(guild.getHome());
player.sendMessage(messages.escapeSuccessfulUser);
for (User member : region.getGuild().getOnlineMembers()) {
member.getPlayer().sendMessage(messages.escapeSuccessfulOpponents.replace("{PLAYER}", player.getName()));
}
return;
}
player.sendMessage(messages.escapeStartedUser.replace("{TIME}", Integer.toString(time)));
String msg = messages.escapeStartedOpponents.replace("{TIME}", Integer.toString(time)).replace("{PLAYER}", player.getName()).replace("{X}", Integer.toString(playerLocation.getBlockX())).replace("{Y}", Integer.toString(playerLocation.getBlockY())).replace("{Z}", Integer.toString(playerLocation.getBlockZ()));
for (User member : region.getGuild().getOnlineMembers()) {
member.getPlayer().sendMessage(msg);
}
Location before = player.getLocation();
AtomicInteger i = new AtomicInteger(0);
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.escapeCancelled);
user.setTeleportation(null);
return;
}
if (i.getAndIncrement() > time) {
user.getTeleportation().cancel();
player.teleport(guild.getHome());
player.sendMessage(messages.escapeSuccessfulUser);
for (User member : region.getGuild().getOnlineMembers()) {
member.getPlayer().sendMessage(messages.escapeSuccessfulOpponents.replace("{PLAYER}", player.getName()));
}
user.setTeleportation(null);
}
}, 0L, 20L));
}
use of net.dzikoysk.funnyguilds.basic.User in project FunnyGuilds by FunnyGuilds.
the class FunnyGuilds method patch.
private void patch() {
PluginConfig config = Settings.getConfig();
for (final Player player : this.getServer().getOnlinePlayers()) {
this.getServer().getScheduler().runTask(this, () -> PacketExtension.registerPlayer(player));
User user = User.get(player);
user.getScoreboard();
user.getDummy();
user.getRank();
if (config.playerlistEnable) {
AbstractTablist.createTablist(config.playerList, config.playerListHeader, config.playerListFooter, config.playerListPing, player);
}
}
for (Guild guild : GuildUtils.getGuilds()) {
if (config.createEntityType != null) {
EntityUtil.spawn(guild);
}
guild.updateRank();
}
}
use of net.dzikoysk.funnyguilds.basic.User in project FunnyGuilds by FunnyGuilds.
the class AxcDeputy method execute.
@Override
public void execute(CommandSender sender, String[] args) {
MessagesConfig messages = Messages.getInstance();
if (args.length < 1) {
sender.sendMessage(messages.generalNoTagGiven);
return;
}
Guild guild = GuildUtils.getByTag(args[0]);
if (guild == null) {
sender.sendMessage(messages.generalNoGuildFound);
return;
}
if (args.length < 2) {
sender.sendMessage(messages.generalNoNickGiven);
return;
}
if (!UserUtils.playedBefore(args[1])) {
sender.sendMessage(messages.generalNotPlayedBefore);
return;
}
User user = User.get(args[1]);
Player player = user.getPlayer();
if (!guild.getMembers().contains(user)) {
sender.sendMessage(messages.adminUserNotMemberOf);
return;
}
User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
if (!SimpleEventHandler.handle(new GuildMemberDeputyEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, admin, guild, user))) {
return;
}
MessageTranslator translator = new MessageTranslator().register("{PLAYER}", user.getName());
if (user.isDeputy()) {
guild.removeDeputy(user);
sender.sendMessage(messages.deputyRemove);
if (player != null) {
player.sendMessage(messages.deputyMember);
}
String message = translator.translate(messages.deputyNoLongerMembers);
for (User member : guild.getOnlineMembers()) {
member.getPlayer().sendMessage(message);
}
return;
}
guild.addDeputy(user);
sender.sendMessage(messages.deputySet);
if (player != null) {
player.sendMessage(messages.deputyOwner);
}
String message = translator.translate(messages.deputyMembers);
for (User member : guild.getOnlineMembers()) {
member.getPlayer().sendMessage(message);
}
}
use of net.dzikoysk.funnyguilds.basic.User in project FunnyGuilds by FunnyGuilds.
the class AxcKick method execute.
@Override
public void execute(CommandSender sender, String[] args) {
MessagesConfig messages = Messages.getInstance();
if (args.length < 1) {
sender.sendMessage(messages.generalNoNickGiven);
return;
}
if (!UserUtils.playedBefore(args[0])) {
sender.sendMessage(messages.generalNotPlayedBefore);
return;
}
User user = User.get(args[0]);
if (!user.hasGuild()) {
sender.sendMessage(messages.generalPlayerHasNoGuild);
return;
}
if (user.isOwner()) {
sender.sendMessage(messages.adminGuildOwner);
return;
}
Guild guild = user.getGuild();
User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
if (!SimpleEventHandler.handle(new GuildMemberKickEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, admin, guild, user))) {
return;
}
// IndependentThread.action(ActionType.PREFIX_GLOBAL_REMOVE_PLAYER, user.getName());
ConcurrencyManager concurrencyManager = FunnyGuilds.getInstance().getConcurrencyManager();
concurrencyManager.postRequests(new PrefixGlobalRemovePlayerRequest(user.getName()));
Player player = user.getPlayer();
guild.removeMember(user);
user.removeGuild();
MessageTranslator translator = new MessageTranslator().register("{GUILD}", guild.getName()).register("{TAG}", guild.getTag()).register("{PLAYER}", user.getName());
if (player != null) {
// IndependentThread.action(ActionType.PREFIX_GLOBAL_UPDATE_PLAYER, player);
concurrencyManager.postRequests(new PrefixGlobalUpdatePlayer(player));
player.sendMessage(translator.translate(messages.kickToPlayer));
}
sender.sendMessage(translator.translate(messages.kickToOwner));
Bukkit.broadcastMessage(translator.translate(messages.broadcastKick));
}
use of net.dzikoysk.funnyguilds.basic.User in project FunnyGuilds by FunnyGuilds.
the class AxcKills method execute.
@Override
public void execute(CommandSender sender, String[] args) {
MessagesConfig messages = Messages.getInstance();
if (args.length < 1) {
sender.sendMessage(messages.generalNoNickGiven);
return;
}
if (!UserUtils.playedBefore(args[0])) {
sender.sendMessage(messages.generalNotPlayedBefore);
return;
}
if (args.length < 2) {
sender.sendMessage(messages.adminNoKillsGiven);
return;
}
int kills;
try {
kills = Integer.valueOf(args[1]);
} catch (NumberFormatException e) {
sender.sendMessage(messages.adminErrorInNumber.replace("{ERROR}", args[1]));
return;
}
User user = User.get(args[0]);
Rank userRank = user.getRank();
int change = kills - userRank.getDeaths();
User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
if (!SimpleEventHandler.handle(new KillsChangeEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, userRank, admin, change))) {
return;
}
user.getRank().setKills(kills);
sender.sendMessage(messages.adminKillsChanged.replace("{PLAYER}", user.getName()).replace("{KILLS}", Integer.toString(kills)));
}
Aggregations