Skip to content

Commit

Permalink
Fixed lots of bugs
Browse files Browse the repository at this point in the history
Took 1 hour 20 minutes
  • Loading branch information
TheNathanSpace committed Sep 5, 2021
1 parent b668402 commit 1cd6cc2
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 35 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@

### Features

- Time to forfeit config option
- Building time config option
- Re-examine forfeit system to make sure it works as intended
- Ties
- Package maps with plugin
- Add more game modifiers like First to 5 (stars) or Most stars in 8 minutes

Expand Down
2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.thekingelessar.assault</groupId>
<artifactId>assault</artifactId>
<name>Assault</name>
<version>0.11.6</version>
<version>0.12.0</version>
<description>Still in development</description>
<url>https://github.com/thekingelessar/assault</url>
<build>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.thekingelessar.assault</groupId>
<artifactId>assault</artifactId>
<version>0.11.6</version>
<version>0.12.0</version>
<packaging>jar</packaging>
<name>Assault</name>
<url>https://github.com/thekingelessar/assault</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.thekingelessar.assault.game.GameInstance;
import com.thekingelessar.assault.game.team.GameTeam;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
Expand Down Expand Up @@ -35,7 +34,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}
else
{
player.sendRawMessage(Color.RED + "The defending team cannot forfeit!");
player.sendRawMessage(ChatColor.RED + "The defending team cannot forfeit!");
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void declareWinners(WinState winState)
switch (winState)
{
case LOWEST_TIME:
subtitleString = "Time: " + ChatColor.LIGHT_PURPLE + Util.secondsToMinutes(Util.round(gameInstance.winningTeam.finalAttackingTime, 2), false) + ChatColor.WHITE + " seconds";
subtitleString = "Time: " + ChatColor.LIGHT_PURPLE + Util.secondsToMinutes(gameInstance.winningTeam.displaySeconds, true) + ChatColor.WHITE + " seconds";
break;

case ATTACKERS_LEFT:
Expand Down Expand Up @@ -108,7 +108,10 @@ public void cleanupGameInstance()

for (BukkitRunnable taskTimer : gameInstance.allTimers)
{
taskTimer.cancel();
if (taskTimer != null)
{
taskTimer.cancel();
}
}

for (GameTeam gameTeam : gameInstance.teams.values())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,12 +566,10 @@ public void endRound(boolean attackersForfeit)
{
long nanosecondsTaken = System.nanoTime() - this.getAttackingTeam().startAttackingTime;
this.getAttackingTeam().finalAttackingTime = nanosecondsTaken / 1000000000.;
this.getAttackingTeam().displaySeconds = Util.round(this.getAttackingTeam().finalAttackingTime, 2);
}

this.getAttackingTeam().displaySeconds = Util.round(this.getAttackingTeam().finalAttackingTime, 2);



if (attackersForfeit)
{
this.getAttackingTeam().finalAttackingTime = Integer.MAX_VALUE;
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/com/thekingelessar/assault/game/map/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Map(YamlConfiguration config)

buildingTime = config.getInt("building_time");
attackTimeLimit = config.getInt("attack_time_limit");

maxZ = config.getDouble("max_z");
minZ = config.getDouble("min_z");
attackerBaseProtMaxZ = config.getDouble("attacker_base_prot_max_z");
Expand Down Expand Up @@ -95,9 +95,14 @@ public Map(YamlConfiguration config)
{
defenderBoundingBoxesGeneric.add((List<Object>) boundingBox);
}
for (Object boundingBox : defenderBoundingBoxesGeneric)
for (List<Object> boundingBox : defenderBoundingBoxesGeneric)
{
defenderBoundingBoxes.add((List<Coordinate>) boundingBox);
List<Coordinate> singleBoundCoord = new ArrayList<>();
for (Object singleBound : boundingBox)
{
singleBoundCoord.add(new Coordinate((String) singleBound));
}
defenderBoundingBoxes.add(singleBoundCoord);
}

List<Object> emeraldSpawnsObject = (List<Object>) baseSubMap.get("emerald_spawns");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,25 @@ public void destroyShops()
npc.despawn();
npc.destroy();
}

this.itemShopNPCs.removeAll(removedIndeces);

if (this.teamBuffShopNPCs.size() != 0)
{
List<NPC> removeList = new ArrayList<>();
for (NPC npc : this.teamBuffShopNPCs)
{
Assault.gameNPCs.remove(npc);
npc.despawn();
npc.destroy();
this.teamBuffShopNPCs.remove(npc);
removeList.add(npc);
}
this.teamBuffShopNPCs.removeAll(removeList);
}
}

public boolean isInDefenderBoundingBox(Location location)
{
int i = 0;
for (List<Coordinate> boundingBox : this.defenderBoundingBoxes)
{
if (Util.isInside(location, boundingBox.get(0).toLocation(null), boundingBox.get(1).toLocation(null)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,11 @@ public void evaluateForfeit()
}

gameInstance.endRound(true);
gameInstance.gameEndManager.declareWinners(GameEndManager.WinState.LOWEST_TIME);

if (this.gameInstance.teamsGone == 1)
{
gameInstance.gameEndManager.declareWinners(GameEndManager.WinState.LOWEST_TIME);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import com.thekingelessar.assault.game.GameInstance;
import com.thekingelessar.assault.game.team.GameTeam;
import com.thekingelessar.assault.util.Title;
import com.thekingelessar.assault.util.Util;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Item;
Expand Down Expand Up @@ -71,8 +69,6 @@ public void advanceTimer()
{
player.playSound(player.getLocation(), Sound.valueOf("BLOCK_NOTE_BLOCK_BASS"), 1.5f, 2.0f);
}

player.sendRawMessage(Assault.ASSAULT_PREFIX + gameInstance.getAttackingTeam().color.chatColor + "Your team " + ChatColor.RESET + "can now forfeit! Use /forfeit.");
}
forfeitAlerted = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,13 @@ public void advanceTimer()
return;
}

if (ticksLeft < (gameInstance.gameMap.buildingTime) * 20 + 1)
if (ticksLeft < 201)
{
List<Player> players = gameInstance.getPlayers();
for (Player player : players)
{
title.clearTitle(player);
}

title = new Title(" ", ChatColor.WHITE + "Building finished in " + ChatColor.LIGHT_PURPLE + (ticksLeft / 20) + ChatColor.WHITE + " seconds");

for (Player player : players)
{
title.clearTitle(player);
title.send(player);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.thekingelessar.assault.game.timertasks;

import com.thekingelessar.assault.game.GameInstance;
import com.thekingelessar.assault.util.FireworkUtils;
import com.thekingelessar.assault.util.Title;
import com.thekingelessar.assault.util.Util;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
Expand Down Expand Up @@ -52,8 +50,8 @@ public void advanceTimer()
title.clearTitle(player);
}

String mainTitle = gameInstance.getAttackingTeam().color.getFormattedName(true, true, ChatColor.BOLD) + ChatColor.WHITE + ": " + Util.secondsToMinutes(Util.round(gameInstance.getAttackingTeam().finalAttackingTime, 2), false);

String mainTitle = gameInstance.getAttackingTeam().color.getFormattedName(true, true, ChatColor.BOLD) + ChatColor.WHITE + ": " + Util.secondsToMinutes(gameInstance.getAttackingTeam().displaySeconds, false);
title = new Title(mainTitle, ChatColor.WHITE + "Swapping teams in " + ChatColor.LIGHT_PURPLE + (ticksLeft / 20) + ChatColor.WHITE + " seconds");

for (Player player : players)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public Coordinate(double x, double y, double z)

public Coordinate(String coordinates)
{
Pattern pattern = Pattern.compile("^ *(-?[0-9]+.?[0-9]*) +(-?[0-9]+.?[0-9]*) +(-?[0-9]+.?[0-9]*) *(-?[0-9]+.?[0-9]*)? ?(-?[0-9]+.?[0-9]*)?");
Pattern pattern = Pattern.compile("^ *(-?[0-9]+\\.?[0-9]*) +(-?[0-9]+\\.?[0-9]*) +(-?[0-9]+\\.?[0-9]*) *(-?[0-9]+\\.?[0-9]*)? *(-?[0-9]+\\.?[0-9]*)?");
Matcher matchedPattern = pattern.matcher(coordinates);

if (matchedPattern.find())
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/maps/map_saloon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ bases:
- BLUE:
defender_spawns:
- 29. 111. 83.5 -180. 0.
defender_bounding_box:
defender_bounding_boxes:
- - 26. 0. 85.
- 31. 255. 81.
objective: 35.5 111.5 74.5
Expand Down

0 comments on commit 1cd6cc2

Please sign in to comment.