Skip to content

Commit

Permalink
Fix world switching invalidly unregistering
Browse files Browse the repository at this point in the history
  • Loading branch information
Efnilite committed Jan 9, 2021
1 parent 8912f93 commit f43eca1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>dev.efnilite</groupId>
<artifactId>witp</artifactId>
<version>1.8</version>
<version>1.8b</version>
<build>
<plugins>
<plugin>
Expand Down
25 changes: 12 additions & 13 deletions src/main/java/dev/efnilite/witp/WITP.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,19 +208,18 @@ public void interact(PlayerInteractEvent event) {
}
}

// todo add join timer
// @EventHandler
// public void onSwitch(PlayerChangedWorldEvent event) {
// ParkourPlayer player = ParkourPlayer.getPlayer(event.getPlayer());
// if (player != null && player.getPlayer().getWorld().getUID() != WITP.getDivider().getWorld().getUID()) {
// try {
// ParkourPlayer.unregister(player, true);
// } catch (IOException ex) {
// ex.printStackTrace();
// Verbose.error("Error while trying to unregister player");
// }
// }
// }
@EventHandler
public void onSwitch(PlayerChangedWorldEvent event) {
ParkourUser user = ParkourUser.getUser(event.getPlayer());
if (event.getFrom().getUID() == WITP.getDivider().getWorld().getUID() && user != null) {
try {
ParkourUser.unregister(user, true);
} catch (IOException ex) {
ex.printStackTrace();
Verbose.error("Error while trying to unregister player");
}
}
}

@EventHandler
public void leave(PlayerQuitEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,13 @@ private void fetchPossibleInLayer() {
public void setBorder(@NotNull ParkourUser player, @NotNull SubareaPoint point) {
int size = (int) ParkourGenerator.Configurable.BORDER_SIZE;
Vector estimated = point.getEstimatedCenter(size);
Verbose.info(estimated.toString() + " // " + size);
WITP.getVersionManager().setWorldBorder(player.getPlayer(), estimated, size);
}

private void createIsland(ParkourPlayer pp, SubareaPoint point) {
Player player = pp.getPlayer();
collection.put(point, pp);
Location spawn = point.getEstimatedCenter((int) pp.getGenerator().borderOffset * 2).toLocation(world).clone();
Location spawn = point.getEstimatedCenter((int) ParkourGenerator.Configurable.BORDER_SIZE).toLocation(world).clone();

Vector dimension = WITP.getVersionManager().getDimensions(spawnIsland, spawn);
spawn.setY(spawn.getY() - dimension.getY());
Expand All @@ -242,6 +241,8 @@ private void createIsland(ParkourPlayer pp, SubareaPoint point) {
min.setZ(min.getZ() - (dimension.getZ() / 2.0));

List<Block> blocks = Util.getBlocks(min, min.clone().add(dimension));

pp.setGenerator(new ParkourGenerator(pp));
pp.getGenerator().data = new SubareaPoint.Data(blocks);
pp.getGenerator().heading = heading.clone();
Location to = null;
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/dev/efnilite/witp/player/ParkourPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public ParkourPlayer(@NotNull Player player, int highScore, String time, String
this.file = new File(WITP.getInstance().getDataFolder() + "/players/" + player.getUniqueId().toString() + ".json");
this.possibleStyle = new ArrayList<>();
setStyle(style);
this.generator = new ParkourGenerator(this);

player.setPlayerTime(getTime(time), false);
WITP.getDivider().generate(this);
Expand All @@ -95,6 +94,10 @@ public ParkourPlayer(@NotNull Player player, int highScore, String time, String
}
}

public void setGenerator(ParkourGenerator generator) {
this.generator = generator;
}

public void removeSpectators(ParkourSpectator... spectators) {
for (ParkourSpectator spectator : spectators) {
this.spectators.remove(spectator.getPlayer().getName());
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 'WITP'
description: 'Automatically generating, infinitely long parkour plugin. The sky, and your time, is the limit. The further you go, the harder it gets. Should be a walk in the park, right?'
author: Efnilite, Ice_Pancake
version: 1.8a
version: 1.8b
api-version: 1.16
main: dev.efnilite.witp.WITP
softdepend: [Vault, PlaceholderAPI]
Expand Down

0 comments on commit f43eca1

Please sign in to comment.