\r
yesVoters.add(p.getName());\r
\r
- if ( checkRatio( ) )\r
+ //if ( checkRatio( ) )\r
+ if ( ((float) yesVoters.size() / (float) plugin.getServer().getOnlinePlayers().length ) >= getRequired() )\r
{\r
applyVote( voteType );\r
return true;\r
noVoters.remove(player.getName());\r
plugin.getLogger().info("Debugging, removeVote() removed NO vote for " + player.getName() );\r
}\r
- if( checkRatio( ) )\r
+\r
+ if ( yesVoters.size() + noVoters.size() == 0 )\r
{\r
- plugin.getLogger().info("Debugging: after removing vote, checkRatio() returns TRUE, applying vote");\r
+ plugin.getLogger().info("Debugging: No voters remaining in lists. Cancel vote.");\r
+ cancelVote();\r
+ return;\r
+ }\r
+ //if( checkRatio( ) )\r
+ if ( ((float) yesVoters.size() / (float) plugin.getServer().getOnlinePlayers().length -1 ) >= getRequired() )\r
+ {\r
+ plugin.getLogger().info("Debugging: after removing vote, ratio test returns TRUE, applying vote");\r
applyVote( voteType );\r
}\r
plugin.getLogger().info("Returning from removeVote()");\r
if (yes == true) yesVoters.add(player.getName());\r
else noVoters.add(player.getName());\r
\r
- if ( (yes == true) && checkRatio( ) )\r
+ //if ( (yes == true) && checkRatio( ) )\r
+ if ( ( yes == true) && ( ((float) yesVoters.size() / (float) plugin.getServer().getOnlinePlayers().length ) >= getRequired() ) )\r
{\r
applyVote( voteType );\r
return true;\r
clearState();\r
}\r
\r
- private boolean checkRatio( )\r
+ private float getRequired( )\r
{\r
- float required = 0.5F;\r
+ float req = 0.0f;\r
if ( voteType.equalsIgnoreCase("sun") || voteType.equalsIgnoreCase("rain") || voteType.equalsIgnoreCase("storm") )\r
- required = (float)plugin.getConfig().getInt("vote.weather.requiredPercent") / 100.0F;\r
+ req = (float)plugin.getConfig().getInt("vote.weather.requiredPercent") / 100.0F;\r
else if ( voteType.equalsIgnoreCase("day") || voteType.equalsIgnoreCase("night") )\r
- required = (float)plugin.getConfig().getInt("vote.time.requiredPercent") / 100.0F;\r
- \r
+ req = (float)plugin.getConfig().getInt("vote.time.requiredPercent") / 100.0F;\r
+\r
+ return req;\r
+ }\r
+\r
+ /*\r
+ // Original approach...\r
+ private boolean checkRatio( )\r
+ {\r
+ float required = getRequired();\r
float ratio = (float) yesVoters.size() / (float) plugin.getServer().getOnlinePlayers().length;\r
if ( ratio >= required ) return true;\r
return false;\r
}\r
+\r
+ // Replacement code\r
+ private boolean checkRatio( )\r
+ {\r
+ if ( ((float) yesVoters.size() / (float) plugin.getServer().getOnlinePlayers().length ) >= getRequired() )\r
+ return true;\r
+ return false;\r
+ }\r
+\r
+ // But, trying to do it inline instead\r
+ */\r
\r
private void clearState()\r
{\r