This commit is contained in:
parent
7bf46692dc
commit
1ef050793e
|
@ -1,8 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<classpath>
|
|
||||||
<classpathentry kind="src" path="src"/>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
|
||||||
<classpathentry kind="lib" path="C:/Development/Plugins.rar/Plugins.rar/Server/plugins/WorldEdit/Vault.jar"/>
|
|
||||||
<classpathentry kind="lib" path="C:/Development/Plugins.rar/Plugins.rar/Server/paperspigot.jar"/>
|
|
||||||
<classpathentry kind="output" path="bin"/>
|
|
||||||
</classpath>
|
|
|
@ -1,17 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>Typa (Authentication)</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
|
@ -1,11 +0,0 @@
|
||||||
eclipse.preferences.version=1
|
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
|
||||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
|
||||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
|
||||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
|
||||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
|
||||||
org.eclipse.jdt.core.compiler.source=1.8
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,6 +0,0 @@
|
||||||
host: '127.0.0.1'
|
|
||||||
port: 3306
|
|
||||||
username: 'root'
|
|
||||||
password: 'password'
|
|
||||||
database: 'login'
|
|
||||||
table: 'login_data'
|
|
|
@ -1,9 +0,0 @@
|
||||||
name: Typa
|
|
||||||
version: 1.0
|
|
||||||
main: net.rifthq.typa.Typa
|
|
||||||
author: [puttydotexe, CoderSYD]
|
|
||||||
commands:
|
|
||||||
register:
|
|
||||||
description: Register Account!
|
|
||||||
login:
|
|
||||||
description: Login to Account!
|
|
|
@ -1,213 +0,0 @@
|
||||||
package net.rifthq.typa;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.DriverManager;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.plugin.PluginManager;
|
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.milkbowl.vault.permission.Permission;
|
|
||||||
import net.rifthq.typa.listeners.PlayerBuildListeners;
|
|
||||||
import net.rifthq.typa.listeners.PlayerCommandListener;
|
|
||||||
import net.rifthq.typa.listeners.PlayerDamageListener;
|
|
||||||
import net.rifthq.typa.listeners.PlayerIntractListener;
|
|
||||||
import net.rifthq.typa.listeners.PlayerJoinListener;
|
|
||||||
import net.rifthq.typa.listeners.PlayerLeaveListener;
|
|
||||||
import net.rifthq.typa.listeners.PlayerMoveListener;
|
|
||||||
import net.rifthq.typa.managers.MySQL;
|
|
||||||
|
|
||||||
public class Typa extends JavaPlugin
|
|
||||||
{
|
|
||||||
private static Typa instance;
|
|
||||||
public static ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
|
|
||||||
public static PluginManager pm = Bukkit.getServer().getPluginManager();
|
|
||||||
public String host;
|
|
||||||
public String username;
|
|
||||||
public String password;
|
|
||||||
public String database;
|
|
||||||
public String table;
|
|
||||||
public int port;
|
|
||||||
private Connection connection;
|
|
||||||
private static Permission perms = null;
|
|
||||||
public static ArrayList<String> logged_in = new ArrayList();
|
|
||||||
|
|
||||||
public static Typa getInstance()
|
|
||||||
{
|
|
||||||
if (instance == null)
|
|
||||||
{
|
|
||||||
instance = new Typa();
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnable()
|
|
||||||
{
|
|
||||||
instance = this;
|
|
||||||
console.sendMessage(ChatColor.GREEN + "[Typa] Has enabled 100%");
|
|
||||||
this.MySQLSetup();
|
|
||||||
this.getConfig().options().copyDefaults(true);
|
|
||||||
this.saveConfig();
|
|
||||||
setupPermissions();
|
|
||||||
pm.registerEvents(new PlayerMoveListener(), this);
|
|
||||||
pm.registerEvents(new PlayerJoinListener(), this);
|
|
||||||
pm.registerEvents(new PlayerLeaveListener(), this);
|
|
||||||
pm.registerEvents(new PlayerDamageListener(), this);
|
|
||||||
pm.registerEvents(new PlayerBuildListeners(), this);
|
|
||||||
pm.registerEvents(new PlayerCommandListener(), this);
|
|
||||||
pm.registerEvents(new PlayerIntractListener(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisable()
|
|
||||||
{
|
|
||||||
instance = null;
|
|
||||||
this.saveConfig();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (this.connection != null && !this.connection.isClosed())
|
|
||||||
{
|
|
||||||
this.connection.close();
|
|
||||||
console.sendMessage("[Typa] Successfully closed connection to SQL.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MySQLSetup()
|
|
||||||
{
|
|
||||||
this.host = this.getConfig().getString("host");
|
|
||||||
this.port = this.getConfig().getInt("port");
|
|
||||||
this.username = this.getConfig().getString("username");
|
|
||||||
this.password = this.getConfig().getString("password");
|
|
||||||
this.database = this.getConfig().getString("database");
|
|
||||||
this.table = this.getConfig().getString("table");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Typa login = this;
|
|
||||||
synchronized (login)
|
|
||||||
{
|
|
||||||
if (this.getConnection() != null && !this.getConnection().isClosed()) { return; }
|
|
||||||
Class.forName("com.mysql.jdbc.Driver");
|
|
||||||
this.setConnection(DriverManager.getConnection("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database, this.username, this.password));
|
|
||||||
console.sendMessage("[Typa] Successfully connected to SQL.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
Bukkit.getServer().shutdown();
|
|
||||||
}
|
|
||||||
catch (ClassNotFoundException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
Bukkit.getServer().shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Connection getConnection()
|
|
||||||
{
|
|
||||||
return this.connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConnection(Connection connection)
|
|
||||||
{
|
|
||||||
this.connection = connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
|
||||||
{
|
|
||||||
Player p = (Player) sender;
|
|
||||||
if (label.equalsIgnoreCase("register"))
|
|
||||||
{
|
|
||||||
|
|
||||||
if (sender instanceof Player)
|
|
||||||
{
|
|
||||||
if (!sender.hasPermission("rifthq.register"))
|
|
||||||
{
|
|
||||||
sender.sendMessage(ChatColor.RED + "You are already authenticated as a " + Typa.getPermissions().getPrimaryGroup(p) + ".");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1)
|
|
||||||
{
|
|
||||||
if (args[0].length() > 25)
|
|
||||||
{
|
|
||||||
p.sendMessage(ChatColor.RED + "Your password must contain less than 50 characters!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args[0].length() < 5)
|
|
||||||
{
|
|
||||||
p.sendMessage(ChatColor.RED + "Your password must contain more than 5 characters!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
MySQL.registerPlayer(p.getUniqueId(), p, args[0], p.getAddress().getHostName().toString());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p.sendMessage(ChatColor.RED + "/register <password>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sender.sendMessage("Player Only Command!");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (label.equalsIgnoreCase("login"))
|
|
||||||
{
|
|
||||||
if (sender instanceof Player)
|
|
||||||
{
|
|
||||||
if (!sender.hasPermission("rifthq.register"))
|
|
||||||
{
|
|
||||||
sender.sendMessage(ChatColor.RED + "You are already authenticated as a " + Typa.getPermissions().getPrimaryGroup(p) + ".");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (logged_in.contains(p.getName()))
|
|
||||||
{
|
|
||||||
p.sendMessage(ChatColor.RED + "You are already logged in!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1)
|
|
||||||
{
|
|
||||||
MySQL.playerLogin(p.getUniqueId(), p, args[0]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p.sendMessage(ChatColor.RED + "/login <password>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sender.sendMessage("Player Only Command!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean setupPermissions()
|
|
||||||
{
|
|
||||||
RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
|
|
||||||
perms = rsp.getProvider();
|
|
||||||
return perms != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Permission getPermissions()
|
|
||||||
{
|
|
||||||
return perms;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
package net.rifthq.typa.listeners;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.rifthq.typa.Typa;
|
|
||||||
|
|
||||||
public class PlayerBuildListeners implements Listener {
|
|
||||||
@EventHandler
|
|
||||||
public void place(BlockPlaceEvent e) {
|
|
||||||
Player p = e.getPlayer();
|
|
||||||
if (!Typa.logged_in.contains(p.getName()) && p.hasPermission("rifthq.login")) {
|
|
||||||
e.setCancelled(true);
|
|
||||||
p.sendMessage(ChatColor.RED + ("You must login before attempting to placing blocks!"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void breakblock(BlockBreakEvent e) {
|
|
||||||
Player p = e.getPlayer();
|
|
||||||
if (!Typa.logged_in.contains(p.getName()) && p.hasPermission("rifthq.login")) {
|
|
||||||
e.setCancelled(true);
|
|
||||||
p.sendMessage(ChatColor.RED + ("You must login before attempting to breaking blocks!"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
package net.rifthq.typa.listeners;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.rifthq.typa.Typa;
|
|
||||||
|
|
||||||
public class PlayerCommandListener implements Listener {
|
|
||||||
@EventHandler
|
|
||||||
public void on(PlayerCommandPreprocessEvent e) {
|
|
||||||
Player p = e.getPlayer();
|
|
||||||
if (!Typa.logged_in.contains(p.getName()) && p.hasPermission("rifthq.login")) {
|
|
||||||
if (e.getMessage().startsWith("/login")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (e.getMessage().startsWith("/register")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
e.setCancelled(true);
|
|
||||||
p.sendMessage(ChatColor.RED + ("You must login before attempting to execute a command!"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
package net.rifthq.typa.listeners;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|
||||||
|
|
||||||
import net.rifthq.typa.Typa;
|
|
||||||
|
|
||||||
public class PlayerDamageListener implements Listener {
|
|
||||||
@EventHandler
|
|
||||||
public void damager(EntityDamageByEntityEvent e) {
|
|
||||||
Player damager;
|
|
||||||
if (e.getDamager() instanceof Player && !Typa.logged_in.contains((damager = (Player) e.getDamager()).getName())
|
|
||||||
&& damager.hasPermission("rifthq.login")) {
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void victim(EntityDamageByEntityEvent e) {
|
|
||||||
Player player;
|
|
||||||
if (e.getEntity() instanceof Player && !Typa.logged_in.contains((player = (Player) e.getEntity()).getName())
|
|
||||||
&& player.hasPermission("rifthq.login")) {
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
package net.rifthq.typa.listeners;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
|
||||||
|
|
||||||
import net.rifthq.typa.Typa;
|
|
||||||
|
|
||||||
public class PlayerIntractListener implements Listener {
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onInventoryClick(InventoryClickEvent event) {
|
|
||||||
if (event.getClickedInventory() != null) {
|
|
||||||
Player player = (Player) event.getWhoClicked();
|
|
||||||
if (!Typa.logged_in.contains(player.getName()) && player.hasPermission("rifthq.login")) {
|
|
||||||
player.closeInventory();
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
package net.rifthq.typa.listeners;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
|
|
||||||
public class PlayerJoinListener implements Listener {
|
|
||||||
@EventHandler
|
|
||||||
public void on(PlayerJoinEvent e) {
|
|
||||||
Player p = e.getPlayer();
|
|
||||||
p.sendMessage(String.valueOf("\u00a7cIf you are new, please use command /register!"));
|
|
||||||
p.sendMessage(String.valueOf("\u00a7cIf you have registered, please use command /login!"));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
package net.rifthq.typa.listeners;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
|
|
||||||
import net.rifthq.typa.Typa;
|
|
||||||
|
|
||||||
public class PlayerLeaveListener implements Listener {
|
|
||||||
@EventHandler
|
|
||||||
public void on(PlayerQuitEvent e) {
|
|
||||||
Player p = e.getPlayer();
|
|
||||||
if (Typa.logged_in.contains(p.getName()) && p.hasPermission("rifthq.login")) {
|
|
||||||
Typa.logged_in.remove(p.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
package net.rifthq.typa.listeners;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
|
||||||
|
|
||||||
import net.rifthq.typa.Typa;
|
|
||||||
|
|
||||||
public class PlayerMoveListener implements Listener
|
|
||||||
{
|
|
||||||
@EventHandler
|
|
||||||
public void move(PlayerMoveEvent e)
|
|
||||||
{
|
|
||||||
Player p = e.getPlayer();
|
|
||||||
if (!Typa.logged_in.contains(p.getName()) && p.hasPermission("rifthq.login"))
|
|
||||||
{
|
|
||||||
e.setTo(e.getFrom());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,107 +0,0 @@
|
||||||
package net.rifthq.typa.managers;
|
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import net.rifthq.typa.Typa;
|
|
||||||
|
|
||||||
public class MySQL {
|
|
||||||
static Typa plugin = Typa.getPlugin(Typa.class);
|
|
||||||
|
|
||||||
public static boolean dataExists(UUID uuid, Player player) {
|
|
||||||
try {
|
|
||||||
PreparedStatement statement = plugin.getConnection()
|
|
||||||
.prepareStatement("SELECT * FROM " + MySQL.plugin.table + " WHERE UUID=?");
|
|
||||||
statement.setString(1, uuid.toString());
|
|
||||||
ResultSet results = statement.executeQuery();
|
|
||||||
if (results.next()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void registerPlayer(UUID uuid, Player player, String password, String ip) {
|
|
||||||
try {
|
|
||||||
if (MySQL.dataExists(uuid, player)) {
|
|
||||||
|
|
||||||
//Player login data not found, print command to create pin.
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PreparedStatement statement = plugin.getConnection()
|
|
||||||
.prepareStatement("INSERT INTO " + MySQL.plugin.table + " (UUID, PASSWORD, IP) VALUES (?,?,?)");
|
|
||||||
statement.setString(1, uuid.toString());
|
|
||||||
statement.setString(2, password);
|
|
||||||
statement.setString(3, ip.toString());
|
|
||||||
statement.executeUpdate();
|
|
||||||
|
|
||||||
//Set pin susfully.
|
|
||||||
|
|
||||||
Typa.logged_in.add(player.getName());
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
//Couldn'tt set pin
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getPlayerPassword(UUID uuid, Player player) {
|
|
||||||
try {
|
|
||||||
if (!dataExists(uuid, player)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
PreparedStatement statement = plugin.getConnection()
|
|
||||||
.prepareStatement("SELECT * FROM " + plugin.table + " WHERE UUID=?");
|
|
||||||
statement.setString(1, uuid.toString());
|
|
||||||
|
|
||||||
ResultSet results = statement.executeQuery();
|
|
||||||
results.first();
|
|
||||||
return results.getString("PASSWORD");
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getPlayerIP(UUID uuid, Player player) {
|
|
||||||
try {
|
|
||||||
if (!dataExists(uuid, player)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
PreparedStatement statement = plugin.getConnection()
|
|
||||||
.prepareStatement("SELECT * FROM " + plugin.table + " WHERE IP=?");
|
|
||||||
statement.setString(1, uuid.toString());
|
|
||||||
|
|
||||||
ResultSet results = statement.executeQuery();
|
|
||||||
results.first();
|
|
||||||
return results.getString("IP");
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void playerLogin(UUID uuid, Player player, String password) {
|
|
||||||
if (!MySQL.dataExists(uuid, player)) {
|
|
||||||
//not set password, print create message.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (password.equals(MySQL.getPlayerPassword(uuid, player))) {
|
|
||||||
Typa.logged_in.add(player.getName());
|
|
||||||
|
|
||||||
//correct passwrord message
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
//incorrect passwword message.
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<classpath>
|
|
||||||
<classpathentry kind="src" path=""/>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
|
||||||
<classpathentry kind="lib" path="C:/Development/Plugins.rar/Plugins.rar/Server/paperspigot.jar"/>
|
|
||||||
<classpathentry kind="lib" path="C:/Development/Plugins.rar/Plugins.rar/Server/plugins/WorldEdit/Vault.jar"/>
|
|
||||||
<classpathentry kind="output" path=""/>
|
|
||||||
</classpath>
|
|
|
@ -1,17 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>Typa(Staff Utils) v1.0</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
|
@ -1,9 +0,0 @@
|
||||||
# Typa Staff Authentication
|
|
||||||
|
|
||||||
**Advice**
|
|
||||||
> Always use latest release rather than cloning and compiling.
|
|
||||||
> If security flaws/issues to arise please contact us via PM rather than publicly.
|
|
||||||
> In the case that you find a error/glitch arises please make sure you follow the issue template.
|
|
||||||
>
|
|
||||||
|
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
host: 149.56.111.213
|
|
||||||
port: 3306
|
|
||||||
username: currency
|
|
||||||
database: typa
|
|
||||||
password: E8ZjXK4ueZ8VGfxD
|
|
||||||
table: staff_data
|
|
||||||
settings:
|
|
||||||
pin:
|
|
||||||
maxcharacters: 25
|
|
||||||
mincharacters: 5
|
|
||||||
|
|
||||||
lang:
|
|
||||||
register:
|
|
||||||
already: '&cYour already registered. Please use /login to authenticate.'
|
|
||||||
toolong: '&cYour password must contain less than %max_characters% characters!'
|
|
||||||
tooshort: '&cYour password must contain more than %min_characters% characters!'
|
|
||||||
autologin: '&aSuccessfully registered and authenticated.'
|
|
||||||
login:
|
|
||||||
already: '&cYou are already authenticated!'
|
|
||||||
notfound: '&cAccount not found! please use /register to start the authenticate process.'
|
|
||||||
successful: '&aSuccessfully authenticated as %player%.'
|
|
||||||
incorrect: '&cIncorrect password!'
|
|
||||||
kickmesesage: |-
|
|
||||||
&7&oAuthentication
|
|
||||||
&cYou failed to authenticate therefore you were kicked!
|
|
||||||
|
|
||||||
lang.resetip.successful: '&aSuccessfully updated %player%'s authentication profile'
|
|
||||||
lang.resetip.self: '&cYou cannot update yourself'
|
|
||||||
lang.resetip.notfound: '&cCould not find %player% in the authentication list!'
|
|
||||||
|
|
||||||
lang.resetplayer.successful: '&aSuccessfully deleted %player%'s authentication profile'
|
|
||||||
lang.resetplayer.self: '&cYou cannot remove yourself'
|
|
||||||
lang.resetplayer.notfound: '&cCould not find %player% in the authentication list!'
|
|
Binary file not shown.
|
@ -1,155 +0,0 @@
|
||||||
package net.rifthq.typa;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.sql.DriverManager;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
|
||||||
import org.bukkit.configuration.file.FileConfigurationOptions;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import com.mysql.jdbc.Connection;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.rifthq.typa.commands.LoginCommand;
|
|
||||||
import net.rifthq.typa.commands.RegisterCommand;
|
|
||||||
import net.rifthq.typa.commands.ResetIPCommand;
|
|
||||||
import net.rifthq.typa.commands.ResetPlayerCommand;
|
|
||||||
import net.rifthq.typa.listeners.PlayerLoginListeners;
|
|
||||||
import net.rifthq.typa.listeners.PlayerMoveListeners;
|
|
||||||
import net.rifthq.typa.managers.MySQL;
|
|
||||||
import net.rifthq.typa.utils.Lists;
|
|
||||||
|
|
||||||
public class Typa extends JavaPlugin {
|
|
||||||
private static Typa instance;
|
|
||||||
public String host;
|
|
||||||
public String username;
|
|
||||||
public String password;
|
|
||||||
public String database;
|
|
||||||
public static String table;
|
|
||||||
public int port;
|
|
||||||
public static Connection connection;
|
|
||||||
|
|
||||||
public static Typa getInstance() {
|
|
||||||
if (instance == null) {
|
|
||||||
instance = new Typa();
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onEnable() {
|
|
||||||
this.setup();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onDisable() {
|
|
||||||
instance = null;
|
|
||||||
this.saveConfig();
|
|
||||||
try {
|
|
||||||
if (connection != null && !connection.isClosed()) {
|
|
||||||
connection.close();
|
|
||||||
getServer().getConsoleSender().sendMessage("[Typa] Successfully closed connection to SQL.");
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private void setup() {
|
|
||||||
instance = this;
|
|
||||||
this.setupFiles();
|
|
||||||
setupMySQL();
|
|
||||||
loadCommands();
|
|
||||||
loadListeners();
|
|
||||||
for (Player online : Bukkit.getServer().getOnlinePlayers()) {
|
|
||||||
if (online.hasPermission("typa.auth"))
|
|
||||||
Lists.toLogin.add(online.getName());
|
|
||||||
online.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 99999, 9999));
|
|
||||||
online.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 99999, 9999));
|
|
||||||
online.sendMessage(ChatColor.RED + "A server reload has caused you to be placed in authentication mode!");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadCommands() {
|
|
||||||
getCommand("register").setExecutor(new RegisterCommand());
|
|
||||||
getCommand("login").setExecutor(new LoginCommand());
|
|
||||||
getCommand("resetpin").setExecutor(new ResetPlayerCommand());
|
|
||||||
getCommand("resetplayer").setExecutor(new ResetIPCommand());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadListeners() {
|
|
||||||
getServer().getPluginManager().registerEvents(new PlayerLoginListeners(), this);
|
|
||||||
getServer().getPluginManager().registerEvents(new PlayerMoveListeners(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConsoleCommandSender getConsoleSender() {
|
|
||||||
return Bukkit.getServer().getConsoleSender();
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileConfigurationOptions getFileConfigurationOptions() {
|
|
||||||
return this.getConfig().options();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupFiles() {
|
|
||||||
try {
|
|
||||||
if (!this.getDataFolder().exists()) {
|
|
||||||
this.getDataFolder().mkdirs();
|
|
||||||
}
|
|
||||||
if (!(new File(this.getDataFolder().getAbsolutePath(), "config.yml")).exists()) {
|
|
||||||
this.getFileConfigurationOptions().copyDefaults(true);
|
|
||||||
this.saveConfig();
|
|
||||||
this.getConsoleSender().sendMessage("[Typa] The config file was not detected, because of the file does not exist it will created.");
|
|
||||||
} else {
|
|
||||||
this.getConsoleSender().sendMessage("[Typa] Successfully loaded all configuration files.");
|
|
||||||
}
|
|
||||||
} catch (Exception exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setupMySQL() {
|
|
||||||
host = this.getConfig().getString("host");
|
|
||||||
port = this.getConfig().getInt("port");
|
|
||||||
username = this.getConfig().getString("username");
|
|
||||||
password = this.getConfig().getString("password");
|
|
||||||
database = this.getConfig().getString("database");
|
|
||||||
table = this.getConfig().getString("table");
|
|
||||||
try {
|
|
||||||
Typa login = this;
|
|
||||||
synchronized (login) {
|
|
||||||
if (this.getConnection() != null && !this.getConnection().isClosed()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Class.forName("com.mysql.jdbc.Driver");
|
|
||||||
this.setConnection((Connection) DriverManager.getConnection(
|
|
||||||
"jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database, this.username,
|
|
||||||
this.password));
|
|
||||||
MySQL.setupTables();
|
|
||||||
getServer().getConsoleSender()
|
|
||||||
.sendMessage("[Typa] Successfully connected to SQL Database using setttings: " + "jdbc:mysql://"
|
|
||||||
+ this.host + ":" + this.port + "/" + this.database + " using user" + this.username
|
|
||||||
+ " using password YES. ");
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
Bukkit.getServer().shutdown();
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
Bukkit.getServer().shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Connection getConnection() {
|
|
||||||
return connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConnection(Connection connection) {
|
|
||||||
Typa.connection = connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,41 +0,0 @@
|
||||||
package net.rifthq.typa.commands;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.rifthq.typa.Typa;
|
|
||||||
import net.rifthq.typa.managers.MySQL;
|
|
||||||
import net.rifthq.typa.utils.Lists;
|
|
||||||
|
|
||||||
public class LoginCommand implements CommandExecutor {
|
|
||||||
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
if (label.equalsIgnoreCase("login")) {
|
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
sender.sendMessage(ChatColor.RED + "This command is for players only!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!player.hasPermission("typa.auth")) {
|
|
||||||
player.sendMessage(ChatColor.RED + "You lack the correct permission(s) to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!(Lists.toLogin.contains(player.getName()))) {
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.register.already")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (Lists.toLogin.contains(player.getName())) {
|
|
||||||
if (args.length == 1) {
|
|
||||||
MySQL.playerLogin(player.getUniqueId(), player, args[0]);
|
|
||||||
} else {
|
|
||||||
player.sendMessage(ChatColor.RED + "/login <pin>");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,47 +0,0 @@
|
||||||
package net.rifthq.typa.commands;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.rifthq.typa.Typa;
|
|
||||||
import net.rifthq.typa.managers.MySQL;
|
|
||||||
|
|
||||||
public class RegisterCommand implements CommandExecutor {
|
|
||||||
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
if (label.equalsIgnoreCase("register")) {
|
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
sender.sendMessage(ChatColor.RED + "This command is for players only!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!player.hasPermission("typa.auth")) {
|
|
||||||
player.sendMessage(ChatColor.RED + "You lack the correct permission(s) to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (MySQL.dataExists(player.getUniqueId(), player)) {
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.register.already")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
if (args[0].length() > Typa.getInstance().getConfig().getInt("settings.pin.maxcharacters")) {
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.register.toolong").replace("%max_characters%", String.valueOf(Typa.getInstance().getConfig().getInt("settings.pin.maxcharacters")))));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args[0].length() < Typa.getInstance().getConfig().getInt("settings.pin.mincharacters")) {
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.register.tooshort").replace("%min_characters%", String.valueOf(Typa.getInstance().getConfig().getInt("settings.pin.mincharacters")))));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
MySQL.registerPlayer(player.getUniqueId(), player, args[0],
|
|
||||||
player.getAddress().getAddress().getHostAddress());
|
|
||||||
} else {
|
|
||||||
player.sendMessage(ChatColor.RED + "/register <pin>");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,48 +0,0 @@
|
||||||
package net.rifthq.typa.commands;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.rifthq.typa.Typa;
|
|
||||||
import net.rifthq.typa.managers.MySQL;
|
|
||||||
|
|
||||||
public class ResetIPCommand implements CommandExecutor {
|
|
||||||
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
if (label.equalsIgnoreCase("resetip")) {
|
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
sender.sendMessage(ChatColor.RED + "This command is for players only!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!player.hasPermission("typa.auth.admin")) {
|
|
||||||
player.sendMessage(ChatColor.RED + "You lack the correct permission(s) to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 0) {
|
|
||||||
player.sendMessage(ChatColor.RED + "/resetip <player>");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Player target = Bukkit.getPlayer(args[0]);
|
|
||||||
if (target == null) {
|
|
||||||
player.sendMessage(ChatColor.RED + "Player not found!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (target == player) {
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.resetip.self")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
MySQL.updatePlayer(target.getUniqueId(), target, target.getAddress().getAddress().getHostAddress(), player);
|
|
||||||
} else {
|
|
||||||
player.sendMessage(ChatColor.RED + "/resetip <player>");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,48 +0,0 @@
|
||||||
package net.rifthq.typa.commands;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.rifthq.typa.Typa;
|
|
||||||
import net.rifthq.typa.managers.MySQL;
|
|
||||||
|
|
||||||
public class ResetPlayerCommand implements CommandExecutor {
|
|
||||||
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
if (label.equalsIgnoreCase("resetplayer")) {
|
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
sender.sendMessage(ChatColor.RED + "This command is for players only!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!player.hasPermission("typa.auth.admin")) {
|
|
||||||
player.sendMessage(ChatColor.RED + "You lack the correct permission(s) to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 0) {
|
|
||||||
player.sendMessage(ChatColor.RED + "/resetplayer <player>");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Player target = Bukkit.getPlayer(args[0]);
|
|
||||||
if (target == null) {
|
|
||||||
player.sendMessage(ChatColor.RED + "Player not found!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (target == player) {
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.resetplayer.self")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
MySQL.deletePlayer(target.getUniqueId(), target, player);
|
|
||||||
} else {
|
|
||||||
player.sendMessage(ChatColor.RED + "/resetplayer <player>");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,45 +0,0 @@
|
||||||
package net.rifthq.typa.listeners;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.rifthq.typa.managers.MySQL;
|
|
||||||
import net.rifthq.typa.utils.Lists;
|
|
||||||
|
|
||||||
public class PlayerLoginListeners implements Listener {
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
||||||
public void onStaffJoin(PlayerJoinEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (!event.getPlayer().hasPermission("typa.force")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (MySQL.dataExists(event.getPlayer().getUniqueId(), event.getPlayer())) {
|
|
||||||
Lists.toLogin.add(player.getName());
|
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 99999, 9999));
|
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 99999, 9999));
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cPlease authenticate via /login!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!MySQL.dataExists(event.getPlayer().getUniqueId(), event.getPlayer())) {
|
|
||||||
Lists.toLogin.add(player.getName());
|
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 99999, 9999));
|
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 99999, 9999));
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&',
|
|
||||||
"&cIt seems your a new staffmember, please register your account to our authtication system via /register"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
||||||
public void onStaffIPJoin(PlayerJoinEvent event) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,26 +0,0 @@
|
||||||
package net.rifthq.typa.listeners;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
|
||||||
|
|
||||||
import net.rifthq.typa.utils.Lists;
|
|
||||||
|
|
||||||
public class PlayerMoveListeners implements Listener {
|
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
|
||||||
Location from = event.getFrom();
|
|
||||||
Location to = event.getTo();
|
|
||||||
if ((from.getBlockX() == to.getBlockX()) && (from.getBlockZ() == to.getBlockZ())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (Lists.toLogin.contains(player.getName())) {
|
|
||||||
event.setTo(event.getFrom());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,152 +0,0 @@
|
||||||
package net.rifthq.typa.managers;
|
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.rifthq.typa.Typa;
|
|
||||||
import net.rifthq.typa.utils.Lists;
|
|
||||||
|
|
||||||
public class MySQL {
|
|
||||||
static Typa plugin = Typa.getPlugin(Typa.class);
|
|
||||||
|
|
||||||
public static boolean dataExists(UUID uuid, Player player) {
|
|
||||||
try {
|
|
||||||
Typa.getInstance();
|
|
||||||
PreparedStatement statement = plugin.getConnection()
|
|
||||||
.prepareStatement("SELECT * FROM " + Typa.table + " WHERE UUID=?");
|
|
||||||
statement.setString(1, uuid.toString());
|
|
||||||
ResultSet results = statement.executeQuery();
|
|
||||||
if (results.next()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void registerPlayer(UUID uuid, Player player, String password, String ip) {
|
|
||||||
try {
|
|
||||||
if (MySQL.dataExists(uuid, player)) {
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.register.already")));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PreparedStatement statement = plugin.getConnection()
|
|
||||||
.prepareStatement("INSERT INTO " + Typa.table + " (UUID, PASSWORD, IP) VALUES (?,?,?)");
|
|
||||||
statement.setString(1, uuid.toString());
|
|
||||||
statement.setString(2, password);
|
|
||||||
statement.setString(3, ip.toString());
|
|
||||||
statement.executeUpdate();
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.register.autologin")));
|
|
||||||
player.removePotionEffect(PotionEffectType.SLOW);
|
|
||||||
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
|
||||||
Lists.toLogin.remove(player.getName());
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
player.sendMessage(
|
|
||||||
ChatColor.RED + "Error whilst atempting to register, please contact a Server Administrator.");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setupTables() {
|
|
||||||
try {
|
|
||||||
PreparedStatement statement = plugin.getConnection()
|
|
||||||
.prepareStatement("CREATE TABLE IF NOT EXISTS `" + Typa.table + "` (`ID` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, `UUID` varchar(50), `PASSWORD` varchar(50), `IP` varchar(50))");
|
|
||||||
statement.executeUpdate();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updatePlayer(UUID uuid, Player player, String ip, Player sender) {
|
|
||||||
try {
|
|
||||||
if (!dataExists(uuid, player)) {
|
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.resetip.notfound").replace("%player%", player.getName())));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PreparedStatement statement = plugin.getConnection()
|
|
||||||
.prepareStatement("UPDATE '" + Typa.table + "' SET 'IP'=? WHERE 'UUID'=?");
|
|
||||||
statement.setString(1, ip.toString());
|
|
||||||
statement.setString(2, uuid.toString());
|
|
||||||
statement.executeUpdate();
|
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.resetip.successful").replace("%player%", player.getName())));
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
sender.sendMessage(ChatColor.RED + "Error whilst atempting to update player, please contact a Server Administrator.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getPlayerPassword(UUID uuid, Player player) {
|
|
||||||
try {
|
|
||||||
if (!dataExists(uuid, player)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
PreparedStatement statement = plugin.getConnection()
|
|
||||||
.prepareStatement("SELECT * FROM " + Typa.table + " WHERE UUID=?");
|
|
||||||
statement.setString(1, uuid.toString());
|
|
||||||
|
|
||||||
ResultSet results = statement.executeQuery();
|
|
||||||
results.first();
|
|
||||||
return results.getString("PASSWORD");
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String deletePlayer(UUID uuid, Player player, Player sender) {
|
|
||||||
try {
|
|
||||||
if (!dataExists(uuid, player)) {
|
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.resetplayer.successful").replace("%player%", player.getName())));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
PreparedStatement statement = plugin.getConnection()
|
|
||||||
.prepareStatement("DELETE FROM " + Typa.table + " WHERE UUID=?");
|
|
||||||
statement.setString(1, uuid.toString());
|
|
||||||
statement.executeUpdate();
|
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.resetplayer.successful").replace("%player%", player.getName())));
|
|
||||||
if (Lists.toLogin.contains(player)) {
|
|
||||||
Lists.toLogin.remove(player);
|
|
||||||
player.removePotionEffect(PotionEffectType.SLOW);
|
|
||||||
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
|
||||||
player.kickPlayer(ChatColor.translateAlternateColorCodes('&',
|
|
||||||
"&7&oAuthentication\n&cYou have been removed from our authentication system\n&c therefore you were kicked!"));
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
sender.sendMessage(
|
|
||||||
ChatColor.RED + "Error whilst atempting to remove player, please contact a Server Administrator.");
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void playerLogin(UUID uuid, Player player, String password) {
|
|
||||||
if (!MySQL.dataExists(uuid, player)) {
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.login.notfound")));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (password.equals(MySQL.getPlayerPassword(uuid, player))) {
|
|
||||||
Lists.toLogin.remove(player.getName());
|
|
||||||
player.removePotionEffect(PotionEffectType.SLOW);
|
|
||||||
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
|
||||||
|
|
||||||
//player.sendMessage(ChatColor.GREEN + "Successfully authenticated as " + player.getName() + ".");
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.login.successful").replace("%player%", player.getName())));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.login.incorrect")));
|
|
||||||
player.removePotionEffect(PotionEffectType.SLOW);
|
|
||||||
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
|
||||||
|
|
||||||
player.kickPlayer(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.login.kickmessage")));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,10 +0,0 @@
|
||||||
package net.rifthq.typa.utils;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class Lists {
|
|
||||||
|
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
||||||
public static ArrayList<String> toLogin = new ArrayList();
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
name: Typa
|
|
||||||
version: 1.2
|
|
||||||
main: net.rifthq.typa.Typa
|
|
||||||
author: [puttydotexe]
|
|
||||||
commands:
|
|
||||||
register:
|
|
||||||
description: Command used to register a staff account.
|
|
||||||
login:
|
|
||||||
description: Command used to log into a staff account.
|
|
||||||
resetpin:
|
|
||||||
description: Command used to reset a staff accounts pin.
|
|
||||||
resetplayer:
|
|
||||||
description: Command used to reset a staff account.
|
|
|
@ -1,8 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<classpath>
|
|
||||||
<classpathentry kind="src" path=""/>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
|
||||||
<classpathentry kind="lib" path="C:/Development/Plugins.rar/Plugins.rar/Server/paperspigot.jar"/>
|
|
||||||
<classpathentry kind="lib" path="C:/Development/Plugins.rar/Plugins.rar/Server/plugins/WorldEdit/Vault.jar"/>
|
|
||||||
<classpathentry kind="output" path=""/>
|
|
||||||
</classpath>
|
|
|
@ -1,17 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>Typa(Staff Utils) v1.1</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
|
@ -1,9 +0,0 @@
|
||||||
# Typa Staff Authentication
|
|
||||||
|
|
||||||
**Advice**
|
|
||||||
> Always use latest release rather than cloning and compiling.
|
|
||||||
> If security flaws/issues to arise please contact us via PM rather than publicly.
|
|
||||||
> In the case that you find a error/glitch arises please make sure you follow the issue template.
|
|
||||||
>
|
|
||||||
|
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
host: localhost
|
|
||||||
port: 3306
|
|
||||||
username: root
|
|
||||||
database: typa
|
|
||||||
password: password
|
|
||||||
table: staff_data
|
|
||||||
settings:
|
|
||||||
pin:
|
|
||||||
maxcharacters: 25
|
|
||||||
mincharacters: 5
|
|
||||||
|
|
||||||
lang:
|
|
||||||
register:
|
|
||||||
already: '&cYour already registered. Please use /login to authenticate.'
|
|
||||||
toolong: '&cYour password must contain less than %max_characters% characters!'
|
|
||||||
tooshort: '&cYour password must contain more than %min_characters% characters!'
|
|
||||||
autologin: '&aSuccessfully registered and authenticated.'
|
|
||||||
login:
|
|
||||||
already: '&cYou are already authenticated!'
|
|
||||||
notfound: '&cAccount not found! please use /register to start the authenticate process.'
|
|
||||||
successful: '&aSuccessfully authenticated as %player%.'
|
|
||||||
incorrect: '&cIncorrect password!'
|
|
||||||
kickmesesage: |-
|
|
||||||
&7&oAuthentication
|
|
||||||
&cYou failed to authenticate therefore you were kicked!
|
|
||||||
|
|
||||||
lang.resetip.successful: '&aSuccessfully updated %player%s authentication profile'
|
|
||||||
lang.resetip.self: '&cYou cannot update yourself'
|
|
||||||
lang.resetip.notfound: '&cCould not find %player% in the authentication list!'
|
|
||||||
|
|
||||||
lang.resetplayer.successful: '&aSuccessfully deleted %player%s authentication profile'
|
|
||||||
lang.resetplayer.self: '&cYou cannot remove yourself'
|
|
||||||
lang.resetplayer.notfound: '&cCould not find %player% in the authentication list!'
|
|
Binary file not shown.
|
@ -1,241 +0,0 @@
|
||||||
package net.rifthq.typa;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLConnection;
|
|
||||||
import java.sql.DriverManager;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
|
||||||
import org.bukkit.configuration.file.FileConfigurationOptions;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import com.mysql.jdbc.Connection;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.rifthq.typa.commands.LoginCommand;
|
|
||||||
import net.rifthq.typa.commands.RegisterCommand;
|
|
||||||
import net.rifthq.typa.commands.ResetIPCommand;
|
|
||||||
import net.rifthq.typa.commands.ResetPlayerCommand;
|
|
||||||
import net.rifthq.typa.listeners.PlayerLoginListeners;
|
|
||||||
import net.rifthq.typa.listeners.PlayerMoveListeners;
|
|
||||||
import net.rifthq.typa.managers.MySQL;
|
|
||||||
import net.rifthq.typa.utils.Config;
|
|
||||||
import net.rifthq.typa.utils.Lists;
|
|
||||||
|
|
||||||
public class Typa extends JavaPlugin
|
|
||||||
{
|
|
||||||
private static Typa instance;
|
|
||||||
public String host;
|
|
||||||
public String username;
|
|
||||||
public String password;
|
|
||||||
public String database;
|
|
||||||
public static String table;
|
|
||||||
public int port;
|
|
||||||
public static Connection connection;
|
|
||||||
private Config mainConfig;
|
|
||||||
|
|
||||||
public static Typa getInstance()
|
|
||||||
{
|
|
||||||
if (instance == null)
|
|
||||||
{
|
|
||||||
instance = new Typa();
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onEnable()
|
|
||||||
{
|
|
||||||
this.setup();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onDisable()
|
|
||||||
{
|
|
||||||
instance = null;
|
|
||||||
this.saveConfig();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (connection != null && !connection.isClosed())
|
|
||||||
{
|
|
||||||
connection.close();
|
|
||||||
getServer().getConsoleSender().sendMessage("[Typa] Successfully closed connection to SQL.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private void setup()
|
|
||||||
{
|
|
||||||
instance = this;
|
|
||||||
this.setupFiles();
|
|
||||||
setupMySQL();
|
|
||||||
loadCommands();
|
|
||||||
loadListeners();
|
|
||||||
this.getAPI();
|
|
||||||
(this.mainConfig = new Config(this, "", "config")).setDefault("Shit", false);
|
|
||||||
this.mainConfig.setDefault("hwid", "");
|
|
||||||
for (Player online : Bukkit.getServer().getOnlinePlayers())
|
|
||||||
{
|
|
||||||
if (online.hasPermission("typa.auth"))
|
|
||||||
Lists.toLogin.add(online.getName());
|
|
||||||
online.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 99999, 9999));
|
|
||||||
online.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 99999, 9999));
|
|
||||||
online.sendMessage(ChatColor.RED + "A server reload has caused you to be placed in authentication mode!");
|
|
||||||
online.sendMessage(ChatColor.RED + "/login <password>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadCommands()
|
|
||||||
{
|
|
||||||
getCommand("register").setExecutor(new RegisterCommand());
|
|
||||||
getCommand("login").setExecutor(new LoginCommand());
|
|
||||||
getCommand("resetpin").setExecutor(new ResetPlayerCommand());
|
|
||||||
getCommand("resetplayer").setExecutor(new ResetIPCommand());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadListeners()
|
|
||||||
{
|
|
||||||
getServer().getPluginManager().registerEvents(new PlayerLoginListeners(), this);
|
|
||||||
getServer().getPluginManager().registerEvents(new PlayerMoveListeners(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConsoleCommandSender getConsoleSender()
|
|
||||||
{
|
|
||||||
return Bukkit.getServer().getConsoleSender();
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileConfigurationOptions getFileConfigurationOptions()
|
|
||||||
{
|
|
||||||
return this.getConfig().options();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupFiles()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!this.getDataFolder().exists())
|
|
||||||
{
|
|
||||||
this.getDataFolder().mkdirs();
|
|
||||||
}
|
|
||||||
if (!(new File(this.getDataFolder().getAbsolutePath(), "config.yml")).exists())
|
|
||||||
{
|
|
||||||
this.getFileConfigurationOptions().copyDefaults(true);
|
|
||||||
this.saveConfig();
|
|
||||||
this.getConsoleSender().sendMessage("[Typa] The config file was not detected, because of the file does not exist it will created.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.getConsoleSender().sendMessage("[Typa] Successfully loaded all configuration files.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception exception)
|
|
||||||
{
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setupMySQL()
|
|
||||||
{
|
|
||||||
host = this.getConfig().getString("host");
|
|
||||||
port = this.getConfig().getInt("port");
|
|
||||||
username = this.getConfig().getString("username");
|
|
||||||
password = this.getConfig().getString("password");
|
|
||||||
database = this.getConfig().getString("database");
|
|
||||||
table = this.getConfig().getString("table");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Typa login = this;
|
|
||||||
synchronized (login)
|
|
||||||
{
|
|
||||||
if (this.getConnection() != null && !this.getConnection().isClosed()) { return; }
|
|
||||||
Class.forName("com.mysql.jdbc.Driver");
|
|
||||||
this.setConnection((Connection) DriverManager.getConnection("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database, this.username, this.password));
|
|
||||||
MySQL.setupTables();
|
|
||||||
getServer().getConsoleSender().sendMessage("[Typa] Successfully connected to SQL Database using setttings: " + "jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database + " using user" + this.username + " using password YES. ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
Bukkit.getServer().shutdown();
|
|
||||||
}
|
|
||||||
catch (ClassNotFoundException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
Bukkit.getServer().shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Connection getConnection()
|
|
||||||
{
|
|
||||||
return connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConnection(Connection connection)
|
|
||||||
{
|
|
||||||
Typa.connection = connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* HWID Whitelist
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
public String wngnq;
|
|
||||||
|
|
||||||
public Typa()
|
|
||||||
{
|
|
||||||
this.wngnq = "Incorrect HWID! Disabling plugin. If you need an HWID, get one from puttydotexe, Grimy! Or message us on MCMarket.";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void wqminoiwn()
|
|
||||||
{
|
|
||||||
Bukkit.getPluginManager().disablePlugin((Plugin) this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getAPI()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
final URL url = new URL("https://pastebin.com/raw/XkZdX1W4");
|
|
||||||
final ArrayList<Object> lines = new ArrayList<Object>();
|
|
||||||
final URLConnection connection = url.openConnection();
|
|
||||||
final BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
|
||||||
String line;
|
|
||||||
while ((line = in.readLine()) != null)
|
|
||||||
{
|
|
||||||
lines.add(line);
|
|
||||||
}
|
|
||||||
if (!lines.contains(this.getConfig().getString("hwid")) && this.getConfig().getString("hwid") != null)
|
|
||||||
{
|
|
||||||
this.getLogger().log(Level.SEVERE, this.wngnq);
|
|
||||||
this.wqminoiwn();
|
|
||||||
}
|
|
||||||
else if (this.getConfig().getString("hwid") == null)
|
|
||||||
{
|
|
||||||
this.getLogger().log(Level.SEVERE, "Add an HWID in the config!");
|
|
||||||
this.wqminoiwn();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
this.getLogger().log(Level.SEVERE, "Error! Disabling plugin.");
|
|
||||||
Bukkit.getPluginManager().disablePlugin((Plugin) this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,6 +0,0 @@
|
||||||
package net.rifthq.typa.commands;
|
|
||||||
|
|
||||||
public class ChangeLogCommand
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,41 +0,0 @@
|
||||||
package net.rifthq.typa.commands;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.rifthq.typa.Typa;
|
|
||||||
import net.rifthq.typa.managers.MySQL;
|
|
||||||
import net.rifthq.typa.utils.Lists;
|
|
||||||
|
|
||||||
public class LoginCommand implements CommandExecutor {
|
|
||||||
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
if (label.equalsIgnoreCase("login")) {
|
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
sender.sendMessage(ChatColor.RED + "This command is for players only!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!player.hasPermission("typa.auth")) {
|
|
||||||
player.sendMessage(ChatColor.RED + "You lack the correct permission(s) to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!(Lists.toLogin.contains(player.getName()))) {
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.register.already")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (Lists.toLogin.contains(player.getName())) {
|
|
||||||
if (args.length == 1) {
|
|
||||||
MySQL.playerLogin(player.getUniqueId(), player, args[0]);
|
|
||||||
} else {
|
|
||||||
player.sendMessage(ChatColor.RED + "/login <pin>");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,47 +0,0 @@
|
||||||
package net.rifthq.typa.commands;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.rifthq.typa.Typa;
|
|
||||||
import net.rifthq.typa.managers.MySQL;
|
|
||||||
|
|
||||||
public class RegisterCommand implements CommandExecutor {
|
|
||||||
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
if (label.equalsIgnoreCase("register")) {
|
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
sender.sendMessage(ChatColor.RED + "This command is for players only!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!player.hasPermission("typa.auth")) {
|
|
||||||
player.sendMessage(ChatColor.RED + "You lack the correct permission(s) to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (MySQL.dataExists(player.getUniqueId(), player)) {
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.register.already")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
if (args[0].length() > Typa.getInstance().getConfig().getInt("settings.pin.maxcharacters")) {
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.register.toolong").replace("%max_characters%", String.valueOf(Typa.getInstance().getConfig().getInt("settings.pin.maxcharacters")))));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args[0].length() < Typa.getInstance().getConfig().getInt("settings.pin.mincharacters")) {
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.register.tooshort").replace("%min_characters%", String.valueOf(Typa.getInstance().getConfig().getInt("settings.pin.mincharacters")))));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
MySQL.registerPlayer(player.getUniqueId(), player, args[0],
|
|
||||||
player.getAddress().getAddress().getHostAddress());
|
|
||||||
} else {
|
|
||||||
player.sendMessage(ChatColor.RED + "/register <pin>");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,48 +0,0 @@
|
||||||
package net.rifthq.typa.commands;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.rifthq.typa.Typa;
|
|
||||||
import net.rifthq.typa.managers.MySQL;
|
|
||||||
|
|
||||||
public class ResetIPCommand implements CommandExecutor {
|
|
||||||
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
if (label.equalsIgnoreCase("resetip")) {
|
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
sender.sendMessage(ChatColor.RED + "This command is for players only!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!player.hasPermission("typa.auth.admin")) {
|
|
||||||
player.sendMessage(ChatColor.RED + "You lack the correct permission(s) to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 0) {
|
|
||||||
player.sendMessage(ChatColor.RED + "/resetip <player>");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Player target = Bukkit.getPlayer(args[0]);
|
|
||||||
if (target == null) {
|
|
||||||
player.sendMessage(ChatColor.RED + "Player not found!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (target == player) {
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.resetip.self")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
MySQL.updatePlayer(target.getUniqueId(), target, target.getAddress().getAddress().getHostAddress(), player);
|
|
||||||
} else {
|
|
||||||
player.sendMessage(ChatColor.RED + "/resetip <player>");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,48 +0,0 @@
|
||||||
package net.rifthq.typa.commands;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.rifthq.typa.Typa;
|
|
||||||
import net.rifthq.typa.managers.MySQL;
|
|
||||||
|
|
||||||
public class ResetPlayerCommand implements CommandExecutor {
|
|
||||||
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
if (label.equalsIgnoreCase("resetplayer")) {
|
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
sender.sendMessage(ChatColor.RED + "This command is for players only!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!player.hasPermission("typa.auth.admin")) {
|
|
||||||
player.sendMessage(ChatColor.RED + "You lack the correct permission(s) to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 0) {
|
|
||||||
player.sendMessage(ChatColor.RED + "/resetplayer <player>");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Player target = Bukkit.getPlayer(args[0]);
|
|
||||||
if (target == null) {
|
|
||||||
player.sendMessage(ChatColor.RED + "Player not found!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (target == player) {
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.resetplayer.self")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
MySQL.deletePlayer(target.getUniqueId(), target, player);
|
|
||||||
} else {
|
|
||||||
player.sendMessage(ChatColor.RED + "/resetplayer <player>");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,45 +0,0 @@
|
||||||
package net.rifthq.typa.listeners;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.rifthq.typa.managers.MySQL;
|
|
||||||
import net.rifthq.typa.utils.Lists;
|
|
||||||
|
|
||||||
public class PlayerLoginListeners implements Listener {
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
||||||
public void onStaffJoin(PlayerJoinEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (!event.getPlayer().hasPermission("typa.force")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (MySQL.dataExists(event.getPlayer().getUniqueId(), event.getPlayer())) {
|
|
||||||
Lists.toLogin.add(player.getName());
|
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 99999, 9999));
|
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 99999, 9999));
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cPlease authenticate via /login!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!MySQL.dataExists(event.getPlayer().getUniqueId(), event.getPlayer())) {
|
|
||||||
Lists.toLogin.add(player.getName());
|
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 99999, 9999));
|
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 99999, 9999));
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&',
|
|
||||||
"&cIt seems your a new staffmember, please register your account to our authtication system via /register"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
||||||
public void onStaffIPJoin(PlayerJoinEvent event) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,26 +0,0 @@
|
||||||
package net.rifthq.typa.listeners;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
|
||||||
|
|
||||||
import net.rifthq.typa.utils.Lists;
|
|
||||||
|
|
||||||
public class PlayerMoveListeners implements Listener {
|
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
|
||||||
Location from = event.getFrom();
|
|
||||||
Location to = event.getTo();
|
|
||||||
if ((from.getBlockX() == to.getBlockX()) && (from.getBlockZ() == to.getBlockZ())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (Lists.toLogin.contains(player.getName())) {
|
|
||||||
event.setTo(event.getFrom());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,152 +0,0 @@
|
||||||
package net.rifthq.typa.managers;
|
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.rifthq.typa.Typa;
|
|
||||||
import net.rifthq.typa.utils.Lists;
|
|
||||||
|
|
||||||
public class MySQL {
|
|
||||||
static Typa plugin = Typa.getPlugin(Typa.class);
|
|
||||||
|
|
||||||
public static boolean dataExists(UUID uuid, Player player) {
|
|
||||||
try {
|
|
||||||
Typa.getInstance();
|
|
||||||
PreparedStatement statement = plugin.getConnection()
|
|
||||||
.prepareStatement("SELECT * FROM " + Typa.table + " WHERE UUID=?");
|
|
||||||
statement.setString(1, uuid.toString());
|
|
||||||
ResultSet results = statement.executeQuery();
|
|
||||||
if (results.next()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void registerPlayer(UUID uuid, Player player, String password, String ip) {
|
|
||||||
try {
|
|
||||||
if (MySQL.dataExists(uuid, player)) {
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.register.already")));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PreparedStatement statement = plugin.getConnection()
|
|
||||||
.prepareStatement("INSERT INTO " + Typa.table + " (UUID, PASSWORD, IP) VALUES (?,?,?)");
|
|
||||||
statement.setString(1, uuid.toString());
|
|
||||||
statement.setString(2, password);
|
|
||||||
statement.setString(3, ip.toString());
|
|
||||||
statement.executeUpdate();
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.register.autologin")));
|
|
||||||
player.removePotionEffect(PotionEffectType.SLOW);
|
|
||||||
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
|
||||||
Lists.toLogin.remove(player.getName());
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
player.sendMessage(
|
|
||||||
ChatColor.RED + "Error whilst atempting to register, please contact a Server Administrator.");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setupTables() {
|
|
||||||
try {
|
|
||||||
PreparedStatement statement = plugin.getConnection()
|
|
||||||
.prepareStatement("CREATE TABLE IF NOT EXISTS `" + Typa.table + "` (`ID` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, `UUID` varchar(50), `PASSWORD` varchar(50), `IP` varchar(50))");
|
|
||||||
statement.executeUpdate();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updatePlayer(UUID uuid, Player player, String ip, Player sender) {
|
|
||||||
try {
|
|
||||||
if (!dataExists(uuid, player)) {
|
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.resetip.notfound").replace("%player%", player.getName())));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PreparedStatement statement = plugin.getConnection()
|
|
||||||
.prepareStatement("UPDATE '" + Typa.table + "' SET 'IP'=? WHERE 'UUID'=?");
|
|
||||||
statement.setString(1, ip.toString());
|
|
||||||
statement.setString(2, uuid.toString());
|
|
||||||
statement.executeUpdate();
|
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.resetip.successful").replace("%player%", player.getName())));
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
sender.sendMessage(ChatColor.RED + "Error whilst atempting to update player, please contact a Server Administrator.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getPlayerPassword(UUID uuid, Player player) {
|
|
||||||
try {
|
|
||||||
if (!dataExists(uuid, player)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
PreparedStatement statement = plugin.getConnection()
|
|
||||||
.prepareStatement("SELECT * FROM " + Typa.table + " WHERE UUID=?");
|
|
||||||
statement.setString(1, uuid.toString());
|
|
||||||
|
|
||||||
ResultSet results = statement.executeQuery();
|
|
||||||
results.first();
|
|
||||||
return results.getString("PASSWORD");
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String deletePlayer(UUID uuid, Player player, Player sender) {
|
|
||||||
try {
|
|
||||||
if (!dataExists(uuid, player)) {
|
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.resetplayer.successful").replace("%player%", player.getName())));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
PreparedStatement statement = plugin.getConnection()
|
|
||||||
.prepareStatement("DELETE FROM " + Typa.table + " WHERE UUID=?");
|
|
||||||
statement.setString(1, uuid.toString());
|
|
||||||
statement.executeUpdate();
|
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.resetplayer.successful").replace("%player%", player.getName())));
|
|
||||||
if (Lists.toLogin.contains(player)) {
|
|
||||||
Lists.toLogin.remove(player);
|
|
||||||
player.removePotionEffect(PotionEffectType.SLOW);
|
|
||||||
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
|
||||||
player.kickPlayer(ChatColor.translateAlternateColorCodes('&',
|
|
||||||
"&7&oAuthentication\n&cYou have been removed from our authentication system\n&c therefore you were kicked!"));
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
sender.sendMessage(
|
|
||||||
ChatColor.RED + "Error whilst atempting to remove player, please contact a Server Administrator.");
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void playerLogin(UUID uuid, Player player, String password) {
|
|
||||||
if (!MySQL.dataExists(uuid, player)) {
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.login.notfound")));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (password.equals(MySQL.getPlayerPassword(uuid, player))) {
|
|
||||||
Lists.toLogin.remove(player.getName());
|
|
||||||
player.removePotionEffect(PotionEffectType.SLOW);
|
|
||||||
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
|
||||||
|
|
||||||
//player.sendMessage(ChatColor.GREEN + "Successfully authenticated as " + player.getName() + ".");
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.login.successful").replace("%player%", player.getName())));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.login.incorrect")));
|
|
||||||
player.removePotionEffect(PotionEffectType.SLOW);
|
|
||||||
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
|
||||||
|
|
||||||
player.kickPlayer(ChatColor.translateAlternateColorCodes('&', Typa.getInstance().getConfig().getString("lang.login.kickmessage")));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,23 +0,0 @@
|
||||||
package net.rifthq.typa.utils;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
public class C
|
|
||||||
{
|
|
||||||
public static String c(String string)
|
|
||||||
{
|
|
||||||
return ChatColor.translateAlternateColorCodes('&', string);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String complete(String string)
|
|
||||||
{
|
|
||||||
String current = "";
|
|
||||||
for (char c : string.toCharArray())
|
|
||||||
{
|
|
||||||
String color = ChatColor.getLastColors(current);
|
|
||||||
|
|
||||||
current = ChatColor.translateAlternateColorCodes('&', current.endsWith("&") || current.endsWith(ChatColor.COLOR_CHAR + "") ? current + c : current + color + c);
|
|
||||||
}
|
|
||||||
return current;
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,60 +0,0 @@
|
||||||
package net.rifthq.typa.utils;
|
|
||||||
|
|
||||||
import org.bukkit.plugin.java.*;
|
|
||||||
import java.io.*;
|
|
||||||
import org.bukkit.configuration.file.*;
|
|
||||||
|
|
||||||
public class Config
|
|
||||||
{
|
|
||||||
private FileConfiguration Config;
|
|
||||||
private File File;
|
|
||||||
private String Name;
|
|
||||||
|
|
||||||
public Config(final JavaPlugin Plugin, final String Path, final String Name)
|
|
||||||
{
|
|
||||||
(this.File = new File(Plugin.getDataFolder() + Path)).mkdirs();
|
|
||||||
this.File = new File(Plugin.getDataFolder() + Path, String.valueOf(Name) + ".yml");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.File.createNewFile();
|
|
||||||
}
|
|
||||||
catch (IOException ex)
|
|
||||||
{}
|
|
||||||
this.Name = Name;
|
|
||||||
this.Config = (FileConfiguration) YamlConfiguration.loadConfiguration(this.File);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return this.Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileConfiguration getConfig()
|
|
||||||
{
|
|
||||||
return this.Config;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefault(final String Path, final Object Set)
|
|
||||||
{
|
|
||||||
if (!this.getConfig().contains(Path))
|
|
||||||
{
|
|
||||||
this.Config.set(Path, Set);
|
|
||||||
this.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void save()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.Config.save(this.File);
|
|
||||||
}
|
|
||||||
catch (IOException ex)
|
|
||||||
{}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reload()
|
|
||||||
{
|
|
||||||
this.Config = (FileConfiguration) YamlConfiguration.loadConfiguration(this.File);
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,10 +0,0 @@
|
||||||
package net.rifthq.typa.utils;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class Lists {
|
|
||||||
|
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
||||||
public static ArrayList<String> toLogin = new ArrayList();
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
name: Typa
|
|
||||||
version: 1.2
|
|
||||||
main: net.rifthq.typa.Typa
|
|
||||||
author: [puttydotexe, Mans]
|
|
||||||
commands:
|
|
||||||
register:
|
|
||||||
description: Command used to register a staff account.
|
|
||||||
login:
|
|
||||||
description: Command used to log into a staff account.
|
|
||||||
resetpin:
|
|
||||||
description: Command used to reset a staff accounts pin.
|
|
||||||
resetplayer:
|
|
||||||
description: Command used to reset a staff account.
|
|
Loading…
Reference in New Issue