Added F InventorySee

This commit is contained in:
Driftay
2019-06-29 10:20:59 -04:00
parent be9bdaa4fd
commit 4c3b8b0d18
14 changed files with 134 additions and 37 deletions

View File

@@ -0,0 +1,70 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.SaberFactions;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import java.util.ArrayList;
import java.util.Objects;
public class CmdInventorySee extends FCommand {
public CmdInventorySee() {
super();
this.aliases.add("invsee");
this.aliases.add("inventorysee");
this.requiredArgs.add("member name");
this.permission = Permission.INVSEE.node;
this.disableOnLock = true;
this.disableOnSpam = false;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
}
@Override
public void perform() {
if (SaberFactions.plugin.getConfig().getBoolean("f-inventory-see.Enabled")) {
fme.msg(TL.GENERIC_DISABLED);
}
Access use = myFaction.getAccess(fme, PermissableAction.TERRITORY);
if (use == Access.DENY || (use == Access.UNDEFINED && !assertMinRole(Role.MODERATOR))) {
fme.msg(TL.GENERIC_NOPERMISSION, "territory");
return;
}
ArrayList<Player> fplayers = myFaction.getOnlinePlayers();
FPlayer targetInv = argAsFPlayer(0);
if (targetInv == null || !fplayers.contains(targetInv.getPlayer())) {
fme.msg(TL.PLAYER_NOT_FOUND, Objects.requireNonNull(targetInv).toString());
return;
}
Inventory inventory = Bukkit.createInventory(me, 36, targetInv.getName() + "'s Inventory");
for (int i = 0; i < 36; i++)
if (targetInv.getPlayer().getInventory().getItem(i) != null)
inventory.setItem(i, targetInv.getPlayer().getInventory().getItem(i));
me.openInventory(inventory);
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_INVENTORYSEE_DESCRIPTION;
}
}

View File

@@ -110,6 +110,7 @@ public class FCmdRoot extends FCommand {
public CmdAlts cmdAlts = new CmdAlts();
public CmdSpam cmdSpam = new CmdSpam();
public CmdCorner cmdCorner = new CmdCorner();
public CmdInventorySee cmdInventorySee = new CmdInventorySee();
@@ -228,6 +229,10 @@ public class FCmdRoot extends FCommand {
this.addSubCommand(this.cmdCorner);
if (SaberFactions.plugin.getConfig().getBoolean("f-inventory-see.Enabled")) {
this.addSubCommand(this.cmdInventorySee);
}
if(SaberFactions.plugin.getConfig().getBoolean("f-alts.Enabled")){
this.addSubCommand(cmdAlts);
}

View File

@@ -668,6 +668,17 @@ public class FactionsPlayerListener implements Listener {
}
}
@EventHandler
public void onInentorySee(InventoryClickEvent e) {
if (e.getCurrentItem() == null)
return;
if (!e.getInventory().getName().endsWith("'s Inventory View"))
return;
e.setCancelled(true);
}
@EventHandler
public void onPlayerBoneMeal(PlayerInteractEvent event) {
Block block = event.getClickedBlock();

View File

@@ -37,6 +37,7 @@ public enum Permission {
HELP("help"),
HOME("home"),
INVITE("invite"),
INVSEE("invsee"),
JOIN("join"),
JOIN_ANY("join.any"),
JOIN_OTHERS("join.others"),

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 ProSavage
* Copyright (C) 2019 Driftay
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -351,6 +351,8 @@ public enum TL {
COMMAND_HOME_DESCRIPTION("Teleport to the faction home"),
COMMAND_HOME_BLOCKED("&c&l[!] You may not teleport to a home that is claimed by &b%1$s"),
COMMAND_INVENTORYSEE_DESCRIPTION("View a faction members inventory"),
COMMAND_INSPECT_DISABLED_MSG("&c&l[!]&7 Inspect mode is now &cdisabled."),
COMMAND_INSPECT_DISABLED_NOFAC("&c&l[!]&7 Inspect mode is now &cdisabled,&7 because you &cdo not have a faction!"),
COMMAND_INSPECT_ENABLED("&c&l[!]&7 Inspect mode is now &aEnabled."),
@@ -899,6 +901,8 @@ public enum TL {
GENERIC_MONEYTAKE("&c{amount} has been taken from your account."),
PLAYER_NOT_FOUND("&c&l[!] &b%1$s &7is either not online or not in your faction!"),
WARBANNER_NOFACTION("&cYou need a faction to use a warbanner!"),
WARBANNER_COOLDOWN("&cThe warbanner is on cooldown for your faction!"),
WARBANNER_INVALIDLOC("&cYou can only use warbanners in enemy land or the warzone"),

View File

@@ -1,7 +1,7 @@
# SaberFactions by Driftay
# Report issues: https://github.com/Driftay/SaberFactions/issues/new
# Live support: https://discord.gg/22AQtX7
# Spigot Site: https://www.spigotmc.org/resources/savagefactions-factionsuuid-reimagined-1-7-1-12.52891/
# Live support: https://discord.gg/TFxWKeX
# Spigot Site: https://www.spigotmc.org/resources/saberfactions-1-7-1-13-the-complete-factions-solution.68840/
# Website: https://www.saberllc.net/
# Jenkins: https://jenkins.saberllc.net/
@@ -711,7 +711,13 @@ faction-disband-broadcast: true
############################################################
See-Invisible-Faction-Members: false
############################################################
# +------------------------------------------------------+ #
# | Faction Inventory See | #
# +------------------------------------------------------+ #
############################################################
f-inventory-see:
Enabled: true
############################################################
# +------------------------------------------------------+ #
# | Faction Alt Accounts | #