Skip to content

Commit

Permalink
feat: minion overhaul
Browse files Browse the repository at this point in the history
Took 5 hours 8 minutes
  • Loading branch information
Swofty-Developments committed Oct 1, 2024
1 parent 1ec18c6 commit e0af1e0
Show file tree
Hide file tree
Showing 81 changed files with 1,029 additions and 239 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.Setter;
import net.minestom.server.timer.Scheduler;
import net.minestom.server.timer.TaskSchedule;
import net.swofty.types.generic.command.commands.MinionGenerationCommand;

import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -108,6 +109,11 @@ public static String getDisplay(long elapsed) {
hours = hours > 12 ? hours - 12 : (hours == 0 ? 12 : hours);

String symbol = isDaytime ? "§e" + DAY_SYMBOL : "§b" + NIGHT_SYMBOL;
return String.format("%d:%s%s %s", hours, formattedMinutes, timePeriod, symbol);
String message = String.format("%d:%s%s %s", hours, formattedMinutes, timePeriod, symbol);

if (MinionGenerationCommand.divisionFactor != 1) {
message += " §c(Minion Speed: " + MinionGenerationCommand.divisionFactor + ")";
}
return message;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,9 @@ public void registerUsage(MinestomCommand command) {
UUID realUUID = player.getUuid();
UUID crackedUUID = UUID.nameUUIDFromBytes((STR."OfflinePlayer:\{player.getName()}").getBytes(StandardCharsets.UTF_8));

player.getSkyBlockExperience().addExperience(
SkyBlockLevelCause.getMuseumCause(MuseumRewards.REWARD_3)
);


List<UUID> adminUUIDs = new ArrayList<>();
ADMIN_LIST.forEach(admin -> adminUUIDs.add(UUID.nameUUIDFromBytes((STR."OfflinePlayer:\{admin}").getBytes(StandardCharsets.UTF_8))));
ADMIN_LIST.forEach(admin -> {
ADMIN_LIST.parallelStream().forEach(admin -> {
try {
adminUUIDs.add(MojangUtils.getUUID(admin));
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package net.swofty.types.generic.command.commands;

import net.minestom.server.command.builder.arguments.ArgumentEnum;
import net.swofty.types.generic.command.CommandParameters;
import net.swofty.types.generic.command.SkyBlockCommand;
import net.swofty.types.generic.user.categories.Rank;

@CommandParameters(aliases = "handleminionspeed",
description = "Handle minion speed",
usage = "/handleminionspeed",
permission = Rank.ADMIN,
allowsConsole = false)
public class MinionGenerationCommand extends SkyBlockCommand {
public static int divisionFactor = 1;

@Override
public void registerUsage(MinestomCommand command) {
ArgumentEnum<Speed> argument = new ArgumentEnum<>("speed", Speed.class);
command.addSyntax((sender, context) -> {
if (!permissionCheck(sender)) return;
Speed speed = context.get(argument);

switch (speed) {
case MULTIPLY_2:
divisionFactor = 2;
break;
case MULTIPLY_5:
divisionFactor = 5;
break;
case MULTIPLY_10:
divisionFactor = 10;
break;
case NORMAL:
divisionFactor = 1;
break;
}

sender.sendMessage("§aSuccessfully set minion speed to §c" + speed.name().toLowerCase());
}, argument);
}

enum Speed {
MULTIPLY_2,
MULTIPLY_5,
MULTIPLY_10,
NORMAL
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import lombok.Getter;
import net.minestom.server.entity.EntityType;
import net.swofty.types.generic.entity.mob.impl.RegionPopulator;
import net.swofty.types.generic.entity.mob.mobs.MobSheep;
import net.swofty.types.generic.entity.mob.mobs.*;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
Expand All @@ -12,8 +12,12 @@

@Getter
public class MobRegistry {
private static List<MobRegistry> REGISTERED_MOBS = new ArrayList<>(Arrays.asList(
new MobRegistry(EntityType.SHEEP, MobSheep.class)
private static final List<MobRegistry> REGISTERED_MOBS = new ArrayList<>(Arrays.asList(
new MobRegistry(EntityType.SHEEP, MobSheep.class),
new MobRegistry(EntityType.ZOMBIE, MobZombie.class),
new MobRegistry(EntityType.CHICKEN, MobChicken.class),
new MobRegistry(EntityType.PIG, MobPig.class),
new MobRegistry(EntityType.RABBIT, MobRabbit.class)
));

private final EntityType entityType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.swofty.types.generic.entity.mob;

import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.sound.Sound;
Expand Down Expand Up @@ -33,6 +34,7 @@
import net.swofty.types.generic.user.SkyBlockPlayer;
import net.swofty.commons.statistics.ItemStatistic;
import net.swofty.commons.statistics.ItemStatistics;
import net.swofty.types.generic.utility.MathUtility;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -209,4 +211,14 @@ public void tick(long time) {
// Suppress odd warnings
}
}

public static @NonNull List<SkyBlockMob> getMobFromFuzzyPosition(Pos position) {
List<SkyBlockMob> mobs = new ArrayList<>();
for (SkyBlockMob mob : getMobs()) {
if (MathUtility.isWithinSameBlock(mob.getPosition(), position)) {
mobs.add(mob);
}
}
return mobs;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package net.swofty.types.generic.entity.mob.mobs;

import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.ai.GoalSelector;
import net.minestom.server.entity.ai.TargetSelector;
import net.minestom.server.entity.ai.goal.RandomStrollGoal;
import net.swofty.commons.statistics.ItemStatistic;
import net.swofty.commons.statistics.ItemStatistics;
import net.swofty.types.generic.entity.mob.SkyBlockMob;
import net.swofty.types.generic.loottable.SkyBlockLootTable;
import net.swofty.types.generic.skill.SkillCategories;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;

public class MobChicken extends SkyBlockMob {
public MobChicken(EntityType entityType) {
super(entityType);
}

@Override
public String getDisplayName() {
return "Chicken";
}

@Override
public Integer getLevel() {
return 1;
}

@Override
public List<GoalSelector> getGoalSelectors() {
return List.of(
new RandomStrollGoal(this, 15)
);
}

@Override
public List<TargetSelector> getTargetSelectors() {
return new ArrayList<>();
}

@Override
public ItemStatistics getBaseStatistics() {
return ItemStatistics.builder()
.withBase(ItemStatistic.HEALTH, 20D)
.withBase(ItemStatistic.SPEED, 70D)
.build();
}

@Override
public @Nullable SkyBlockLootTable getLootTable() {
return null;
}

@Override
public SkillCategories getSkillCategory() {
return SkillCategories.FARMING;
}

@Override
public long damageCooldown() {
return 200;
}

@Override
public long getSkillXP() {
return 4;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package net.swofty.types.generic.entity.mob.mobs;

import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.ai.GoalSelector;
import net.minestom.server.entity.ai.TargetSelector;
import net.minestom.server.entity.ai.goal.RandomStrollGoal;
import net.swofty.commons.statistics.ItemStatistic;
import net.swofty.commons.statistics.ItemStatistics;
import net.swofty.types.generic.entity.mob.SkyBlockMob;
import net.swofty.types.generic.loottable.SkyBlockLootTable;
import net.swofty.types.generic.skill.SkillCategories;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;

public class MobCow extends SkyBlockMob {
public MobCow(EntityType entityType) {
super(entityType);
}

@Override
public String getDisplayName() {
return "Cow";
}

@Override
public Integer getLevel() {
return 1;
}

@Override
public List<GoalSelector> getGoalSelectors() {
return List.of(
new RandomStrollGoal(this, 15)
);
}

@Override
public List<TargetSelector> getTargetSelectors() {
return new ArrayList<>();
}

@Override
public ItemStatistics getBaseStatistics() {
return ItemStatistics.builder()
.withBase(ItemStatistic.HEALTH, 100D)
.withBase(ItemStatistic.SPEED, 70D)
.build();
}

@Override
public @Nullable SkyBlockLootTable getLootTable() {
return null;
}

@Override
public SkillCategories getSkillCategory() {
return SkillCategories.FARMING;
}

@Override
public long damageCooldown() {
return 200;
}

@Override
public long getSkillXP() {
return 4;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package net.swofty.types.generic.entity.mob.mobs;

import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.ai.GoalSelector;
import net.minestom.server.entity.ai.TargetSelector;
import net.minestom.server.entity.ai.goal.RandomStrollGoal;
import net.swofty.commons.statistics.ItemStatistic;
import net.swofty.commons.statistics.ItemStatistics;
import net.swofty.types.generic.entity.mob.SkyBlockMob;
import net.swofty.types.generic.loottable.SkyBlockLootTable;
import net.swofty.types.generic.skill.SkillCategories;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;

public class MobPig extends SkyBlockMob {
public MobPig(EntityType entityType) {
super(entityType);
}

@Override
public String getDisplayName() {
return "Pig";
}

@Override
public Integer getLevel() {
return 1;
}

@Override
public List<GoalSelector> getGoalSelectors() {
return List.of(
new RandomStrollGoal(this, 15)
);
}

@Override
public List<TargetSelector> getTargetSelectors() {
return new ArrayList<>();
}

@Override
public ItemStatistics getBaseStatistics() {
return ItemStatistics.builder()
.withBase(ItemStatistic.HEALTH, 20D)
.withBase(ItemStatistic.SPEED, 70D)
.build();
}

@Override
public @Nullable SkyBlockLootTable getLootTable() {
return null;
}

@Override
public SkillCategories getSkillCategory() {
return SkillCategories.FARMING;
}

@Override
public long damageCooldown() {
return 200;
}

@Override
public long getSkillXP() {
return 4;
}
}
Loading

0 comments on commit e0af1e0

Please sign in to comment.