mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
disabledItems now also uses the Worlds UUID
This commit is contained in:
parent
ebf6725d7e
commit
a37fe6d62a
@ -34,7 +34,7 @@ public class PerWorldSettingsService {
|
|||||||
|
|
||||||
private final SlimefunPlugin plugin;
|
private final SlimefunPlugin plugin;
|
||||||
|
|
||||||
private final OptionalMap<String, Set<String>> disabledItems = new OptionalMap<>(HashMap::new);
|
private final OptionalMap<UUID, Set<String>> disabledItems = new OptionalMap<>(HashMap::new);
|
||||||
private final Map<SlimefunAddon, Set<String>> disabledAddons = new HashMap<>();
|
private final Map<SlimefunAddon, Set<String>> disabledAddons = new HashMap<>();
|
||||||
private final Set<UUID> disabledWorlds = new HashSet<>();
|
private final Set<UUID> disabledWorlds = new HashSet<>();
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ public class PerWorldSettingsService {
|
|||||||
* The {@link World} to load
|
* The {@link World} to load
|
||||||
*/
|
*/
|
||||||
public void load(World world) {
|
public void load(World world) {
|
||||||
disabledItems.putIfAbsent(world.getName(), loadWorldFromConfig(world));
|
disabledItems.putIfAbsent(world.getUID(), loadWorldFromConfig(world));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,7 +113,7 @@ public class PerWorldSettingsService {
|
|||||||
* @return Whether the given {@link SlimefunItem} is enabled in that {@link World}
|
* @return Whether the given {@link SlimefunItem} is enabled in that {@link World}
|
||||||
*/
|
*/
|
||||||
public boolean isEnabled(World world, SlimefunItem item) {
|
public boolean isEnabled(World world, SlimefunItem item) {
|
||||||
Set<String> items = disabledItems.computeIfAbsent(world.getName(), name -> loadWorldFromConfig(world));
|
Set<String> items = disabledItems.computeIfAbsent(world.getUID(), id -> loadWorldFromConfig(world));
|
||||||
|
|
||||||
if (disabledWorlds.contains(world.getUID())) {
|
if (disabledWorlds.contains(world.getUID())) {
|
||||||
return false;
|
return false;
|
||||||
@ -133,7 +133,7 @@ public class PerWorldSettingsService {
|
|||||||
* Whether the given {@link SlimefunItem} should be enabled in that world
|
* Whether the given {@link SlimefunItem} should be enabled in that world
|
||||||
*/
|
*/
|
||||||
public void setEnabled(World world, SlimefunItem item, boolean enabled) {
|
public void setEnabled(World world, SlimefunItem item, boolean enabled) {
|
||||||
Set<String> items = disabledItems.computeIfAbsent(world.getName(), name -> loadWorldFromConfig(world));
|
Set<String> items = disabledItems.computeIfAbsent(world.getUID(), id -> loadWorldFromConfig(world));
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
items.remove(item.getID());
|
items.remove(item.getID());
|
||||||
@ -199,7 +199,7 @@ public class PerWorldSettingsService {
|
|||||||
* The {@link World} to save
|
* The {@link World} to save
|
||||||
*/
|
*/
|
||||||
public void save(World world) {
|
public void save(World world) {
|
||||||
Set<String> items = disabledItems.computeIfAbsent(world.getName(), name -> loadWorldFromConfig(world));
|
Set<String> items = disabledItems.computeIfAbsent(world.getUID(), id -> loadWorldFromConfig(world));
|
||||||
|
|
||||||
Config config = new Config(plugin, "world-settings/" + world + ".yml");
|
Config config = new Config(plugin, "world-settings/" + world + ".yml");
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ public class PerWorldSettingsService {
|
|||||||
|
|
||||||
private Set<String> loadWorldFromConfig(World world) {
|
private Set<String> loadWorldFromConfig(World world) {
|
||||||
String name = world.getName();
|
String name = world.getName();
|
||||||
Optional<Set<String>> optional = disabledItems.get(name);
|
Optional<Set<String>> optional = disabledItems.get(world.getUID());
|
||||||
|
|
||||||
if (optional.isPresent()) {
|
if (optional.isPresent()) {
|
||||||
return optional.get();
|
return optional.get();
|
||||||
|
Loading…
Reference in New Issue
Block a user