Promote, kick, and admin command bugs fixed.
This commit is contained in:
@@ -36,10 +36,7 @@ public class CmdAdmin extends FCommand {
|
||||
if (fyou == null) {
|
||||
return;
|
||||
}
|
||||
if (fme.getRole() == Role.ADMIN){
|
||||
fme.msg(TL.COMMAND_ADMIN_NOTADMIN);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean permAny = Permission.ADMIN_ANY.has(sender, false);
|
||||
Faction targetFaction = fyou.getFaction();
|
||||
|
||||
@@ -47,20 +44,17 @@ public class CmdAdmin extends FCommand {
|
||||
msg(TL.COMMAND_ADMIN_NOTMEMBER, fyou.describeTo(fme, true));
|
||||
return;
|
||||
}
|
||||
if ((fyou == fme && fme.getRole() == Role.COLEADER) || (fme.getRole() == Role.COLEADER && fyou.getRole() == Role.ADMIN)){
|
||||
msg(TL.COMMAND_ADMIN_NOTADMIN);
|
||||
return;
|
||||
}
|
||||
|
||||
if (fme != null && fme.getRole() != Role.ADMIN && !permAny) {
|
||||
msg(TL.COMMAND_ADMIN_NOTADMIN);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (fyou == fme && !permAny) {
|
||||
msg(TL.COMMAND_ADMIN_TARGETSELF);
|
||||
return;
|
||||
}
|
||||
|
||||
// only perform a FPlayerJoinEvent when newLeader isn't actually in the faction
|
||||
if (fyou.getFaction() != targetFaction) {
|
||||
FPlayerJoinEvent event = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(me), targetFaction, FPlayerJoinEvent.PlayerJoinReason.LEADER);
|
||||
@@ -70,23 +64,19 @@ public class CmdAdmin extends FCommand {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
FPlayer admin = targetFaction.getFPlayerAdmin();
|
||||
|
||||
// if target player is currently admin, demote and replace him
|
||||
if (fyou == admin && fyou.getFaction().getSize() == 1){
|
||||
msg(TL.COMMAND_ADMIN_NOMEMBERS);
|
||||
return;
|
||||
}
|
||||
if (fyou == admin) {
|
||||
targetFaction.promoteNewLeader();
|
||||
msg(TL.COMMAND_ADMIN_DEMOTES, fyou.describeTo(fme, true));
|
||||
fyou.msg(TL.COMMAND_ADMIN_DEMOTED, senderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fyou, true));
|
||||
return;
|
||||
}
|
||||
|
||||
// promote target player, and demote existing admin if one exists
|
||||
if (admin != null) {
|
||||
admin.setRole(Role.COLEADER);
|
||||
admin.setRole(Role.MODERATOR);
|
||||
}
|
||||
fyou.setRole(Role.ADMIN);
|
||||
msg(TL.COMMAND_ADMIN_PROMOTES, fyou.describeTo(fme, true));
|
||||
|
||||
121
src/main/java/com/massivecraft/factions/cmd/CmdBanner.java
Normal file
121
src/main/java/com/massivecraft/factions/cmd/CmdBanner.java
Normal file
@@ -0,0 +1,121 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
public class CmdBanner extends FCommand {
|
||||
public CmdBanner() {
|
||||
super();
|
||||
|
||||
this.aliases.add("banner");
|
||||
this.aliases.add("warbanner");
|
||||
|
||||
this.permission = Permission.BANNER.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeColeader = true;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
if (me.getItemInHand().getType() == Material.BANNER) {
|
||||
if (hasMoney(fme, P.p.getConfig().getInt("fbanners.Banner-Cost"))) {
|
||||
if (me.getItemInHand().getAmount() != 1) {
|
||||
me.getItemInHand().setAmount(me.getItemInHand().getAmount() - 1);
|
||||
}
|
||||
ItemStack bannerInHand = me.getItemInHand();
|
||||
bannerInHand.setAmount(1);
|
||||
removeFromInventory(me.getInventory(), bannerInHand);
|
||||
takeMoney(fme, P.p.getConfig().getInt("fbanners.Banner-Cost"));
|
||||
ItemStack warBanner = P.p.createItem(bannerInHand.getType(), 1, bannerInHand.getDurability(), P.p.getConfig().getString("fbanners.Item.Name"), P.p.getConfig().getStringList("fbanners.Item.Lore"));
|
||||
me.getInventory().addItem(warBanner);
|
||||
fme.msg(TL.COMMAND_BANNER_SUCCESS);
|
||||
|
||||
}
|
||||
} else {
|
||||
fme.msg(TL.COMMAND_BANNER_WRONGITEM);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasMoney(FPlayer fme, int amt) {
|
||||
Economy econ = P.p.getEcon();
|
||||
if (econ.getBalance((Player) fme.getPlayer()) >= amt) {
|
||||
return true;
|
||||
} else {
|
||||
fme.msg(TL.COMMAND_BANNER_NOTENOUGHMONEY);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void takeMoney(FPlayer fme, int amt) {
|
||||
if (hasMoney(fme, amt)) {
|
||||
Economy econ = P.p.getEcon();
|
||||
econ.withdrawPlayer(fme.getPlayer(), amt);
|
||||
fme.sendMessage(TL.COMMAND_BANNER_MONEYTAKE.toString().replace("{amount}", amt + ""));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean inventoryContains(Inventory inventory, ItemStack item) {
|
||||
int count = 0;
|
||||
ItemStack[] items = inventory.getContents();
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) {
|
||||
count += items[i].getAmount();
|
||||
}
|
||||
if (count >= item.getAmount()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void removeFromInventory(Inventory inventory, ItemStack item) {
|
||||
int amt = item.getAmount();
|
||||
ItemStack[] items = inventory.getContents();
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) {
|
||||
if (items[i].getAmount() > amt) {
|
||||
items[i].setAmount(items[i].getAmount() - amt);
|
||||
break;
|
||||
} else if (items[i].getAmount() == amt) {
|
||||
items[i] = null;
|
||||
break;
|
||||
} else {
|
||||
amt -= items[i].getAmount();
|
||||
items[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
inventory.setContents(items);
|
||||
}
|
||||
|
||||
public int getEmptySlots(Player p) {
|
||||
PlayerInventory inventory = p.getInventory();
|
||||
ItemStack[] cont = inventory.getContents();
|
||||
int i = 0;
|
||||
for (ItemStack item : cont)
|
||||
if (item != null && item.getType() != Material.AIR) {
|
||||
i++;
|
||||
}
|
||||
return 36 - i;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_BANNER_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.util.WarmUpUtil;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdCheckpoint extends FCommand {
|
||||
public CmdCheckpoint() {
|
||||
super();
|
||||
this.aliases.add("checkp");
|
||||
this.aliases.add("checkpoint");
|
||||
this.aliases.add("cpoint");
|
||||
|
||||
this.optionalArgs.put("set", "");
|
||||
|
||||
this.permission = Permission.CHECKPOINT.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = true;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeColeader = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
if (!P.p.getConfig().getBoolean("checkpoints.Enabled")) {
|
||||
fme.msg(TL.COMMAND_CHECKPOINT_DISABLED);
|
||||
return;
|
||||
}
|
||||
if (args.size() == 1) {
|
||||
FLocation myLocation = new FLocation(fme.getPlayer().getLocation());
|
||||
Faction myLocFaction = Board.getInstance().getFactionAt(myLocation);
|
||||
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == fme.getFaction()) {
|
||||
fme.getFaction().setCheckpoint(fme.getPlayer().getLocation());
|
||||
fme.msg(TL.COMMAND_CHECKPOINT_SET);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (fme.getFaction().getCheckpoint() == null) {
|
||||
fme.msg(TL.COMMAND_CHECKPOINT_NOT_SET);
|
||||
return;
|
||||
}
|
||||
FLocation checkLocation = new FLocation(fme.getFaction().getCheckpoint());
|
||||
Faction checkfaction = Board.getInstance().getFactionAt(checkLocation);
|
||||
|
||||
if (checkfaction.getId().equals(Factions.getInstance().getWilderness().getId()) || checkfaction.getId().equals(fme.getFaction().getId())) {
|
||||
fme.msg(TL.COMMAND_CHECKPOINT_GO);
|
||||
fme.getPlayer().teleport(fme.getFaction().getCheckpoint());
|
||||
} else {
|
||||
fme.msg(TL.COMMAND_CHECKPOINT_CLAIMED);
|
||||
}
|
||||
this.doWarmUp(WarmUpUtil.Warmup.WARP, TL.WARMUPS_NOTIFY_TELEPORT, "Checkpoint", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Create a smoke effect
|
||||
CmdCheckpoint.this.me.teleport(fme.getFaction().getCheckpoint());
|
||||
}
|
||||
}, this.p.getConfig().getLong("warmups.f-checkpoint", 0));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_CHECKPOINT_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
90
src/main/java/com/massivecraft/factions/cmd/CmdColeader.java
Normal file
90
src/main/java/com/massivecraft/factions/cmd/CmdColeader.java
Normal file
@@ -0,0 +1,90 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class CmdColeader extends FCommand {
|
||||
public CmdColeader() {
|
||||
super();
|
||||
this.aliases.add("co");
|
||||
this.aliases.add("setcoleader");
|
||||
this.aliases.add("coleader");
|
||||
this.aliases.add("setco");
|
||||
|
||||
this.optionalArgs.put("player name", "name");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.COLEADER.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = true;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
||||
if (you == null) {
|
||||
FancyMessage msg = new FancyMessage(TL.COMMAND_COLEADER_CANDIDATES.toString()).color(ChatColor.GOLD);
|
||||
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) {
|
||||
String s = player.getName();
|
||||
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " coleader " + s);
|
||||
}
|
||||
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.MODERATOR)) {
|
||||
String s = player.getName();
|
||||
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " coleader " + s);
|
||||
}
|
||||
|
||||
sendFancyMessage(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean permAny = Permission.COLEADER_ANY.has(sender, false);
|
||||
Faction targetFaction = you.getFaction();
|
||||
|
||||
if (targetFaction != myFaction && !permAny) {
|
||||
msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(fme, true));
|
||||
return;
|
||||
}
|
||||
|
||||
if (fme != null && fme.getRole() != Role.ADMIN && !permAny) {
|
||||
msg(TL.COMMAND_COLEADER_NOTADMIN);
|
||||
return;
|
||||
}
|
||||
|
||||
if (you == fme && !permAny) {
|
||||
msg(TL.COMMAND_COLEADER_SELF);
|
||||
return;
|
||||
}
|
||||
|
||||
if (you.getRole() == Role.ADMIN) {
|
||||
msg(TL.COMMAND_COLEADER_TARGETISADMIN);
|
||||
return;
|
||||
}
|
||||
|
||||
if (you.getRole() == Role.COLEADER) {
|
||||
// Revoke
|
||||
you.setRole(Role.MODERATOR);
|
||||
targetFaction.msg(TL.COMMAND_COLEADER_REVOKED, you.describeTo(targetFaction, true));
|
||||
msg(TL.COMMAND_COLEADER_REVOKES, you.describeTo(fme, true));
|
||||
} else {
|
||||
// Give
|
||||
you.setRole(Role.COLEADER);
|
||||
targetFaction.msg(TL.COMMAND_COLEADER_PROMOTED, you.describeTo(targetFaction, true));
|
||||
msg(TL.COMMAND_COLEADER_PROMOTES, you.describeTo(fme, true));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_COLEADER_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
71
src/main/java/com/massivecraft/factions/cmd/CmdGetVault.java
Normal file
71
src/main/java/com/massivecraft/factions/cmd/CmdGetVault.java
Normal file
@@ -0,0 +1,71 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CmdGetVault extends FCommand {
|
||||
public CmdGetVault() {
|
||||
super();
|
||||
|
||||
this.aliases.add("getvault");
|
||||
|
||||
this.permission = Permission.GETVAULT.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = true;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeColeader = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
if (!P.p.getConfig().getBoolean("fvault.Enabled")) {
|
||||
fme.sendMessage("This command is disabled!");
|
||||
return;
|
||||
}
|
||||
Location vaultLocation = fme.getFaction().getVault();
|
||||
ItemStack vault = P.p.createItem(Material.CHEST, 1, (short) 0, P.p.color(P.p.getConfig().getString("fvault.Item.Name")), P.p.colorList(P.p.getConfig().getStringList("fvault.Item.Lore")));
|
||||
|
||||
if (inventoryContains(me.getInventory(), vault)) {
|
||||
fme.msg(TL.COMMAND_GETVAULT_ALREADYHAVE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (vaultLocation != null) {
|
||||
fme.msg(TL.COMMAND_GETVAULT_ALREADYSET);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
me.getInventory().addItem(vault);
|
||||
fme.msg(TL.COMMAND_GETVAULT_RECEIVE);
|
||||
|
||||
}
|
||||
|
||||
public boolean inventoryContains(Inventory inventory, ItemStack item) {
|
||||
int count = 0;
|
||||
ItemStack[] items = inventory.getContents();
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) {
|
||||
count += items[i].getAmount();
|
||||
}
|
||||
if (count >= item.getAmount()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_GETVAULT_DESCRIPTION;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,7 +29,6 @@ public class CmdKick extends FCommand {
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeColeader = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@@ -42,11 +41,19 @@ public class CmdKick extends FCommand {
|
||||
String s = player.getName();
|
||||
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s);
|
||||
}
|
||||
if (fme.getRole() == Role.ADMIN) {
|
||||
if (fme.getRole().isAtLeast(Role.COLEADER)) {
|
||||
// For both coleader and admin, add mods.
|
||||
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.MODERATOR)) {
|
||||
String s = player.getName();
|
||||
msg.then(s + " ").color(ChatColor.GRAY).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s);
|
||||
}
|
||||
if (fme.getRole() == Role.ADMIN) {
|
||||
// Only add coleader to this for the leader.
|
||||
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.COLEADER)) {
|
||||
String s = player.getName();
|
||||
msg.then(s + " ").color(ChatColor.RED).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sendFancyMessage(msg);
|
||||
@@ -66,11 +73,6 @@ public class CmdKick extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((fme.getRole() == Role.MODERATOR || fme.getRole() == Role.COLEADER) && toKick.getRole() == Role.ADMIN){
|
||||
msg(TL.COMMAND_KICK_INSUFFICIENTRANK);
|
||||
return;
|
||||
}
|
||||
|
||||
// players with admin-level "disband" permission can bypass these requirements
|
||||
if (!Permission.KICK_ANY.has(sender)) {
|
||||
|
||||
@@ -97,6 +99,14 @@ public class CmdKick extends FCommand {
|
||||
}
|
||||
}
|
||||
|
||||
Access access = myFaction.getAccess(fme, PermissableAction.KICK);
|
||||
// This statement allows us to check if they've specifically denied it, or default to
|
||||
// the old setting of allowing moderators to kick
|
||||
if (access == Access.DENY || (access == Access.UNDEFINED && !assertMinRole(Role.MODERATOR))) {
|
||||
fme.msg(TL.GENERIC_NOPERMISSION, "kick");
|
||||
return;
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
||||
if (!canAffordCommand(Conf.econCostKick, TL.COMMAND_KICK_TOKICK.toString())) {
|
||||
return;
|
||||
@@ -121,7 +131,6 @@ public class CmdKick extends FCommand {
|
||||
}
|
||||
|
||||
if (Conf.logFactionKick) {
|
||||
//TODO:TL
|
||||
P.p.log((senderIsConsole ? "A console command" : fme.getName()) + " kicked " + toKick.getName() + " from the faction: " + toKickFaction.getTag());
|
||||
}
|
||||
|
||||
@@ -138,4 +147,4 @@ public class CmdKick extends FCommand {
|
||||
return TL.COMMAND_KICK_DESCRIPTION;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdKillHolograms extends FCommand {
|
||||
public CmdKillHolograms() {
|
||||
super();
|
||||
|
||||
this.aliases.add("killholos");
|
||||
|
||||
this.requiredArgs.add("radius");
|
||||
|
||||
this.permission = Permission.KILLHOLOS.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeColeader = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
me.sendMessage("Killing Invisible Armor Stands..");
|
||||
me.chat("/minecraft:kill @e[type=ArmorStand,r=" + argAsInt(0) + "]");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_KILLHOLOGRAMS_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
53
src/main/java/com/massivecraft/factions/cmd/CmdNear.java
Normal file
53
src/main/java/com/massivecraft/factions/cmd/CmdNear.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CmdNear extends FCommand {
|
||||
public CmdNear() {
|
||||
super();
|
||||
|
||||
this.aliases.add("near");
|
||||
this.aliases.add("nearby");
|
||||
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = true;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeColeader = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
if (!P.p.getConfig().getBoolean("fnear.Enabled")) {
|
||||
fme.msg(TL.COMMAND_NEAR_DISABLED_MSG);
|
||||
return;
|
||||
}
|
||||
|
||||
double range = P.p.getConfig().getInt("fnear.Radius");
|
||||
String format = TL.COMMAND_NEAR_FORMAT.toString();
|
||||
fme.msg(TL.COMMAND_NEAR_USE_MSG);
|
||||
for (Entity e : me.getNearbyEntities(range, 255, range)) {
|
||||
if (e instanceof Player) {
|
||||
Player player = (((Player) e).getPlayer());
|
||||
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
|
||||
if (fme.getFaction() == fplayer.getFaction()) {
|
||||
double distance = me.getLocation().distance(player.getLocation());
|
||||
fme.sendMessage(format.replace("{playername}", player.getDisplayName()).replace("{distance}", (int) distance + ""));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_NEAR_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
90
src/main/java/com/massivecraft/factions/cmd/CmdRules.java
Normal file
90
src/main/java/com/massivecraft/factions/cmd/CmdRules.java
Normal file
@@ -0,0 +1,90 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class CmdRules extends FCommand {
|
||||
public CmdRules() {
|
||||
super();
|
||||
aliases.add("r");
|
||||
aliases.add("rule");
|
||||
aliases.add("rules");
|
||||
|
||||
this.optionalArgs.put("add/remove/set/clear", "");
|
||||
this.errorOnToManyArgs = false;
|
||||
|
||||
permission = Permission.RULES.node;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = true;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeColeader = true;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
if (!P.p.getConfig().getBoolean("frules.Enabled")) {
|
||||
fme.msg(TL.COMMAND_RULES_DISABLED_MSG);
|
||||
return;
|
||||
}
|
||||
if (this.args.size() == 0) {
|
||||
HashMap<Integer, String> rules = fme.getFaction().getRulesMap();
|
||||
if (rules.size() == 0) {
|
||||
List<String> ruleList = P.p.getConfig().getStringList("frules.default-rules");
|
||||
fme.sendMessage(P.p.colorList(ruleList));
|
||||
|
||||
} else {
|
||||
for (int i = 0; i <= rules.size() - 1; i++) {
|
||||
fme.sendMessage(P.p.color(rules.get(i)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (this.args.size() == 1) {
|
||||
if (args.get(0).equalsIgnoreCase("add")) {
|
||||
fme.msg(TL.COMMAND_RULES_ADD_INVALIDARGS);
|
||||
}
|
||||
if (args.get(0).equalsIgnoreCase("set")) {
|
||||
fme.msg(TL.COMMAND_RULES_SET_INVALIDARGS);
|
||||
}
|
||||
if (args.get(0).equalsIgnoreCase("add")) {
|
||||
fme.msg(TL.COMMAND_RULES_ADD_INVALIDARGS);
|
||||
}
|
||||
if (args.get(0).equalsIgnoreCase("clear")) {
|
||||
fme.getFaction().clearRules();
|
||||
fme.msg(TL.COMMAND_RULES_CLEAR_SUCCESS);
|
||||
}
|
||||
|
||||
}
|
||||
if (this.args.size() >= 2) {
|
||||
if (args.get(0).equalsIgnoreCase("add")) {
|
||||
String message = "";
|
||||
StringBuilder string = new StringBuilder(message);
|
||||
for (int i = 1; i <= args.size() - 1; i++) {
|
||||
string.append(" " + args.get(i));
|
||||
}
|
||||
fme.getFaction().addRule(string.toString());
|
||||
fme.msg(TL.COMMAND_RULES_ADD_SUCCESS);
|
||||
}
|
||||
|
||||
if (this.args.size() == 2) {
|
||||
if (args.get(0).equalsIgnoreCase("remove")) {
|
||||
int index = argAsInt(1);
|
||||
fme.getFaction().removeRule(index - 1);
|
||||
fme.msg(TL.COMMAND_RULES_REMOVE_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_RULES_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.darkblade12.particleeffect.ParticleEffect;
|
||||
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.util.Particle.ParticleEffect;
|
||||
import com.massivecraft.factions.util.VisualizeUtil;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Location;
|
||||
|
||||
166
src/main/java/com/massivecraft/factions/cmd/CmdTnt.java
Normal file
166
src/main/java/com/massivecraft/factions/cmd/CmdTnt.java
Normal file
@@ -0,0 +1,166 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
public class CmdTnt extends FCommand {
|
||||
public CmdTnt() {
|
||||
super();
|
||||
this.aliases.add("tnt");
|
||||
|
||||
this.optionalArgs.put("add/take", "");
|
||||
this.optionalArgs.put("amount", "number");
|
||||
|
||||
this.permission = Permission.TNT.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = true;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
if (!P.p.getConfig().getBoolean("ftnt.Enabled")) {
|
||||
fme.msg(TL.COMMAND_TNT_DISABLED_MSG);
|
||||
return;
|
||||
}
|
||||
if (args.size() == 2) {
|
||||
if (args.get(0).equalsIgnoreCase("add")) {
|
||||
int testNumber = -1;
|
||||
try {
|
||||
testNumber = Integer.parseInt(args.get(1));
|
||||
} catch (NumberFormatException e) {
|
||||
fme.msg(TL.COMMAND_TNT_INVALID_NUM);
|
||||
return;
|
||||
}
|
||||
int amount = Integer.parseInt(args.get(1));
|
||||
if (amount < 0) {
|
||||
fme.msg(TL.COMMAND_TNT_POSITIVE);
|
||||
return;
|
||||
}
|
||||
Inventory inv = me.getInventory();
|
||||
int invTnt = 0;
|
||||
for (int i = 0; i <= inv.getSize(); i++) {
|
||||
if (inv.getItem(i) == null) {
|
||||
continue;
|
||||
}
|
||||
if (inv.getItem(i).getType() == Material.TNT) {
|
||||
invTnt += inv.getItem(i).getAmount();
|
||||
}
|
||||
}
|
||||
if (amount > invTnt) {
|
||||
fme.msg(TL.COMMAND_TNT_DEPOSIT_NOTENOUGH);
|
||||
return;
|
||||
}
|
||||
ItemStack tnt = new ItemStack(Material.TNT, amount);
|
||||
removeFromInventory(me.getInventory(), tnt);
|
||||
me.updateInventory();
|
||||
fme.getFaction().addTnt(amount);
|
||||
fme.msg(TL.COMMAND_TNT_DEPOSIT_SUCCESS);
|
||||
fme.sendMessage(P.p.color(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", fme.getFaction().getTnt() + "")));
|
||||
return;
|
||||
|
||||
}
|
||||
if (args.get(0).equalsIgnoreCase("take")) {
|
||||
int testNumber = -1;
|
||||
try {
|
||||
testNumber = Integer.parseInt(args.get(1));
|
||||
} catch (NumberFormatException e) {
|
||||
fme.msg(TL.COMMAND_TNT_INVALID_NUM);
|
||||
return;
|
||||
}
|
||||
int amount = Integer.parseInt(args.get(1));
|
||||
if (amount < 0) {
|
||||
fme.msg(TL.COMMAND_TNT_POSITIVE);
|
||||
return;
|
||||
}
|
||||
if (fme.getFaction().getTnt() < amount) {
|
||||
fme.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH);
|
||||
return;
|
||||
}
|
||||
int fullStacks = amount / 64;
|
||||
int remainderAmt = amount % 64;
|
||||
if ((remainderAmt == 0 && getEmptySlots(me) <= fullStacks)) {
|
||||
fme.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH);
|
||||
return;
|
||||
}
|
||||
if (getEmptySlots(me) + 1 <= fullStacks) {
|
||||
fme.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH);
|
||||
return;
|
||||
}
|
||||
ItemStack tnt64 = new ItemStack(Material.TNT, 64);
|
||||
for (int i = 0; i <= fullStacks - 1; i++) {
|
||||
me.getInventory().addItem(tnt64);
|
||||
}
|
||||
if (remainderAmt != 0) {
|
||||
ItemStack tnt = new ItemStack(Material.TNT, remainderAmt);
|
||||
me.getInventory().addItem(tnt);
|
||||
}
|
||||
fme.getFaction().takeTnt(amount);
|
||||
me.updateInventory();
|
||||
fme.msg(TL.COMMAND_TNT_WIDTHDRAW_SUCCESS);
|
||||
}
|
||||
}
|
||||
fme.sendMessage(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", fme.getFaction().getTnt() + ""));
|
||||
}
|
||||
|
||||
|
||||
public boolean inventoryContains(Inventory inventory, ItemStack item) {
|
||||
int count = 0;
|
||||
ItemStack[] items = inventory.getContents();
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) {
|
||||
count += items[i].getAmount();
|
||||
}
|
||||
if (count >= item.getAmount()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void removeFromInventory(Inventory inventory, ItemStack item) {
|
||||
int amt = item.getAmount();
|
||||
ItemStack[] items = inventory.getContents();
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) {
|
||||
if (items[i].getAmount() > amt) {
|
||||
items[i].setAmount(items[i].getAmount() - amt);
|
||||
break;
|
||||
} else if (items[i].getAmount() == amt) {
|
||||
items[i] = null;
|
||||
break;
|
||||
} else {
|
||||
amt -= items[i].getAmount();
|
||||
items[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
inventory.setContents(items);
|
||||
}
|
||||
|
||||
public int getEmptySlots(Player p) {
|
||||
PlayerInventory inventory = p.getInventory();
|
||||
ItemStack[] cont = inventory.getContents();
|
||||
int i = 0;
|
||||
for (ItemStack item : cont)
|
||||
if (item != null && item.getType() != Material.AIR) {
|
||||
i++;
|
||||
}
|
||||
return 36 - i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_TNT_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
47
src/main/java/com/massivecraft/factions/cmd/CmdTpBanner.java
Normal file
47
src/main/java/com/massivecraft/factions/cmd/CmdTpBanner.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.listeners.FactionsPlayerListener;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.util.WarmUpUtil;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdTpBanner extends FCommand {
|
||||
public CmdTpBanner() {
|
||||
super();
|
||||
|
||||
this.aliases.add("tpbanner");
|
||||
|
||||
this.permission = Permission.TPBANNER.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = true;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeColeader = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
final FactionsPlayerListener fpl = new FactionsPlayerListener(P.p);
|
||||
|
||||
if (fpl.bannerLocations.containsKey(fme.getTag())) {
|
||||
fme.msg(TL.COMMAND_TPBANNER_SUCCESS);
|
||||
this.doWarmUp(WarmUpUtil.Warmup.BANNER, TL.WARMUPS_NOTIFY_TELEPORT, "Banner", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
me.teleport(fpl.bannerLocations.get(fme.getTag()));
|
||||
}
|
||||
}, this.p.getConfig().getLong("warmups.f-banner", 0));
|
||||
} else {
|
||||
fme.msg(TL.COMMAND_TPBANNER_NOTSET);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_TPBANNER_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
41
src/main/java/com/massivecraft/factions/cmd/CmdUpgrades.java
Normal file
41
src/main/java/com/massivecraft/factions/cmd/CmdUpgrades.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.fupgrades.FUpgradesGUI;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdUpgrades extends FCommand {
|
||||
public CmdUpgrades() {
|
||||
super();
|
||||
this.aliases.add("upgrades");
|
||||
this.aliases.add("upgrade");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("mobs/crops/exp", "");
|
||||
|
||||
this.permission = Permission.UPGRADES.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = true;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
if (!P.p.getConfig().getBoolean("fupgrades.Enabled")) {
|
||||
fme.sendMessage("This command is disabled!");
|
||||
return;
|
||||
}
|
||||
FUpgradesGUI fgui = new FUpgradesGUI();
|
||||
fgui.openMainMenu(fme);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_UPGRADES_DESCRIPTION;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class FPromoteCommand extends FCommand {
|
||||
|
||||
@@ -28,30 +27,22 @@ public class FPromoteCommand extends FCommand {
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
|
||||
FPlayer target = this.argAsBestFPlayerMatch(0);
|
||||
if (target == null) {
|
||||
msg(TL.GENERIC_NOPLAYERFOUND, this.argAsString(0));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!target.getFaction().equals(myFaction)) {
|
||||
msg(TL.COMMAND_PROMOTE_WRONGFACTION, target.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Access access = myFaction.getAccess(fme.getRole(), PermissableAction.PROMOTE);
|
||||
if (fme.getRole() == Role.COLEADER && target.getRole() == Role.ADMIN){
|
||||
fme.msg(TL.COMMAND_PROMOTE_COLEADER_ADMIN);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Well this is messy.
|
||||
if (access == null || access == Access.UNDEFINED) {
|
||||
if (!assertMinRole(Role.COLEADER)) {
|
||||
if (!assertMinRole(Role.MODERATOR)) {
|
||||
return;
|
||||
}
|
||||
} else if (access == Access.DENY) {
|
||||
@@ -59,22 +50,21 @@ public class FPromoteCommand extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Role current = target.getRole();
|
||||
Role promotion = Role.getRelative(current, +relative);
|
||||
|
||||
if (promotion == null) {
|
||||
fme.msg(TL.COMMAND_PROMOTE_NOTTHATPLAYER);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (fme == target && fme.getRole() == Role.COLEADER){
|
||||
fme.msg(TL.COMMAND_PROMOTE_COLEADER_ADMIN);
|
||||
// Don't allow people to promote people to their same or higher rnak.
|
||||
if (fme.getRole().value <= promotion.value) {
|
||||
fme.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED);
|
||||
return;
|
||||
}
|
||||
String action = relative > 0 ? TL.COMMAND_PROMOTE_PROMOTED.toString() : TL.COMMAND_PROMOTE_DEMOTED.toString();
|
||||
|
||||
String action = relative > 0 ? TL.COMMAND_PROMOTE_PROMOTED.toString() : TL.COMMAND_PROMOTE_DEMOTED.toString();
|
||||
|
||||
// Success!
|
||||
target.setRole(promotion);
|
||||
@@ -90,4 +80,4 @@ public class FPromoteCommand extends FCommand {
|
||||
return TL.COMMAND_PROMOTE_DESCRIPTION;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user