Skip to content

Commit

Permalink
Merge pull request #133 from Efnilite/dev
Browse files Browse the repository at this point in the history
Merge 5.3.0
  • Loading branch information
Efnilite authored Aug 18, 2024
2 parents 6930ba5 + 9ef21a1 commit b8f4b30
Show file tree
Hide file tree
Showing 22 changed files with 169 additions and 183 deletions.
12 changes: 7 additions & 5 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
**[Infinite Elytra Parkour](https://www.spigotmc.org/resources/115322/) | [Infinite Parkour+](https://www.spigotmc.org/resources/105019/)**

- Running Multiverse with IP now does not require VoidGen
- Improved responsiveness of parkour and scoreboard
- Fixed leaderboards sorting being wrong
- Fixed placeholders returning wrong values
- Fixed vague sorting locale in leaderboard menu
- Added model id support (thanks **[@wilddip](https://github.com/wilddip)**)
- Fixed Chinese translation (thanks **[@jhqwqmc](https://github.com/jhqwqmc)**)
- Fixed MySQL error on score saving
- Fixed being able to take out items in the leaderboard
- Fixed errors on joining spectator
- Fixed errors on leaving
- Fixed heading not working on parkour
15 changes: 2 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>dev.efnilite</groupId>
<artifactId>IP</artifactId>
<version>5.2.4</version>
<version>5.3.0</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
Expand Down Expand Up @@ -89,10 +89,6 @@
<name>Maven Central</name>
<url>https://repo.maven.apache.org/maven2/</url>
</repository>
<repository>
<id>codemc</id>
<url>https://repo.codemc.org/repository/maven-public/</url>
</repository>
</repositories>

<dependencies>
Expand All @@ -106,7 +102,7 @@
<dependency>
<groupId>com.github.Efnilite</groupId>
<artifactId>vilib</artifactId>
<version>e0352344d6</version>
<version>dd786231c3</version>
<scope>compile</scope>
</dependency>

Expand Down Expand Up @@ -158,12 +154,5 @@
<version>5.11.0-M1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>net.skinsrestorer</groupId>
<artifactId>skinsrestorer-api</artifactId>
<version>15.2.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
17 changes: 10 additions & 7 deletions src/main/java/dev/efnilite/ip/Events.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import dev.efnilite.ip.player.ParkourPlayer;
import dev.efnilite.ip.player.ParkourUser;
import dev.efnilite.ip.session.Session;
import dev.efnilite.ip.world.WorldManager;
import dev.efnilite.ip.world.World;
import dev.efnilite.vilib.event.EventWatcher;
import dev.efnilite.vilib.particle.ParticleData;
import dev.efnilite.vilib.particle.Particles;
Expand Down Expand Up @@ -60,7 +60,7 @@ public void chat(AsyncPlayerChatEvent event) {

Session session = user.session;

if (session.muted.contains(user)) {
if (session.isMuted(user)) {
return;
}

Expand All @@ -81,19 +81,19 @@ public void join(PlayerJoinEvent event) {
return;
}

if (!player.getWorld().equals(WorldManager.getWorld())) {
if (!player.getWorld().equals(World.getWorld())) {
return;
}

World fallback = Bukkit.getWorld(Config.CONFIG.getString("world.fall-back"));
org.bukkit.World fallback = Bukkit.getWorld(Config.CONFIG.getString("world.fall-back"));

if (fallback != null) {
PaperLib.teleportAsync(player, fallback.getSpawnLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
return;
}

PaperLib.teleportAsync(player, Bukkit.getWorlds().stream()
.filter(world -> !world.equals(WorldManager.getWorld()))
.filter(world -> !world.equals(World.getWorld()))
.findAny()
.orElseThrow(() -> new NoSuchElementException("No fallback world was found!"))
.getSpawnLocation());
Expand Down Expand Up @@ -234,12 +234,15 @@ private ItemStack getHeldItem(Player player) {
public void switchWorld(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
ParkourUser user = ParkourUser.getUser(player);
World parkour = WorldManager.getWorld();
org.bukkit.World parkour = World.getWorld();

boolean isAdmin = Config.CONFIG.getBoolean("permissions.enabled") ? ParkourOption.ADMIN.mayPerform(player) : player.isOp();

if (player.getWorld() == parkour && user == null && !isAdmin && player.getTicksLived() > 20) {
player.kickPlayer("You can't enter the parkour world by teleporting!");
Bukkit.getWorlds().stream()
.filter(world -> !world.equals(parkour))
.findAny()
.ifPresent(world -> PaperLib.teleportAsync(player, world.getSpawnLocation()));
return;
}

Expand Down
13 changes: 3 additions & 10 deletions src/main/java/dev/efnilite/ip/IP.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
import dev.efnilite.ip.config.Option;
import dev.efnilite.ip.hook.HoloHook;
import dev.efnilite.ip.hook.PAPIHook;
import dev.efnilite.ip.hook.SkinsRestorerHook;
import dev.efnilite.ip.mode.DefaultMode;
import dev.efnilite.ip.mode.Modes;
import dev.efnilite.ip.mode.SpectatorMode;
import dev.efnilite.ip.player.ParkourUser;
import dev.efnilite.ip.reward.Rewards;
import dev.efnilite.ip.storage.Storage;
import dev.efnilite.ip.world.WorldManager;
import dev.efnilite.ip.world.World;
import dev.efnilite.vilib.ViPlugin;
import dev.efnilite.vilib.bstats.bukkit.Metrics;
import dev.efnilite.vilib.bstats.charts.SimplePie;
Expand Down Expand Up @@ -93,12 +92,6 @@ public void enable() {
Registry.register(new DefaultMode());
Registry.register(new SpectatorMode());

try {
SkinsRestorerHook.initialize();
} catch (NoClassDefFoundError e) {
getLogger().warning("SkinsRestorer is not available: " + e.getMessage());
}

Modes.init();
Menu.init(this);

Expand All @@ -122,7 +115,7 @@ public void enable() {
// ----- Worlds -----

if (Config.CONFIG.getBoolean("joining")) {
WorldManager.create();
World.create();
}

// ----- Events -----
Expand Down Expand Up @@ -156,7 +149,7 @@ public void disable() {
Modes.DEFAULT.getLeaderboard().write(false);

Storage.close();
WorldManager.delete();
World.delete();
} catch (Throwable ignored) {

}
Expand Down
19 changes: 14 additions & 5 deletions src/main/java/dev/efnilite/ip/config/Option.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import dev.efnilite.ip.style.Style;
import dev.efnilite.vilib.particle.ParticleData;
import org.bukkit.*;
import org.bukkit.block.BlockFace;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.util.Vector;

Expand All @@ -22,7 +23,7 @@ public class Option {
public static List<Integer> POSSIBLE_LEADS;

// Advanced settings
public static Vector HEADING;
public static BlockFace HEADING;

public static Map<ParkourOption, Boolean> OPTIONS_ENABLED;
public static Map<ParkourOption, String> OPTIONS_DEFAULTS;
Expand Down Expand Up @@ -88,7 +89,15 @@ public static void init(boolean firstLoad) {
}

// Generation
HEADING = stringToVector(Config.GENERATION.getString("advanced.island.parkour.heading"));
String heading = Config.GENERATION.getString("advanced.island.parkour.heading");

switch (heading.toLowerCase()) {
case "north" -> HEADING = BlockFace.NORTH;
case "south" -> HEADING = BlockFace.SOUTH;
case "west" -> HEADING = BlockFace.WEST;
case "east" -> HEADING = BlockFace.EAST;
default -> IP.logging().error("Invalid heading: %s".formatted(heading));
}

// Scoring

Expand All @@ -100,9 +109,9 @@ public static void init(boolean firstLoad) {

private static Vector stringToVector(String direction) {
return switch (direction.toLowerCase()) {
case "north" -> new org.bukkit.util.Vector(0, 0, -1);
case "south" -> new org.bukkit.util.Vector(0, 0, 1);
case "west" -> new org.bukkit.util.Vector(-1, 0, 0);
case "north" -> new Vector(0, 0, -1);
case "south" -> new Vector(0, 0, 1);
case "west" -> new Vector(-1, 0, 0);
default -> new Vector(1, 0, 0); // east
};
}
Expand Down
22 changes: 16 additions & 6 deletions src/main/java/dev/efnilite/ip/generator/ParkourGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public class ParkourGenerator {
/**
* The direction of the parkour
*/
public Vector heading = Option.HEADING.clone();
public Vector heading = Option.HEADING.getDirection();

/**
* Generator options
Expand Down Expand Up @@ -283,7 +283,10 @@ protected BlockData selectBlockData() {
Style style = Registry.getStyle(profile.get("style").value());

if (style == null) {
profile.set("style", Registry.getStyles().stream().findFirst().get().getName());
profile.set("style", Registry.getStyles().stream()
.findFirst()
.orElseThrow()
.getName());
return selectBlockData();
}

Expand Down Expand Up @@ -318,14 +321,21 @@ protected Block selectNext(Block current, int distance, int height) {
}

double mean = 0;
double standardDeviation = generatorOptions.contains(GeneratorOption.REDUCE_RANDOM_BLOCK_SELECTION_ANGLE) ? 0.6 : 1;
double standardDeviation = generatorOptions.contains(GeneratorOption.REDUCE_RANDOM_BLOCK_SELECTION_ANGLE) ? 0.5 : 1;

int randomOffset = new JumpOffsetGenerator(height, distance).getRandomOffset(mean, standardDeviation);

Vector offset = new Vector(distance + 1, height, randomOffset);
Vector offset = heading.clone()
.multiply(distance + 1)
.setY(height);
if (offset.getX() == 0) {
offset.setX(randomOffset);
} else {
offset.setZ(randomOffset);
}

// rotate offset to match heading
offset.rotateAroundY(angleInY(heading, Option.HEADING.clone()));
offset.rotateAroundY(angleInY(heading, Option.HEADING.getDirection()));

return current.getLocation().add(offset).getBlock();
}
Expand Down Expand Up @@ -541,7 +551,7 @@ int record = leaderboard != null ? leaderboard.get(player.getUUID()).score() : 0

score = 0;
start = null;
heading = Option.HEADING;
heading = Option.HEADING.getDirection();

if (regenerate) { // generate back the blocks
player.teleport(playerSpawn);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/dev/efnilite/ip/hook/HoloHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public static void init() {

Leaderboard leaderboard = mode.getLeaderboard();

if (leaderboard == null) {
return "?";
}

String type = split[1].toLowerCase();
String rank = split[2].replace("#", "");

Expand Down
7 changes: 4 additions & 3 deletions src/main/java/dev/efnilite/ip/hook/PAPIHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private String parseDifficulty(double difficulty) {

private String getInfiniteScore(String rankData, Function<Score, ?> f) {
int rank;
Leaderboard leaderboard;
Leaderboard leaderboard = null;
Matcher matcher = INFINITE_REGEX.matcher(rankData);

// use mode-specific format
Expand All @@ -174,13 +174,14 @@ private String getInfiniteScore(String rankData, Function<Score, ?> f) {
Mode mode = Registry.getMode(name);
if (mode != null) {
leaderboard = mode.getLeaderboard();
} else {
leaderboard = Modes.DEFAULT.getLeaderboard();
}
// use generic format
// x_rank
} else {
rank = Integer.parseInt(rankData);
}

if (leaderboard == null) {
leaderboard = Modes.DEFAULT.getLeaderboard();
}

Expand Down
67 changes: 0 additions & 67 deletions src/main/java/dev/efnilite/ip/hook/SkinsRestorerHook.java

This file was deleted.

Loading

0 comments on commit b8f4b30

Please sign in to comment.