...
 
Commits (2)
No preview for this file type
# Random ID
This plugin generates random IDs and UUIDs via placeholders or via commands. It can also display the UUID of a player via placeholder or via command.
## Features:
- Generate random IDs via Command or via Placeholder
- Generate random UUIDs via Command or via Placeholder
- Get your own UUID via Command or via Placeholder
- Get the UUID of a player via Command
- PlaceHolderAPI Support
- Config
- Messages are completely editable
- Permissions
- In-game commands
- Multi-version support
- Open-Source
- Support
## Commands:
- `/uuid`
- Get your own UUID
- `/uuid <player>`
- Get the UUID of a player
- `/randomid`
- Get a random ID
- `/randomid <length>`
- Get a random ID in a certain length
- `/randomid reload`
- Reload the config file
- `/randomuuid`
- Get a random UUID
## Placeholders (with PlaceholderAPI):
- Get a random ID
- `%RandomID_id%`
- Get a random ID with Chat Message
- `%RandomID_id-msg%`
- Get a random ID in a certain length
- `%RandomID_id-<length>%`
- Get a random ID in a certain length with Chat Message
- `%RandomID_id-<length>-msg%`
- Get a random UUID
- `%RandomID_uuid%`
- Get a random UUID with Chat Message
- `%RandomID_uuid-msg%`
- Get your own UUID
- `%RandomID_player_uuid%`
- Get your own UUID with Chat Message
- `%RandomID_player_uuid-msg%`
- Get the UUID of a player
- `%RandomID_player_uuid-<player>%`
- Get the UUID of a player with Chat Message
- `%RandomID_player_uuid-<player>-msg%`
## Permissions:
- `RandomID.reload`
- `/randomid reload`
- `RandomID.ID.random`
- `/randomid`
- `/randomid <length>`
- `RandomID.UUID.self`
- `/uuid`
- `RandomID.UUID.other`
- `/uuid player`
- `RandomID.UUID.random`
- `/randomuuid`
## Links:
- Sites: [>> GitLab <<](https://gitlab.com/hampoelz/RandomID)
- Support: [>> GitLab <<](https://gitlab.com/hampoelz/RandomID/issues)
- Releases: [>> GitLab <<](https://gitlab.com/hampoelz/RandomID/tags)
# Random ID
This plugin generates random IDs and UUIDs via placeholders or via commands. It can also display the UUID of a player via placeholder or via command.
## Features:
- Generate random IDs via Command or via Placeholder
- Generate random UUIDs via Command or via Placeholder
- Get your own UUID via Command or via Placeholder
- Get the UUID of a player via Command
- PlaceHolderAPI Support
- Config
- Messages are completely editable
- Permissions
- In-game commands
- Multi-version support
- Open-Source
- Support
## Commands:
- `/id`
- Get your Personal UUID (if enabled)
- `/id <player>`
- Get the Personal UUID of a player (if enabled)
- `/uuid`
- Get your own UUID
- `/uuid <player>`
- Get the UUID of a player
- `/randomid`
- Get a random ID
- `/randomid <length>`
- Get a random ID in a certain length
- `/randomid reload`
- Reload the config file
- `/randomuuid`
- Get a random UUID
## Placeholders (with PlaceholderAPI):
- Get a random ID
- `%RandomID_id%`
- Get a random ID with Chat Message
- `%RandomID_id-msg%`
- Get a random ID in a certain length
- `%RandomID_id-<length>%`
- Get a random ID in a certain length with Chat Message
- `%RandomID_id-<length>-msg%`
- Get a random UUID
- `%RandomID_uuid%`
- Get a random UUID with Chat Message
- `%RandomID_uuid-msg%`
- Get your Personal ID
- `%RandomID_personal_id%`
- Get your Personal ID with Chat Message
- `%RandomID_personal_id-msg%`
- Get the Personal ID of a player
- `%RandomID_personal_id-<player>%`
- Get the Personal ID of a player with Chat Message
- `%RandomID_personal_id-<player>-msg%`
- Get your own UUID
- `%RandomID_player_uuid%`
- Get your own UUID with Chat Message
- `%RandomID_player_uuid-msg%`
- Get the UUID of a player
- `%RandomID_player_uuid-<player>%`
- Get the UUID of a player with Chat Message
- `%RandomID_player_uuid-<player>-msg%`
## Permissions:
- `RandomID.reload`
- `/randomid reload`
- `RandomID.ID.random`
- `/randomid`
- `/randomid <length>`
- `RandomID.UUID.self`
- `/uuid`
- `RandomID.UUID.other`
- `/uuid player`
- `RandomID.UUID.random`
- `/randomuuid`
## Links:
- Sites: [>> GitLab <<](https://gitlab.com/hampoelz/RandomID)
- Support: [>> GitLab <<](https://gitlab.com/hampoelz/RandomID/issues)
- Releases: [>> GitLab <<](https://gitlab.com/hampoelz/RandomID/tags)
- License: [>> MIT License <<](https://gitlab.com/hampoelz/RandomID/blob/master/LICENSE)
\ No newline at end of file
name: RandomID
version: 1.3
author: Rene Hampoelz
website: hampoelz.net
main: net.hampoelz.RandomID.Main.Main
softdepend: [PlaceholderAPI]
commands:
uuid:
usage: /uuid [player]
description: Get the UUID [from a Player]
randomid:
usage: /RandomID [length / reload]
description: Get a random ID [in a certain length] / reload the config file
randomuuid:
usage: /RandomUUID
description: Get a random UUID
permissions:
RandomID.*:
children:
RandomID.ID.*: true
RandomID.UUID.*: true
RandomID.reload: true
RandomID.ID.*:
children:
RandomID.ID.random: true
RandomID.UUID.*:
children:
RandomID.UUID.self: true
RandomID.UUID.other: true
RandomID.UUID.random: true
\ No newline at end of file
name: RandomID
version: 1.4
author: Rene Hampoelz
website: hampoelz.net
main: net.hampoelz.RandomID.Main.Main
softdepend: [PlaceholderAPI]
commands:
id:
usage: /id [player]
description: Get your Personal ID [from a Player]
aliases: [personalid, myid]
uuid:
usage: /uuid [player]
description: Get the UUID [from a Player]
randomid:
usage: /RandomID [length / reload]
description: Get a random ID [in a certain length] / reload the config file
randomuuid:
usage: /RandomUUID
description: Get a random UUID
permissions:
RandomID.*:
children:
RandomID.ID.*: true
RandomID.UUID.*: true
RandomID.PersonalID.*: true
RandomID.reload: true
RandomID.ID.*:
children:
RandomID.ID.random: true
RandomID.UUID.*:
children:
RandomID.UUID.self: true
RandomID.UUID.other: true
RandomID.UUID.random: true
RandomID.PersonalID.*:
children:
RandomID.PersonalID.self: true
RandomID.PersonalID.other: true
\ No newline at end of file
......@@ -6,7 +6,7 @@ import java.util.UUID;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.hampoelz.RandomID.Main.Config;
import net.hampoelz.RandomID.Configs.Config;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
......@@ -66,19 +66,19 @@ public class GeneratorAPI
return uuid;
}
public static void SendMSGPlayer(Player p, String ID, String Name, String Info, String Hover)
public static void SendMSGPlayer(Player p, String Content, String Name, String Info, String Hover)
{
TextComponent line1 = new TextComponent();
line1.setText(Name);
line1.setText(ChatColor.translateAlternateColorCodes('&', Name));
line1.setColor(ChatColor.BLUE);
line1.setBold(true);
TextComponent line1_id = new TextComponent();
line1_id.setText(ID);
line1_id.setText(ChatColor.translateAlternateColorCodes('&', Content));
line1_id.setColor(ChatColor.GOLD);
line1_id.setBold(true);
line1_id.setClickEvent(new ClickEvent(Action.SUGGEST_COMMAND, ID));
line1_id.setHoverEvent(new HoverEvent(net.md_5.bungee.api.chat.HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', Hover)).create()));
line1_id.setClickEvent(new ClickEvent(Action.SUGGEST_COMMAND, Content));
line1_id.setHoverEvent(new HoverEvent(net.md_5.bungee.api.chat.HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', "&a&l" + Hover)).create()));
line1.addExtra(line1_id);
......@@ -90,11 +90,11 @@ public class GeneratorAPI
p.sendMessage("");
}
public static void SendMSGConsole(CommandSender sender, String ID, String Name, String Info)
public static void SendMSGConsole(CommandSender sender, String Content, String Name, String Info)
{
sender.sendMessage("");
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&l-----------------------------------------"));
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&9&l" + Name + "&6&l" + ID));
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&9&l" + Name + "&6&l" + Content));
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&a&l" + Info));
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&l-----------------------------------------"));
sender.sendMessage("");
......
package net.hampoelz.RandomID.Commands;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import net.hampoelz.RandomID.API.GeneratorAPI;
import net.hampoelz.RandomID.Configs.Config;
import net.hampoelz.RandomID.Configs.PersonalID;
import net.md_5.bungee.api.ChatColor;
public class ID implements CommandExecutor
{
@SuppressWarnings("deprecation")
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
{
if (Config.getPersonalIDUse())
{
if (sender instanceof ConsoleCommandSender)
{
if (args.length == 1)
{
OfflinePlayer op = Bukkit.getOfflinePlayer(args[0]);
if (PersonalID.getPlayerID(op.getUniqueId()) != null)
{
GeneratorAPI.SendMSGConsole(sender, PersonalID.getPlayerID(op.getUniqueId()), Config.getPersonalIDMessagesPlayerIDName().replace("%player%", op.getName()), Config.getPersonalIDMessagesPlayerIDInfo().replace("%player%", op.getName()));
}
else
{
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.getPersonalIDMessagesNoIDPlayer()));
}
}
else
{
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7Usage: &cid <player>"));
}
}
if (sender instanceof Player)
{
Player p = (Player) sender;
if (args.length == 0)
{
if (p.hasPermission("RandomID.PersonalID.self"))
{
if (PersonalID.getPlayerID(p.getUniqueId()) != null)
{
GeneratorAPI.SendMSGPlayer(p, PersonalID.getPlayerID(p.getUniqueId()), Config.getPersonalIDMessagesOwnIDName(), Config.getPersonalIDMessagesOwnIDInfo(), "Click to copy your ID in your chat");
}
else
{
p.kickPlayer(ChatColor.translateAlternateColorCodes('&', Config.getPersonalIDMessagesNoIDKick()));
}
}
else
{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.getMessagesNoPermissions()));
}
}
else if (args.length == 1)
{
OfflinePlayer op = Bukkit.getOfflinePlayer(args[0]);
if (p.hasPermission("RandomID.PersonalID.other"))
{
if (op == null)
{
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.getMessagesPlayerNotExist()));
}
else if(op == p)
{
if (p.hasPermission("RandomID.PersonalID.self"))
{
if (PersonalID.getPlayerID(p.getUniqueId()) != null)
{
GeneratorAPI.SendMSGPlayer(p, PersonalID.getPlayerID(p.getUniqueId()), Config.getPersonalIDMessagesOwnIDName(), Config.getPersonalIDMessagesOwnIDInfo(), "Click to copy your ID in your chat");
}
else
{
p.kickPlayer(ChatColor.translateAlternateColorCodes('&', Config.getPersonalIDMessagesNoIDKick()));
}
}
else
{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.getMessagesNoPermissions()));
}
}
else
{
if (PersonalID.getPlayerID(op.getUniqueId()) != null)
{
GeneratorAPI.SendMSGPlayer(p, PersonalID.getPlayerID(op.getUniqueId()), Config.getPersonalIDMessagesPlayerIDName().replace("%player%", op.getName()), Config.getPersonalIDMessagesPlayerIDInfo().replace("%player%", op.getName()), "Click to copy " + op.getName() + "'s ID in your chat");
}
else
{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.getPersonalIDMessagesNoIDPlayer()));
}
}
}
else
{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.getMessagesNoPermissions()));
}
}
else
{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.getPersonalIDMessagesUsage()));
}
}
}
else
{
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.getMessagesModuleDisabled()));
}
return true;
}
}
......@@ -10,7 +10,8 @@ import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.entity.Player;
import net.hampoelz.RandomID.API.GeneratorAPI;
import net.hampoelz.RandomID.Main.Config;
import net.hampoelz.RandomID.Configs.Config;
import net.hampoelz.RandomID.Configs.PersonalID;
import net.md_5.bungee.api.ChatColor;
public class RandomID implements CommandExecutor
......@@ -37,6 +38,20 @@ public class RandomID implements CommandExecutor
{
Config.load();
if (Config.getPersonalIDUse())
{
try
{
PersonalID.save();
}
catch (IOException e)
{
e.printStackTrace();
}
PersonalID.load();
}
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&aThe config was successfully reloaded"));
}
catch (IOException | InvalidConfigurationException e)
......@@ -93,6 +108,20 @@ public class RandomID implements CommandExecutor
{
Config.load();
if (Config.getPersonalIDUse())
{
try
{
PersonalID.save();
}
catch (IOException e)
{
e.printStackTrace();
}
PersonalID.load();
}
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8[&6RandomID&8] &aThe config was successfully reloaded"));
}
catch (IOException | InvalidConfigurationException e)
......
......@@ -7,7 +7,7 @@ import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import net.hampoelz.RandomID.API.GeneratorAPI;
import net.hampoelz.RandomID.Main.Config;
import net.hampoelz.RandomID.Configs.Config;
import net.md_5.bungee.api.ChatColor;
public class RandomUUID implements CommandExecutor
......
......@@ -9,7 +9,7 @@ import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import net.hampoelz.RandomID.API.GeneratorAPI;
import net.hampoelz.RandomID.Main.Config;
import net.hampoelz.RandomID.Configs.Config;
import net.md_5.bungee.api.ChatColor;
public class UUID implements CommandExecutor
......@@ -18,23 +18,24 @@ public class UUID implements CommandExecutor
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
{
Player p = (Player) sender;
OfflinePlayer op = Bukkit.getOfflinePlayer(args[0]);
if (sender instanceof ConsoleCommandSender)
{
if (args.length == 1)
{
OfflinePlayer op = Bukkit.getOfflinePlayer(args[0]);
GeneratorAPI.SendMSGConsole(sender, op.getUniqueId().toString(), Config.getMessagesPlayerUUIDName().replace("%player%", op.getName()), Config.getMessagesPlayerUUIDInfo().replace("%player%", op.getName()));
}
else
{
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7Usage: &cuuid <player>"));
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7Usage: &cid <player>"));
}
}
if (sender instanceof Player)
{
Player p = (Player) sender;
if (args.length == 0)
{
if (p.hasPermission("RandomID.UUID.self"))
......@@ -48,6 +49,8 @@ public class UUID implements CommandExecutor
}
else if (args.length == 1)
{
OfflinePlayer op = Bukkit.getOfflinePlayer(args[0]);
if (p.hasPermission("RandomID.UUID.other"))
{
if (op == null)
......
package net.hampoelz.RandomID.Configs;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
public class Config
{
public static File ConfigFile = new File("plugins/RandomID", "config.yml");
public static FileConfiguration Config = YamlConfiguration.loadConfiguration(ConfigFile);
//----------------------------------------------------------------------------------------------------------------------\\
public static void save() throws IOException
{
Config.save(ConfigFile);
}
public static void load() throws FileNotFoundException, IOException, InvalidConfigurationException
{
Config.load(ConfigFile);
}
private static void setConfigContent(int ConfigVersion) throws IOException
{
Config.set("config.ConfigVersion", ConfigVersion);
Config.set("config.Messages.No Permissions", "&8[&6RandomID&8] &cYou not have permission to perform this command.");
Config.set("config.Messages.Usage", "&8[&6RandomID&8] &7Usages:\n &c/uuid [player]\n &c/randomuuid\n &c/randomid [length / reload]");
Config.set("config.Messages.Player not exist", "&8[&6RandomID&8] &cApparently, the specified player does not exist.");
Config.set("config.Messages.Module Disabled", "&8[&6RandomID&8] &cSorry, this module is disabled.");
Config.set("config.Messages.Random ID.Name", "&9&lRandom ID: ");
Config.set("config.Messages.Random ID.Info", "&5&lThis is a randomly generated ID");
Config.set("config.Messages.Random UUID.Name", "&9&lRandom UUID: ");
Config.set("config.Messages.Random UUID.Info", "&5&lThis is a randomly generated UUID");
Config.set("config.Messages.Own UUID.Name", "&9&lYour UUID: ");
Config.set("config.Messages.Own UUID.Info", "&5&lThis is your UUID");
Config.set("config.Messages.Player UUID.Name", "&9&l%player%'s UUID: ");
Config.set("config.Messages.Player UUID.Info", "&5&lThis is %player%'s UUID");
Config.set("config.Settings.ID chars", "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
Config.set("config.Settings.ID length", 9);
Config.set("config.Personal ID.Use", false);
Config.set("config.Personal ID.Messages.Own ID.Name", "&9&lYour Personal ID: ");
Config.set("config.Personal ID.Messages.Own ID.Info", "&5&lThis is your Personal ID, you can use it for support, reports, etc.");
Config.set("config.Personal ID.Messages.Player ID.Name", "&9&l%player%'s Personal ID: ");
Config.set("config.Personal ID.Messages.Player ID.Info", "&5&lThis is %player%'s Personal ID.");
Config.set("config.Personal ID.Messages.Usage", "&8[&6Personal ID&8] &7Usage: &c/id [player]");
Config.set("config.Personal ID.Messages.No ID Kick", "&6Please rejoin to generate your ID.");
Config.set("config.Personal ID.Messages.No ID Player", "&8[&6Personal ID&8] &cThis player does not have an ID yet");
Config.set("config.Personal ID.Settings.ID chars", "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
Config.set("config.Personal ID.Settings.ID length", 9);
save();
}
public static void setConfig() throws IOException
{
int ConfigVersion = 4;
int Version = Config.getInt("config.ConfigVersion");
if(!ConfigFile.exists())
{
setConfigContent(ConfigVersion);
}
else if (Version != ConfigVersion)
{
File ConfigFileBackup = new File("plugins/RandomID", "old config [v" + Version + "].yml");
FileUtils.copyFile(ConfigFile, ConfigFileBackup);
for (String key : Config.getKeys(false))
{
Config.set(key, null);
}
save();
setConfigContent(ConfigVersion);
}
}
//----------------------------------------------------------------------------------------------------------------------\\
public static String getMessagesNoPermissions()
{
return Config.getString("config.Messages.No Permissions");
}
public static String getMessagesUsage()
{
return Config.getString("config.Messages.Usage");
}
public static String getMessagesModuleDisabled()
{
return Config.getString("config.Messages.Module Disabled");
}
public static String getMessagesPlayerNotExist()
{
return Config.getString("config.Messages.Player not exist");
}
public static String getMessagesRandomIDName()
{
return Config.getString("config.Messages.Random ID.Name");
}
public static String getMessagesRandomIDInfo()
{
return Config.getString("config.Messages.Random ID.Info");
}
public static String getMessagesRandomUUIDName()
{
return Config.getString("config.Messages.Random UUID.Name");
}
public static String getMessagesRandomUUIDInfo()
{
return Config.getString("config.Messages.Random UUID.Info");
}
public static String getMessagesOwnUUIDName()
{
return Config.getString("config.Messages.Own UUID.Name");
}
public static String getMessagesOwnUUIDInfo()
{
return Config.getString("config.Messages.Own UUID.Info");
}
public static String getMessagesPlayerUUIDName()
{
return Config.getString("config.Messages.Player UUID.Name");
}
public static String getMessagesPlayerUUIDInfo()
{
return Config.getString("config.Messages.Player UUID.Info");
}
public static String getSettingsIDchars()
{
return Config.getString("config.Settings.ID chars");
}
public static int getSettingsIDlength()
{
return Config.getInt("config.Settings.ID length");
}
//----------------------------------------------------------------------------------------------------------------------\\
public static Boolean getPersonalIDUse()
{
return Config.getBoolean("config.Personal ID.Use");
}
public static String getPersonalIDMessagesOwnIDName()
{
return Config.getString("config.Personal ID.Messages.Own ID.Name");
}
public static String getPersonalIDMessagesOwnIDInfo()
{
return Config.getString("config.Personal ID.Messages.Own ID.Info");
}
public static String getPersonalIDMessagesPlayerIDName()
{
return Config.getString("config.Personal ID.Messages.Player ID.Name");
}
public static String getPersonalIDMessagesPlayerIDInfo()
{
return Config.getString("config.Personal ID.Messages.Player ID.Info");
}
public static String getPersonalIDMessagesUsage()
{
return Config.getString("config.Personal ID.Messages.Usage");
}
public static String getPersonalIDMessagesNoIDKick()
{
return Config.getString("config.Personal ID.Messages.No ID Kick");
}
public static String getPersonalIDMessagesNoIDPlayer()
{
return Config.getString("config.Personal ID.Messages.No ID Player");
}
/*
public static Boolean getPersonalIDSettingsUseMySQL()
{
return Config.getBoolean("config.Personal ID.Settings.Use MySQL");
}
*/
public static String getPersonalIDSettingsIDchars()
{
return Config.getString("config.Personal ID.Settings.ID chars");
}
public static int getPersonalIDSettingsIDlength()
{
return Config.getInt("config.Personal ID.Settings.ID length");
}
}
package net.hampoelz.RandomID.Configs;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.UUID;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
public class PersonalID
{
public static File PersonalIDFile = new File("plugins/RandomID", "PersonalID.yml");
public static FileConfiguration PersonalID = YamlConfiguration.loadConfiguration(PersonalIDFile);
//----------------------------------------------------------------------------------------------------------------------\\
public static void save() throws IOException
{
PersonalID.save(PersonalIDFile);
}
public static void load() throws FileNotFoundException, IOException, InvalidConfigurationException
{
PersonalID.load(PersonalIDFile);
}
//----------------------------------------------------------------------------------------------------------------------\\
public static void setPlayerID(UUID uuid, String id) throws IOException
{
PersonalID.set(uuid.toString(), id);
save();
}
//----------------------------------------------------------------------------------------------------------------------\\
public static String getPlayerID(UUID uuid)
{
return PersonalID.getString(uuid.toString());
}
}
package net.hampoelz.RandomID.Events;
import java.io.IOException;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import net.hampoelz.RandomID.API.GeneratorAPI;
import net.hampoelz.RandomID.Configs.Config;
import net.hampoelz.RandomID.Configs.PersonalID;
public class JoinEvent implements Listener
{
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) throws IOException, InvalidConfigurationException
{
if (Config.getPersonalIDUse())
{
PersonalID.setPlayerID(event.getPlayer().getUniqueId(), GeneratorAPI.IDGenerator(Config.getPersonalIDSettingsIDlength(), Config.getPersonalIDSettingsIDchars()));
}
}
}
This diff is collapsed.
......@@ -5,9 +5,13 @@ import java.io.IOException;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import net.hampoelz.RandomID.Commands.ID;
import net.hampoelz.RandomID.Commands.RandomID;
import net.hampoelz.RandomID.Commands.RandomUUID;
import net.hampoelz.RandomID.Commands.UUID;
import net.hampoelz.RandomID.Configs.Config;
import net.hampoelz.RandomID.Configs.PersonalID;
import net.hampoelz.RandomID.Events.JoinEvent;
public class Main extends JavaPlugin
{
......@@ -32,6 +36,20 @@ public class Main extends JavaPlugin
e.printStackTrace();
}
if (Config.getPersonalIDUse())
{
try
{
PersonalID.save();
}
catch (IOException e)
{
e.printStackTrace();
}
}
Bukkit.getPluginManager().registerEvents(new JoinEvent(), this);
getCommands();
instance = this;
......@@ -52,6 +70,10 @@ public class Main extends JavaPlugin
private void getCommands()
{
getCommand("id").setExecutor(new ID());
getCommand("personalid").setExecutor(new ID());
getCommand("myid").setExecutor(new ID());
getCommand("uuid").setExecutor(new UUID());
getCommand("randomid").setExecutor(new RandomID());
getCommand("randomuuid").setExecutor(new RandomUUID());
......
......@@ -6,6 +6,9 @@ import org.bukkit.entity.Player;
import me.clip.placeholderapi.external.EZPlaceholderHook;
import net.hampoelz.RandomID.API.GeneratorAPI;
import net.hampoelz.RandomID.Configs.Config;
import net.hampoelz.RandomID.Configs.PersonalID;
import net.md_5.bungee.api.ChatColor;
@SuppressWarnings("deprecation")
public class Placeholder extends EZPlaceholderHook
......@@ -37,58 +40,79 @@ public class Placeholder extends EZPlaceholderHook
}
}
if (identifier.equals("id"))
{
String ID = GeneratorAPI.IDGenerator(Config.getSettingsIDlength(), Config.getSettingsIDchars());
return ID;
}
else if (identifier.equals("id-msg"))
if (identifier.equals("personal_id"))
{
String ID = GeneratorAPI.IDGenerator(Config.getSettingsIDlength(), Config.getSettingsIDchars());
if (p != null)
if (Config.getPersonalIDUse())
{
GeneratorAPI.SendMSGPlayer(p, ID, Config.getMessagesRandomIDName(), Config.getMessagesRandomIDInfo(), "Click to copy this ID in your chat");
if (PersonalID.getPlayerID(p.getUniqueId()) != null)
{
return PersonalID.getPlayerID(p.getUniqueId());
}
else
{
p.kickPlayer(ChatColor.translateAlternateColorCodes('&', Config.getPersonalIDMessagesNoIDKick()));
}
}
return ID;
return null;
}
else if (identifier.equals("id-" + length))
if (identifier.equals("personal_id-msg"))
{
String ID = GeneratorAPI.IDGenerator(length, Config.getSettingsIDchars());
if (Config.getPersonalIDUse())
{
if (PersonalID.getPlayerID(p.getUniqueId()) != null)
{
GeneratorAPI.SendMSGPlayer(p, PersonalID.getPlayerID(p.getUniqueId()), Config.getPersonalIDMessagesOwnIDName(), Config.getPersonalIDMessagesOwnIDInfo(), "Click to copy your ID in your chat");
return PersonalID.getPlayerID(p.getUniqueId());
}
else
{
p.kickPlayer(ChatColor.translateAlternateColorCodes('&', Config.getPersonalIDMessagesNoIDKick()));
}
}
return ID;
return null;
}
else if (identifier.equals("id-" + length + "-msg"))
if (identifier.equals("personal_id-" + op.getName()))
{
String ID = GeneratorAPI.IDGenerator(length, Config.getSettingsIDchars());
if (p != null)
if (Config.getPersonalIDUse())
{
GeneratorAPI.SendMSGPlayer(p, ID, Config.getMessagesRandomIDName(), Config.getMessagesRandomIDInfo(), "Click to copy this ID in your chat");
if (PersonalID.getPlayerID(op.getUniqueId()) != null)
{
return PersonalID.getPlayerID(op.getUniqueId());
}
else
{
return " ";
}
}
return ID;
return null;
}
else if (identifier.equals("uuid"))
{
String UUID = GeneratorAPI.UUIDGenerator();
return UUID;
}
else if (identifier.equals("uuid-msg"))
if (identifier.equals("personal_id-" + op.getName() + "-msg"))
{
String UUID = GeneratorAPI.UUIDGenerator();
if (p != null)
if (Config.getPersonalIDUse())
{
GeneratorAPI.SendMSGPlayer(p, UUID, Config.getMessagesRandomUUIDName(), Config.getMessagesRandomUUIDInfo(), "Click to copy this UUID in your chat");
if (PersonalID.getPlayerID(op.getUniqueId()) != null)
{
GeneratorAPI.SendMSGPlayer(p, PersonalID.getPlayerID(op.getUniqueId()), Config.getPersonalIDMessagesPlayerIDName().replace("%player%", op.getName()), Config.getPersonalIDMessagesPlayerIDInfo().replace("%player%", op.getName()), "Click to copy " + op.getName() + "'s ID in your chat");
return PersonalID.getPlayerID(op.getUniqueId());
}
else
{
return " ";
}
}
return UUID;
return null;
}
else if (identifier.equals("player_uuid"))
if (identifier.equals("player_uuid"))
{
if (p != null)
{
......@@ -96,8 +120,11 @@ public class Placeholder extends EZPlaceholderHook
return UUID;
}
return null;
}
else if (identifier.equals("player_uuid-msg"))
if (identifier.equals("player_uuid-msg"))
{
String UUID = p.getUniqueId().toString();
......@@ -108,13 +135,15 @@ public class Placeholder extends EZPlaceholderHook
return UUID;
}
else if (identifier.equals("player_uuid-" + op.getName()))
if (identifier.equals("player_uuid-" + op.getName()))
{
String UUID = op.getUniqueId().toString();
return UUID;
}
else if (identifier.equals("player_uuid-" + op.getName() + "-msg"))
if (identifier.equals("player_uuid-" + op.getName() + "-msg"))
{
String UUID = op.getUniqueId().toString();
......@@ -122,7 +151,64 @@ public class Placeholder extends EZPlaceholderHook
return UUID;
}
if (identifier.equals("id"))
{
String ID = GeneratorAPI.IDGenerator(Config.getSettingsIDlength(), Config.getSettingsIDchars());
return ID;
}
if (identifier.equals("id-msg"))
{
String ID = GeneratorAPI.IDGenerator(Config.getSettingsIDlength(), Config.getSettingsIDchars());
if (p != null)
{
GeneratorAPI.SendMSGPlayer(p, ID, Config.getMessagesRandomIDName(), Config.getMessagesRandomIDInfo(), "Click to copy this ID in your chat");
}
return ID;
}
if (identifier.equals("id-" + length))
{
String ID = GeneratorAPI.IDGenerator(length, Config.getSettingsIDchars());
return ID;
}
if (identifier.equals("id-" + length + "-msg"))
{
String ID = GeneratorAPI.IDGenerator(length, Config.getSettingsIDchars());
if (p != null)
{
GeneratorAPI.SendMSGPlayer(p, ID, Config.getMessagesRandomIDName(), Config.getMessagesRandomIDInfo(), "Click to copy this ID in your chat");
}
return ID;
}
if (identifier.equals("uuid"))
{
String UUID = GeneratorAPI.UUIDGenerator();
return UUID;
}
if (identifier.equals("uuid-msg"))
{
String UUID = GeneratorAPI.UUIDGenerator();
if (p != null)
{
GeneratorAPI.SendMSGPlayer(p, UUID, Config.getMessagesRandomUUIDName(), Config.getMessagesRandomUUIDInfo(), "Click to copy this UUID in your chat");
}
return UUID;
}
return null;
}
}