return voteType;\r
}\r
\r
+ public void removeVote(Player player )\r
+ {\r
+ if ( ! voteRunning || (voteType == null ) )\r
+ return;\r
+\r
+ plugin.getLogger().info("Debugging removeVote() with player: " + player.getName() );\r
+ if ( yesVoters.contains(player.getName()) )\r
+ {\r
+ yesVoters.remove(player.getName());\r
+ plugin.getLogger().info("Debugging, removeVote() removed YES vote for " + player.getName() );\r
+ }\r
+\r
+ if ( noVoters.contains(player.getName()) )\r
+ {\r
+ noVoters.remove(player.getName());\r
+ plugin.getLogger().info("Debugging, removeVote() removed NO vote for " + player.getName() );\r
+ }\r
+ if( checkRatio( ) )\r
+ {\r
+ plugin.getLogger().info("Debugging: after removing vote, checkRatio() returns TRUE, applying vote");\r
+ applyVote( voteType );\r
+ }\r
+ plugin.getLogger().info("Returning from removeVote()");\r
+ }\r
+\r
public boolean addVote(Player player, boolean yes) \r
{\r
if ( ! voteRunning || (voteType == null ) )\r
required = (float)plugin.getConfig().getInt("vote.time.requiredPercent") / 100.0F;\r
\r
float ratio = (float) yesVoters.size() / (float) plugin.getServer().getOnlinePlayers().length;\r
- if ( ratio > required ) return true;\r
+ if ( ratio >= required ) return true;\r
return false;\r
}\r
\r
\r
import org.bukkit.plugin.PluginLogger;\r
\r
-public class YAVote extends JavaPlugin {\r
+import org.bukkit.event.Listener;\r
+import org.bukkit.event.EventHandler;\r
+import org.bukkit.event.player.PlayerQuitEvent;\r
+\r
+public class YAVote extends JavaPlugin implements Listener {\r
public PluginLogger logger;\r
private Votemanager manager;\r
\r
logger.info("Creating configuration file");\r
saveConfig();\r
}\r
+\r
+ getServer().getPluginManager().registerEvents(this, this);\r
+\r
logger.info("Version " + getDescription().getVersion() + " is enabled!");\r
}\r
+\r
+ @EventHandler\r
+ public void onLogout(PlayerQuitEvent event)\r
+ {\r
+ logger.info("Triggered onLogout() with " + getServer().getOnlinePlayers().length + " players online.");\r
+ manager.removeVote( event.getPlayer() );\r
+ }\r
\r
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){\r
if(cmd.getName().equalsIgnoreCase("vote")){\r