Skip to content

Commit caed32b

Browse files
committed
Update 1.0.2
1 parent d72c8a8 commit caed32b

File tree

6 files changed

+34
-6
lines changed

6 files changed

+34
-6
lines changed

client/src/main/java/com/fox2code/foxloader/client/mixins/MixinEntityPlayerSP.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,9 @@ public String getPlayerName() {
3838
public boolean isOperator() {
3939
return ((Entity) (Object) this).worldObj.worldInfo.isCheatsEnabled();
4040
}
41+
42+
@Override
43+
public void kick(String message) {
44+
throw new IllegalStateException("kick cannot be used client-side");
45+
}
4146
}

common/src/main/java/com/fox2code/foxloader/network/NetworkPlayer.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ public interface NetworkPlayer {
4242
*/
4343
default boolean isOperator() { throw new RuntimeException(); }
4444

45+
/**
46+
* Will kick the player.
47+
*
48+
* @throws IllegalStateException if used client side.
49+
*/
50+
default void kick(String message) { throw new RuntimeException(); }
51+
4552
enum ConnectionType {
4653
SINGLE_PLAYER(true, true), CLIENT_ONLY(true, false), SERVER_ONLY(false, true);
4754

common/src/main/java/com/fox2code/foxloader/registry/EnumReflectTranslator.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,24 @@ public final class EnumReflectTranslator<E extends Enum<E>, T> implements Iterab
2020
private final Class<E> enumType;
2121
private final Class<T> type;
2222
private final Class<?> target;
23+
private final T defaultElement;
2324

2425
public EnumReflectTranslator(Class<E> e, Class<T> type) {
25-
this(e, type, type);
26+
this(e, type, type, null);
2627
}
2728

2829
public EnumReflectTranslator(Class<E> e, Class<T> type, Class<?> target) {
30+
this(e, type, target, null);
31+
}
32+
33+
public EnumReflectTranslator(Class<E> e, Class<T> type, Class<?> target, E defaultElement) {
2934
this.provider = this::provideElement;
3035
this.cache = new EnumMap<>(e);
3136
this.enumType = e;
3237
this.type = type;
3338
this.target = target;
39+
this.defaultElement = defaultElement == null ?
40+
null : translate(defaultElement);
3441
if (PREFILL_CACHE) {
3542
fillCache();
3643
}
@@ -52,8 +59,12 @@ private T provideElement(E e) {
5259
lastError = ex;
5360
}
5461
}
55-
throw new RuntimeException("Failed to get element " +
56-
e.name() + " on " + this.target.getName(), lastError);
62+
if (this.defaultElement == null) {
63+
throw new RuntimeException("Failed to get element " +
64+
e.name() + " on " + this.target.getName(), lastError);
65+
} else {
66+
return this.defaultElement;
67+
}
5768
}
5869

5970
public T translate(E e) {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ org.gradle.parallel=true
33
org.gradle.jvmargs=-Xmx1024m -XX:-UseGCOverheadLimit -Dfile.encoding=UTF-8
44

55
# FoxLoader properties
6-
foxloader.version=1.0.1
6+
foxloader.version=1.0.2
77
foxloader.lastReIndevTransformerChanges=1.0.0
88

99
# ReIndev properties

server/src/main/java/com/fox2code/foxloader/registry/GameRegistryServer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public class GameRegistryServer extends GameRegistry {
2424
public static final int[] abilityToCatchFire = new int[MAXIMUM_BLOCK_ID];
2525
public static final EnumReflectTranslator<BuiltInMaterial, Material> MATERIAL =
2626
new EnumReflectTranslator<>(BuiltInMaterial.class, Material.class);
27-
public static final EnumReflectTranslator<BuiltInStepSounds, StepSound> STEP_SOUND =
28-
new EnumReflectTranslator<>(BuiltInStepSounds.class, StepSound.class, Block.class);
27+
public static final EnumReflectTranslator<BuiltInStepSounds, StepSound> STEP_SOUND = // Server doesn't contain all the sounds
28+
new EnumReflectTranslator<>(BuiltInStepSounds.class, StepSound.class, Block.class, BuiltInStepSounds.POWDER);
2929
// Common entries end
3030
private static byte[] serverHello;
3131

server/src/main/java/com/fox2code/foxloader/server/mixins/MixinEntityPlayerMP.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ public boolean isOperator() {
5454
return this.mcServer.configManager.isOp(this.username);
5555
}
5656

57+
@Override
58+
public void kick(String message) {
59+
this.playerNetServerHandler.kickPlayer(message);
60+
}
61+
5762
@Override
5863
public void notifyHasFoxLoader() {
5964
this.hasFoxLoader = true;

0 commit comments

Comments
 (0)