you would do it through your mysql class where it checks the connection, not through your commands
edit: oh wait yours just loads a url, onot sure looks like you already wrapped it with exceptions
|
Please help i have PI, and my vote claim command is bugged, When it get's no response from the check it crash's the server.
Can you make it if theres no response it sends a message like 'Verification server down'
cote command:
package server.model.players.command.impl;
import server.model.players.Client;
import server.model.players.command.CommandHandler;
public class ClaimVotePoints implements CommandHandler {
@Override
public void execute(Client c, String command) {
if(c.checkVotes(c.playerName)) {
c.votingPoints += 50;
c.getItems().addItem(995, 50000000);
c.sendMessage("Thanks for voting! Credited: 50 Vote Points & 50M!");
} else {
c.sendMessage("Please vote first!");
}
}
}
CHECK METHOD IN CLIENT.JAVA
public boolean checkVotes(String playerName) {
try {
String urlString = "http://resource.fabecraft.com/~fabecraf/vote.php?type=checkvote&username="+playerName;
urlString = urlString.replaceAll(" ", "%20");
URL url = new URL(urlString);
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
String results = reader.readLine();
if(results.length() > 0) {
if(results.equals("user needs reward...")) {
return true;
} else {
return false;
}
}
} catch (MalformedURLException e) {
System.out.println("Malformed URL Exception in checkVotes(String playerName)");
} catch (IOException e) {
System.out.println("IO Exception in checkVotes(String playerName)");
}
return false;
}
you would do it through your mysql class where it checks the connection, not through your commands
edit: oh wait yours just loads a url, onot sure looks like you already wrapped it with exceptions
Well my vote is
In commands.javaif (playerCommand.startsWith("reward") || playerCommand.startsWith("claim")) {
if(c.checkVotes(c.playerName)) {
c.getItems().addItem(995, 10000000);
c.Wheel +=3;
c.lvlPoints +=50;
c.getDH().sendDialogues(60, 945);
} else {
c.sendMessage("You have not yet voted, type ::vote to do so");
}
}
Note: Make sure u put in the ints in client.java (i think its client.java)
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |