CraftTweet 1.0-SNAPSHOT

Links player's Twitter account to Minecraft.

  1. Compilable
    Native Minecraft Version:
    1.16
    Tested Minecraft Versions:
    • 1.7
    • 1.8
    • 1.9
    • 1.10
    • 1.11
    • 1.12
    • 1.13
    • 1.14
    • 1.15
    • 1.16
    Source Code:
    https://github.com/Internalizable/CraftTweet
    Contributors:
    Twitter4J, HikariCP
    Languages Supported:
    Universal
    [​IMG]

    CraftTweet - Connects Twitter Accounts to Minecraft accounts

    [​IMG]
    Overview
    CraftTweet links any player's Minecraft account to Twitter using Twitter4J, making it easier for server owners to interact with their players' social media accounts.

    How does it work?
    CraftTweet authenticates users based on Twitter's OAuth. You'd have to apply for a developer account in order to build an application for your own server. When authenticated on Twitter, users will then receive a pin to confirm ingame.

    Requirements
    • A functioning MySQL database (to store keys).
    • A functioning OAuth app (provided by apps.twitter.com)
    Installation
    First, apply for a developer account using your network's twitter page. After applying for your developer account and gaining access to build applications, head over to your twitter's developer dashboard.

    upload_2021-2-9_23-19-14.png

    Go to your Projects tab, and click Create App under the Standalone apps. Then, configure your app's information and save your API key and API secret key since they will be used in the configuration file (do not share those with anyone!). Assign permissions based on your needs (in most instances it's only Read + Write).

    upload_2021-2-9_23-21-12.png
    Drop CraftTweet.jar into your plugins folder and start your server.

    Configuration
    After starting your sever, head over to your plugin's folder and edit the configuration file.

    Code (YAML):

    mysql
    : # MySQL Server Details, self-explanatory
      host
    : localhost
      port
    : 3306
      database
    : twitter
      username
    : root
      password
    : test
    oauthp
    : somePublicKey # Use your twitter application's API key.
    oauths
    : somePrivateKey # Use your twitter application's API secret key.
    limitHour
    : 15 # Limit how many tweets a user can send in an hour.
    messages
    :
      prefix
    : "&bTwitterLink &8| "
      noperms
    : "&cYou do not have the right to execute this command!"
      unknownformat
    : "&cUnknown format! Use /link to start."
      general
    :
        isLinked
    : "&7Your current Minecraft account is &alinked &7to the Twitter account &a%account%&7!"
        isNotLinked
    : "&7Your current Minecraft account is &cnot linked &7to any Twitter account!\n&7Use &a/link create &7to start the linking process."
      link
    :
        success
    : "&aYou have succesfully linked your twitter account with your Minecraft account!"
        url
    : "&7Please click the following link to authenticate your twitter account with your Minecraft account\n&a%url%\n&7Use your &aPIN &7using /link confirm &aPIN &7to initiate the link."
      error
    :
        token
    : "&cThe giving token is wrong, please try again!"
        norequest
    : "&cYou have to iniate a linkage request before confirming!"
        notlinked
    : "&cYou do not have a twitter account linked!"
        alreadylinked
    : "&7You already have a twitter account linked!"
     
    • %url% is substituted with the authentication URL.
    • %account% is substituted with the user's account name.
    Commands
    In order to link a Twitter account, the permission link.use should be applied.
    • /link - Initial command.
    • /link create - Fetches an authorization URL for authentication.
    • /link confirm [PIN] - Confirms the PIN given when authenticated.
    Additionally, this command can ONLY be executed by console.
    • /link tweet [USERNAME] [TWEET] - Tweets the given message of an ONLINE (has to be online) user if he has a Twitter account linked to his twitter account.
    For Developers
    CraftTweet has it's own API based on CompletableFutures and it's own queuing system.

    Code (Java):
    Player p;[/SIZE]
    String tweet = "Hello World!";[/SIZE]
    [SIZE=6][SIZE=4]if(TwitterCache.doesTwitterExist(p.getUniqueId().toString())) { // Checks if a player has a twitter account linked.[/SIZE][/SIZE]
    [SIZE=6][SIZE=4]TwitterPlayer twitterPlayer = TwitterCache.getPlayer(p.getUniqueId().toString()); // Get his twitter factory instance.[/SIZE][/SIZE]
    [SIZE=6][SIZE=4]QueueManager.addToQueue(twitterPlayer, tweet); // Queue his tweet.[/SIZE][/SIZE]
    [SIZE=6][SIZE=4]}


    If you would like to bypass the Queue, take a look at TwitterAPI's github page based on CompletableFutures


    Feedback
    If you encounter any errors or issues, or have any feedback please do so by either sending me a direct message or replying to this resource's thread.


    To-Do List



      • BungeeCord / Redis support.
      • More extensive API.
      • Interactive PIN confirmations.
      • Callback urls (OPTIONAL)