TntFill Fixed & Code Cleanup
This commit is contained in:
parent
e3e6f5561c
commit
51838df0d7
@ -143,6 +143,7 @@ public class Aliases {
|
|||||||
public static ArrayList<String> vault = new ArrayList<>(Collections.singletonList("vault"));
|
public static ArrayList<String> vault = new ArrayList<>(Collections.singletonList("vault"));
|
||||||
public static ArrayList<String> viewChest = new ArrayList<>(Arrays.asList("viewchest", "viewpv"));
|
public static ArrayList<String> viewChest = new ArrayList<>(Arrays.asList("viewchest", "viewpv"));
|
||||||
private static transient Aliases i = new Aliases();
|
private static transient Aliases i = new Aliases();
|
||||||
|
|
||||||
public static void load() {
|
public static void load() {
|
||||||
FactionsPlugin.getInstance().persist.loadOrSaveDefault(i, Aliases.class, "aliases");
|
FactionsPlugin.getInstance().persist.loadOrSaveDefault(i, Aliases.class, "aliases");
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ public class CmdBanner extends FCommand {
|
|||||||
warBanner.setAmount(1);
|
warBanner.setAmount(1);
|
||||||
context.player.getInventory().addItem(warBanner);
|
context.player.getInventory().addItem(warBanner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean hasMoney(FPlayer fme, int amt) {
|
public boolean hasMoney(FPlayer fme, int amt) {
|
||||||
Economy econ = FactionsPlugin.getInstance().getEcon();
|
Economy econ = FactionsPlugin.getInstance().getEcon();
|
||||||
@ -55,6 +56,7 @@ public class CmdBanner extends FCommand {
|
|||||||
fme.msg(TL.COMMAND_BANNER_NOTENOUGHMONEY);
|
fme.msg(TL.COMMAND_BANNER_NOTENOUGHMONEY);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void takeMoney(FPlayer fme, int amt) {
|
public void takeMoney(FPlayer fme, int amt) {
|
||||||
if (this.hasMoney(fme, amt)) {
|
if (this.hasMoney(fme, amt)) {
|
||||||
|
@ -225,7 +225,7 @@ public class CmdConfig extends FCommand {
|
|||||||
if (!success.isEmpty()) {
|
if (!success.isEmpty()) {
|
||||||
if (context.sender instanceof Player) {
|
if (context.sender instanceof Player) {
|
||||||
context.sendMessage(success);
|
context.sendMessage(success);
|
||||||
FactionsPlugin.getInstance().log(success + TL.COMMAND_CONFIG_LOG.format((Player) context.sender));
|
FactionsPlugin.getInstance().log(success + TL.COMMAND_CONFIG_LOG.format(context.sender));
|
||||||
} else // using FactionsPlugin.getInstance().log() instead of sendMessage if run from server console so that "[Factions v#.#.#]" is prepended in server log
|
} else // using FactionsPlugin.getInstance().log() instead of sendMessage if run from server console so that "[Factions v#.#.#]" is prepended in server log
|
||||||
{
|
{
|
||||||
FactionsPlugin.getInstance().log(success);
|
FactionsPlugin.getInstance().log(success);
|
||||||
|
@ -115,7 +115,9 @@ public class CmdCreate extends FCommand {
|
|||||||
Discord.mainGuild.getController().setNickname(m, Discord.getNicknameString(context.fPlayer)).queue();
|
Discord.mainGuild.getController().setNickname(m, Discord.getNicknameString(context.fPlayer)).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (HierarchyException e) {System.out.print(e.getMessage());}
|
} catch (HierarchyException e) {
|
||||||
|
System.out.print(e.getMessage());
|
||||||
|
}
|
||||||
//End Discord
|
//End Discord
|
||||||
context.msg(TL.COMMAND_CREATE_YOUSHOULD, FactionsPlugin.getInstance().cmdBase.cmdDescription.getUsageTemplate(context));
|
context.msg(TL.COMMAND_CREATE_YOUSHOULD, FactionsPlugin.getInstance().cmdBase.cmdDescription.getUsageTemplate(context));
|
||||||
if (Conf.econEnabled) Econ.setBalance(faction.getAccountId(), Conf.econFactionStartingBalance);
|
if (Conf.econEnabled) Econ.setBalance(faction.getAccountId(), Conf.econFactionStartingBalance);
|
||||||
|
@ -13,6 +13,7 @@ public class CmdDebug extends FCommand {
|
|||||||
this.aliases.add("debug");
|
this.aliases.add("debug");
|
||||||
this.requirements = new CommandRequirements.Builder(Permission.DEBUG).build();
|
this.requirements = new CommandRequirements.Builder(Permission.DEBUG).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
FactionsPlugin.getInstance().divider();
|
FactionsPlugin.getInstance().divider();
|
||||||
@ -51,7 +52,9 @@ public class CmdDebug extends FCommand {
|
|||||||
System.out.print("Emotes enabled: " + Discord.useEmotes);
|
System.out.print("Emotes enabled: " + Discord.useEmotes);
|
||||||
System.out.print("Leader role null: " + (Discord.leader == null ? "True" : "False"));
|
System.out.print("Leader role null: " + (Discord.leader == null ? "True" : "False"));
|
||||||
System.out.print("Attempt Log:");
|
System.out.print("Attempt Log:");
|
||||||
for (DiscordSetupAttempt d : Discord.setupLog) {System.out.print(d.getDifferentialFormatted() + " " + d.getSuccess() + " " + d.getReason());}
|
for (DiscordSetupAttempt d : Discord.setupLog) {
|
||||||
|
System.out.print(d.getDifferentialFormatted() + " " + d.getSuccess() + " " + d.getReason());
|
||||||
|
}
|
||||||
System.out.print("End Attempt Log");
|
System.out.print("End Attempt Log");
|
||||||
System.out.print("----End Discord----");
|
System.out.print("----End Discord----");
|
||||||
System.out.print("--------End Debug Info--------");
|
System.out.print("--------End Debug Info--------");
|
||||||
|
@ -31,47 +31,47 @@ public class CmdDeinvite extends FCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
if (context.args.size() == 0) {
|
if (context.args.size() == 0) {
|
||||||
FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD);
|
FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD);
|
||||||
for (String id : context.faction.getInvites()) {
|
for (String id : context.faction.getInvites()) {
|
||||||
FPlayer fp = FPlayers.getInstance().getById(id);
|
FPlayer fp = FPlayers.getInstance().getById(id);
|
||||||
String name = fp != null ? fp.getName() : id;
|
String name = fp != null ? fp.getName() : id;
|
||||||
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
|
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
|
||||||
}
|
}
|
||||||
context.sendFancyMessage(msg);
|
context.sendFancyMessage(msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FPlayer you = context.argAsBestFPlayerMatch(0);
|
||||||
|
if (!context.fPlayer.isAdminBypassing()) {
|
||||||
|
Access access = context.faction.getAccess(context.fPlayer, PermissableAction.INVITE);
|
||||||
|
if (access != Access.ALLOW && context.fPlayer.getRole() != Role.LEADER) {
|
||||||
|
context.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FPlayer you = context.argAsBestFPlayerMatch(0);
|
if (you == null) {
|
||||||
if (!context.fPlayer.isAdminBypassing()) {
|
FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD);
|
||||||
Access access = context.faction.getAccess(context.fPlayer, PermissableAction.INVITE);
|
for (String id : context.faction.getInvites()) {
|
||||||
if (access != Access.ALLOW && context.fPlayer.getRole() != Role.LEADER) {
|
if (context.faction.getInvites().isEmpty()) return;
|
||||||
context.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites");
|
FPlayer fp = FPlayers.getInstance().getById(id);
|
||||||
return;
|
String name = fp != null ? fp.getName() : id;
|
||||||
}
|
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
|
||||||
}
|
}
|
||||||
|
context.sendFancyMessage(msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (you == null) {
|
if (you.getFaction() == context.faction) {
|
||||||
FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD);
|
context.msg(TL.COMMAND_DEINVITE_ALREADYMEMBER, you.getName(), context.faction.getTag());
|
||||||
for (String id : context.faction.getInvites()) {
|
context.msg(TL.COMMAND_DEINVITE_MIGHTWANT, FactionsPlugin.getInstance().cmdBase.cmdKick.getUsageTemplate(context));
|
||||||
if (context.faction.getInvites().isEmpty()) return;
|
return;
|
||||||
FPlayer fp = FPlayers.getInstance().getById(id);
|
}
|
||||||
String name = fp != null ? fp.getName() : id;
|
|
||||||
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
|
|
||||||
}
|
|
||||||
context.sendFancyMessage(msg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (you.getFaction() == context.faction) {
|
context.faction.deinvite(you);
|
||||||
context.msg(TL.COMMAND_DEINVITE_ALREADYMEMBER, you.getName(), context.faction.getTag());
|
you.msg(TL.COMMAND_DEINVITE_REVOKED, context.fPlayer.describeTo(you), context.faction.describeTo(you));
|
||||||
context.msg(TL.COMMAND_DEINVITE_MIGHTWANT, FactionsPlugin.getInstance().cmdBase.cmdKick.getUsageTemplate(context));
|
context.faction.msg(TL.COMMAND_DEINVITE_REVOKES, context.fPlayer.describeTo(context.faction), you.describeTo(context.faction));
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
context.faction.deinvite(you);
|
|
||||||
you.msg(TL.COMMAND_DEINVITE_REVOKED, context.fPlayer.describeTo(you), context.faction.describeTo(you));
|
|
||||||
context.faction.msg(TL.COMMAND_DEINVITE_REVOKES, context.fPlayer.describeTo(context.faction), you.describeTo(context.faction));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.*;
|
import com.massivecraft.factions.FPlayer;
|
||||||
|
import com.massivecraft.factions.FPlayers;
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason;
|
import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Role;
|
||||||
import com.massivecraft.factions.util.UtilFly;
|
|
||||||
import com.massivecraft.factions.zcore.fperms.Access;
|
import com.massivecraft.factions.zcore.fperms.Access;
|
||||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
@ -89,7 +91,8 @@ public class CmdDisband extends FCommand {
|
|||||||
follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower));
|
follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) context.fPlayer.setFFlying(false, false);
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
||||||
|
context.fPlayer.setFFlying(false, false);
|
||||||
} else {
|
} else {
|
||||||
context.player.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER));
|
context.player.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER));
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ public class CmdDiscord extends FCommand {
|
|||||||
.playerOnly()
|
.playerOnly()
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
if (context.fPlayer.discordSetup()) {
|
if (context.fPlayer.discordSetup()) {
|
||||||
|
@ -7,15 +7,14 @@ import com.massivecraft.factions.FactionsPlugin;
|
|||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Saser
|
* @author Saser
|
||||||
*/
|
*/
|
||||||
public class CmdDrain extends FCommand{
|
public class CmdDrain extends FCommand {
|
||||||
public CmdDrain(){
|
public CmdDrain() {
|
||||||
this.aliases.addAll(Aliases.drain);
|
this.aliases.addAll(Aliases.drain);
|
||||||
this.requirements = new CommandRequirements.Builder(Permission.DRAIN)
|
this.requirements = new CommandRequirements.Builder(Permission.DRAIN)
|
||||||
.playerOnly()
|
.playerOnly()
|
||||||
@ -34,12 +33,12 @@ public class CmdDrain extends FCommand{
|
|||||||
|
|
||||||
double totalBalance = 0;
|
double totalBalance = 0;
|
||||||
|
|
||||||
for(FPlayer fPlayer : context.faction.getFPlayers()) {
|
for (FPlayer fPlayer : context.faction.getFPlayers()) {
|
||||||
if(context.faction.getFPlayers().size() == 1){
|
if (context.faction.getFPlayers().size() == 1) {
|
||||||
context.fPlayer.msg(TL.COMMAND_DRAIN_NO_PLAYERS);
|
context.fPlayer.msg(TL.COMMAND_DRAIN_NO_PLAYERS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (FPlayers.getInstance().getByPlayer(context.player).equals(fPlayer)){
|
if (FPlayers.getInstance().getByPlayer(context.player).equals(fPlayer)) {
|
||||||
continue; // skip the command executor
|
continue; // skip the command executor
|
||||||
}
|
}
|
||||||
double balance = FactionsPlugin.getInstance().getEcon().getBalance(fPlayer.getPlayer());
|
double balance = FactionsPlugin.getInstance().getEcon().getBalance(fPlayer.getPlayer());
|
||||||
|
@ -102,9 +102,11 @@ public class CmdFly extends FCommand {
|
|||||||
return false;
|
return false;
|
||||||
if (toFac.getAccess(fme, PermissableAction.FLY) == Access.ALLOW) return true;
|
if (toFac.getAccess(fme, PermissableAction.FLY) == Access.ALLOW) return true;
|
||||||
if (fme.getFaction().isWilderness()) return false;
|
if (fme.getFaction().isWilderness()) return false;
|
||||||
if (toFac.isSystemFaction()) return me.hasPermission(Permission.valueOf("FLY_" + ChatColor.stripColor(toFac.getTag()).toUpperCase()).node);
|
if (toFac.isSystemFaction())
|
||||||
|
return me.hasPermission(Permission.valueOf("FLY_" + ChatColor.stripColor(toFac.getTag()).toUpperCase()).node);
|
||||||
Relation relationTo = toFac.getRelationTo(fme.getFaction());
|
Relation relationTo = toFac.getRelationTo(fme.getFaction());
|
||||||
if (!relationTo.isEnemy() && !relationTo.isMember()) return me.hasPermission(Permission.valueOf("FLY_" + relationTo.name()).node);
|
if (!relationTo.isEnemy() && !relationTo.isMember())
|
||||||
|
return me.hasPermission(Permission.valueOf("FLY_" + relationTo.name()).node);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,14 +128,14 @@ public class CmdFly extends FCommand {
|
|||||||
flyMap.remove(fme.getName());
|
flyMap.remove(fme.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInFlightChecker(Player player) {
|
|
||||||
return flyMap.containsKey(player.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void checkEnemiesSync(FPlayer fp) {
|
private static void checkEnemiesSync(FPlayer fp) {
|
||||||
Bukkit.getScheduler().runTask(FactionsPlugin.instance, fp::checkIfNearbyEnemies);
|
Bukkit.getScheduler().runTask(FactionsPlugin.instance, fp::checkIfNearbyEnemies);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isInFlightChecker(Player player) {
|
||||||
|
return flyMap.containsKey(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
if (!context.fPlayer.isAdminBypassing()) {
|
if (!context.fPlayer.isAdminBypassing()) {
|
||||||
@ -173,17 +175,17 @@ public class CmdFly extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> {
|
context.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> {
|
||||||
fme.setFlying(true);
|
fme.setFlying(true);
|
||||||
flyMap.put(fme.getPlayer().getName(), true);
|
flyMap.put(fme.getPlayer().getName(), true);
|
||||||
if (particleTask == null) {
|
if (particleTask == null) {
|
||||||
startParticles();
|
startParticles();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flyTask == null) {
|
if (flyTask == null) {
|
||||||
startFlyCheck();
|
startFlyCheck();
|
||||||
}
|
}
|
||||||
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-fly", 0));
|
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-fly", 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -47,7 +47,9 @@ public class CmdGetVault extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!context.fPlayer.takeMoney(amount)) {return;}
|
if (!context.fPlayer.takeMoney(amount)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//success :)
|
//success :)
|
||||||
context.player.getInventory().addItem(vault);
|
context.player.getInventory().addItem(vault);
|
||||||
|
@ -18,6 +18,7 @@ public class CmdHelp extends FCommand {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public ArrayList<ArrayList<String>> helpPages;
|
public ArrayList<ArrayList<String>> helpPages;
|
||||||
|
|
||||||
//TODO: Add Help GUI
|
//TODO: Add Help GUI
|
||||||
public CmdHelp() {
|
public CmdHelp() {
|
||||||
super();
|
super();
|
||||||
|
@ -139,7 +139,9 @@ public class CmdJoin extends FCommand {
|
|||||||
Discord.mainGuild.getController().setNickname(m, Discord.getNicknameString(context.fPlayer)).queue();
|
Discord.mainGuild.getController().setNickname(m, Discord.getNicknameString(context.fPlayer)).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (HierarchyException e) {System.out.print(e.getMessage());}
|
} catch (HierarchyException e) {
|
||||||
|
System.out.print(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
if (Conf.logFactionJoin) {
|
if (Conf.logFactionJoin) {
|
||||||
if (samePlayer) {
|
if (samePlayer) {
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
public class CmdLeave extends FCommand {
|
public class CmdLeave extends FCommand {
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ public class CmdLock extends FCommand {
|
|||||||
description: use the /f lock [on/off] command to temporarily lock the data files from being overwritten
|
description: use the /f lock [on/off] command to temporarily lock the data files from being overwritten
|
||||||
default: op
|
default: op
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public CmdLock() {
|
public CmdLock() {
|
||||||
super();
|
super();
|
||||||
this.aliases.addAll(Aliases.lock);
|
this.aliases.addAll(Aliases.lock);
|
||||||
|
@ -31,53 +31,53 @@ public class CmdMod extends FCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
FPlayer you = context.argAsBestFPlayerMatch(0);
|
FPlayer you = context.argAsBestFPlayerMatch(0);
|
||||||
if (you == null) {
|
if (you == null) {
|
||||||
FancyMessage msg = new FancyMessage(TL.COMMAND_MOD_CANDIDATES.toString()).color(ChatColor.GOLD);
|
FancyMessage msg = new FancyMessage(TL.COMMAND_MOD_CANDIDATES.toString()).color(ChatColor.GOLD);
|
||||||
for (FPlayer player : context.faction.getFPlayersWhereRole(Role.NORMAL)) {
|
for (FPlayer player : context.faction.getFPlayersWhereRole(Role.NORMAL)) {
|
||||||
String s = player.getName();
|
String s = player.getName();
|
||||||
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " mod " + s);
|
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " mod " + s);
|
||||||
}
|
|
||||||
|
|
||||||
context.sendFancyMessage(msg);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean permAny = Permission.MOD_ANY.has(context.sender, false);
|
context.sendFancyMessage(msg);
|
||||||
Faction targetFaction = you.getFaction();
|
return;
|
||||||
if (targetFaction != context.faction && !permAny) {
|
}
|
||||||
context.msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(context.fPlayer, true));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (context.fPlayer != null && context.fPlayer.getRole() != Role.LEADER && !permAny) {
|
boolean permAny = Permission.MOD_ANY.has(context.sender, false);
|
||||||
context.msg(TL.COMMAND_MOD_NOTADMIN);
|
Faction targetFaction = you.getFaction();
|
||||||
return;
|
if (targetFaction != context.faction && !permAny) {
|
||||||
}
|
context.msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(context.fPlayer, true));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (you == context.fPlayer && !permAny) {
|
if (context.fPlayer != null && context.fPlayer.getRole() != Role.LEADER && !permAny) {
|
||||||
context.msg(TL.COMMAND_MOD_SELF);
|
context.msg(TL.COMMAND_MOD_NOTADMIN);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (you.getRole() == Role.LEADER) {
|
if (you == context.fPlayer && !permAny) {
|
||||||
context.msg(TL.COMMAND_MOD_TARGETISADMIN);
|
context.msg(TL.COMMAND_MOD_SELF);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (you.getRole() == Role.MODERATOR) {
|
if (you.getRole() == Role.LEADER) {
|
||||||
// Revoke
|
context.msg(TL.COMMAND_MOD_TARGETISADMIN);
|
||||||
you.setRole(Role.NORMAL);
|
return;
|
||||||
targetFaction.msg(TL.COMMAND_MOD_REVOKED, you.describeTo(targetFaction, true));
|
}
|
||||||
context.msg(TL.COMMAND_MOD_REVOKES, you.describeTo(context.fPlayer, true));
|
|
||||||
} else {
|
|
||||||
// Give
|
|
||||||
you.setRole(Role.MODERATOR);
|
|
||||||
targetFaction.msg(TL.COMMAND_MOD_PROMOTED, you.describeTo(targetFaction, true));
|
|
||||||
context.msg(TL.COMMAND_MOD_PROMOTES, you.describeTo(context.fPlayer, true));
|
|
||||||
FactionsPlugin.instance.getFlogManager().log(targetFaction, FLogType.RANK_EDIT, context.fPlayer.getName(), you.getName(), ChatColor.LIGHT_PURPLE + "Mod");
|
|
||||||
|
|
||||||
}
|
if (you.getRole() == Role.MODERATOR) {
|
||||||
|
// Revoke
|
||||||
|
you.setRole(Role.NORMAL);
|
||||||
|
targetFaction.msg(TL.COMMAND_MOD_REVOKED, you.describeTo(targetFaction, true));
|
||||||
|
context.msg(TL.COMMAND_MOD_REVOKES, you.describeTo(context.fPlayer, true));
|
||||||
|
} else {
|
||||||
|
// Give
|
||||||
|
you.setRole(Role.MODERATOR);
|
||||||
|
targetFaction.msg(TL.COMMAND_MOD_PROMOTED, you.describeTo(targetFaction, true));
|
||||||
|
context.msg(TL.COMMAND_MOD_PROMOTES, you.describeTo(context.fPlayer, true));
|
||||||
|
FactionsPlugin.instance.getFlogManager().log(targetFaction, FLogType.RANK_EDIT, context.fPlayer.getName(), you.getName(), ChatColor.LIGHT_PURPLE + "Mod");
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,7 +29,6 @@ public class CmdPaypalSee extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (context.args.size() == 0) {
|
if (context.args.size() == 0) {
|
||||||
if (context.fPlayer.getFaction().getPaypal() == null) {
|
if (context.fPlayer.getFaction().getPaypal() == null) {
|
||||||
context.msg(TL.COMMAND_PAYPAL_NOTSET);
|
context.msg(TL.COMMAND_PAYPAL_NOTSET);
|
||||||
|
@ -11,11 +11,15 @@ public class CmdPlayerTitleToggle extends FCommand {
|
|||||||
this.requirements = new CommandRequirements.Builder(Permission.TOGGLE_TITLES)
|
this.requirements = new CommandRequirements.Builder(Permission.TOGGLE_TITLES)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
context.fPlayer.setTitlesEnabled(!context.fPlayer.hasTitlesEnabled());
|
context.fPlayer.setTitlesEnabled(!context.fPlayer.hasTitlesEnabled());
|
||||||
context.msg(TL.COMMAND_TITLETOGGLE_TOGGLED, context.fPlayer.hasTitlesEnabled() ? FactionsPlugin.getInstance().color("&dEnabled") : FactionsPlugin.getInstance().color("&dDisabled"));
|
context.msg(TL.COMMAND_TITLETOGGLE_TOGGLED, context.fPlayer.hasTitlesEnabled() ? FactionsPlugin.getInstance().color("&dEnabled") : FactionsPlugin.getInstance().color("&dDisabled"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TL getUsageTranslation() {return TL.COMMAND_TITLETOGGLE_DESCRIPTION;}
|
public TL getUsageTranslation() {
|
||||||
|
return TL.COMMAND_TITLETOGGLE_DESCRIPTION;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import com.massivecraft.factions.FactionsPlugin;
|
|||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
|
||||||
public class CmdSeeDiscord extends FCommand{
|
public class CmdSeeDiscord extends FCommand {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Driftay
|
* @author Driftay
|
||||||
@ -29,7 +29,6 @@ public class CmdSeeDiscord extends FCommand{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (context.args.size() == 0) {
|
if (context.args.size() == 0) {
|
||||||
if (context.fPlayer.getFaction().getDiscord() == null) {
|
if (context.fPlayer.getFaction().getDiscord() == null) {
|
||||||
context.msg(TL.COMMAND_DISCORD_NOTSET);
|
context.msg(TL.COMMAND_DISCORD_NOTSET);
|
||||||
|
@ -12,7 +12,7 @@ public class CmdSetDiscord extends FCommand {
|
|||||||
* @author Driftay
|
* @author Driftay
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public CmdSetDiscord(){
|
public CmdSetDiscord() {
|
||||||
super();
|
super();
|
||||||
this.aliases.addAll(Aliases.discord_set);
|
this.aliases.addAll(Aliases.discord_set);
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ public class CmdSetDiscord extends FCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDiscordInvite(String invite){
|
private boolean isDiscordInvite(String invite) {
|
||||||
return invite.contains("discord.gg") || invite.contains("discord.me");
|
return invite.contains("discord.gg") || invite.contains("discord.me");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd;
|
|||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.FPlayers;
|
import com.massivecraft.factions.FPlayers;
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import mkremins.fanciful.FancyMessage;
|
import mkremins.fanciful.FancyMessage;
|
||||||
@ -28,12 +27,12 @@ public class CmdShowInvites extends FCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
FancyMessage msg = new FancyMessage(TL.COMMAND_SHOWINVITES_PENDING.toString()).color(ChatColor.GOLD);
|
FancyMessage msg = new FancyMessage(TL.COMMAND_SHOWINVITES_PENDING.toString()).color(ChatColor.GOLD);
|
||||||
for (String id : context.faction.getInvites()) {
|
for (String id : context.faction.getInvites()) {
|
||||||
FPlayer fp = FPlayers.getInstance().getById(id);
|
FPlayer fp = FPlayers.getInstance().getById(id);
|
||||||
String name = fp != null ? fp.getName() : id;
|
String name = fp != null ? fp.getName() : id;
|
||||||
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_SHOWINVITES_CLICKTOREVOKE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
|
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_SHOWINVITES_CLICKTOREVOKE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -11,7 +11,7 @@ public class CmdSpawnerLock extends FCommand {
|
|||||||
* @author Illyria Team
|
* @author Illyria Team
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public CmdSpawnerLock(){
|
public CmdSpawnerLock() {
|
||||||
super();
|
super();
|
||||||
this.aliases.addAll(Aliases.spawnerlock);
|
this.aliases.addAll(Aliases.spawnerlock);
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ public class CmdSpawnerLock extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context){
|
public void perform(CommandContext context) {
|
||||||
Conf.spawnerLock = !Conf.spawnerLock;
|
Conf.spawnerLock = !Conf.spawnerLock;
|
||||||
context.msg(TL.COMMAND_SPAWNER_LOCK_TOGGLED, Conf.spawnerLock ? FactionsPlugin.getInstance().color("&aEnabled") : FactionsPlugin.getInstance().color("&4Disabled"));
|
context.msg(TL.COMMAND_SPAWNER_LOCK_TOGGLED, Conf.spawnerLock ? FactionsPlugin.getInstance().color("&aEnabled") : FactionsPlugin.getInstance().color("&4Disabled"));
|
||||||
}
|
}
|
||||||
|
@ -34,56 +34,56 @@ public class CmdTag extends FCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
|
|
||||||
String tag = context.argAsString(0);
|
String tag = context.argAsString(0);
|
||||||
|
|
||||||
// TODO does not first test cover selfcase?
|
// TODO does not first test cover selfcase?
|
||||||
if (Factions.getInstance().isTagTaken(tag) && !MiscUtil.getComparisonString(tag).equals(context.faction.getComparisonTag())) {
|
if (Factions.getInstance().isTagTaken(tag) && !MiscUtil.getComparisonString(tag).equals(context.faction.getComparisonTag())) {
|
||||||
context.msg(TL.COMMAND_TAG_TAKEN);
|
context.msg(TL.COMMAND_TAG_TAKEN);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<String> errors = MiscUtil.validateTag(tag);
|
||||||
|
if (errors.size() > 0) {
|
||||||
|
context.sendMessage(errors);
|
||||||
|
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 (!context.canAffordCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE.toString())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// trigger the faction rename event (cancellable)
|
||||||
|
FactionRenameEvent renameEvent = new FactionRenameEvent(context.fPlayer, tag);
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(renameEvent);
|
||||||
|
if (renameEvent.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// then make 'em pay (if applicable)
|
||||||
|
if (!context.payForCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE, TL.COMMAND_TAG_FORCHANGE)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String oldtag = context.faction.getTag();
|
||||||
|
context.faction.setTag(tag);
|
||||||
|
Discord.changeFactionTag(context.faction, oldtag);
|
||||||
|
FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.FTAG_EDIT, context.fPlayer.getName(), tag);
|
||||||
|
|
||||||
|
|
||||||
|
// Inform
|
||||||
|
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
|
||||||
|
if (fplayer.getFactionId().equals(context.faction.getId())) {
|
||||||
|
fplayer.msg(TL.COMMAND_TAG_FACTION, context.fPlayer.describeTo(context.faction, true), context.faction.getTag(context.faction));
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
// Broadcast the tag change (if applicable)
|
||||||
ArrayList<String> errors = MiscUtil.validateTag(tag);
|
if (Conf.broadcastTagChanges) {
|
||||||
if (errors.size() > 0) {
|
Faction faction = fplayer.getFaction();
|
||||||
context.sendMessage(errors);
|
fplayer.msg(TL.COMMAND_TAG_CHANGED, context.fPlayer.getColorTo(faction) + oldtag, context.faction.getTag(faction));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
FTeamWrapper.updatePrefixes(context.faction);
|
||||||
if (!context.canAffordCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE.toString())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// trigger the faction rename event (cancellable)
|
|
||||||
FactionRenameEvent renameEvent = new FactionRenameEvent(context.fPlayer, tag);
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(renameEvent);
|
|
||||||
if (renameEvent.isCancelled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// then make 'em pay (if applicable)
|
|
||||||
if (!context.payForCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE, TL.COMMAND_TAG_FORCHANGE)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String oldtag = context.faction.getTag();
|
|
||||||
context.faction.setTag(tag);
|
|
||||||
Discord.changeFactionTag(context.faction, oldtag);
|
|
||||||
FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.FTAG_EDIT, context.fPlayer.getName(), tag);
|
|
||||||
|
|
||||||
|
|
||||||
// Inform
|
|
||||||
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
|
|
||||||
if (fplayer.getFactionId().equals(context.faction.getId())) {
|
|
||||||
fplayer.msg(TL.COMMAND_TAG_FACTION, context.fPlayer.describeTo(context.faction, true), context.faction.getTag(context.faction));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Broadcast the tag change (if applicable)
|
|
||||||
if (Conf.broadcastTagChanges) {
|
|
||||||
Faction faction = fplayer.getFaction();
|
|
||||||
fplayer.msg(TL.COMMAND_TAG_CHANGED, context.fPlayer.getColorTo(faction) + oldtag, context.faction.getTag(faction));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FTeamWrapper.updatePrefixes(context.faction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,7 +2,6 @@ package com.massivecraft.factions.cmd;
|
|||||||
|
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
import com.massivecraft.factions.listeners.FactionsBlockListener;
|
import com.massivecraft.factions.listeners.FactionsBlockListener;
|
||||||
import com.massivecraft.factions.listeners.FactionsPlayerListener;
|
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.util.WarmUpUtil;
|
import com.massivecraft.factions.util.WarmUpUtil;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
@ -308,16 +308,16 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
|||||||
*/
|
*/
|
||||||
public void addVariableCommands() {
|
public void addVariableCommands() {
|
||||||
//Discord
|
//Discord
|
||||||
if (Conf.useDiscordSystem && !discordEnabled) {
|
if (Conf.useDiscordSystem && !discordEnabled) {
|
||||||
this.addSubCommand(this.cmdInviteBot);
|
this.addSubCommand(this.cmdInviteBot);
|
||||||
this.addSubCommand(this.cmdSetGuild);
|
this.addSubCommand(this.cmdSetGuild);
|
||||||
this.addSubCommand(this.cmdSetDiscord);
|
this.addSubCommand(this.cmdSetDiscord);
|
||||||
this.addSubCommand(this.cmdSeeDiscord);
|
this.addSubCommand(this.cmdSeeDiscord);
|
||||||
this.addSubCommand(this.cmdDiscord);
|
this.addSubCommand(this.cmdDiscord);
|
||||||
discordEnabled = true;
|
discordEnabled = true;
|
||||||
}
|
}
|
||||||
//Reserve
|
//Reserve
|
||||||
if(Conf.useReserveSystem){
|
if (Conf.useReserveSystem) {
|
||||||
this.addSubCommand(this.cmdReserve);
|
this.addSubCommand(this.cmdReserve);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,7 +350,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
|||||||
internalFTOPEnabled = true;
|
internalFTOPEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Conf.useAuditSystem){
|
if (Conf.useAuditSystem) {
|
||||||
this.addSubCommand(cmdAudit);
|
this.addSubCommand(cmdAudit);
|
||||||
fAuditEnabled = true;
|
fAuditEnabled = true;
|
||||||
}
|
}
|
||||||
@ -394,7 +394,9 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rebuild() {if (CommodoreProvider.isSupported()) brigadierManager.build();}
|
public void rebuild() {
|
||||||
|
if (CommodoreProvider.isSupported()) brigadierManager.build();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
|
@ -25,7 +25,7 @@ public class CmdKickAlt extends FCommand {
|
|||||||
* @author Driftay
|
* @author Driftay
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public CmdKickAlt(){
|
public CmdKickAlt() {
|
||||||
super();
|
super();
|
||||||
this.aliases.addAll(Aliases.alts_kick);
|
this.aliases.addAll(Aliases.alts_kick);
|
||||||
this.requiredArgs.add("player name");
|
this.requiredArgs.add("player name");
|
||||||
@ -86,7 +86,7 @@ public class CmdKickAlt extends FCommand {
|
|||||||
// This statement allows us to check if they've specifically denied it,
|
// This statement allows us to check if they've specifically denied it,
|
||||||
// or default to
|
// or default to
|
||||||
// the old setting of allowing moderators to kick
|
// the old setting of allowing moderators to kick
|
||||||
if (access != Access.ALLOW && !context.assertMinRole(Role.MODERATOR)) {
|
if (access != Access.ALLOW && !context.assertMinRole(Role.MODERATOR)) {
|
||||||
context.msg(TL.GENERIC_NOPERMISSION, "kick");
|
context.msg(TL.GENERIC_NOPERMISSION, "kick");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,11 @@ public class CmdAudit extends FCommand {
|
|||||||
.noErrorOnManyArgs()
|
.noErrorOnManyArgs()
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
Faction faction = context.args.size() == 1 && context.sender.isOp() ? context.argAsFaction(0) : context.faction;
|
Faction faction = context.args.size() == 1 && context.sender.isOp() ? context.argAsFaction(0) : context.faction;
|
||||||
new FAuditMenu((Player)context.sender, faction).open((Player)context.sender);
|
new FAuditMenu((Player) context.sender, faction).open((Player) context.sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
|
|||||||
/*
|
/*
|
||||||
@author Saser
|
@author Saser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
@ -92,9 +93,9 @@ public class FAuditMenu extends GUIMenu {
|
|||||||
LinkedList<FactionLogs.FactionLog> log = logs.getMostRecentLogs().get(logType);
|
LinkedList<FactionLogs.FactionLog> log = logs.getMostRecentLogs().get(logType);
|
||||||
if (log != null) {
|
if (log != null) {
|
||||||
int slot = logType == FLogType.F_TNT ? 0 : 3;
|
int slot = logType == FLogType.F_TNT ? 0 : 3;
|
||||||
int pagesToShow = (int)Math.max(1.0D, Math.ceil((double)log.size() / (double)perPage));
|
int pagesToShow = (int) Math.max(1.0D, Math.ceil((double) log.size() / (double) perPage));
|
||||||
|
|
||||||
for(int page = 1; page <= pagesToShow; ++page) {
|
for (int page = 1; page <= pagesToShow; ++page) {
|
||||||
int startIndex = log.size() - (page * perPage - perPage);
|
int startIndex = log.size() - (page * perPage - perPage);
|
||||||
if (startIndex >= log.size()) {
|
if (startIndex >= log.size()) {
|
||||||
startIndex = log.size() - 1;
|
startIndex = log.size() - 1;
|
||||||
@ -102,7 +103,7 @@ public class FAuditMenu extends GUIMenu {
|
|||||||
|
|
||||||
List<String> lore = Lists.newArrayList("", CC.GreenB + "Logs");
|
List<String> lore = Lists.newArrayList("", CC.GreenB + "Logs");
|
||||||
|
|
||||||
for(int i = startIndex; i > startIndex - perPage; --i) {
|
for (int i = startIndex; i > startIndex - perPage; --i) {
|
||||||
if (i < log.size()) {
|
if (i < log.size()) {
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
break;
|
break;
|
||||||
|
@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
|
|||||||
/**
|
/**
|
||||||
* @author Saser
|
* @author Saser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.FPlayers;
|
import com.massivecraft.factions.FPlayers;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
@ -45,17 +46,20 @@ public class FChestListener implements Listener {
|
|||||||
Player player = (Player) event.getWhoClicked();
|
Player player = (Player) event.getWhoClicked();
|
||||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||||
Faction faction;
|
Faction faction;
|
||||||
if(!event.getView().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")))) return;
|
if (!event.getView().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title"))))
|
||||||
|
return;
|
||||||
if (event.getClick() == ClickType.UNKNOWN) {
|
if (event.getClick() == ClickType.UNKNOWN) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(CC.RedB + "(!) " + CC.Red + "You cannot use that click type inside the /f chest!");
|
player.sendMessage(CC.RedB + "(!) " + CC.Red + "You cannot use that click type inside the /f chest!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ItemStack currentItem = event.getCurrentItem();
|
ItemStack currentItem = event.getCurrentItem();
|
||||||
if (event.getClick() == ClickType.NUMBER_KEY) currentItem = event.getClickedInventory().getItem(event.getSlot());
|
if (event.getClick() == ClickType.NUMBER_KEY)
|
||||||
|
currentItem = event.getClickedInventory().getItem(event.getSlot());
|
||||||
Material currentItemType = currentItem != null ? currentItem.getType() : Material.AIR;
|
Material currentItemType = currentItem != null ? currentItem.getType() : Material.AIR;
|
||||||
ItemStack cursorItem = event.getCursor();
|
ItemStack cursorItem = event.getCursor();
|
||||||
if (event.getClick() == ClickType.NUMBER_KEY) cursorItem = player.getInventory().getItem(event.getHotbarButton());
|
if (event.getClick() == ClickType.NUMBER_KEY)
|
||||||
|
cursorItem = player.getInventory().getItem(event.getHotbarButton());
|
||||||
Material cursorItemType = cursorItem != null ? cursorItem.getType() : Material.AIR;
|
Material cursorItemType = cursorItem != null ? cursorItem.getType() : Material.AIR;
|
||||||
if (fPlayer == null || !(faction = fPlayer.getFaction()).isNormal()) {
|
if (fPlayer == null || !(faction = fPlayer.getFaction()).isNormal()) {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
@ -65,16 +69,16 @@ public class FChestListener implements Listener {
|
|||||||
if (event.getClickedInventory() == null) return;
|
if (event.getClickedInventory() == null) return;
|
||||||
if (event.getView().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title"))) && !event.getClick().isShiftClick()) {
|
if (event.getView().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title"))) && !event.getClick().isShiftClick()) {
|
||||||
if (currentItemType != Material.AIR) {
|
if (currentItemType != Material.AIR) {
|
||||||
Inventory ours = faction.getChestInventory();
|
Inventory ours = faction.getChestInventory();
|
||||||
if(event.getClickedInventory() == ours) {
|
if (event.getClickedInventory() == ours) {
|
||||||
if (ours == null || !ours.contains(currentItem)) {
|
if (ours == null || !ours.contains(currentItem)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(CC.RedB + "(!) That item not longer exists!");
|
player.sendMessage(CC.RedB + "(!) That item not longer exists!");
|
||||||
Bukkit.getLogger().info("[FactionChest] " + player.getName() + " tried to remove " + currentItem + " from /f chest when it didnt contain! Items: " + (ours == null ? "none" : Arrays.toString(ours.getContents())));
|
Bukkit.getLogger().info("[FactionChest] " + player.getName() + " tried to remove " + currentItem + " from /f chest when it didnt contain! Items: " + (ours == null ? "none" : Arrays.toString(ours.getContents())));
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
logRemoveItem(currentItem, fPlayer, player);
|
logRemoveItem(currentItem, fPlayer, player);
|
||||||
} else if (cursorItemType != Material.AIR && !event.isShiftClick()) {
|
} else if (cursorItemType != Material.AIR && !event.isShiftClick()) {
|
||||||
logAddItem(cursorItem, fPlayer, player);
|
logAddItem(cursorItem, fPlayer, player);
|
||||||
|
@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
|
|||||||
/**
|
/**
|
||||||
* @author Saser
|
* @author Saser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
@ -127,7 +128,7 @@ public class FLogManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JSONUtils.saveJSONToFile(logFile, factionLogMap,logToken);
|
JSONUtils.saveJSONToFile(logFile, factionLogMap, logToken);
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
Bukkit.getLogger().info("ERROR SAVING JSON LOGS: " + e1.getMessage());
|
Bukkit.getLogger().info("ERROR SAVING JSON LOGS: " + e1.getMessage());
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
|
@ -27,8 +27,10 @@ public enum FLogType {
|
|||||||
private String msg;
|
private String msg;
|
||||||
private int requiredArgs;
|
private int requiredArgs;
|
||||||
|
|
||||||
public String getDisplayName() {
|
FLogType(String displayName, String msg, int requiredArgs) {
|
||||||
return this.displayName;
|
this.displayName = displayName;
|
||||||
|
this.msg = msg;
|
||||||
|
this.requiredArgs = requiredArgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,15 +48,22 @@ public enum FLogType {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public String getDisplayName() {
|
||||||
public String toString() { return name(); }
|
return this.displayName;
|
||||||
|
|
||||||
public int getSlot() { return FactionsPlugin.getInstance().getConfig().getInt("faudit-gui.slots." + name().toLowerCase()); }
|
|
||||||
|
|
||||||
public Material getMaterial(){
|
|
||||||
return XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("faudit-gui.materials." + name().toLowerCase())).parseMaterial();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSlot() {
|
||||||
|
return FactionsPlugin.getInstance().getConfig().getInt("faudit-gui.slots." + name().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getMaterial() {
|
||||||
|
return XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("faudit-gui.materials." + name().toLowerCase())).parseMaterial();
|
||||||
|
}
|
||||||
|
|
||||||
public String getMsg() {
|
public String getMsg() {
|
||||||
return this.msg;
|
return this.msg;
|
||||||
@ -63,10 +72,4 @@ public enum FLogType {
|
|||||||
public int getRequiredArgs() {
|
public int getRequiredArgs() {
|
||||||
return this.requiredArgs;
|
return this.requiredArgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
FLogType(String displayName, String msg, int requiredArgs) {
|
|
||||||
this.displayName = displayName;
|
|
||||||
this.msg = msg;
|
|
||||||
this.requiredArgs = requiredArgs;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
|
|||||||
/**
|
/**
|
||||||
* @author Saser
|
* @author Saser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -16,8 +17,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class FactionLogs {
|
public class FactionLogs {
|
||||||
private Map<FLogType, LinkedList<FactionLog>> mostRecentLogs = new ConcurrentHashMap<>();
|
|
||||||
public static transient SimpleDateFormat format = new SimpleDateFormat("MM/dd hh:mmaa");
|
public static transient SimpleDateFormat format = new SimpleDateFormat("MM/dd hh:mmaa");
|
||||||
|
private Map<FLogType, LinkedList<FactionLog>> mostRecentLogs = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public FactionLogs() {
|
public FactionLogs() {
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
|
|||||||
/**
|
/**
|
||||||
* @author Saser
|
* @author Saser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@ -65,11 +66,32 @@ public class LogTimer extends ConcurrentHashMap<LogTimer.TimerType, Map<LogTimer
|
|||||||
return this.username;
|
return this.username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum TimerSubType {
|
||||||
|
SPAWNER_BREAK,
|
||||||
|
SPAWNER_PLACE;
|
||||||
|
|
||||||
|
TimerSubType() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum TimerType {
|
||||||
|
SPAWNER_EDIT;
|
||||||
|
|
||||||
|
TimerType() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class Timer {
|
public class Timer {
|
||||||
private long startTime;
|
private long startTime;
|
||||||
private long count;
|
private long count;
|
||||||
private Object extraData;
|
private Object extraData;
|
||||||
|
|
||||||
|
public Timer(long startTime, long count, Object extraData) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
this.count = count;
|
||||||
|
this.extraData = extraData;
|
||||||
|
}
|
||||||
|
|
||||||
LogTimer.Timer increment(long amount) {
|
LogTimer.Timer increment(long amount) {
|
||||||
this.count += amount;
|
this.count += amount;
|
||||||
return this;
|
return this;
|
||||||
@ -79,47 +101,28 @@ public class LogTimer extends ConcurrentHashMap<LogTimer.TimerType, Map<LogTimer
|
|||||||
return System.currentTimeMillis() - this.startTime >= expiration;
|
return System.currentTimeMillis() - this.startTime >= expiration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Timer(long startTime, long count, Object extraData) {
|
|
||||||
this.startTime = startTime;
|
|
||||||
this.count = count;
|
|
||||||
this.extraData = extraData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getStartTime() {
|
public long getStartTime() {
|
||||||
return this.startTime;
|
return this.startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getCount() {
|
|
||||||
return this.count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getExtraData() {
|
|
||||||
return this.extraData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStartTime(long startTime) {
|
public void setStartTime(long startTime) {
|
||||||
this.startTime = startTime;
|
this.startTime = startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getCount() {
|
||||||
|
return this.count;
|
||||||
|
}
|
||||||
|
|
||||||
public void setCount(long count) {
|
public void setCount(long count) {
|
||||||
this.count = count;
|
this.count = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object getExtraData() {
|
||||||
|
return this.extraData;
|
||||||
|
}
|
||||||
|
|
||||||
public void setExtraData(Object extraData) {
|
public void setExtraData(Object extraData) {
|
||||||
this.extraData = extraData;
|
this.extraData = extraData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum TimerSubType {
|
|
||||||
SPAWNER_BREAK,
|
|
||||||
SPAWNER_PLACE;
|
|
||||||
TimerSubType() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum TimerType {
|
|
||||||
SPAWNER_EDIT;
|
|
||||||
TimerType() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ public class CmdWeeWoo extends FCommand {
|
|||||||
}
|
}
|
||||||
context.faction.setWeeWoo(false);
|
context.faction.setWeeWoo(false);
|
||||||
context.msg(TL.COMMAND_WEEWOO_STOPPED, context.fPlayer.getNameAndTag());
|
context.msg(TL.COMMAND_WEEWOO_STOPPED, context.fPlayer.getNameAndTag());
|
||||||
if(!Conf.useDiscordSystem) return;
|
if (!Conf.useDiscordSystem) return;
|
||||||
String discordChannelId = context.faction.getWeeWooChannelId();
|
String discordChannelId = context.faction.getWeeWooChannelId();
|
||||||
if (discordChannelId != null && !discordChannelId.isEmpty()) {
|
if (discordChannelId != null && !discordChannelId.isEmpty()) {
|
||||||
TextChannel textChannel = Discord.jda.getTextChannelById(discordChannelId);
|
TextChannel textChannel = Discord.jda.getTextChannelById(discordChannelId);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.massivecraft.factions.cmd.claim;
|
package com.massivecraft.factions.cmd.claim;
|
||||||
|
|
||||||
import com.massivecraft.factions.Board;
|
import com.massivecraft.factions.Board;
|
||||||
import com.massivecraft.factions.Conf;
|
|
||||||
import com.massivecraft.factions.FLocation;
|
import com.massivecraft.factions.FLocation;
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
import com.massivecraft.factions.cmd.Aliases;
|
import com.massivecraft.factions.cmd.Aliases;
|
||||||
|
@ -89,7 +89,7 @@ public class CmdClaimLine extends FCommand {
|
|||||||
location = location.add(blockFace.getModX() * 16, 0, blockFace.getModZ() * 16);
|
location = location.add(blockFace.getModX() * 16, 0, blockFace.getModZ() * 16);
|
||||||
FactionsPlugin.instance.logFactionEvent(forFaction, FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.GreenB + "CLAIMED", String.valueOf(i), new FLocation(context.player.getLocation()).formatXAndZ(","));
|
FactionsPlugin.instance.logFactionEvent(forFaction, FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.GreenB + "CLAIMED", String.valueOf(i), new FLocation(context.player.getLocation()).formatXAndZ(","));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TL getUsageTranslation() {
|
public TL getUsageTranslation() {
|
||||||
|
@ -10,8 +10,6 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
import com.massivecraft.factions.util.CornerTask;
|
import com.massivecraft.factions.util.CornerTask;
|
||||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
@ -21,7 +21,6 @@ public class CmdUnclaimall extends FCommand {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//TODO: Add UnclaimAll Confirmation GUI
|
//TODO: Add UnclaimAll Confirmation GUI
|
||||||
|
|
||||||
public CmdUnclaimall() {
|
public CmdUnclaimall() {
|
||||||
this.aliases.addAll(Aliases.unclaim_all_unsafe);
|
this.aliases.addAll(Aliases.unclaim_all_unsafe);
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class CmdMoney extends FCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
if (!Conf.econEnabled || !Conf.bankEnabled) {
|
if (!Conf.econEnabled || !Conf.bankEnabled) {
|
||||||
context.msg(TL.ECON_OFF, "economy option is enabled, please set \'econEnabled\' to true in conf.json");
|
context.msg(TL.ECON_OFF, "economy option is enabled, please set 'econEnabled' to true in conf.json");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
context.commandChain.add(this);
|
context.commandChain.add(this);
|
||||||
|
@ -8,7 +8,6 @@ import com.massivecraft.factions.cmd.FCommand;
|
|||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
public class CmdMoneyBalance extends FCommand {
|
public class CmdMoneyBalance extends FCommand {
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ public class CmdGrace extends FCommand {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//TODO: Make Timed Format For Grace Period
|
//TODO: Make Timed Format For Grace Period
|
||||||
|
|
||||||
public CmdGrace() {
|
public CmdGrace() {
|
||||||
super();
|
super();
|
||||||
this.aliases.addAll(Aliases.grace);
|
this.aliases.addAll(Aliases.grace);
|
||||||
|
@ -84,7 +84,7 @@ public abstract class FRelationCommand extends FCommand {
|
|||||||
// trigger the faction relation event
|
// trigger the faction relation event
|
||||||
FactionRelationEvent relationEvent = new FactionRelationEvent(context.faction, them, oldRelation, currentRelation);
|
FactionRelationEvent relationEvent = new FactionRelationEvent(context.faction, them, oldRelation, currentRelation);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(relationEvent);
|
Bukkit.getServer().getPluginManager().callEvent(relationEvent);
|
||||||
FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.RELATION_CHANGE,context.fPlayer.getName(), this.targetRelation.getColor() + this.targetRelation.name(), oldRelation.getColor() + them.getTag());
|
FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.RELATION_CHANGE, context.fPlayer.getName(), this.targetRelation.getColor() + this.targetRelation.name(), oldRelation.getColor() + them.getTag());
|
||||||
FactionsPlugin.instance.logFactionEvent(them, FLogType.RELATION_CHANGE, oldRelation.getColor() + context.fPlayer.getName(), this.targetRelation.getColor() + this.targetRelation.name(), "your faction");
|
FactionsPlugin.instance.logFactionEvent(them, FLogType.RELATION_CHANGE, oldRelation.getColor() + context.fPlayer.getName(), this.targetRelation.getColor() + this.targetRelation.name(), "your faction");
|
||||||
|
|
||||||
them.msg(TL.COMMAND_RELATIONS_MUTUAL, currentRelationColor + targetRelation.getTranslation(), currentRelationColor + context.faction.getTag());
|
them.msg(TL.COMMAND_RELATIONS_MUTUAL, currentRelationColor + targetRelation.getTranslation(), currentRelationColor + context.faction.getTag());
|
||||||
|
@ -10,14 +10,22 @@ import java.util.ArrayList;
|
|||||||
public class ListParameterizedType implements ParameterizedType {
|
public class ListParameterizedType implements ParameterizedType {
|
||||||
private Type type;
|
private Type type;
|
||||||
|
|
||||||
public ListParameterizedType(Type type) { this.type = type; }
|
public ListParameterizedType(Type type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type[] getActualTypeArguments() { return new Type[] { this.type }; }
|
public Type[] getActualTypeArguments() {
|
||||||
|
return new Type[]{this.type};
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type getRawType() { return ArrayList.class; }
|
public Type getRawType() {
|
||||||
|
return ArrayList.class;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type getOwnerType() { return null; }
|
public Type getOwnerType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,16 @@ package com.massivecraft.factions.cmd.reserve;
|
|||||||
public class ReserveObject {
|
public class ReserveObject {
|
||||||
private String name;
|
private String name;
|
||||||
private String factionName;
|
private String factionName;
|
||||||
public ReserveObject(String name, String factionName){
|
|
||||||
|
public ReserveObject(String name, String factionName) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.factionName = factionName;
|
this.factionName = factionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFactionName() {
|
public String getFactionName() {
|
||||||
return this.factionName;
|
return this.factionName;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,24 @@ public class CmdTnt extends FCommand {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void removeItems(Inventory inventory, ItemStack item, int toRemove) {
|
||||||
|
if (toRemove <= 0 || inventory == null || item == null)
|
||||||
|
return;
|
||||||
|
for (int i = 0; i < inventory.getSize(); i++) {
|
||||||
|
ItemStack loopItem = inventory.getItem(i);
|
||||||
|
if (loopItem == null || !item.isSimilar(loopItem))
|
||||||
|
continue;
|
||||||
|
if (toRemove <= 0)
|
||||||
|
return;
|
||||||
|
if (toRemove < loopItem.getAmount()) {
|
||||||
|
loopItem.setAmount(loopItem.getAmount() - toRemove);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
inventory.clear(i);
|
||||||
|
toRemove -= loopItem.getAmount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
if (!FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) {
|
if (!FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) {
|
||||||
@ -110,8 +128,10 @@ public class CmdTnt extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i <= fullStacks - 1; i++) context.player.getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), 64));
|
for (int i = 0; i <= fullStacks - 1; i++)
|
||||||
if (remainderAmt != 0) context.player.getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), remainderAmt));
|
context.player.getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), 64));
|
||||||
|
if (remainderAmt != 0)
|
||||||
|
context.player.getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), remainderAmt));
|
||||||
|
|
||||||
context.faction.takeTnt(amount);
|
context.faction.takeTnt(amount);
|
||||||
context.player.updateInventory();
|
context.player.updateInventory();
|
||||||
@ -123,7 +143,9 @@ public class CmdTnt extends FCommand {
|
|||||||
Inventory inv = context.player.getInventory();
|
Inventory inv = context.player.getInventory();
|
||||||
int invTnt = 0;
|
int invTnt = 0;
|
||||||
for (int i = 0; i <= inv.getSize(); i++) {
|
for (int i = 0; i <= inv.getSize(); i++) {
|
||||||
if (inv.getItem(i) == null) { continue; }
|
if (inv.getItem(i) == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (inv.getItem(i).getType() == Material.TNT) {
|
if (inv.getItem(i).getType() == Material.TNT) {
|
||||||
invTnt += inv.getItem(i).getAmount();
|
invTnt += inv.getItem(i).getAmount();
|
||||||
}
|
}
|
||||||
@ -152,7 +174,6 @@ public class CmdTnt extends FCommand {
|
|||||||
context.sendMessage(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", context.faction.getTnt() + "").replace("{maxAmount}", context.faction.getTntBankLimit() + ""));
|
context.sendMessage(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", context.faction.getTnt() + "").replace("{maxAmount}", context.faction.getTntBankLimit() + ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean inventoryContains(Inventory inventory, ItemStack item) {
|
public boolean inventoryContains(Inventory inventory, ItemStack item) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
ItemStack[] items = inventory.getContents();
|
ItemStack[] items = inventory.getContents();
|
||||||
@ -177,24 +198,6 @@ public class CmdTnt extends FCommand {
|
|||||||
return check >= howmany;
|
return check >= howmany;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeItems(Inventory inventory, ItemStack item, int toRemove) {
|
|
||||||
if (toRemove <= 0 || inventory == null || item == null)
|
|
||||||
return;
|
|
||||||
for (int i = 0; i < inventory.getSize(); i++) {
|
|
||||||
ItemStack loopItem = inventory.getItem(i);
|
|
||||||
if (loopItem == null || !item.isSimilar(loopItem))
|
|
||||||
continue;
|
|
||||||
if (toRemove <= 0)
|
|
||||||
return;
|
|
||||||
if (toRemove < loopItem.getAmount()) {
|
|
||||||
loopItem.setAmount(loopItem.getAmount() - toRemove);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
inventory.clear(i);
|
|
||||||
toRemove -= loopItem.getAmount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeFromInventory(Inventory inventory, ItemStack item) {
|
public void removeFromInventory(Inventory inventory, ItemStack item) {
|
||||||
int amt = item.getAmount();
|
int amt = item.getAmount();
|
||||||
ItemStack[] items = inventory.getContents();
|
ItemStack[] items = inventory.getContents();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.massivecraft.factions.cmd.tnt;
|
package com.massivecraft.factions.cmd.tnt;
|
||||||
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.FactionsPlugin;
|
import com.massivecraft.factions.FactionsPlugin;
|
||||||
import com.massivecraft.factions.cmd.Aliases;
|
import com.massivecraft.factions.cmd.Aliases;
|
||||||
import com.massivecraft.factions.cmd.CommandContext;
|
import com.massivecraft.factions.cmd.CommandContext;
|
||||||
@ -23,13 +24,9 @@ import java.util.*;
|
|||||||
|
|
||||||
public class CmdTntFill extends FCommand {
|
public class CmdTntFill extends FCommand {
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Illyria Team
|
|
||||||
*/
|
|
||||||
|
|
||||||
public CmdTntFill() {
|
public CmdTntFill() {
|
||||||
super();
|
super();
|
||||||
this.aliases.addAll(Aliases.tnt_tntfill);
|
this.aliases.add("tntfill");
|
||||||
|
|
||||||
this.requiredArgs.add("radius");
|
this.requiredArgs.add("radius");
|
||||||
this.requiredArgs.add("amount");
|
this.requiredArgs.add("amount");
|
||||||
@ -43,8 +40,8 @@ public class CmdTntFill extends FCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
if (!FactionsPlugin.instance.getConfig().getBoolean("Tntfill.enabled")) {
|
if (!FactionsPlugin.getInstance().getConfig().getBoolean("Tntfill.enabled")) {
|
||||||
context.msg(TL.COMMAND_TNT_DISABLED_MSG);
|
context.msg(TL.GENERIC_DISABLED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,23 +55,23 @@ public class CmdTntFill extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
context.msg(TL.COMMAND_TNTFILL_HEADER);
|
context.msg(TL.COMMAND_TNTFILL_HEADER);
|
||||||
int radius = context.argAsInt(0, 0); // We don't know the max yet, so let's not assume.
|
// We don't know the max yet, so let's not assume.
|
||||||
int amount = context.argAsInt(1, 0); // We don't know the max yet, so let's not assume.
|
int radius = context.argAsInt(0, 0);
|
||||||
|
int amount = context.argAsInt(1, 0);
|
||||||
|
|
||||||
if (amount <= 0 || radius <= 0) {
|
if (amount < 0) {
|
||||||
context.msg(TL.COMMAND_TNT_POSITIVE);
|
context.msg(TL.COMMAND_TNT_POSITIVE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (radius > FactionsPlugin.getInstance().getConfig().getInt("Tntfill.max-radius")) {
|
||||||
if (radius > FactionsPlugin.instance.getConfig().getInt("Tntfill.max-radius")) {
|
context.msg(TL.COMMAND_TNTFILL_RADIUSMAX.toString().replace("{max}", FactionsPlugin.getInstance().getConfig().getInt("Tntfill.max-radius") + ""));
|
||||||
context.msg(TL.COMMAND_TNTFILL_RADIUSMAX.toString().replace("{max}", FactionsPlugin.instance.getConfig().getInt("Tntfill.max-radius") + ""));
|
return;
|
||||||
|
}
|
||||||
|
if (amount > FactionsPlugin.getInstance().getConfig().getInt("Tntfill.max-amount")) {
|
||||||
|
context.msg(TL.COMMAND_TNTFILL_AMOUNTMAX.toString().replace("{max}", FactionsPlugin.getInstance().getConfig().getInt("Tntfill.max-amount") + ""));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (amount > FactionsPlugin.instance.getConfig().getInt("Tntfill.max-amount")) {
|
|
||||||
context.msg(TL.COMMAND_TNTFILL_AMOUNTMAX.toString().replace("{max}", FactionsPlugin.instance.getConfig().getInt("Tntfill.max-amount") + ""));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// How many dispensers are we to fill in?
|
// How many dispensers are we to fill in?
|
||||||
|
|
||||||
Location start = context.player.getLocation();
|
Location start = context.player.getLocation();
|
||||||
@ -89,103 +86,82 @@ public class CmdTntFill extends FCommand {
|
|||||||
if (block == null) continue;
|
if (block == null) continue;
|
||||||
BlockState blockState = block.getState();
|
BlockState blockState = block.getState();
|
||||||
if (!(blockState instanceof Dispenser)) continue;
|
if (!(blockState instanceof Dispenser)) continue;
|
||||||
|
Dispenser dis = (Dispenser) blockState;
|
||||||
|
// skip if we can't add anything
|
||||||
|
if (isInvFull(dis.getInventory())) continue;
|
||||||
opDispensers.add((Dispenser) blockState);
|
opDispensers.add((Dispenser) blockState);
|
||||||
}
|
}
|
||||||
if (opDispensers.isEmpty()) {
|
if (opDispensers.isEmpty()) {
|
||||||
context.fPlayer.msg(TL.COMMAND_TNTFILL_NODISPENSERS.toString().replace("{radius}", radius + ""));
|
context.fPlayer.msg(TL.COMMAND_TNTFILL_NODISPENSERS.toString().replace("{radius}", radius + ""));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// What's the required amount of resources
|
|
||||||
int requiredTnt = (opDispensers.size() * amount);
|
int requiredTnt = (opDispensers.size() * amount);
|
||||||
|
int playerTnt = getTNTInside(context.player);
|
||||||
// Do I have enough tnt in my inventory?
|
// if player does not have enough tnt, just take whatever he has and add it to the bank
|
||||||
int playerTnt = inventoryItemCount(context.player.getInventory(), Material.TNT);
|
// then use the bank as source. If bank < required abort.
|
||||||
if (playerTnt < requiredTnt) {
|
if (playerTnt < requiredTnt) {
|
||||||
// How much TNT will I take from bank?
|
|
||||||
int getFactionTnt = requiredTnt - playerTnt;
|
|
||||||
|
|
||||||
// Do I have enough tnt in bank?
|
// Do I have enough tnt in bank?
|
||||||
if ((context.faction.getTnt() < getFactionTnt)) {
|
if ((context.faction.getTnt() < (requiredTnt - playerTnt))) {
|
||||||
context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
|
context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// move whatever tnt you have to the bank, ignoring limit because its gonna be taken out later anyways
|
||||||
// Take TNT from the bank.
|
context.faction.addTnt(playerTnt);
|
||||||
removeFromBank(context, getFactionTnt);
|
removeItems(context.fPlayer.getPlayer().getInventory(), new ItemStack(Material.TNT), playerTnt);
|
||||||
|
// Take TNT from the bank
|
||||||
|
fillDispensers(context, opDispensers, amount);
|
||||||
|
} else {
|
||||||
|
// Take TNT from the player
|
||||||
|
fillDispensers(context.fPlayer, opDispensers, amount);
|
||||||
}
|
}
|
||||||
fillDispensers(context.fPlayer, opDispensers, amount);
|
|
||||||
// Remove used TNT from player inventory.
|
|
||||||
context.sendMessage(TL.COMMAND_TNTFILL_SUCCESS.toString().replace("{amount}", requiredTnt + "").replace("{dispensers}", opDispensers.size() + ""));
|
context.sendMessage(TL.COMMAND_TNTFILL_SUCCESS.toString().replace("{amount}", requiredTnt + "").replace("{dispensers}", opDispensers.size() + ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actually fill every dispenser with the precise amount.
|
// Actually fill every dispenser with the precise amount.
|
||||||
private void fillDispensers(FPlayer fPlayer, List<Dispenser> dispensers, int count) {
|
private void fillDispensers(FPlayer fPlayer, List<Dispenser> dispensers, int count) {
|
||||||
for (Dispenser dispenser : dispensers) {
|
for (Dispenser dispenser : dispensers) {
|
||||||
if (takeTnt(fPlayer, count)) {
|
int canBeAdded = getAddable(dispenser.getInventory(), Material.TNT);
|
||||||
dispenser.getInventory().addItem(new ItemStack(Material.TNT, count));
|
if (canBeAdded <= 0) continue;
|
||||||
} else {return;}
|
int toAdd = Math.min(canBeAdded, count);
|
||||||
|
if (toAdd > getTNTInside(fPlayer.getPlayer())) {
|
||||||
|
fPlayer.msg(TL.COMMAND_TNTFILL_NOTENOUGH.toString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
removeItems(fPlayer.getPlayer().getInventory(), new ItemStack(Material.TNT), toAdd);
|
||||||
|
dispenser.getInventory().addItem(new ItemStack(Material.TNT, toAdd));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeFromBank(CommandContext context, int amount) {
|
private void fillDispensers(CommandContext context, List<Dispenser> dispensers, int count) {
|
||||||
try {
|
for (Dispenser dispenser : dispensers) {
|
||||||
Integer.parseInt(context.args.get(1));
|
int canBeAdded = getAddable(dispenser.getInventory(), Material.TNT);
|
||||||
} catch (NumberFormatException e) {
|
if (canBeAdded <= 0) continue;
|
||||||
context.fPlayer.msg(TL.COMMAND_TNT_INVALID_NUM.toString());
|
int toAdd = Math.min(canBeAdded, count);
|
||||||
return;
|
if (context.faction.getTnt() < toAdd) {
|
||||||
|
context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
context.faction.takeTnt(toAdd);
|
||||||
|
dispenser.getInventory().addItem(new ItemStack(Material.TNT, toAdd));
|
||||||
}
|
}
|
||||||
if (amount < 0) {
|
|
||||||
context.fPlayer.msg(TL.COMMAND_TNT_POSITIVE.toString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (context.faction.getTnt() < amount) {
|
|
||||||
context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int fullStacks = amount / 64;
|
|
||||||
int remainderAmt = amount % 64;
|
|
||||||
if ((remainderAmt == 0 && getEmptySlots(context.player) <= fullStacks)) {
|
|
||||||
context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (getEmptySlots(context.player) + 1 <= fullStacks) {
|
|
||||||
context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ItemStack tnt64 = new ItemStack(Material.TNT, 64);
|
|
||||||
for (int i = 0; i <= fullStacks - 1; i++) {
|
|
||||||
context.player.getInventory().addItem(tnt64);
|
|
||||||
}
|
|
||||||
if (remainderAmt != 0) {
|
|
||||||
ItemStack tnt = new ItemStack(Material.TNT, remainderAmt);
|
|
||||||
context.player.getInventory().addItem(tnt);
|
|
||||||
}
|
|
||||||
context.faction.takeTnt(amount);
|
|
||||||
context.player.updateInventory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean takeTnt(FPlayer fme, int amount) {
|
public static void removeItems(Inventory inventory, ItemStack item, int toRemove) {
|
||||||
Inventory inv = fme.getPlayer().getInventory();
|
if (toRemove <= 0 || inventory == null || item == null)
|
||||||
int invTnt = 0;
|
return;
|
||||||
for (int i = 0; i <= inv.getSize(); i++) {
|
for (int i = 0; i < inventory.getSize(); i++) {
|
||||||
if (inv.getItem(i) == null) {
|
ItemStack loopItem = inventory.getItem(i);
|
||||||
|
if (loopItem == null || !item.isSimilar(loopItem))
|
||||||
continue;
|
continue;
|
||||||
|
if (toRemove <= 0)
|
||||||
|
return;
|
||||||
|
if (toRemove < loopItem.getAmount()) {
|
||||||
|
loopItem.setAmount(loopItem.getAmount() - toRemove);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (inv.getItem(i).getType() == Material.TNT) {
|
inventory.clear(i);
|
||||||
invTnt += inv.getItem(i).getAmount();
|
toRemove -= loopItem.getAmount();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (amount > invTnt) {
|
|
||||||
fme.msg(TL.COMMAND_TNTFILL_NOTENOUGH.toString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
ItemStack tnt = new ItemStack(Material.TNT, amount);
|
|
||||||
if (fme.getFaction().getTnt() + amount > FactionsPlugin.getInstance().getConfig().getInt("ftnt.Bank-Limit")) {
|
|
||||||
fme.msg(TL.COMMAND_TNT_EXCEEDLIMIT.toString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
removeFromInventory(fme.getPlayer().getInventory(), tnt);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Counts the item type available in the inventory.
|
// Counts the item type available in the inventory.
|
||||||
@ -197,35 +173,37 @@ public class CmdTntFill extends FCommand {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeFromInventory(Inventory inventory, ItemStack item) {
|
public int getAddable(Inventory inv, Material material) {
|
||||||
int amt = item.getAmount();
|
int output = 0;
|
||||||
ItemStack[] items = inventory.getContents();
|
int notempty = 0;
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (int i = 0; i < inv.getSize(); ++i) {
|
||||||
if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) {
|
ItemStack is = inv.getItem(i);
|
||||||
if (items[i].getAmount() > amt) {
|
if (is != null) {
|
||||||
items[i].setAmount(items[i].getAmount() - amt);
|
++notempty;
|
||||||
break;
|
if (is.getType() == material) {
|
||||||
} else if (items[i].getAmount() == amt) {
|
int amount = is.getAmount();
|
||||||
items[i] = null;
|
output += 64 - amount;
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
amt -= items[i].getAmount();
|
|
||||||
items[i] = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inventory.setContents(items);
|
return output + (inv.getSize() - notempty) * 64;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getEmptySlots(Player p) {
|
public boolean isInvFull(Inventory inv) {
|
||||||
PlayerInventory inventory = p.getInventory();
|
return inv.firstEmpty() == -1;
|
||||||
ItemStack[] cont = inventory.getContents();
|
}
|
||||||
int i = 0;
|
|
||||||
for (ItemStack item : cont)
|
public int getTNTInside(Player p) {
|
||||||
if (item != null && item.getType() != Material.AIR) {
|
int result = 0;
|
||||||
i++;
|
PlayerInventory pi = p.getInventory();
|
||||||
|
ItemStack[] contents;
|
||||||
|
for (int length = (contents = pi.getContents()).length, i = 0; i < length; ++i) {
|
||||||
|
ItemStack is = contents[i];
|
||||||
|
if (is != null && is.getType() == Material.TNT) {
|
||||||
|
result += is.getAmount();
|
||||||
}
|
}
|
||||||
return 36 - i;
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,22 +27,26 @@ public class CmdWild extends FCommand {
|
|||||||
public static HashMap<Player, Integer> waitingTeleport;
|
public static HashMap<Player, Integer> waitingTeleport;
|
||||||
public static HashMap<Player, String> teleportRange;
|
public static HashMap<Player, String> teleportRange;
|
||||||
public static HashSet<Player> teleporting;
|
public static HashSet<Player> teleporting;
|
||||||
|
|
||||||
public CmdWild() {
|
public CmdWild() {
|
||||||
super();
|
super();
|
||||||
this.aliases.addAll(Aliases.wild);
|
this.aliases.addAll(Aliases.wild);
|
||||||
this.requirements = new CommandRequirements.Builder(Permission.WILD)
|
this.requirements = new CommandRequirements.Builder(Permission.WILD)
|
||||||
.playerOnly()
|
.playerOnly()
|
||||||
.build();
|
.build();
|
||||||
waitingTeleport = new HashMap<>();
|
waitingTeleport = new HashMap<>();
|
||||||
teleporting = new HashSet<>();
|
teleporting = new HashSet<>();
|
||||||
teleportRange = new HashMap<>();
|
teleportRange = new HashMap<>();
|
||||||
startWild();
|
startWild();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
if (!waitingTeleport.containsKey(context.player)) {
|
if (!waitingTeleport.containsKey(context.player)) {
|
||||||
context.player.openInventory(new WildGUI(context.player, context.fPlayer).getInventory());
|
context.player.openInventory(new WildGUI(context.player, context.fPlayer).getInventory());
|
||||||
} else {context.fPlayer.msg(TL.COMMAND_WILD_WAIT);}
|
} else {
|
||||||
|
context.fPlayer.msg(TL.COMMAND_WILD_WAIT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startWild() {
|
public void startWild() {
|
||||||
@ -64,6 +68,7 @@ public class CmdWild extends FCommand {
|
|||||||
}
|
}
|
||||||
}, 0L, 20L);
|
}, 0L, 20L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attemptTeleport(Player p) {
|
public void attemptTeleport(Player p) {
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
int tries = 0;
|
int tries = 0;
|
||||||
@ -84,26 +89,34 @@ public class CmdWild extends FCommand {
|
|||||||
}
|
}
|
||||||
tries++;
|
tries++;
|
||||||
}
|
}
|
||||||
if (!success) {p.sendMessage(TL.COMMAND_WILD_FAILED.toString());}
|
if (!success) {
|
||||||
|
p.sendMessage(TL.COMMAND_WILD_FAILED.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void teleportPlayer(Player p, FLocation loc) {
|
public void teleportPlayer(Player p, FLocation loc) {
|
||||||
Location finalLoc;
|
Location finalLoc;
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("Wild.Arrival.SpawnAbove")) {
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("Wild.Arrival.SpawnAbove")) {
|
||||||
finalLoc = new Location(p.getWorld(), loc.getX(), p.getWorld().getHighestBlockYAt(Math.round(loc.getX()), Math.round(loc.getZ())) + FactionsPlugin.getInstance().getConfig().getInt("Wild.Arrival.SpawnAboveBlocks", 1), loc.getZ());
|
finalLoc = new Location(p.getWorld(), loc.getX(), p.getWorld().getHighestBlockYAt(Math.round(loc.getX()), Math.round(loc.getZ())) + FactionsPlugin.getInstance().getConfig().getInt("Wild.Arrival.SpawnAboveBlocks", 1), loc.getZ());
|
||||||
} else {finalLoc = new Location(p.getWorld(), loc.getX(), p.getWorld().getHighestBlockYAt(Math.round(loc.getX()), Math.round(loc.getZ())), loc.getZ());}
|
} else {
|
||||||
|
finalLoc = new Location(p.getWorld(), loc.getX(), p.getWorld().getHighestBlockYAt(Math.round(loc.getX()), Math.round(loc.getZ())), loc.getZ());
|
||||||
|
}
|
||||||
p.teleport(finalLoc, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
p.teleport(finalLoc, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||||
setTeleporting(p);
|
setTeleporting(p);
|
||||||
applyEffects(p);
|
applyEffects(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyEffects(Player p) {
|
public void applyEffects(Player p) {
|
||||||
for (String s : FactionsPlugin.getInstance().getConfig().getStringList("Wild.Arrival.Effects")) {
|
for (String s : FactionsPlugin.getInstance().getConfig().getStringList("Wild.Arrival.Effects")) {
|
||||||
p.addPotionEffect(new PotionEffect(PotionEffectType.getByName(s), 40, 1));
|
p.addPotionEffect(new PotionEffect(PotionEffectType.getByName(s), 40, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTeleporting(Player p) {
|
public void setTeleporting(Player p) {
|
||||||
teleporting.add(p);
|
teleporting.add(p);
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> teleporting.remove(p), FactionsPlugin.getInstance().getConfig().getInt("Wild.Arrival.FallDamageWindow") * 20);
|
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> teleporting.remove(p), FactionsPlugin.getInstance().getConfig().getInt("Wild.Arrival.FallDamageWindow") * 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TL getUsageTranslation() {
|
public TL getUsageTranslation() {
|
||||||
return TL.COMMAND_WILD_DESCRIPTION;
|
return TL.COMMAND_WILD_DESCRIPTION;
|
||||||
|
@ -23,11 +23,13 @@ public class WildGUI implements FactionGUI {
|
|||||||
FPlayer fplayer;
|
FPlayer fplayer;
|
||||||
HashMap<Integer, String> map;
|
HashMap<Integer, String> map;
|
||||||
Inventory inv;
|
Inventory inv;
|
||||||
|
|
||||||
public WildGUI(Player player, FPlayer fplayer) {
|
public WildGUI(Player player, FPlayer fplayer) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.fplayer = fplayer;
|
this.fplayer = fplayer;
|
||||||
map = new HashMap<>();
|
map = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(int slot, ClickType action) {
|
public void onClick(int slot, ClickType action) {
|
||||||
if (map.containsKey(slot)) {
|
if (map.containsKey(slot)) {
|
||||||
@ -46,7 +48,7 @@ public class WildGUI implements FactionGUI {
|
|||||||
inv = Bukkit.createInventory(this, FactionsPlugin.getInstance().getConfig().getInt("Wild.GUI.Size"), FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("Wild.GUI.Name")));
|
inv = Bukkit.createInventory(this, FactionsPlugin.getInstance().getConfig().getInt("Wild.GUI.Size"), FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("Wild.GUI.Name")));
|
||||||
ItemStack fillItem = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("Wild.GUI.FillMaterial")).parseItem();
|
ItemStack fillItem = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("Wild.GUI.FillMaterial")).parseItem();
|
||||||
ItemMeta meta = fillItem.getItemMeta();
|
ItemMeta meta = fillItem.getItemMeta();
|
||||||
if(meta == null) return;
|
if (meta == null) return;
|
||||||
meta.setDisplayName("");
|
meta.setDisplayName("");
|
||||||
fillItem.setItemMeta(meta);
|
fillItem.setItemMeta(meta);
|
||||||
for (int fill = 0; fill < FactionsPlugin.getInstance().getConfig().getInt("Wild.GUI.Size"); ++fill) {
|
for (int fill = 0; fill < FactionsPlugin.getInstance().getConfig().getInt("Wild.GUI.Size"); ++fill) {
|
||||||
@ -55,7 +57,7 @@ public class WildGUI implements FactionGUI {
|
|||||||
for (String key : Objects.requireNonNull(FactionsPlugin.getInstance().getConfig().getConfigurationSection("Wild.Zones")).getKeys(false)) {
|
for (String key : Objects.requireNonNull(FactionsPlugin.getInstance().getConfig().getConfigurationSection("Wild.Zones")).getKeys(false)) {
|
||||||
ItemStack zoneItem = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("Wild.Zones." + key + ".Material")).parseItem();
|
ItemStack zoneItem = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("Wild.Zones." + key + ".Material")).parseItem();
|
||||||
ItemMeta zoneMeta = zoneItem.getItemMeta();
|
ItemMeta zoneMeta = zoneItem.getItemMeta();
|
||||||
if(zoneMeta == null) return;
|
if (zoneMeta == null) return;
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
for (String s : FactionsPlugin.getInstance().getConfig().getStringList("Wild.Zones." + key + ".Lore")) {
|
for (String s : FactionsPlugin.getInstance().getConfig().getStringList("Wild.Zones." + key + ".Lore")) {
|
||||||
lore.add(FactionsPlugin.getInstance().color(s));
|
lore.add(FactionsPlugin.getInstance().color(s));
|
||||||
@ -72,7 +74,9 @@ public class WildGUI implements FactionGUI {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
if (inv == null) {build();}
|
if (inv == null) {
|
||||||
|
build();
|
||||||
|
}
|
||||||
return inv;
|
return inv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
27
src/main/java/com/massivecraft/factions/util/Pair.java
Normal file
27
src/main/java/com/massivecraft/factions/util/Pair.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package com.massivecraft.factions.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factions - Developed by FactionsUUID Team.
|
||||||
|
*/
|
||||||
|
public class Pair<Left, Right> {
|
||||||
|
|
||||||
|
public static <Left, Right> Pair<Left, Right> of(Left left, Right right) {
|
||||||
|
return new Pair<>(left, right);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Left left;
|
||||||
|
private final Right right;
|
||||||
|
|
||||||
|
private Pair(Left left, Right right) {
|
||||||
|
this.left = left;
|
||||||
|
this.right = right;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Left getLeft() {
|
||||||
|
return this.left;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Right getRight() {
|
||||||
|
return this.right;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user