Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
Fixed dangerous return value from EnumSetting.getType, thanks @GurteX
Browse files Browse the repository at this point in the history
  • Loading branch information
3arthqu4ke committed Mar 13, 2024
1 parent 6f14982 commit 2c5aef0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
org.gradle.jvmargs = -Xmx2G

version = 0.3.0
version = 0.3.1
minecraft_version = 1.20.4
mapping_version = 1
neoforge_version = 1-beta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

import me.earth.pingbypass.api.command.impl.arguments.EnumArgument;
import me.earth.pingbypass.api.config.impl.Parsers;
import me.earth.pingbypass.api.setting.Setting;
import me.earth.pingbypass.api.setting.impl.BuilderWithFactory;
import me.earth.pingbypass.api.setting.impl.SettingImpl;

public class EnumBuilder<T extends Enum<T>> extends BuilderWithFactory<T, Setting<T>, EnumBuilder<T>> {
public class EnumBuilder<T extends Enum<T>> extends BuilderWithFactory<T, EnumSetting<T>, EnumBuilder<T>> {
public EnumBuilder(Class<T> type) {
this(type.getEnumConstants()[0]);
}

public EnumBuilder(T initial) {
super(SettingImpl::new);
super(EnumSetting::new);
this.withArgumentType(new EnumArgument<>(initial.getDeclaringClass()))
.withParser(Parsers.enumParser(initial.getDeclaringClass()))
.withValue(initial);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ public EnumSetting(Function<T, Component> componentFactory, CanBeVisible visibil
public Class<T> getType() {
return getDefaultValue().getDeclaringClass();
}

}

1 comment on commit 2c5aef0

@GurteX
Copy link

@GurteX GurteX commented on 2c5aef0 Mar 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true

Please sign in to comment.