diff --git a/src/main/java/com/sk89q/worldguard/bukkit/BukkitPlayer.java b/src/main/java/com/sk89q/worldguard/bukkit/BukkitPlayer.java index 416317b6..07c96337 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/BukkitPlayer.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/BukkitPlayer.java @@ -33,18 +33,21 @@ public class BukkitPlayer extends LocalPlayer { private final WorldGuardPlugin plugin; private final Player player; - + private final String name; + public BukkitPlayer(WorldGuardPlugin plugin, Player player) { checkNotNull(plugin); checkNotNull(player); this.plugin = plugin; this.player = player; + // getName() takes longer than before in newer versions of Minecraft + this.name = player.getName(); } @Override public String getName() { - return player.getName(); + return name; } @Override diff --git a/src/main/java/com/sk89q/worldguard/protection/ApplicableRegionSet.java b/src/main/java/com/sk89q/worldguard/protection/ApplicableRegionSet.java index 6f6d9b7d..7b9e61cd 100644 --- a/src/main/java/com/sk89q/worldguard/protection/ApplicableRegionSet.java +++ b/src/main/java/com/sk89q/worldguard/protection/ApplicableRegionSet.java @@ -19,7 +19,6 @@ package com.sk89q.worldguard.protection; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.ObjectArrays; import com.sk89q.worldguard.LocalPlayer; import com.sk89q.worldguard.protection.association.RegionAssociable; @@ -35,6 +34,7 @@ import javax.annotation.Nullable; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; @@ -346,7 +346,7 @@ public int size() { * @return a set of regions */ public Set getRegions() { - return ImmutableSet.copyOf(applicable); + return new HashSet(applicable); } @Override diff --git a/src/main/java/com/sk89q/worldguard/protection/FlagValueCalculator.java b/src/main/java/com/sk89q/worldguard/protection/FlagValueCalculator.java index 660313c7..0a0e5dad 100644 --- a/src/main/java/com/sk89q/worldguard/protection/FlagValueCalculator.java +++ b/src/main/java/com/sk89q/worldguard/protection/FlagValueCalculator.java @@ -31,6 +31,7 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion; import javax.annotation.Nullable; +import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -55,6 +56,7 @@ public class FlagValueCalculator { private final List regions; @Nullable private final ProtectedRegion globalRegion; + private final Iterable applicable; /** * Create a new instance. @@ -67,6 +69,12 @@ public FlagValueCalculator(List regions, @Nullable ProtectedReg this.regions = regions; this.globalRegion = globalRegion; + + if (globalRegion != null) { + applicable = Iterables.concat(regions, Arrays.asList(globalRegion)); + } else { + applicable = regions; + } } /** @@ -76,11 +84,7 @@ public FlagValueCalculator(List regions, @Nullable ProtectedReg * @return an iterable */ private Iterable getApplicable() { - if (globalRegion != null) { - return Iterables.concat(regions, ImmutableList.of(globalRegion)); - } else { - return regions; - } + return applicable; } /** diff --git a/src/main/java/com/sk89q/worldguard/protection/flags/RegionGroup.java b/src/main/java/com/sk89q/worldguard/protection/flags/RegionGroup.java index b1f1598f..5a06938e 100644 --- a/src/main/java/com/sk89q/worldguard/protection/flags/RegionGroup.java +++ b/src/main/java/com/sk89q/worldguard/protection/flags/RegionGroup.java @@ -19,9 +19,10 @@ package com.sk89q.worldguard.protection.flags; -import com.google.common.collect.ImmutableSet; import com.sk89q.worldguard.domains.Association; +import java.util.Arrays; +import java.util.EnumSet; import java.util.Set; import static com.google.common.base.Preconditions.checkNotNull; @@ -41,7 +42,7 @@ public enum RegionGroup { private final Set contained; RegionGroup(Association... association) { - this.contained = ImmutableSet.copyOf(association); + this.contained = association.length > 0 ? EnumSet.copyOf(Arrays.asList(association)) : EnumSet.noneOf(Association.class); } /**