Skip to content

Commit

Permalink
Small ParkourKit optimisation
Browse files Browse the repository at this point in the history
Updated dependencies
  • Loading branch information
A5H73Y committed Mar 17, 2023
1 parent f1d220a commit d1b9965
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/maven-build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Build

env:
artifact_name: 'Parkour-7.1.0'
artifact_name: 'Parkour-7.2.0'
release_type: '-RELEASE'

on: push
Expand Down Expand Up @@ -31,7 +31,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}${{ env.release_type }}.${{ github.run_number }}
tag_name: ${{ env.artifact_name }}${{ env.release_type }}.${{ github.run_number }}
release_name: ${{ env.artifact_name }}${{ env.release_type }}.${{ github.run_number }}
draft: false
prerelease: false
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ For the list of known supported plugins and tutorials on how to set them up, [cl
<dependency>
<groupId>com.github.A5H73Y</groupId>
<artifactId>Parkour</artifactId>
<version>7.1.0</version>
<version>7.2.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
Expand All @@ -48,5 +48,5 @@ repositories {
```

```
compile 'com.github.A5H73Y:Parkour:7.1.0'
compile 'com.github.A5H73Y:Parkour:7.2.0'
```
16 changes: 16 additions & 0 deletions docs/changelogs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@ Changelogs

Please note that each version of Parkour is backwards compatible with the previous version and will automatically upgrade your config upon server start up. There will be no manual intervention, unless stated in breaking changes.

## 7.2.0

* Added ability to set a one-time fee for a course
Added "ParkourTool.RemoveRightClickRestriction" to support geyser controls
* Added "Other.Display.CurrencyName" to show or hide currency name in messages
* Added Throwables to be ParkourTools
* Ability to disable nested parkour commands
* Added ability to affect vehicles with ParkourKit (OnCourse.ParkourKit.IncludeVehicles)
* Added ability to return items achieved while on Course (OnFinish.GiveGainedItemsBack & OnLeave.GiveGainedItemsBack)
* Fixed decimal rewarddelay not working
* Fixed teleporting away from a Course detection
* Fixed Restart cooldown being reset
* Fixed existing session NPE
* Small ParkourKit optimisation
* Update dependencies

## 7.1.0
* Improved ParkourTools to be more structured
* Added ability for each ParkourTool to have individual cooldown and cooldown message
Expand Down
13 changes: 9 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.a5h73y</groupId>
<artifactId>Parkour</artifactId>
<version>7.1.0</version>
<version>7.2.0</version>
<packaging>jar</packaging>

<name>Parkour</name>
Expand Down Expand Up @@ -111,7 +111,7 @@
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.0.0</version>
<version>3.0.1</version>
<scope>compile</scope>
</dependency>
<!-- MySQL Database -->
Expand All @@ -138,7 +138,7 @@
<dependency>
<groupId>com.github.cryptomorin</groupId>
<artifactId>XSeries</artifactId>
<version>9.2.0</version>
<version>9.3.0</version>
<scope>compile</scope>
</dependency>
<!-- Version Compare -->
Expand All @@ -158,13 +158,18 @@
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.33</version>
<version>2.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20230227</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public void onPlayerMove(PlayerMoveEvent event) {

ParkourKitAction kitAction = parkourKit.getAction(belowMaterial);

if (kitAction != null) {
performBelowAction(player, kitAction);
} else {
if (kitAction != null && parkourKit.isHasFloorActions()) {
performFloorAction(player, kitAction);
} else if (parkourKit.isHasWallActions()) {
performWallAction(player, parkourKit);
}
}
Expand Down Expand Up @@ -110,7 +110,7 @@ private void performWallAction(Player player, ParkourKit parkourKit) {
}
}

private void performBelowAction(Player player, ParkourKitAction kitAction) {
private void performFloorAction(Player player, ParkourKitAction kitAction) {
switch (kitAction.getActionType()) {
case FINISH:
parkour.getPlayerManager().finishCourse(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,14 @@ public void onVehicleMove(VehicleMoveEvent event) {
Material belowMaterial = event.getVehicle().getLocation().getBlock().getRelative(BlockFace.DOWN).getType();
ParkourKitAction kitAction = parkourKit.getAction(belowMaterial);

if (kitAction != null) {
performBelowAction(player, event.getVehicle(), kitAction);
} else {
if (kitAction != null && parkourKit.isHasFloorActions()) {
performFloorAction(player, event.getVehicle(), kitAction);
} else if (parkourKit.isHasWallActions()) {
performWallAction(player, event.getVehicle(), parkourKit);
}
}

private void performBelowAction(Player player, Vehicle vehicle, ParkourKitAction kitAction) {
Vector velocity = vehicle.getVelocity();
private void performFloorAction(Player player, Vehicle vehicle, ParkourKitAction kitAction) {
switch (kitAction.getActionType()) {
case FINISH:
parkour.getPlayerManager().finishCourse(player);
Expand All @@ -77,9 +76,7 @@ private void performBelowAction(Player player, Vehicle vehicle, ParkourKitAction
break;

case LAUNCH:
// player.sendMessage(String.valueOf(velocity.getY()));
// TODO why is this so temperamental
velocity.setY(velocity.getY() + 5);
vehicle.setVelocity(new Vector(0, 0.5, 0));
break;

case BOUNCE:
Expand Down Expand Up @@ -116,8 +113,6 @@ private void performBelowAction(Player player, Vehicle vehicle, ParkourKitAction
default:
break;
}

vehicle.setVelocity(velocity);
}

private void performWallAction(Player player, Vehicle vehicle, ParkourKit parkourKit) {
Expand All @@ -138,7 +133,7 @@ private void performWallAction(Player player, Vehicle vehicle, ParkourKit parkou
double z = blockFace == BlockFace.EAST || blockFace == BlockFace.WEST ? 0
: blockFace == BlockFace.NORTH ? strength : -strength;

vehicle.setVelocity(new Vector(x, 0.3, z));
vehicle.setVelocity(new Vector(x, 0.5, z));
break;
default:
break;
Expand Down
30 changes: 20 additions & 10 deletions src/main/java/io/github/a5h73y/parkour/type/kit/ActionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,26 @@
import org.jetbrains.annotations.NotNull;

public enum ActionType {
FINISH,
DEATH,
LAUNCH,
BOUNCE,
SPEED,
NORUN,
NOPOTION,
CLIMB,
REPULSE,
POTION;
FINISH(true),
DEATH(true),
LAUNCH(true),
BOUNCE(true),
SPEED(true),
NORUN(true),
NOPOTION(true),
CLIMB(false),
REPULSE(false),
POTION(true);

private final boolean isFloorType;

ActionType(boolean isFloorType) {
this.isFloorType = isFloorType;
}

public boolean isFloorType() {
return isFloorType;
}

@NotNull
public String getDisplayName() {
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/io/github/a5h73y/parkour/type/kit/ParkourKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class ParkourKit implements Serializable {

private final String name;
private final Map<Material, ParkourKitAction> parkourActions;
private final boolean hasFloorActions;
private final boolean hasWallActions;

/**
* Construct a ParkourKit from the details.
Expand All @@ -31,6 +33,10 @@ public class ParkourKit implements Serializable {
public ParkourKit(final String name, Map<Material, ParkourKitAction> parkourActions) {
this.name = name;
this.parkourActions = parkourActions;
this.hasFloorActions = parkourActions.values().stream()
.anyMatch(parkourKitAction -> parkourKitAction.getActionType().isFloorType());
this.hasWallActions = parkourActions.values().stream()
.anyMatch(parkourKitAction -> !parkourKitAction.getActionType().isFloorType());
}

/**
Expand Down Expand Up @@ -58,4 +64,12 @@ public Set<Material> getMaterials() {
public String getName() {
return name;
}

public boolean isHasFloorActions() {
return hasFloorActions;
}

public boolean isHasWallActions() {
return hasWallActions;
}
}

0 comments on commit d1b9965

Please sign in to comment.