Thread: Motivote2 Installation (PI, Ruse, ANY)

Page 1 of 9 123 ... LastLast
Results 1 to 10 of 84
  1. #1 Motivote2 Installation (PI, Ruse, ANY) 
    ???

    funkE's Avatar
    Join Date
    Feb 2008
    Posts
    2,612
    Thanks given
    255
    Thanks received
    989
    Rep Power
    1366


    MOTIVOTERS (v3) HAS BEEN RELEASED

    Media and information: http://www.rune-server.org/programmi...d-service.html
    Download server library: https://github.com/SuprahFry/Voting-Gateway/releases
    Set up gateway account: Motivote v2 - Hosted Voting Services

    Initializing Motivote (ALL BASES!!!)
    Motivote will require your server's API key in order to function, this can be obtained in the server control panel.

    You can start by initializing the AuthService by supplying Motivote with your API key in the main(String[]) method of your application.

    Code:
    public static void main(String[] args) throws Exception {
    	AuthService.setProvider(new Motivote("API_KEY_HERE"));
    	// other important code below.
    }
    Note: you only have to add AuthService.setProvider(new Motivote("API_KEY_HERE")) at the top of your EXISTING main method!

    Creating an Auth or Redeem Command
    Now, in order for users to redeem the auth codes they voted for, you will have to create some sort of command for them to enter their auth code and then check it with Motivote's database to see if it is valid. Let's do that now.

    Project Insanity Bases
    In order to add a command to a Project Insanity base, you must first open

    Code:
    ./src/server/model/players/packets/Commands.java
    "." refers to the location in which your source's "src" directory (or similar) is located.

    Search for your playerCommands method [void playerCommands(Client c, String playerCommand)]. Below is an example of a redeem checker.

    Code:
    if (playerCommand.startswith("redeem")) {
    	String auth = playerCommand.replace("redeem ", "");
    	boolean success = AuthService.provider().redeemNow(auth);
    	
    	if (success) {
    		c.getItems().addItem(995, 10000);
    		c.sendMessage("Auth redeemed, thanks for voting!");
    	}
    	else {
    		c.sendMessage("Invalid auth supplied, please try again later.");
    	}
    }
    YOU'RE DONE! THAT'S IT!

    Ruse Bases

    Somewhere in your source, there should be CommandPacketListener.java, inside it find the playerCommands method. At the bottom, put the following code:

    Code:
    if (command[0].equalsIgnoreCase("redeem")) {
    	String auth = command[1];
    	boolean success = AuthService.provider().redeemNow(auth);
    	Item item = new Item(995, 100000);
    	
    	if (success) {
    		player.getInventory().add(item, true);
    		player.getPacketSender().sendMessage("Auth redeemed, thanks for voting!");
    	}
    	else {
    		player.getPacketSender().sendMessage("Invalid auth supplied, please try again later.");
    	}
    }
    YOU'RE DONE! THAT'S IT!

    Spoiler for Extra information:
    Non-blocking API Calls
    Motivote supports Future<?>s if you want to store it and check progress.

    An example for experienced developers below utilizing an ExecutorService. Note that implementations can vary widely which is why I do not supply a specific example for any server.

    Code:
    // somewhere in your class constructor or something
    ExecutorService svc = Executors.newCachedThreadPool();
    
    // somewhere in your command handler
    
    // assumed variables: final String auth, final Player player
    svc.execute(new Runnable() {
    	@Override
    	public void run() {
    		if (success) {
    			player.give(995, 100000);
    			player.message("Thanks for voting!");
    		}
    		else {
    			player.message("Invalid auth provided. Try again later.");
    		}
    	}
    });
    Info API Calls
    Motivote also allows you to gather information about a specific auth code, so you can do some extra checks or store info in your database

    Code:
    Vote vote = AuthService.provider().infoNow("AUTH_CODE_HERE");
    System.out.println("Auth: " + vote.address());
    System.out.println("Callback Date: " + vote.callbackDate()); // as a UNIX timestamp
    System.out.println("IP: " + vote.address()); // voter's IP address as reported by Motivote
    System.out.println("Fulfilled: " + vote.fulfilled()); // reward has been given for auth
    System.out.println("Ready: " + vote.ready()); // vote has been verified, auth has been generated, ready to be fulfilled if not already
    System.out.println("Redeemed: " + vote.redeemed()); // vote has been redeemed in this API call, can return no if vote has already been redeemed.
    Non-singleton pattern
    I have included a simple singleton pattern to make it easier for newcomers to initialize and access the AuthService. I strongly advise against that (singleton) approach since it is a classic case of bad design.

    Code:
    AuthService authSvc = new Motivote("API_KEY_HERE");
    System.out.println(authSvc.redeemNow("AUTH_CODE_HERE"));
    Last edited by funkE; 12-06-2015 at 04:09 PM. Reason: update and title stuff
    .
    Reply With Quote  
     

  2. Thankful users:


  3. #2  
    ???

    funkE's Avatar
    Join Date
    Feb 2008
    Posts
    2,612
    Thanks given
    255
    Thanks received
    989
    Rep Power
    1366
    Bump for visibility!
    .
    Reply With Quote  
     

  4. #3  
    ???

    funkE's Avatar
    Join Date
    Feb 2008
    Posts
    2,612
    Thanks given
    255
    Thanks received
    989
    Rep Power
    1366
    To the top! Considering how popular MV was before, I would assume there'd be some activity here. Maybe the forum is just too crowded.
    .
    Reply With Quote  
     

  5. #4  
    Coding coding coding...

    Ivo's Avatar
    Join Date
    Mar 2008
    Age
    33
    Posts
    1,425
    Thanks given
    30
    Thanks received
    147
    Rep Power
    2017
    Could you explain to someone like me, who has no idea what is it but looks sort of intresting... what is this supposed to do?
    Reply With Quote  
     

  6. #5  
    ???

    funkE's Avatar
    Join Date
    Feb 2008
    Posts
    2,612
    Thanks given
    255
    Thanks received
    989
    Rep Power
    1366
    Quote Originally Posted by Ivo View Post
    Could you explain to someone like me, who has no idea what is it but looks sort of intresting... what is this supposed to do?
    It's basically an easy to use vote page. Every vote generates an auth code people can use to redeem a reward on your server. It handles everything for you. This way, you don't have to manage any code and you can simply embed the motivote vote page in your own website to provide a seamless experience
    .
    Reply With Quote  
     

  7. #6  
    Registered Member
    hc747's Avatar
    Join Date
    Dec 2013
    Age
    26
    Posts
    1,474
    Thanks given
    3,312
    Thanks received
    691
    Rep Power
    1098
    Friendly bump out of interest!
    Reply With Quote  
     

  8. #7  
    ???

    funkE's Avatar
    Join Date
    Feb 2008
    Posts
    2,612
    Thanks given
    255
    Thanks received
    989
    Rep Power
    1366
    Quote Originally Posted by hc747 View Post
    Friendly bump out of interest!
    Thanks, appreciate it.
    here's another bump
    .
    Reply With Quote  
     

  9. #8  
    Registered Member
    Join Date
    Sep 2015
    Posts
    3
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    I would like some help with this i get 7 errors including the imports i added for this Motivote
    Reply With Quote  
     

  10. #9  
    ???

    funkE's Avatar
    Join Date
    Feb 2008
    Posts
    2,612
    Thanks given
    255
    Thanks received
    989
    Rep Power
    1366
    Quote Originally Posted by Koed U Choob View Post
    I would like some help with this i get 7 errors including the imports i added for this Motivote
    You did include the files in the download into your source folder/build path, right
    .
    Reply With Quote  
     

  11. #10  
    Registered Member
    Join Date
    Sep 2015
    Posts
    3
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Yes.
    look here is a screenie of errors and the src folder
    Reply With Quote  
     

Page 1 of 9 123 ... LastLast

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]Fixing <, >, and other characters
    By TaeYang in forum Help
    Replies: 10
    Last Post: 04-15-2016, 12:53 PM
  2. Replies: 1
    Last Post: 08-23-2011, 01:58 AM
  3. Replies: 4
    Last Post: 08-03-2011, 09:42 AM
  4. Replies: 4
    Last Post: 07-03-2011, 06:17 PM
  5. [PI] And other 641 Item problem.
    By The GOD in forum Help
    Replies: 6
    Last Post: 04-22-2011, 10:50 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
  •