use of net.dzikoysk.funnyguilds.basic.User in project FunnyGuilds by FunnyGuilds.
the class MxcBase method execute.
@Override
public void execute(CommandSender sender, String[] args) {
MessagesConfig messages = Messages.getInstance();
Player player = (Player) sender;
User user = User.get(player);
if (!Settings.getConfig().regionsEnabled) {
player.sendMessage(messages.regionsDisabled);
return;
}
if (!user.hasGuild()) {
player.sendMessage(messages.generalHasNoGuild);
return;
}
if (!user.isOwner() && !user.isDeputy()) {
player.sendMessage(messages.generalIsNotOwner);
return;
}
Guild guild = user.getGuild();
Region region = RegionUtils.get(guild.getName());
Location loc = player.getLocation();
if (!region.isIn(loc)) {
player.sendMessage(messages.setbaseOutside);
return;
}
if (!SimpleEventHandler.handle(new GuildBaseChangeEvent(EventCause.USER, user, guild, loc))) {
return;
}
guild.setHome(loc);
if (guild.getHome().getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR) {
for (int i = guild.getHome().getBlockY(); i > 0; i--) {
guild.getHome().setY(i);
if (guild.getHome().getBlock().getType() != Material.AIR) {
break;
}
}
}
player.sendMessage(messages.setbaseDone);
}
use of net.dzikoysk.funnyguilds.basic.User in project FunnyGuilds by FunnyGuilds.
the class MxcPvP method execute.
@Override
public void execute(CommandSender sender, String[] args) {
MessagesConfig messages = Messages.getInstance();
Player player = (Player) sender;
User user = User.get(player);
if (!user.hasGuild()) {
player.sendMessage(messages.generalHasNoGuild);
return;
}
if (!user.isOwner() && !user.isDeputy()) {
player.sendMessage(messages.generalIsNotOwner);
return;
}
Guild guild = user.getGuild();
if (guild.getPvP()) {
guild.setPvP(false);
player.sendMessage(messages.pvpOff);
} else {
guild.setPvP(true);
player.sendMessage(messages.pvpOn);
}
}
use of net.dzikoysk.funnyguilds.basic.User in project FunnyGuilds by FunnyGuilds.
the class AxcDeaths 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.adminNoDeathsGiven);
return;
}
int deaths;
try {
deaths = 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 = deaths - userRank.getDeaths();
User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
if (!SimpleEventHandler.handle(new DeathsChangeEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, userRank, admin, change))) {
return;
}
userRank.setDeaths(deaths);
sender.sendMessage(messages.adminDeathsChanged.replace("{PLAYER}", user.getName()).replace("{DEATHS}", Integer.toString(deaths)));
}
use of net.dzikoysk.funnyguilds.basic.User in project FunnyGuilds by FunnyGuilds.
the class AxcDelete 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;
}
User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
if (!SimpleEventHandler.handle(new GuildDeleteEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, admin, guild))) {
return;
}
GuildUtils.deleteGuild(guild);
Player owner = guild.getOwner().getPlayer();
MessageTranslator translator = new MessageTranslator().register("{GUILD}", guild.getName()).register("{TAG}", guild.getTag()).register("{ADMIN}", sender.getName()).register("{PLAYER}", sender.getName());
if (owner != null) {
owner.sendMessage(translator.translate(messages.adminGuildBroken));
}
sender.sendMessage(translator.translate(messages.deleteSuccessful));
Bukkit.getServer().broadcastMessage(translator.translate(messages.broadcastDelete));
}
use of net.dzikoysk.funnyguilds.basic.User in project FunnyGuilds by FunnyGuilds.
the class AxcLeader 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]);
if (!guild.getMembers().contains(user)) {
sender.sendMessage(messages.adminUserNotMemberOf);
return;
}
if (guild.getOwner().equals(user)) {
sender.sendMessage(messages.adminAlreadyLeader);
return;
}
User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
if (!SimpleEventHandler.handle(new GuildMemberLeaderEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, admin, guild, user))) {
return;
}
Player leaderPlayer = user.getPlayer();
guild.setOwner(user);
sender.sendMessage(messages.leaderSet);
if (leaderPlayer != null) {
leaderPlayer.sendMessage(messages.leaderOwner);
}
String message = messages.leaderMembers.replace("{PLAYER}", user.getName());
for (User member : guild.getOnlineMembers()) {
member.getPlayer().sendMessage(message);
}
}
Aggregations