mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-06-11 13:33:54 +00:00
Some updates
- Added Reddit flair sync - Removed magical saddle because the stacking potato does the same thing - Some internal improvements - Fixed bug where if a service throws an error while starting or stopping it breaks the entire plugin
This commit is contained in:
@ -65,7 +65,6 @@ public class CommandLoader extends FreedomService
|
||||
{
|
||||
try
|
||||
{
|
||||
FLog.debug("Loading command class " + commandClass.getSimpleName());
|
||||
add(commandClass.newInstance());
|
||||
}
|
||||
catch (InstantiationException | IllegalAccessException | ExceptionInInitializerError ex)
|
||||
@ -73,10 +72,7 @@ public class CommandLoader extends FreedomService
|
||||
FLog.warning("Failed to register command: /" + commandClass.getSimpleName().replace("Command_" , ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getCommandAmount()
|
||||
{
|
||||
return commands.size();
|
||||
FLog.info("Loaded " + commands.size() + " commands");
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
public @interface CommandPermissions
|
||||
{
|
||||
|
||||
Rank level() default Rank.IMPOSTOR;
|
||||
Rank level() default Rank.NON_OP;
|
||||
|
||||
SourceType source() default SourceType.BOTH;
|
||||
|
||||
|
@ -0,0 +1,69 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.dean.jraw.ApiException;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Link your reddit account", usage = "/<command> <username | code <code>>")
|
||||
public class Command_linkreddit extends FreedomCommand
|
||||
{
|
||||
|
||||
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||
{
|
||||
if (!plugin.rd.enabled)
|
||||
{
|
||||
msg("The reddit system is currently disabled.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (getData(playerSender).getRedditUsername() != null)
|
||||
{
|
||||
msg("Your reddit account is already linked.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length == 1 && !args[0].equals("code"))
|
||||
{
|
||||
String username = args[0];
|
||||
String code = plugin.rd.addLinkCode(getData(playerSender), username);
|
||||
|
||||
try
|
||||
{
|
||||
plugin.rd.sendModMessage(username, "Link Code", "Please run the following in-game to link your reddit account: /linkreddit code " + code);
|
||||
}
|
||||
catch (ApiException e)
|
||||
{
|
||||
msg("Could not find a reddit account by the name of " + args[0], ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
msg("A linking code has been sent to " + username + ". Please check your mod mail at " + ChatColor.AQUA + "https://www.reddit.com/message/moderator", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
|
||||
String code = args[1];
|
||||
String username = plugin.rd.checkLinkCode(code);
|
||||
|
||||
if (username == null)
|
||||
{
|
||||
msg(code + " is not a valid code", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
msg("Successfully linked the reddit account " + username + " to your Minecraft account.", ChatColor.GREEN);
|
||||
if (plugin.rd.updateFlair(playerSender))
|
||||
{
|
||||
msg("Your flair has been updated.", ChatColor.GREEN);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Obtain a magical saddle.", usage = "/<command>")
|
||||
public class Command_magicalsaddle extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.MAGICAL_SADDLE))
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getMagicalSaddle());
|
||||
msg("You have been given a Magical Saddle", ChatColor.GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("You do not own a Magical Saddle! Purchase one from the shop.", ChatColor.RED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -35,11 +35,9 @@ public class Command_totalfreedommod extends FreedomCommand
|
||||
}
|
||||
|
||||
plugin.config.load();
|
||||
for (FreedomService service : plugin.fsh.getServices())
|
||||
{
|
||||
service.onStop();
|
||||
service.onStart();
|
||||
}
|
||||
|
||||
plugin.fsh.stopServices();
|
||||
plugin.fsh.startServices();
|
||||
|
||||
final String message = String.format("%s v%s reloaded.",
|
||||
TotalFreedomMod.pluginName,
|
||||
|
@ -0,0 +1,41 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Unlink your reddit account", usage = "/<command>")
|
||||
public class Command_unlinkreddit extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!plugin.rd.enabled)
|
||||
{
|
||||
msg("The reddit system is currently disabled.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerData data = getData(playerSender);
|
||||
|
||||
if (data.getRedditUsername() == null)
|
||||
{
|
||||
msg("You don't have a reddit account linked.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
plugin.rd.removeFlair(data.getRedditUsername());
|
||||
|
||||
data.setRedditUsername(null);
|
||||
plugin.pl.save(data);
|
||||
|
||||
msg("Successfully unlinked your reddit account. If you had a flair, it was removed.", ChatColor.GREEN);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user