Skip to content

Commit

Permalink
Bugfies
Browse files Browse the repository at this point in the history
  • Loading branch information
ImDaBigBoss committed Oct 15, 2022
1 parent bb2cebd commit c2fbcf3
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
public class GameManager {
private KitDuels plugin;

private Random random = new Random();

public Map<String, String> editModePlayers = new HashMap<>();

public Map<String, List<CommonPlayer>> enabledMaps = new HashMap<>();
Expand Down Expand Up @@ -68,7 +70,7 @@ public String getNextMap() {
}

if (currentNumPlayers == 0) {
int index = new Random().nextInt(enabledMaps.size());
int index = random.nextInt(enabledMaps.size());
currentMap = new ArrayList<>(enabledMaps.keySet()).get(index);
}

Expand Down Expand Up @@ -97,7 +99,7 @@ public String getNextMap(int players) {
}

if (currentNumPlayers == 0) {
int index = new Random().nextInt(maps.size());
int index = random.nextInt(maps.size());
currentMap = maps.get(index);
}

Expand Down Expand Up @@ -246,7 +248,7 @@ public void startGame(String map) {
} else if (plugin.getKitManager().getPlayerKits().containsKey(mapPlayer.getName())) {
kitName = plugin.getKitManager().getPlayerKits().get(mapPlayer.getName());
} else {
int index = new Random().nextInt(plugin.getKitManager().getKits().size());
int index = random.nextInt(plugin.getKitManager().getKits().size());
kitName = plugin.getKitManager().getKits().get(index);
}
if (!kitName.equalsIgnoreCase("")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ public void entityDamage(EntityDamageEvent event) {
for (CommonPlayer alivePlayer : plugin.getGameManager().mapAlivePlayers.get(map)) {
winPlayer = alivePlayer;
}
if (winPlayer == null) {
plugin.getLog().error("Win player is null in map " + map + "! Please contact a developer!");
return;
}

plugin.getGameManager().ongoingMaps.remove(map);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ public boolean deleteWorld(File path) {

for (File file : files) {
if (file.isDirectory()) {
deleteWorld(file);
if (!deleteWorld(file)) {
return false;
}
} else {
file.delete();
if (!file.delete()) {
return false;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ public void run() {
for (CommonPlayer alivePlayer : plugin.getGameManager().mapAlivePlayers.get(map)) {
winPlayer = alivePlayer;
}
if (winPlayer == null) {
plugin.getLog().error("Win player is null in map " + map + "! Please contact a developer!");
return;
}

plugin.getGameManager().ongoingMaps.remove(map);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import org.bukkit.*;
import org.bukkit.plugin.java.JavaPlugin;
import org.geysermc.cumulus.Forms;
import org.geysermc.floodgate.api.FloodgateApi;

import java.util.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public void showMapSelector(CommonPlayer player, boolean byKit) {
showMapSelectorJava(player, byKit);
}


private String randomIcon = "textures/ui/refresh.png";
private String kitIcon = "textures/ui/new_offer_symbol.png";
private String mapIcon = "textures/ui/new_offer_symbol.png";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ public boolean deleteWorld(File path) {

for (File file : files) {
if (file.isDirectory()) {
deleteWorld(file);
if (!deleteWorld(file)) {
return false;
}
} else {
file.delete();
if (!file.delete()) {
return false;
}
}
}
}
Expand Down

0 comments on commit c2fbcf3

Please sign in to comment.