Skip to content

Commit

Permalink
misc: skill item -> disguise tool
Browse files Browse the repository at this point in the history
  • Loading branch information
MATRIX-feather committed Oct 8, 2024
1 parent 957ab00 commit 7469a9e
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 32 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ bukkit {
permissionRoot + "lookup",
permissionRoot + "skin_cache",
permissionRoot + "switch_backend",
permissionRoot + "make_skill_item",
permissionRoot + "make_disguise_tool",

permissionRoot + "mirror.immune",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ public class MakeSkillItemSubCommand extends MorphPluginObject implements ISubCo
@Override
public @NotNull String getCommandName()
{
return "make_skill_item";
return "make_disguise_tool";
}

@Override
public @Nullable String getPermissionRequirement()
{
return CommonPermissions.MAKE_SKILL_ITEM;
return CommonPermissions.MAKE_DISGUISE_TOOL;
}

@Override
public FormattableMessage getHelpMessage()
{
return new FormattableMessage(plugin, "make selected a skill item");
return new FormattableMessage(plugin, "make selected a disguise tool");
}

private final List<String> emptyList = List.of();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class CommonPermissions

public final static String ACCESS_SKIN_CACHE = PERM_ROOT + "skin_cache";

public final static String MAKE_SKILL_ITEM = PERM_ROOT + "make_skill_item";
public final static String MAKE_DISGUISE_TOOL = PERM_ROOT + "make_disguise_tool";

public final static String SET_BACKEND = PERM_ROOT + "switch_backend";

Expand Down
31 changes: 15 additions & 16 deletions src/main/java/xiamomc/morph/misc/recipe/RecipeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import xiamomc.pluginbase.Annotations.Initializer;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -69,14 +68,14 @@ public void reload()

private void readValuesFromConfig(YamlConfiguration config)
{
allowCrafting = config.getBoolean(RecipeOptions.ALLOW_SKILL_ITEM_CRAFTING.toString(), false);
unShaped = config.getBoolean(RecipeOptions.SKILL_ITEM_CRAFTING_UNSHAPED.toString(), false);
shape = config.getStringList(RecipeOptions.SKILL_ITEM_CRAFTING_SHAPE.toString());
resultMaterialId = config.getString(RecipeOptions.SKILL_ITEM_RESULT_MATERIAL.toString(), "~UNSET");
resultName = config.getString(RecipeOptions.SKILL_ITEM_RESULT_NAME.toString(), "~UNSET");
resultLore = config.getStringList(RecipeOptions.SKILL_ITEM_RESULT_LORE.toString());
allowCrafting = config.getBoolean(RecipeOptions.ALLOW_DISGUISE_TOOL_CRAFTING.toString(), false);
unShaped = config.getBoolean(RecipeOptions.DISGUISE_TOOL_CRAFTING_UNSHAPED.toString(), false);
shape = config.getStringList(RecipeOptions.DISGUISE_TOOL_CRAFTING_SHAPE.toString());
resultMaterialId = config.getString(RecipeOptions.DISGUISE_TOOL_RESULT_MATERIAL.toString(), "~UNSET");
resultName = config.getString(RecipeOptions.DISGUISE_TOOL_RESULT_NAME.toString(), "~UNSET");
resultLore = config.getStringList(RecipeOptions.DISGUISE_TOOL_RESULT_LORE.toString());

var materialSection = config.getConfigurationSection(RecipeOptions.SKILL_ITEM_CRAFTING_MATERIALS.toString());
var materialSection = config.getConfigurationSection(RecipeOptions.DISGUISE_TOOL_CRAFTING_MATERIALS.toString());

if (materialSection != null)
{
Expand Down Expand Up @@ -132,7 +131,7 @@ private Material getMaterialFrom(String str)
}

@NotNull
public static final NamespacedKey SKILLITEM_CRAFTING_KEY = NamespacedKey.fromString("feathermorph:skill_item_crafting");
public static final NamespacedKey SKILLITEM_CRAFTING_KEY = NamespacedKey.fromString("feathermorph:disguise_tool_crafting");

private void prepareRecipe()
{
Expand Down Expand Up @@ -249,16 +248,16 @@ private void test_saveConfig()
return;
}

yamlConfiguration.set(RecipeOptions.ALLOW_SKILL_ITEM_CRAFTING.toString(), allowCrafting);
yamlConfiguration.set(RecipeOptions.SKILL_ITEM_CRAFTING_UNSHAPED.toString(), this.unShaped);
yamlConfiguration.set(RecipeOptions.SKILL_ITEM_CRAFTING_SHAPE.toString(), this.shape);
yamlConfiguration.set(RecipeOptions.SKILL_ITEM_RESULT_MATERIAL.toString(), this.resultMaterialId);
yamlConfiguration.set(RecipeOptions.SKILL_ITEM_RESULT_NAME.toString(), this.resultName);
yamlConfiguration.set(RecipeOptions.SKILL_ITEM_RESULT_LORE.toString(), this.resultLore);
yamlConfiguration.set(RecipeOptions.ALLOW_DISGUISE_TOOL_CRAFTING.toString(), allowCrafting);
yamlConfiguration.set(RecipeOptions.DISGUISE_TOOL_CRAFTING_UNSHAPED.toString(), this.unShaped);
yamlConfiguration.set(RecipeOptions.DISGUISE_TOOL_CRAFTING_SHAPE.toString(), this.shape);
yamlConfiguration.set(RecipeOptions.DISGUISE_TOOL_RESULT_MATERIAL.toString(), this.resultMaterialId);
yamlConfiguration.set(RecipeOptions.DISGUISE_TOOL_RESULT_NAME.toString(), this.resultName);
yamlConfiguration.set(RecipeOptions.DISGUISE_TOOL_RESULT_LORE.toString(), this.resultLore);

this.materials.forEach((str, id) ->
{
var node = RecipeOptions.SKILL_ITEM_CRAFTING_MATERIALS.toString() + "." + str;
var node = RecipeOptions.DISGUISE_TOOL_CRAFTING_MATERIALS.toString() + "." + str;
yamlConfiguration.set(node, id);
});

Expand Down
17 changes: 9 additions & 8 deletions src/main/java/xiamomc/morph/misc/recipe/RecipeOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@

public class RecipeOptions
{
public static final ConfigOption<Boolean> ALLOW_SKILL_ITEM_CRAFTING = new ConfigOption<>(skillItemNode().append("enabled"), true);
public static final ConfigOption<Boolean> SKILL_ITEM_CRAFTING_UNSHAPED = new ConfigOption<>(skillItemNode().append("shapeless"), true);
public static final ConfigOption<List<String>> SKILL_ITEM_CRAFTING_SHAPE = new ConfigOption<>(skillItemNode().append("crafting_shape"), new ArrayList<>());
public static final ConfigOption<Map<String, String>> SKILL_ITEM_CRAFTING_MATERIALS = new ConfigOption<>(skillItemNode().append("crafting_materials"), new HashMap<>());
public static final ConfigOption<String> SKILL_ITEM_RESULT_MATERIAL = new ConfigOption<>(skillItemNode().append("result_material"), "minecraft:feather");
public static final ConfigOption<String> SKILL_ITEM_RESULT_NAME = new ConfigOption<>(skillItemNode().append("result_item_name"), "~UNSET");
public static final ConfigOption<List<String>> SKILL_ITEM_RESULT_LORE = new ConfigOption<>(skillItemNode().append("result_item_lore"), new ArrayList<>());
public static final ConfigOption<Boolean> ALLOW_DISGUISE_TOOL_CRAFTING = new ConfigOption<>(skillItemNode().append("enabled"), true);
public static final ConfigOption<Boolean> DISGUISE_TOOL_CRAFTING_UNSHAPED = new ConfigOption<>(skillItemNode().append("shapeless"), true);
public static final ConfigOption<List<String>> DISGUISE_TOOL_CRAFTING_SHAPE = new ConfigOption<>(skillItemNode().append("crafting_shape"), new ArrayList<>());
public static final ConfigOption<Map<String, String>> DISGUISE_TOOL_CRAFTING_MATERIALS = new ConfigOption<>(skillItemNode().append("crafting_materials"), new HashMap<>());
public static final ConfigOption<String> DISGUISE_TOOL_RESULT_MATERIAL = new ConfigOption<>(skillItemNode().append("result_material"), "minecraft:feather");
public static final ConfigOption<String> DISGUISE_TOOL_RESULT_NAME = new ConfigOption<>(skillItemNode().append("result_item_name"), "~UNSET");
public static final ConfigOption<List<String>> DISGUISE_TOOL_RESULT_LORE = new ConfigOption<>(skillItemNode().append("result_item_lore"), new ArrayList<>());
public static final ConfigOption<Integer> CONFIG_VERSION = new ConfigOption<>(ConfigNode.create().append("version"), 0);

private static ConfigNode craftingNode()
{
return ConfigNode.create().append("item_crafting");
}
private static ConfigNode skillItemNode()
{
return craftingNode().append("skill_item");
return craftingNode().append("disguise_tool");
}
}
2 changes: 1 addition & 1 deletion src/main/java/xiamomc/morph/utilities/ItemUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static String itemToStr(ItemStack stack)
}
}

public static final String SKILL_ACTIVATE_ITEM_KEY = "feathermorph:is_skill_item";
public static final String SKILL_ACTIVATE_ITEM_KEY = "feathermorph:is_disguise_tool";

public static ItemStack buildSkillItemFrom(ItemStack stack)
{
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/recipes.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
root:
# Item crafting options
item_crafting:
# Options for the Skill Item
skill_item:
# Options for the Disguise Tool
disguise_tool:
enabled: true

# Should this recipe shapeless?
Expand Down Expand Up @@ -36,3 +36,4 @@ root:
crafting_materials:
A: minecraft:feather
B: minecraft:redstone
version: 1

0 comments on commit 7469a9e

Please sign in to comment.