Skip to content

Commit

Permalink
Scoreboard numbers on the side start from 1 instead of 4.
Browse files Browse the repository at this point in the history
Fixed the bug that occurred when placing a wall torch.

The amount of minutes the player has been in game is saved to file now.

Players are reminded of how many minutes they have left to complete the game now.
  • Loading branch information
its-c10 committed Feb 11, 2022
1 parent f54e7b9 commit 4d972b3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/main/java/net/dohaw/ironcraft/IronCraftPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ public Location getRandomChamber() {
}

public Location getRandomJourneySpawnPoint() {
System.out.println("SPAWN LOCATIONS: " + journeySpawnPoints);
return journeySpawnPoints.get(new Random().nextInt(journeySpawnPoints.size()));
}

Expand All @@ -177,8 +176,14 @@ public void updateScoreboard(Player player) {

if(!playerData.isManager()){

// If they aren't in the tutorial, then they don't need the objectives on the side of their screen.
if(!playerData.isInTutorial()){
player.setScoreboard(manager.getNewScoreboard());
return;
}

int currentObjectiveOrdinal = playerData.getCurrentTutorialObjective().ordinal();
int counter = 4;
int counter = 1;
for (Objective objective : Objective.values()) {

Score objScore;
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/net/dohaw/ironcraft/PlayerData.java
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,14 @@ public void setManagerFeedback(String managerFeedback) {
this.managerFeedback = managerFeedback;
}

public int getMinutesInGame() {
return minutesInGame;
}

public void setMinutesInGame(int minutesInGame) {
this.minutesInGame = minutesInGame;
}

public void writeDataToFile(IronCraftPlugin plugin) throws IOException {

File file = new File(plugin.getDataFolder() + File.separator + "end_game_data", "input_" + uuid.toString() + ".yml");
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/net/dohaw/ironcraft/Reminder.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ public void run() {
message = PLAYER_REMINDERS.get(currentIndexReminder);
playerIndexReminders.put(uuid, currentIndexReminder);

// Reminds them of how much time they have left if they are in the actual game.
if(!data.isInTutorial()){
int minutesInGame = data.getMinutesInGame();
player.sendMessage(StringUtils.colorString("&7You have &e" + (7 - minutesInGame) + "&7 minutes to complete the game!"));
}

}
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(StringUtils.colorString(message)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public PlayerData loadData() {
playerData.setInTutorial(config.getBoolean("Is In Tutorial"));
playerData.setChamberLocation(config.getLocation("Chamber Location"));
playerData.setCurrentTutorialObjective(Objective.valueOf(config.getString("Tutorial Objective")));
playerData.setMinutesInGame(config.getInt("Minutes In Game"));

return playerData;
}
Expand All @@ -34,6 +35,7 @@ public void saveData(PlayerData data) {
config.set("Is In Tutorial", data.isInTutorial());
config.set("Chamber Location", data.getChamberLocation());
config.set("Tutorial Objective", data.getCurrentTutorialObjective().toString());
config.set("Minutes In Game", data.getMinutesInGame());
saveConfig();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void onPlaceTorch(BlockPlaceEvent e) {
Player player = e.getPlayer();
PlayerData playerData = getPlayerData(player);
Material blockPlacedType = e.getBlockPlaced().getType();
if (playerData.getCurrentTutorialObjective() == Objective.PLACE_A_TORCH && blockPlacedType == Material.TORCH || blockPlacedType == Material.WALL_TORCH) {
if (playerData.getCurrentTutorialObjective() == Objective.PLACE_A_TORCH && (blockPlacedType == Material.TORCH || blockPlacedType == Material.WALL_TORCH) ) {
playerData.setCurrentTutorialObjective(plugin.getNextObjective(Objective.PLACE_A_TORCH));
Bukkit.getServer().getPluginManager().callEvent(new CompleteObjectiveEvent(playerData));
}
Expand Down

0 comments on commit 4d972b3

Please sign in to comment.