-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from mircokroon/entities
Entities
- Loading branch information
Showing
51 changed files
with
1,621 additions
and
431 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package config; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class Option { | ||
Version v; | ||
Supplier<Object> obj; | ||
|
||
public Option(Version v, Supplier<Object> obj) { | ||
this.v = v; | ||
this.obj = obj; | ||
} | ||
|
||
public static Option of(Version v, Supplier<Object> obj) { | ||
return new Option(v, obj); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package config; | ||
|
||
public enum Version { | ||
V1_12, | ||
V1_13, | ||
V1_14, | ||
V1_15, | ||
V1_16, | ||
ANY; | ||
|
||
boolean isVersion(VersionReporter versionReporter) { | ||
switch (this) { | ||
case V1_12: return versionReporter.isAtLeast1_12(); | ||
case V1_13: return versionReporter.isAtLeast1_13(); | ||
case V1_14: return versionReporter.isAtLeast1_14(); | ||
case V1_15: return versionReporter.isAtLeast1_15(); | ||
case V1_16: return versionReporter.isAtLeast1_16(); | ||
case ANY: return true; | ||
default: return false; | ||
} | ||
} | ||
|
||
public boolean isDataVersion(int dataVersion) { | ||
switch (this) { | ||
case V1_12: return VersionReporter.isAtLeast1_12(dataVersion); | ||
case V1_13: return VersionReporter.isAtLeast1_13(dataVersion); | ||
case V1_14: return VersionReporter.isAtLeast1_14(dataVersion); | ||
case V1_15: return VersionReporter.isAtLeast1_15(dataVersion); | ||
case V1_16: return VersionReporter.isAtLeast1_16(dataVersion); | ||
case ANY: return true; | ||
default: return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package config; | ||
|
||
import game.protocol.Protocol; | ||
import game.protocol.ProtocolVersionHandler; | ||
|
||
public class VersionReporter { | ||
private final static int DATA_VERSION_1_12 = 1022; | ||
private final static int DATA_VERSION_1_13 = 1444; | ||
private final static int DATA_VERSION_1_14 = 1901; | ||
private final static int DATA_VERSION_1_15 = 2200; | ||
private final static int DATA_VERSION_1_16 = 2504; | ||
|
||
private final static int VERSION_1_12 = 317; | ||
private final static int VERSION_1_13 = 341; | ||
private final static int VERSION_1_14 = 440; | ||
private final static int VERSION_1_15 = 550; | ||
private final static int VERSION_1_16 = 701; | ||
|
||
private final int protocolVersion; | ||
public VersionReporter(int version) { | ||
this.protocolVersion = version; | ||
} | ||
|
||
public Protocol getProtocol() { | ||
return ProtocolVersionHandler.getInstance().getProtocolByProtocolVersion(protocolVersion); | ||
} | ||
|
||
public static <T> T select(int dataVersion, Class<T> type, Option... opts) { | ||
for (Option opt : opts) { | ||
if (is(dataVersion, opt.v)) { | ||
return type.cast(opt.obj.get()); | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public <T> T select(Class<T> type, Option... opts) { | ||
for (Option opt : opts) { | ||
if (is(opt.v)) { | ||
return type.cast(opt.obj.get()); | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public static boolean is(int dataVersion, Version v) { | ||
return v.isDataVersion(dataVersion); | ||
} | ||
|
||
public boolean is(Version v) { | ||
return v.isVersion(this); | ||
} | ||
|
||
public boolean isAtLeast1_12() { | ||
return protocolVersion >= VERSION_1_12; | ||
} | ||
public boolean isAtLeast1_13() { | ||
return protocolVersion >= VERSION_1_13; | ||
} | ||
public boolean isAtLeast1_14() { | ||
return protocolVersion >= VERSION_1_14; | ||
} | ||
public boolean isAtLeast1_15() { | ||
return protocolVersion >= VERSION_1_15; | ||
} | ||
public boolean isAtLeast1_16() { | ||
return protocolVersion >= VERSION_1_16; | ||
} | ||
|
||
public static boolean isAtLeast1_12(int dataVersion) { | ||
return dataVersion >= DATA_VERSION_1_12; | ||
} | ||
public static boolean isAtLeast1_13(int dataVersion) { | ||
return dataVersion >= DATA_VERSION_1_13; | ||
} | ||
public static boolean isAtLeast1_14(int dataVersion) { | ||
return dataVersion >= DATA_VERSION_1_14; | ||
} | ||
public static boolean isAtLeast1_15(int dataVersion) { | ||
return dataVersion >= DATA_VERSION_1_15; | ||
} | ||
public static boolean isAtLeast1_16(int dataVersion) { | ||
return dataVersion >= DATA_VERSION_1_16; | ||
} | ||
|
||
public boolean is1_12() { | ||
return protocolVersion >= VERSION_1_12 && protocolVersion < VERSION_1_13; | ||
} | ||
public boolean is1_13() { | ||
return protocolVersion >= VERSION_1_13 && protocolVersion < VERSION_1_14; | ||
} | ||
public boolean is1_14() { | ||
return protocolVersion >= VERSION_1_14 && protocolVersion < VERSION_1_15; | ||
} | ||
public boolean is1_15() { | ||
return protocolVersion >= VERSION_1_15 && protocolVersion < VERSION_1_16; | ||
} | ||
public boolean is1_16() { | ||
return protocolVersion >= VERSION_1_16; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.