Merge pull request #2977 from zax71/codestyle-changes

This commit is contained in:
Ben Woo 2023-08-26 19:26:51 +08:00 committed by GitHub
commit 954e304f3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 52 additions and 54 deletions

View File

@ -7,14 +7,6 @@
package com.onarandombox.MultiverseCore; package com.onarandombox.MultiverseCore;
import java.io.File;
import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import com.dumptruckman.minecraft.util.Logging; import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.anchor.AnchorManager; import com.onarandombox.MultiverseCore.anchor.AnchorManager;
import com.onarandombox.MultiverseCore.api.Destination; import com.onarandombox.MultiverseCore.api.Destination;
@ -47,6 +39,12 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jvnet.hk2.annotations.Service; import org.jvnet.hk2.annotations.Service;
import java.io.File;
import java.lang.annotation.Annotation;
import java.util.List;
import java.util.logging.Logger;
import java.util.stream.Collectors;
/** /**
* The implementation of the Multiverse-{@link MVCore}. * The implementation of the Multiverse-{@link MVCore}.
*/ */
@ -377,7 +375,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
* Gets the best service from this plugin that implements the given contract or has the given implementation. * Gets the best service from this plugin that implements the given contract or has the given implementation.
* *
* @param contractOrImpl The contract or concrete implementation to get the best instance of * @param contractOrImpl The contract or concrete implementation to get the best instance of
* @param qualifiers The set of qualifiers that must match this service definition * @param qualifiers The set of qualifiers that must match this service definition
* @return An instance of the contract or impl if it is a service and is already instantiated, null otherwise * @return An instance of the contract or impl if it is a service and is already instantiated, null otherwise
* @throws MultiException if there was an error during service lookup * @throws MultiException if there was an error during service lookup
*/ */
@ -395,7 +393,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
* the provided qualifiers. * the provided qualifiers.
* *
* @param contractOrImpl The contract or concrete implementation to get the best instance of * @param contractOrImpl The contract or concrete implementation to get the best instance of
* @param qualifiers The set of qualifiers that must match this service definition * @param qualifiers The set of qualifiers that must match this service definition
* @return A list of services implementing this contract or concrete implementation. May not return null, but may * @return A list of services implementing this contract or concrete implementation. May not return null, but may
* return an empty list * return an empty list
* @throws MultiException if there was an error during service lookup * @throws MultiException if there was an error during service lookup
@ -415,10 +413,10 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
/** /**
* This is for unit testing ONLY. Do not use this constructor. * This is for unit testing ONLY. Do not use this constructor.
* *
* @param loader The PluginLoader to use. * @param loader The PluginLoader to use.
* @param description The Description file to use. * @param description The Description file to use.
* @param dataFolder The folder that other datafiles can be found in. * @param dataFolder The folder that other datafiles can be found in.
* @param file The location of the plugin. * @param file The location of the plugin.
*/ */
public MultiverseCore(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) { public MultiverseCore(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) {
super(loader, description, dataFolder, file); super(loader, description, dataFolder, file);

View File

@ -1,15 +1,15 @@
package com.onarandombox.MultiverseCore.configuration.node; package com.onarandombox.MultiverseCore.configuration.node;
import io.github.townyadvanced.commentedconfiguration.setting.CommentedNode;
import io.vavr.control.Option;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import io.github.townyadvanced.commentedconfiguration.setting.CommentedNode;
import io.vavr.control.Option;
import org.jetbrains.annotations.NotNull;
/** /**
* A collection of {@link CommentedNode}s, with mappings to nodes by name. * A collection of {@link CommentedNode}s, with mappings to nodes by name.
*/ */
@ -52,7 +52,7 @@ public class NodeGroup implements Collection<Node> {
/** /**
* Gets the node with the given name. * Gets the node with the given name.
* *
* @param name The name of the node to get. * @param name The name of the node to get.
* @return The node with the given name, or {@link Option.None} if no node with the given name exists. * @return The node with the given name, or {@link Option.None} if no node with the given name exists.
*/ */
public Option<Node> findNode(String name) { public Option<Node> findNode(String name) {

View File

@ -7,29 +7,12 @@
package com.onarandombox.MultiverseCore.world; package com.onarandombox.MultiverseCore.world;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.Stack;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import com.dumptruckman.minecraft.util.Logging; import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.BlockSafety; import com.onarandombox.MultiverseCore.api.BlockSafety;
import com.onarandombox.MultiverseCore.api.LocationManipulation; import com.onarandombox.MultiverseCore.api.LocationManipulation;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MVWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter; import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.api.WorldPurger; import com.onarandombox.MultiverseCore.api.WorldPurger;
import com.onarandombox.MultiverseCore.config.MVCoreConfig; import com.onarandombox.MultiverseCore.config.MVCoreConfig;
@ -56,6 +39,22 @@ import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.jvnet.hk2.annotations.Service; import org.jvnet.hk2.annotations.Service;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.Stack;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
/** /**
* Public facing API to add/remove Multiverse worlds. * Public facing API to add/remove Multiverse worlds.
*/ */
@ -179,7 +178,7 @@ public class SimpleMVWorldManager implements MVWorldManager {
} }
this.server.getWorld(oldName).setAutoSave(false); this.server.getWorld(oldName).setAutoSave(false);
} }
// Grab a bit of metadata from the old world. // Grab a bit of metadata from the old world.
MVWorld oldWorld = getMVWorld(oldName); MVWorld oldWorld = getMVWorld(oldName);
@ -207,7 +206,7 @@ public class SimpleMVWorldManager implements MVWorldManager {
if (oldWorld != null && wasAutoSave) { if (oldWorld != null && wasAutoSave) {
oldWorld.getCBWorld().setAutoSave(true); oldWorld.getCBWorld().setAutoSave(true);
} }
if (newWorldFile.exists()) { if (newWorldFile.exists()) {
Logging.fine("Succeeded at copying files"); Logging.fine("Succeeded at copying files");
@ -227,8 +226,8 @@ public class SimpleMVWorldManager implements MVWorldManager {
// actually load the world // actually load the world
if (doLoad(newName)) { if (doLoad(newName)) {
Logging.fine("Succeeded at loading cloned world '" + newName + "'"); Logging.fine("Succeeded at loading cloned world '" + newName + "'");
return true; return true;
} }
Logging.severe("Failed to load the cloned world '" + newName + "'"); Logging.severe("Failed to load the cloned world '" + newName + "'");
return false; return false;
@ -408,7 +407,7 @@ public class SimpleMVWorldManager implements MVWorldManager {
this.worlds.remove(name); this.worlds.remove(name);
Logging.info("World '%s' was unloaded from Bukkit.", name); Logging.info("World '%s' was unloaded from Bukkit.", name);
return true; return true;
} else if (!unloadBukkit){ } else if (!unloadBukkit) {
this.worlds.remove(name); this.worlds.remove(name);
Logging.info("World '%s' was unloaded from Multiverse.", name); Logging.info("World '%s' was unloaded from Multiverse.", name);
return true; return true;
@ -992,6 +991,7 @@ public class SimpleMVWorldManager implements MVWorldManager {
/** /**
* Gets the {@link FileConfiguration} that this {@link SimpleMVWorldManager} is using. * Gets the {@link FileConfiguration} that this {@link SimpleMVWorldManager} is using.
*
* @return The {@link FileConfiguration} that this {@link SimpleMVWorldManager} is using. * @return The {@link FileConfiguration} that this {@link SimpleMVWorldManager} is using.
*/ */
public FileConfiguration getConfigWorlds() { public FileConfiguration getConfigWorlds() {
@ -1001,24 +1001,24 @@ public class SimpleMVWorldManager implements MVWorldManager {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public boolean hasUnloadedWorld(String name, boolean includeLoaded) { public boolean hasUnloadedWorld(String name, boolean includeLoaded) {
if (getMVWorld(name) != null) { if (getMVWorld(name) != null) {
return includeLoaded; return includeLoaded;
} }
for (Map.Entry<String, WorldProperties> entry : this.worldsFromTheConfig.entrySet()) { for (Map.Entry<String, WorldProperties> entry : this.worldsFromTheConfig.entrySet()) {
if (name.equals(entry.getKey()) || name.equals(entry.getValue().getAlias())) { if (name.equals(entry.getKey()) || name.equals(entry.getValue().getAlias())) {
return true; return true;
} }
} }
return false; return false;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public Collection<String> getPotentialWorlds() { public Collection<String> getPotentialWorlds() {
File worldContainer = this.server.getWorldContainer(); File worldContainer = this.server.getWorldContainer();
if (worldContainer == null) { if (worldContainer == null) {
return Collections.emptyList(); return Collections.emptyList();