mirror of
https://github.com/toolbox4minecraft/amidst.git
synced 2025-01-08 12:08:08 +08:00
applied the code clean up tool by Eclipse
This commit is contained in:
parent
9db9f9ad20
commit
bd0e586886
@ -50,7 +50,7 @@ public enum Classes {
|
||||
Log.i("Checking " + jarFile.getName());
|
||||
List<RealClass> realClasses = RealClasses.fromJarFile(jarFile);
|
||||
Map<SymbolicClassDeclaration, List<RealClass>> map = translator.translateToAllMatching(realClasses);
|
||||
Map<SymbolicClassDeclaration, Integer> result = new HashMap<SymbolicClassDeclaration, Integer>();
|
||||
Map<SymbolicClassDeclaration, Integer> result = new HashMap<>();
|
||||
for (Entry<SymbolicClassDeclaration, List<RealClass>> entry : map.entrySet()) {
|
||||
result.put(entry.getKey(), entry.getValue().size());
|
||||
if (entry.getValue().isEmpty()) {
|
||||
|
@ -13,7 +13,7 @@ import amidst.documentation.Immutable;
|
||||
@Immutable
|
||||
public class RealClass {
|
||||
private static Map<Character, String> createPrimitiveTypeConversionMap() {
|
||||
Map<Character, String> result = new HashMap<Character, String>();
|
||||
Map<Character, String> result = new HashMap<>();
|
||||
result.put('B', "byte");
|
||||
result.put('C', "char");
|
||||
result.put('D', "double");
|
||||
@ -219,7 +219,7 @@ public class RealClass {
|
||||
}
|
||||
|
||||
private String[] readArguments(String arguments) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
List<String> result = new ArrayList<>();
|
||||
String args = arguments.substring(1).split("\\)")[0];
|
||||
Matcher matcher = ARG_PATTERN.matcher(args);
|
||||
while (matcher.find()) {
|
||||
|
@ -26,11 +26,11 @@ public class RealClassBuilder {
|
||||
int cpSize = readCpSize(stream);
|
||||
int[] constantTypes = new int[cpSize];
|
||||
RealClassConstant<?>[] constants = new RealClassConstant<?>[cpSize];
|
||||
List<String> utf8Constants = new ArrayList<String>();
|
||||
List<Float> floatConstants = new ArrayList<Float>();
|
||||
List<Long> longConstants = new ArrayList<Long>();
|
||||
List<Integer> stringIndices = new ArrayList<Integer>();
|
||||
List<ReferenceIndex> methodIndices = new ArrayList<ReferenceIndex>();
|
||||
List<String> utf8Constants = new ArrayList<>();
|
||||
List<Float> floatConstants = new ArrayList<>();
|
||||
List<Long> longConstants = new ArrayList<>();
|
||||
List<Integer> stringIndices = new ArrayList<>();
|
||||
List<ReferenceIndex> methodIndices = new ArrayList<>();
|
||||
readConstants(
|
||||
stream,
|
||||
cpSize,
|
||||
@ -148,7 +148,7 @@ public class RealClassBuilder {
|
||||
throws IOException {
|
||||
String value = readStringValue(stream);
|
||||
utf8Constants.add(value);
|
||||
return new RealClassConstant<String>(type, value);
|
||||
return new RealClassConstant<>(type, value);
|
||||
}
|
||||
|
||||
private String readStringValue(DataInputStream stream) throws IOException {
|
||||
@ -161,31 +161,31 @@ public class RealClassBuilder {
|
||||
|
||||
private RealClassConstant<Integer> readInteger(DataInputStream stream, byte type) throws IOException {
|
||||
int value = stream.readInt();
|
||||
return new RealClassConstant<Integer>(type, value);
|
||||
return new RealClassConstant<>(type, value);
|
||||
}
|
||||
|
||||
private RealClassConstant<Float> readFloat(DataInputStream stream, byte type, List<Float> floatConstants)
|
||||
throws IOException {
|
||||
float value = stream.readFloat();
|
||||
floatConstants.add(value);
|
||||
return new RealClassConstant<Float>(type, value);
|
||||
return new RealClassConstant<>(type, value);
|
||||
}
|
||||
|
||||
private RealClassConstant<Long> readLong(DataInputStream stream, byte type, List<Long> longConstants)
|
||||
throws IOException {
|
||||
long value = stream.readLong();
|
||||
longConstants.add(value);
|
||||
return new RealClassConstant<Long>(type, value);
|
||||
return new RealClassConstant<>(type, value);
|
||||
}
|
||||
|
||||
private RealClassConstant<Double> readDouble(DataInputStream stream, byte type) throws IOException {
|
||||
double value = stream.readDouble();
|
||||
return new RealClassConstant<Double>(type, value);
|
||||
return new RealClassConstant<>(type, value);
|
||||
}
|
||||
|
||||
private RealClassConstant<Integer> readClassReference(DataInputStream stream, byte type) throws IOException {
|
||||
int value = stream.readUnsignedShort();
|
||||
return new RealClassConstant<Integer>(type, value);
|
||||
return new RealClassConstant<>(type, value);
|
||||
}
|
||||
|
||||
private RealClassConstant<Integer> readStringReference(
|
||||
@ -194,13 +194,13 @@ public class RealClassBuilder {
|
||||
List<Integer> stringIndices) throws IOException {
|
||||
int value = stream.readUnsignedShort();
|
||||
stringIndices.add(value);
|
||||
return new RealClassConstant<Integer>(type, value);
|
||||
return new RealClassConstant<>(type, value);
|
||||
}
|
||||
|
||||
private RealClassConstant<ReferenceIndex> readAnotherReference(DataInputStream stream, byte type)
|
||||
throws IOException {
|
||||
ReferenceIndex value = readReferenceIndex(stream);
|
||||
return new RealClassConstant<ReferenceIndex>(type, value);
|
||||
return new RealClassConstant<>(type, value);
|
||||
}
|
||||
|
||||
private int readAccessFlags(DataInputStream stream) throws IOException {
|
||||
|
@ -18,7 +18,7 @@ public interface RealClassDetector {
|
||||
}
|
||||
|
||||
public default List<RealClass> allMatching(List<RealClass> realClasses) {
|
||||
List<RealClass> result = new ArrayList<RealClass>();
|
||||
List<RealClass> result = new ArrayList<>();
|
||||
for (RealClass realClass : realClasses) {
|
||||
if (detect(realClass)) {
|
||||
result.add(realClass);
|
||||
|
@ -40,7 +40,7 @@ public enum RealClasses {
|
||||
|
||||
private static List<RealClass> readJarFile(ZipFile zipFile) throws IOException, RealClassCreationException {
|
||||
Enumeration<? extends ZipEntry> enu = zipFile.entries();
|
||||
List<RealClass> result = new ArrayList<RealClass>();
|
||||
List<RealClass> result = new ArrayList<>();
|
||||
while (enu.hasMoreElements()) {
|
||||
RealClass entry = readJarFileEntry(zipFile, enu.nextElement());
|
||||
if (entry != null) {
|
||||
|
@ -19,7 +19,7 @@ import amidst.documentation.NotThreadSafe;
|
||||
@NotThreadSafe
|
||||
public class SymbolicClassBuilder {
|
||||
private static Map<String, Class<?>> createPrimitivesMap() {
|
||||
Map<String, Class<?>> result = new HashMap<String, Class<?>>();
|
||||
Map<String, Class<?>> result = new HashMap<>();
|
||||
result.put("byte", byte.class);
|
||||
result.put("int", int.class);
|
||||
result.put("float", float.class);
|
||||
@ -34,9 +34,9 @@ public class SymbolicClassBuilder {
|
||||
|
||||
private static final Map<String, Class<?>> PRIMITIVES_MAP = createPrimitivesMap();
|
||||
|
||||
private final Map<String, SymbolicConstructor> constructorsBySymbolicName = new HashMap<String, SymbolicConstructor>();
|
||||
private final Map<String, SymbolicMethod> methodsBySymbolicName = new HashMap<String, SymbolicMethod>();
|
||||
private final Map<String, SymbolicField> fieldsBySymbolicName = new HashMap<String, SymbolicField>();
|
||||
private final Map<String, SymbolicConstructor> constructorsBySymbolicName = new HashMap<>();
|
||||
private final Map<String, SymbolicMethod> methodsBySymbolicName = new HashMap<>();
|
||||
private final Map<String, SymbolicField> fieldsBySymbolicName = new HashMap<>();
|
||||
|
||||
private final ClassLoader classLoader;
|
||||
private final Map<String, String> realClassNamesBySymbolicClassName;
|
||||
|
@ -24,9 +24,9 @@ public class SymbolicClassGraphBuilder {
|
||||
}
|
||||
|
||||
public Map<String, SymbolicClass> construct() throws SymbolicClassGraphCreationException {
|
||||
Map<String, String> realClassNamesBySymbolicClassName = new HashMap<String, String>();
|
||||
Map<String, SymbolicClass> symbolicClassesByRealClassName = new HashMap<String, SymbolicClass>();
|
||||
Map<SymbolicClassDeclaration, SymbolicClassBuilder> symbolicClassBuildersBySymbolicClassDeclaration = new HashMap<SymbolicClassDeclaration, SymbolicClassBuilder>();
|
||||
Map<String, String> realClassNamesBySymbolicClassName = new HashMap<>();
|
||||
Map<String, SymbolicClass> symbolicClassesByRealClassName = new HashMap<>();
|
||||
Map<SymbolicClassDeclaration, SymbolicClassBuilder> symbolicClassBuildersBySymbolicClassDeclaration = new HashMap<>();
|
||||
createSymbolicClasses(
|
||||
realClassNamesBySymbolicClassName,
|
||||
symbolicClassesByRealClassName,
|
||||
@ -97,7 +97,7 @@ public class SymbolicClassGraphBuilder {
|
||||
|
||||
private Map<String, SymbolicClass> createProduct(
|
||||
Map<SymbolicClassDeclaration, SymbolicClassBuilder> symbolicClassBuildersBySymbolicClassDeclaration) {
|
||||
Map<String, SymbolicClass> result = new HashMap<String, SymbolicClass>();
|
||||
Map<String, SymbolicClass> result = new HashMap<>();
|
||||
for (Entry<SymbolicClassDeclaration, SymbolicClassBuilder> entry : symbolicClassBuildersBySymbolicClassDeclaration
|
||||
.entrySet()) {
|
||||
result.put(entry.getKey().getSymbolicClassName(), entry.getValue().getProduct());
|
||||
|
@ -15,7 +15,7 @@ public class SymbolicParameterDeclarationList {
|
||||
@Immutable
|
||||
public static class SymbolicParameterDeclarationListBuilder<T> {
|
||||
private final T nextBuilder;
|
||||
private final List<SymbolicParameterDeclaration> declarations = new ArrayList<SymbolicParameterDeclaration>();
|
||||
private final List<SymbolicParameterDeclaration> declarations = new ArrayList<>();
|
||||
private final ExecuteOnEnd executeOnEnd;
|
||||
|
||||
public SymbolicParameterDeclarationListBuilder(T nextBuilder, ExecuteOnEnd executeOnEnd) {
|
||||
|
@ -24,9 +24,9 @@ public class CTBuilder {
|
||||
public class SCDBuilder {
|
||||
private String symbolicClassName;
|
||||
private boolean isOptional;
|
||||
private final List<SymbolicConstructorDeclaration> constructors = new ArrayList<SymbolicConstructorDeclaration>();
|
||||
private final List<SymbolicMethodDeclaration> methods = new ArrayList<SymbolicMethodDeclaration>();
|
||||
private final List<SymbolicFieldDeclaration> fields = new ArrayList<SymbolicFieldDeclaration>();
|
||||
private final List<SymbolicConstructorDeclaration> constructors = new ArrayList<>();
|
||||
private final List<SymbolicMethodDeclaration> methods = new ArrayList<>();
|
||||
private final List<SymbolicFieldDeclaration> fields = new ArrayList<>();
|
||||
|
||||
private void init(String symbolicClassName, boolean isOptional) {
|
||||
this.symbolicClassName = symbolicClassName;
|
||||
@ -56,7 +56,7 @@ public class CTBuilder {
|
||||
private SymbolicParameterDeclarationListBuilder<SCDBuilder> constructor(
|
||||
final String symbolicName,
|
||||
final boolean isOptional) {
|
||||
return new SymbolicParameterDeclarationListBuilder<SCDBuilder>(this, new ExecuteOnEnd() {
|
||||
return new SymbolicParameterDeclarationListBuilder<>(this, new ExecuteOnEnd() {
|
||||
@Override
|
||||
public void run(SymbolicParameterDeclarationList parameters) {
|
||||
constructors.add(new SymbolicConstructorDeclaration(symbolicName, isOptional, parameters));
|
||||
@ -80,7 +80,7 @@ public class CTBuilder {
|
||||
final String symbolicName,
|
||||
final String realName,
|
||||
final boolean isOptional) {
|
||||
return new SymbolicParameterDeclarationListBuilder<SCDBuilder>(this, new ExecuteOnEnd() {
|
||||
return new SymbolicParameterDeclarationListBuilder<>(this, new ExecuteOnEnd() {
|
||||
@Override
|
||||
public void run(SymbolicParameterDeclarationList parameters) {
|
||||
methods.add(new SymbolicMethodDeclaration(symbolicName, realName, isOptional, parameters));
|
||||
@ -129,8 +129,9 @@ public class CTBuilder {
|
||||
}
|
||||
|
||||
private SCDBuilder thenDeclare(String symbolicClassName, boolean isOptional) {
|
||||
if (detector == null)
|
||||
if (detector == null) {
|
||||
throw new IllegalStateException("can't declare a symbolic class without calling ifDetect before");
|
||||
}
|
||||
CTBuilder.this.declarationBuilder.init(symbolicClassName, isOptional);
|
||||
return CTBuilder.this.declarationBuilder;
|
||||
}
|
||||
@ -149,7 +150,7 @@ public class CTBuilder {
|
||||
if (previous != null) {
|
||||
return previous.constructResult();
|
||||
} else {
|
||||
return new HashMap<RealClassDetector, SymbolicClassDeclaration>();
|
||||
return new HashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class ClassTranslator {
|
||||
}
|
||||
|
||||
public Map<SymbolicClassDeclaration, List<RealClass>> translateToAllMatching(List<RealClass> realClasses) {
|
||||
Map<SymbolicClassDeclaration, List<RealClass>> result = new HashMap<SymbolicClassDeclaration, List<RealClass>>();
|
||||
Map<SymbolicClassDeclaration, List<RealClass>> result = new HashMap<>();
|
||||
for (Entry<RealClassDetector, SymbolicClassDeclaration> entry : translations.entrySet()) {
|
||||
SymbolicClassDeclaration declaration = entry.getValue();
|
||||
List<RealClass> allMatching = entry.getKey().allMatching(realClasses);
|
||||
@ -37,7 +37,7 @@ public class ClassTranslator {
|
||||
}
|
||||
|
||||
public Map<SymbolicClassDeclaration, String> translate(List<RealClass> realClasses) throws ClassNotFoundException {
|
||||
Map<SymbolicClassDeclaration, String> result = new HashMap<SymbolicClassDeclaration, String>();
|
||||
Map<SymbolicClassDeclaration, String> result = new HashMap<>();
|
||||
for (Entry<RealClassDetector, SymbolicClassDeclaration> entry : translations.entrySet()) {
|
||||
RealClass firstMatching = entry.getKey().firstMatching(realClasses);
|
||||
String realClassName = null;
|
||||
|
@ -89,8 +89,8 @@ public class Fragment {
|
||||
private final AtomicReferenceArray<List<WorldIcon>> worldIcons;
|
||||
|
||||
public Fragment(int numberOfLayers) {
|
||||
this.images = new AtomicReferenceArray<BufferedImage>(numberOfLayers);
|
||||
this.worldIcons = new AtomicReferenceArray<List<WorldIcon>>(numberOfLayers);
|
||||
this.images = new AtomicReferenceArray<>(numberOfLayers);
|
||||
this.worldIcons = new AtomicReferenceArray<>(numberOfLayers);
|
||||
}
|
||||
|
||||
public void setAlpha(float alpha) {
|
||||
|
@ -14,7 +14,7 @@ import amidst.logging.Log;
|
||||
public class FragmentCache {
|
||||
private static final int NEW_FRAGMENTS_PER_REQUEST = 1024;
|
||||
|
||||
private final List<Fragment> cache = new LinkedList<Fragment>();
|
||||
private final List<Fragment> cache = new LinkedList<>();
|
||||
private volatile int cacheSize = 0;
|
||||
|
||||
private final ConcurrentLinkedQueue<Fragment> availableQueue;
|
||||
|
@ -13,9 +13,9 @@ import amidst.settings.Setting;
|
||||
|
||||
@NotThreadSafe
|
||||
public class FragmentManager {
|
||||
private final ConcurrentLinkedQueue<Fragment> availableQueue = new ConcurrentLinkedQueue<Fragment>();
|
||||
private final ConcurrentLinkedQueue<Fragment> loadingQueue = new ConcurrentLinkedQueue<Fragment>();
|
||||
private final ConcurrentLinkedQueue<Fragment> recycleQueue = new ConcurrentLinkedQueue<Fragment>();
|
||||
private final ConcurrentLinkedQueue<Fragment> availableQueue = new ConcurrentLinkedQueue<>();
|
||||
private final ConcurrentLinkedQueue<Fragment> loadingQueue = new ConcurrentLinkedQueue<>();
|
||||
private final ConcurrentLinkedQueue<Fragment> recycleQueue = new ConcurrentLinkedQueue<>();
|
||||
private final FragmentCache cache;
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
|
@ -33,7 +33,6 @@ import amidst.gui.main.viewer.Zoom;
|
||||
import amidst.mojangapi.world.Dimension;
|
||||
import amidst.mojangapi.world.World;
|
||||
import amidst.mojangapi.world.coordinates.Resolution;
|
||||
import amidst.mojangapi.world.oracle.EndIsland;
|
||||
import amidst.mojangapi.world.versionfeatures.VersionFeatures;
|
||||
import amidst.settings.Setting;
|
||||
import amidst.settings.Settings;
|
||||
@ -131,20 +130,20 @@ public class LayerBuilder {
|
||||
AmidstSettings settings) {
|
||||
// @formatter:off
|
||||
return Collections.unmodifiableList(Arrays.asList(
|
||||
new AlphaInitializer( declarations.get(LayerIds.ALPHA), settings.fragmentFading),
|
||||
new BiomeDataLoader( declarations.get(LayerIds.BIOME_DATA), world.getBiomeDataOracle()),
|
||||
new EndIslandsLoader( declarations.get(LayerIds.END_ISLANDS), world.getEndIslandOracle()),
|
||||
new ImageLoader( declarations.get(LayerIds.BACKGROUND), Resolution.QUARTER, new BackgroundColorProvider(new BiomeColorProvider(biomeSelection, settings.biomeProfileSelection), new TheEndColorProvider())),
|
||||
new ImageLoader( declarations.get(LayerIds.SLIME), Resolution.CHUNK, new SlimeColorProvider(world.getSlimeChunkOracle())),
|
||||
new WorldIconLoader<Void>( declarations.get(LayerIds.SPAWN), world.getSpawnProducer()),
|
||||
new WorldIconLoader<Void>( declarations.get(LayerIds.STRONGHOLD), world.getStrongholdProducer()),
|
||||
new WorldIconLoader<Void>( declarations.get(LayerIds.PLAYER), world.getPlayerProducer()),
|
||||
new WorldIconLoader<Void>( declarations.get(LayerIds.VILLAGE), world.getVillageProducer()),
|
||||
new WorldIconLoader<Void>( declarations.get(LayerIds.TEMPLE), world.getTempleProducer()),
|
||||
new WorldIconLoader<Void>( declarations.get(LayerIds.MINESHAFT), world.getMineshaftProducer()),
|
||||
new WorldIconLoader<Void>( declarations.get(LayerIds.OCEAN_MONUMENT), world.getOceanMonumentProducer()),
|
||||
new WorldIconLoader<Void>( declarations.get(LayerIds.NETHER_FORTRESS), world.getNetherFortressProducer()),
|
||||
new WorldIconLoader<List<EndIsland>>(declarations.get(LayerIds.END_CITY), world.getEndCityProducer(), Fragment::getEndIslands)
|
||||
new AlphaInitializer( declarations.get(LayerIds.ALPHA), settings.fragmentFading),
|
||||
new BiomeDataLoader( declarations.get(LayerIds.BIOME_DATA), world.getBiomeDataOracle()),
|
||||
new EndIslandsLoader( declarations.get(LayerIds.END_ISLANDS), world.getEndIslandOracle()),
|
||||
new ImageLoader( declarations.get(LayerIds.BACKGROUND), Resolution.QUARTER, new BackgroundColorProvider(new BiomeColorProvider(biomeSelection, settings.biomeProfileSelection), new TheEndColorProvider())),
|
||||
new ImageLoader( declarations.get(LayerIds.SLIME), Resolution.CHUNK, new SlimeColorProvider(world.getSlimeChunkOracle())),
|
||||
new WorldIconLoader<>(declarations.get(LayerIds.SPAWN), world.getSpawnProducer()),
|
||||
new WorldIconLoader<>(declarations.get(LayerIds.STRONGHOLD), world.getStrongholdProducer()),
|
||||
new WorldIconLoader<>(declarations.get(LayerIds.PLAYER), world.getPlayerProducer()),
|
||||
new WorldIconLoader<>(declarations.get(LayerIds.VILLAGE), world.getVillageProducer()),
|
||||
new WorldIconLoader<>(declarations.get(LayerIds.TEMPLE), world.getTempleProducer()),
|
||||
new WorldIconLoader<>(declarations.get(LayerIds.MINESHAFT), world.getMineshaftProducer()),
|
||||
new WorldIconLoader<>(declarations.get(LayerIds.OCEAN_MONUMENT), world.getOceanMonumentProducer()),
|
||||
new WorldIconLoader<>(declarations.get(LayerIds.NETHER_FORTRESS), world.getNetherFortressProducer()),
|
||||
new WorldIconLoader<>(declarations.get(LayerIds.END_CITY), world.getEndCityProducer(), Fragment::getEndIslands)
|
||||
));
|
||||
// @formatter:on
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class LicenseWindow {
|
||||
}
|
||||
|
||||
private JList<License> createLicenseList(License[] licenses, final JTextArea textArea) {
|
||||
final JList<License> result = new JList<License>(licenses);
|
||||
final JList<License> result = new JList<>(licenses);
|
||||
result.setBorder(new LineBorder(Color.darkGray, 1));
|
||||
result.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
result.addListSelectionListener(new ListSelectionListener() {
|
||||
|
@ -55,7 +55,7 @@ public class MainWindow {
|
||||
private final AmidstMenu menuBar;
|
||||
private final SeedSearcherWindow seedSearcherWindow;
|
||||
|
||||
private final AtomicReference<ViewerFacade> viewerFacade = new AtomicReference<ViewerFacade>();
|
||||
private final AtomicReference<ViewerFacade> viewerFacade = new AtomicReference<>();
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
public MainWindow(
|
||||
|
@ -20,8 +20,8 @@ import amidst.settings.biomeprofile.BiomeProfileVisitor;
|
||||
public class BiomeProfileMenuFactory {
|
||||
@NotThreadSafe
|
||||
private static class BiomeProfileVisitorImpl implements BiomeProfileVisitor {
|
||||
private final List<JCheckBoxMenuItem> allCheckBoxes = new ArrayList<JCheckBoxMenuItem>();
|
||||
private final List<JMenu> menuStack = new ArrayList<JMenu>();
|
||||
private final List<JCheckBoxMenuItem> allCheckBoxes = new ArrayList<>();
|
||||
private final List<JMenu> menuStack = new ArrayList<>();
|
||||
private ActionListener firstListener;
|
||||
private boolean isFirstContainer = true;
|
||||
|
||||
|
@ -26,8 +26,8 @@ public class LayersMenu {
|
||||
private final AmidstSettings settings;
|
||||
private final Setting<Dimension> dimensionSetting;
|
||||
private final Setting<Boolean> enableAllLayersSetting;
|
||||
private final List<JMenuItem> overworldMenuItems = new LinkedList<JMenuItem>();
|
||||
private final List<JMenuItem> endMenuItems = new LinkedList<JMenuItem>();
|
||||
private final List<JMenuItem> overworldMenuItems = new LinkedList<>();
|
||||
private final List<JMenuItem> endMenuItems = new LinkedList<>();
|
||||
private volatile ViewerFacade viewerFacade;
|
||||
private volatile boolean showEnableAllLayers;
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class BiomeWidget extends Widget {
|
||||
private final LayerReloader layerReloader;
|
||||
private final BiomeProfileSelection biomeProfileSelection;
|
||||
|
||||
private List<Biome> biomes = new ArrayList<Biome>();
|
||||
private List<Biome> biomes = new ArrayList<>();
|
||||
private int maxNameWidth = 0;
|
||||
private int biomeListHeight;
|
||||
private boolean isInitialized = false;
|
||||
|
@ -94,7 +94,7 @@ public class ProfileSelectPanel {
|
||||
|
||||
private final Setting<String> lastProfileSetting;
|
||||
private final Component component;
|
||||
private final List<ProfileComponent> profileComponents = new ArrayList<ProfileComponent>();
|
||||
private final List<ProfileComponent> profileComponents = new ArrayList<>();
|
||||
|
||||
private ProfileComponent selected = null;
|
||||
private int selectedIndex = INVALID_INDEX;
|
||||
|
@ -61,7 +61,7 @@ public class SeedSearcherWindow {
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
private JComboBox<WorldType> createWorldTypeComboBox() {
|
||||
return new JComboBox<WorldType>(WorldType.getSelectableArray());
|
||||
return new JComboBox<>(WorldType.getSelectableArray());
|
||||
}
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
|
@ -17,7 +17,7 @@ import amidst.documentation.NotThreadSafe;
|
||||
|
||||
@NotThreadSafe
|
||||
public class FileLogger implements Logger {
|
||||
private final ConcurrentLinkedQueue<String> logMessageQueue = new ConcurrentLinkedQueue<String>();
|
||||
private final ConcurrentLinkedQueue<String> logMessageQueue = new ConcurrentLinkedQueue<>();
|
||||
private final File file;
|
||||
private final ScheduledExecutorService executor;
|
||||
|
||||
|
@ -19,7 +19,7 @@ public class Log {
|
||||
private static final boolean IS_USING_ALERTS = true;
|
||||
private static final boolean IS_SHOWING_DEBUG = true;
|
||||
|
||||
private static final Map<String, Logger> LOGGER = new HashMap<String, Logger>();
|
||||
private static final Map<String, Logger> LOGGER = new HashMap<>();
|
||||
|
||||
static {
|
||||
addListener("console", CONSOLE_LOGGER);
|
||||
|
@ -18,7 +18,7 @@ public enum LibraryFinder {
|
||||
|
||||
@NotNull
|
||||
public static List<URL> getLibraryUrls(File librariesDirectory, List<LibraryJson> libraries) {
|
||||
List<URL> result = new ArrayList<URL>();
|
||||
List<URL> result = new ArrayList<>();
|
||||
for (LibraryJson library : libraries) {
|
||||
File libraryFile = getLibraryFile(librariesDirectory, library);
|
||||
if (libraryFile != null) {
|
||||
|
@ -156,7 +156,7 @@ public class SaveDirectory {
|
||||
*/
|
||||
@NotNull
|
||||
public List<PlayerNbt> createMultiplayerPlayerNbts() {
|
||||
List<PlayerNbt> result = new ArrayList<PlayerNbt>();
|
||||
List<PlayerNbt> result = new ArrayList<>();
|
||||
for (File playerdataFile : getPlayerdataFiles()) {
|
||||
if (playerdataFile.isFile()) {
|
||||
result.add(createPlayerdataPlayerNbt(getPlayerUUIDFromPlayerdataFile(playerdataFile)));
|
||||
|
@ -79,7 +79,7 @@ public class VersionDirectory {
|
||||
return readVersionJson().getLibraryUrls(dotMinecraftDirectory.getLibraries());
|
||||
} catch (IOException | MojangApiParsingException e) {
|
||||
Log.w("Invalid jar profile loaded. Library loading will be skipped. (Path: " + json + ")");
|
||||
return new ArrayList<URL>();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class WorldFilterJson_MatchAll {
|
||||
}
|
||||
|
||||
private List<WorldFilter> createFilterList() {
|
||||
List<WorldFilter> filters = new ArrayList<WorldFilter>();
|
||||
List<WorldFilter> filters = new ArrayList<>();
|
||||
for (WorldFilterJson_Biome biomeFilterJson : biomeFilters) {
|
||||
filters.add(biomeFilterJson.createBiomeFilter());
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public enum PlayerLocationSaver {
|
||||
private static Map<String, Tag> modifyPositionInBaseMapSinglePlayer(
|
||||
Map<String, Tag> baseMap,
|
||||
PlayerCoordinates coordinates) {
|
||||
Map<String, Tag> result = new HashMap<String, Tag>();
|
||||
Map<String, Tag> result = new HashMap<>();
|
||||
CompoundTag dataTag = (CompoundTag) baseMap.get(NBTTagKeys.TAG_KEY_DATA);
|
||||
CompoundTag modifiedDataTag = modifyPositionInDataTagSinglePlayer(dataTag, coordinates);
|
||||
result.put(NBTTagKeys.TAG_KEY_DATA, modifiedDataTag);
|
||||
@ -67,7 +67,7 @@ public enum PlayerLocationSaver {
|
||||
private static Map<String, Tag> modifyPositionInDataMapSinglePlayer(
|
||||
Map<String, Tag> dataMap,
|
||||
PlayerCoordinates coordinates) {
|
||||
Map<String, Tag> result = new HashMap<String, Tag>(dataMap);
|
||||
Map<String, Tag> result = new HashMap<>(dataMap);
|
||||
CompoundTag playerTag = (CompoundTag) dataMap.get(NBTTagKeys.TAG_KEY_PLAYER);
|
||||
CompoundTag modifiedPlayerTag = modifyPositionInPlayerTagSinglePlayer(playerTag, coordinates);
|
||||
result.put(NBTTagKeys.TAG_KEY_PLAYER, modifiedPlayerTag);
|
||||
@ -91,7 +91,7 @@ public enum PlayerLocationSaver {
|
||||
private static Map<String, Tag> modifyPositionInPlayerMap(
|
||||
Map<String, Tag> playerMap,
|
||||
PlayerCoordinates coordinates) {
|
||||
Map<String, Tag> result = new HashMap<String, Tag>(playerMap);
|
||||
Map<String, Tag> result = new HashMap<>(playerMap);
|
||||
ListTag posTag = (ListTag) playerMap.get(NBTTagKeys.TAG_KEY_POS);
|
||||
ListTag modifiedPosTag = modifyPositionInPosTag(posTag, coordinates);
|
||||
result.put(NBTTagKeys.TAG_KEY_POS, modifiedPosTag);
|
||||
@ -105,7 +105,7 @@ public enum PlayerLocationSaver {
|
||||
}
|
||||
|
||||
private static List<Tag> modifyPositionInPosList(List<Tag> posList, PlayerCoordinates coordinates) {
|
||||
List<Tag> result = new ArrayList<Tag>(posList);
|
||||
List<Tag> result = new ArrayList<>(posList);
|
||||
result.set(0, new DoubleTag("x", coordinates.getXForNBTFile()));
|
||||
result.set(1, new DoubleTag("y", coordinates.getYForNBTFile()));
|
||||
result.set(2, new DoubleTag("z", coordinates.getZForNBTFile()));
|
||||
|
@ -220,7 +220,7 @@ public enum RecognisedVersion {
|
||||
}
|
||||
|
||||
public static Map<String, RecognisedVersion> generateNameToRecognisedVersionMap() {
|
||||
Map<String, RecognisedVersion> result = new LinkedHashMap<String, RecognisedVersion>();
|
||||
Map<String, RecognisedVersion> result = new LinkedHashMap<>();
|
||||
for (RecognisedVersion recognisedVersion : RecognisedVersion.values()) {
|
||||
if (result.containsKey(recognisedVersion.getName())) {
|
||||
RecognisedVersion colliding = result.get(recognisedVersion.getName());
|
||||
@ -235,7 +235,7 @@ public enum RecognisedVersion {
|
||||
}
|
||||
|
||||
public static Map<String, RecognisedVersion> generateMagicStringToRecognisedVersionMap() {
|
||||
Map<String, RecognisedVersion> result = new LinkedHashMap<String, RecognisedVersion>();
|
||||
Map<String, RecognisedVersion> result = new LinkedHashMap<>();
|
||||
for (RecognisedVersion recognisedVersion : RecognisedVersion.values()) {
|
||||
if (result.containsKey(recognisedVersion.getMagicString())) {
|
||||
RecognisedVersion colliding = result.get(recognisedVersion.getMagicString());
|
||||
|
@ -1,7 +1,6 @@
|
||||
package amidst.mojangapi.world;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import amidst.documentation.Immutable;
|
||||
import amidst.mojangapi.file.MojangApiParsingException;
|
||||
@ -23,7 +22,6 @@ import amidst.mojangapi.world.icon.type.EndCityWorldIconTypeProvider;
|
||||
import amidst.mojangapi.world.icon.type.ImmutableWorldIconTypeProvider;
|
||||
import amidst.mojangapi.world.icon.type.TempleWorldIconTypeProvider;
|
||||
import amidst.mojangapi.world.oracle.BiomeDataOracle;
|
||||
import amidst.mojangapi.world.oracle.EndIsland;
|
||||
import amidst.mojangapi.world.oracle.EndIslandOracle;
|
||||
import amidst.mojangapi.world.oracle.HeuristicWorldSpawnOracle;
|
||||
import amidst.mojangapi.world.oracle.ImmutableWorldSpawnOracle;
|
||||
@ -126,7 +124,7 @@ public class WorldBuilder {
|
||||
biomeDataOracle,
|
||||
versionFeatures.getValidBiomesAtMiddleOfChunk_Stronghold()),
|
||||
new PlayerProducer(movablePlayerList),
|
||||
new StructureProducer<Void>(
|
||||
new StructureProducer<>(
|
||||
Resolution.CHUNK,
|
||||
4,
|
||||
new VillageLocationChecker(
|
||||
@ -136,7 +134,7 @@ public class WorldBuilder {
|
||||
new ImmutableWorldIconTypeProvider(DefaultWorldIconTypes.VILLAGE),
|
||||
Dimension.OVERWORLD,
|
||||
false),
|
||||
new StructureProducer<Void>(
|
||||
new StructureProducer<>(
|
||||
Resolution.CHUNK,
|
||||
8,
|
||||
new TempleLocationChecker(
|
||||
@ -146,14 +144,14 @@ public class WorldBuilder {
|
||||
new TempleWorldIconTypeProvider(biomeDataOracle),
|
||||
Dimension.OVERWORLD,
|
||||
false),
|
||||
new StructureProducer<Void>(
|
||||
new StructureProducer<>(
|
||||
Resolution.CHUNK,
|
||||
8,
|
||||
versionFeatures.getMineshaftAlgorithmFactory().apply(seed),
|
||||
new ImmutableWorldIconTypeProvider(DefaultWorldIconTypes.MINESHAFT),
|
||||
Dimension.OVERWORLD,
|
||||
false),
|
||||
new StructureProducer<Void>(
|
||||
new StructureProducer<>(
|
||||
Resolution.CHUNK,
|
||||
8,
|
||||
versionFeatures.getOceanMonumentLocationCheckerFactory().apply(
|
||||
@ -164,14 +162,14 @@ public class WorldBuilder {
|
||||
new ImmutableWorldIconTypeProvider(DefaultWorldIconTypes.OCEAN_MONUMENT),
|
||||
Dimension.OVERWORLD,
|
||||
false),
|
||||
new StructureProducer<Void>(
|
||||
new StructureProducer<>(
|
||||
Resolution.NETHER_CHUNK,
|
||||
88,
|
||||
new NetherFortressAlgorithm(seed),
|
||||
new ImmutableWorldIconTypeProvider(DefaultWorldIconTypes.NETHER_FORTRESS),
|
||||
Dimension.NETHER,
|
||||
false),
|
||||
new StructureProducer<List<EndIsland>>(
|
||||
new StructureProducer<>(
|
||||
Resolution.CHUNK,
|
||||
8,
|
||||
new EndCityLocationChecker(seed),
|
||||
|
@ -46,7 +46,7 @@ public class Biome {
|
||||
}
|
||||
|
||||
// @formatter:off
|
||||
private static final Map<String, Biome> biomeMap = new HashMap<String, Biome>();
|
||||
private static final Map<String, Biome> biomeMap = new HashMap<>();
|
||||
private static final Biome[] biomes = new Biome[256];
|
||||
|
||||
public static final Biome ocean = new Biome("Ocean", 0, BiomeColor.from( 0, 0, 112), BiomeType.OCEAN);
|
||||
|
@ -19,7 +19,7 @@ public class PlayerProducer extends CachedWorldIconProducer {
|
||||
|
||||
@Override
|
||||
protected List<WorldIcon> doCreateCache() {
|
||||
List<WorldIcon> result = new LinkedList<WorldIcon>();
|
||||
List<WorldIcon> result = new LinkedList<>();
|
||||
for (Player player : movablePlayerList) {
|
||||
PlayerCoordinates coordinates = player.getPlayerCoordinates();
|
||||
result.add(
|
||||
|
@ -29,7 +29,7 @@ public abstract class StrongholdProducer_Base extends CachedWorldIconProducer {
|
||||
|
||||
@Override
|
||||
protected List<WorldIcon> doCreateCache() {
|
||||
List<WorldIcon> result = new LinkedList<WorldIcon>();
|
||||
List<WorldIcon> result = new LinkedList<>();
|
||||
Random random = new Random(seed);
|
||||
int ring = getInitialValue_ring();
|
||||
int structuresPerRing = STRUCTURES_ON_FIRST_RING;
|
||||
|
@ -20,7 +20,7 @@ public class WorldIconCollector implements Consumer<WorldIcon> {
|
||||
|
||||
private void initListIfNecessary() {
|
||||
if (worldIcons == null) {
|
||||
worldIcons = new LinkedList<WorldIcon>();
|
||||
worldIcons = new LinkedList<>();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ public enum DefaultWorldIconTypes {
|
||||
private static final Map<String, DefaultWorldIconTypes> typeMap = createTypeMap();
|
||||
|
||||
private static Map<String, DefaultWorldIconTypes> createTypeMap() {
|
||||
Map<String, DefaultWorldIconTypes> result = new HashMap<String, DefaultWorldIconTypes>();
|
||||
Map<String, DefaultWorldIconTypes> result = new HashMap<>();
|
||||
for (DefaultWorldIconTypes iconType : EnumSet.allOf(DefaultWorldIconTypes.class)) {
|
||||
result.put(iconType.getName(), iconType);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public class EndIslandOracle {
|
||||
int chunkY,
|
||||
int chunksPerFragmentX,
|
||||
int chunksPerFragmentY) {
|
||||
List<EndIsland> result = new LinkedList<EndIsland>();
|
||||
List<EndIsland> result = new LinkedList<>();
|
||||
for (int y = -SURROUNDING_CHUNKS; y <= chunksPerFragmentY + SURROUNDING_CHUNKS; y++) {
|
||||
for (int x = -SURROUNDING_CHUNKS; x <= chunksPerFragmentX + SURROUNDING_CHUNKS; x++) {
|
||||
EndIsland island = tryCreateEndIsland(chunkX + x, chunkY + y);
|
||||
|
@ -24,7 +24,7 @@ public class MovablePlayerList implements Iterable<Player> {
|
||||
private final boolean isSaveEnabled;
|
||||
|
||||
private volatile WorldPlayerType worldPlayerType;
|
||||
private volatile ConcurrentLinkedQueue<Player> players = new ConcurrentLinkedQueue<Player>();
|
||||
private volatile ConcurrentLinkedQueue<Player> players = new ConcurrentLinkedQueue<>();
|
||||
|
||||
public MovablePlayerList(
|
||||
PlayerInformationCache playerInformationCache,
|
||||
@ -52,7 +52,7 @@ public class MovablePlayerList implements Iterable<Player> {
|
||||
public void load(WorkerExecutor workerExecutor, Runnable onPlayerFinishedLoading) {
|
||||
if (saveDirectory != null) {
|
||||
Log.i("loading player locations");
|
||||
ConcurrentLinkedQueue<Player> players = new ConcurrentLinkedQueue<Player>();
|
||||
ConcurrentLinkedQueue<Player> players = new ConcurrentLinkedQueue<>();
|
||||
this.players = players;
|
||||
loadPlayersLater(players, workerExecutor, onPlayerFinishedLoading);
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ import amidst.logging.Log;
|
||||
*/
|
||||
@ThreadSafe
|
||||
public class PlayerInformationCacheImpl implements PlayerInformationCache {
|
||||
private final Map<String, PlayerInformation> byUUID = new ConcurrentHashMap<String, PlayerInformation>();
|
||||
private final Map<String, PlayerInformation> byName = new ConcurrentHashMap<String, PlayerInformation>();
|
||||
private final Map<String, PlayerInformation> byUUID = new ConcurrentHashMap<>();
|
||||
private final Map<String, PlayerInformation> byName = new ConcurrentHashMap<>();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
|
@ -53,7 +53,7 @@ public enum WorldPlayerType {
|
||||
@NotNull
|
||||
public List<PlayerNbt> createPlayerNbts(SaveDirectory saveDirectory) {
|
||||
if (this == BOTH) {
|
||||
List<PlayerNbt> result = new ArrayList<PlayerNbt>();
|
||||
List<PlayerNbt> result = new ArrayList<>();
|
||||
result.addAll(saveDirectory.createSingleplayerPlayerNbts());
|
||||
result.addAll(saveDirectory.createMultiplayerPlayerNbts());
|
||||
return result;
|
||||
|
@ -184,7 +184,7 @@ public enum DefaultVersionFeatures {
|
||||
}
|
||||
|
||||
private static List<Biome> getValidBiomesForStrongholdSinceV13w36a() {
|
||||
List<Biome> result = new ArrayList<Biome>();
|
||||
List<Biome> result = new ArrayList<>();
|
||||
for (Biome biome : Biome.allBiomes()) {
|
||||
if (biome.getType().getBiomeDepth() > 0) {
|
||||
result.add(biome);
|
||||
|
@ -13,7 +13,7 @@ import amidst.mojangapi.minecraftinterface.RecognisedVersion;
|
||||
@NotThreadSafe
|
||||
public class ListVersionFeatureBuilder<V> {
|
||||
private static <V> List<V> concat(List<V> values, List<V> additionalValues) {
|
||||
List<V> result = new ArrayList<V>(values.size() + additionalValues.size());
|
||||
List<V> result = new ArrayList<>(values.size() + additionalValues.size());
|
||||
result.addAll(values);
|
||||
result.addAll(additionalValues);
|
||||
return result;
|
||||
@ -22,8 +22,8 @@ public class ListVersionFeatureBuilder<V> {
|
||||
private List<V> defaultValue = null;
|
||||
private RecognisedVersion previous = null;
|
||||
private RecognisedVersion previousExact = null;
|
||||
private final List<VersionFeatureEntry<List<V>>> exactMatches = new LinkedList<VersionFeatureEntry<List<V>>>();
|
||||
private final List<VersionFeatureEntry<List<V>>> entriesNewestFirst = new LinkedList<VersionFeatureEntry<List<V>>>();
|
||||
private final List<VersionFeatureEntry<List<V>>> exactMatches = new LinkedList<>();
|
||||
private final List<VersionFeatureEntry<List<V>>> entriesNewestFirst = new LinkedList<>();
|
||||
|
||||
@SafeVarargs
|
||||
public final ListVersionFeatureBuilder<V> init(V... defaultValues) {
|
||||
@ -56,7 +56,7 @@ public class ListVersionFeatureBuilder<V> {
|
||||
throw new IllegalStateException("you have to specify all exact matches before the first since");
|
||||
} else {
|
||||
previousExact = version;
|
||||
exactMatches.add(0, new VersionFeatureEntry<List<V>>(version, Collections.unmodifiableList(value)));
|
||||
exactMatches.add(0, new VersionFeatureEntry<>(version, Collections.unmodifiableList(value)));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -81,7 +81,7 @@ public class ListVersionFeatureBuilder<V> {
|
||||
throw new IllegalStateException("you have to specify versions in ascending order");
|
||||
} else {
|
||||
previous = version;
|
||||
entriesNewestFirst.add(0, new VersionFeatureEntry<List<V>>(version, Collections.unmodifiableList(value)));
|
||||
entriesNewestFirst.add(0, new VersionFeatureEntry<>(version, Collections.unmodifiableList(value)));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -97,7 +97,7 @@ public class ListVersionFeatureBuilder<V> {
|
||||
}
|
||||
|
||||
public VersionFeature<List<V>> construct() {
|
||||
return new VersionFeature<List<V>>(
|
||||
return new VersionFeature<>(
|
||||
defaultValue,
|
||||
Collections.unmodifiableList(exactMatches),
|
||||
Collections.unmodifiableList(entriesNewestFirst));
|
||||
|
@ -8,11 +8,11 @@ import amidst.mojangapi.minecraftinterface.RecognisedVersion;
|
||||
@Immutable
|
||||
public class VersionFeature<V> {
|
||||
public static <V> VersionFeatureBuilder<V> builder() {
|
||||
return new VersionFeatureBuilder<V>();
|
||||
return new VersionFeatureBuilder<>();
|
||||
}
|
||||
|
||||
public static <V> ListVersionFeatureBuilder<V> listBuilder() {
|
||||
return new ListVersionFeatureBuilder<V>();
|
||||
return new ListVersionFeatureBuilder<>();
|
||||
}
|
||||
|
||||
private final V defaultValue;
|
||||
|
@ -13,8 +13,8 @@ public class VersionFeatureBuilder<V> {
|
||||
private V defaultValue = null;
|
||||
private RecognisedVersion previous = null;
|
||||
private RecognisedVersion previousExact = null;
|
||||
private final List<VersionFeatureEntry<V>> exactMatches = new LinkedList<VersionFeatureEntry<V>>();
|
||||
private final List<VersionFeatureEntry<V>> entriesNewestFirst = new LinkedList<VersionFeatureEntry<V>>();
|
||||
private final List<VersionFeatureEntry<V>> exactMatches = new LinkedList<>();
|
||||
private final List<VersionFeatureEntry<V>> entriesNewestFirst = new LinkedList<>();
|
||||
|
||||
public VersionFeatureBuilder<V> init(V defaultValue) {
|
||||
if (this.defaultValue == null) {
|
||||
@ -37,7 +37,7 @@ public class VersionFeatureBuilder<V> {
|
||||
throw new IllegalStateException("you have to specify all exact matches before the first since");
|
||||
} else {
|
||||
previousExact = version;
|
||||
exactMatches.add(0, new VersionFeatureEntry<V>(version, value));
|
||||
exactMatches.add(0, new VersionFeatureEntry<>(version, value));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -52,13 +52,13 @@ public class VersionFeatureBuilder<V> {
|
||||
throw new IllegalStateException("you have to specify versions in ascending order");
|
||||
} else {
|
||||
previous = version;
|
||||
entriesNewestFirst.add(0, new VersionFeatureEntry<V>(version, value));
|
||||
entriesNewestFirst.add(0, new VersionFeatureEntry<>(version, value));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public VersionFeature<V> construct() {
|
||||
return new VersionFeature<V>(
|
||||
return new VersionFeature<>(
|
||||
defaultValue,
|
||||
Collections.unmodifiableList(exactMatches),
|
||||
Collections.unmodifiableList(entriesNewestFirst));
|
||||
|
@ -11,32 +11,32 @@ public enum Settings {
|
||||
;
|
||||
|
||||
public static <T> Setting<T> createImmutable(T value) {
|
||||
return new ImmutableSetting<T>(value);
|
||||
return new ImmutableSetting<>(value);
|
||||
}
|
||||
|
||||
public static Setting<String> createString(Preferences preferences, String key, @NotNull String defaultValue) {
|
||||
return new SettingBase<String>(
|
||||
return new SettingBase<>(
|
||||
defaultValue,
|
||||
value -> preferences.get(key, value),
|
||||
value -> preferences.put(key, value));
|
||||
}
|
||||
|
||||
public static Setting<Boolean> createBoolean(Preferences preferences, String key, boolean defaultValue) {
|
||||
return new SettingBase<Boolean>(
|
||||
return new SettingBase<>(
|
||||
defaultValue,
|
||||
value -> preferences.getBoolean(key, value),
|
||||
value -> preferences.putBoolean(key, value));
|
||||
}
|
||||
|
||||
public static Setting<Dimension> createDimension(Preferences preferences, String key, Dimension defaultValue) {
|
||||
return new SettingBase<Dimension>(
|
||||
return new SettingBase<>(
|
||||
defaultValue,
|
||||
value -> Dimension.from(preferences.getInt(key, value.getId())),
|
||||
value -> preferences.putInt(key, value.getId()));
|
||||
}
|
||||
|
||||
public static <T> Setting<T> createDummy(T defaultValue) {
|
||||
return new SettingBase<T>(defaultValue, value -> value, value -> {
|
||||
return new SettingBase<>(defaultValue, value -> value, value -> {
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ import amidst.mojangapi.world.biome.BiomeColor;
|
||||
@Immutable
|
||||
public class BiomeProfile {
|
||||
private static Map<String, BiomeColorJson> createDefaultColorMap() {
|
||||
Map<String, BiomeColorJson> result = new HashMap<String, BiomeColorJson>();
|
||||
Map<String, BiomeColorJson> result = new HashMap<>();
|
||||
for (Biome biome : Biome.allBiomes()) {
|
||||
result.put(biome.getName(), biome.getDefaultColor().createBiomeColorJson());
|
||||
}
|
||||
@ -105,7 +105,7 @@ public class BiomeProfile {
|
||||
}
|
||||
|
||||
private Set<Entry<String, BiomeColorJson>> getSortedColorMapEntries() {
|
||||
SortedMap<String, BiomeColorJson> result = new TreeMap<String, BiomeColorJson>(Biome::compareByIndex);
|
||||
SortedMap<String, BiomeColorJson> result = new TreeMap<>(Biome::compareByIndex);
|
||||
result.putAll(colorMap);
|
||||
return result.entrySet();
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import amidst.documentation.ThreadSafe;
|
||||
*/
|
||||
@ThreadSafe
|
||||
public class TaskQueue {
|
||||
private final ConcurrentLinkedQueue<Runnable> tasks = new ConcurrentLinkedQueue<Runnable>();
|
||||
private final ConcurrentLinkedQueue<Runnable> tasks = new ConcurrentLinkedQueue<>();
|
||||
|
||||
/**
|
||||
* Executes all tasks. Returns true, if at least one task was executed.
|
||||
|
@ -12,12 +12,12 @@ import amidst.documentation.NotThreadSafe;
|
||||
public class Lazy<T> {
|
||||
public static <T> Lazy<T> fromValue(T value) {
|
||||
Objects.requireNonNull(value, VALUE_NULL_ERROR);
|
||||
return new Lazy<T>(() -> value);
|
||||
return new Lazy<>(() -> value);
|
||||
}
|
||||
|
||||
public static <T> Lazy<T> from(Supplier<T> supplier) {
|
||||
Objects.requireNonNull(supplier, SUPPLIER_NULL_ERROR);
|
||||
return new Lazy<T>(supplier);
|
||||
return new Lazy<>(supplier);
|
||||
}
|
||||
|
||||
private static final String VALUE_NULL_ERROR = "the value of a lazy cannot be null";
|
||||
|
@ -20,8 +20,8 @@ public class GenerateRecognisedVersionList {
|
||||
private final VersionListJson versionList;
|
||||
private final File versions;
|
||||
private final DotMinecraftDirectory dotMinecraftDirectory;
|
||||
private final List<String> versionsWithError = new LinkedList<String>();
|
||||
private final List<String> downloadFailed = new LinkedList<String>();
|
||||
private final List<String> versionsWithError = new LinkedList<>();
|
||||
private final List<String> downloadFailed = new LinkedList<>();
|
||||
private final RecognisedVersionEnumBuilder builder = RecognisedVersionEnumBuilder.createPopulated();
|
||||
|
||||
public GenerateRecognisedVersionList(String prefix, String libraries, VersionListJson versionList) {
|
||||
|
@ -26,8 +26,8 @@ public class GenerateWorldTestData {
|
||||
private final VersionListJson versionList;
|
||||
private final File versions;
|
||||
private final DotMinecraftDirectory dotMinecraftDirectory;
|
||||
private final List<String> failed = new LinkedList<String>();
|
||||
private final List<String> successful = new LinkedList<String>();
|
||||
private final List<String> failed = new LinkedList<>();
|
||||
private final List<String> successful = new LinkedList<>();
|
||||
|
||||
public GenerateWorldTestData(String prefix, String libraries, VersionListJson versionList) {
|
||||
this.prefix = prefix;
|
||||
|
@ -31,8 +31,8 @@ public class MinecraftVersionCompatibilityChecker {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
List<VersionListEntryJson> supported = new ArrayList<VersionListEntryJson>();
|
||||
List<VersionListEntryJson> unsupported = new ArrayList<VersionListEntryJson>();
|
||||
List<VersionListEntryJson> supported = new ArrayList<>();
|
||||
List<VersionListEntryJson> unsupported = new ArrayList<>();
|
||||
for (VersionListEntryJson version : versionList.getVersions()) {
|
||||
if (checkOne(version)) {
|
||||
supported.add(version);
|
||||
|
@ -22,7 +22,7 @@ public class RecognisedVersionEnumBuilder {
|
||||
return result;
|
||||
}
|
||||
|
||||
private final Map<String, RecognisedVersionEnumEntryBuilder> builders = new LinkedHashMap<String, RecognisedVersionEnumEntryBuilder>();
|
||||
private final Map<String, RecognisedVersionEnumEntryBuilder> builders = new LinkedHashMap<>();
|
||||
private int maxNameLength;
|
||||
private int maxDeclarationLength;
|
||||
|
||||
@ -65,19 +65,19 @@ public class RecognisedVersionEnumBuilder {
|
||||
}
|
||||
|
||||
public Iterable<String> renderNew() {
|
||||
List<String> result = new LinkedList<String>();
|
||||
List<String> result = new LinkedList<>();
|
||||
render(result, b -> !b.isKnown(), b -> b.renderLine(maxNameLength, maxDeclarationLength));
|
||||
return result;
|
||||
}
|
||||
|
||||
public Iterable<String> renderRenamed() {
|
||||
List<String> result = new LinkedList<String>();
|
||||
List<String> result = new LinkedList<>();
|
||||
render(result, b -> b.isRenamed(), b -> b.renderLine(maxNameLength, maxDeclarationLength));
|
||||
return result;
|
||||
}
|
||||
|
||||
public Iterable<String> renderComplete() {
|
||||
List<String> result = new LinkedList<String>();
|
||||
List<String> result = new LinkedList<>();
|
||||
render(result, b -> !b.isKnown(), b -> b.renderLine(maxNameLength, maxDeclarationLength));
|
||||
render(result, b -> b.isKnown(), b -> b.renderLine(maxNameLength, maxDeclarationLength));
|
||||
return result;
|
||||
|
@ -24,7 +24,7 @@ public class RecognisedVersionEnumEntryBuilder {
|
||||
private final boolean isKnown;
|
||||
private final String knownName;
|
||||
private final String magicString;
|
||||
private final List<String> matches = new LinkedList<String>();
|
||||
private final List<String> matches = new LinkedList<>();
|
||||
private String declaration;
|
||||
|
||||
public RecognisedVersionEnumEntryBuilder(boolean isKnown, String knownName, String magicString) {
|
||||
|
@ -10,8 +10,8 @@ import amidst.mojangapi.world.testworld.storage.json.BiomeDataJson;
|
||||
|
||||
@NotThreadSafe
|
||||
public class BiomeDataJsonBuilder {
|
||||
private final SortedMap<AreaJson, short[]> quarterBiomeData = new TreeMap<AreaJson, short[]>();
|
||||
private final SortedMap<AreaJson, short[]> fullBiomeData = new TreeMap<AreaJson, short[]>();
|
||||
private final SortedMap<AreaJson, short[]> quarterBiomeData = new TreeMap<>();
|
||||
private final SortedMap<AreaJson, short[]> fullBiomeData = new TreeMap<>();
|
||||
|
||||
public void store(int x, int y, int width, int height, boolean useQuarterResolution, int[] biomeData) {
|
||||
store(getBiomeDataMap(useQuarterResolution), x, y, width, height, biomeData);
|
||||
|
@ -32,7 +32,7 @@ public enum TestWorldCache {
|
||||
private final TestWorldBuilder builder = TestWorldBuilder.from(DefaultTestWorldDirectoryDeclaration.get());
|
||||
private final TestWorldDirectoryReader reader = builder.createReader();
|
||||
private final TestWorldDirectoryWriter writer = builder.createWriter();
|
||||
private final ConcurrentHashMap<TestWorldDeclaration, TestWorld> cache = new ConcurrentHashMap<TestWorldDeclaration, TestWorld>();
|
||||
private final ConcurrentHashMap<TestWorldDeclaration, TestWorld> cache = new ConcurrentHashMap<>();
|
||||
|
||||
public void doCreateAndPut(TestWorldDeclaration declaration, MinecraftInterface realMinecraftInterface)
|
||||
throws MinecraftInterfaceException,
|
||||
|
@ -45,7 +45,7 @@ public class TestWorldDirectoryDeclaration {
|
||||
World world,
|
||||
BiomeDataJson quarterBiomeData,
|
||||
BiomeDataJson fullBiomeData) {
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
for (Entry<String, TestWorldEntryDeclaration<?>> entry : entries.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
if (name.equals(TestWorldEntryNames.QUARTER_RESOLUTION_BIOME_DATA)) {
|
||||
|
@ -11,10 +11,10 @@ import amidst.mojangapi.world.testworld.file.TestWorldEntryDeclaration;
|
||||
|
||||
@NotThreadSafe
|
||||
public class TestWorldDirectoryDeclarationBuilder {
|
||||
private final Map<String, TestWorldEntryDeclarationBuilder<?>> builders = new HashMap<String, TestWorldEntryDeclarationBuilder<?>>();
|
||||
private final Map<String, TestWorldEntryDeclarationBuilder<?>> builders = new HashMap<>();
|
||||
|
||||
public TestWorldDirectoryDeclaration create() {
|
||||
Map<String, TestWorldEntryDeclaration<?>> result = new HashMap<String, TestWorldEntryDeclaration<?>>();
|
||||
Map<String, TestWorldEntryDeclaration<?>> result = new HashMap<>();
|
||||
for (Entry<String, TestWorldEntryDeclarationBuilder<?>> entry : builders.entrySet()) {
|
||||
result.put(entry.getKey(), entry.getValue().constructThis());
|
||||
}
|
||||
@ -22,7 +22,7 @@ public class TestWorldDirectoryDeclarationBuilder {
|
||||
}
|
||||
|
||||
public <T> TestWorldEntryDeclarationBuilder<T> entry(String name, Class<T> clazz) {
|
||||
TestWorldEntryDeclarationBuilder<T> builder = new TestWorldEntryDeclarationBuilder<T>(this, name, clazz);
|
||||
TestWorldEntryDeclarationBuilder<T> builder = new TestWorldEntryDeclarationBuilder<>(this, name, clazz);
|
||||
builders.put(name, builder);
|
||||
return builder;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public class TestWorldEntryDeclarationBuilder<T> {
|
||||
Objects.requireNonNull(deserializer);
|
||||
Objects.requireNonNull(extractor);
|
||||
Objects.requireNonNull(equalityChecker);
|
||||
return new TestWorldEntryDeclaration<T>(
|
||||
return new TestWorldEntryDeclaration<>(
|
||||
name,
|
||||
clazz,
|
||||
serializer,
|
||||
|
@ -29,7 +29,7 @@ public class TestWorldDirectoryReader {
|
||||
}
|
||||
|
||||
private Map<String, Object> readAll(TestWorldDeclaration worldDeclaration) throws IOException {
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
for (TestWorldEntryDeclaration<?> entryDeclaration : directoryDeclaration.getEntryDeclarations()) {
|
||||
if (worldDeclaration.isSupported(entryDeclaration.getName())) {
|
||||
readEntry(result, worldDeclaration, entryDeclaration);
|
||||
|
@ -44,7 +44,7 @@ public class CoordinatesCollectionJson {
|
||||
}
|
||||
|
||||
private static SortedSet<CoordinatesInWorld> createSortedSet(List<WorldIcon> icons) {
|
||||
SortedSet<CoordinatesInWorld> result = new TreeSet<CoordinatesInWorld>();
|
||||
SortedSet<CoordinatesInWorld> result = new TreeSet<>();
|
||||
for (WorldIcon icon : icons) {
|
||||
result.add(icon.getCoordinates());
|
||||
}
|
||||
@ -52,7 +52,7 @@ public class CoordinatesCollectionJson {
|
||||
}
|
||||
|
||||
private static SortedSet<CoordinatesInWorld> createSortedSet(CoordinatesInWorld coordinates) {
|
||||
SortedSet<CoordinatesInWorld> result = new TreeSet<CoordinatesInWorld>();
|
||||
SortedSet<CoordinatesInWorld> result = new TreeSet<>();
|
||||
result.add(coordinates);
|
||||
return result;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import amidst.mojangapi.world.oracle.EndIslandOracle;
|
||||
@Immutable
|
||||
public class EndIslandsJson {
|
||||
public static EndIslandsJson extract(EndIslandOracle oracle, int fragmentsAroundOrigin) {
|
||||
SortedMap<CoordinatesInWorld, List<EndIsland>> result = new TreeMap<CoordinatesInWorld, List<EndIsland>>();
|
||||
SortedMap<CoordinatesInWorld, List<EndIsland>> result = new TreeMap<>();
|
||||
FragmentCornerWalker.walkFragmentsAroundOrigin(fragmentsAroundOrigin).walk(
|
||||
corner -> result.put(corner, oracle.getAt(corner)));
|
||||
return new EndIslandsJson(result);
|
||||
|
Loading…
Reference in New Issue
Block a user