mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-28 12:47:36 +00:00
2023.03 update 2 / 2
I think we're done!!!
This commit is contained in:
parent
2265783afb
commit
b7ea1b8b3e
@ -53,6 +53,13 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>me.totalfreedom</groupId>
|
||||
<artifactId>shop</artifactId>
|
||||
<version>2023.02</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
|
@ -149,7 +149,10 @@ public class ChatManager extends FreedomService
|
||||
{
|
||||
Displayable display = plugin.rm.getDisplay(sender);
|
||||
FLog.info("[ADMIN] " + sender.getName() + " " + display.getTag() + ": " + message, true);
|
||||
plugin.dc.messageAdminChatChannel(sender.getName() + " \u00BB " + message);
|
||||
|
||||
if (plugin.dc != null) {
|
||||
plugin.dc.getUtils().messageAdminChatChannel(sender.getName() + " \u00BB " + message);
|
||||
}
|
||||
|
||||
server.getOnlinePlayers().stream().filter(player -> plugin.al.isAdmin(player)).forEach(player ->
|
||||
{
|
||||
|
@ -39,8 +39,8 @@ import me.totalfreedom.totalfreedommod.permissions.PermissionManager;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerList;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
||||
import me.totalfreedom.totalfreedommod.rank.RankManager;
|
||||
import me.totalfreedom.totalfreedommod.shop.Shop;
|
||||
import me.totalfreedom.totalfreedommod.shop.Votifier;
|
||||
import me.totalfreedom.shop.Shop;
|
||||
import me.totalfreedom.shop.Votifier;
|
||||
import me.totalfreedom.totalfreedommod.sql.SQLite;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
@ -299,11 +299,19 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
as = new AntiSpam();
|
||||
wr = new WorldRestrictions();
|
||||
pl = new PlayerList();
|
||||
sh = new Shop();
|
||||
vo = new Votifier();
|
||||
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("TF-Shoppe")) {
|
||||
sh = new Shop();
|
||||
vo = new Votifier();
|
||||
}
|
||||
|
||||
an = new Announcer();
|
||||
cm = new ChatManager();
|
||||
dc = new TFM_Accessor().botAccessor();
|
||||
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("TFD4J")) {
|
||||
dc = new TFM_Accessor().botAccessor();
|
||||
}
|
||||
|
||||
pul = new PunishmentList();
|
||||
bm = new BanManager();
|
||||
im = new IndefiniteBanList();
|
||||
|
@ -148,44 +148,48 @@ public class Admin
|
||||
|
||||
if (!active)
|
||||
{
|
||||
if (getRank().isAtLeast(Rank.ADMIN))
|
||||
{
|
||||
if (plugin.btb != null)
|
||||
{
|
||||
plugin.btb.killTelnetSessions(getName());
|
||||
}
|
||||
|
||||
// Ensure admins don't have admin functionality when removed (FS-222)
|
||||
AdminList.vanished.remove(getName());
|
||||
|
||||
if (plugin.esb != null)
|
||||
{
|
||||
plugin.esb.setVanished(getName(), false);
|
||||
}
|
||||
|
||||
setCommandSpy(false);
|
||||
setPotionSpy(false);
|
||||
|
||||
Server server = Bukkit.getServer();
|
||||
Player player = server.getPlayer(getUuid());
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
// Update chats
|
||||
FPlayer freedomPlayer = plugin.pl.getPlayer(player);
|
||||
freedomPlayer.removeAdminFunctionality();
|
||||
|
||||
// Disable vanish
|
||||
for (Player player1 : server.getOnlinePlayers())
|
||||
{
|
||||
player1.showPlayer(plugin, player);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
setActiveSplitWorkToReduceComplexity(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
private void setActiveSplitWorkToReduceComplexity(TotalFreedomMod plugin) {
|
||||
if (getRank().isAtLeast(Rank.ADMIN))
|
||||
{
|
||||
if (plugin.btb != null)
|
||||
{
|
||||
plugin.btb.killTelnetSessions(getName());
|
||||
}
|
||||
|
||||
// Ensure admins don't have admin functionality when removed (FS-222)
|
||||
AdminList.vanished.remove(getName());
|
||||
|
||||
if (plugin.esb != null)
|
||||
{
|
||||
plugin.esb.setVanished(getName(), false);
|
||||
}
|
||||
|
||||
setCommandSpy(false);
|
||||
setPotionSpy(false);
|
||||
|
||||
Server server = Bukkit.getServer();
|
||||
Player player = server.getPlayer(getUuid());
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
// Update chats
|
||||
FPlayer freedomPlayer = plugin.pl.getPlayer(player);
|
||||
freedomPlayer.removeAdminFunctionality();
|
||||
|
||||
// Disable vanish
|
||||
for (Player player1 : server.getOnlinePlayers())
|
||||
{
|
||||
player1.showPlayer(plugin, player);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Rank getRank()
|
||||
{
|
||||
return rank;
|
||||
|
@ -35,6 +35,7 @@ public class AdminList extends FreedomService
|
||||
@Override
|
||||
public void onStop()
|
||||
{
|
||||
// This does nothing. This comment is here to prevent SonarLint from complaining.
|
||||
}
|
||||
|
||||
public void load()
|
||||
|
@ -71,6 +71,7 @@ public class BanManager extends FreedomService
|
||||
@Override
|
||||
public void onStop()
|
||||
{
|
||||
// This does nothing. This comment is here to prevent SonarLint from complaining.
|
||||
}
|
||||
|
||||
public Set<Ban> getAllBans()
|
||||
|
@ -19,10 +19,6 @@ public class IndefiniteBan implements IConfig
|
||||
private String reason = null;
|
||||
private Date expiry = null;
|
||||
|
||||
public IndefiniteBan()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadFrom(ConfigurationSection cs)
|
||||
{
|
||||
|
@ -79,6 +79,7 @@ public class IndefiniteBanList extends FreedomService
|
||||
@Override
|
||||
public void onStop()
|
||||
{
|
||||
// This does nothing. This comment is here to prevent SonarLint from complaining.
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@ -113,6 +114,10 @@ public class IndefiniteBanList extends FreedomService
|
||||
}
|
||||
}
|
||||
|
||||
onPlayerLoginSplitWorkToReduceComplexity(event, ban, bannedBy);
|
||||
}
|
||||
|
||||
private void onPlayerLoginSplitWorkToReduceComplexity(PlayerLoginEvent event, IndefiniteBan ban, String bannedBy) {
|
||||
if (ban != null)
|
||||
{
|
||||
if (ban.isExpired())
|
||||
@ -123,8 +128,8 @@ public class IndefiniteBanList extends FreedomService
|
||||
}
|
||||
|
||||
String kickMessage = ChatColor.RED + "Your " + bannedBy + " is "
|
||||
+ (ban.hasExpiry() ? "" : "indefinitely ")
|
||||
+ "banned from this server.";
|
||||
+ (ban.hasExpiry() ? "" : "indefinitely ")
|
||||
+ "banned from this server.";
|
||||
String reason = ban.getReason();
|
||||
if (!Strings.isNullOrEmpty(reason))
|
||||
{
|
||||
@ -145,7 +150,6 @@ public class IndefiniteBanList extends FreedomService
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, kickMessage);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCount()
|
||||
{
|
||||
nameBanCount = 0;
|
||||
|
@ -26,6 +26,7 @@ public class BlockBlocker extends FreedomService
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
// TODO: Remove deprecated method. Complexity is also O(35) which is very bad.
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
|
@ -66,6 +66,7 @@ public class InteractBlocker extends FreedomService
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Current cognitive complexity is O(24). This is too high.
|
||||
private void handleRightClick(PlayerInteractEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
|
@ -54,6 +54,7 @@ public class MobBlocker extends FreedomService
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Complexity for this method is too high [O(23)]. This needs to be fixed.
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event)
|
||||
{
|
||||
|
@ -24,6 +24,7 @@ public class PVPBlocker extends FreedomService
|
||||
{
|
||||
}
|
||||
|
||||
// TODO: Complexity is O(26). This needs to be reduced.
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event)
|
||||
{
|
||||
@ -70,7 +71,7 @@ public class PVPBlocker extends FreedomService
|
||||
}
|
||||
}
|
||||
|
||||
if (player != null & !plugin.al.isAdmin(player))
|
||||
if (player != null && !plugin.al.isAdmin(player))
|
||||
{
|
||||
if (player.getGameMode() == GameMode.CREATIVE)
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ public class CommandBlocker extends FreedomService
|
||||
entryList.clear();
|
||||
}
|
||||
|
||||
public void load()
|
||||
public void load() // TODO: Complexity is 21. Need to fix this.
|
||||
{
|
||||
entryList.clear();
|
||||
unknownCommands.clear();
|
||||
@ -147,6 +147,7 @@ public class CommandBlocker extends FreedomService
|
||||
return isCommandBlocked(command, sender, false);
|
||||
}
|
||||
|
||||
// TODO: Complexity is 22. Need to fix this. Complexity can be no more than O(15).
|
||||
public boolean isCommandBlocked(String command, CommandSender sender, boolean doAction)
|
||||
{
|
||||
if (command == null || command.isEmpty())
|
||||
|
@ -166,6 +166,7 @@ public class CoreProtectBridge extends FreedomService
|
||||
return historyMap.get(player.getUniqueId());
|
||||
}
|
||||
|
||||
// TODO: Complexity is O(19). This should be reduced.
|
||||
public void showPageToPlayer(Player player, FUtil.PaginationList<CoreProtectAPI.ParseResult> results, int pageNum)
|
||||
{
|
||||
if (player == null || !player.isOnline())
|
||||
|
@ -5,12 +5,13 @@ import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class LibsDisguisesBridge extends FreedomService
|
||||
{
|
||||
private LibsDisguises libsDisguisesPlugin = null;
|
||||
private static LibsDisguises libsDisguisesPlugin = null;
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
@ -22,22 +23,18 @@ public class LibsDisguisesBridge extends FreedomService
|
||||
{
|
||||
}
|
||||
|
||||
public LibsDisguises getLibsDisguisesPlugin()
|
||||
public static LibsDisguises getLibsDisguisesPlugin()
|
||||
{
|
||||
if (libsDisguisesPlugin == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
final Plugin libsDisguises = server.getPluginManager().getPlugin("LibsDisguises");
|
||||
if (libsDisguises != null)
|
||||
final Plugin libsDisguises = Bukkit.getServer().getPluginManager().getPlugin("LibsDisguises");
|
||||
if (libsDisguises instanceof LibsDisguises)
|
||||
{
|
||||
if (libsDisguises instanceof LibsDisguises)
|
||||
{
|
||||
libsDisguisesPlugin = (LibsDisguises)libsDisguises;
|
||||
}
|
||||
libsDisguisesPlugin = (LibsDisguises) libsDisguises;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
} catch (Exception ex)
|
||||
{
|
||||
FLog.severe(ex);
|
||||
}
|
||||
@ -68,8 +65,7 @@ public class LibsDisguisesBridge extends FreedomService
|
||||
DisguiseAPI.undisguiseToAll(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
} catch (Exception ex)
|
||||
{
|
||||
FLog.severe(ex);
|
||||
}
|
||||
@ -80,7 +76,7 @@ public class LibsDisguisesBridge extends FreedomService
|
||||
return !BlockedDisguises.disabled;
|
||||
}
|
||||
|
||||
public void setDisguisesEnabled(boolean state)
|
||||
public static void setDisguisesEnabled(boolean state)
|
||||
{
|
||||
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
||||
|
||||
|
@ -124,7 +124,7 @@ public class CageData
|
||||
this.location = location;
|
||||
this.outerMaterial = outer;
|
||||
this.innerMaterial = inner;
|
||||
input = null;
|
||||
input = null; // TODO: Remove static variable declaration in a non-static block.
|
||||
|
||||
buildHistory(location);
|
||||
regenerate();
|
||||
@ -141,7 +141,7 @@ public class CageData
|
||||
this.location = location;
|
||||
this.outerMaterial = outer;
|
||||
this.innerMaterial = inner;
|
||||
CageData.input = input;
|
||||
CageData.input = input; // TODO: Remove static variable declaration in a non-static block.
|
||||
|
||||
buildHistory(location);
|
||||
regenerate();
|
||||
|
@ -13,7 +13,12 @@ public class Command_cleardiscordqueue extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
plugin.dc.clearQueue();
|
||||
if (plugin.dc == null) {
|
||||
msg("Discord is not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
plugin.dc.getUtils().clearQueue();
|
||||
msg("Cleared the discord message queue.");
|
||||
return true;
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import me.totalfreedom.shop.ShopItem;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -15,6 +16,11 @@ public class Command_clownfish extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.sh == null) {
|
||||
sender.sendMessage(Component.text("The shop is currently disabled."));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.CLOWN_FISH) && (!plugin.lp.CLOWNFISH_TOGGLE.contains(playerSender.getName())))
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getClownFish());
|
||||
|
@ -19,7 +19,7 @@ public class Command_coins extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!ConfigEntry.SHOP_ENABLED.getBoolean())
|
||||
if (plugin.sh == null || !ConfigEntry.SHOP_ENABLED.getBoolean())
|
||||
{
|
||||
msg("The shop is currently disabled!", ChatColor.RED);
|
||||
return true;
|
||||
@ -30,13 +30,12 @@ public class Command_coins extends FreedomCommand
|
||||
switch (args.length)
|
||||
{
|
||||
// Mode for seeing how many coins the sender has (doesn't work from console)
|
||||
case 0:
|
||||
case 0 ->
|
||||
{
|
||||
if (senderIsConsole)
|
||||
{
|
||||
msg("When used from the console, you must define a target player.");
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
PlayerData playerData = getData(playerSender);
|
||||
msg(prefix + ChatColor.GREEN + "You have " + ChatColor.RED + playerData.getCoins() + ChatColor.GREEN
|
||||
@ -45,16 +44,16 @@ public class Command_coins extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Mode for seeing how many coins a player has.
|
||||
case 1:
|
||||
case 1 ->
|
||||
{
|
||||
Player target = getPlayer(args[0]);
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
PlayerData playerData = getData(target);
|
||||
msg(prefix + ChatColor.GREEN + target.getName() + " has " + ChatColor.RED + playerData.getCoins() + ChatColor.GREEN + " coins.");
|
||||
@ -62,8 +61,9 @@ public class Command_coins extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Mode for paying another player coins
|
||||
case 3:
|
||||
case 3 ->
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("pay"))
|
||||
{
|
||||
@ -79,8 +79,7 @@ public class Command_coins extends FreedomCommand
|
||||
{
|
||||
// Prevents players from trying to be cheeky with negative numbers.
|
||||
coinsToTransfer = Math.max(Math.abs(Integer.parseInt(args[2])), 1);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
} catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid number: " + args[2], ChatColor.RED);
|
||||
return true;
|
||||
@ -96,8 +95,7 @@ public class Command_coins extends FreedomCommand
|
||||
if (target == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
PlayerData playerData = getData(target);
|
||||
playerData.setCoins(playerData.getCoins() + coinsToTransfer);
|
||||
@ -119,9 +117,9 @@ public class Command_coins extends FreedomCommand
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
default ->
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -1,10 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
@ -13,7 +8,13 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
|
||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@CommandPermissions(rank = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Show all commands for all server plugins.", usage = "/<command>", aliases = "cmdlist")
|
||||
public class Command_commandlist extends FreedomCommand
|
||||
{
|
||||
@ -35,8 +36,7 @@ public class Command_commandlist extends FreedomCommand
|
||||
String command_name = entry.getKey();
|
||||
commands.add(command_name);
|
||||
}
|
||||
}
|
||||
catch (Throwable ignored)
|
||||
} catch (Throwable ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,13 @@ public class Command_consolesay extends FreedomCommand
|
||||
}
|
||||
|
||||
String message = StringUtils.join(args, " ");
|
||||
FUtil.bcastMsg(String.format("§7[CONSOLE] §c%s §8\u00BB §f%s", sender.getName(), StringUtils.join(args, " ")));
|
||||
plugin.dc.messageChatChannel("[CONSOLE] " + sender.getName() + " \u00BB " + ChatColor.stripColor(message));
|
||||
FUtil.bcastMsg(String.format("§7[CONSOLE] §c%s §8» §f%s", sender.getName(), StringUtils.join(args, " ")));
|
||||
|
||||
if (plugin.dc != null) {
|
||||
plugin.dc.getUtils().messageChatChannel("[CONSOLE] " + sender.getName() + " \u00BB " + ChatColor.stripColor(message), true);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
@ -52,9 +51,9 @@ public class Command_doom extends FreedomCommand
|
||||
admin.setActive(false);
|
||||
plugin.al.save(admin);
|
||||
plugin.al.updateTables();
|
||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||
if (plugin.dc != null && plugin.dc.isEnabled() && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||
{
|
||||
Discord.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
||||
plugin.dc.getBot().syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import me.totalfreedom.shop.ShopItem;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -15,6 +15,11 @@ public class Command_fireball extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.sh == null) {
|
||||
msg("The shop is currently disabled.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.FIRE_BALL))
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getFireBall());
|
||||
|
@ -1,7 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.shop.ShopItem;
|
||||
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;
|
||||
@ -11,16 +11,19 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Obtain a grappling hook", usage = "/<command>")
|
||||
public class Command_grapplinghook extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.sh == null) {
|
||||
msg("The shop is currently disabled.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.GRAPPLING_HOOK))
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getGrapplingHook());
|
||||
msg("You have been given a Grappling Hook", ChatColor.GREEN);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
msg("You do not own a Grappling Hook! Purchase one from the shop.", ChatColor.RED);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import me.totalfreedom.shop.ShopItem;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -15,6 +15,11 @@ public class Command_lightningrod extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.sh == null) {
|
||||
msg("The shop is currently disabled.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.LIGHTNING_ROD))
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getLightningRod());
|
||||
|
@ -1,6 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -16,7 +15,7 @@ public class Command_linkdiscord extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!plugin.dc.enabled)
|
||||
if (plugin.dc == null || !plugin.dc.isEnabled())
|
||||
{
|
||||
msg("The Discord integration system is currently disabled.", ChatColor.RED);
|
||||
return true;
|
||||
@ -45,17 +44,16 @@ public class Command_linkdiscord extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Discord.LINK_CODES.containsValue(data))
|
||||
if (plugin.dc.getBot().getLinkCodes().containsValue(data))
|
||||
{
|
||||
code = Discord.getCode(data);
|
||||
}
|
||||
else
|
||||
code = plugin.dc.getBot().getCode(data);
|
||||
} else
|
||||
{
|
||||
code = plugin.dc.generateCode(5);
|
||||
Discord.LINK_CODES.put(code, data);
|
||||
code = plugin.dc.getBot().generateCode(5);
|
||||
plugin.dc.getBot().getLinkCodes().put(code, data);
|
||||
}
|
||||
msg("Your linking code is " + ChatColor.AQUA + code, ChatColor.GREEN);
|
||||
msg("Take this code and DM the server bot (" + plugin.dc.formatBotTag() + ") the code (do not put anything else in the message, only the code)");
|
||||
msg("Take this code and DM the server bot (" + plugin.dc.getBot().formatBotTag() + ") the code (do not put anything else in the message, only the code)");
|
||||
return true;
|
||||
}
|
||||
}
|
@ -26,15 +26,14 @@ public class Command_links extends FreedomCommand
|
||||
|
||||
List<String> lines = new ArrayList<>();
|
||||
|
||||
for (String key : values.keySet())
|
||||
values.keySet()
|
||||
.stream()
|
||||
.filter(key -> values.get(key) instanceof String)
|
||||
.forEach(key ->
|
||||
{
|
||||
if (!(values.get(key) instanceof String))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String link = (String)values.get(key);
|
||||
String link = (String) values.get(key);
|
||||
lines.add(ChatColor.GOLD + "- " + key + ": " + ChatColor.AQUA + link);
|
||||
}
|
||||
});
|
||||
|
||||
msg("Social Media Links:", ChatColor.AQUA);
|
||||
sender.sendMessage(lines.toArray(new String[0]));
|
||||
|
@ -2,7 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import me.totalfreedom.shop.ShopItem;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -16,9 +16,9 @@ public class Command_loginmessage extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!plugin.pl.getData(playerSender).hasItem(ShopItem.LOGIN_MESSAGES) && !isAdmin(playerSender))
|
||||
if (plugin.sh == null || !plugin.pl.getData(playerSender).hasItem(ShopItem.LOGIN_MESSAGES) && !isAdmin(playerSender))
|
||||
{
|
||||
msg("You did not purchase the ability to use login messages! Purchase the ability from the shop.", ChatColor.RED);
|
||||
msg("You did not purchase the ability to use login messages, or the shop is not present! Purchase the ability from the shop.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import me.totalfreedom.shop.ShopItem;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -17,6 +17,10 @@ public class Command_manageshop extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.sh == null) {
|
||||
msg("The shop is currently disabled.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!FUtil.isExecutive(sender.getName()))
|
||||
{
|
||||
|
@ -1,12 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
@ -16,6 +11,11 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Manage your admin entry.", usage = "/<command> [-o <admin name>] <clearips | clearip <ip> | setscformat <format> | clearscformat> | syncroles>")
|
||||
public class Command_myadmin extends FreedomCommand
|
||||
@ -73,8 +73,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
if (init == null)
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Clearing my IPs", true);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Clearing " + target.getName() + "'s IPs", true);
|
||||
}
|
||||
@ -104,8 +103,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
if (init == null)
|
||||
{
|
||||
msg("That IP is not registered to you.");
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
msg("That IP does not belong to that player.");
|
||||
}
|
||||
@ -117,8 +115,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
if (init == null)
|
||||
{
|
||||
msg("You cannot remove your current IP.");
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
msg("You cannot remove that admins current IP.");
|
||||
}
|
||||
@ -163,7 +160,7 @@ public class Command_myadmin extends FreedomCommand
|
||||
|
||||
case "syncroles":
|
||||
{
|
||||
if (plugin.dc.enabled)
|
||||
if (plugin.dc != null && plugin.dc.isEnabled())
|
||||
{
|
||||
if (!ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||
{
|
||||
@ -176,12 +173,11 @@ public class Command_myadmin extends FreedomCommand
|
||||
msg("Please run /linkdiscord first!", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
boolean synced = Discord.syncRoles(target, playerData.getDiscordID());
|
||||
boolean synced = plugin.dc.getBot().syncRoles(target, playerData.getDiscordID());
|
||||
if (synced)
|
||||
{
|
||||
msg("Successfully synced your roles.", ChatColor.GREEN);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
msg("Failed to sync your roles, please check the console.", ChatColor.RED);
|
||||
}
|
||||
@ -214,31 +210,27 @@ public class Command_myadmin extends FreedomCommand
|
||||
options.addAll(singleArguments);
|
||||
options.addAll(doubleArguments);
|
||||
return options;
|
||||
}
|
||||
else if (args.length == 2)
|
||||
} else if (args.length == 2)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("-o"))
|
||||
{
|
||||
return FUtil.getPlayerList();
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
if (doubleArguments.contains(args[0]) && args[0].equalsIgnoreCase("clearip"))
|
||||
{
|
||||
List<String> ips = plugin.al.getAdmin(sender).getIps();
|
||||
ips.remove(FUtil.getIp((Player)sender));
|
||||
ips.remove(FUtil.getIp((Player) sender));
|
||||
return ips;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (args.length == 3 && args[0].equalsIgnoreCase("-o"))
|
||||
} else if (args.length == 3 && args[0].equalsIgnoreCase("-o"))
|
||||
{
|
||||
List<String> options = new ArrayList<>();
|
||||
options.addAll(singleArguments);
|
||||
options.addAll(doubleArguments);
|
||||
return options;
|
||||
}
|
||||
else if (args.length == 4 && args[0].equalsIgnoreCase("-o") && args[2].equalsIgnoreCase("clearip"))
|
||||
} else if (args.length == 4 && args[0].equalsIgnoreCase("-o") && args[2].equalsIgnoreCase("clearip"))
|
||||
{
|
||||
Admin admin = plugin.al.getEntryByName(args[1]);
|
||||
if (admin != null)
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
|
||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Check your permissions", usage = "/<command> [prefix | reload]")
|
||||
public class Command_permissions extends FreedomCommand
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(rank = Rank.NON_OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Go to the PlotWorld.", usage = "/<command>", aliases = "pw")
|
||||
public class Command_plotworld extends FreedomCommand
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Enable, disable, or reload a specified plugin, as well as list all plugins on the server.", usage = "/<command> <<enable | disable | reload> <pluginname>> | list>", aliases = "plc")
|
||||
public class Command_plugincontrol extends FreedomCommand
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(
|
||||
description = "Manipulate your potion effects. Duration is measured in server ticks (~20 ticks per second).",
|
||||
usage = "/<command> <list | clearall | clear [target name] | add <type> <duration> <amplifier> [target name]>",
|
||||
@ -44,6 +44,7 @@ public class Command_potion extends FreedomCommand
|
||||
server.getOnlinePlayers().forEach(target -> target.getActivePotionEffects().forEach(effect ->
|
||||
target.removePotionEffect(effect.getType())));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
case 2:
|
||||
|
@ -15,7 +15,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Allows admins to see potions that are thrown.", usage = "/<command> <enable | on | disable | off> | history [player] <page>", aliases = "potspy")
|
||||
public class Command_potionspy extends FreedomCommand
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Purge current mutes, command blocks, orbits, freezes, potion effects, cages, and entities.", usage = "/<command>")
|
||||
public class Command_purgeall extends FreedomCommand
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Show the rank of the sender or a specified user.", usage = "/<command> [player]")
|
||||
public class Command_rank extends FreedomCommand
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Broadcasts the given message. Supports colors.", usage = "/<command> <message>")
|
||||
public class Command_rawsay extends FreedomCommand
|
||||
{
|
||||
|
@ -2,11 +2,12 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Forcefully start a reaction", usage = "/<command>")
|
||||
public class Command_reactionbar extends FreedomCommand
|
||||
{
|
||||
@ -14,6 +15,11 @@ public class Command_reactionbar extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.sh == null) {
|
||||
msg("The shop is currently disabled", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!FUtil.isDeveloper(playerSender))
|
||||
{
|
||||
return noPerms();
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME, blockHostConsole = true)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME, blockHostConsole = true)
|
||||
@CommandParameters(description = "Report a player for all admins to see.", usage = "/<command> <player> <reason>")
|
||||
public class Command_report extends FreedomCommand
|
||||
{
|
||||
@ -54,9 +54,9 @@ public class Command_report extends FreedomCommand
|
||||
|
||||
boolean logged = false;
|
||||
|
||||
if (plugin.dc.enabled)
|
||||
if (plugin.dc != null && plugin.dc.isEnabled())
|
||||
{
|
||||
logged = (player == null) ? plugin.dc.sendReportOffline(playerSender, offlinePlayer, report) : plugin.dc.sendReport(playerSender, player, report);
|
||||
logged = (player == null) ? plugin.dc.getUtils().sendReportOffline(playerSender, offlinePlayer, report) : plugin.dc.getUtils().sendReport(playerSender, player, report);
|
||||
}
|
||||
|
||||
msg(ChatColor.GREEN + "Thank you, your report has been successfully logged."
|
||||
|
@ -13,7 +13,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Ride on the top of the specified player.", usage = "/<command> <playername | mode <normal | off | ask>>")
|
||||
public class Command_ride extends FreedomCommand
|
||||
{
|
||||
|
@ -1,13 +1,13 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import me.totalfreedom.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)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Obtain a rideable ender pearl", usage = "/<command>")
|
||||
public class Command_rideablepearl extends FreedomCommand
|
||||
{
|
||||
@ -15,6 +15,12 @@ public class Command_rideablepearl extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.sh == null)
|
||||
{
|
||||
msg("The shop is currently disabled.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.RIDEABLE_PEARL))
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getRideablePearl());
|
||||
|
@ -17,7 +17,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Remove all blocks of a certain type in the radius of certain players.", usage = "/<command> <block> [radius (default=50)] [player]")
|
||||
public class Command_ro extends FreedomCommand
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "You have thrown a rock, but you have also summoned a meteor!", usage = "/<command>")
|
||||
public class Command_rock extends FreedomCommand
|
||||
{
|
||||
|
@ -7,7 +7,6 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
@ -17,7 +16,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "List, add, remove, or set the rank of admins, clean or reload the admin list, or view admin information.", usage = "/<command> <list | clean | reload | | setrank <username> <rank> | <add | remove | info> <username>>", aliases = "slconfig")
|
||||
public class Command_saconfig extends FreedomCommand
|
||||
{
|
||||
@ -107,9 +106,9 @@ public class Command_saconfig extends FreedomCommand
|
||||
plugin.rm.updateDisplay(player);
|
||||
}
|
||||
|
||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||
if (plugin.dc != null && plugin.dc.isEnabled() && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||
{
|
||||
Discord.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
||||
plugin.dc.getBot().syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID());
|
||||
}
|
||||
|
||||
msg("Set " + admin.getName() + "'s rank to " + rank.getName());
|
||||
@ -203,9 +202,9 @@ public class Command_saconfig extends FreedomCommand
|
||||
plugin.al.updateTables();
|
||||
plugin.rm.updateDisplay(player);
|
||||
|
||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||
if (plugin.dc != null && plugin.dc.isEnabled() && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||
{
|
||||
Discord.syncRoles(admin, plugin.pl.getData(player).getDiscordID());
|
||||
plugin.dc.getBot().syncRoles(admin, plugin.pl.getData(player).getDiscordID());
|
||||
}
|
||||
}
|
||||
|
||||
@ -257,9 +256,9 @@ public class Command_saconfig extends FreedomCommand
|
||||
plugin.rm.updateDisplay(player);
|
||||
}
|
||||
|
||||
if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||
if (plugin.dc != null && plugin.dc.isEnabled() && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean())
|
||||
{
|
||||
Discord.syncRoles(admin, plugin.pl.getData(adminName).getDiscordID());
|
||||
plugin.dc.getBot().syncRoles(admin, plugin.pl.getData(adminName).getDiscordID());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Broadcasts the given message as the server, includes sender name.", usage = "/<command> <message>")
|
||||
public class Command_say extends FreedomCommand
|
||||
{
|
||||
@ -41,7 +41,11 @@ public class Command_say extends FreedomCommand
|
||||
}
|
||||
|
||||
FUtil.bcastMsg(String.format("[Server:%s] %s", sender.getName(), message), ChatColor.LIGHT_PURPLE);
|
||||
plugin.dc.messageChatChannel(String.format("[Server:%s] \u00BB %s", sender.getName(), message));
|
||||
|
||||
if (plugin.dc != null) {
|
||||
plugin.dc.getUtils().messageChatChannel(String.format("[Server:%s] \u00BB %s", sender.getName(), message), true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Sends a guardian particle effect with an enderman scream to the specified player.", usage = "/<command> <player>")
|
||||
public class Command_scare extends FreedomCommand
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ import org.bukkit.generator.WorldInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Get the seed of the world you are currently in.", usage = "/seed [world]")
|
||||
public class Command_seed extends FreedomCommand
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Check the status of the server, including opped players, admins, etc.", usage = "/<command>", aliases = "ss")
|
||||
public class Command_serverstats extends FreedomCommand
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Set your compass to the specified position.", usage = "/<command> <x> <y> <z>")
|
||||
public class Command_setcompass extends FreedomCommand
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Set the on/off state of the lever at position x, y, z in world 'worldname'.", usage = "/<command> <x> <y> <z> <worldname> <on | off>")
|
||||
public class Command_setlever extends FreedomCommand
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Sets everyone's WorldEdit block modification limit to the default limit or to a custom limit.", usage = "/<command> [limit]", aliases = "setl,swl")
|
||||
public class Command_setlimit extends FreedomCommand
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Sets a specific player's WorldEdit block modification limit to the default limit or to a custom limit.", usage = "/<command> <player> [limit]", aliases = "setpl,spl")
|
||||
public class Command_setplayerlimit extends FreedomCommand
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Set the spawn point of the world you are in.", usage = "/<command>")
|
||||
public class Command_setspawnworld extends FreedomCommand
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
|
||||
@CommandPermissions(rank = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
|
||||
@CommandParameters(description = "Set a player's total votes", usage = "/<command> <player> <votes>")
|
||||
public class Command_settotalvotes extends FreedomCommand
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Open the shop GUI", usage = "/<command>", aliases = "sh")
|
||||
public class Command_shop extends FreedomCommand
|
||||
{
|
||||
@ -15,7 +15,7 @@ public class Command_shop extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!ConfigEntry.SHOP_ENABLED.getBoolean())
|
||||
if (plugin.sh == null || !ConfigEntry.SHOP_ENABLED.getBoolean())
|
||||
{
|
||||
msg("The shop is currently disabled!", ChatColor.RED);
|
||||
return true;
|
||||
|
@ -14,7 +14,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Someone being a little bitch? Smite them down...", usage = "/<command> <player> [reason] [-ci | -q]")
|
||||
public class Command_smite extends FreedomCommand
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Spawns the specified entity.", usage = "/<command> <entitytype> [amount]", aliases = "spawnentity")
|
||||
public class Command_spawnmob extends FreedomCommand
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Quickly spectate someone.", usage = "/<command> <playername>", aliases = "spec")
|
||||
public class Command_spectate extends FreedomCommand
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Quickly change your own gamemode to spectator, or define someone's username to change theirs.", usage = "/<command> <[partialname]>", aliases = "gmsp")
|
||||
public class Command_spectator extends FreedomCommand
|
||||
{
|
||||
|
@ -1,13 +1,13 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import me.totalfreedom.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)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Obtain a stacking potato", usage = "/<command>")
|
||||
public class Command_stackingpotato extends FreedomCommand
|
||||
{
|
||||
@ -15,6 +15,11 @@ public class Command_stackingpotato extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.sh == null) {
|
||||
msg("The shop is currently disabled.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.STACKING_POTATO))
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getStackingPotato());
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Shows Minecraft server info, such as authentication status.", usage = "/<command>")
|
||||
public class Command_status extends FreedomCommand
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Kicks everyone and stops the server.", usage = "/<command> [reason]")
|
||||
public class Command_stop extends FreedomCommand
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Stops all sounds or a specified sound.", usage = "/<command> [sound]")
|
||||
public class Command_stopsound extends FreedomCommand
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Quickly change your own gamemode to survival, or define someone's username to change theirs.", usage = "/<command> <[partialname] | -a>", aliases = "gms")
|
||||
public class Command_survival extends FreedomCommand
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Allows you to set your own prefix.", usage = "/<command> [-s[ave]] <set <tag..> | list | gradient <hex> <hex> <tag..> | off | clear <player> | clearall>")
|
||||
public class Command_tag extends FreedomCommand
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Give yourself a prefix with random colors", usage = "/<command> <tag>", aliases = "tn")
|
||||
public class Command_tagnyan extends FreedomCommand
|
||||
{
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Give yourself a prefix with rainbow colors.", usage = "/<command> <tag>")
|
||||
public class Command_tagrainbow extends FreedomCommand
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Temporarily ban someone.", usage = "/<command> [-q] <username> [duration] [reason]", aliases = "tban,noob")
|
||||
public class Command_tempban extends FreedomCommand
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Toggles TotalFreedomMod settings", usage = "/<command> [option] [value] [value]")
|
||||
public class Command_toggle extends FreedomCommand
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Toggle online players' ability to chat.", usage = "/<command>", aliases = "tc")
|
||||
public class Command_togglechat extends FreedomCommand
|
||||
{
|
||||
|
@ -5,7 +5,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Toggle whether or not a player has the ability to use clownfish", usage = "/<command> <player>", aliases = "togglecf")
|
||||
public class Command_toggleclownfish extends FreedomCommand
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Toggle the display of Discord messages in-game.", usage = "/<command>", aliases = "tdiscord,tdisc")
|
||||
public class Command_togglediscord extends FreedomCommand
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Toggle item pickup.", usage = "/<command>")
|
||||
public class Command_togglepickup extends FreedomCommand
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Throw a mob in the direction you are facing when you right click with a bone.",
|
||||
usage = "/<command> <mobtype [speed] | off | list>")
|
||||
public class Command_tossmob extends FreedomCommand
|
||||
|
@ -12,7 +12,7 @@ import org.bukkit.entity.Player;
|
||||
/*
|
||||
* See https://github.com/TotalFreedom/License - This file may not be edited or removed.
|
||||
*/
|
||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Shows information about TotalFreedomMod or reloads it", usage = "/<command> [reload]", aliases = "tfm")
|
||||
public class Command_totalfreedommod extends FreedomCommand
|
||||
{
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Go to a random location in the current world you are in", usage = "/<command>", aliases = "tpr,rtp")
|
||||
public class Command_tprandom extends FreedomCommand
|
||||
{
|
||||
|
@ -1,13 +1,13 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import me.totalfreedom.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)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Trails rainbow wool behind you as you walk/fly.", usage = "/<command>")
|
||||
public class Command_trail extends FreedomCommand
|
||||
{
|
||||
@ -15,6 +15,11 @@ public class Command_trail extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.sh == null) {
|
||||
msg("Shop is not enabled.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!plugin.pl.getData(playerSender).hasItem(ShopItem.RAINBOW_TRAIL))
|
||||
{
|
||||
msg("You didn't purchase the ability to have a " + ShopItem.RAINBOW_TRAIL.getName() + "! Purchase it from the shop.", ChatColor.RED);
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Unbans the specified player.", usage = "/<command> <username> [-r]")
|
||||
public class Command_unban extends FreedomCommand
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Unbans the specified ip.", usage = "/<command> <ip> [-q]")
|
||||
public class Command_unbanip extends FreedomCommand
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Unbans the specified name.", usage = "/<command> <name> [-q]")
|
||||
public class Command_unbanname extends FreedomCommand
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Unblocks commands for a player.", usage = "/<command> <player>", aliases = "unblockcommand,unblockcommands,ubcmds,unblockcmds,ubc")
|
||||
public class Command_unblockcmd extends FreedomCommand
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Uncage a player", usage = "/<command> <name>")
|
||||
public class Command_uncage extends FreedomCommand
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Undisguise all online players on the server", usage = "/<command> [-a]", aliases = "uall")
|
||||
public class Command_undisguiseall extends FreedomCommand
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Unlink your Discord account from your Minecraft account", usage = "/<command> [player]")
|
||||
public class Command_unlinkdiscord extends FreedomCommand
|
||||
{
|
||||
@ -15,7 +15,7 @@ public class Command_unlinkdiscord extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!plugin.dc.enabled)
|
||||
if (plugin.dc == null || !plugin.dc.isEnabled())
|
||||
{
|
||||
msg("The Discord integration system is currently disabled.", ChatColor.RED);
|
||||
return true;
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Unmutes a player", usage = "/<command> [-q] <player>")
|
||||
public class Command_unmute extends FreedomCommand
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Vanish/unvanish yourself.", usage = "/<command> [-s[ilent]]", aliases = "v")
|
||||
public class Command_vanish extends FreedomCommand
|
||||
{
|
||||
@ -46,7 +46,10 @@ public class Command_vanish extends FreedomCommand
|
||||
FUtil.bcastMsg(plugin.rm.craftLoginMessage(playerSender, null));
|
||||
server.broadcast(Component.translatable("multiplayer.player.joined", Component.text(playerSender.getName()))
|
||||
.color(NamedTextColor.YELLOW));
|
||||
plugin.dc.messageChatChannel("**" + playerSender.getName() + " joined the server" + "**", true);
|
||||
|
||||
if (plugin.dc != null) {
|
||||
plugin.dc.getUtils().messageChatChannel("**" + playerSender.getName() + " joined the server" + "**", true);
|
||||
}
|
||||
}
|
||||
|
||||
PlayerData playerData = plugin.pl.getData(playerSender);
|
||||
@ -97,7 +100,9 @@ public class Command_vanish extends FreedomCommand
|
||||
msg("You have vanished.", ChatColor.GOLD);
|
||||
server.broadcast(Component.translatable("multiplayer.player.left", Component.text(playerSender.getName()))
|
||||
.color(NamedTextColor.YELLOW));
|
||||
plugin.dc.messageChatChannel("**" + playerSender.getName() + " left the server" + "**", true);
|
||||
if (plugin.dc != null) {
|
||||
plugin.dc.getUtils().messageChatChannel("**" + playerSender.getName() + " left the server" + "**", true);
|
||||
}
|
||||
}
|
||||
|
||||
FLog.info(playerSender.getName() + " is now vanished.");
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Information on how to vote", usage = "/<command>")
|
||||
public class Command_vote extends FreedomCommand
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Warns the specified player.", usage = "/<command> [-q] <player> <reason>")
|
||||
public class Command_warn extends FreedomCommand
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Manage the whitelist.", usage = "/<command> <on | off | list | count | add <player> | remove <player> | addall | purge>")
|
||||
public class Command_whitelist extends FreedomCommand
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "See who has an item and optionally clear the specified item.", usage = "/<command> <item> [clear]", aliases = "wh")
|
||||
public class Command_whohas extends FreedomCommand
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandParameters(description = "Run any command on all users, username placeholder = ?.", usage = "/<command> [fluff] ? [fluff] ?")
|
||||
public class Command_wildcard extends FreedomCommand
|
||||
{
|
||||
|
@ -1,35 +1,14 @@
|
||||
package me.totalfreedom.totalfreedommod.fun;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.SplittableRandom;
|
||||
import java.util.UUID;
|
||||
import me.totalfreedom.shop.ShopItem;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.SoundCategory;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.EnderPearl;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.Firework;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
@ -45,6 +24,8 @@ import org.bukkit.inventory.meta.FireworkMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ItemFun extends FreedomService
|
||||
{
|
||||
|
||||
@ -61,8 +42,7 @@ public class ItemFun extends FreedomService
|
||||
List<String> featureList = new ArrayList<>();
|
||||
featureList.add(item.getDataName());
|
||||
cooldownTracker.put(player.getName(), featureList);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
cooldownTracker.get(player.getName()).add(item.getDataName());
|
||||
}
|
||||
@ -73,7 +53,7 @@ public class ItemFun extends FreedomService
|
||||
{
|
||||
cooldownTracker.get(player.getName()).remove(item.getDataName());
|
||||
}
|
||||
}.runTaskLater(plugin, seconds * 20);
|
||||
}.runTaskLater(plugin, seconds * 20L);
|
||||
}
|
||||
|
||||
public boolean onCooldown(Player player, ShopItem item)
|
||||
@ -98,6 +78,7 @@ public class ItemFun extends FreedomService
|
||||
@EventHandler
|
||||
public void onPlayerEntityInteract(PlayerInteractEntityEvent event)
|
||||
{
|
||||
if (plugin.sh == null) return; // This is to prevent an NPE if the Shoppe isn't present.
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Entity entity = event.getRightClicked();
|
||||
@ -126,7 +107,7 @@ public class ItemFun extends FreedomService
|
||||
Location playerLoc = player.getLocation();
|
||||
Vector direction = playerLoc.getDirection().normalize();
|
||||
|
||||
LivingEntity livingEntity = (LivingEntity)event.getRightClicked();
|
||||
LivingEntity livingEntity = (LivingEntity) event.getRightClicked();
|
||||
EntityType entityType = livingEntity.getType();
|
||||
if (entityType != fPlayer.mobThrowerCreature())
|
||||
{
|
||||
@ -141,6 +122,8 @@ public class ItemFun extends FreedomService
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (plugin.sh == null) return; // This is to prevent an NPE if the Shoppe isn't present.
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (entity instanceof Player || !(event.getDamager() instanceof Player))
|
||||
@ -148,7 +131,7 @@ public class ItemFun extends FreedomService
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player)event.getDamager();
|
||||
Player player = (Player) event.getDamager();
|
||||
|
||||
if (!player.getInventory().getItemInMainHand().getType().equals(Material.POTATO))
|
||||
{
|
||||
@ -167,6 +150,8 @@ public class ItemFun extends FreedomService
|
||||
@EventHandler
|
||||
public void onPlayerInteractEvent(PlayerInteractEvent event)
|
||||
{
|
||||
if (plugin.sh == null) return; // This is to prevent an NPE if the Shoppe isn't present.
|
||||
|
||||
if (event.getAction() == Action.LEFT_CLICK_AIR
|
||||
|| event.getAction() == Action.LEFT_CLICK_BLOCK)
|
||||
{
|
||||
@ -178,7 +163,7 @@ public class ItemFun extends FreedomService
|
||||
|
||||
switch (event.getMaterial())
|
||||
{
|
||||
case GUNPOWDER:
|
||||
case GUNPOWDER ->
|
||||
{
|
||||
if (!fPlayer.isMP44Armed())
|
||||
{
|
||||
@ -190,15 +175,12 @@ public class ItemFun extends FreedomService
|
||||
if (fPlayer.toggleMP44Firing())
|
||||
{
|
||||
fPlayer.startArrowShooter(plugin);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
fPlayer.stopArrowShooter();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case BLAZE_ROD:
|
||||
case BLAZE_ROD ->
|
||||
{
|
||||
if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.LIGHTNING_ROD, player.getInventory(), plugin.sh.getLightningRod()))
|
||||
{
|
||||
@ -219,10 +201,8 @@ public class ItemFun extends FreedomService
|
||||
player.getWorld().strikeLightning(targetBlock.getLocation());
|
||||
}
|
||||
cooldown(player, ShopItem.LIGHTNING_ROD, 10);
|
||||
break;
|
||||
}
|
||||
|
||||
case FIRE_CHARGE:
|
||||
case FIRE_CHARGE ->
|
||||
{
|
||||
if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.FIRE_BALL, player.getInventory(), plugin.sh.getFireBall()))
|
||||
{
|
||||
@ -240,14 +220,12 @@ public class ItemFun extends FreedomService
|
||||
FIRE_BALL_UUIDS.add(fireball.getUniqueId());
|
||||
fireball.setVelocity(player.getLocation().getDirection().multiply(2));
|
||||
cooldown(player, ShopItem.FIRE_BALL, 5);
|
||||
break;
|
||||
}
|
||||
|
||||
case TROPICAL_FISH:
|
||||
case TROPICAL_FISH ->
|
||||
{
|
||||
final int RADIUS_HIT = 5;
|
||||
final int STRENGTH = 4;
|
||||
|
||||
|
||||
if (plugin.lp.CLOWNFISH_TOGGLE.contains(player.getName()))
|
||||
{
|
||||
player.sendMessage(ChatColor.GRAY + "An admin has disabled your ability to use clownfish.");
|
||||
@ -284,8 +262,7 @@ public class ItemFun extends FreedomService
|
||||
target.setVelocity(targetPosVec.subtract(playerLocVec).normalize().multiply(STRENGTH));
|
||||
didHit = true;
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException ignored)
|
||||
} catch (IllegalArgumentException ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -302,12 +279,10 @@ public class ItemFun extends FreedomService
|
||||
}
|
||||
cooldown(player, ShopItem.CLOWN_FISH, 30);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
default ->
|
||||
{
|
||||
// Do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -315,10 +290,12 @@ public class ItemFun extends FreedomService
|
||||
@EventHandler
|
||||
public void onProjectileLaunch(ProjectileLaunchEvent event)
|
||||
{
|
||||
if (plugin.sh == null) return;
|
||||
|
||||
Projectile entity = event.getEntity();
|
||||
if (entity instanceof EnderPearl && entity.getShooter() instanceof Player)
|
||||
{
|
||||
Player player = (Player)entity.getShooter();
|
||||
Player player = (Player) entity.getShooter();
|
||||
if (plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.RIDEABLE_PEARL, player.getInventory(), plugin.sh.getRideablePearl()))
|
||||
{
|
||||
entity.addPassenger(player);
|
||||
@ -333,7 +310,7 @@ public class ItemFun extends FreedomService
|
||||
Arrow arrow = null;
|
||||
if (entity instanceof Arrow)
|
||||
{
|
||||
arrow = (Arrow)entity;
|
||||
arrow = (Arrow) entity;
|
||||
}
|
||||
//Redundant Player cast is required to avoid suspicious method calls.
|
||||
if (arrow != null
|
||||
@ -349,7 +326,7 @@ public class ItemFun extends FreedomService
|
||||
if (FIRE_BALL_UUIDS.contains(entity.getUniqueId()))
|
||||
{
|
||||
FIRE_BALL_UUIDS.remove(entity.getUniqueId());
|
||||
Firework firework = (Firework)entity.getWorld().spawnEntity(entity.getLocation(), EntityType.FIREWORK);
|
||||
Firework firework = (Firework) entity.getWorld().spawnEntity(entity.getLocation(), EntityType.FIREWORK);
|
||||
firework.setSilent(true);
|
||||
FireworkMeta meta = firework.getFireworkMeta();
|
||||
FireworkEffect explosionEffect = FireworkEffect.builder().withColor(Color.ORANGE).withFade(Color.YELLOW).with(FireworkEffect.Type.BALL_LARGE).trail(true).build();
|
||||
@ -376,6 +353,8 @@ public class ItemFun extends FreedomService
|
||||
@EventHandler
|
||||
public void onFish(PlayerFishEvent event)
|
||||
{
|
||||
if (plugin.sh == null) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
PlayerData data = plugin.pl.getData(player);
|
||||
PlayerInventory inv = event.getPlayer().getInventory();
|
||||
@ -404,40 +383,32 @@ public class ItemFun extends FreedomService
|
||||
if (orientation >= 0.0 && orientation < 22.5)
|
||||
{
|
||||
zVel = speed;
|
||||
}
|
||||
else if (orientation >= 22.5 && orientation < 67.5)
|
||||
} else if (orientation >= 22.5 && orientation < 67.5)
|
||||
{
|
||||
xVel = -(speed / 2.0);
|
||||
zVel = speed / 2.0;
|
||||
}
|
||||
else if (orientation >= 67.5 && orientation < 112.5)
|
||||
} else if (orientation >= 67.5 && orientation < 112.5)
|
||||
{
|
||||
xVel = -speed;
|
||||
}
|
||||
else if (orientation >= 112.5 && orientation < 157.5)
|
||||
} else if (orientation >= 112.5 && orientation < 157.5)
|
||||
{
|
||||
xVel = -(speed / 2.0);
|
||||
zVel = -(speed / 2.0);
|
||||
}
|
||||
else if (orientation >= 157.5 && orientation < 202.5)
|
||||
} else if (orientation >= 157.5 && orientation < 202.5)
|
||||
{
|
||||
zVel = -speed;
|
||||
}
|
||||
else if (orientation >= 202.5 && orientation < 247.5)
|
||||
} else if (orientation >= 202.5 && orientation < 247.5)
|
||||
{
|
||||
xVel = speed / 2.0;
|
||||
zVel = -(speed / 2.0);
|
||||
}
|
||||
else if (orientation >= 247.5 && orientation < 292.5)
|
||||
} else if (orientation >= 247.5 && orientation < 292.5)
|
||||
{
|
||||
xVel = speed;
|
||||
}
|
||||
else if (orientation >= 292.5 && orientation < 337.5)
|
||||
} else if (orientation >= 292.5 && orientation < 337.5)
|
||||
{
|
||||
xVel = speed / 2.0;
|
||||
zVel = speed / 2.0;
|
||||
}
|
||||
else if (orientation >= 337.5 && orientation < 360.0)
|
||||
} else if (orientation >= 337.5 && orientation < 360.0)
|
||||
{
|
||||
zVel = speed;
|
||||
}
|
||||
@ -447,8 +418,7 @@ public class ItemFun extends FreedomService
|
||||
if (event.getState() == PlayerFishEvent.State.FISHING)
|
||||
{
|
||||
orientationTracker.put(player, player.getLocation().getYaw());
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
orientationTracker.remove(player);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import java.util.SplittableRandom;
|
||||
import java.util.UUID;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import me.totalfreedom.shop.ShopItem;
|
||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -36,6 +36,8 @@ public class Trailer extends FreedomService
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerMove(PlayerMoveEvent event)
|
||||
{
|
||||
if (plugin.sh == null) return; // Shop is disabled
|
||||
|
||||
/* Doesn't continue any further if...
|
||||
* - The trail list is empty
|
||||
* - The player doesn't have their trail enabled in the first place
|
||||
@ -63,6 +65,7 @@ public class Trailer extends FreedomService
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Make this particles instead of blocks!
|
||||
fromBlock.setType(Groups.WOOL_COLORS.get(random.nextInt(Groups.WOOL_COLORS.size())));
|
||||
BlockData data = fromBlock.getBlockData();
|
||||
Material material = Material.getMaterial(String.valueOf(fromBlock.getType()));
|
||||
|
@ -5,7 +5,7 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import me.totalfreedom.shop.ShopItem;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
@ -5,7 +5,8 @@ import discord4j.core.DiscordClientBuilder;
|
||||
import discord4j.core.GatewayDiscordClient;
|
||||
import discord4j.core.event.domain.interaction.ChatInputInteractionEvent;
|
||||
import discord4j.core.object.entity.Guild;
|
||||
import discord4j.core.object.entity.Message;
|
||||
import discord4j.core.object.entity.Member;
|
||||
import discord4j.core.object.entity.Role;
|
||||
import discord4j.core.object.entity.channel.TextChannel;
|
||||
import me.totalfreedom.discord.command.HelpCommand;
|
||||
import me.totalfreedom.discord.command.ListCommand;
|
||||
@ -13,19 +14,19 @@ import me.totalfreedom.discord.command.TPSCommand;
|
||||
import me.totalfreedom.discord.handling.CommandHandler;
|
||||
import me.totalfreedom.discord.util.SnowflakeEntry;
|
||||
import me.totalfreedom.discord.util.TFM_Bridge;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import net.dv8tion.jda.internal.utils.concurrent.CountingThreadFactory;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
|
||||
public class Bot
|
||||
@ -45,6 +46,10 @@ public class Bot
|
||||
.login()
|
||||
.block();
|
||||
|
||||
this.tfm = new TFM_Bridge(this);
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
if (client == null) throw new IllegalStateException();
|
||||
|
||||
final CommandHandler handler = new CommandHandler(client.getRestClient());
|
||||
@ -71,12 +76,125 @@ public class Bot
|
||||
.then(client.onDisconnect())
|
||||
.block(); // We use .block() as there is not another non-daemon thread and the jvm would close otherwise.
|
||||
|
||||
this.tfm = new TFM_Bridge(this);
|
||||
|
||||
RATELIMIT_EXECUTOR = new ScheduledThreadPoolExecutor(5, new CountingThreadFactory(this::poolIdentifier, "RateLimit"));
|
||||
RATELIMIT_EXECUTOR.setRemoveOnCancelPolicy(true);
|
||||
}
|
||||
|
||||
public String getCode(PlayerData playerData) {
|
||||
for (String code : LINK_CODES.keySet())
|
||||
{
|
||||
if (LINK_CODES.get(code).equals(playerData))
|
||||
{
|
||||
return code;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public String generateCode(int size)
|
||||
{
|
||||
return RandomStringUtils.randomNumeric(size);
|
||||
}
|
||||
|
||||
public String formatBotTag() {
|
||||
return client.getSelf()
|
||||
.blockOptional()
|
||||
.orElseThrow()
|
||||
.getUsername() + "#" + client.getSelf()
|
||||
.blockOptional()
|
||||
.orElseThrow()
|
||||
.getDiscriminator();
|
||||
}
|
||||
|
||||
public boolean syncRoles(Admin admin, String discordID)
|
||||
{
|
||||
if (discordID == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Guild server = client.getGuildById(SnowflakeEntry.serverID)
|
||||
.blockOptional()
|
||||
.orElseThrow();
|
||||
|
||||
Member member = server.getMemberById(Snowflake.of(discordID))
|
||||
.blockOptional()
|
||||
.orElseThrow();
|
||||
|
||||
Role adminRole = server.getRoleById(SnowflakeEntry.adminRoleID)
|
||||
.blockOptional()
|
||||
.orElseThrow();
|
||||
|
||||
Role senioradminRole = server.getRoleById(SnowflakeEntry.seniorRoleID)
|
||||
.blockOptional()
|
||||
.orElseThrow();
|
||||
|
||||
if (!admin.isActive())
|
||||
{
|
||||
syncRolesActivityCheck(member, adminRole, senioradminRole);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (admin.getRank().equals(Rank.ADMIN))
|
||||
{
|
||||
syncRolesAdminAssignment(member, adminRole, senioradminRole);
|
||||
return true;
|
||||
}
|
||||
else if (admin.getRank().equals(Rank.SENIOR_ADMIN))
|
||||
{
|
||||
syncRolesSeniorAssignment(member, adminRole, senioradminRole);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void syncRolesAdminAssignment(Member member, Role adminRole, Role senioradminRole) {
|
||||
member.getRoles().doFirst(() -> {
|
||||
if (!member.getRoles().collectList().blockOptional().orElseThrow().contains(adminRole))
|
||||
{
|
||||
member.addRole(adminRole.getId()).block();
|
||||
}
|
||||
}).doOnEach(r -> {
|
||||
Role role = r.get();
|
||||
if (role == null) return;
|
||||
|
||||
if (role.equals(senioradminRole))
|
||||
{
|
||||
member.removeRole(role.getId()).block();
|
||||
}
|
||||
}).subscribe();
|
||||
}
|
||||
|
||||
private void syncRolesActivityCheck(Member member, Role adminRole, Role senioradminRole) {
|
||||
member.getRoles().doOnEach(r -> {
|
||||
Role role = r.get();
|
||||
if (role == null) return;
|
||||
|
||||
if (role.equals(adminRole) || role.equals(senioradminRole))
|
||||
{
|
||||
member.removeRole(role.getId()).block();
|
||||
}
|
||||
}).subscribe();
|
||||
}
|
||||
|
||||
private void syncRolesSeniorAssignment(Member member, Role adminRole, Role senioradminRole) {
|
||||
member.getRoles().doFirst(() -> {
|
||||
if (!member.getRoles().collectList().blockOptional().orElseThrow().contains(senioradminRole))
|
||||
{
|
||||
member.addRole(senioradminRole.getId()).block();
|
||||
}
|
||||
}).doOnEach(r -> {
|
||||
Role role = r.get();
|
||||
if (role == null) return;
|
||||
|
||||
if (role.equals(adminRole))
|
||||
{
|
||||
member.removeRole(role.getId()).block();
|
||||
}
|
||||
}).subscribe();
|
||||
}
|
||||
|
||||
|
||||
private String poolIdentifier()
|
||||
{
|
||||
return "TFD4J";
|
||||
|
@ -60,85 +60,6 @@ public class TFM_Bridge
|
||||
}).blockFirst();
|
||||
}
|
||||
|
||||
public String getCode(PlayerData playerData)
|
||||
{
|
||||
for (String code : bot.getLinkCodes().keySet())
|
||||
{
|
||||
if (bot.getLinkCodes().get(code).equals(playerData))
|
||||
{
|
||||
return code;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean syncRoles(Admin admin, String discordID)
|
||||
{
|
||||
if (discordID == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Guild server = bot.getGuildById().block();
|
||||
|
||||
if (server == null)
|
||||
{
|
||||
FLog.severe("The Discord server ID specified is invalid, or the bot is not on the server.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Member member = server.getMemberById(Snowflake.of(discordID)).block();
|
||||
if (member == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Role adminRole = server.getRoleById(SnowflakeEntry.adminRoleID).block();
|
||||
if (adminRole == null)
|
||||
{
|
||||
FLog.severe("The specified Admin role does not exist!");
|
||||
return false;
|
||||
}
|
||||
|
||||
Role senioradminRole = server.getRoleById(SnowflakeEntry.seniorRoleID).block();
|
||||
if (senioradminRole == null)
|
||||
{
|
||||
FLog.severe("The specified Senior Admin role does not exist!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!admin.isActive())
|
||||
{
|
||||
member.getRoles()
|
||||
.filter(role -> role.equals(adminRole) || role.equals(senioradminRole))
|
||||
.subscribe(r -> member.removeRole(r.getId()).block());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (admin.getRank().equals(Rank.ADMIN))
|
||||
{
|
||||
member.getRoles()
|
||||
.filter(role -> !role.equals(adminRole))
|
||||
.subscribe(r -> member.addRole(r.getId()).block());
|
||||
member.getRoles()
|
||||
.filter(role -> role.equals(senioradminRole))
|
||||
.subscribe(r -> member.removeRole(r.getId()).block());
|
||||
return true;
|
||||
}
|
||||
else if (admin.getRank().equals(Rank.SENIOR_ADMIN))
|
||||
{
|
||||
member.getRoles()
|
||||
.filter(role -> !role.equals(senioradminRole))
|
||||
.subscribe(r -> member.addRole(r.getId()).block());
|
||||
|
||||
member.getRoles()
|
||||
.filter(role -> role.equals(adminRole))
|
||||
.subscribe(r -> member.removeRole(r.getId()).block());
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public TotalFreedomMod getCommons() {
|
||||
return commons;
|
||||
}
|
||||
|
@ -3,14 +3,18 @@ package me.totalfreedom.discord.util;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import discord4j.core.object.entity.Guild;
|
||||
import discord4j.core.object.entity.Message;
|
||||
import discord4j.core.object.entity.channel.Channel;
|
||||
import discord4j.core.object.entity.channel.TextChannel;
|
||||
import discord4j.core.object.reaction.ReactionEmoji;
|
||||
import discord4j.core.spec.EmbedCreateSpec;
|
||||
import discord4j.core.spec.MessageCreateSpec;
|
||||
import discord4j.discordjson.json.EmojiData;
|
||||
import discord4j.discordjson.json.ReactionData;
|
||||
import me.totalfreedom.discord.TFD4J;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@ -23,7 +27,7 @@ import java.util.Objects;
|
||||
|
||||
public class Utilities
|
||||
{
|
||||
private final Flux<Message> sentMessages = Flux.fromIterable(new ArrayList<>());
|
||||
private Flux<Message> sentMessages = Flux.fromIterable(new ArrayList<>());
|
||||
private final TFD4J tfd4J;
|
||||
private final ImmutableList<String> DISCORD_SUBDOMAINS = (ImmutableList<String>)
|
||||
List.of("discordapp.com",
|
||||
@ -35,6 +39,11 @@ public class Utilities
|
||||
this.tfd4J = tfd4J;
|
||||
}
|
||||
|
||||
public void clearQueue()
|
||||
{
|
||||
sentMessages = Flux.fromIterable(new ArrayList<>());
|
||||
}
|
||||
|
||||
public String sanitizeChatMessage(String message)
|
||||
{
|
||||
String newMessage = message;
|
||||
@ -116,6 +125,48 @@ public class Utilities
|
||||
}
|
||||
}
|
||||
|
||||
public boolean sendReportOffline(Player reporter, OfflinePlayer reported, String reason)
|
||||
{
|
||||
if (!tfd4J.getBot().shouldISendReport())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final Guild server = tfd4J.getBot().getGuildById().block();
|
||||
|
||||
if (server == null) return false;
|
||||
|
||||
final Channel channel = server.getChannelById(SnowflakeEntry.reportChannelID).block();
|
||||
|
||||
if (!(channel instanceof TextChannel tch)) return false;
|
||||
|
||||
final EmbedCreateSpec.Builder builder = EmbedCreateSpec.builder()
|
||||
.title("Report for " + reported.getName() + " (offline)")
|
||||
.description(reason)
|
||||
.footer("Reported by " + reporter.getName(), "https://minotar.net/helm/" + reporter.getName() + ".png")
|
||||
.timestamp(Instant.from(ZonedDateTime.now()));
|
||||
if (tfd4J.getBot().getTFM().getCommons().esb.isEnabled())
|
||||
{
|
||||
com.earth2me.essentials.User user = tfd4J.getBot().getTFM().getCommons().esb.getEssentialsUser(reported.getName());
|
||||
String location = "World: " + Objects.requireNonNull(user.getLastLocation().getWorld()).getName() + ", X: " + user.getLastLocation().getBlockX() + ", Y: " + user.getLastLocation().getBlockY() + ", Z: " + user.getLastLocation().getBlockZ();
|
||||
builder.addField("Location", location, true);
|
||||
builder.addField("God Mode", WordUtils.capitalizeFully(String.valueOf(user.isGodModeEnabled())), true);
|
||||
if (user.getNickname() != null)
|
||||
{
|
||||
builder.addField("Nickname", user.getNickname(), true);
|
||||
}
|
||||
}
|
||||
EmbedCreateSpec embed = builder.build();
|
||||
Message message = tch.createMessage(embed).block();
|
||||
|
||||
if (message != null && !ConfigEntry.DISCORD_REPORT_ARCHIVE_CHANNEL_ID.getString().isEmpty())
|
||||
{
|
||||
message.addReaction(ReactionEmoji.unicode("\uD83D\uDCCB")).subscribe();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean sendReport(Player reporter, Player reported, String reason)
|
||||
{
|
||||
if (!tfd4J.getBot().shouldISendReport())
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: TFD4J
|
||||
main: me.totalfreedom.discord.TFD4J
|
||||
version: 1.0
|
||||
version: 2023.03
|
||||
api-version: 1.19
|
||||
depend: [TotalFreedomMod]
|
||||
libraries:
|
||||
|
@ -11,6 +11,15 @@
|
||||
|
||||
<artifactId>shop</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>me.totalfreedom</groupId>
|
||||
<artifactId>commons</artifactId>
|
||||
<version>2023.02</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user