From 40735e00e8127ddc2be9aa7d994004f232a27c75 Mon Sep 17 00:00:00 2001 From: Caleb Owens Date: Sun, 27 Feb 2022 09:38:27 -0500 Subject: [PATCH] fixed bug that caused players to lose their items if they left the game and joined back. --- src/main/java/net/dohaw/ironcraft/PlayerData.java | 1 - .../java/net/dohaw/ironcraft/prompt/AutonomySurveyPrompt.java | 3 +++ src/main/java/net/dohaw/ironcraft/prompt/IDPrompt.java | 1 + .../java/net/dohaw/ironcraft/prompt/RepeatTutorialPrompt.java | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/dohaw/ironcraft/PlayerData.java b/src/main/java/net/dohaw/ironcraft/PlayerData.java index ca4e95c..d503448 100644 --- a/src/main/java/net/dohaw/ironcraft/PlayerData.java +++ b/src/main/java/net/dohaw/ironcraft/PlayerData.java @@ -360,7 +360,6 @@ public void initManager(IronCraftPlugin plugin){ public void initWorker(IronCraftPlugin plugin){ Player player = getPlayer(); this.isManager = false; - player.getInventory().clear(); player.setGravity(true); player.setInvisible(false); player.setAllowFlight(false); diff --git a/src/main/java/net/dohaw/ironcraft/prompt/AutonomySurveyPrompt.java b/src/main/java/net/dohaw/ironcraft/prompt/AutonomySurveyPrompt.java index 3dbe9e7..dd37072 100644 --- a/src/main/java/net/dohaw/ironcraft/prompt/AutonomySurveyPrompt.java +++ b/src/main/java/net/dohaw/ironcraft/prompt/AutonomySurveyPrompt.java @@ -124,6 +124,7 @@ public Prompt acceptInput(ConversationContext context, String input) { // Lets them play the game again. Bukkit.getScheduler().runTaskLater(plugin, () -> { + player.getInventory().clear(); playerData.setCurrentTutorialObjective(Objective.COLLECT_WOOD); player.teleport(randomSpawnPoint); playerData.setMinutesInGame(0); @@ -132,6 +133,8 @@ public Prompt acceptInput(ConversationContext context, String input) { }else{ player.sendRawMessage("Congratulations. You are finished."); + playerData.setRoundsPlayed(0); + playerData.setCurrentTutorialObjective(null); } return END_OF_CONVERSATION; diff --git a/src/main/java/net/dohaw/ironcraft/prompt/IDPrompt.java b/src/main/java/net/dohaw/ironcraft/prompt/IDPrompt.java index 6c4a709..40e1539 100644 --- a/src/main/java/net/dohaw/ironcraft/prompt/IDPrompt.java +++ b/src/main/java/net/dohaw/ironcraft/prompt/IDPrompt.java @@ -53,6 +53,7 @@ public Prompt acceptInput(ConversationContext context, String providedID) { player.sendRawMessage("There was an error! Please contact an administrator..."); } else { + player.getInventory().clear(); data = playerDataHandler.getData(player); int numOnlinePlayers = Bukkit.getOnlinePlayers().size(); boolean isManager = numOnlinePlayers == 1 ? false : ThreadLocalRandom.current().nextBoolean(); diff --git a/src/main/java/net/dohaw/ironcraft/prompt/RepeatTutorialPrompt.java b/src/main/java/net/dohaw/ironcraft/prompt/RepeatTutorialPrompt.java index 4c2e877..24d54ef 100644 --- a/src/main/java/net/dohaw/ironcraft/prompt/RepeatTutorialPrompt.java +++ b/src/main/java/net/dohaw/ironcraft/prompt/RepeatTutorialPrompt.java @@ -60,6 +60,7 @@ public Prompt acceptInput(ConversationContext context, String input) { playerData.setCurrentTutorialObjective(Objective.COLLECT_WOOD); playerData.setInTutorial(false); + player.getInventory().clear(); Bukkit.getScheduler().runTaskLater(plugin, () -> { player.teleport(randomSpawnPoint); playerData.initWorker(plugin);