Skip to content

Commit

Permalink
fix bugs related to immutability
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Nov 3, 2024
1 parent e22dd8f commit fb56629
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ public DeathSoundEffects() {
}
})
.filter(Objects::nonNull)
.collect(Collectors.collectingAndThen(Collectors.toList(), ImmutableList::copyOf));
if (this.death_sounds.isEmpty()) {
this.death_sounds.addAll(defaults.stream().map(Sound::valueOf).collect(Collectors.toList()));
}
.collect(Collectors.collectingAndThen(Collectors.toList(), list -> {
if (list.isEmpty())
list.addAll(defaults.stream().map(Sound::valueOf).collect(Collectors.toList()));
return ImmutableList.copyOf(list);
}));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ public ExplodeSoundEffects() {
}
})
.filter(Objects::nonNull)
.collect(Collectors.collectingAndThen(Collectors.toList(), ImmutableList::copyOf));
if (this.explode_sounds.isEmpty()) {
this.explode_sounds.addAll(defaults.stream().map(Sound::valueOf).collect(Collectors.toList()));
}
.collect(Collectors.collectingAndThen(Collectors.toList(), list -> {
if (list.isEmpty())
list.addAll(defaults.stream().map(Sound::valueOf).collect(Collectors.toList()));
return ImmutableList.copyOf(list);
}));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.xginko.pumpkinpvpreloaded.modules.effects;

import com.google.common.collect.ImmutableList;
import me.xginko.pumpkinpvpreloaded.PumpkinPVPReloaded;
import me.xginko.pumpkinpvpreloaded.events.PostPumpkinExplodeEvent;
import me.xginko.pumpkinpvpreloaded.events.PostPumpkinHeadEntityExplodeEvent;
Expand Down Expand Up @@ -102,7 +103,7 @@ public FireworkEffects() {
}
}

this.firework_effects = parsedFireworkEffects.stream().distinct().collect(Collectors.toList());
this.firework_effects = ImmutableList.copyOf(parsedFireworkEffects);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.xginko.pumpkinpvpreloaded.modules.mechanics;

import com.google.common.collect.ImmutableSet;
import me.xginko.pumpkinpvpreloaded.events.PrePumpkinExplodeEvent;
import me.xginko.pumpkinpvpreloaded.modules.PumpkinPVPModule;
import org.bukkit.event.EventHandler;
Expand All @@ -9,7 +10,6 @@
import org.jetbrains.annotations.NotNull;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class EnablePerWorld extends PumpkinPVPModule implements Listener {
Expand All @@ -22,7 +22,7 @@ public EnablePerWorld() {
"Add the names of the worlds you want this plugins features to be enabled in.");
this.blacklist_mode = config.getBoolean(configPath + ".use-as-blacklist", false,
"Make it so that the plugin's features are disabled in the listed worlds.");
this.active_worlds = new HashSet<>(config.getList(configPath + ".worlds",
this.active_worlds = ImmutableSet.copyOf(config.getList(configPath + ".worlds",
Arrays.asList("world", "world_nether", "world_the_end")));
}

Expand Down

0 comments on commit fb56629

Please sign in to comment.