Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/main/java/ch/njol/skript/classes/data/SkriptClasses.java
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ public String toVariableNameString(Color color) {
}
}));

Classes.registerClass(new ClassInfo<>(StructureType.class, "structuretype")
Classes.registerClass(new ClassInfo<>(StructureType.class, "treetype")
.user("tree ?types?", "trees?")
.name("Tree Type")
.description("A tree type represents a tree species or a huge mushroom species. These can be generated in a world with the <a href='#EffTree'>generate tree</a> effect.")
Expand All @@ -386,18 +386,18 @@ public String toVariableNameString(Color color) {
.parser(new Parser<StructureType>() {
@Override
@Nullable
public StructureType parse(final String s, final ParseContext context) {
return StructureType.fromName(s);
public StructureType parse(String name, ParseContext context) {
return StructureType.fromName(name);
}

@Override
public String toString(final StructureType o, final int flags) {
return o.toString(flags);
public String toString(StructureType type, int flags) {
return type.toString(flags);
}

@Override
public String toVariableNameString(final StructureType o) {
return "" + o.name().toLowerCase(Locale.ENGLISH);
public String toVariableNameString(StructureType type) {
return "" + type.name().toLowerCase(Locale.ENGLISH);
Comment thread
adraarda23 marked this conversation as resolved.
Outdated
}
}).serializer(new EnumSerializer<>(StructureType.class)));

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ch/njol/skript/effects/EffTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public class EffTree extends Effect {

static {
Skript.registerEffect(EffTree.class,
"(grow|create|generate) tree [of type %structuretype%] %directions% %locations%",
"(grow|create|generate) %structuretype% %directions% %locations%");
"(grow|create|generate) tree [of type %treetype%] %directions% %locations%",
"(grow|create|generate) %treetype% %directions% %locations%");
}

@SuppressWarnings("null")
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/ch/njol/skript/events/EvtGrow.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public class EvtGrow extends SkriptEvent {

static {
Skript.registerEvent("Grow", EvtGrow.class, CollectionUtils.array(StructureGrowEvent.class, BlockGrowEvent.class),
"grow[th] [of (1:%-structuretypes%|2:%-itemtypes/blockdatas%)]",
"grow[th] [of (1:%-treetypes%|2:%-itemtypes/blockdatas%)]",
"grow[th] from %itemtypes/blockdatas%",
"grow[th] [in]to (1:%structuretypes%|2:%itemtypes/blockdatas%)",
"grow[th] from %itemtypes/blockdatas% [in]to (1:%structuretypes%|2:%itemtypes/blockdatas%)"
"grow[th] [in]to (1:%treetypes%|2:%itemtypes/blockdatas%)",
"grow[th] from %itemtypes/blockdatas% [in]to (1:%treetypes%|2:%itemtypes/blockdatas%)"
)
.description(
"Called when a tree, giant mushroom or plant grows to next stage.",
Expand Down
38 changes: 19 additions & 19 deletions src/main/java/ch/njol/skript/util/StructureType.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@ public enum StructureType {
private Noun name;
private final TreeType[] types;

private StructureType(final TreeType... types) {
private StructureType(TreeType... types) {
this.types = types;
name = new Noun("tree types." + name() + ".name");
}
public void grow(final Location loc) {

public void grow(Location location) {
TreeType tree = CollectionUtils.getRandom(types);
assert tree != null; // No enum member causes empty types
loc.getWorld().generateTree(loc, tree);
location.getWorld().generateTree(location, tree);
}
public void grow(final Block b) {

public void grow(Block block) {
TreeType tree = CollectionUtils.getRandom(types);
assert tree != null; // No enum member causes empty types
b.getWorld().generateTree(b.getLocation(), tree);
block.getWorld().generateTree(block.getLocation(), tree);
}

public TreeType[] getTypes() {
Expand All @@ -63,15 +63,15 @@ public String toString() {
return name.toString();
}

public String toString(final int flags) {
public String toString(int flags) {
return name.toString(flags);
}

public Noun getName() {
return name;
}
public boolean is(final TreeType type) {

public boolean is(TreeType type) {
return CollectionUtils.contains(types, type);
}

Expand All @@ -85,17 +85,17 @@ public boolean is(final TreeType type) {
}

@Nullable
public static StructureType fromName(String s) {
public static StructureType fromName(String input) {
if (parseMap.isEmpty()) {
for (final StructureType t : values()) {
final String pattern = Language.get("tree types." + t.name() + ".pattern");
parseMap.put(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE), t);
for (StructureType type : values()) {
String pattern = Language.get("tree types." + type.name() + ".pattern");
parseMap.put(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE), type);
}
}
s = "" + s.toLowerCase(Locale.ENGLISH);
for (final Entry<Pattern, StructureType> e : parseMap.entrySet()) {
if (e.getKey().matcher(s).matches())
return e.getValue();
input = "" + input.toLowerCase(Locale.ENGLISH);
Comment thread
adraarda23 marked this conversation as resolved.
Outdated
for (Entry<Pattern, StructureType> entry : parseMap.entrySet()) {
if (entry.getKey().matcher(input).matches())
return entry.getValue();
}
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/lang/default.lang
Original file line number Diff line number Diff line change
Expand Up @@ -2915,7 +2915,7 @@ types:
direction: direction¦s @a
slot: slot¦s @a
color: color¦s @a
structuretype: tree type¦s @a
treetype: tree type¦s @a
enchantmenttype: enchantment type¦s @an
experience: experience point¦s @an
experience.pattern: (e?xp|experience( points?)?)
Expand Down