Skip to content

Commit

Permalink
unvote on player left
Browse files Browse the repository at this point in the history
  • Loading branch information
mayli committed Feb 5, 2020
1 parent 8ab69a6 commit efde092
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/main/java/rtv/RockTheVotePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,22 @@ public class RockTheVotePlugin extends Plugin {

// register event handlers and create variables in the constructor
public RockTheVotePlugin() {
// un-vote on player leave
Events.on(PlayerLeave.class, e-> {
Player player = e.player;
int cur = this.votes.size();
int req = (int) Math.ceil(ratio * Vars.playerGroup.size());
if(votes.contains(player)) {
votes.remove(player);
Call.sendMessage("RTV: [accent]" + player.name + "[] left, [green]" + cur + "[] votes, [green]" + req + "[] required");
}
});
// clear votes on game over
Events.on(GameOverEvent.class, e -> {
this.votes.clear();
});
}


//register commands that player can invoke in-game
@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"author": "mayli",
"main": "rtv.RockTheVotePlugin",
"description": "A plugin to change map by /rtv.",
"version": 1.1
"version": 1.2
}

0 comments on commit efde092

Please sign in to comment.