Add Faction vaults.
These can be accessed with /f vault <number> Set a Faction's max vaults with /f setmaxvaults <faction> <number> - can be run from console so Buycraft can execute it. * This is a not very tested implementation. Should be tested more in depth before being pushed to a release.
This commit is contained in:
parent
46805200dd
commit
0294a60675
9
pom.xml
9
pom.xml
@ -310,6 +310,11 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.drtshock</groupId>
|
||||||
|
<artifactId>PlayerVaults</artifactId>
|
||||||
|
<version>3.6.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
@ -337,5 +342,9 @@
|
|||||||
<id>stealthyone-snapshots</id>
|
<id>stealthyone-snapshots</id>
|
||||||
<url>http://repo.stealthyone.com/content/repositories/snapshots/</url>
|
<url>http://repo.stealthyone.com/content/repositories/snapshots/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>playervaults</id>
|
||||||
|
<url>https://ci.drtshock.net/plugin/repository/everything/</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
</project>
|
</project>
|
||||||
|
@ -356,6 +356,9 @@ public class Conf {
|
|||||||
public static Set<String> worldsIgnorePvP = new LinkedHashSet<String>();
|
public static Set<String> worldsIgnorePvP = new LinkedHashSet<String>();
|
||||||
public static Set<String> worldsNoWildernessProtection = new LinkedHashSet<String>();
|
public static Set<String> worldsNoWildernessProtection = new LinkedHashSet<String>();
|
||||||
|
|
||||||
|
// faction-<factionId>
|
||||||
|
public static String vaultPrefix = "faction-%s";
|
||||||
|
|
||||||
public static Backend backEnd = Backend.JSON;
|
public static Backend backEnd = Backend.JSON;
|
||||||
|
|
||||||
public static transient int mapHeight = 8;
|
public static transient int mapHeight = 8;
|
||||||
|
@ -27,6 +27,10 @@ public interface Faction extends EconomyParticipator {
|
|||||||
|
|
||||||
public void clearWarps();
|
public void clearWarps();
|
||||||
|
|
||||||
|
public int getMaxVaults();
|
||||||
|
|
||||||
|
public void setMaxVaults(int value);
|
||||||
|
|
||||||
public void addAnnouncement(FPlayer fPlayer, String msg);
|
public void addAnnouncement(FPlayer fPlayer, String msg);
|
||||||
|
|
||||||
public void sendUnreadAnnouncements(FPlayer fPlayer);
|
public void sendUnreadAnnouncements(FPlayer fPlayer);
|
||||||
|
@ -20,6 +20,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
@ -56,6 +57,8 @@ public class P extends MPlugin {
|
|||||||
public FCmdRoot cmdBase;
|
public FCmdRoot cmdBase;
|
||||||
public CmdAutoHelp cmdAutoHelp;
|
public CmdAutoHelp cmdAutoHelp;
|
||||||
|
|
||||||
|
private boolean hookedPlayervaults;
|
||||||
|
|
||||||
public P() {
|
public P() {
|
||||||
p = this;
|
p = this;
|
||||||
}
|
}
|
||||||
@ -71,6 +74,7 @@ public class P extends MPlugin {
|
|||||||
// Load Conf from disk
|
// Load Conf from disk
|
||||||
Conf.load();
|
Conf.load();
|
||||||
Essentials.setup();
|
Essentials.setup();
|
||||||
|
hookedPlayervaults = setupPlayervaults();
|
||||||
FPlayers.getInstance().load();
|
FPlayers.getInstance().load();
|
||||||
Factions.getInstance().load();
|
Factions.getInstance().load();
|
||||||
for (FPlayer fPlayer : FPlayers.getInstance().getAllFPlayers()) {
|
for (FPlayer fPlayer : FPlayers.getInstance().getAllFPlayers()) {
|
||||||
@ -128,6 +132,11 @@ public class P extends MPlugin {
|
|||||||
return perms != null;
|
return perms != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean setupPlayervaults() {
|
||||||
|
Plugin plugin = getServer().getPluginManager().getPlugin("PlayerVaults");
|
||||||
|
return plugin != null && plugin.isEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GsonBuilder getGsonBuilder() {
|
public GsonBuilder getGsonBuilder() {
|
||||||
Type mapFLocToStringSetType = new TypeToken<Map<FLocation, Set<String>>>() {
|
Type mapFLocToStringSetType = new TypeToken<Map<FLocation, Set<String>>>() {
|
||||||
@ -312,6 +321,10 @@ public class P extends MPlugin {
|
|||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isHookedPlayervaults() {
|
||||||
|
return hookedPlayervaults;
|
||||||
|
}
|
||||||
|
|
||||||
public String getPrimaryGroup(OfflinePlayer player) {
|
public String getPrimaryGroup(OfflinePlayer player) {
|
||||||
return perms == null || !perms.hasGroupSupport() ? " " : perms.getPrimaryGroup(Bukkit.getWorlds().get(0).toString(), player);
|
return perms == null || !perms.hasGroupSupport() ? " " : perms.getPrimaryGroup(Bukkit.getWorlds().get(0).toString(), player);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
|
import com.massivecraft.factions.P;
|
||||||
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
|
public class CmdSetMaxVaults extends FCommand {
|
||||||
|
|
||||||
|
public CmdSetMaxVaults() {
|
||||||
|
this.aliases.add("setmaxvaults");
|
||||||
|
this.aliases.add("smv");
|
||||||
|
|
||||||
|
this.requiredArgs.add("faction");
|
||||||
|
this.requiredArgs.add("number");
|
||||||
|
|
||||||
|
this.permission = Permission.SETMAXVAULTS.node;
|
||||||
|
this.disableOnLock = false;
|
||||||
|
|
||||||
|
senderMustBePlayer = false;
|
||||||
|
senderMustBeMember = false;
|
||||||
|
senderMustBeModerator = false;
|
||||||
|
senderMustBeAdmin = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void perform() {
|
||||||
|
Faction targetFaction = argAsFaction(0);
|
||||||
|
int value = argAsInt(1, -1);
|
||||||
|
if(value < 0) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Number must be greater than 0.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(targetFaction == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Couldn't find Faction: " + ChatColor.YELLOW + argAsString(0));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
targetFaction.setMaxVaults(value);
|
||||||
|
sender.sendMessage(TL.COMMAND_SETMAXVAULTS_SUCCESS.format(targetFaction.getTag(), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TL getUsageTranslation() {
|
||||||
|
return TL.COMMAND_SETMAXVAULTS_DESCRIPTION;
|
||||||
|
}
|
||||||
|
}
|
84
src/main/java/com/massivecraft/factions/cmd/CmdVault.java
Normal file
84
src/main/java/com/massivecraft/factions/cmd/CmdVault.java
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
|
import com.drtshock.playervaults.PlayerVaults;
|
||||||
|
import com.drtshock.playervaults.util.Lang;
|
||||||
|
import com.drtshock.playervaults.vaultmanagement.UUIDVaultManager;
|
||||||
|
import com.drtshock.playervaults.vaultmanagement.VaultOperations;
|
||||||
|
import com.drtshock.playervaults.vaultmanagement.VaultViewInfo;
|
||||||
|
import com.massivecraft.factions.Conf;
|
||||||
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class CmdVault extends FCommand {
|
||||||
|
|
||||||
|
public CmdVault() {
|
||||||
|
this.aliases.add("vault");
|
||||||
|
|
||||||
|
//this.requiredArgs.add("");
|
||||||
|
this.optionalArgs.put("number", "number");
|
||||||
|
|
||||||
|
this.permission = Permission.VAULT.node;
|
||||||
|
this.disableOnLock = false;
|
||||||
|
|
||||||
|
senderMustBePlayer = true;
|
||||||
|
senderMustBeMember = true;
|
||||||
|
senderMustBeModerator = false;
|
||||||
|
senderMustBeAdmin = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void perform() {
|
||||||
|
/*
|
||||||
|
/f vault <number>
|
||||||
|
*/
|
||||||
|
|
||||||
|
int number = argAsInt(0, 0); // Default to 0 or show on 0
|
||||||
|
|
||||||
|
Player player = me;
|
||||||
|
|
||||||
|
if (PlayerVaults.getInstance().getInVault().containsKey(player.getUniqueId().toString())) {
|
||||||
|
return; // Already in a vault so they must be trying to dupe.
|
||||||
|
}
|
||||||
|
|
||||||
|
int max = myFaction.getMaxVaults();
|
||||||
|
if (number > max) {
|
||||||
|
me.sendMessage(TL.COMMAND_VAULTS_TOOHIGH.format(number, max));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Something like faction-id
|
||||||
|
String vaultName = String.format(Conf.vaultPrefix, myFaction.getId());
|
||||||
|
|
||||||
|
if (number < 1) {
|
||||||
|
// Message about which vaults that Faction has.
|
||||||
|
// List the target
|
||||||
|
YamlConfiguration file = UUIDVaultManager.getInstance().getPlayerVaultFile(vaultName);
|
||||||
|
if (file == null) {
|
||||||
|
sender.sendMessage(Lang.TITLE.toString() + Lang.VAULT_DOES_NOT_EXIST.toString());
|
||||||
|
} else {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (String key : file.getKeys(false)) {
|
||||||
|
sb.append(key.replace("vault", "")).append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(Lang.TITLE.toString() + Lang.EXISTING_VAULTS.toString().replaceAll("%p", fme.getTag()).replaceAll("%v", sb.toString().trim()));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
} // end listing vaults.
|
||||||
|
|
||||||
|
// Attempt to open vault.
|
||||||
|
if (VaultOperations.openOtherVault(player, vaultName, String.valueOf(number))) {
|
||||||
|
// Success
|
||||||
|
PlayerVaults.getInstance().getInVault().put(player.getUniqueId().toString(), new VaultViewInfo(vaultName, number));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TL getUsageTranslation() {
|
||||||
|
return TL.COMMAND_VERSION_DESCRIPTION;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
|
import com.massivecraft.factions.P;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -151,6 +152,11 @@ public class FCmdRoot extends FCommand {
|
|||||||
this.addSubCommand(this.cmdClaimLine);
|
this.addSubCommand(this.cmdClaimLine);
|
||||||
this.addSubCommand(this.cmdTop);
|
this.addSubCommand(this.cmdTop);
|
||||||
this.addSubCommand(this.cmdAHome);
|
this.addSubCommand(this.cmdAHome);
|
||||||
|
if (P.p.isHookedPlayervaults()) {
|
||||||
|
P.p.log("Found playervaults hook, adding /f vault and /f setmaxvault commands.");
|
||||||
|
this.addSubCommand(new CmdSetMaxVaults());
|
||||||
|
this.addSubCommand(new CmdVault());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -78,6 +78,8 @@ public enum Permission {
|
|||||||
SEECHUNK("seechunk"),
|
SEECHUNK("seechunk"),
|
||||||
SETWARP("setwarp"),
|
SETWARP("setwarp"),
|
||||||
TOP("top"),
|
TOP("top"),
|
||||||
|
VAULT("vault"),
|
||||||
|
SETMAXVAULTS("setmaxvaults"),
|
||||||
WARP("warp");
|
WARP("warp");
|
||||||
|
|
||||||
public final String node;
|
public final String node;
|
||||||
|
@ -42,6 +42,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
|||||||
protected HashMap<String, List<String>> announcements = new HashMap<String, List<String>>();
|
protected HashMap<String, List<String>> announcements = new HashMap<String, List<String>>();
|
||||||
protected ConcurrentHashMap<String, LazyLocation> warps = new ConcurrentHashMap<String, LazyLocation>();
|
protected ConcurrentHashMap<String, LazyLocation> warps = new ConcurrentHashMap<String, LazyLocation>();
|
||||||
private long lastDeath;
|
private long lastDeath;
|
||||||
|
protected int maxVaults;
|
||||||
|
|
||||||
public HashMap<String, List<String>> getAnnouncements() {
|
public HashMap<String, List<String>> getAnnouncements() {
|
||||||
return this.announcements;
|
return this.announcements;
|
||||||
@ -95,6 +96,14 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
|||||||
warps.clear();
|
warps.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMaxVaults() {
|
||||||
|
return this.maxVaults;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxVaults(int value) {
|
||||||
|
this.maxVaults = value;
|
||||||
|
}
|
||||||
|
|
||||||
public Set<String> getInvites() {
|
public Set<String> getInvites() {
|
||||||
return invites;
|
return invites;
|
||||||
}
|
}
|
||||||
|
@ -434,6 +434,11 @@ public enum TL {
|
|||||||
COMMAND_SETHOME_SETOTHER("<b>You have set the home for the %1$s<i> faction."),
|
COMMAND_SETHOME_SETOTHER("<b>You have set the home for the %1$s<i> faction."),
|
||||||
COMMAND_SETHOME_DESCRIPTION("Set the faction home"),
|
COMMAND_SETHOME_DESCRIPTION("Set the faction home"),
|
||||||
|
|
||||||
|
COMMAND_SETMAXVAULTS_DESCRIPTION("Set max vaults for a Faction."),
|
||||||
|
COMMAND_SETMAXVAULTS_SUCCESS("&aSet max vaults for &e%s &ato &b%d"),
|
||||||
|
|
||||||
|
COMMAND_VAULTS_TOOHIGH("You tried to open vault %d but your Faction only has %d vaults."),
|
||||||
|
|
||||||
COMMAND_SHOW_NOFACTION_SELF("You are not in a faction"),
|
COMMAND_SHOW_NOFACTION_SELF("You are not in a faction"),
|
||||||
COMMAND_SHOW_NOFACTION_OTHER("That's not a faction"),
|
COMMAND_SHOW_NOFACTION_OTHER("That's not a faction"),
|
||||||
COMMAND_SHOW_TOSHOW("to show faction information"),
|
COMMAND_SHOW_TOSHOW("to show faction information"),
|
||||||
|
@ -2,7 +2,7 @@ name: Factions
|
|||||||
version: ${project.version}
|
version: ${project.version}
|
||||||
main: com.massivecraft.factions.P
|
main: com.massivecraft.factions.P
|
||||||
authors: [Olof Larsson, Brett Flannigan, drtshock]
|
authors: [Olof Larsson, Brett Flannigan, drtshock]
|
||||||
softdepend: [PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, iChat, LocalAreaChat, LWC, nChat, ChatManager, CAPI, AuthMe, Vault, Spout, WorldEdit, WorldGuard, AuthDB, CaptureThePoints, CombatTag, dynmap]
|
softdepend: [PlayerVaults, PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, iChat, LocalAreaChat, LWC, nChat, ChatManager, CAPI, AuthMe, Vault, Spout, WorldEdit, WorldGuard, AuthDB, CaptureThePoints, CombatTag, dynmap]
|
||||||
commands:
|
commands:
|
||||||
factions:
|
factions:
|
||||||
description: Reference command for Factions.
|
description: Reference command for Factions.
|
||||||
@ -18,6 +18,7 @@ permissions:
|
|||||||
factions.save: true
|
factions.save: true
|
||||||
factions.modifypower: true
|
factions.modifypower: true
|
||||||
factions.ahome: true
|
factions.ahome: true
|
||||||
|
factions.setmaxvaults: true
|
||||||
factions.*:
|
factions.*:
|
||||||
description: This is just an alias for factions.kit.admin
|
description: This is just an alias for factions.kit.admin
|
||||||
children:
|
children:
|
||||||
@ -96,6 +97,7 @@ permissions:
|
|||||||
factions.monitorlogins: true
|
factions.monitorlogins: true
|
||||||
factions.top: true
|
factions.top: true
|
||||||
factions.togglealliancechat: true
|
factions.togglealliancechat: true
|
||||||
|
factions.vault: true
|
||||||
factions.admin:
|
factions.admin:
|
||||||
description: hand over your admin rights
|
description: hand over your admin rights
|
||||||
factions.admin.any:
|
factions.admin.any:
|
||||||
@ -265,3 +267,7 @@ permissions:
|
|||||||
description: Ability to send players to their faction home.
|
description: Ability to send players to their faction home.
|
||||||
factions.autoleavebypass:
|
factions.autoleavebypass:
|
||||||
description: Bypass autoleave.
|
description: Bypass autoleave.
|
||||||
|
factions.vault:
|
||||||
|
description: Access faction vault.
|
||||||
|
factions.setmaxvault:
|
||||||
|
description: Set a faction's max vaults.
|
Loading…
Reference in New Issue
Block a user