Skip to content
This repository has been archived by the owner on Apr 18, 2020. It is now read-only.

Cleanup #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@
build/
run/
.gradle/

bin/
*.launch
*.classpath
*.project
.settings
9 changes: 4 additions & 5 deletions src/main/java/com/martmists/libgamerule/Gamerule.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import java.util.function.Supplier;

public class Gamerule implements ModInitializer {
public static Supplier<MinecraftServer> SERVER_SUPPLIER;
static Supplier<MinecraftServer> SERVER_SUPPLIER;
public static boolean dirty = false;
public static CommandDispatcher<ServerCommandSource> DISPATCHER;
public static List<CommandNode<ServerCommandSource>> unregistered = new ArrayList<>();
private static CommandDispatcher<ServerCommandSource> DISPATCHER;
public static final List<CommandNode<ServerCommandSource>> unregistered = new ArrayList<>();

public static <T extends GameRules.Rule<T>> GameRules.RuleKey<T> register(String name, GameRules.RuleType<T> type) {
dirty = true;
Expand All @@ -51,8 +51,7 @@ public static <T extends GameRules.Rule<T> & ValueGetter<V>, V> V get(GameRules.
}

public static <T extends GameRules.Rule<T>> GameRules.RuleType<T> createRuleType(Supplier<ArgumentType<?>> argumentType, Function<GameRules.RuleType<T>, T> factory) {
return createRuleType(argumentType, factory, (s, r) -> {
});
return createRuleType(argumentType, factory, (s, r) -> {});
}

public static <T extends GameRules.Rule<T>> GameRules.RuleType<T> createRuleType(Supplier<ArgumentType<?>> argumentType, Function<GameRules.RuleType<T>, T> factory, BiConsumer<MinecraftServer, T> notifier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.stream.Collectors;

public class EnumArgumentType<E extends Enum<E>> implements ArgumentType<E> {
Class<E> clazz;
private Class<E> clazz;

public EnumArgumentType(Class<E> enumClass) {
this.clazz = enumClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

@Mixin(GameRuleCommand.class)
public interface GameRuleCommandAccessor {
/** @noinspection PublicStaticMixinMember */
@Invoker
@SuppressWarnings("PublicStaticMixinMember")
static <T extends GameRules.Rule<T>> int invokeExecuteSet(CommandContext<ServerCommandSource> commandContext, GameRules.RuleKey<T> ruleKey) {
throw new AssertionError("This shouldn't happen!");
}

/** @noinspection PublicStaticMixinMember */
@Invoker
@SuppressWarnings("PublicStaticMixinMember")
static <T extends GameRules.Rule<T>> int invokeExecuteQuery(ServerCommandSource serverCommandSource, GameRules.RuleKey<T> ruleKey) {
throw new AssertionError("This shouldn't happen!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

@Mixin(GameRules.class)
public interface GameRulesAccessor {
/** @noinspection PublicStaticMixinMember */
@Invoker
@SuppressWarnings("PublicStaticMixinMember")
static <T extends GameRules.Rule<T>> GameRules.RuleKey<T> invokeRegister(String name, GameRules.RuleType<T> type) {
throw new AssertionError("This shouldn't happen!");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.martmists.libgamerule.mixin;

import com.mojang.brigadier.arguments.ArgumentType;

import net.minecraft.server.MinecraftServer;
import net.minecraft.world.GameRules;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
Expand All @@ -11,9 +13,9 @@

@Mixin(GameRules.RuleType.class)
public interface RuleTypeAccessor {
/** @noinspection PublicStaticMixinMember */
@Invoker("<init>")
@SuppressWarnings("PublicStaticMixinMember")
static GameRules.RuleType invokeNew(Supplier<ArgumentType<?>> argumentType, Function factory, BiConsumer notifier) {
static <T extends GameRules.Rule<T>> GameRules.RuleType<T> invokeNew(Supplier<ArgumentType<?>> argumentType, Function<GameRules.RuleType<T>, T> factory, BiConsumer<MinecraftServer, T> notifier) {
throw new AssertionError("This shouldn't happen!");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

public class BooleanRule extends GameRules.Rule<BooleanRule> implements ValueGetter<Boolean> {
// Using this instead of GameRules.BooleanRule for ease of use
boolean value;
private boolean value;

public BooleanRule(GameRules.RuleType<BooleanRule> ruleType, boolean value) {
super(ruleType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.minecraft.world.GameRules;

public class DoubleRule extends GameRules.Rule<DoubleRule> implements ValueGetter<Double> {
double value;
private double value;

public DoubleRule(GameRules.RuleType<DoubleRule> ruleType, double value) {
super(ruleType);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/martmists/libgamerule/rules/EnumRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import net.minecraft.world.GameRules;

public class EnumRule<E extends Enum<E>> extends GameRules.Rule<EnumRule<E>> implements ValueGetter<E> {
Class<E> clazz;
E value;
private Class<E> clazz;

private E value;

public EnumRule(GameRules.RuleType<EnumRule<E>> ruleType, E value) {
super(ruleType);
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/martmists/libgamerule/rules/IntRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

public class IntRule extends GameRules.Rule<IntRule> implements ValueGetter<Integer> {
// Not using GameRules.IntRule for flexibility in create()

int value;
private int value;

public IntRule(GameRules.RuleType<IntRule> ruleType, int value) {
super(ruleType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.minecraft.world.GameRules;

public class StringRule extends GameRules.Rule<StringRule> implements ValueGetter<String> {
String value;
private String value;

public StringRule(GameRules.RuleType<StringRule> ruleType, String value) {
super(ruleType);
Expand Down