Make BiomeAdaptor support Bukkit 1.13 and bump java-version to 1.8 (#3526)

This commit is contained in:
R4zorax 2018-08-02 03:23:29 +02:00 committed by t00thpick1
parent 63378ae4c1
commit 7800e48f61
2 changed files with 26 additions and 63 deletions

View File

@ -53,8 +53,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.8</source>
<target>1.8</target>
<excludes>
</excludes>
</configuration>
@ -79,7 +79,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.5</version>
<version>3.1.1</version>
<configuration>
<artifactSet>
<includes>
@ -135,7 +135,7 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.13-pre7-R0.1-SNAPSHOT</version>
<version>1.13-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -1,73 +1,36 @@
package com.gmail.nossr50.util.adapter;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import org.bukkit.block.Biome;
import com.gmail.nossr50.mcMMO;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class BiomeAdapter {
public static final Set<Biome> WATER_BIOMES;
public static final Set<Biome> ICE_BIOMES;
static {
List<Biome> temp = new ArrayList<Biome>();
EnumSet<Biome> set = null;
try {
temp.add(Biome.valueOf("RIVER"));
temp.add(Biome.valueOf("OCEAN"));
temp.add(Biome.valueOf("DEEP_OCEAN"));
} catch (Exception e) {
temp.clear();
} finally {
try {
set = EnumSet.copyOf(temp);
} catch (IllegalArgumentException e) {
mcMMO.p.getLogger().severe("Biome enum mismatch");;
List<Biome> allBiomes = Arrays.asList(Biome.values());
List<Biome> waterBiomes = new ArrayList<Biome>();
List<Biome> iceBiomes = new ArrayList<Biome>();
for (Biome biome : allBiomes) {
if (isWater(biome.name()) && !isCold(biome.name())) {
waterBiomes.add(biome);
} else if (isCold(biome.name())) {
iceBiomes.add(biome);
}
temp.clear();
}
WATER_BIOMES = set;
set = null;
try {
temp.add(Biome.valueOf("FROZEN_OCEAN"));
temp.add(Biome.valueOf("FROZEN_RIVER"));
temp.add(Biome.valueOf("TAIGA"));
temp.add(Biome.valueOf("TAIGA_HILLS"));
temp.add(Biome.valueOf("TAIGA_COLD_HILLS"));
temp.add(Biome.valueOf("TAIGA_COLD"));
temp.add(Biome.valueOf("MUTATED_TAIGA_COLD"));
temp.add(Biome.valueOf("ICE_MOUNTAINS"));
temp.add(Biome.valueOf("ICE_FLATS"));
temp.add(Biome.valueOf("MUTATED_ICE_FLATS"));
} catch (Exception e) {
temp.clear();
try {
temp.add(Biome.valueOf("FROZEN_OCEAN"));
temp.add(Biome.valueOf("FROZEN_RIVER"));
temp.add(Biome.valueOf("TAIGA"));
temp.add(Biome.valueOf("TAIGA_HILLS"));
temp.add(Biome.valueOf("TAIGA_MOUNTAINS"));
temp.add(Biome.valueOf("COLD_TAIGA"));
temp.add(Biome.valueOf("COLD_TAIGA_HILLS"));
temp.add(Biome.valueOf("COLD_TAIGA_MOUNTAINS"));
temp.add(Biome.valueOf("ICE_MOUNTAINS"));
temp.add(Biome.valueOf("ICE_PLAINS"));
temp.add(Biome.valueOf("ICE_PLAINS_SPIKES"));
} catch (Exception e1) {
temp.clear();
WATER_BIOMES = EnumSet.copyOf(waterBiomes);
ICE_BIOMES = EnumSet.copyOf(iceBiomes);
}
} finally {
try {
set = EnumSet.copyOf(temp);
} catch (IllegalArgumentException e) {
mcMMO.p.getLogger().severe("Biome enum mismatch");;
private static boolean isWater(String name) {
return name.contains("RIVER") || name.contains("OCEAN");
}
temp.clear();
}
ICE_BIOMES = set;
private static boolean isCold(String name) {
return (name.contains("COLD") || name.contains("ICE") || name.contains("FROZEN") || name.contains("TAIGA")) && !(name.contains("WARM"));
}
}