Skip to content

Commit

Permalink
Add Proximity Effects Mutation (#50)
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher White <[email protected]>
  • Loading branch information
cswhite2000 authored Oct 22, 2023
1 parent fc2cd5a commit af85a42
Show file tree
Hide file tree
Showing 14 changed files with 296 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/main/java/dev/pgm/community/mutations/Mutation.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static net.kyori.adventure.text.Component.text;

import dev.pgm.community.mutations.options.MutationOption;
import java.util.Collection;
import java.util.Set;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.HoverEvent;
Expand Down Expand Up @@ -38,7 +39,7 @@ public interface Mutation {
*
* @return a set of {@link MutationOption}
*/
Set<MutationOption> getOptions();
Collection<MutationOption> getOptions();

/**
* Gets whether it is safe to enable current mutation Ex. If map is rage, don't allow rage
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/dev/pgm/community/mutations/MutationBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.google.common.collect.Sets;
import dev.pgm.community.Community;
import dev.pgm.community.mutations.options.MutationOption;
import java.util.Set;
import java.util.Collection;
import javax.annotation.Nullable;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
Expand Down Expand Up @@ -43,7 +43,7 @@ public void disable() {
}

@Override
public Set<MutationOption> getOptions() {
public Collection<MutationOption> getOptions() {
return Sets.newHashSet();
}

Expand Down
6 changes: 5 additions & 1 deletion src/main/java/dev/pgm/community/mutations/MutationType.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ public enum MutationType {
FIREBALL_BOW("Fireball Bow", "All projectiles are fireballs", Material.FIREBALL),
CANNON_SUPPLIES("Cannon Supplies", "Supplies for making TNT cannons", Material.REDSTONE),
GRAPPLING_HOOK("Grappling Hook", "Everyone can use a grappling hook", Material.FISHING_ROD),
NO_SPAWN_KIT("No Spawn Kit", "No Spawn Kits!", Material.BARRIER);
NO_SPAWN_KIT("No Spawn Kit", "No Spawn Kits!", Material.BARRIER),
PROXIMITY_EFFECT(
"Proximity Effects",
"Give potion effects based on distance to Objectives",
Material.GLASS_BOTTLE);

String displayName;
String description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import dev.pgm.community.mutations.types.items.GrapplingHookMutation;
import dev.pgm.community.mutations.types.items.NoSpawnKitMutation;
import dev.pgm.community.mutations.types.items.PotionMutation;
import dev.pgm.community.mutations.types.mapdev.ProximityEffectsMutation;
import dev.pgm.community.mutations.types.mechanics.BlindMutation;
import dev.pgm.community.mutations.types.mechanics.DoubleJumpMutation;
import dev.pgm.community.mutations.types.mechanics.FlyMutation;
Expand Down Expand Up @@ -206,6 +207,8 @@ private Mutation getNewMutation(MutationType type) {
return new GrapplingHookMutation(getMatch());
case NO_SPAWN_KIT:
return new NoSpawnKitMutation(getMatch());
case PROXIMITY_EFFECT:
return new ProximityEffectsMutation(getMatch());
default:
logger.warning(type.getDisplayName() + " has not been implemented yet");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static tc.oc.pgm.util.bukkit.BukkitUtils.colorize;

import dev.pgm.community.mutations.Mutation;
import dev.pgm.community.mutations.feature.MutationFeature;
import dev.pgm.community.mutations.options.MutationBooleanOption;
import dev.pgm.community.mutations.options.MutationListOption;
Expand Down Expand Up @@ -41,7 +42,7 @@ private void render(Player player, InventoryContents contents) {

List<MutationOption> options =
mutations.getMutations().stream()
.map(mt -> mt.getOptions())
.map(Mutation::getOptions)
.flatMap(mo -> mo.stream())
.collect(Collectors.toList());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import dev.pgm.community.mutations.options.MutationRangeOption;
import dev.pgm.community.mutations.types.BowMutation;
import dev.pgm.community.mutations.types.KitMutationBase;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
Expand Down Expand Up @@ -52,7 +53,7 @@ public WebSlingersMutation(Match match) {
}

@Override
public Set<MutationOption> getOptions() {
public Collection<MutationOption> getOptions() {
return Sets.newHashSet(WEB_LIFE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import dev.pgm.community.mutations.MutationType;
import dev.pgm.community.mutations.options.MutationOption;
import dev.pgm.community.mutations.options.MutationRangeOption;
import java.util.Collection;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.event.HandlerList;
Expand All @@ -29,7 +30,7 @@ public BlitzMutation(Match match) {
}

@Override
public Set<MutationOption> getOptions() {
public Collection<MutationOption> getOptions() {
return Sets.newHashSet(BLITZ_LIVES);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import dev.pgm.community.mutations.options.MutationOption;
import dev.pgm.community.mutations.options.MutationRangeOption;
import dev.pgm.community.mutations.types.KitMutationBase;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Random;
Expand Down Expand Up @@ -108,7 +109,7 @@ public ExplosionMutation(Match match) {
}

@Override
public Set<MutationOption> getOptions() {
public Collection<MutationOption> getOptions() {
return Sets.newHashSet(FIREBALL_POWER, FIREBALL_FIRE, LAUNCH_COOLDOWN, MYSTERY_TNT, TNT_SIZE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import dev.pgm.community.mutations.MutationType;
import dev.pgm.community.mutations.options.MutationBooleanOption;
import dev.pgm.community.mutations.options.MutationOption;
import java.util.Collection;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
Expand Down Expand Up @@ -37,7 +38,7 @@ public NoSpawnKitMutation(Match match) {
}

@Override
public Set<MutationOption> getOptions() {
public Collection<MutationOption> getOptions() {
return Sets.newHashSet(CLEAR_ITEMS_OPTION, CLEAR_ARMOR_OPTION, CLEAR_EFFECTS_OPTION);
}

Expand Down
Loading

0 comments on commit af85a42

Please sign in to comment.