Skip to content

Commit

Permalink
Keep players from going to the wrong side
Browse files Browse the repository at this point in the history
Took 27 minutes
  • Loading branch information
TheNathanSpace committed Sep 9, 2021
1 parent e00343f commit 6d7f07e
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 15 deletions.
13 changes: 1 addition & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,13 @@

### Bugs

- Bugs probably exist surrounding the FT5S mode, especially with ties
- can still get over wall barriers
- `NullPointerException` with `GamePlayer` when leave and rejoin
- Citizens NPCs aren't deleted properly, so they stick around in Citizens' config

### Features

### Modifier: First to Five Stars

- ~~Make new modifier~~
- ~~Keep track of times picked up~~
- ~~Update scoreboard with times picked up~~
- ~~On item pickup, don't end until counter reaches 5~~
- ~~If time ends and counter not at 5, winning team is the one with the most stars~~
- ~~Different 480 time when enabled~~
- Test (especially ties)

### Other

- Multiverse support
- Package maps with plugin
- Add more game modifiers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import com.thekingelessar.assault.Assault;
import com.thekingelessar.assault.game.GameInstance;
import com.thekingelessar.assault.game.GameStage;
import com.thekingelessar.assault.game.world.map.MapBase;
import com.thekingelessar.assault.game.player.DeathType;
import com.thekingelessar.assault.game.player.GamePlayer;
import com.thekingelessar.assault.game.player.PlayerMode;
import com.thekingelessar.assault.game.team.GameTeam;
import com.thekingelessar.assault.game.world.map.MapBase;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -103,8 +103,63 @@ else if ((System.nanoTime() - gamePlayer.startTimeInAir) / 1000000000. > 5)
if (voidY < gameInstance.gameMap.voidLevel && gameInstance.gameMap.voidEnabled)
{
GamePlayer gamePlayer = gameInstance.getGamePlayer(player);
gamePlayer.respawn(null, true, DeathType.VOID);
if (gamePlayer != null)
{
gamePlayer.respawn(null, true, DeathType.VOID);
}
}

if (gameInstance.gameStage.equals(GameStage.PREGAME))
{
return;
}

if (gameInstance.gameStage.equals(GameStage.BUILDING))
{
GamePlayer gamePlayer = gameInstance.getGamePlayer(player);
if (gamePlayer != null)
{
if (newLocation.getX() > gameInstance.gameMap.borderX && gamePlayer.gameTeam.mapBase.objective.x < gameInstance.gameMap.borderX)
{
cancelMovement(playerMoveEvent);

player.sendMessage(Assault.ASSAULT_PREFIX + "You can't go over here!");
return;
}

if (newLocation.getX() < gameInstance.gameMap.borderX && gamePlayer.gameTeam.mapBase.objective.x > gameInstance.gameMap.borderX)
{
cancelMovement(playerMoveEvent);

player.sendMessage(Assault.ASSAULT_PREFIX + "You can't go over here!");
return;
}
}

return;
}

if (newLocation.getX() > gameInstance.gameMap.borderX && gameInstance.getDefendingTeam().mapBase.objective.x < gameInstance.gameMap.borderX)
{
player.sendMessage(Assault.ASSAULT_PREFIX + "You can't go over here!");
GamePlayer gamePlayer = gameInstance.getGamePlayer(player);
if (gamePlayer != null)
{
cancelMovement(playerMoveEvent);
return;
}
}

if (newLocation.getX() < gameInstance.gameMap.borderX && gameInstance.getDefendingTeam().mapBase.objective.x > gameInstance.gameMap.borderX)
{
player.sendMessage(Assault.ASSAULT_PREFIX + "You can't go over here!");
GamePlayer gamePlayer = gameInstance.getGamePlayer(player);
if (gamePlayer != null)
{
cancelMovement(playerMoveEvent);
}
}

}

private void cancelMovement(PlayerMoveEvent playerMoveEvent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void addSpawnItem(ItemStack spawnItem)
spawnItems.add(spawnItem);
}

public void spawn(PlayerMode playerMode, boolean keepInventory)
public void spawn(PlayerMode playerMode, boolean keepInventory) // keepInventory and checking if GameStage is BUILDING is a little redundant
{
GameTeam playerTeam = gameInstance.getPlayerTeam(player);
PlayerMode mode = PlayerMode.setPlayerMode(player, playerMode, gameInstance);
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/thekingelessar/assault/game/world/map/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class Map
public int attackTimeLimit = 480;
public int firstToFiveStarsTimeLimit = 480;

public double borderX = 0;

public double maxZ = 86;
public double minZ = 2;

Expand Down Expand Up @@ -132,6 +134,15 @@ public Map(YamlConfiguration config)
Assault.INSTANCE.getLogger().log(Level.WARNING, "first_to_five_stars_time_limit invalid; defaulting to 480");
}

try
{
borderX = config.getDouble("border_x");
}
catch (Exception exception)
{
Assault.INSTANCE.getLogger().log(Level.WARNING, "border_x invalid; defaulting to 0");
}

try
{
maxZ = config.getDouble("max_z");
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/maps/map_saloon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ building_coins: 100
attack_time_limit: 480
first_to_five_stars_time_limit: 480

border_x: 0

max_z: 86.
min_z: 2.

Expand Down

0 comments on commit 6d7f07e

Please sign in to comment.