Skip to content

Latest commit

 

History

History
92 lines (79 loc) · 3.41 KB

README.md

File metadata and controls

92 lines (79 loc) · 3.41 KB

UUIDCache offers an easy way to store minecraft player uuid's into an redis database and automatically cache them.

How to setup the plugin?

First install the redis-server:

sudo apt-get install redis-server or for CentOS, OpenSUSE or other distributions: yum install redis-server

Then put the plugin on your server and edit the config file:

RedisHost: 127.0.0.1 //The redis host RedisPort: 6379 //The redis port AuthUsingPassword: false //If you have a password set for your redis server RedisPassword: MyPassword //The password. CacheEntryExpire: 7200 //The time in seconds after the uuid cache entry will expire and removed from redis.

There is an API for UUIDCache:

Get the uuid:

package de.fileinputstream.uuidcache.commands;
import de.fileinputstream.uuidcache.UUIDCacheBootstrap;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
/**
 * This class has been generated by Alexander on 30.04.18 17:35
 * You are not allowed to edit this resource or other components of it
 * © 2018 Alexander Fiedler
 */
public class CommandUUID implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        if(commandSender.isOp()) {
            if(strings.length == 1) {
                String player = strings[0];
                 UUIDCacheBootstrap.getInstance().getUuidCache().getUUID(player, s1 -> commandSender.sendMessage(ChatColor.GREEN + "UUID of " + player + " is: " + s1));
                 //Do something with the uuid.
            } else {
                commandSender.sendMessage(ChatColor.DARK_RED + "§bPlease use /uuid <Name>");
                return true;
            }
        }
        return false;
    }
}

Evict an uuid:

package de.fileinputstream.uuidcache.commands;

import de.fileinputstream.uuidcache.UUIDCacheBootstrap;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

/**
 * This class has been generated by Alexander on 30.04.18 18:06
 * You are not allowed to edit this resource or other components of it
 * © 2018 Alexander Fiedler
 */
public class CommandUncacheUUID implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        if(commandSender.isOp()) {
            if(strings.length == 1) {
                String name = strings[0];
                if((UUIDCacheBootstrap.getInstance().getRedisManager().getJedis().exists("uuidcache:" + name.toLowerCase() ))) {
                    UUIDCacheBootstrap.getInstance().getUuidCache().getUUID(name, s1 -> {
                        UUIDCacheBootstrap.getInstance().getUuidCache().uncacheUUID(name);
                        commandSender.sendMessage(ChatColor.GREEN + "This uuid has been uncached now!");

                    });

                } else {
                    commandSender.sendMessage(ChatColor.DARK_RED + "This uuid hasn't been cached yet.");
                    return true;
                }
            } else {
                commandSender.sendMessage(ChatColor.DARK_RED + "§bPlease use /uncacheuuid <Name>");
                return true;
            }

        }
        return false;
    }
}

Please take a look at the javadoc at : https://fileinputstream.github.io/UUIDCache/docs/