Skip to content

Commit ff60c47

Browse files
committed
v2.9.1: Setup and Edit Mode Bug fixes
- Fixed an issue where you couldn't set an exit point outside the border in Edit Mode. - Fixed an issue during setup where borders weren't saved correctly so would not work unless setup in edit mode. - Fixed an issue where you could not progress in Edit Mode to actually add a checkpoint. - Fixed an issue in Edit Mode where adding the parkour to the database would fail and resultantly would get cleared the next time you reloaded the server. - Fixed an issue where sometimes players could get past the border for a significant distance before getting teleported back - Removed a debug log message Signed-off-by: Block2Block <accounts@block2block.me>
1 parent e5a866a commit ff60c47

8 files changed

Lines changed: 90 additions & 87 deletions

File tree

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 22 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<artifactId>plugin</artifactId>
1313
<name>HubParkour</name>
14-
<version>2.9</version>
14+
<version>2.9.1</version>
1515

1616
<build>
1717
<defaultGoal>clean package</defaultGoal>

plugin/src/main/java/me/block2block/hubparkour/entities/EditWizard.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,14 +495,22 @@ public void run() {
495495
returnToCheckpointMenu();
496496
return true;
497497
}
498+
break;
498499
}
499500
case CHECKPOINTS_ADD_REWARDS: {
500501
if (message.equalsIgnoreCase("cancel")) {
501502
returnToCheckpointMenu();
502503
return true;
503504
}
504505
if (message.equalsIgnoreCase("done")) {
505-
parkour.addCheckpoint(checkpoint, after + 1);
506+
Checkpoint finalCheckpoint = checkpoint;
507+
new BukkitRunnable(){
508+
@Override
509+
public void run() {
510+
//Use final checkpoint as checkpoint gets set to null in the returnToCheckpointMenu call.
511+
parkour.addCheckpoint(finalCheckpoint, after + 1);
512+
}
513+
}.runTask(HubParkour.getInstance());
506514
ConfigUtil.sendMessageOrDefault(player, "Messages.Commands.Admin.Edit.Checkpoints.Add.Success", "The checkpoint has been successfully added!", true, Collections.emptyMap());
507515
returnToCheckpointMenu();
508516
return true;
@@ -521,10 +529,11 @@ public void run() {
521529
case BORDER_POINT_B:
522530
case BORDER_POINT_A: {
523531
if (message.equalsIgnoreCase("done")) {
524-
parkour.setBorders(Collections.emptyList());
532+
parkour.setBorders(new ArrayList<>());
525533
ConfigUtil.sendMessageOrDefault(player, "Messages.Commands.Admin.Edit.Border-Updated", "Border successfully updated!", true, Collections.emptyMap());
526534
returnToMainMenu();
527535
}
536+
break;
528537
}
529538
case REWARD_COOLDOWN: {
530539
String cooldowns = message;
@@ -595,6 +604,7 @@ public void onStick(Location location) {
595604
if (borderCheck(location)) return;
596605
checkpoint = new Checkpoint(location, after + 1, null);
597606
ConfigUtil.sendMessageOrDefault(player, "Messages.Commands.Admin.Edit.Checkpoints.Add.Type-Rewards", "If you wish to add rewards for this particular checkpoint, type them in chat or type it with /parkour input [command]. You can specify more than one by submitting commands several times. Once you're finished, type 'done'.", true, Collections.emptyMap());
607+
currentModification = WizardStep.CHECKPOINTS_ADD_REWARDS;
598608
break;
599609
}
600610
case BORDER_POINT_A: {
@@ -658,7 +668,6 @@ public void onStick(Location location) {
658668
case EXIT_POINT: {
659669
ExitPoint exitPoint = new ExitPoint(location);
660670

661-
if (borderCheck(location)) return;
662671
parkour.setExitPoint(exitPoint, parkour.getExitPoint() != null);
663672
ConfigUtil.sendMessageOrDefault(player, "Messages.Commands.Admin.Edit.Exit-Point-Set", "Your new exit point has been set!", true, Collections.emptyMap());
664673
returnToMainMenu();

plugin/src/main/java/me/block2block/hubparkour/entities/Parkour.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ public void playerEnd(IHubParkourPlayer p) {
266266
}
267267

268268
if (getExitPoint() != null) {
269-
HubParkour.getInstance().getLogger().info("Teleporting to exit point");
270269
Location location = getExitPoint().getLocation().clone();
271270
location.setY(location.getY() + 0.5);
272271
location.setZ(location.getZ() + 0.5);
@@ -406,7 +405,6 @@ public void run() {
406405

407406
public void addCheckpoint(Checkpoint point, int checkNo) {
408407
point.setParkour(this);
409-
CacheManager.addPoint(point);
410408
List<Checkpoint> checkpoints = new ArrayList<>(this.checkpoints);
411409
this.checkpoints.clear();
412410
for (Checkpoint checkpoint : checkpoints) {
@@ -435,6 +433,9 @@ public void run() {
435433
public void run() {
436434
HubParkour.getInstance().getDbManager().addCheckpoint(id, point);
437435
HubParkour.getInstance().getDbManager().resetSplitTimes(id);
436+
437+
438+
CacheManager.addPoint(point);
438439
}
439440
}.runTaskAsynchronously(HubParkour.getInstance());
440441

plugin/src/main/java/me/block2block/hubparkour/entities/SetupWizard.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ public void stickInteract(Location location) {
305305
return;
306306
}
307307
}
308+
borderPoints.add(new BorderPoint(location));
308309
currentStage = SetupStage.NAME;
309310
ConfigUtil.sendMessageOrDefault(player, "Messages.Commands.Admin.Setup.Please-Set-Name", "Now, you need to set a name for your parkour! Please enter a name for your parkour into chat or type it with /parkour input [name]. It must be one word and not a duplicate. Names are compatible with formatting codes.", true, Collections.emptyMap());
310311
break;

plugin/src/main/java/me/block2block/hubparkour/listeners/PressurePlateListener.java

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,55 @@ public class PressurePlateListener implements Listener {
3535
@SuppressWarnings("unused")
3636
@EventHandler
3737
public void onPressurePlate(PlayerMoveEvent e) {
38+
if (CacheManager.isParkour(e.getPlayer())) {
39+
Player p = e.getPlayer();
40+
HubParkourPlayer player = CacheManager.getPlayer(p);
41+
Parkour parkour = player.getParkour();
42+
if (parkour.getBorders().size() == 2) {
43+
Location borderA = parkour.getBorders().get(0).getLocation(), borderB = parkour.getBorders().get(1).getLocation();
44+
45+
double highX = 0, lowX = 0, highY = 0, lowY = 0, highZ = 0, lowZ = 0;
46+
if (borderA.getX() > borderB.getX()) {
47+
highX = borderA.getX();
48+
lowX = borderB.getX();
49+
} else {
50+
highX = borderB.getX();
51+
lowX = borderA.getX();
52+
}
53+
54+
if (borderA.getY() > borderB.getY()) {
55+
highY = borderA.getY();
56+
lowY = borderB.getY();
57+
} else {
58+
highY = borderB.getY();
59+
lowY = borderA.getY();
60+
}
61+
62+
if (borderA.getZ() > borderB.getZ()) {
63+
highZ = borderA.getZ();
64+
lowZ = borderB.getZ();
65+
} else {
66+
highZ = borderB.getZ();
67+
lowZ = borderA.getZ();
68+
}
69+
70+
if ((highX < p.getLocation().getX() || lowX > p.getLocation().getX()) || (highY < p.getLocation().getY() || lowY > p.getLocation().getY()) || (highZ < p.getLocation().getZ() || lowZ > p.getLocation().getZ())) {
71+
Location l = parkour.getRestartPoint().getLocation().clone();
72+
if (player.getLastReached() != 0) {
73+
l = parkour.getCheckpoint(player.getLastReached()).getLocation().clone();
74+
}
75+
l.setX(l.getX() + 0.5);
76+
l.setY(l.getY() + 0.5);
77+
l.setZ(l.getZ() + 0.5);
78+
e.getPlayer().setFallDistance(0);
79+
e.getPlayer().setVelocity(new Vector(0, 0, 0));
80+
e.getPlayer().teleport(l);
81+
ConfigUtil.sendMessageOrDefault(e.getPlayer(), "Messages.Parkour.Teleport", "You have been teleported to your last checkpoint.", true, Collections.emptyMap());
82+
return;
83+
}
84+
}
85+
}
86+
3887
if (e.getFrom().getBlock().getType().equals(e.getTo().getBlock().getType())) {
3988
if (CacheManager.isParkour(e.getPlayer())) {
4089
if (e.getPlayer().isOnGround()) {
@@ -165,52 +214,6 @@ public void run() {
165214
}
166215
}
167216
}
168-
{
169-
Player p = e.getPlayer();
170-
HubParkourPlayer player = CacheManager.getPlayer(p);
171-
Parkour parkour = player.getParkour();
172-
if (parkour.getBorders().size() == 2) {
173-
Location borderA = parkour.getBorders().get(0).getLocation(), borderB = parkour.getBorders().get(1).getLocation();
174-
175-
double highX = 0, lowX = 0, highY = 0, lowY = 0, highZ = 0, lowZ = 0;
176-
if (borderA.getX() > borderB.getX()) {
177-
highX = borderA.getX();
178-
lowX = borderB.getX();
179-
} else {
180-
highX = borderB.getX();
181-
lowX = borderA.getX();
182-
}
183-
184-
if (borderA.getY() > borderB.getY()) {
185-
highY = borderA.getY();
186-
lowY = borderB.getY();
187-
} else {
188-
highY = borderB.getY();
189-
lowY = borderA.getY();
190-
}
191-
192-
if (borderA.getZ() > borderB.getZ()) {
193-
highZ = borderA.getZ();
194-
lowZ = borderB.getZ();
195-
} else {
196-
highZ = borderB.getZ();
197-
lowZ = borderA.getZ();
198-
}
199-
if ((highX < p.getLocation().getX() || lowX > p.getLocation().getX()) || (highY < p.getLocation().getY() || lowY > p.getLocation().getY()) || (highZ < p.getLocation().getZ() || lowZ > p.getLocation().getZ())) {
200-
Location l = parkour.getRestartPoint().getLocation().clone();
201-
if (player.getLastReached() != 0) {
202-
l = parkour.getCheckpoint(player.getLastReached()).getLocation().clone();
203-
}
204-
l.setX(l.getX() + 0.5);
205-
l.setY(l.getY() + 0.5);
206-
l.setZ(l.getZ() + 0.5);
207-
e.getPlayer().setFallDistance(0);
208-
e.getPlayer().setVelocity(new Vector(0, 0, 0));
209-
e.getPlayer().teleport(l);
210-
ConfigUtil.sendMessageOrDefault(e.getPlayer(), "Messages.Parkour.Teleport", "You have been teleported to your last checkpoint.", true, Collections.emptyMap());
211-
}
212-
}
213-
}
214217
if (ConfigUtil.getBoolean("Settings.Incompatibility-Workarounds.VoidSpawn.Enabled", false)) {
215218
if (ConfigUtil.getBoolean("Settings.Teleport.On-Void", true)) {
216219
if (ConfigUtil.getInt("Settings.Incompatibility-Workarounds.VoidSpawn.Min-Y", -1) > e.getTo().getY()) {

plugin/src/main/resources/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: HubParkour
22
main: me.block2block.hubparkour.HubParkour
3-
version: "2.9"
3+
version: "2.9.1"
44
author: Block2Block
55
website: https://block2block.me/
66
description: This is an all-in-one lightweight Parkour plugin for your Hub server!

0 commit comments

Comments
 (0)