mirror of
https://github.com/TotalFreedomMC/TFGuilds.git
synced 2024-12-22 16:05:00 +00:00
Modification to SQL statements and fix invites (#8)
* Add primary key (rowid) to database * Fix players not being able to join after being invited
This commit is contained in:
parent
a1a1f8edb0
commit
8636c88f94
5 changed files with 17 additions and 11 deletions
|
@ -73,7 +73,7 @@ public class InviteSubCommand extends Common implements SubCommand
|
||||||
|
|
||||||
guild.invite(player);
|
guild.invite(player);
|
||||||
player.sendMessage(PREFIX + ChatColor.GOLD + sender.getName() + ChatColor.GRAY + " has sent you an invite to join " + ChatColor.GOLD + guild.getName());
|
player.sendMessage(PREFIX + ChatColor.GOLD + sender.getName() + ChatColor.GRAY + " has sent you an invite to join " + ChatColor.GOLD + guild.getName());
|
||||||
player.sendMessage("Do " + ChatColor.GOLD + "/g join " + guild.getName() + ChatColor.GRAY + " to join!");
|
player.sendMessage(PREFIX + "Do " + ChatColor.GOLD + "/g join " + guild.getName() + ChatColor.GRAY + " to join!");
|
||||||
player.sendMessage(PREFIX + "The invite will expire in 90 seconds.");
|
player.sendMessage(PREFIX + "The invite will expire in 90 seconds.");
|
||||||
sender.sendMessage(PREFIX + "The invite has been sent to " + ChatColor.GOLD + player.getName());
|
sender.sendMessage(PREFIX + "The invite has been sent to " + ChatColor.GOLD + player.getName());
|
||||||
|
|
||||||
|
@ -86,7 +86,9 @@ public class InviteSubCommand extends Common implements SubCommand
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
guild.removeInvite(player);
|
guild.removeInvite(player);
|
||||||
|
|
||||||
if (player.isOnline())
|
if (player.isOnline())
|
||||||
{
|
{
|
||||||
player.sendMessage(PREFIX + "The invite to " + ChatColor.GOLD + guild.getName() + ChatColor.GRAY + " has expired!");
|
player.sendMessage(PREFIX + "The invite to " + ChatColor.GOLD + guild.getName() + ChatColor.GRAY + " has expired!");
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class JoinSubCommand extends Common implements SubCommand
|
||||||
|
|
||||||
if (guild.getState() == Guild.State.INVITE_ONLY)
|
if (guild.getState() == Guild.State.INVITE_ONLY)
|
||||||
{
|
{
|
||||||
if (guild.isInvited(playerSender))
|
if (!guild.isInvited(playerSender))
|
||||||
{
|
{
|
||||||
sender.sendMessage(PREFIX + "You must be invited to join the guild.");
|
sender.sendMessage(PREFIX + "You must be invited to join the guild.");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -353,7 +353,7 @@ public class Guild
|
||||||
Connection connection = TFGuilds.getPlugin().getSQL().getConnection();
|
Connection connection = TFGuilds.getPlugin().getSQL().getConnection();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO ranks (guild_id, name, members) VALUES (?, ?, ?)");
|
PreparedStatement statement = connection.prepareStatement("INSERT INTO ranks (`guild_id`, `name`, `members`) VALUES (?, ?, ?)");
|
||||||
statement.setString(1, id);
|
statement.setString(1, id);
|
||||||
statement.setString(2, name);
|
statement.setString(2, name);
|
||||||
statement.setString(3, null);
|
statement.setString(3, null);
|
||||||
|
@ -475,7 +475,8 @@ public class Guild
|
||||||
Connection connection = TFGuilds.getPlugin().getSQL().getConnection();
|
Connection connection = TFGuilds.getPlugin().getSQL().getConnection();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement statement = newSave ? connection.prepareStatement("INSERT INTO guilds VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
PreparedStatement statement = newSave ? connection.prepareStatement("INSERT INTO guilds (`id`, `name`, `owner`, `moderators`, `members`, `tag`, `default_rank`, `state`, `motd`, `x`, `y`, `z`, `world`, `creation`)" +
|
||||||
|
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
||||||
: connection.prepareStatement("UPDATE guilds SET owner=?," +
|
: connection.prepareStatement("UPDATE guilds SET owner=?," +
|
||||||
"moderators=?," +
|
"moderators=?," +
|
||||||
"members=?," +
|
"members=?," +
|
||||||
|
@ -559,7 +560,7 @@ public class Guild
|
||||||
Connection connection = TFGuilds.getPlugin().getSQL().getConnection();
|
Connection connection = TFGuilds.getPlugin().getSQL().getConnection();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO warps VALUES (?, ?, ?, ?, ?, ?)");
|
PreparedStatement statement = connection.prepareStatement("INSERT INTO warps (`guild_id`, `name`, `x`, `y`, `z`, `world`) VALUES (?, ?, ?, ?, ?, ?)");
|
||||||
statement.setString(1, id);
|
statement.setString(1, id);
|
||||||
statement.setString(2, name);
|
statement.setString(2, name);
|
||||||
Location location = warps.get(name);
|
Location location = warps.get(name);
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class User
|
||||||
Connection connection = TFGuilds.getPlugin().getSQL().getConnection();
|
Connection connection = TFGuilds.getPlugin().getSQL().getConnection();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement statement = newSave ? connection.prepareStatement("INSERT INTO users VALUES (?, ?, ?)")
|
PreparedStatement statement = newSave ? connection.prepareStatement("INSERT INTO users (`uuid`, `id`, `tag`) VALUES (?, ?, ?)")
|
||||||
: connection.prepareStatement("UPDATE users SET tag=? WHERE id=?");
|
: connection.prepareStatement("UPDATE users SET tag=? WHERE id=?");
|
||||||
if (newSave)
|
if (newSave)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,6 @@ public class SQLDatabase
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Bukkit.getLogger().info(ConfigEntry.MYSQL_USERNAME.getString());
|
|
||||||
connection = DriverManager.getConnection(String.format("jdbc:mysql://%s:%d/%s",
|
connection = DriverManager.getConnection(String.format("jdbc:mysql://%s:%d/%s",
|
||||||
ConfigEntry.MYSQL_HOST.getString(),
|
ConfigEntry.MYSQL_HOST.getString(),
|
||||||
ConfigEntry.MYSQL_PORT.getInteger(),
|
ConfigEntry.MYSQL_PORT.getInteger(),
|
||||||
|
@ -47,7 +46,8 @@ public class SQLDatabase
|
||||||
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `users` (" +
|
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `users` (" +
|
||||||
"`uuid` TEXT," +
|
"`uuid` TEXT," +
|
||||||
"`id` INT," +
|
"`id` INT," +
|
||||||
"`tag` BOOLEAN)")
|
"`tag` BOOLEAN," +
|
||||||
|
"`rowid` INTEGER AUTO_INCREMENT PRIMARY KEY)")
|
||||||
.execute();
|
.execute();
|
||||||
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `warps` (" +
|
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `warps` (" +
|
||||||
"`guild_id` TEXT," +
|
"`guild_id` TEXT," +
|
||||||
|
@ -55,7 +55,8 @@ public class SQLDatabase
|
||||||
"`x` DOUBLE," +
|
"`x` DOUBLE," +
|
||||||
"`y` DOUBLE," +
|
"`y` DOUBLE," +
|
||||||
"`z` DOUBLE," +
|
"`z` DOUBLE," +
|
||||||
"`world` TEXT)")
|
"`world` TEXT," +
|
||||||
|
"`rowid` INTEGER AUTO_INCREMENT PRIMARY KEY)")
|
||||||
.execute();
|
.execute();
|
||||||
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `guilds` (" +
|
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `guilds` (" +
|
||||||
"`id` TEXT," +
|
"`id` TEXT," +
|
||||||
|
@ -71,12 +72,14 @@ public class SQLDatabase
|
||||||
"`y` DOUBLE," +
|
"`y` DOUBLE," +
|
||||||
"`z` DOUBLE," +
|
"`z` DOUBLE," +
|
||||||
"`world` TEXT," +
|
"`world` TEXT," +
|
||||||
"`creation` LONG)")
|
"`creation` LONG," +
|
||||||
|
"`rowid` INTEGER AUTO_INCREMENT PRIMARY KEY)")
|
||||||
.execute();
|
.execute();
|
||||||
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `ranks` (" +
|
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `ranks` (" +
|
||||||
"`guild_id` TEXT," +
|
"`guild_id` TEXT," +
|
||||||
"`name` TEXT," +
|
"`name` TEXT," +
|
||||||
"`members` TEXT)")
|
"`members` TEXT," +
|
||||||
|
"`rowid` INTEGER AUTO_INCREMENT PRIMARY KEY)")
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue