new version 1.3.3
This commit is contained in:
parent
2d5c5eea48
commit
d9eb747c1b
37 changed files with 1021 additions and 471 deletions
|
|
@ -43,7 +43,7 @@ public class CoopMode implements Mode {
|
|||
@Override
|
||||
public void create(Player player) {
|
||||
if (!Config.CONFIG.getBoolean("joining")) {
|
||||
player.sendMessage("§cJoining is currently disabled.");
|
||||
player.sendMessage(Locales.getString(player, "other.joining_disabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -66,6 +66,8 @@ public class CoopMode implements Mode {
|
|||
// Initialize contributions
|
||||
for (ParkourPlayer pp : session.getPlayers()) {
|
||||
playerContributions.put(pp.getUUID(), 0);
|
||||
pp.player.sendTitle("§a§lCOOP MODE", "§7Work together for a shared score!", 10, 70, 20);
|
||||
pp.player.sendMessage("§a§lCoop Mode §7activated! Team score is shared.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,11 @@ import dev.loki.loparkour.util.Item;
|
|||
import dev.loki.loparkour.config.Config;
|
||||
import dev.loki.loparkour.config.Locales;
|
||||
import dev.loki.loparkour.generator.ParkourGenerator;
|
||||
import dev.loki.loparkour.ghost.GhostManager;
|
||||
import dev.loki.loparkour.ghost.GhostRecorder;
|
||||
import dev.loki.loparkour.leaderboard.Leaderboard;
|
||||
import dev.loki.loparkour.player.ParkourPlayer;
|
||||
import dev.loki.loparkour.player.ParkourSpectator;
|
||||
import dev.loki.loparkour.session.Session;
|
||||
|
||||
import org.bukkit.*;
|
||||
|
|
@ -17,6 +20,7 @@ import org.bukkit.util.Vector;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
|
|
@ -47,7 +51,7 @@ public class ElytraMode implements Mode {
|
|||
@Override
|
||||
public void create(Player player) {
|
||||
if (!Config.CONFIG.getBoolean("joining")) {
|
||||
player.sendMessage("§cJoining is currently disabled.");
|
||||
player.sendMessage(Locales.getString(player, "other.joining_disabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -81,18 +85,30 @@ public class ElytraMode implements Mode {
|
|||
p.getInventory().addItem(new ItemStack(Material.FIREWORK_ROCKET, fireworks));
|
||||
|
||||
ringsCollected.put(p.getUniqueId(), 0);
|
||||
|
||||
// Notify player
|
||||
p.sendTitle("§b§lELYTRA MODE", "§7Fly through rings for bonus points!", 10, 70, 20);
|
||||
p.sendMessage("§b§lElytra Mode §7activated! Use fireworks to boost.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
// Don't call super.tick() - we don't want normal block generation
|
||||
tickCounter++;
|
||||
|
||||
// Spawn rings every 5 blocks
|
||||
if (tickCounter % 100 == 0 && !state.history.isEmpty()) {
|
||||
Location ringLoc = getLatest().getLocation().clone().add(0, 3, 0);
|
||||
rings.add(new RingCheckpoint(ringLoc));
|
||||
// Update spectators
|
||||
getSpectators().forEach(ParkourSpectator::update);
|
||||
|
||||
// Check for fall (much lower threshold for elytra)
|
||||
if (player.getLocation().getY() < state.lastStandingPlayerLocation.getY() - 50) {
|
||||
lifecycle.fall();
|
||||
return;
|
||||
}
|
||||
|
||||
// Spawn rings every 2 seconds
|
||||
if (tickCounter % 40 == 0) {
|
||||
spawnNextRing();
|
||||
}
|
||||
|
||||
// Display rings and check for player passing through
|
||||
|
|
@ -116,20 +132,40 @@ public class ElytraMode implements Mode {
|
|||
// Bonus points for passing through ring
|
||||
lifecycle.score();
|
||||
lifecycle.score();
|
||||
lifecycle.score(); // 3 points per ring
|
||||
|
||||
pp.player.playSound(pp.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1f, 1.5f);
|
||||
pp.player.spawnParticle(Particle.TOTEM, ring.location, 20, 0.5, 0.5, 0.5, 0.1);
|
||||
|
||||
// Update last standing location to ring location
|
||||
state.lastStandingPlayerLocation = ring.location.clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Remove old rings
|
||||
if (ring.location.distance(player.getLocation()) > 50) {
|
||||
if (ring.location.distance(player.getLocation()) > 100) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
// Check firework cooldown
|
||||
checkFireworkCooldown();
|
||||
|
||||
// Start timer if not started
|
||||
if (state.start == null) state.start = Instant.now();
|
||||
}
|
||||
|
||||
private void spawnNextRing() {
|
||||
Location playerLoc = player.getLocation();
|
||||
|
||||
// Spawn ring ahead of player in flight direction
|
||||
Vector direction = player.getLocation().getDirection();
|
||||
Location ringLoc = playerLoc.clone().add(direction.multiply(20)).add(0, 5, 0);
|
||||
|
||||
// Add some randomness
|
||||
ringLoc.add((Math.random() - 0.5) * 10, (Math.random() - 0.5) * 5, (Math.random() - 0.5) * 10);
|
||||
|
||||
rings.add(new RingCheckpoint(ringLoc));
|
||||
}
|
||||
|
||||
private void displayRing(Location center) {
|
||||
|
|
|
|||
|
|
@ -1,180 +0,0 @@
|
|||
package dev.loki.loparkour.mode;
|
||||
|
||||
import dev.loki.loparkour.util.Item;
|
||||
|
||||
import dev.loki.loparkour.config.Config;
|
||||
import dev.loki.loparkour.config.Locales;
|
||||
import dev.loki.loparkour.generator.ParkourGenerator;
|
||||
import dev.loki.loparkour.leaderboard.Leaderboard;
|
||||
import dev.loki.loparkour.player.ParkourPlayer;
|
||||
import dev.loki.loparkour.session.Session;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class GravityShiftMode implements Mode {
|
||||
|
||||
private final Leaderboard leaderboard = new Leaderboard(getName(), Leaderboard.Sort.SCORE);
|
||||
private final Random random = new Random();
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "gravity-shift";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public dev.loki.loparkour.util.Item getItem(String locale) {
|
||||
return Locales.getItem(locale, "play.single.gravity-shift");
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Leaderboard getLeaderboard() {
|
||||
return leaderboard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(Player player) {
|
||||
if (!Config.CONFIG.getBoolean("joining")) {
|
||||
player.sendMessage("Joining is currently disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
ParkourPlayer pp = ParkourPlayer.getPlayer(player);
|
||||
if (pp != null && pp.session.generator != null && pp.session.generator.getMode() instanceof GravityShiftMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.closeInventory();
|
||||
|
||||
Session.create(session -> new GravityShiftGenerator(session), null, null, player);
|
||||
}
|
||||
|
||||
private static class GravityShiftGenerator extends ParkourGenerator {
|
||||
private int jumpsUntilShift;
|
||||
private final int shiftInterval;
|
||||
private PotionEffect currentEffect;
|
||||
|
||||
public GravityShiftGenerator(@NotNull Session session) {
|
||||
super(session);
|
||||
this.shiftInterval = Config.CONFIG.getInt("modes.gravity-shift.interval");
|
||||
this.jumpsUntilShift = shiftInterval;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void score() {
|
||||
super.score();
|
||||
|
||||
jumpsUntilShift--;
|
||||
|
||||
if (jumpsUntilShift <= 0) {
|
||||
applyRandomEffect();
|
||||
jumpsUntilShift = shiftInterval;
|
||||
}
|
||||
}
|
||||
|
||||
private void applyRandomEffect() {
|
||||
if (currentEffect != null) {
|
||||
player.player.removePotionEffect(currentEffect.getType());
|
||||
}
|
||||
|
||||
List<EffectData> effects = new ArrayList<>();
|
||||
|
||||
if (Config.CONFIG.getBoolean("modes.gravity-shift.effects.jump-boost.enabled")) {
|
||||
effects.add(new EffectData(
|
||||
PotionEffectType.JUMP,
|
||||
Config.CONFIG.getInt("modes.gravity-shift.effects.jump-boost.amplifier"),
|
||||
Config.CONFIG.getInt("modes.gravity-shift.effects.jump-boost.duration"),
|
||||
"Jump Boost"
|
||||
));
|
||||
}
|
||||
|
||||
if (Config.CONFIG.getBoolean("modes.gravity-shift.effects.speed.enabled")) {
|
||||
effects.add(new EffectData(
|
||||
PotionEffectType.SPEED,
|
||||
Config.CONFIG.getInt("modes.gravity-shift.effects.speed.amplifier"),
|
||||
Config.CONFIG.getInt("modes.gravity-shift.effects.speed.duration"),
|
||||
"Speed"
|
||||
));
|
||||
}
|
||||
|
||||
if (Config.CONFIG.getBoolean("modes.gravity-shift.effects.slowness.enabled")) {
|
||||
effects.add(new EffectData(
|
||||
PotionEffectType.SLOW,
|
||||
Config.CONFIG.getInt("modes.gravity-shift.effects.slowness.amplifier"),
|
||||
Config.CONFIG.getInt("modes.gravity-shift.effects.slowness.duration"),
|
||||
"Slowness"
|
||||
));
|
||||
}
|
||||
|
||||
if (Config.CONFIG.getBoolean("modes.gravity-shift.effects.levitation.enabled")) {
|
||||
effects.add(new EffectData(
|
||||
PotionEffectType.LEVITATION,
|
||||
Config.CONFIG.getInt("modes.gravity-shift.effects.levitation.amplifier"),
|
||||
Config.CONFIG.getInt("modes.gravity-shift.effects.levitation.duration"),
|
||||
"Levitation"
|
||||
));
|
||||
}
|
||||
|
||||
if (effects.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
EffectData selected = effects.get(new Random().nextInt(effects.size()));
|
||||
currentEffect = new PotionEffect(
|
||||
selected.type,
|
||||
selected.duration * 20,
|
||||
selected.amplifier - 1,
|
||||
false,
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
player.player.addPotionEffect(currentEffect);
|
||||
|
||||
// Visual feedback
|
||||
player.player.sendTitle("§6⚡", "§e" + selected.name, 5, 20, 10);
|
||||
player.player.playSound(player.player.getLocation(), org.bukkit.Sound.ENTITY_ENDERMAN_TELEPORT, 1.0f, 1.5f);
|
||||
player.player.spawnParticle(org.bukkit.Particle.PORTAL, player.player.getLocation().add(0, 1, 0), 50, 0.5, 0.5, 0.5, 0.5);
|
||||
|
||||
player.sendTranslated("modes.gravity-shift.effect-applied", selected.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset(boolean regenerate) {
|
||||
if (currentEffect != null && player != null && player.player != null) {
|
||||
player.player.removePotionEffect(currentEffect.getType());
|
||||
}
|
||||
jumpsUntilShift = shiftInterval;
|
||||
super.reset(regenerate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mode getMode() {
|
||||
return Modes.GRAVITY_SHIFT;
|
||||
}
|
||||
}
|
||||
|
||||
private static class EffectData {
|
||||
final PotionEffectType type;
|
||||
final int amplifier;
|
||||
final int duration;
|
||||
final String name;
|
||||
|
||||
EffectData(PotionEffectType type, int amplifier, int duration, String name) {
|
||||
this.type = type;
|
||||
this.amplifier = amplifier;
|
||||
this.duration = duration;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
package dev.loki.loparkour.mode;
|
||||
|
||||
import dev.loki.loparkour.util.Item;
|
||||
|
||||
import dev.loki.loparkour.config.Config;
|
||||
import dev.loki.loparkour.config.Locales;
|
||||
import dev.loki.loparkour.generator.ParkourGenerator;
|
||||
import dev.loki.loparkour.leaderboard.Leaderboard;
|
||||
import dev.loki.loparkour.player.ParkourPlayer;
|
||||
import dev.loki.loparkour.session.Session;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class HardcoreMode implements Mode {
|
||||
|
||||
private final Leaderboard leaderboard = new Leaderboard(getName(), Leaderboard.Sort.SCORE);
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "hardcore";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public dev.loki.loparkour.util.Item getItem(String locale) {
|
||||
return Locales.getItem(locale, "play.single.hardcore");
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Leaderboard getLeaderboard() {
|
||||
return leaderboard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(Player player) {
|
||||
if (!Config.CONFIG.getBoolean("joining")) {
|
||||
player.sendMessage("Joining is currently disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
ParkourPlayer pp = ParkourPlayer.getPlayer(player);
|
||||
if (pp != null && pp.session.generator != null && pp.session.generator.getMode() instanceof HardcoreMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.closeInventory();
|
||||
|
||||
Session.create(session -> new HardcoreGenerator(session), null, null, player);
|
||||
}
|
||||
|
||||
private static class HardcoreGenerator extends ParkourGenerator {
|
||||
|
||||
public HardcoreGenerator(@NotNull Session session) {
|
||||
super(session);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fall() {
|
||||
boolean resetRewards = Config.CONFIG.getBoolean("modes.hardcore.reset-rewards");
|
||||
|
||||
if (resetRewards) {
|
||||
player.collectedRewards.clear();
|
||||
player.sendTranslated("modes.hardcore.rewards-lost");
|
||||
}
|
||||
|
||||
player.sendTranslated("modes.hardcore.full-reset");
|
||||
|
||||
super.fall();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mode getMode() {
|
||||
return Modes.HARDCORE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,8 +7,6 @@ public class Modes {
|
|||
public static DefaultMode DEFAULT;
|
||||
public static SpectatorMode SPECTATOR;
|
||||
public static SpeedrunMode SPEEDRUN;
|
||||
public static GravityShiftMode GRAVITY_SHIFT;
|
||||
public static HardcoreMode HARDCORE;
|
||||
public static ElytraMode ELYTRA;
|
||||
public static RaceMode RACE;
|
||||
public static CoopMode COOP;
|
||||
|
|
@ -17,8 +15,6 @@ public class Modes {
|
|||
DEFAULT = (DefaultMode) Registry.getMode("default");
|
||||
SPECTATOR = (SpectatorMode) Registry.getMode("spectator");
|
||||
SPEEDRUN = (SpeedrunMode) Registry.getMode("speedrun");
|
||||
GRAVITY_SHIFT = (GravityShiftMode) Registry.getMode("gravity-shift");
|
||||
HARDCORE = (HardcoreMode) Registry.getMode("hardcore");
|
||||
ELYTRA = (ElytraMode) Registry.getMode("elytra");
|
||||
RACE = (RaceMode) Registry.getMode("race");
|
||||
COOP = (CoopMode) Registry.getMode("coop");
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class RaceMode implements Mode {
|
|||
@Override
|
||||
public void create(Player player) {
|
||||
if (!Config.CONFIG.getBoolean("joining")) {
|
||||
player.sendMessage("§cJoining is currently disabled.");
|
||||
player.sendMessage(Locales.getString(player, "other.joining_disabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -59,6 +59,12 @@ public class RaceMode implements Mode {
|
|||
public RaceGenerator(@NotNull Session session) {
|
||||
super(session);
|
||||
this.targetScore = Config.CONFIG.getInt("modes.race.target-score");
|
||||
|
||||
// Notify players
|
||||
for (ParkourPlayer pp : session.getPlayers()) {
|
||||
pp.player.sendTitle("§6§lRACE MODE", "§7First to " + targetScore + " points wins!", 10, 70, 20);
|
||||
pp.player.sendMessage("§6§lRace Mode §7activated! Target: §e" + targetScore + " §7points.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -63,12 +63,18 @@ public class SpeedrunMode implements Mode {
|
|||
Session.create(session -> new SpeedrunGenerator(session), null, null, player);
|
||||
}
|
||||
|
||||
private static class SpeedrunGenerator extends ParkourGenerator {
|
||||
public static class SpeedrunGenerator extends ParkourGenerator {
|
||||
private final Map<Block, Long> blockTimestamps = new HashMap<>();
|
||||
private final Map<Block, ScheduledTask> scheduledTasks = new HashMap<>();
|
||||
|
||||
public SpeedrunGenerator(@NotNull Session session) {
|
||||
super(session);
|
||||
|
||||
// Notify player
|
||||
for (ParkourPlayer pp : session.getPlayers()) {
|
||||
pp.player.sendTitle("§c§lSPEEDRUN MODE", "§7Blocks disappear after you step on them!", 10, 70, 20);
|
||||
pp.player.sendMessage("§c§lSpeedrun Mode §7activated! Don't look back!");
|
||||
}
|
||||
}
|
||||
|
||||
public void onBlockTouch(@NotNull Block block) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue