mirror of
https://github.com/TotalFreedomMC/TFGuilds.git
synced 2025-01-03 13:38:19 +00:00
readd tfm bridge and add guild deletion
This commit is contained in:
parent
f55e2ebb72
commit
9f2fd4ad87
8 changed files with 175 additions and 14 deletions
20
pom.xml
20
pom.xml
|
@ -55,6 +55,14 @@
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>jitpack.io</id>
|
||||||
|
<url>https://jitpack.io</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>papermc</id>
|
||||||
|
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigotmc-repo</id>
|
<id>spigotmc-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
|
@ -78,5 +86,17 @@
|
||||||
<version>1.18.12</version>
|
<version>1.18.12</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.TFPatches</groupId>
|
||||||
|
<artifactId>TotalFreedomMod</artifactId>
|
||||||
|
<version>5.5</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.Pravian</groupId>
|
||||||
|
<artifactId>Aero</artifactId>
|
||||||
|
<version>5f82926</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -1,18 +1,17 @@
|
||||||
package me.totalfreedom.tfguilds;
|
package me.totalfreedom.tfguilds;
|
||||||
|
|
||||||
|
import me.totalfreedom.tfguilds.bridge.TFMBridge;
|
||||||
|
import me.totalfreedom.tfguilds.command.*;
|
||||||
import me.totalfreedom.tfguilds.util.GLog;
|
import me.totalfreedom.tfguilds.util.GLog;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import me.totalfreedom.tfguilds.command.CreateGuildCommand;
|
|
||||||
import me.totalfreedom.tfguilds.command.GuildChatCommand;
|
|
||||||
import me.totalfreedom.tfguilds.command.GuildTagCommand;
|
|
||||||
import me.totalfreedom.tfguilds.command.TfGuildsCommand;
|
|
||||||
import me.totalfreedom.tfguilds.config.Config;
|
import me.totalfreedom.tfguilds.config.Config;
|
||||||
import me.totalfreedom.tfguilds.listener.ChatManager;
|
import me.totalfreedom.tfguilds.listener.ChatManager;
|
||||||
|
|
||||||
public final class TFGuilds extends JavaPlugin
|
public final class TFGuilds extends JavaPlugin
|
||||||
{
|
{
|
||||||
public static TFGuilds plugin;
|
public static TFGuilds plugin;
|
||||||
|
public TFMBridge tfmb;
|
||||||
public Config config;
|
public Config config;
|
||||||
public Config guilds;
|
public Config guilds;
|
||||||
|
|
||||||
|
@ -24,6 +23,7 @@ public final class TFGuilds extends JavaPlugin
|
||||||
enableListeners();
|
enableListeners();
|
||||||
config = new Config(plugin, "config.yml");
|
config = new Config(plugin, "config.yml");
|
||||||
guilds = new Config(plugin, "guilds.yml");
|
guilds = new Config(plugin, "guilds.yml");
|
||||||
|
tfmb = new TFMBridge();
|
||||||
GLog.info("Enabled");
|
GLog.info("Enabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ public final class TFGuilds extends JavaPlugin
|
||||||
this.getCommand("createguild").setExecutor(new CreateGuildCommand());
|
this.getCommand("createguild").setExecutor(new CreateGuildCommand());
|
||||||
this.getCommand("guildtag").setExecutor(new GuildTagCommand());
|
this.getCommand("guildtag").setExecutor(new GuildTagCommand());
|
||||||
this.getCommand("guildchat").setExecutor(new GuildChatCommand());
|
this.getCommand("guildchat").setExecutor(new GuildChatCommand());
|
||||||
|
this.getCommand("disbandguild").setExecutor(new DisbandGuildCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableListeners()
|
private void enableListeners()
|
||||||
|
|
43
src/main/java/me/totalfreedom/tfguilds/bridge/TFMBridge.java
Normal file
43
src/main/java/me/totalfreedom/tfguilds/bridge/TFMBridge.java
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
package me.totalfreedom.tfguilds.bridge;
|
||||||
|
|
||||||
|
import me.totalfreedom.tfguilds.TFGuilds;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class TFMBridge
|
||||||
|
{
|
||||||
|
private TFGuilds plugin;
|
||||||
|
private TotalFreedomMod tfmPlugin;
|
||||||
|
|
||||||
|
public TFMBridge()
|
||||||
|
{
|
||||||
|
this.plugin = TFGuilds.plugin;
|
||||||
|
this.tfmPlugin = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TotalFreedomMod getTFM()
|
||||||
|
{
|
||||||
|
if (tfmPlugin == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Plugin tfm = plugin.getServer().getPluginManager().getPlugin("TotalFreedomMod");
|
||||||
|
if (tfm != null && tfm instanceof TotalFreedomMod)
|
||||||
|
{
|
||||||
|
tfmPlugin = (TotalFreedomMod) tfm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tfmPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAdmin(Player player)
|
||||||
|
{
|
||||||
|
return getTFM().al.isAdmin(player);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
package me.totalfreedom.tfguilds.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.tfguilds.util.GLog;
|
||||||
|
import me.totalfreedom.tfguilds.util.GUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class DisbandGuildCommand implements CommandExecutor
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||||
|
{
|
||||||
|
Player player = (Player) sender;
|
||||||
|
String guild = GUtil.getGuild(player);
|
||||||
|
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
if (GUtil.isConsole(player))
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.RED + "You are not allowed to run this command.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (guild == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String owner = GUtil.getOwner(guild);
|
||||||
|
if (!owner.equalsIgnoreCase(player.getName()))
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.RED + "You aren't the owner of your guild!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(ChatColor.RED + "Are you sure you want to delete your guild? Type 'CONFIRM' to continue.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].toLowerCase().equalsIgnoreCase("confirm"))
|
||||||
|
{
|
||||||
|
GUtil.deleteGuild(player);
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Successfully deleted and cleared data for " + guild + ".");
|
||||||
|
GLog.info(player.getName() + " deleted guild " + guild);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package me.totalfreedom.tfguilds.command;
|
||||||
|
|
||||||
import me.totalfreedom.tfguilds.util.GBase;
|
import me.totalfreedom.tfguilds.util.GBase;
|
||||||
import me.totalfreedom.tfguilds.util.GUtil;
|
import me.totalfreedom.tfguilds.util.GUtil;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
@ -44,13 +45,13 @@ public class GuildTagCommand extends GBase implements CommandExecutor
|
||||||
{
|
{
|
||||||
if (args[0].equalsIgnoreCase("set"))
|
if (args[0].equalsIgnoreCase("set"))
|
||||||
{
|
{
|
||||||
if (!args[1].toLowerCase().equals(guild))
|
if (!args[1].toLowerCase().contains(guild))
|
||||||
{
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "Your guild tag must contain your guild name.");
|
sender.sendMessage(ChatColor.RED + "Your guild tag must contain your guild name.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GUtil.setTag(GUtil.color(args[1]), guild);
|
GUtil.setTag(GUtil.color(StringUtils.join(args, " ")), guild);
|
||||||
sender.sendMessage(ChatColor.GREEN + "Guild tag set to \"" + GUtil.color(args[1]) + ChatColor.GREEN + "\"");
|
sender.sendMessage(ChatColor.GREEN + "Guild tag set to \"" + GUtil.color(args[1]) + ChatColor.GREEN + "\"");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,49 @@
|
||||||
package me.totalfreedom.tfguilds.command;
|
package me.totalfreedom.tfguilds.command;
|
||||||
|
|
||||||
import me.totalfreedom.tfguilds.util.GBase;
|
import me.totalfreedom.tfguilds.util.GBase;
|
||||||
|
import me.totalfreedom.tfguilds.util.GLog;
|
||||||
import me.totalfreedom.tfguilds.util.GUtil;
|
import me.totalfreedom.tfguilds.util.GUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class TfGuildsCommand extends GBase implements CommandExecutor
|
public class TfGuildsCommand extends GBase implements CommandExecutor
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
sender.sendMessage(GUtil.color("&aTFGuilds &2is a plugin which allows for players to make their own guilds, providing guild chat and guild teleportation."));
|
sender.sendMessage(GUtil.color("&aTFGuilds &2is a plugin which allows for players to make their own guilds, providing guild chat and guild teleportation."));
|
||||||
sender.sendMessage(String.format(GUtil.color("&2Version &av%s"), plugin.getDescription().getVersion()));
|
sender.sendMessage(String.format(GUtil.color("&2Version &av%s"), plugin.getDescription().getVersion()));
|
||||||
sender.sendMessage(GUtil.color("&2Developed by &aspeednt & supernt"));
|
sender.sendMessage(GUtil.color("&2Developed by &aspeednt & supernt"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args[0].toLowerCase().equals("reload"))
|
||||||
|
{
|
||||||
|
if (!plugin.tfmb.isAdmin((Player) sender))
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.RED + "No permission.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
plugin.config.load();
|
||||||
|
plugin.guilds.load();
|
||||||
|
GLog.info("All configs reloaded successfully");
|
||||||
|
sender.sendMessage(GUtil.color("&aAll configuration files have been reloaded successfully."));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -24,7 +24,6 @@ public class GUtil
|
||||||
{
|
{
|
||||||
plugin.guilds.set("guilds." + guildName, guildName);
|
plugin.guilds.set("guilds." + guildName, guildName);
|
||||||
plugin.guilds.set("guilds." + guildName + ".owner", owner.getName());
|
plugin.guilds.set("guilds." + guildName + ".owner", owner.getName());
|
||||||
plugin.guilds.set("guilds." + guildName + ".members", owner.getName());
|
|
||||||
|
|
||||||
List<String> players = plugin.guilds.getStringList("guilds." + guildName + ".members");
|
List<String> players = plugin.guilds.getStringList("guilds." + guildName + ".members");
|
||||||
players.add(owner.getName());
|
players.add(owner.getName());
|
||||||
|
@ -34,6 +33,15 @@ public class GUtil
|
||||||
GLog.info(owner.getName() + " has created a new guild: " + guildName);
|
GLog.info(owner.getName() + " has created a new guild: " + guildName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void deleteGuild(CommandSender owner)
|
||||||
|
{
|
||||||
|
GLog.info("Removing guilds.yml data for " + getGuild((Player) owner));
|
||||||
|
plugin.guilds.set("guilds." + getGuild((Player) owner), null);
|
||||||
|
plugin.guilds.set("guilds." + getGuild((Player) owner) + ".owner", null);
|
||||||
|
plugin.guilds.set("guilds." + getGuild((Player) owner) + ".members", null);
|
||||||
|
plugin.guilds.save();
|
||||||
|
}
|
||||||
|
|
||||||
public static void setTag(String tag, String guildName)
|
public static void setTag(String tag, String guildName)
|
||||||
{
|
{
|
||||||
plugin.guilds.set("guilds." + guildName + ".tag", tag);
|
plugin.guilds.set("guilds." + guildName + ".tag", tag);
|
||||||
|
|
|
@ -4,10 +4,11 @@ main: me.totalfreedom.tfguilds.TFGuilds
|
||||||
api-version: 1.15
|
api-version: 1.15
|
||||||
authors: [speednt]
|
authors: [speednt]
|
||||||
description: Plugin which allows for players to make their own guilds on the server
|
description: Plugin which allows for players to make their own guilds on the server
|
||||||
|
depend: [TotalFreedomMod, Aero]
|
||||||
commands:
|
commands:
|
||||||
tfguilds:
|
tfguilds:
|
||||||
description: Plugin info
|
description: Plugin info
|
||||||
usage: /<command>
|
usage: /<command> <reload>
|
||||||
aliases: [guilds, tfguildsinfo, tfginfo, guildsinfo]
|
aliases: [guilds, tfguildsinfo, tfginfo, guildsinfo]
|
||||||
createguild:
|
createguild:
|
||||||
description: Creates a guild
|
description: Creates a guild
|
||||||
|
@ -21,3 +22,7 @@ commands:
|
||||||
description: Speak to your guild
|
description: Speak to your guild
|
||||||
usage: /<command> <message>
|
usage: /<command> <message>
|
||||||
aliases: [gchat]
|
aliases: [gchat]
|
||||||
|
disbandguild:
|
||||||
|
description: Deletes your guild
|
||||||
|
usage: /<command>
|
||||||
|
aliases: [deleteguild]
|
Loading…
Reference in a new issue