mirror of
https://github.com/TotalFreedomMC/TFGuilds.git
synced 2024-12-21 23:45:04 +00:00
This commit is contained in:
commit
7d1b8fd580
6 changed files with 124 additions and 20 deletions
|
@ -13,8 +13,9 @@ public class Common
|
|||
public static final String IN_GUILD = PREFIX + "You are already in a guild.";
|
||||
public static final String PLAYER_NOT_FOUND = PREFIX + "That player is not online.";
|
||||
public static final String PLAYER_NOT_IN_GUILD = PREFIX + "That player is not in your guild.";
|
||||
public static final String IN_GAME_ONLY = PREFIX + "You must be in-game to interact with guilds";
|
||||
public static final String USAGE = PREFIX + "Correct usage: " + ChatColor.GOLD;
|
||||
public static final String IN_GAME_ONLY = PREFIX + "You must be in-game to interact with guilds.";
|
||||
public static final String USAGE = PREFIX + "Usage: " + ChatColor.GOLD;
|
||||
public static final String WARN = PREFIX + ChatColor.RED + "Warning: " + ChatColor.GRAY;
|
||||
|
||||
public static final TFMBridge tfmBridge = TFGuilds.getPlugin().getTfmBridge();
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ public class TFGuilds extends JavaPlugin
|
|||
private Config config;
|
||||
private SQLDatabase sqlDatabase;
|
||||
private TFMBridge tfmBridge;
|
||||
private Map<String, SubCommand> subCommands = new HashMap<>();
|
||||
private final Map<String, SubCommand> subCommands = new HashMap<>();
|
||||
|
||||
public static TFGuilds getPlugin()
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ public class TFGuilds extends JavaPlugin
|
|||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
this.plugin = this;
|
||||
plugin = this;
|
||||
config = new Config("config.yml");
|
||||
sqlDatabase = new SQLDatabase(this);
|
||||
User.loadAll();
|
||||
|
|
|
@ -1,16 +1,22 @@
|
|||
package me.totalfreedom.tfguilds.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.tfguilds.Common;
|
||||
import me.totalfreedom.tfguilds.TFGuilds;
|
||||
import me.totalfreedom.tfguilds.guild.Guild;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class DisbandSubCommand extends Common implements SubCommand
|
||||
{
|
||||
|
||||
private final List<CommandSender> confirm = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Player playerSender, String[] args)
|
||||
{
|
||||
|
@ -35,9 +41,7 @@ public class DisbandSubCommand extends Common implements SubCommand
|
|||
return;
|
||||
}
|
||||
|
||||
guild.disband();
|
||||
sender.sendMessage(PREFIX + "The guild " + ChatColor.GOLD + guild.getName() + ChatColor.GRAY + " has been disbanded.");
|
||||
Bukkit.broadcastMessage(PREFIX + ChatColor.GOLD + sender.getName() + ChatColor.GRAY + " has disbanded the guild " + ChatColor.GOLD + guild.getName());
|
||||
disband(sender, guild);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -54,8 +58,31 @@ public class DisbandSubCommand extends Common implements SubCommand
|
|||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(PREFIX + "The guild " + ChatColor.GOLD + guild.getName() + ChatColor.GRAY + " has been disbanded.");
|
||||
Bukkit.broadcastMessage(PREFIX + ChatColor.GOLD + sender.getName() + ChatColor.GRAY + " has disbanded the guild " + ChatColor.GOLD + guild.getName());
|
||||
guild.disband();
|
||||
disband(sender, guild);
|
||||
}
|
||||
private void disband(CommandSender sender, Guild guild)
|
||||
{
|
||||
if (!confirm.contains(sender))
|
||||
{
|
||||
sender.sendMessage(WARN + "Are you sure you want to disband the guild "
|
||||
+ ChatColor.GOLD + guild.getName() + ChatColor.GRAY + "? Type "
|
||||
+ ChatColor.GOLD + "/g disband" + ChatColor.GRAY + " again within 10 seconds to confirm.");
|
||||
confirm.add(sender);
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
confirm.remove(sender);
|
||||
}
|
||||
}.runTaskLater(TFGuilds.getPlugin(), 10 * 20);
|
||||
}
|
||||
else
|
||||
{
|
||||
confirm.remove(sender);
|
||||
guild.disband();
|
||||
sender.sendMessage(PREFIX + "The guild " + ChatColor.GOLD + guild.getName() + ChatColor.GRAY + " has been disbanded.");
|
||||
Bukkit.broadcastMessage(PREFIX + ChatColor.GOLD + sender.getName() + ChatColor.GRAY + " has disbanded the guild " + ChatColor.GOLD + guild.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
package me.totalfreedom.tfguilds.command;
|
||||
|
||||
import java.util.HashMap;
|
||||
import me.totalfreedom.tfguilds.Common;
|
||||
import me.totalfreedom.tfguilds.TFGuilds;
|
||||
import me.totalfreedom.tfguilds.guild.Guild;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class KickSubCommand extends Common implements SubCommand
|
||||
{
|
||||
|
||||
private final HashMap<CommandSender, Player> confirm = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Player playerSender, String[] args)
|
||||
{
|
||||
|
@ -63,8 +68,28 @@ public class KickSubCommand extends Common implements SubCommand
|
|||
return;
|
||||
}
|
||||
|
||||
guild.removeMember(player);
|
||||
sender.sendMessage(PREFIX + "Successfully kicked " + ChatColor.GOLD + player.getName() + ChatColor.GRAY + " from your guild.");
|
||||
player.sendMessage(PREFIX + ChatColor.GOLD + sender.getName() + ChatColor.GRAY + " has kicked you from " + ChatColor.GOLD + guild.getName());
|
||||
if (!confirm.containsKey(sender) || !confirm.containsValue(player))
|
||||
{
|
||||
sender.sendMessage(WARN + "Are you sure you want to kick "
|
||||
+ ChatColor.GOLD + player.getName() + ChatColor.GRAY + " from the guild? Type "
|
||||
+ ChatColor.GOLD + "/g kick " + player.getName()
|
||||
+ ChatColor.GRAY + " again within 10 seconds to confirm.");
|
||||
confirm.put(sender, player);
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
confirm.remove(player);
|
||||
}
|
||||
}.runTaskLater(TFGuilds.getPlugin(), 10 * 20);
|
||||
}
|
||||
else
|
||||
{
|
||||
confirm.remove(sender);
|
||||
guild.removeMember(player);
|
||||
sender.sendMessage(PREFIX + "Successfully kicked " + ChatColor.GOLD + player.getName() + ChatColor.GRAY + " from the guild.");
|
||||
player.sendMessage(PREFIX + ChatColor.GOLD + sender.getName() + ChatColor.GRAY + " has kicked you from " + ChatColor.GOLD + guild.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,20 @@
|
|||
package me.totalfreedom.tfguilds.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.tfguilds.Common;
|
||||
import me.totalfreedom.tfguilds.TFGuilds;
|
||||
import me.totalfreedom.tfguilds.guild.Guild;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class LeaveSubCommand extends Common implements SubCommand
|
||||
{
|
||||
|
||||
private final List<CommandSender> confirm = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Player playerSender, String[] args)
|
||||
{
|
||||
|
@ -31,8 +37,28 @@ public class LeaveSubCommand extends Common implements SubCommand
|
|||
return;
|
||||
}
|
||||
|
||||
guild.removeMember(playerSender);
|
||||
guild.broadcast(PREFIX + ChatColor.GOLD + sender.getName() + ChatColor.GRAY + " has left the guild.");
|
||||
sender.sendMessage(PREFIX + "You have left the guild.");
|
||||
if (!confirm.contains(sender))
|
||||
{
|
||||
sender.sendMessage(WARN + "Are you sure you want to leave "
|
||||
+ ChatColor.GOLD + guild.getName() + ChatColor.GRAY + "? Type "
|
||||
+ ChatColor.GOLD + "/g leave"
|
||||
+ ChatColor.GRAY + " again within 10 seconds to confirm.");
|
||||
confirm.add(sender);
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
confirm.remove(sender);
|
||||
}
|
||||
}.runTaskLater(TFGuilds.getPlugin(), 10 * 20);
|
||||
}
|
||||
else
|
||||
{
|
||||
confirm.remove(sender);
|
||||
guild.removeMember(playerSender);
|
||||
guild.broadcast(PREFIX + ChatColor.GOLD + sender.getName() + ChatColor.GRAY + " has left the guild.");
|
||||
sender.sendMessage(PREFIX + "You have left the guild.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
package me.totalfreedom.tfguilds.command;
|
||||
|
||||
import java.util.HashMap;
|
||||
import me.totalfreedom.tfguilds.Common;
|
||||
import me.totalfreedom.tfguilds.TFGuilds;
|
||||
import me.totalfreedom.tfguilds.guild.Guild;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class SetOwnerSubCommand extends Common implements SubCommand
|
||||
{
|
||||
private final HashMap<CommandSender, Player> confirm = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Player playerSender, String[] args)
|
||||
|
@ -57,9 +61,30 @@ public class SetOwnerSubCommand extends Common implements SubCommand
|
|||
return;
|
||||
}
|
||||
|
||||
guild.setOwner(player);
|
||||
sender.sendMessage(PREFIX + "Successfully set " + ChatColor.GOLD + player.getName() + ChatColor.GRAY + " as the new owner of the guild.");
|
||||
guild.broadcast(PREFIX + ChatColor.GOLD + sender.getName() + ChatColor.GRAY + " has set " + ChatColor.GOLD + player.getName() + ChatColor.GRAY + " as the new owner of the guild.");
|
||||
player.sendMessage(PREFIX + ChatColor.GOLD + sender.getName() + ChatColor.GRAY + " has set you as the owner of " + ChatColor.GOLD + guild.getName());
|
||||
if (!confirm.containsKey(sender) || !confirm.containsValue(player))
|
||||
{
|
||||
sender.sendMessage(WARN + "Are you sure you want to transfer ownership of "
|
||||
+ ChatColor.GOLD + guild.getName() + ChatColor.GRAY + " to "
|
||||
+ ChatColor.GOLD + player.getName() + ChatColor.GRAY + "? Type "
|
||||
+ ChatColor.GOLD + "/g setowner " + player.getName()
|
||||
+ ChatColor.GRAY + " again within 10 seconds to confirm.");
|
||||
confirm.put(sender, player);
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
confirm.remove(sender);
|
||||
}
|
||||
}.runTaskLater(TFGuilds.getPlugin(), 10 * 20);
|
||||
}
|
||||
else
|
||||
{
|
||||
confirm.remove(sender);
|
||||
guild.setOwner(player);
|
||||
sender.sendMessage(PREFIX + "Successfully set " + ChatColor.GOLD + player.getName() + ChatColor.GRAY + " as the new owner of the guild.");
|
||||
guild.broadcast(PREFIX + ChatColor.GOLD + sender.getName() + ChatColor.GRAY + " has set " + ChatColor.GOLD + player.getName() + ChatColor.GRAY + " as the new owner of the guild.");
|
||||
player.sendMessage(PREFIX + ChatColor.GOLD + sender.getName() + ChatColor.GRAY + " has set you as the owner of " + ChatColor.GOLD + guild.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue