From 398154b576c729587937b8f19b1663f598fe4761 Mon Sep 17 00:00:00 2001 From: TheComputerGeek2 Date: Tue, 21 Feb 2017 23:22:08 -0800 Subject: [PATCH] Add edit config command. --- plugin.yml | 3 +++ src/com/massivecraft/factions/Factions.java | 8 +++++++ src/com/massivecraft/factions/Perm.java | 1 + .../factions/cmd/CmdFactions.java | 2 ++ .../factions/cmd/CmdFactionsConfig.java | 22 +++++++++++++++++++ .../cmd/type/TypeFactionChunkChangeType.java | 19 ++++++++++++++++ .../massivecraft/factions/entity/MConf.java | 20 +++++++++++++++++ 7 files changed, 75 insertions(+) create mode 100644 src/com/massivecraft/factions/cmd/CmdFactionsConfig.java create mode 100644 src/com/massivecraft/factions/cmd/type/TypeFactionChunkChangeType.java diff --git a/plugin.yml b/plugin.yml index 6b2f6a9d..dd403c84 100644 --- a/plugin.yml +++ b/plugin.yml @@ -84,6 +84,7 @@ permissions: factions.unclaim.all: {description: unclaim all faction land, default: false} factions.unsethome: {description: unset faction home, default: false} factions.unstuck: {description: teleport to nearest wilderness, default: false} + factions.config: {description: edit the factions config, default: false} factions.version: {description: see plugin version, default: false} # -------------------------------------------- # # STAR NOTATION @@ -167,6 +168,7 @@ permissions: factions.unclaim.all: true factions.unsethome: true factions.unstuck: true + factions.config: true factions.version: true # -------------------------------------------- # # KITS @@ -179,6 +181,7 @@ permissions: default: false children: factions.kit.rank2: true + factions.config: true factions.kit.rank2: default: false children: diff --git a/src/com/massivecraft/factions/Factions.java b/src/com/massivecraft/factions/Factions.java index 8664a91d..bb16a5bb 100644 --- a/src/com/massivecraft/factions/Factions.java +++ b/src/com/massivecraft/factions/Factions.java @@ -1,5 +1,9 @@ package com.massivecraft.factions; +import com.massivecraft.factions.cmd.type.TypeFactionChunkChangeType; +import com.massivecraft.factions.cmd.type.TypeRel; +import com.massivecraft.factions.event.EventFactionsChunkChangeType; +import com.massivecraft.massivecore.command.type.RegistryType; import org.bukkit.ChatColor; import com.massivecraft.factions.adapter.BoardAdapter; @@ -122,6 +126,10 @@ public class Factions extends MassivePlugin "What factions exists and what players belong to them." ); + // Register types + RegistryType.register(Rel.class, TypeRel.get()); + RegistryType.register(EventFactionsChunkChangeType.class, TypeFactionChunkChangeType.get()); + // Register Faction accountId Extractor // TODO: Perhaps this should be placed in the econ integration somewhere? MUtil.registerExtractor(String.class, "accountId", ExtractorFactionAccountId.get()); diff --git a/src/com/massivecraft/factions/Perm.java b/src/com/massivecraft/factions/Perm.java index 19583f83..52c826e6 100644 --- a/src/com/massivecraft/factions/Perm.java +++ b/src/com/massivecraft/factions/Perm.java @@ -85,6 +85,7 @@ public enum Perm implements Identified UNCLAIM_ALL, UNSETHOME, UNSTUCK, + CONFIG, VERSION, // END OF LIST diff --git a/src/com/massivecraft/factions/cmd/CmdFactions.java b/src/com/massivecraft/factions/cmd/CmdFactions.java index dc32d88e..4661244a 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactions.java +++ b/src/com/massivecraft/factions/cmd/CmdFactions.java @@ -68,6 +68,7 @@ public class CmdFactions extends FactionsCommand public CmdFactionsDisband cmdFactionsDisband = new CmdFactionsDisband(); public CmdFactionsPowerBoost cmdFactionsPowerBoost = new CmdFactionsPowerBoost(); public CmdFactionsSetpower cmdFactionsSetpower = new CmdFactionsSetpower(); + public CmdFactionsConfig cmdFactionsConfig = new CmdFactionsConfig(); public MassiveCommandVersion cmdFactionsVersion = new MassiveCommandVersion(Factions.get()).setAliases("v", "version").addRequirements(RequirementHasPerm.get(Perm.VERSION)); // -------------------------------------------- // @@ -123,6 +124,7 @@ public class CmdFactions extends FactionsCommand this.addChild(this.cmdFactionsDisband); this.addChild(this.cmdFactionsPowerBoost); this.addChild(this.cmdFactionsSetpower); + this.addChild(this.cmdFactionsConfig); this.addChild(this.cmdFactionsVersion); // Deprecated Commands diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsConfig.java b/src/com/massivecraft/factions/cmd/CmdFactionsConfig.java new file mode 100644 index 00000000..09ab82bf --- /dev/null +++ b/src/com/massivecraft/factions/cmd/CmdFactionsConfig.java @@ -0,0 +1,22 @@ +package com.massivecraft.factions.cmd; + +import com.massivecraft.factions.Perm; +import com.massivecraft.factions.entity.MConf; +import com.massivecraft.massivecore.command.editor.CommandEditSingleton; +import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; + +public class CmdFactionsConfig extends CommandEditSingleton +{ + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + + public CmdFactionsConfig() + { + super(MConf.get()); + + // Requirements + this.addRequirements(RequirementHasPerm.get(Perm.CONFIG)); + } + +} diff --git a/src/com/massivecraft/factions/cmd/type/TypeFactionChunkChangeType.java b/src/com/massivecraft/factions/cmd/type/TypeFactionChunkChangeType.java new file mode 100644 index 00000000..ddcecda4 --- /dev/null +++ b/src/com/massivecraft/factions/cmd/type/TypeFactionChunkChangeType.java @@ -0,0 +1,19 @@ +package com.massivecraft.factions.cmd.type; + +import com.massivecraft.factions.event.EventFactionsChunkChangeType; +import com.massivecraft.massivecore.command.type.enumeration.TypeEnum; + +public class TypeFactionChunkChangeType extends TypeEnum +{ + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static TypeFactionChunkChangeType i = new TypeFactionChunkChangeType(); + public static TypeFactionChunkChangeType get() { return i; } + public TypeFactionChunkChangeType() + { + super(EventFactionsChunkChangeType.class); + } + +} diff --git a/src/com/massivecraft/factions/entity/MConf.java b/src/com/massivecraft/factions/entity/MConf.java index a3622dda..dca36d23 100644 --- a/src/com/massivecraft/factions/entity/MConf.java +++ b/src/com/massivecraft/factions/entity/MConf.java @@ -7,6 +7,11 @@ import java.util.List; import java.util.Map; import java.util.Set; +import com.massivecraft.massivecore.command.editor.annotation.EditorName; +import com.massivecraft.massivecore.command.editor.annotation.EditorType; +import com.massivecraft.massivecore.command.editor.annotation.EditorTypeInner; +import com.massivecraft.massivecore.command.editor.annotation.EditorVisible; +import com.massivecraft.massivecore.command.type.TypeMillisDiff; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.EntityType; @@ -22,6 +27,7 @@ import com.massivecraft.massivecore.store.Entity; import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.TimeUnit; +@EditorName("config") public class MConf extends Entity { // -------------------------------------------- // @@ -96,14 +102,17 @@ public class MConf extends Entity // After how many milliseconds should players be automatically kicked from their faction? // The Default + @EditorType(TypeMillisDiff.class) public long removePlayerMillisDefault = 10 * TimeUnit.MILLIS_PER_DAY; // 10 days // Player Age Bonus + @EditorTypeInner({TypeMillisDiff.class, TypeMillisDiff.class}) public Map removePlayerMillisPlayerAgeToBonus = MUtil.map( 2 * TimeUnit.MILLIS_PER_WEEK, 10 * TimeUnit.MILLIS_PER_DAY // +10 days after 2 weeks ); // Faction Age Bonus + @EditorTypeInner({TypeMillisDiff.class, TypeMillisDiff.class}) public Map removePlayerMillisFactionAgeToBonus = MUtil.map( 4 * TimeUnit.MILLIS_PER_WEEK, 10 * TimeUnit.MILLIS_PER_DAY, // +10 days after 4 weeks 2 * TimeUnit.MILLIS_PER_WEEK, 5 * TimeUnit.MILLIS_PER_DAY // +5 days after 2 weeks @@ -492,6 +501,7 @@ public class MConf extends Entity public int seeChunkKeepEvery = 5; public int seeChunkSkipEvery = 0; + @EditorType(TypeMillisDiff.class) public long seeChunkPeriodMillis = 500; public int seeChunkParticleAmount = 30; public float seeChunkParticleOffsetY = 2; @@ -529,6 +539,7 @@ public class MConf extends Entity // This way they can be protected in Faction territory. // Interacting with these materials when they are already placed in the terrain results in an edit. + @EditorVisible(false) public BackstringEnumSet materialsEditOnInteract = new BackstringEnumSet(Material.class, "DIODE_BLOCK_OFF", // Minecraft 1.? "DIODE_BLOCK_ON", // Minecraft 1.? @@ -543,6 +554,7 @@ public class MConf extends Entity // Interacting with the the terrain holding this item in hand results in an edit. // There's no need to add all block materials here. Only special items other than blocks. + @EditorVisible(false) public BackstringEnumSet materialsEditTools = new BackstringEnumSet(Material.class, "FIREBALL", // Minecraft 1.? "FLINT_AND_STEEL", // Minecraft 1.? @@ -555,6 +567,7 @@ public class MConf extends Entity // The duplication bug found in Spigot 1.8 protocol patch // https://github.com/MassiveCraft/Factions/issues/693 + @EditorVisible(false) public BackstringEnumSet materialsEditToolsDupeBug = new BackstringEnumSet(Material.class, "CHEST", // Minecraft 1.? "SIGN_POST", // Minecraft 1.? @@ -565,6 +578,7 @@ public class MConf extends Entity ); // Interacting with these materials placed in the terrain results in door toggling. + @EditorVisible(false) public BackstringEnumSet materialsDoor = new BackstringEnumSet(Material.class, "WOODEN_DOOR", // Minecraft 1.? "ACACIA_DOOR", // Minecraft 1.8 @@ -582,6 +596,7 @@ public class MConf extends Entity ); // Interacting with these materials placed in the terrain results in opening a container. + @EditorVisible(false) public BackstringEnumSet materialsContainer = new BackstringEnumSet(Material.class, "DISPENSER", // Minecraft 1.? "CHEST", // Minecraft 1.? @@ -616,12 +631,14 @@ public class MConf extends Entity ); // Interacting with these entities results in an edit. + @EditorVisible(false) public BackstringEnumSet entityTypesEditOnInteract = new BackstringEnumSet(EntityType.class, "ITEM_FRAME", // Minecraft 1.? "ARMOR_STAND" // Minecraft 1.8 ); // Damaging these entities results in an edit. + @EditorVisible(false) public BackstringEnumSet entityTypesEditOnDamage = new BackstringEnumSet(EntityType.class, "ITEM_FRAME", // Minecraft 1.? "ARMOR_STAND", // Minecraft 1.8 @@ -629,12 +646,14 @@ public class MConf extends Entity ); // Interacting with these entities results in opening a container. + @EditorVisible(false) public BackstringEnumSet entityTypesContainer = new BackstringEnumSet(EntityType.class, "MINECART_CHEST", // Minecraft 1.? "MINECART_HOPPER" // Minecraft 1.? ); // The complete list of entities considered to be monsters. + @EditorVisible(false) public BackstringEnumSet entityTypesMonsters = new BackstringEnumSet(EntityType.class, "BLAZE", // Minecraft 1.? "CAVE_SPIDER", // Minecraft 1.? @@ -667,6 +686,7 @@ public class MConf extends Entity ); // List of entities considered to be animals. + @EditorVisible(false) public BackstringEnumSet entityTypesAnimals = new BackstringEnumSet(EntityType.class, "BAT", // Minecraft 1.? "CHICKEN", // Minecraft 1.?