本文整理汇总了Java中org.inventivetalent.reflection.minecraft.Minecraft.VERSION属性的典型用法代码示例。如果您正苦于以下问题:Java Minecraft.VERSION属性的具体用法?Java Minecraft.VERSION怎么用?Java Minecraft.VERSION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.inventivetalent.reflection.minecraft.Minecraft
的用法示例。
在下文中一共展示了Minecraft.VERSION属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkExtraVersionConditions
static boolean checkExtraVersionConditions(ExtraMethod annotation) {
Minecraft.Version currentVersion = Minecraft.VERSION;
if (annotation.forVersion().length == 0 && annotation.fromVersion() == Minecraft.Version.UNKNOWN && annotation.untilVersion() == Minecraft.Version.UNKNOWN) {
// No version condition specified, just generate it
return true;
}
if (annotation.fromVersion() != Minecraft.Version.UNKNOWN && currentVersion.newerThan(annotation.fromVersion())) {
return true;
}
if (annotation.untilVersion() != Minecraft.Version.UNKNOWN && currentVersion.olderThan(annotation.untilVersion())) {
return true;
}
if (annotation.forVersion().length > 0) {
for (Minecraft.Version version : annotation.forVersion()) {
if (version == currentVersion) {
return true;
}
}
}
return false;
}
示例2: send
void send(Collection<? extends Player> receivers, double x, double y, double z, double offsetX, double offsetY, double offsetZ, double speed, int count, int... extra) {
if (!this.effect.isCompatible()) {
throw new ParticleException("Particle " + this.effect + " is not compatible with the server version (" + Minecraft.VERSION + " < " + this.effect.getMinVersion() + ")");
}
try {
if (Minecraft.VERSION.newerThan(v1_8_R1)) {
send_1_8(receivers, x, y, z, offsetX, offsetY, offsetZ, speed, count, extra);
} else {//1.7
send_1_7(effect.name, receivers, x, y, z, offsetX, offsetY, offsetZ, speed, count);
}
} catch (Exception e) {
throw new ParticleException("Failed to send particle " + this.effect + " to " + receivers.toString(), e);
}
}
示例3: parseAnnotationVersions
/**
* Parses an annotation to the current server version. Removes all entries
* that don't match the version, but keeps the original order for matching
* names.
*
* @param clazz Class of the annotation
* @param annotation annotation
* @param <A> annotation type
* @return a list of matching names
*/
<A extends Annotation> List<String> parseAnnotationVersions(java.lang.Class<A> clazz, A annotation) {
List<String> list = new ArrayList<>();
try {
String[] names = (String[]) clazz.getMethod("value").invoke(annotation);
Minecraft.Version[] versions = (Minecraft.Version[]) clazz.getMethod("versions").invoke(annotation);
if (versions.length == 0) {// No versions specified -> directly use the names
for (String name : names) {
list.add(name);
}
} else {
if (versions.length > names.length) {
throw new RuntimeException("versions array cannot have more elements than the names (" + clazz + ")");
}
for (int i = 0; i < versions.length; i++) {
if (Minecraft.VERSION == versions[i]) {// Wohoo, perfect match!
list.add(names[i]);
} else {
if (names[i].startsWith(">") && Minecraft.VERSION.newerThan(versions[i])) {// Match if the current version is newer
list.add(names[i].substring(1));
} else if (names[i].startsWith("<") && Minecraft.VERSION.olderThan(versions[i])) {// Match if the current version is older
list.add(names[i].substring(1));
}
}
}
}
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
return list;
}
示例4: parseAnnotationVersions
/**
* Parses an annotation to the current server version. Removes all entries that don't match the version, but keeps the original order for matching names.
*
* @param clazz Class of the annotation
* @param annotation annotation
* @param <A> annotation type
* @return a list of matching names
*/
<A extends Annotation> List<String> parseAnnotationVersions(java.lang.Class<A> clazz, A annotation) {
List<String> list = new ArrayList<>();
try {
String[] names = (String[]) clazz.getMethod("value").invoke(annotation);
Minecraft.Version[] versions = (Minecraft.Version[]) clazz.getMethod("versions").invoke(annotation);
if (versions.length == 0) {// No versions specified -> directly use the names
for (String name : names) {
list.add(name);
}
} else {
if (versions.length > names.length) {
throw new RuntimeException("versions array cannot have more elements than the names (" + clazz + ")");
}
for (int i = 0; i < versions.length; i++) {
if (Minecraft.VERSION == versions[i]) {// Wohoo, perfect match!
list.add(names[i]);
} else {
if (names[i].startsWith(">") && Minecraft.VERSION.newerThan(versions[i])) {// Match if the current version is newer
list.add(names[i].substring(1));
} else if (names[i].startsWith("<") && Minecraft.VERSION.olderThan(versions[i])) {// Match if the current version is older
list.add(names[i].substring(1));
}
}
}
}
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
return list;
}