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

View File

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