Thread: ::claim

Results 1 to 4 of 4
  1. #1 ::claim 
    Registered Member
    Join Date
    Aug 2012
    Posts
    76
    Thanks given
    1
    Thanks received
    0
    Rep Power
    10
    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;
    }
    Reply With Quote  
     

  2. #2  
    Banned
    Join Date
    Apr 2012
    Posts
    479
    Thanks given
    36
    Thanks received
    72
    Rep Power
    0
    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
    Reply With Quote  
     

  3. #3  
    Super Donator

    Batukka's Avatar
    Join Date
    Oct 2011
    Posts
    2,433
    Thanks given
    86
    Thanks received
    342
    Rep Power
    496
    add null check.
    Reply With Quote  
     

  4. #4  
    Development Services √

    Oogle's Avatar
    Join Date
    Apr 2012
    Age
    25
    Posts
    3,976
    Thanks given
    650
    Thanks received
    516
    Rep Power
    483
    Well my vote is

    if (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");
    }
    }
    In commands.java

    Note: Make sure u put in the ints in client.java (i think its client.java)


    Attached image

    Attached image
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [PI] Smart Claim ;)
    By NewKid in forum Snippets
    Replies: 21
    Last Post: 03-31-2012, 03:15 AM
  2. Need Help With ::claim
    By Nuno555 in forum Help
    Replies: 8
    Last Post: 01-22-2012, 03:51 AM
  3. [PI] ::claim help
    By Killznodie in forum Help
    Replies: 5
    Last Post: 05-04-2011, 09:29 AM
  4. Help with claim system
    By tehbeasthax in forum Help
    Replies: 5
    Last Post: 01-31-2010, 07:36 PM
  5. Help with claim system
    By owndscape in forum Help
    Replies: 1
    Last Post: 09-26-2009, 09:43 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •