mirror of
https://github.com/TotalFreedomMC/TFGuilds.git
synced 2024-12-22 16:05:00 +00:00
guild warps (FS-1)
* adds guild warps * some more message standardization * formatting * alphabetize help subcommand and guild command
This commit is contained in:
parent
2701a5de4a
commit
13c6063474
45 changed files with 600 additions and 109 deletions
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>me.totalfreedom</groupId>
|
||||
<artifactId>TFGuilds</artifactId>
|
||||
<version>0.3.0</version>
|
||||
<version>0.3.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>TFGuilds</name>
|
||||
|
|
|
@ -19,6 +19,7 @@ public class Common
|
|||
public static final String NO_PERMS = ChatColor.RED + "No permission.";
|
||||
public static final String PREFIX = "%s%[%p%TFGuilds%s%] %p%";
|
||||
public static final String PNF = ChatColor.RED + "Player not found.";
|
||||
public static final String NG = ChatColor.RED + "You aren't in a guild!";
|
||||
|
||||
public static Map<Player, Guild> INVITES = new HashMap<>();
|
||||
public static List<Player> IN_GUILD_CHAT = new ArrayList<>();
|
||||
|
|
|
@ -12,6 +12,7 @@ import me.totalfreedom.tfguilds.sql.SQLDatabase;
|
|||
import me.totalfreedom.tfguilds.sql.SQLGuildData;
|
||||
import me.totalfreedom.tfguilds.sql.SQLRankData;
|
||||
import me.totalfreedom.tfguilds.sql.SQLUserData;
|
||||
import me.totalfreedom.tfguilds.sql.SQLWarpData;
|
||||
import me.totalfreedom.tfguilds.sql.SQLWorldData;
|
||||
import me.totalfreedom.tfguilds.util.GLog;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
@ -31,8 +32,9 @@ public final class TFGuilds extends JavaPlugin
|
|||
public SQLDatabase sql;
|
||||
public SQLGuildData guildData;
|
||||
public SQLRankData rankData;
|
||||
public SQLWorldData worldData;
|
||||
public SQLUserData userData;
|
||||
public SQLWarpData warpData;
|
||||
public SQLWorldData worldData;
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
|
@ -43,8 +45,9 @@ public final class TFGuilds extends JavaPlugin
|
|||
sql = new SQLDatabase();
|
||||
guildData = new SQLGuildData();
|
||||
rankData = new SQLRankData();
|
||||
worldData = new SQLWorldData();
|
||||
userData = new SQLUserData();
|
||||
warpData = new SQLWarpData();
|
||||
worldData = new SQLWorldData();
|
||||
loadCommands();
|
||||
loadListeners();
|
||||
GLog.info("Enabled " + this.getDescription().getFullName());
|
||||
|
|
|
@ -79,7 +79,7 @@ public class AddModSubcommand extends Common implements CommandExecutor
|
|||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public class ChatSubcommand extends Common implements CommandExecutor
|
|||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ public class CreateRankSubcommand extends Common implements CommandExecutor
|
|||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public class CreateSubcommand extends Common implements CommandExecutor
|
|||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
Player player = (Player)sender;
|
||||
String name = StringUtils.join(args, " ", 1, args.length);
|
||||
String identifier = GUtil.flatten(name);
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public class DeleteRankSubcommand extends Common implements CommandExecutor
|
|||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package me.totalfreedom.tfguilds.command;
|
||||
|
||||
import me.totalfreedom.tfguilds.Common;
|
||||
import me.totalfreedom.tfguilds.guild.Guild;
|
||||
import me.totalfreedom.tfguilds.guild.GuildWarp;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
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;
|
||||
|
||||
public class DeleteWarpSubcommand extends Common implements CommandExecutor
|
||||
{
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
sender.sendMessage(tl(PREFIX + "Proper usage: /g deletewarp <name>"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player)sender;
|
||||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!guild.hasModerator(player.getUniqueId()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "Only guild moderators and guild owners are allowed to create guild warps.");
|
||||
return true;
|
||||
}
|
||||
|
||||
String warpName = StringUtils.join(args, " ", 1, args.length);
|
||||
if (!Guild.warpExists(guild.getIdentifier(), warpName))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "Warp not found.");
|
||||
return true;
|
||||
}
|
||||
|
||||
GuildWarp warp = plugin.warpData.get(guild.getIdentifier(), warpName);
|
||||
plugin.warpData.delete(warp);
|
||||
sender.sendMessage(tl(PREFIX + "Deleted guild warp \"" + warpName + "\"."));
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -56,7 +56,7 @@ public class DisbandSubcommand extends Common implements CommandExecutor
|
|||
Player player = (Player)sender;
|
||||
if (!Guild.isInGuild(player))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public class GuildChatCommand extends Common implements CommandExecutor
|
|||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,60 +21,69 @@ public class GuildCommand extends Common implements CommandExecutor, TabComplete
|
|||
{
|
||||
switch (args[0].toLowerCase())
|
||||
{
|
||||
case "list":
|
||||
return new ListSubcommand().onCommand(sender, command, label, args);
|
||||
case "help":
|
||||
return new HelpSubcommand().onCommand(sender, command, label, args);
|
||||
case "create":
|
||||
return new CreateSubcommand().onCommand(sender, command, label, args);
|
||||
case "disband":
|
||||
return new DisbandSubcommand().onCommand(sender, command, label, args);
|
||||
case "invite":
|
||||
return new InviteSubcommand().onCommand(sender, command, label, args);
|
||||
// Please keep the commands here & in HelpSubcommand.java in alphabetical order
|
||||
case "addmod":
|
||||
return new AddModSubcommand().onCommand(sender, command, label, args);
|
||||
case "removemod":
|
||||
return new RemoveModSubcommand().onCommand(sender, command, label, args);
|
||||
case "setowner":
|
||||
return new SetOwnerSubcommand().onCommand(sender, command, label, args);
|
||||
case "setstate":
|
||||
return new SetStateSubcommand().onCommand(sender, command, label, args);
|
||||
case "chat":
|
||||
return new ChatSubcommand().onCommand(sender, command, label, args);
|
||||
case "createrank":
|
||||
return new CreateRankSubcommand().onCommand(sender, command, label, args);
|
||||
case "create":
|
||||
return new CreateSubcommand().onCommand(sender, command, label, args);
|
||||
case "deleterank":
|
||||
return new DeleteRankSubcommand().onCommand(sender, command, label, args);
|
||||
case "deletewarp":
|
||||
return new DeleteWarpSubcommand().onCommand(sender, command, label, args);
|
||||
case "disband":
|
||||
return new DisbandSubcommand().onCommand(sender, command, label, args);
|
||||
case "help":
|
||||
return new HelpSubcommand().onCommand(sender, command, label, args);
|
||||
case "home":
|
||||
return new HomeSubcommand().onCommand(sender, command, label, args);
|
||||
case "info":
|
||||
return new InfoSubcommand().onCommand(sender, command, label, args);
|
||||
case "invite":
|
||||
return new InviteSubcommand().onCommand(sender, command, label, args);
|
||||
case "join":
|
||||
return new JoinSubcommand().onCommand(sender, command, label, args);
|
||||
case "kick":
|
||||
return new KickSubcommand().onCommand(sender, command, label, args);
|
||||
case "leave":
|
||||
return new LeaveSubcommand().onCommand(sender, command, label, args);
|
||||
case "tp":
|
||||
return new TPSubcommand().onCommand(sender, command, label, args);
|
||||
case "info":
|
||||
return new InfoSubcommand().onCommand(sender, command, label, args);
|
||||
case "tag":
|
||||
return new TagSubcommand().onCommand(sender, command, label, args);
|
||||
case "chat":
|
||||
return new ChatSubcommand().onCommand(sender, command, label, args);
|
||||
case "join":
|
||||
return new JoinSubcommand().onCommand(sender, command, label, args);
|
||||
case "rename":
|
||||
return new RenameSubcommand().onCommand(sender, command, label, args);
|
||||
case "createrank":
|
||||
return new CreateRankSubcommand().onCommand(sender, command, label, args);
|
||||
case "deleterank":
|
||||
return new DeleteRankSubcommand().onCommand(sender, command, label, args);
|
||||
case "setrank":
|
||||
return new SetRankSubcommand().onCommand(sender, command, label, args);
|
||||
case "list":
|
||||
return new ListSubcommand().onCommand(sender, command, label, args);
|
||||
case "motd":
|
||||
return new MOTDSubcommand().onCommand(sender, command, label, args);
|
||||
case "home":
|
||||
return new HomeSubcommand().onCommand(sender, command, label, args);
|
||||
case "removemod":
|
||||
return new RemoveModSubcommand().onCommand(sender, command, label, args);
|
||||
case "rename":
|
||||
return new RenameSubcommand().onCommand(sender, command, label, args);
|
||||
case "roster":
|
||||
return new RosterSubcommand().onCommand(sender, command, label, args);
|
||||
case "setdefaultrank":
|
||||
return new SetDefaultRankSubcommand().onCommand(sender, command, label, args);
|
||||
case "setmember":
|
||||
return new SetMemberSubcommand().onCommand(sender, command, label, args);
|
||||
case "setowner":
|
||||
return new SetOwnerSubcommand().onCommand(sender, command, label, args);
|
||||
case "setrank":
|
||||
return new SetRankSubcommand().onCommand(sender, command, label, args);
|
||||
case "setstate":
|
||||
return new SetStateSubcommand().onCommand(sender, command, label, args);
|
||||
case "setwarp":
|
||||
return new SetWarpSubcommand().onCommand(sender, command, label, args);
|
||||
case "tag":
|
||||
return new TagSubcommand().onCommand(sender, command, label, args);
|
||||
case "toggletags":
|
||||
return new ToggleTagsSubcommand().onCommand(sender, command, label, args);
|
||||
case "toggletag":
|
||||
return new ToggleTagSubcommand().onCommand(sender, command, label, args);
|
||||
case "setmember":
|
||||
return new SetMemberSubcommand().onCommand(sender, command, label, args);
|
||||
case "tp":
|
||||
return new TPSubcommand().onCommand(sender, command, label, args);
|
||||
case "warps":
|
||||
return new WarpsSubcommand().onCommand(sender, command, label, args);
|
||||
case "warp":
|
||||
return new WarpSubcommand().onCommand(sender, command, label, args);
|
||||
}
|
||||
sender.sendMessage(tl(PREFIX + "Unknown command - Run /g help if you need help"));
|
||||
return true;
|
||||
|
@ -88,10 +97,10 @@ public class GuildCommand extends Common implements CommandExecutor, TabComplete
|
|||
if (args.length == 1)
|
||||
{
|
||||
return Arrays.asList("addmod", "chat", "createrank", "create",
|
||||
"deleterank", "disband", "help", "home", "info", "invite",
|
||||
"deleterank", "deletewarp", "disband", "help", "home", "info", "invite",
|
||||
"join", "kick", "leave", "list", "motd", "removemod", "rename",
|
||||
"roster", "setowner", "setrank", "setstate", "tag", "tp", "setdefaultrank",
|
||||
"toggletags", "toggletag", "setmember");
|
||||
"roster", "setdefaultrank", "setmember", "setowner", "setrank", "setstate",
|
||||
"setwarp", "tag", "toggletags", "toggletag", "tp", "warps", "warp");
|
||||
}
|
||||
else if (args.length == 2)
|
||||
{
|
||||
|
@ -141,7 +150,7 @@ public class GuildCommand extends Common implements CommandExecutor, TabComplete
|
|||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
Player player = (Player) sender;
|
||||
Player player = (Player)sender;
|
||||
Guild guild = Guild.getGuild(player);
|
||||
if (guild.getOwner().equals(player.getUniqueId()))
|
||||
{
|
||||
|
@ -154,7 +163,7 @@ public class GuildCommand extends Common implements CommandExecutor, TabComplete
|
|||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
Player player = (Player) sender;
|
||||
Player player = (Player)sender;
|
||||
Guild guild = Guild.getGuild(player);
|
||||
return guild.getOnlyMembers();
|
||||
}
|
||||
|
@ -174,7 +183,7 @@ public class GuildCommand extends Common implements CommandExecutor, TabComplete
|
|||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
Player player = (Player) sender;
|
||||
Player player = (Player)sender;
|
||||
Guild guild = Guild.getGuild(player);
|
||||
if (guild.hasModerator(player.getUniqueId()))
|
||||
{
|
||||
|
@ -189,7 +198,7 @@ public class GuildCommand extends Common implements CommandExecutor, TabComplete
|
|||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
Player player = (Player) sender;
|
||||
Player player = (Player)sender;
|
||||
Guild guild = Guild.getGuild(player);
|
||||
if (guild.getOwner().equals(player.getUniqueId()))
|
||||
{
|
||||
|
@ -197,6 +206,15 @@ public class GuildCommand extends Common implements CommandExecutor, TabComplete
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
case "deletewarp":
|
||||
case "warp":
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
return Guild.getGuildWarps();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
|
|
|
@ -10,34 +10,39 @@ public class HelpSubcommand extends Common implements CommandExecutor
|
|||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
// Please keep the commands here & in GuildCommand.java in alphabetical order
|
||||
sender.sendMessage(tl("%s%[%p%TFGuilds%s%] %p%Command List"));
|
||||
sender.sendMessage(tl("%s% - %p%list"));
|
||||
sender.sendMessage(tl("%s% - %p%help"));
|
||||
sender.sendMessage(tl("%s% - %p%create <name>"));
|
||||
sender.sendMessage(tl("%s% - %p%join <guild>"));
|
||||
sender.sendMessage(tl("%s% - %p%disband [name]"));
|
||||
sender.sendMessage(tl("%s% - %p%invite <player>"));
|
||||
sender.sendMessage(tl("%s% - %p%addmod <guild <player> | player>"));
|
||||
sender.sendMessage(tl("%s% - %p%removemod <guild <name> | name>"));
|
||||
sender.sendMessage(tl("%s% - %p%setowner <guild <player> | player>"));
|
||||
sender.sendMessage(tl("%s% - %p%chat [message]"));
|
||||
sender.sendMessage(tl("%s% - %p%createrank <name>"));
|
||||
sender.sendMessage(tl("%s% - %p%create <name>"));
|
||||
sender.sendMessage(tl("%s% - %p%deleterank <rank>"));
|
||||
sender.sendMessage(tl("%s% - %p%deletewarp <warp>"));
|
||||
sender.sendMessage(tl("%s% - %p%disband [name]"));
|
||||
sender.sendMessage(tl("%s% - %p%help"));
|
||||
sender.sendMessage(tl("%s% - %p%home [set]"));
|
||||
sender.sendMessage(tl("%s% - %p%info [guild | player]"));
|
||||
sender.sendMessage(tl("%s% - %p%invite <player>"));
|
||||
sender.sendMessage(tl("%s% - %p%join <guild>"));
|
||||
sender.sendMessage(tl("%s% - %p%kick <guild <player> | player>"));
|
||||
sender.sendMessage(tl("%s% - %p%leave"));
|
||||
sender.sendMessage(tl("%s% - %p%tp <player>"));
|
||||
sender.sendMessage(tl("%s% - %p%info [guild | player]"));
|
||||
sender.sendMessage(tl("%s% - %p%tag <set <tag> | clear>"));
|
||||
sender.sendMessage(tl("%s% - %p%rename <name>"));
|
||||
sender.sendMessage(tl("%s% - %p%createrank <name>"));
|
||||
sender.sendMessage(tl("%s% - %p%deleterank <rank>"));
|
||||
sender.sendMessage(tl("%s% - %p%setrank <player> <rank | none>"));
|
||||
sender.sendMessage(tl("%s% - %p%list [page]"));
|
||||
sender.sendMessage(tl("%s% - %p%motd <set <motd> | clear>"));
|
||||
sender.sendMessage(tl("%s% - %p%home [set]"));
|
||||
sender.sendMessage(tl("%s% - %p%chat [message]"));
|
||||
sender.sendMessage(tl("%s% - %p%removemod <guild <name> | name>"));
|
||||
sender.sendMessage(tl("%s% - %p%rename <name>"));
|
||||
sender.sendMessage(tl("%s% - %p%roster [guild | player]"));
|
||||
sender.sendMessage(tl("%s% - %p%setstate <open | invite | closed>"));
|
||||
sender.sendMessage(tl("%s% - %p%setdefaultrank <rank | none>"));
|
||||
sender.sendMessage(tl("%s% - %p%setmember <guild> <player>"));
|
||||
sender.sendMessage(tl("%s% - %p%setowner <guild <player> | player>"));
|
||||
sender.sendMessage(tl("%s% - %p%setrank <player> <rank | none>"));
|
||||
sender.sendMessage(tl("%s% - %p%setstate <open | invite | closed>"));
|
||||
sender.sendMessage(tl("%s% - %p%setwarp <name>"));
|
||||
sender.sendMessage(tl("%s% - %p%tag <set <tag> | clear [guild]>>"));
|
||||
sender.sendMessage(tl("%s% - %p%toggletags"));
|
||||
sender.sendMessage(tl("%s% - %p%toggletag [player]"));
|
||||
sender.sendMessage(tl("%s% - %p%setmember <guild> <player>"));
|
||||
sender.sendMessage(tl("%s% - %p%tp <player>"));
|
||||
sender.sendMessage(tl("%s% - %p%warps"));
|
||||
sender.sendMessage(tl("%s% - %p%warp <name>"));
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ public class HomeSubcommand extends Common implements CommandExecutor
|
|||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ public class InfoSubcommand extends Common implements CommandExecutor
|
|||
Guild guild = Guild.getGuild((Player)sender);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ public class InviteSubcommand extends Common implements CommandExecutor
|
|||
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public class KickSubcommand extends Common implements CommandExecutor
|
|||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public class LeaveSubcommand extends Common implements CommandExecutor
|
|||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,20 +41,20 @@ public class ListSubcommand extends Common implements CommandExecutor
|
|||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "Invalid number");
|
||||
sender.sendMessage(ChatColor.RED + "Invalid number.");
|
||||
}
|
||||
}
|
||||
|
||||
if (pageIndex < 1 || pageIndex > paged.getPageCount())
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "Not a valid page number");
|
||||
sender.sendMessage(ChatColor.RED + "Not a valid page number.");
|
||||
return true;
|
||||
}
|
||||
|
||||
paged.getPage(pageIndex);
|
||||
List<String> page = paged.getPage(pageIndex);
|
||||
|
||||
sender.sendMessage(tl(PREFIX + "%s%Guild List (%p%" + guilds.size() + " total%s%) [%p%Page " + pageIndex + "%s%/%p%" + paged.getPageCount() + "%s%]"));
|
||||
sender.sendMessage(tl(PREFIX + "%s%Guild list (%p%" + guilds.size() + " total%s%) [%p%Page " + pageIndex + "%s%/%p%" + paged.getPageCount() + "%s%]"));
|
||||
|
||||
for (String guild : page)
|
||||
{
|
||||
|
|
|
@ -32,7 +32,7 @@ public class MOTDSubcommand extends Common implements CommandExecutor
|
|||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public class RemoveModSubcommand extends Common implements CommandExecutor
|
|||
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
if (guild.getModerators().contains(((Player) sender).getUniqueId()))
|
||||
if (guild.getModerators().contains(((Player)sender).getUniqueId()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You may not demote yourself.");
|
||||
return true;
|
||||
|
@ -82,7 +82,7 @@ public class RemoveModSubcommand extends Common implements CommandExecutor
|
|||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public class RenameSubcommand extends Common implements CommandExecutor
|
|||
String identifier = GUtil.flatten(newName);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ public class RosterSubcommand extends Common implements CommandExecutor
|
|||
Guild guild = Guild.getGuild((Player)sender);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public class SetDefaultRankSubcommand extends Common implements CommandExecutor
|
|||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public class SetOwnerSubcommand extends Common implements CommandExecutor
|
|||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ public class SetRankSubcommand extends Common implements CommandExecutor
|
|||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ public class SetStateSubcommand extends Common implements CommandExecutor
|
|||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package me.totalfreedom.tfguilds.command;
|
||||
|
||||
import me.totalfreedom.tfguilds.Common;
|
||||
import me.totalfreedom.tfguilds.guild.Guild;
|
||||
import me.totalfreedom.tfguilds.guild.GuildWarp;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
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;
|
||||
|
||||
public class SetWarpSubcommand extends Common implements CommandExecutor
|
||||
{
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
sender.sendMessage(tl(PREFIX + "Proper usage: /g setwarp <name>"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player)sender;
|
||||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!guild.hasModerator(player.getUniqueId()))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "Only guild moderators and guild owners are allowed to create guild warps.");
|
||||
return true;
|
||||
}
|
||||
|
||||
String warpName = StringUtils.join(args, " ", 1, args.length);
|
||||
if (Guild.warpExists(guild.getIdentifier(), warpName))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "A warp with that name already exists.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Guild.createWarp(guild.getIdentifier(), warpName, player);
|
||||
sender.sendMessage(tl(PREFIX + "Successfully created new guild warp \"" + warpName + "\"."));
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -31,7 +31,7 @@ public class TPSubcommand extends Common implements CommandExecutor
|
|||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public class TagSubcommand extends Common implements CommandExecutor
|
|||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public class ToggleTagSubcommand extends Common implements CommandExecutor
|
|||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
package me.totalfreedom.tfguilds.command;
|
||||
|
||||
import me.totalfreedom.tfguilds.Common;
|
||||
import me.totalfreedom.tfguilds.guild.Guild;
|
||||
import me.totalfreedom.tfguilds.guild.GuildWarp;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
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;
|
||||
|
||||
public class WarpSubcommand extends Common implements CommandExecutor
|
||||
{
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
sender.sendMessage(tl(PREFIX + "Proper usage: /g warp <name>"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player)sender;
|
||||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
String warpName = StringUtils.join(args, " ", 1, args.length);
|
||||
if (!Guild.warpExists(guild.getIdentifier(), warpName))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "Warp not found.");
|
||||
return true;
|
||||
}
|
||||
|
||||
GuildWarp warp = plugin.warpData.get(guild.getIdentifier(), warpName);
|
||||
Location warpLoc = new Location(warp.getWorld(), warp.getX(), warp.getY(), warp.getZ());
|
||||
player.teleport(warpLoc);
|
||||
sender.sendMessage(tl(PREFIX + "Warping to \"" + warpName + "\"."));
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package me.totalfreedom.tfguilds.command;
|
||||
|
||||
import java.util.List;
|
||||
import me.totalfreedom.tfguilds.Common;
|
||||
import me.totalfreedom.tfguilds.guild.Guild;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
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;
|
||||
|
||||
public class WarpsSubcommand extends Common implements CommandExecutor
|
||||
{
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (sender instanceof ConsoleCommandSender)
|
||||
{
|
||||
sender.sendMessage(NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player)sender;
|
||||
Guild guild = Guild.getGuild(player);
|
||||
if (guild == null)
|
||||
{
|
||||
sender.sendMessage(NG);
|
||||
return true;
|
||||
}
|
||||
|
||||
List<String> warps = Guild.getGuildWarps();
|
||||
sender.sendMessage(tl(PREFIX + "%s%Guild warps (%p%" + warps.size() + " total%s%)\n%p%" + StringUtils.join(warps, "%s%,%p% ")));
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -234,7 +234,9 @@ public class Guild
|
|||
for (UUID moderator : moderators)
|
||||
{
|
||||
if (moderator.equals(owner))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(moderator);
|
||||
only.add(player.getName());
|
||||
}
|
||||
|
@ -288,10 +290,22 @@ public class Guild
|
|||
{
|
||||
List<String> g = new ArrayList<>();
|
||||
for (Guild guild : plugin.guildData.getAll())
|
||||
{
|
||||
g.add(guild.getName());
|
||||
}
|
||||
return g;
|
||||
}
|
||||
|
||||
public static List<String> getGuildWarps()
|
||||
{
|
||||
List<String> warps = new ArrayList<>();
|
||||
for (GuildWarp warp : plugin.warpData.getAll())
|
||||
{
|
||||
warps.add(warp.getWarpName());
|
||||
}
|
||||
return warps;
|
||||
}
|
||||
|
||||
public String getInformation()
|
||||
{
|
||||
return Common.tl(Common.PREFIX + "Guild Information\n" +
|
||||
|
@ -339,7 +353,9 @@ public class Guild
|
|||
{
|
||||
Player player = Bukkit.getPlayer(member);
|
||||
if (player == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Common.IN_GUILD_CHAT.remove(player);
|
||||
}
|
||||
plugin.guildData.delete(this);
|
||||
|
@ -358,13 +374,17 @@ public class Guild
|
|||
public void updateRankIdentifiers()
|
||||
{
|
||||
for (GuildRank rank : ranks)
|
||||
{
|
||||
rank.updateGuildIdentifier(identifier);
|
||||
}
|
||||
}
|
||||
|
||||
public static Guild createGuild(String identifier, String name, Player owner)
|
||||
{
|
||||
if (plugin.guildData.exists(identifier))
|
||||
{
|
||||
return getGuild(identifier);
|
||||
}
|
||||
|
||||
Guild guild = plugin.guildData.create(identifier, name, owner);
|
||||
GLog.info(owner.getName() + " has created guild " + name);
|
||||
|
@ -390,4 +410,14 @@ public class Guild
|
|||
{
|
||||
return getGuild(player) != null;
|
||||
}
|
||||
|
||||
public static GuildWarp createWarp(String identifier, String warpName, Player player)
|
||||
{
|
||||
return GuildWarp.createGuildWarp(identifier, warpName, player);
|
||||
}
|
||||
|
||||
public static boolean warpExists(String identifier, String warpName)
|
||||
{
|
||||
return plugin.warpData.exists(identifier, warpName);
|
||||
}
|
||||
}
|
44
src/main/java/me/totalfreedom/tfguilds/guild/GuildWarp.java
Normal file
44
src/main/java/me/totalfreedom/tfguilds/guild/GuildWarp.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
package me.totalfreedom.tfguilds.guild;
|
||||
|
||||
import lombok.Getter;
|
||||
import me.totalfreedom.tfguilds.TFGuilds;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Getter
|
||||
public class GuildWarp
|
||||
{
|
||||
private static final TFGuilds plugin = TFGuilds.getPlugin();
|
||||
|
||||
private final String iguild;
|
||||
private final String warpName;
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
private final World world;
|
||||
|
||||
public GuildWarp(String iguild, String warpName, double x, double y, double z, World world)
|
||||
{
|
||||
this.iguild = iguild;
|
||||
this.warpName = warpName;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public static GuildWarp createGuildWarp(String identifier, String name, Player player)
|
||||
{
|
||||
return plugin.warpData.create(identifier, name, player);
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
plugin.warpData.save(this);
|
||||
}
|
||||
|
||||
public void delete()
|
||||
{
|
||||
plugin.warpData.delete(this);
|
||||
}
|
||||
}
|
|
@ -71,7 +71,10 @@ public class ChatListener implements Listener
|
|||
}
|
||||
|
||||
User user = plugin.userData.get(player.getUniqueId());
|
||||
if (!user.isTag()) return;
|
||||
if (!user.isTag())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (guild.hasTag())
|
||||
{
|
||||
|
|
|
@ -69,6 +69,14 @@ public class SQLDatabase
|
|||
"\t`default_rank` TEXT,\n" +
|
||||
"\t`creation` BIGINT\n" +
|
||||
");").execute();
|
||||
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `warps` (\n" +
|
||||
"\t`identifier` TEXT,\n" +
|
||||
"\t`warp_name` TEXT,\n" +
|
||||
"\t`x` DOUBLE,\n" +
|
||||
"\t`y` DOUBLE,\n" +
|
||||
"\t`z` DOUBLE,\n" +
|
||||
"\t`world` SMALLINT\n" +
|
||||
");").execute();
|
||||
return connection;
|
||||
}
|
||||
catch (SQLException ex)
|
||||
|
|
|
@ -56,17 +56,24 @@ public class SQLGuildData
|
|||
statement.setString(1, identifier);
|
||||
ResultSet set = statement.executeQuery();
|
||||
boolean next = set.next();
|
||||
if (!next) return null;
|
||||
if (!next)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String name = set.getString("name");
|
||||
UUID owner = plugin.userData.get(set.getInt("owner")).getUuid();
|
||||
List<UUID> members = new ArrayList<>();
|
||||
for (String stringMember : set.getString("members").split(","))
|
||||
{
|
||||
members.add(plugin.userData.get(Integer.parseInt(stringMember)).getUuid());
|
||||
}
|
||||
List<UUID> moderators = new ArrayList<>();
|
||||
if (set.getString("moderators") != null)
|
||||
{
|
||||
for (String stringModerator : set.getString("moderators").split(","))
|
||||
{
|
||||
moderators.add(plugin.userData.get(Integer.parseInt(stringModerator)).getUuid());
|
||||
}
|
||||
}
|
||||
String tag = set.getString("tag");
|
||||
GuildState state = GuildState.values()[set.getInt("state")];
|
||||
|
@ -74,7 +81,9 @@ public class SQLGuildData
|
|||
if (set.getString("ranks") != null)
|
||||
{
|
||||
for (String rankString : set.getString("ranks").split(","))
|
||||
{
|
||||
ranks.add(plugin.rankData.get(identifier, rankString));
|
||||
}
|
||||
}
|
||||
String motd = set.getString("motd");
|
||||
Location home = new Location(plugin.worldData.getWorld(set.getInt("world")),
|
||||
|
@ -97,7 +106,9 @@ public class SQLGuildData
|
|||
for (Guild guild : getAll())
|
||||
{
|
||||
if (guild.getMembers().contains(player.getUniqueId()))
|
||||
{
|
||||
return guild;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -110,7 +121,9 @@ public class SQLGuildData
|
|||
ResultSet set = statement.executeQuery();
|
||||
List<Guild> guilds = new ArrayList<>();
|
||||
while (set.next())
|
||||
{
|
||||
guilds.add(get(set.getString("identifier")));
|
||||
}
|
||||
return guilds;
|
||||
}
|
||||
catch (SQLException ex)
|
||||
|
@ -164,21 +177,27 @@ public class SQLGuildData
|
|||
statement.setString(3, "" + plugin.userData.get(guild.getOwner()).getId());
|
||||
List<String> members = new ArrayList<>();
|
||||
for (UUID member : guild.getMembers())
|
||||
{
|
||||
members.add("" + plugin.userData.get(member).getId());
|
||||
}
|
||||
statement.setString(4, members.size() == 0 ? null : StringUtils.join(members, ","));
|
||||
List<String> moderators = new ArrayList<>();
|
||||
for (UUID moderator : guild.getModerators())
|
||||
{
|
||||
moderators.add("" + plugin.userData.get(moderator).getId());
|
||||
}
|
||||
statement.setString(5, moderators.size() == 0 ? null : StringUtils.join(moderators, ","));
|
||||
statement.setString(6, guild.getTag());
|
||||
statement.setInt(7, guild.getState().ordinal());
|
||||
List<String> stringRanks = new ArrayList<>();
|
||||
for (GuildRank rank : guild.getRanks())
|
||||
{
|
||||
stringRanks.add(rank.getIdentifier());
|
||||
}
|
||||
statement.setString(8, stringRanks.size() == 0 ? null : StringUtils.join(stringRanks, ","));
|
||||
statement.setString(9, guild.getMotd());
|
||||
Location home = guild.getHome();
|
||||
statement.setDouble(10, home == null ? 0.0 : home.getX());
|
||||
statement.setDouble(10, home == null ? 0.0 : home.getX());
|
||||
statement.setDouble(11, home == null ? 100.0 : home.getY());
|
||||
statement.setDouble(12, home == null ? 0.0 : home.getZ());
|
||||
statement.setInt(13, home == null ? plugin.worldData.getWorldID(Bukkit.getWorlds().get(0)) : plugin.worldData.getWorldID(home.getWorld()));
|
||||
|
|
|
@ -48,13 +48,18 @@ public class SQLRankData
|
|||
statement.setString(1, guildIdentifier);
|
||||
statement.setString(2, identifier);
|
||||
ResultSet set = statement.executeQuery();
|
||||
if (!set.next()) return null;
|
||||
if (!set.next())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String name = set.getString("name");
|
||||
List<UUID> members = new ArrayList<>();
|
||||
if (set.getString("members") != null)
|
||||
{
|
||||
for (String stringMember : set.getString("members").split(","))
|
||||
{
|
||||
members.add(plugin.userData.get(Integer.parseInt(stringMember)).getUuid());
|
||||
}
|
||||
}
|
||||
return new GuildRank(guildIdentifier, identifier, name, members);
|
||||
}
|
||||
|
@ -92,7 +97,9 @@ public class SQLRankData
|
|||
statement.setString(1, rank.getName());
|
||||
List<String> members = new ArrayList<>();
|
||||
for (UUID member : rank.getMembers())
|
||||
{
|
||||
members.add("" + plugin.userData.get(member).getId());
|
||||
}
|
||||
statement.setString(2, members.size() == 0 ? null : StringUtils.join(members, ","));
|
||||
statement.setString(3, rank.getIguild());
|
||||
statement.setString(4, rank.getIdentifier());
|
||||
|
|
|
@ -54,7 +54,10 @@ public class SQLUserData
|
|||
|
||||
public User get(UUID uuid)
|
||||
{
|
||||
if (!exists(uuid)) create(uuid);
|
||||
if (!exists(uuid))
|
||||
{
|
||||
create(uuid);
|
||||
}
|
||||
try (Connection connection = plugin.sql.getConnection())
|
||||
{
|
||||
PreparedStatement statement = connection.prepareStatement(SELECT);
|
||||
|
|
138
src/main/java/me/totalfreedom/tfguilds/sql/SQLWarpData.java
Normal file
138
src/main/java/me/totalfreedom/tfguilds/sql/SQLWarpData.java
Normal file
|
@ -0,0 +1,138 @@
|
|||
package me.totalfreedom.tfguilds.sql;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.tfguilds.TFGuilds;
|
||||
import me.totalfreedom.tfguilds.guild.GuildWarp;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SQLWarpData
|
||||
{
|
||||
private static final TFGuilds plugin = TFGuilds.getPlugin();
|
||||
private static final String TABLE_NAME = "warps";
|
||||
|
||||
private final String SELECT = "SELECT * FROM `" + TABLE_NAME + "` WHERE identifier=? AND warp_name=?";
|
||||
private final String SELECT_ALL = "SELECT * FROM `" + TABLE_NAME + "`";
|
||||
private final String UPDATE = "UPDATE `" + TABLE_NAME + "` WHERE identifier=? AND warp_name=? SET x=?, y=?, z=?, world=?";
|
||||
private final String DELETE = "DELETE FROM `" + TABLE_NAME + "` WHERE identifier=? AND warp_name=?";
|
||||
private final String INSERT = "INSERT INTO `" + TABLE_NAME + "` (`identifier`, `warp_name`, `x`, `y`, `z`, `world`) VALUES (?, ?, ?, ?, ?, ?);";
|
||||
|
||||
public boolean exists(String identifier, String warpName)
|
||||
{
|
||||
try (Connection connection = plugin.sql.getConnection())
|
||||
{
|
||||
PreparedStatement statement = connection.prepareStatement(SELECT);
|
||||
statement.setString(1, identifier);
|
||||
statement.setString(2, warpName);
|
||||
ResultSet set = statement.executeQuery();
|
||||
return set.next();
|
||||
}
|
||||
catch (SQLException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public GuildWarp get(String identifier, String warpName)
|
||||
{
|
||||
try (Connection connection = plugin.sql.getConnection())
|
||||
{
|
||||
PreparedStatement statement = connection.prepareStatement(SELECT);
|
||||
statement.setString(1, identifier);
|
||||
statement.setString(2, warpName);
|
||||
ResultSet set = statement.executeQuery();
|
||||
double x = set.getDouble("x");
|
||||
double y = set.getDouble("y");
|
||||
double z = set.getDouble("z");
|
||||
World world = plugin.worldData.getWorld(set.getInt("world"));
|
||||
return new GuildWarp(identifier, warpName, x, y, z, world);
|
||||
}
|
||||
catch (SQLException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<GuildWarp> getAll()
|
||||
{
|
||||
try (Connection connection = plugin.sql.getConnection())
|
||||
{
|
||||
PreparedStatement statement = connection.prepareStatement(SELECT_ALL);
|
||||
ResultSet set = statement.executeQuery();
|
||||
List<GuildWarp> warps = new ArrayList<>();
|
||||
while (set.next())
|
||||
{
|
||||
warps.add(get(set.getString("identifier"), set.getString("warp_name")));
|
||||
}
|
||||
return warps;
|
||||
}
|
||||
catch (SQLException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public GuildWarp create(String identifier, String warpName, Player player)
|
||||
{
|
||||
try (Connection connection = plugin.sql.getConnection())
|
||||
{
|
||||
PreparedStatement statement = connection.prepareStatement(INSERT);
|
||||
statement.setString(1, identifier);
|
||||
statement.setString(2, warpName);
|
||||
statement.setDouble(3, player.getLocation().getX());
|
||||
statement.setDouble(4, player.getLocation().getY());
|
||||
statement.setDouble(5, player.getLocation().getZ());
|
||||
statement.setInt(6, plugin.worldData.getWorldID(player.getWorld()));
|
||||
statement.execute();
|
||||
return new GuildWarp(identifier, warpName, player.getLocation().getX(), player.getLocation().getY(),
|
||||
player.getLocation().getZ(), player.getWorld());
|
||||
}
|
||||
catch (SQLException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void save(GuildWarp warp)
|
||||
{
|
||||
try (Connection connection = plugin.sql.getConnection())
|
||||
{
|
||||
PreparedStatement statement = connection.prepareStatement(UPDATE);
|
||||
statement.setString(1, warp.getIguild());
|
||||
statement.setString(2, warp.getWarpName());
|
||||
statement.setDouble(3, warp.getX());
|
||||
statement.setDouble(4, warp.getY());
|
||||
statement.setDouble(5, warp.getZ());
|
||||
statement.setInt(6, plugin.worldData.getWorldID(warp.getWorld()));
|
||||
statement.execute();
|
||||
}
|
||||
catch (SQLException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void delete(GuildWarp warp)
|
||||
{
|
||||
try (Connection connection = plugin.sql.getConnection())
|
||||
{
|
||||
PreparedStatement statement = connection.prepareStatement(DELETE);
|
||||
statement.setString(1, warp.getIguild());
|
||||
statement.setString(2, warp.getWarpName());
|
||||
statement.execute();
|
||||
}
|
||||
catch (SQLException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -79,7 +79,10 @@ public class SQLWorldData
|
|||
{
|
||||
try (Connection connection = plugin.sql.getConnection())
|
||||
{
|
||||
if (!existsID(id)) return null;
|
||||
if (!existsID(id))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
PreparedStatement statement = connection.prepareStatement(SELECT_ID);
|
||||
statement.setInt(1, id);
|
||||
ResultSet set = statement.executeQuery();
|
||||
|
|
|
@ -10,6 +10,7 @@ public class User
|
|||
{
|
||||
private final int id;
|
||||
private final UUID uuid;
|
||||
|
||||
@Setter
|
||||
private boolean tag;
|
||||
|
||||
|
@ -24,4 +25,4 @@ public class User
|
|||
{
|
||||
TFGuilds.getPlugin().userData.save(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ public class PaginationList<T> extends ArrayList<T>
|
|||
|
||||
/**
|
||||
* Defines a new Pagination List.
|
||||
*
|
||||
* @param epp Elements per page - how many elements will be included on a page of the list.
|
||||
*/
|
||||
public PaginationList(int epp)
|
||||
|
@ -20,7 +21,8 @@ public class PaginationList<T> extends ArrayList<T>
|
|||
|
||||
/**
|
||||
* Defines a new Pagination List.
|
||||
* @param epp Elements per page - how many elements will be included on a page of the list.
|
||||
*
|
||||
* @param epp Elements per page - how many elements will be included on a page of the list.
|
||||
* @param elements Elements to add to the list immediately.
|
||||
*/
|
||||
@SafeVarargs
|
||||
|
@ -35,17 +37,21 @@ public class PaginationList<T> extends ArrayList<T>
|
|||
*/
|
||||
public int getPageCount()
|
||||
{
|
||||
return (int) Math.ceil((double) size() / (double) epp);
|
||||
return (int)Math.ceil((double)size() / (double)epp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a page from the list.
|
||||
*
|
||||
* @param page Page you want to access.
|
||||
* @return A sublist of only the elements from that page.
|
||||
*/
|
||||
public List<T> getPage(int page)
|
||||
{
|
||||
if (page < 1 || page > getPageCount()) return null;
|
||||
if (page < 1 || page > getPageCount())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
int startIndex = (page - 1) * epp;
|
||||
int endIndex = Math.min(startIndex + (epp - 1), this.size() - 1);
|
||||
return subList(startIndex, endIndex + 1);
|
||||
|
|
|
@ -2,22 +2,22 @@ name: TFGuilds
|
|||
version: ${project.version}
|
||||
main: me.totalfreedom.tfguilds.TFGuilds
|
||||
api-version: 1.16
|
||||
authors: [speed, super]
|
||||
authors: [ speed, super ]
|
||||
description: A guilds plugin for the TotalFreedom server.
|
||||
commands:
|
||||
guild:
|
||||
description: The main command of TFGuilds.
|
||||
usage: /<command> <help>
|
||||
aliases: [g]
|
||||
aliases: [ g ]
|
||||
guildchat:
|
||||
description: Talk in chat with your guild.
|
||||
usage: /<command> [message]
|
||||
aliases: [gchat]
|
||||
aliases: [ gchat ]
|
||||
tfguilds:
|
||||
description: Information about the plugin.
|
||||
usage: /<command>
|
||||
aliases: [tfg]
|
||||
aliases: [ tfg ]
|
||||
guildchatspy:
|
||||
description: An admin only command which allows for spying on guild chat.
|
||||
usage: /<command>
|
||||
aliases: [gchatspy, gcs]
|
||||
aliases: [ gchatspy, gcs ]
|
Loading…
Reference in a new issue