Skip to content

Commit

Permalink
fixed bug that caused players to lose their items if they left the ga…
Browse files Browse the repository at this point in the history
…me and joined back.
  • Loading branch information
its-c10 committed Feb 27, 2022
1 parent dd77efe commit 40735e0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/main/java/net/dohaw/ironcraft/PlayerData.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/dohaw/ironcraft/prompt/IDPrompt.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 40735e0

Please sign in to comment.