Added F Notifcations Command (Allows Players To Disable Notifications From Land Claiming)
This commit is contained in:
parent
95a202d2cf
commit
c237667def
@ -10,6 +10,7 @@ public class Aliases {
|
|||||||
/**
|
/**
|
||||||
* @author DroppingAnvil
|
* @author DroppingAnvil
|
||||||
*/
|
*/
|
||||||
|
public static ArrayList<String> notifications = new ArrayList<>(Arrays.asList("notifications", "notis"));
|
||||||
public static ArrayList<String> alts_alts = new ArrayList<>(Arrays.asList("alts", "alt"));
|
public static ArrayList<String> alts_alts = new ArrayList<>(Arrays.asList("alts", "alt"));
|
||||||
public static ArrayList<String> alts_list = new ArrayList<>(Arrays.asList("list", "l"));
|
public static ArrayList<String> alts_list = new ArrayList<>(Arrays.asList("list", "l"));
|
||||||
public static ArrayList<String> alts_invite = new ArrayList<>(Collections.singletonList("invite"));
|
public static ArrayList<String> alts_invite = new ArrayList<>(Collections.singletonList("invite"));
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factions - Developed by Driftay.
|
||||||
|
* All rights reserved 2020.
|
||||||
|
* Creation Date: 4/2/2020
|
||||||
|
*/
|
||||||
|
public class CmdNotifications extends FCommand {
|
||||||
|
|
||||||
|
public CmdNotifications() {
|
||||||
|
super();
|
||||||
|
this.aliases.addAll(Aliases.notifications);
|
||||||
|
this.requirements = new CommandRequirements.Builder(Permission.NOTIFICATIONS)
|
||||||
|
.playerOnly()
|
||||||
|
.memberOnly()
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void perform(CommandContext context) {
|
||||||
|
if (context.fPlayer.hasNotificationsEnabled()) {
|
||||||
|
context.fPlayer.setNotificationsEnabled(false);
|
||||||
|
context.msg(TL.COMMAND_NOTIFICATIONS_TOGGLED_OFF);
|
||||||
|
} else {
|
||||||
|
context.fPlayer.setNotificationsEnabled(true);
|
||||||
|
context.msg(TL.COMMAND_NOTIFICATIONS_TOGGLED_ON);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TL getUsageTranslation() {
|
||||||
|
return TL.COMMAND_NOTIFICATIONS_DESCRIPTION;
|
||||||
|
}
|
||||||
|
}
|
@ -170,6 +170,8 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
|||||||
public CmdReserve cmdReserve = new CmdReserve();
|
public CmdReserve cmdReserve = new CmdReserve();
|
||||||
public CmdDelHome cmdDelHome = new CmdDelHome();
|
public CmdDelHome cmdDelHome = new CmdDelHome();
|
||||||
public CmdClaimFill cmdClaimFill = new CmdClaimFill();
|
public CmdClaimFill cmdClaimFill = new CmdClaimFill();
|
||||||
|
public CmdNotifications cmdNotifications = new CmdNotifications();
|
||||||
|
|
||||||
//Variables to know if we already setup certain sub commands
|
//Variables to know if we already setup certain sub commands
|
||||||
public Boolean discordEnabled = false;
|
public Boolean discordEnabled = false;
|
||||||
public Boolean checkEnabled = false;
|
public Boolean checkEnabled = false;
|
||||||
@ -303,6 +305,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
|||||||
this.addSubCommand(this.cmdSpawnerLock);
|
this.addSubCommand(this.cmdSpawnerLock);
|
||||||
this.addSubCommand(this.cmdDrain);
|
this.addSubCommand(this.cmdDrain);
|
||||||
this.addSubCommand(this.cmdLookup);
|
this.addSubCommand(this.cmdLookup);
|
||||||
|
this.addSubCommand(this.cmdNotifications);
|
||||||
addVariableCommands();
|
addVariableCommands();
|
||||||
if (CommodoreProvider.isSupported()) brigadierManager.build();
|
if (CommodoreProvider.isSupported()) brigadierManager.build();
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,7 @@ public enum Permission {
|
|||||||
MAP("map"),
|
MAP("map"),
|
||||||
MAPHEIGHT("mapheight"),
|
MAPHEIGHT("mapheight"),
|
||||||
MOD("mod"),
|
MOD("mod"),
|
||||||
|
NOTIFICATIONS("notifications"),
|
||||||
COLEADER("coleader"),
|
COLEADER("coleader"),
|
||||||
MOD_ANY("mod.any"),
|
MOD_ANY("mod.any"),
|
||||||
COLEADER_ANY("coleader.any"),
|
COLEADER_ANY("coleader.any"),
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
package com.massivecraft.factions.util;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Saser
|
|
||||||
*/
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ItemUtil {
|
|
||||||
private static Map<String, ItemStack> cachedSkulls = new HashMap<>();
|
|
||||||
|
|
||||||
public ItemUtil() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getItemCount(Inventory inventory) {
|
|
||||||
if (inventory == null) {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
int itemsFound = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < inventory.getSize(); ++i) {
|
|
||||||
ItemStack item = inventory.getItem(i);
|
|
||||||
if (item != null && item.getType() != Material.AIR) {
|
|
||||||
++itemsFound;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return itemsFound;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStack createPlayerHead(String name) {
|
|
||||||
ItemStack skull = cachedSkulls.get(name);
|
|
||||||
if (skull != null) {
|
|
||||||
return skull.clone();
|
|
||||||
} else {
|
|
||||||
skull = new ItemStack(XMaterial.PLAYER_HEAD.parseMaterial());
|
|
||||||
SkullMeta sm = (SkullMeta) skull.getItemMeta();
|
|
||||||
sm.setOwner(name);
|
|
||||||
skull.setItemMeta(sm);
|
|
||||||
cachedSkulls.put(name, skull.clone());
|
|
||||||
return skull;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
package com.massivecraft.factions.util;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Factions - Developed by FactionsUUID Team.
|
|
||||||
*/
|
|
||||||
public class Pair<Left, Right> {
|
|
||||||
|
|
||||||
private final Left left;
|
|
||||||
private final Right right;
|
|
||||||
private Pair(Left left, Right right) {
|
|
||||||
this.left = left;
|
|
||||||
this.right = right;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <Left, Right> Pair<Left, Right> of(Left left, Right right) {
|
|
||||||
return new Pair<>(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Left getLeft() {
|
|
||||||
return this.left;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Right getRight() {
|
|
||||||
return this.right;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
package com.massivecraft.factions.util;
|
|
||||||
|
|
||||||
import java.util.TreeMap;
|
|
||||||
|
|
||||||
public class RomanNumber {
|
|
||||||
private static TreeMap<Integer, String> map;
|
|
||||||
|
|
||||||
static {
|
|
||||||
(map = new TreeMap<>()).put(1000, "M");
|
|
||||||
RomanNumber.map.put(900, "CM");
|
|
||||||
RomanNumber.map.put(500, "D");
|
|
||||||
RomanNumber.map.put(400, "CD");
|
|
||||||
RomanNumber.map.put(100, "C");
|
|
||||||
RomanNumber.map.put(90, "XC");
|
|
||||||
RomanNumber.map.put(50, "L");
|
|
||||||
RomanNumber.map.put(40, "XL");
|
|
||||||
RomanNumber.map.put(10, "X");
|
|
||||||
RomanNumber.map.put(9, "IX");
|
|
||||||
RomanNumber.map.put(5, "V");
|
|
||||||
RomanNumber.map.put(4, "IV");
|
|
||||||
RomanNumber.map.put(1, "I");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toRoman(int number) {
|
|
||||||
int l = RomanNumber.map.floorKey(number);
|
|
||||||
if (number == l) {
|
|
||||||
return RomanNumber.map.get(number);
|
|
||||||
}
|
|
||||||
return RomanNumber.map.get(l) + toRoman(number - l);
|
|
||||||
}
|
|
||||||
}
|
|
@ -86,7 +86,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
protected transient long lastFrostwalkerMessage;
|
protected transient long lastFrostwalkerMessage;
|
||||||
protected transient boolean shouldTakeFallDamage = true;
|
protected transient boolean shouldTakeFallDamage = true;
|
||||||
protected boolean isStealthEnabled = false;
|
protected boolean isStealthEnabled = false;
|
||||||
protected boolean notificationsEnabled = true;
|
protected boolean notificationsEnabled;
|
||||||
protected boolean titlesEnabled = true;
|
protected boolean titlesEnabled = true;
|
||||||
protected boolean isAlt = false;
|
protected boolean isAlt = false;
|
||||||
boolean inspectMode = false;
|
boolean inspectMode = false;
|
||||||
@ -112,6 +112,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
this.getDeaths();
|
this.getDeaths();
|
||||||
this.showScoreboard = FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-enabled", false);
|
this.showScoreboard = FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-enabled", false);
|
||||||
this.mapHeight = Conf.mapHeight;
|
this.mapHeight = Conf.mapHeight;
|
||||||
|
this.notificationsEnabled = true;
|
||||||
|
|
||||||
if (!Conf.newPlayerStartingFactionID.equals("0") && Factions.getInstance().isValidFactionId(Conf.newPlayerStartingFactionID)) {
|
if (!Conf.newPlayerStartingFactionID.equals("0") && Factions.getInstance().isValidFactionId(Conf.newPlayerStartingFactionID)) {
|
||||||
this.factionId = Conf.newPlayerStartingFactionID;
|
this.factionId = Conf.newPlayerStartingFactionID;
|
||||||
@ -141,6 +142,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
this.notificationsEnabled = other.notificationsEnabled;
|
this.notificationsEnabled = other.notificationsEnabled;
|
||||||
this.showScoreboard = FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-enabled", true);
|
this.showScoreboard = FactionsPlugin.getInstance().getConfig().getBoolean("scoreboard.default-enabled", true);
|
||||||
this.mapHeight = Conf.mapHeight;
|
this.mapHeight = Conf.mapHeight;
|
||||||
|
this.notificationsEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAlt() {
|
public boolean isAlt() {
|
||||||
@ -1255,8 +1257,10 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
Set<FPlayer> informTheseFPlayers = new HashSet<>();
|
Set<FPlayer> informTheseFPlayers = new HashSet<>();
|
||||||
informTheseFPlayers.add(this);
|
informTheseFPlayers.add(this);
|
||||||
informTheseFPlayers.addAll(forFaction.getFPlayersWhereOnline(true));
|
informTheseFPlayers.addAll(forFaction.getFPlayersWhereOnline(true));
|
||||||
for (FPlayer fp : informTheseFPlayers)
|
for (FPlayer fp : informTheseFPlayers) {
|
||||||
|
if (!fp.hasNotificationsEnabled()) continue;
|
||||||
fp.msg(TL.CLAIM_CLAIMED, this.describeTo(fp, true), forFaction.describeTo(fp), currentFaction.describeTo(fp));
|
fp.msg(TL.CLAIM_CLAIMED, this.describeTo(fp, true), forFaction.describeTo(fp), currentFaction.describeTo(fp));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Board.getInstance().setFactionAt(forFaction, flocation);
|
Board.getInstance().setFactionAt(forFaction, flocation);
|
||||||
|
Loading…
Reference in New Issue
Block a user