add permission description

This commit is contained in:
Flemmli97 2020-09-15 12:43:38 +02:00
parent 79734ba177
commit de78a4b0b6
5 changed files with 61 additions and 40 deletions

View File

@ -1,3 +1,11 @@
Flan 1.0.6
======================
- Update Fabric API to use the new PlayerBlockBreakEvent
Should fix issues with other mods bypassing claim protection
(If the mods dont directly break the blocks)
- Fix the lang configs being overwritten constantly
- Add description + translation for all permissions (used in the permission menu)
Flan 1.0.5
======================
- Moved the config files to the run/server root folder. (The place where all other mods configs are too)

View File

@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx2G
loader_version=0.9.1+build.205
# Mod Properties
mod_version = 1.0.5
mod_version = 1.0.6
maven_group = com.flemmli97.flan
archives_base_name = flan

View File

@ -10,51 +10,54 @@ import java.util.EnumSet;
public enum EnumPermission {
EDITCLAIM(ConfigHandler.config.claimingItem),
EDITPERMS(Items.COMMAND_BLOCK),
BREAK(Items.DIAMOND_PICKAXE),
PLACE(Items.GRASS_BLOCK),
OPENCONTAINER(Items.CHEST),
ANVIL(Items.ANVIL),
BED(Items.RED_BED),
BEACON(Items.BEACON),
DOOR(Items.OAK_DOOR),
FENCEGATE(Items.OAK_FENCE_GATE),
TRAPDOOR(Items.OAK_TRAPDOOR),
BUTTONLEVER(Items.LEVER),
PRESSUREPLATE(Items.STONE_PRESSURE_PLATE),
NOTEBLOCK(Items.NOTE_BLOCK),
REDSTONE(Items.REDSTONE),
JUKEBOX(Items.JUKEBOX),
ITEMFRAMEROTATE(Items.ITEM_FRAME),
LECTERNTAKE(Items.LECTERN),
ENDCRYSTALPLACE(Items.END_CRYSTAL),
TARGETBLOCK(Items.TARGET),
PROJECTILES(Items.ARROW),
TRAMPLE(Items.FARMLAND),
PORTAL(Items.OBSIDIAN),
RAID(null),
BOAT(Items.OAK_BOAT),
MINECART(Items.MINECART),
BUCKET(Items.BUCKET),
ENDERPEARL(Items.ENDER_PEARL),
ANIMALINTERACT(Items.CHICKEN_SPAWN_EGG),
HURTANIMAL(Items.BEEF),
XP(Items.EXPERIENCE_BOTTLE),
TRADING(Items.EMERALD),
ARMORSTAND(Items.ARMOR_STAND),
BREAKNONLIVING(Items.COMMAND_BLOCK_MINECART),
HURTPLAYER(Items.DIAMOND_SWORD),
EXPLOSIONS(Items.TNT),
WITHER(Items.WITHER_SKELETON_SKULL),
FIRESPREAD(Items.BLAZE_POWDER);
EDITCLAIM(ConfigHandler.config.claimingItem, "Gives permission to edit (resize, delete...) the claim"),
EDITPERMS(Items.COMMAND_BLOCK, "Gives permission to change the claims permissions"),
BREAK(Items.DIAMOND_PICKAXE, "Permission to break blocks in the claim"),
PLACE(Items.GRASS_BLOCK, "Permission to place blocks in the claim"),
OPENCONTAINER(Items.CHEST, "Permission to open containers (chest, furnace etc.)"),
ANVIL(Items.ANVIL, "Permission to use anvils"),
BED(Items.RED_BED, "Permission to use beds"),
BEACON(Items.BEACON, "Permission to use beacons"),
DOOR(Items.OAK_DOOR, "Permission to use doors"),
FENCEGATE(Items.OAK_FENCE_GATE, "Permission to use fence gates"),
TRAPDOOR(Items.OAK_TRAPDOOR, "Permission to use trapdoors"),
BUTTONLEVER(Items.LEVER, "Permission to trigger levers and buttons"),
PRESSUREPLATE(Items.STONE_PRESSURE_PLATE, "Permission to trigger pressure plates"),
NOTEBLOCK(Items.NOTE_BLOCK, "Permission to change noteblocks"),
REDSTONE(Items.REDSTONE, "Permission to change redstone components"),
JUKEBOX(Items.JUKEBOX, "Permission to insert/take music discs"),
ITEMFRAMEROTATE(Items.ITEM_FRAME, "Permission to rotate items in item frames"),
LECTERNTAKE(Items.LECTERN, "Permission to change books in a lectern"),
ENDCRYSTALPLACE(Items.END_CRYSTAL, "Permission to place end crystals"),
TARGETBLOCK(Items.TARGET, "Permission to trigger target blocks"),
PROJECTILES(Items.ARROW, "Permission to let shot projectiles interact with blocks (e.g. arrow on button)"),
TRAMPLE(Items.FARMLAND, "Permission to enable block trampling (farmland, turtle eggs)"),
PORTAL(Items.OBSIDIAN, "Permission to use nether portals"),
RAID(null, "Permission to trigger raids in claim. Wont prevent raids (just) outside"),
BOAT(Items.OAK_BOAT, "Permission to sit in boats"),
MINECART(Items.MINECART, "Permission to sit in minecarts"),
BUCKET(Items.BUCKET, "Permission to take liquids with buckets"),
ENDERPEARL(Items.ENDER_PEARL, "Permission to use enderpearls"),
ANIMALINTERACT(Items.CHICKEN_SPAWN_EGG, "Permission to interact with animals (e.g. shearing sheeps)"),
HURTANIMAL(Items.BEEF, "Permission to hurt animals"),
XP(Items.EXPERIENCE_BOTTLE, "Permission to pick up xp orbs"),
TRADING(Items.EMERALD, "Permission to trade with villagers"),
ARMORSTAND(Items.ARMOR_STAND, "Permission to interact with armor stands"),
BREAKNONLIVING(Items.COMMAND_BLOCK_MINECART, "Permission to break things like minecarts or armor stands"),
HURTPLAYER(Items.DIAMOND_SWORD, "Permission to hurt other players"),
EXPLOSIONS(Items.TNT, "Toggle explosions in claim"),
WITHER(Items.WITHER_SKELETON_SKULL,"Toggle wither breaking blocks in claim"),
FIRESPREAD(Items.BLAZE_POWDER, "Toggle firespread in claim");
private final Item item;
public String translation;
private static final EnumSet<EnumPermission> alwaysGlobal = EnumSet.of(HURTPLAYER, EXPLOSIONS, WITHER, FIRESPREAD);
EnumPermission(Item item) {
EnumPermission(Item item, String translation) {
this.item = item;
this.translation = translation;
}
public ItemStack getItem() {

View File

@ -1,5 +1,6 @@
package com.flemmli97.flan.config;
import com.flemmli97.flan.claim.EnumPermission;
import com.google.gson.JsonObject;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.server.MinecraftServer;
@ -10,6 +11,7 @@ import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.EnumMap;
public class LangConfig {
@ -102,6 +104,10 @@ public class LangConfig {
field.set(this, obj.get(field.getName()).getAsString());
}
}
for(EnumPermission perm : EnumPermission.values()){
if(obj.has(perm.toString()+".desc"))
perm.translation = obj.get(perm.toString()+".desc").getAsString();
}
} catch (IOException | IllegalAccessException e) {
e.printStackTrace();
}
@ -116,6 +122,8 @@ public class LangConfig {
obj.addProperty(field.getName(), (String) field.get(this));
}
}
for(EnumPermission perm : EnumPermission.values())
obj.addProperty(perm.toString()+".desc", perm.translation);
FileWriter writer = new FileWriter(this.config);
ConfigHandler.GSON.toJson(obj, writer);
writer.close();

View File

@ -28,6 +28,8 @@ public class ServerScreenHelper {
ItemStack stack = perm.getItem();
stack.setCustomName(new LiteralText(perm.toString()).setStyle(Style.EMPTY.withFormatting(Formatting.GOLD)));
ListTag lore = new ListTag();
Text trans = new LiteralText(perm.translation).setStyle(Style.EMPTY.withFormatting(Formatting.YELLOW));
lore.add(StringTag.of(Text.Serializer.toJson(trans)));
String permFlag;
if (group == null) {
if (claim.parentClaim() == null)