use of com.griefdefender.lib.flowpowered.math.vector.Vector3i in project BanFromClaim by Baktus79.
the class BfcAllCommandGD method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
MessageHandler.sendConsole("&cThis command can only be used in-game.");
return true;
}
final Player player = (Player) sender;
final Location loc = player.getLocation();
final Vector3i vector = Vector3i.from(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
final Core gd = GriefDefender.getCore();
final Claim claim = gd.getClaimManager(loc.getWorld().getUID()).getClaimAt(vector);
final ClaimData claimData = new ClaimData();
final boolean isManager = claim.getUserTrusts(TrustTypes.MANAGER).contains(player.getUniqueId());
final boolean isOwner = claim.getOwnerUniqueId().equals(player.getUniqueId());
boolean allowBan = false;
if (claim.isWilderness()) {
MessageHandler.sendMessage(player, Messages.OUTSIDE_CLAIM);
return true;
}
if (isOwner || isManager) {
allowBan = true;
} else if (player.hasPermission("bfc.admin")) {
allowBan = true;
}
if (allowBan) {
claimData.banAll(claim.getUniqueId().toString());
if (claimData.isAllBanned(claim.getUniqueId().toString())) {
MessageHandler.sendMessage(player, Messages.BAN_ALL);
} else {
MessageHandler.sendMessage(player, Messages.UNBAN_ALL);
}
} else {
MessageHandler.sendMessage(player, Messages.NO_ACCESS);
return true;
}
return true;
}
use of com.griefdefender.lib.flowpowered.math.vector.Vector3i in project BanFromClaim by Baktus79.
the class BfcCommandGD method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
MessageHandler.sendConsole("&cThis command can only be used in-game.");
return true;
}
final Player player = (Player) sender;
final Location loc = player.getLocation();
final Vector3i vector = Vector3i.from(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
final Core gd = GriefDefender.getCore();
final Claim claim = gd.getClaimManager(loc.getWorld().getUID()).getClaimAt(vector);
if (args.length == 0) {
MessageHandler.sendMessage(player, Messages.NO_ARGUMENTS);
return true;
}
if (claim.isWilderness()) {
MessageHandler.sendMessage(player, Messages.OUTSIDE_CLAIM);
return true;
}
@SuppressWarnings("deprecation") final OfflinePlayer bannedPlayer = Bukkit.getOfflinePlayer(args[0]);
final boolean isManager = claim.getUserTrusts(TrustTypes.MANAGER).contains(player.getUniqueId());
final boolean isOwner = claim.getOwnerUniqueId().equals(player.getUniqueId());
boolean allowBan = false;
if (isOwner || isManager) {
allowBan = true;
} else if (player.hasPermission("bfc.admin")) {
allowBan = true;
}
if (!bannedPlayer.hasPlayedBefore()) {
MessageHandler.sendMessage(player, Messages.placeholders(Messages.UNVALID_PLAYERNAME, args[0], player.getDisplayName(), null));
return true;
} else if (bannedPlayer == player) {
MessageHandler.sendMessage(player, Messages.BAN_SELF);
return true;
} else if (bannedPlayer.getName().equals(claim.getOwnerName())) {
MessageHandler.sendMessage(player, Messages.BAN_OWNER);
return true;
}
if (bannedPlayer.isOnline()) {
if (bannedPlayer.getPlayer().hasPermission("bfc.bypass")) {
MessageHandler.sendMessage(player, Messages.placeholders(Messages.PROTECTED, bannedPlayer.getPlayer().getDisplayName(), null, null));
return true;
}
}
if (!allowBan) {
MessageHandler.sendMessage(player, Messages.NO_ACCESS);
return true;
} else {
final String claimOwner = claim.getOwnerName();
final int sizeRadius = Math.max(claim.getLength(), claim.getWidth());
final Location greaterCorner = new Location(Bukkit.getWorld(claim.getWorldUniqueId()), claim.getGreaterBoundaryCorner().getX(), 64D, claim.getGreaterBoundaryCorner().getZ());
final Location lesserCorner = new Location(Bukkit.getWorld(claim.getWorldUniqueId()), claim.getLesserBoundaryCorner().getX(), 64D, claim.getLesserBoundaryCorner().getZ());
if (setClaimData(player, claim.getUniqueId().toString(), bannedPlayer.getUniqueId().toString(), true)) {
if (bannedPlayer.isOnline()) {
final Location bannedLoc = bannedPlayer.getPlayer().getLocation();
final Vector3i bannedVec = Vector3i.from(bannedLoc.getBlockX(), bannedLoc.getBlockY(), bannedLoc.getBlockZ());
if (claim.contains(bannedVec)) {
final LocationFinder lf = new LocationFinder(greaterCorner, lesserCorner, claim.getWorldUniqueId(), sizeRadius);
Bukkit.getScheduler().runTaskAsynchronously(BfcPlugin.getInstance(), () -> lf.IterateCircumferencesGD(randomCircumferenceRadiusLoc -> {
if (randomCircumferenceRadiusLoc == null) {
if (Config.SAFE_LOCATION == null) {
bannedPlayer.getPlayer().teleport(bannedLoc.getWorld().getSpawnLocation());
} else {
bannedPlayer.getPlayer().teleport(Config.SAFE_LOCATION);
}
} else {
bannedPlayer.getPlayer().teleport(randomCircumferenceRadiusLoc);
}
MessageHandler.sendMessage(bannedPlayer.getPlayer(), Messages.placeholders(Messages.BANNED_TARGET, bannedPlayer.getName(), player.getDisplayName(), claimOwner));
}));
}
}
MessageHandler.sendMessage(player, Messages.placeholders(Messages.BANNED, bannedPlayer.getName(), null, null));
} else {
MessageHandler.sendMessage(player, Messages.ALREADY_BANNED);
}
}
return true;
}
use of com.griefdefender.lib.flowpowered.math.vector.Vector3i in project BanFromClaim by Baktus79.
the class UnbfcCommandGD method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
MessageHandler.sendConsole("&cThis command can only be used in-game.");
return true;
}
final Player player = (Player) sender;
final Location loc = player.getLocation();
final Vector3i vector = Vector3i.from(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
final Core gd = GriefDefender.getCore();
final Claim claim = gd.getClaimManager(loc.getWorld().getUID()).getClaimAt(vector);
if (args.length == 0) {
MessageHandler.sendMessage(player, Messages.NO_ARGUMENTS);
return true;
}
if (claim.isWilderness()) {
MessageHandler.sendMessage(player, Messages.OUTSIDE_CLAIM);
return true;
}
final boolean isManager = claim.getUserTrusts(TrustTypes.MANAGER).contains(player.getUniqueId());
final boolean isOwner = claim.getOwnerUniqueId().equals(player.getUniqueId());
boolean allowBan = false;
if (isOwner || isManager) {
allowBan = true;
} else if (player.hasPermission("bfc.admin")) {
allowBan = true;
}
OfflinePlayer bPlayer = null;
if (!allowBan) {
MessageHandler.sendMessage(player, Messages.NO_ACCESS);
return true;
} else {
final String claimOwner = claim.getOwnerName();
final String claimID = claim.getUniqueId().toString();
if (listPlayers(claimID) != null) {
for (final String bp : listPlayers(claimID)) {
final OfflinePlayer bannedPlayer = Bukkit.getOfflinePlayer(UUID.fromString(bp));
if (bannedPlayer.getName().equalsIgnoreCase(args[0])) {
bPlayer = bannedPlayer;
if (setClaimData(player, claimID, bp, false)) {
MessageHandler.sendMessage(player, Messages.placeholders(Messages.UNBANNED, bannedPlayer.getName(), player.getDisplayName(), claimOwner));
if (bannedPlayer.isOnline()) {
MessageHandler.sendMessage(bannedPlayer.getPlayer(), Messages.placeholders(Messages.UNBANNED_TARGET, bannedPlayer.getName(), player.getDisplayName(), claimOwner));
}
return true;
}
}
}
}
}
if (bPlayer == null) {
MessageHandler.sendMessage(player, Messages.placeholders(Messages.NOT_BANNED, args[0], player.getDisplayName(), null));
}
return true;
}
use of com.griefdefender.lib.flowpowered.math.vector.Vector3i in project BanFromClaim by Baktus79.
the class BfclistCommandGD method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
MessageHandler.sendConsole("&cThis command can only be used in-game.");
return true;
}
final Player player = (Player) sender;
final Location loc = player.getLocation();
final Vector3i vector = Vector3i.from(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
final Core gd = GriefDefender.getCore();
final Claim claim = gd.getClaimManager(loc.getWorld().getUID()).getClaimAt(vector);
final ClaimData claimData = new ClaimData();
if (args.length != 0) {
if (isInt(args[0])) {
this.number = Integer.parseInt(args[0]);
this.countTo = 5 * number;
this.countFrom = 5 * number - 5;
} else {
MessageHandler.sendMessage(player, Messages.UNVALID_NUMBER);
return true;
}
}
if (claim.isWilderness()) {
MessageHandler.sendMessage(player, Messages.OUTSIDE_CLAIM);
return true;
}
final boolean isManager = claim.getUserTrusts(TrustTypes.MANAGER).contains(player.getUniqueId());
final boolean isOwner = claim.getOwnerUniqueId().equals(player.getUniqueId());
boolean allowBan = false;
if (isOwner || isManager) {
allowBan = true;
} else if (player.hasPermission("bfc.admin")) {
allowBan = true;
}
int totalPage = 1;
if (!allowBan) {
MessageHandler.sendMessage(player, Messages.NO_ACCESS);
return true;
} else {
MessageHandler.sendMessage(player, Messages.placeholders(Messages.LIST_HEADER, null, player.getDisplayName(), claim.getOwnerName()));
if (claimData.isAllBanned(claim.getUniqueId().toString())) {
MessageHandler.sendMessage(player, Messages.LIST_BAN_ALL);
return true;
}
if (listPlayers(claim.getUniqueId().toString()) == null) {
MessageHandler.sendMessage(player, Messages.placeholders(Messages.LIST_EMPTY, null, player.getDisplayName(), claim.getOwnerName()));
return true;
} else {
totalPage = listPlayers(claim.getUniqueId().toString()).size() / 5 + 1;
for (int i = 0; i < listPlayers(claim.getUniqueId().toString()).toArray().length; i++) {
if (this.number > totalPage || this.number == 0) {
this.countTo = 5 * totalPage;
this.countFrom = 5 * totalPage - 5;
this.number = totalPage;
}
if (i >= this.countFrom) {
final String bp = (String) listPlayers(claim.getUniqueId().toString()).toArray()[i];
final OfflinePlayer bannedPlayer = Bukkit.getOfflinePlayer(UUID.fromString(bp));
MessageHandler.sendMessage(player, "&6" + bannedPlayer.getName());
if (i == this.countTo) {
MessageHandler.sendMessage(player, "");
MessageHandler.sendMessage(player, "&e<--- [&6" + this.number + "\\" + totalPage + "&e] --->");
break;
}
continue;
}
}
if (this.number == totalPage) {
MessageHandler.sendMessage(player, "");
MessageHandler.sendMessage(player, "&e<--- [&6" + totalPage + "\\" + totalPage + "&e] --->");
}
}
}
return true;
}
use of com.griefdefender.lib.flowpowered.math.vector.Vector3i in project BanFromClaim by Baktus79.
the class KfcCommandGD method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
MessageHandler.sendConsole("&cThis command can only be used in-game.");
return true;
}
final Player player = (Player) sender;
final Location loc = player.getLocation();
final Vector3i vector = Vector3i.from(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
final Core gd = GriefDefender.getCore();
final Claim claim = gd.getClaimManager(loc.getWorld().getUID()).getClaimAt(vector);
if (args.length == 0) {
MessageHandler.sendMessage(player, Messages.NO_ARGUMENTS);
return true;
}
if (claim.isWilderness()) {
MessageHandler.sendMessage(player, Messages.OUTSIDE_CLAIM);
return true;
}
final Player kickedPlayer = Bukkit.getPlayer(args[0]);
final boolean isManager = claim.getUserTrusts(TrustTypes.MANAGER).contains(player.getUniqueId());
final boolean isOwner = claim.getOwnerUniqueId().equals(player.getUniqueId());
boolean allowKick = false;
if (isOwner || isManager) {
allowKick = true;
} else if (player.hasPermission("bfc.admin")) {
allowKick = true;
}
if (kickedPlayer == null) {
MessageHandler.sendMessage(player, Messages.placeholders(Messages.UNVALID_PLAYERNAME, args[0], player.getDisplayName(), null));
return true;
} else if (kickedPlayer == player) {
MessageHandler.sendMessage(player, Messages.KICK_SELF);
return true;
} else if (kickedPlayer.getName().equals(claim.getOwnerName())) {
MessageHandler.sendMessage(player, Messages.KICK_OWNER);
return true;
}
if (kickedPlayer.hasPermission("bfc.bypass")) {
MessageHandler.sendMessage(player, Messages.placeholders(Messages.PROTECTED, kickedPlayer.getDisplayName(), null, null));
return true;
}
if (!allowKick) {
MessageHandler.sendMessage(player, Messages.NO_ACCESS);
return true;
} else {
final int sizeRadius = Math.max(claim.getLength(), claim.getWidth());
final Location greaterCorner = new Location(Bukkit.getWorld(claim.getWorldUniqueId()), claim.getGreaterBoundaryCorner().getX(), 64D, claim.getGreaterBoundaryCorner().getZ());
final Location lesserCorner = new Location(Bukkit.getWorld(claim.getWorldUniqueId()), claim.getLesserBoundaryCorner().getX(), 64D, claim.getLesserBoundaryCorner().getZ());
final String claimOwner = claim.getOwnerName();
final Location kickedLoc = kickedPlayer.getLocation();
final Vector3i kickedVec = Vector3i.from(kickedLoc.getBlockX(), kickedLoc.getBlockY(), kickedLoc.getBlockZ());
if (claim.contains(kickedVec)) {
final LocationFinder lf = new LocationFinder(greaterCorner, lesserCorner, claim.getWorldUniqueId(), sizeRadius);
Bukkit.getScheduler().runTaskAsynchronously(BfcPlugin.getInstance(), () -> lf.IterateCircumferencesGD(randomCircumferenceRadiusLoc -> {
if (randomCircumferenceRadiusLoc == null) {
if (Config.SAFE_LOCATION == null) {
kickedPlayer.teleport(kickedLoc.getWorld().getSpawnLocation());
} else {
kickedPlayer.teleport(Config.SAFE_LOCATION);
}
} else {
kickedPlayer.teleport(randomCircumferenceRadiusLoc);
}
MessageHandler.sendMessage(kickedPlayer, Messages.placeholders(Messages.KICKED_TARGET, kickedPlayer.getName(), player.getDisplayName(), claimOwner));
}));
}
}
MessageHandler.sendMessage(player, Messages.placeholders(Messages.KICKED, kickedPlayer.getName(), null, null));
return true;
}
Aggregations