Skip to content

Commit

Permalink
Use Params API a bit more
Browse files Browse the repository at this point in the history
  • Loading branch information
imDaniX committed Aug 20, 2023
1 parent 0fec74e commit 24fd068
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ private BlockClickActivator(Logic base, Material block, String location, ClickTy
}

public static BlockClickActivator create(Logic base, Parameters param) {
Material block = ItemUtils.getMaterial(param.getString("block-type"));
ClickType click = ClickType.getByName(param.getString("click-type"));
Material block = param.get("block-type", ItemUtils::getMaterial);
ClickType click = param.getSafe("click-type", ClickType::getByName);
String loc = param.getString("location");
return new BlockClickActivator(base, block, loc, click);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private WeChangeActivator(Logic base, Material blockType, String region) {
}

public static WeChangeActivator create(Logic base, Parameters param) {
Material blockType = ItemUtils.getMaterial(param.getString("blocktype"));
Material blockType = param.get("blocktype", ItemUtils::getMaterial);
String region = param.getString("region", "");
return new WeChangeActivator(base, blockType, region);
}
Expand Down Expand Up @@ -66,11 +66,10 @@ public void saveOptions(@NotNull ConfigurationSection cfg) {

@Override
public String toString() {
String sb = super.toString() + " (" +
return super.toString() + " (" +
"block-type:" + (blockType != null ? blockType : "ANY") +
" region:" + (region.isEmpty() ? "-" : region.toUpperCase(Locale.ROOT)) +
")";
return sb;
}

/**
Expand Down

0 comments on commit 24fd068

Please sign in to comment.