Skip to content

Commit

Permalink
Hotfix 1.5a
Browse files Browse the repository at this point in the history
  • Loading branch information
Efnilite committed Jan 3, 2021
1 parent 0560792 commit d497e06
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
23 changes: 15 additions & 8 deletions src/main/java/dev/efnilite/witp/ParkourPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -70,10 +71,12 @@ public ParkourPlayer(@NotNull Player player, int highScore, String time, String
this.previousLocation = player.getLocation().clone();
this.previousInventory = new HashMap<>();
int index = 0;
for (ItemStack item : player.getInventory().getContents()) {
Inventory inventory = player.getInventory();
for (ItemStack item : inventory.getContents()) {
if (item != null) {
previousInventory.put(index, item);
}
index++;
}
this.useSpecial = showScoreboard;
this.showDeathMsg = showDeathMsg;
Expand Down Expand Up @@ -522,13 +525,17 @@ public static void unregister(@NotNull ParkourPlayer player, boolean sendBack) t
player.save();
WITP.getDivider().leave(player);
players.remove(player.getPlayer());
if (WITP.getConfiguration().getFile("config").getBoolean("bungeecord.enabled")) {
Util.sendPlayer(player.getPlayer(), WITP.getConfiguration().getString("config", "bungeecord.return_server"));
} else {
player.getPlayer().getInventory().clear();
player.getPlayer().teleport(player.getPreviousLocation());
for (int slot : player.getPreviousInventory().keySet()){
player.getPlayer().getInventory().setItem(slot, player.getPreviousInventory().get(slot));
if (sendBack) {
if (WITP.getConfiguration().getFile("config").getBoolean("bungeecord.enabled")) {
Util.sendPlayer(player.getPlayer(), WITP.getConfiguration().getString("config", "bungeecord.return_server"));
} else {
Player pl = player.getPlayer();
pl.getInventory().clear();
pl.teleport(player.getPreviousLocation());
for (int slot : player.getPreviousInventory().keySet()) {
pl.getInventory().setItem(slot, player.getPreviousInventory().get(slot));
}
pl.resetPlayerTime();
}
}
}
Expand Down
14 changes: 11 additions & 3 deletions src/main/java/dev/efnilite/witp/generator/ParkourGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ public void generateNext() {
break;
case 1: // slab
material = Material.SMOOTH_QUARTZ_SLAB.createBlockData();
height = Math.min(height, 0);
height = 0; // todo allow multiple heights
((Slab) material).setType(Slab.Type.BOTTOM);
break;
case 2: // pane
Expand All @@ -413,7 +413,7 @@ public void generateNext() {
Location local = lastSpawn.clone();
List<Block> possible = getPossible(gap - height, height);
if (possible.size() == 0) {
lastSpawn = local;
lastSpawn = local.clone();
return;
}

Expand All @@ -435,7 +435,15 @@ public void generateNext() {
case 1:
File folder = new File(WITP.getInstance().getDataFolder() + "/structures/");
List<File> files = Arrays.asList(folder.listFiles((dir, name) -> name.contains("parkour-")));
File structure = files.get(random.nextInt(files.size() - 1));
File structure;
if (files.size() > 1) {
structure = files.get(random.nextInt(files.size()));
} else if (files.size() == 1) {
structure = files.get(0);
} else {
Verbose.error("No structures to choose from!");
return;
}

structureCooldown = 20;
int gapStructure = distanceChances.get(random.nextInt(distanceChances.size())) + 1;
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.5
version: 1.5a
api-version: 1.16
main: dev.efnilite.witp.WITP
softdepend: [Vault, PlaceholderAPI]
Expand Down

0 comments on commit d497e06

Please sign in to comment.