mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
commit
1293a8aa1e
2
pom.xml
2
pom.xml
@ -156,7 +156,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.16.4-R0.1-SNAPSHOT</version>
|
<version>1.16.5-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ public class LoginProcess extends FreedomService
|
|||||||
private static boolean lockdownEnabled = false;
|
private static boolean lockdownEnabled = false;
|
||||||
public List<String> TELEPORT_ON_JOIN = new ArrayList<>();
|
public List<String> TELEPORT_ON_JOIN = new ArrayList<>();
|
||||||
public List<String> CLEAR_ON_JOIN = new ArrayList<>();
|
public List<String> CLEAR_ON_JOIN = new ArrayList<>();
|
||||||
|
public List<String> CLOWNFISH_TOGGLE = new ArrayList<>();
|
||||||
|
|
||||||
public static boolean isLockdownEnabled()
|
public static boolean isLockdownEnabled()
|
||||||
{
|
{
|
||||||
|
@ -1,61 +1,61 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking;
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
|
||||||
public class EditBlocker extends FreedomService
|
public class EditBlocker extends FreedomService
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onBlockPlace(BlockPlaceEvent event)
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
{
|
{
|
||||||
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
|
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
|
||||||
if (!fPlayer.isEditBlocked())
|
if (!fPlayer.isEditBlocked())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.al.isAdminSync(event.getPlayer()))
|
if (plugin.al.isAdminSync(event.getPlayer()))
|
||||||
{
|
{
|
||||||
fPlayer.setEditBlocked(false);
|
fPlayer.setEditBlocked(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to place blocks has been disabled!");
|
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to place blocks has been disabled!");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onBlockBreak(BlockBreakEvent event)
|
public void onBlockBreak(BlockBreakEvent event)
|
||||||
{
|
{
|
||||||
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
|
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
|
||||||
if (!fPlayer.isEditBlocked())
|
if (!fPlayer.isEditBlocked())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.al.isAdminSync(event.getPlayer()))
|
if (plugin.al.isAdminSync(event.getPlayer()))
|
||||||
{
|
{
|
||||||
fPlayer.setEditBlocked(false);
|
fPlayer.setEditBlocked(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to destroy blocks has been disabled!");
|
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to destroy blocks has been disabled!");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,14 +15,14 @@ public class Command_clownfish extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.CLOWN_FISH))
|
if (plugin.pl.getData(playerSender).hasItem(ShopItem.CLOWN_FISH) && (!plugin.lp.CLOWNFISH_TOGGLE.contains(playerSender.getName())))
|
||||||
{
|
{
|
||||||
playerSender.getInventory().addItem(plugin.sh.getClownFish());
|
playerSender.getInventory().addItem(plugin.sh.getClownFish());
|
||||||
msg("You have been given a Clown Fish", ChatColor.GREEN);
|
msg("You have been given a Clown Fish", ChatColor.GREEN);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg("You do not own a Clown Fish! Purchase one from the shop.", ChatColor.RED);
|
msg("You do not own a Clown Fish or an admin has toggled your ability to use it. Purchase one from the shop.", ChatColor.RED);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,54 +1,54 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Shows the amount of coins you have or another player has", usage = "/<command> [playername]")
|
@CommandParameters(description = "Shows the amount of coins you have or another player has", usage = "/<command> [playername]")
|
||||||
public class Command_coins extends FreedomCommand
|
public class Command_coins extends FreedomCommand
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (!ConfigEntry.SHOP_ENABLED.getBoolean())
|
if (!ConfigEntry.SHOP_ENABLED.getBoolean())
|
||||||
{
|
{
|
||||||
msg("The shop is currently disabled!", ChatColor.RED);
|
msg("The shop is currently disabled!", ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Player p;
|
Player p;
|
||||||
final String prefix = FUtil.colorize(ConfigEntry.SHOP_PREFIX.getString() + " ");
|
final String prefix = FUtil.colorize(ConfigEntry.SHOP_PREFIX.getString() + " ");
|
||||||
if (args.length > 0)
|
if (args.length > 0)
|
||||||
{
|
{
|
||||||
if (getPlayer(args[0]) != null)
|
if (getPlayer(args[0]) != null)
|
||||||
{
|
{
|
||||||
p = getPlayer(args[0]);
|
p = getPlayer(args[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg(PLAYER_NOT_FOUND);
|
msg(PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (senderIsConsole)
|
if (senderIsConsole)
|
||||||
{
|
{
|
||||||
msg(prefix + ChatColor.RED + "You are not a player, use /coins <playername>");
|
msg(prefix + ChatColor.RED + "You are not a player, use /coins <playername>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p = playerSender;
|
p = playerSender;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlayerData playerData = plugin.pl.getData(p);
|
PlayerData playerData = plugin.pl.getData(p);
|
||||||
msg(prefix + ChatColor.GREEN + (args.length > 0 ? p.getName() + " has " : "You have ") + ChatColor.RED + playerData.getCoins() + ChatColor.GREEN + " coins.");
|
msg(prefix + ChatColor.GREEN + (args.length > 0 ? p.getName() + " has " : "You have ") + ChatColor.RED + playerData.getCoins() + ChatColor.GREEN + " coins.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,69 +1,69 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Surprise someone.", usage = "/<command> <player>")
|
@CommandParameters(description = "Surprise someone.", usage = "/<command> <player>")
|
||||||
public class Command_explode extends FreedomCommand
|
public class Command_explode extends FreedomCommand
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Player player = getPlayer(args[0]);
|
final Player player = getPlayer(args[0]);
|
||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.setFlying(false);
|
player.setFlying(false);
|
||||||
player.setVelocity(player.getVelocity().clone().add(new Vector(0, 50, 0)));
|
player.setVelocity(player.getVelocity().clone().add(new Vector(0, 50, 0)));
|
||||||
|
|
||||||
for (int i = 1; i <= 3; i++)
|
for (int i = 1; i <= 3; i++)
|
||||||
{
|
{
|
||||||
FUtil.createExplosionOnDelay(player.getLocation(), 2L, i * 10);
|
FUtil.createExplosionOnDelay(player.getLocation(), 2L, i * 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
new BukkitRunnable()
|
new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
player.getWorld().strikeLightning(player.getLocation());
|
player.getWorld().strikeLightning(player.getLocation());
|
||||||
player.getWorld().createExplosion(player.getLocation(), 4L);
|
player.getWorld().createExplosion(player.getLocation(), 4L);
|
||||||
}
|
}
|
||||||
player.setHealth(0.0);
|
player.setHealth(0.0);
|
||||||
msg("Exploded " + player.getName());
|
msg("Exploded " + player.getName());
|
||||||
}
|
}
|
||||||
}.runTaskLater(plugin, 40);
|
}.runTaskLater(plugin, 40);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
{
|
{
|
||||||
if (args.length == 1 && plugin.al.isAdmin(sender))
|
if (args.length == 1 && plugin.al.isAdmin(sender))
|
||||||
{
|
{
|
||||||
return FUtil.getPlayerList();
|
return FUtil.getPlayerList();
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -21,8 +21,13 @@ public class Command_fuckoff extends FreedomCommand
|
|||||||
|
|
||||||
FPlayer player = plugin.pl.getPlayer(playerSender);
|
FPlayer player = plugin.pl.getPlayer(playerSender);
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("off"))
|
if (!args[0].equals("on"))
|
||||||
{
|
{
|
||||||
|
player.disableFuckoff();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
double radius = 25.0;
|
double radius = 25.0;
|
||||||
if (args.length >= 2)
|
if (args.length >= 2)
|
||||||
{
|
{
|
||||||
@ -34,14 +39,12 @@ public class Command_fuckoff extends FreedomCommand
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player.setFuckoff(radius);
|
player.setFuckoff(radius);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
player.disableFuckoff();
|
|
||||||
}
|
|
||||||
|
|
||||||
msg("Fuckoff " + (player.isFuckOff() ? ("enabled. Radius: " + player.getFuckoffRadius() + ".") : "disabled."));
|
msg("Fuckoff " + (player.isFuckOff() ? ("enabled. Radius: " + player.getFuckoffRadius() + ".") : "disabled."));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,219 +1,219 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Manage the shop", usage = "/<command> <coins: <add | set | remove> <amount> <player | all> | items: <give | take> <item> <player>", aliases = "ms")
|
@CommandParameters(description = "Manage the shop", usage = "/<command> <coins: <add | set | remove> <amount> <player | all> | items: <give | take> <item> <player>", aliases = "ms")
|
||||||
public class Command_manageshop extends FreedomCommand
|
public class Command_manageshop extends FreedomCommand
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!FUtil.isExecutive(sender.getName()))
|
if (!FUtil.isExecutive(sender.getName()))
|
||||||
{
|
{
|
||||||
return noPerms();
|
return noPerms();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length < 2)
|
if (args.length < 2)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args[0].equals("coins"))
|
if (args[0].equals("coins"))
|
||||||
{
|
{
|
||||||
if (args.length < 4)
|
if (args.length < 4)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (args[1])
|
switch (args[1])
|
||||||
{
|
{
|
||||||
|
|
||||||
case "add":
|
case "add":
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int amount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2])));
|
int amount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2])));
|
||||||
if (!args[3].equals("all"))
|
if (!args[3].equals("all"))
|
||||||
{
|
{
|
||||||
PlayerData playerData = plugin.pl.getData(args[3]);
|
PlayerData playerData = plugin.pl.getData(args[3]);
|
||||||
if (playerData == null)
|
if (playerData == null)
|
||||||
{
|
{
|
||||||
msg(PLAYER_NOT_FOUND);
|
msg(PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
playerData.setCoins(playerData.getCoins() + amount);
|
playerData.setCoins(playerData.getCoins() + amount);
|
||||||
plugin.pl.save(playerData);
|
plugin.pl.save(playerData);
|
||||||
msg("Successfully added " + amount + " coins to " + args[3] + ". Their new balance is " + playerData.getCoins(), ChatColor.GREEN);
|
msg("Successfully added " + amount + " coins to " + args[3] + ". Their new balance is " + playerData.getCoins(), ChatColor.GREEN);
|
||||||
Player player = getPlayer(args[3]);
|
Player player = getPlayer(args[3]);
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins());
|
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
PlayerData playerData = plugin.pl.getData(player);
|
PlayerData playerData = plugin.pl.getData(player);
|
||||||
playerData.setCoins(playerData.getCoins() + amount);
|
playerData.setCoins(playerData.getCoins() + amount);
|
||||||
plugin.pl.save(playerData);
|
plugin.pl.save(playerData);
|
||||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins());
|
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins());
|
||||||
}
|
}
|
||||||
msg("Successfully added " + amount + " coins to all online players.", ChatColor.GREEN);
|
msg("Successfully added " + amount + " coins to all online players.", ChatColor.GREEN);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
msg("Invalid number: " + args[2], ChatColor.RED);
|
msg("Invalid number: " + args[2], ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "remove":
|
case "remove":
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int amount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2])));
|
int amount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2])));
|
||||||
if (!args[3].equals("all"))
|
if (!args[3].equals("all"))
|
||||||
{
|
{
|
||||||
PlayerData playerData = plugin.pl.getData(args[3]);
|
PlayerData playerData = plugin.pl.getData(args[3]);
|
||||||
if (playerData == null)
|
if (playerData == null)
|
||||||
{
|
{
|
||||||
msg(PLAYER_NOT_FOUND);
|
msg(PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
playerData.setCoins(playerData.getCoins() - amount);
|
playerData.setCoins(playerData.getCoins() - amount);
|
||||||
if (playerData.getCoins() < 0)
|
if (playerData.getCoins() < 0)
|
||||||
{
|
{
|
||||||
playerData.setCoins(0);
|
playerData.setCoins(0);
|
||||||
}
|
}
|
||||||
plugin.pl.save(playerData);
|
plugin.pl.save(playerData);
|
||||||
msg("Successfully removed " + amount + " coins from " + args[3] + ". Their new balance is " + playerData.getCoins(), ChatColor.GREEN);
|
msg("Successfully removed " + amount + " coins from " + args[3] + ". Their new balance is " + playerData.getCoins(), ChatColor.GREEN);
|
||||||
Player player = getPlayer(args[3]);
|
Player player = getPlayer(args[3]);
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins());
|
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
PlayerData playerData = plugin.pl.getData(player);
|
PlayerData playerData = plugin.pl.getData(player);
|
||||||
playerData.setCoins(playerData.getCoins() - amount);
|
playerData.setCoins(playerData.getCoins() - amount);
|
||||||
if (playerData.getCoins() < 0)
|
if (playerData.getCoins() < 0)
|
||||||
{
|
{
|
||||||
playerData.setCoins(0);
|
playerData.setCoins(0);
|
||||||
}
|
}
|
||||||
plugin.pl.save(playerData);
|
plugin.pl.save(playerData);
|
||||||
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins());
|
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins());
|
||||||
}
|
}
|
||||||
msg("Successfully took " + amount + " coins from all online players.", ChatColor.GREEN);
|
msg("Successfully took " + amount + " coins from all online players.", ChatColor.GREEN);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
msg("Invalid number: " + args[2], ChatColor.RED);
|
msg("Invalid number: " + args[2], ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "set":
|
case "set":
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int amount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2])));
|
int amount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2])));
|
||||||
PlayerData playerData = plugin.pl.getData(args[3]);
|
PlayerData playerData = plugin.pl.getData(args[3]);
|
||||||
if (playerData == null)
|
if (playerData == null)
|
||||||
{
|
{
|
||||||
msg(PLAYER_NOT_FOUND);
|
msg(PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
playerData.setCoins(amount);
|
playerData.setCoins(amount);
|
||||||
plugin.pl.save(playerData);
|
plugin.pl.save(playerData);
|
||||||
msg("Successfully set " + args[3] + "'s coins to " + amount, ChatColor.GREEN);
|
msg("Successfully set " + args[3] + "'s coins to " + amount, ChatColor.GREEN);
|
||||||
Player player = getPlayer(args[3]);
|
Player player = getPlayer(args[3]);
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " set your coin balance to " + amount);
|
player.sendMessage(ChatColor.GREEN + sender.getName() + " set your coin balance to " + amount);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
msg("Invalid number: " + args[2], ChatColor.RED);
|
msg("Invalid number: " + args[2], ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (args[0].equals("items"))
|
else if (args[0].equals("items"))
|
||||||
{
|
{
|
||||||
if (args[1].equals("list"))
|
if (args[1].equals("list"))
|
||||||
{
|
{
|
||||||
msg("List of all shop items: " + StringUtils.join(ShopItem.values(), ", "));
|
msg("List of all shop items: " + StringUtils.join(ShopItem.values(), ", "));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length < 4)
|
if (args.length < 4)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[1].equals("give"))
|
if (args[1].equals("give"))
|
||||||
{
|
{
|
||||||
ShopItem item = ShopItem.findItem(args[2].toUpperCase());
|
ShopItem item = ShopItem.findItem(args[2].toUpperCase());
|
||||||
if (item == null)
|
if (item == null)
|
||||||
{
|
{
|
||||||
msg(args[2] + " is not a valid item.", ChatColor.RED);
|
msg(args[2] + " is not a valid item.", ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerData playerData = plugin.pl.getData(args[3]);
|
PlayerData playerData = plugin.pl.getData(args[3]);
|
||||||
if (playerData == null)
|
if (playerData == null)
|
||||||
{
|
{
|
||||||
msg(PLAYER_NOT_FOUND);
|
msg(PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
playerData.giveItem(item);
|
playerData.giveItem(item);
|
||||||
plugin.pl.save(playerData);
|
plugin.pl.save(playerData);
|
||||||
msg("Successfully gave the " + item.getName() + " to " + args[3], ChatColor.GREEN);
|
msg("Successfully gave the " + item.getName() + " to " + args[3], ChatColor.GREEN);
|
||||||
Player player = getPlayer(args[3]);
|
Player player = getPlayer(args[3]);
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave the " + item.getName() + " to you");
|
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave the " + item.getName() + " to you");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (args[1].equals("take"))
|
else if (args[1].equals("take"))
|
||||||
{
|
{
|
||||||
ShopItem item = ShopItem.findItem(args[2].toUpperCase());
|
ShopItem item = ShopItem.findItem(args[2].toUpperCase());
|
||||||
if (item == null)
|
if (item == null)
|
||||||
{
|
{
|
||||||
msg(args[2] + " is not a valid item.", ChatColor.RED);
|
msg(args[2] + " is not a valid item.", ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerData playerData = plugin.pl.getData(args[3]);
|
PlayerData playerData = plugin.pl.getData(args[3]);
|
||||||
if (playerData == null)
|
if (playerData == null)
|
||||||
{
|
{
|
||||||
msg(PLAYER_NOT_FOUND);
|
msg(PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
playerData.removeItem(item);
|
playerData.removeItem(item);
|
||||||
plugin.pl.save(playerData);
|
plugin.pl.save(playerData);
|
||||||
msg("Successfully took the " + item.getName() + " from " + args[3], ChatColor.GREEN);
|
msg("Successfully took the " + item.getName() + " from " + args[3], ChatColor.GREEN);
|
||||||
Player player = getPlayer(args[3]);
|
Player player = getPlayer(args[3]);
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED + sender.getName() + " took the " + item.getName() + " from you");
|
player.sendMessage(ChatColor.RED + sender.getName() + " took the " + item.getName() + " from you");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,23 +1,23 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.History;
|
import me.totalfreedom.totalfreedommod.util.History;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Check the name history of a specified player.", usage = "/<command> <username>", aliases = "nh")
|
@CommandParameters(description = "Check the name history of a specified player.", usage = "/<command> <username>", aliases = "nh")
|
||||||
public class Command_namehistory extends FreedomCommand
|
public class Command_namehistory extends FreedomCommand
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (args.length != 1)
|
if (args.length != 1)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
History.reportHistory(sender, args[0]);
|
History.reportHistory(sender, args[0]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,62 +1,62 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Sends a guardian particle effect with an enderman scream to the specified player.", usage = "/<command> <player>")
|
@CommandParameters(description = "Sends a guardian particle effect with an enderman scream to the specified player.", usage = "/<command> <player>")
|
||||||
public class Command_scare extends FreedomCommand
|
public class Command_scare extends FreedomCommand
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (!FUtil.isPaper())
|
if (!FUtil.isPaper())
|
||||||
{
|
{
|
||||||
msg("This command won't work without Paper!", ChatColor.RED);
|
msg("This command won't work without Paper!", ChatColor.RED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Player player = getPlayer(args[0]);
|
final Player player = getPlayer(args[0]);
|
||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("Scared " + player.getName());
|
msg("Scared " + player.getName());
|
||||||
player.sendMessage(ChatColor.RED + "ZING");
|
player.sendMessage(ChatColor.RED + "ZING");
|
||||||
|
|
||||||
player.spawnParticle(Particle.MOB_APPEARANCE, player.getLocation(), 4);
|
player.spawnParticle(Particle.MOB_APPEARANCE, player.getLocation(), 4);
|
||||||
for (int i = 0; i < 10; ++i)
|
for (int i = 0; i < 10; ++i)
|
||||||
{
|
{
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_SCREAM, 1, 0);
|
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_SCREAM, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
{
|
{
|
||||||
if (args.length == 1 && plugin.al.isAdmin(sender))
|
if (args.length == 1 && plugin.al.isAdmin(sender))
|
||||||
{
|
{
|
||||||
return FUtil.getPlayerList();
|
return FUtil.getPlayerList();
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Check the status of the server, including opped players, admins, etc.", usage = "/<command>", aliases = "ss")
|
@CommandParameters(description = "Check the status of the server, including opped players, admins, etc.", usage = "/<command>", aliases = "ss")
|
||||||
public class Command_serverstats extends FreedomCommand
|
public class Command_serverstats extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
msg("-==" + ConfigEntry.SERVER_NAME.getString() + " server stats==-", ChatColor.GOLD);
|
msg("-==" + ConfigEntry.SERVER_NAME.getString() + " server stats==-", ChatColor.GOLD);
|
||||||
msg("Total opped players: " + server.getOperators().size(), ChatColor.RED);
|
msg("Total opped players: " + server.getOperators().size(), ChatColor.RED);
|
||||||
msg("Total admins: " + plugin.al.getAllAdmins().size() + " (" + plugin.al.getActiveAdmins().size() + " active)", ChatColor.BLUE);
|
msg("Total admins: " + plugin.al.getAllAdmins().size() + " (" + plugin.al.getActiveAdmins().size() + " active)", ChatColor.BLUE);
|
||||||
int bans = plugin.im.getIndefBans().size();
|
int bans = plugin.im.getIndefBans().size();
|
||||||
int nameBans = plugin.im.getNameBanCount();
|
int nameBans = plugin.im.getNameBanCount();
|
||||||
int uuidBans = plugin.im.getUuidBanCount();
|
int uuidBans = plugin.im.getUuidBanCount();
|
||||||
int ipBans = plugin.im.getIpBanCount();
|
int ipBans = plugin.im.getIpBanCount();
|
||||||
msg("Total indefinite ban entries: " + bans + " (" + nameBans + " name bans, " + uuidBans + " UUID bans, and " + ipBans + " IP bans)", ChatColor.GREEN);
|
msg("Total indefinite ban entries: " + bans + " (" + nameBans + " name bans, " + uuidBans + " UUID bans, and " + ipBans + " IP bans)", ChatColor.GREEN);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = 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
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean enabled = plugin.lp.CLOWNFISH_TOGGLE.contains(args[0]);
|
||||||
|
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
plugin.lp.CLOWNFISH_TOGGLE.remove(args[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
plugin.lp.CLOWNFISH_TOGGLE.add(args[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg(args[0] + " will " + (enabled ? "now" : "no longer") + " have the ability to use clownfish.");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -1,34 +1,34 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Information on how to vote", usage = "/<command>")
|
@CommandParameters(description = "Information on how to vote", usage = "/<command>")
|
||||||
public class Command_vote extends FreedomCommand
|
public class Command_vote extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
List<String> voteInfo = ConfigEntry.VOTING_INFO.getStringList();
|
List<String> voteInfo = ConfigEntry.VOTING_INFO.getStringList();
|
||||||
|
|
||||||
if (voteInfo.isEmpty())
|
if (voteInfo.isEmpty())
|
||||||
{
|
{
|
||||||
msg("The voting information section of the config.yml file has not been configured.", ChatColor.RED);
|
msg("The voting information section of the config.yml file has not been configured.", ChatColor.RED);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg(FUtil.colorize(StringUtils.join(voteInfo, "\n")));
|
msg(FUtil.colorize(StringUtils.join(voteInfo, "\n")));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,7 @@ public enum ConfigEntry
|
|||||||
SERVER_LOGIN_SUBTITLE(String.class, "server.login_title.subtitle"),
|
SERVER_LOGIN_SUBTITLE(String.class, "server.login_title.subtitle"),
|
||||||
SERVER_OWNERS(List.class, "server.owners"),
|
SERVER_OWNERS(List.class, "server.owners"),
|
||||||
SERVER_EXECUTIVES(List.class, "server.executives"),
|
SERVER_EXECUTIVES(List.class, "server.executives"),
|
||||||
|
SERVER_ASSTISTANT_EXECUTIVES(List.class, "server.assistant_executives"),
|
||||||
SERVER_MASTER_BUILDER_MANAGEMENT(List.class, "server.master_builder_management"),
|
SERVER_MASTER_BUILDER_MANAGEMENT(List.class, "server.master_builder_management"),
|
||||||
SERVER_BAN_URL(String.class, "server.ban_url"),
|
SERVER_BAN_URL(String.class, "server.ban_url"),
|
||||||
SERVER_INDEFBAN_URL(String.class, "server.indefban_url"),
|
SERVER_INDEFBAN_URL(String.class, "server.indefban_url"),
|
||||||
|
@ -402,6 +402,11 @@ public class Discord extends FreedomService
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (message.contains("§"))
|
||||||
|
{
|
||||||
|
message = StringUtils.remove(message, "§");
|
||||||
|
}
|
||||||
|
|
||||||
if (enabled && !chat_channel_id.isEmpty())
|
if (enabled && !chat_channel_id.isEmpty())
|
||||||
{
|
{
|
||||||
@ -422,6 +427,11 @@ public class Discord extends FreedomService
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (message.contains("§"))
|
||||||
|
{
|
||||||
|
message = StringUtils.remove(message, "§");
|
||||||
|
}
|
||||||
|
|
||||||
if (enabled && !chat_channel_id.isEmpty())
|
if (enabled && !chat_channel_id.isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -247,6 +247,12 @@ public class ItemFun extends FreedomService
|
|||||||
{
|
{
|
||||||
final int RADIUS_HIT = 5;
|
final int RADIUS_HIT = 5;
|
||||||
final int STRENGTH = 4;
|
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.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.CLOWN_FISH, player.getInventory(), plugin.sh.getClownFish()))
|
if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.CLOWN_FISH, player.getInventory(), plugin.sh.getClownFish()))
|
||||||
{
|
{
|
||||||
|
@ -8,8 +8,9 @@ public enum Title implements Displayable
|
|||||||
MASTER_BUILDER("a", "Master Builder", ChatColor.DARK_AQUA, org.bukkit.ChatColor.DARK_AQUA, "MB", true, true),
|
MASTER_BUILDER("a", "Master Builder", ChatColor.DARK_AQUA, org.bukkit.ChatColor.DARK_AQUA, "MB", true, true),
|
||||||
VERIFIED_ADMIN("a", "Verified Admin", ChatColor.LIGHT_PURPLE, org.bukkit.ChatColor.LIGHT_PURPLE, "VA", false, true),
|
VERIFIED_ADMIN("a", "Verified Admin", ChatColor.LIGHT_PURPLE, org.bukkit.ChatColor.LIGHT_PURPLE, "VA", false, true),
|
||||||
EXECUTIVE("an", "Executive", ChatColor.RED, org.bukkit.ChatColor.RED, "Exec", true, true),
|
EXECUTIVE("an", "Executive", ChatColor.RED, org.bukkit.ChatColor.RED, "Exec", true, true),
|
||||||
|
ASSTEXEC("an", "Assistant Executive", ChatColor.RED, org.bukkit.ChatColor.RED, "Asst Exec", true, true),
|
||||||
DEVELOPER("a", "Developer", ChatColor.DARK_PURPLE, org.bukkit.ChatColor.DARK_PURPLE, "Dev", true, true),
|
DEVELOPER("a", "Developer", ChatColor.DARK_PURPLE, org.bukkit.ChatColor.DARK_PURPLE, "Dev", true, true),
|
||||||
OWNER("the", "Owner", ChatColor.of("#ff0000"), org.bukkit.ChatColor.DARK_RED, "Owner", true, true);
|
OWNER("the", "Owner", ChatColor.DARK_RED, org.bukkit.ChatColor.DARK_RED, "Owner", true, true);
|
||||||
|
|
||||||
|
|
||||||
private final String article;
|
private final String article;
|
||||||
|
@ -1,425 +1,425 @@
|
|||||||
package me.totalfreedom.totalfreedommod.shop;
|
package me.totalfreedom.totalfreedommod.shop;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.boss.BarColor;
|
import org.bukkit.boss.BarColor;
|
||||||
import org.bukkit.boss.BarStyle;
|
import org.bukkit.boss.BarStyle;
|
||||||
import org.bukkit.boss.BossBar;
|
import org.bukkit.boss.BossBar;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
public class Shop extends FreedomService
|
public class Shop extends FreedomService
|
||||||
{
|
{
|
||||||
public final int coinsPerReactionWin = ConfigEntry.SHOP_REACTIONS_COINS_PER_WIN.getInteger();
|
public final int coinsPerReactionWin = ConfigEntry.SHOP_REACTIONS_COINS_PER_WIN.getInteger();
|
||||||
public final String prefix = ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + "Reaction" + ChatColor.DARK_GRAY + "] ";
|
public final String prefix = ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + "Reaction" + ChatColor.DARK_GRAY + "] ";
|
||||||
private final String LOGIN_MESSAGE_GUI_TITLE = ChatColor.DARK_GREEN + ChatColor.BOLD.toString() + "Login Messages";
|
private final String LOGIN_MESSAGE_GUI_TITLE = ChatColor.DARK_GREEN + ChatColor.BOLD.toString() + "Login Messages";
|
||||||
public String reactionString = "";
|
public String reactionString = "";
|
||||||
public Date reactionStartTime;
|
public Date reactionStartTime;
|
||||||
public BukkitTask countdownTask;
|
public BukkitTask countdownTask;
|
||||||
private BukkitTask reactions;
|
private BukkitTask reactions;
|
||||||
private BossBar countdownBar = null;
|
private BossBar countdownBar = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
if (ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean())
|
if (ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean())
|
||||||
{
|
{
|
||||||
startReactionTimer();
|
startReactionTimer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startReactionTimer()
|
public void startReactionTimer()
|
||||||
{
|
{
|
||||||
long interval = ConfigEntry.SHOP_REACTIONS_INTERVAL.getInteger() * 20L;
|
long interval = ConfigEntry.SHOP_REACTIONS_INTERVAL.getInteger() * 20L;
|
||||||
|
|
||||||
reactions = new BukkitRunnable()
|
reactions = new BukkitRunnable()
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
startReaction();
|
startReaction();
|
||||||
}
|
}
|
||||||
}.runTaskLater(plugin, interval);
|
}.runTaskLater(plugin, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forceStartReaction()
|
public void forceStartReaction()
|
||||||
{
|
{
|
||||||
reactions.cancel();
|
reactions.cancel();
|
||||||
startReaction();
|
startReaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startReaction()
|
public void startReaction()
|
||||||
{
|
{
|
||||||
if (!ConfigEntry.SHOP_ENABLED.getBoolean())
|
if (!ConfigEntry.SHOP_ENABLED.getBoolean())
|
||||||
{
|
{
|
||||||
FLog.debug("The shop is not enabled, therefore a reaction did not start.");
|
FLog.debug("The shop is not enabled, therefore a reaction did not start.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
reactionString = FUtil.randomAlphanumericString(ConfigEntry.SHOP_REACTIONS_STRING_LENGTH.getInteger());
|
reactionString = FUtil.randomAlphanumericString(ConfigEntry.SHOP_REACTIONS_STRING_LENGTH.getInteger());
|
||||||
|
|
||||||
FUtil.bcastMsg(prefix + ChatColor.AQUA + "Enter the code above to win " + ChatColor.GOLD + coinsPerReactionWin + ChatColor.AQUA + " coins!", false);
|
FUtil.bcastMsg(prefix + ChatColor.AQUA + "Enter the code above to win " + ChatColor.GOLD + coinsPerReactionWin + ChatColor.AQUA + " coins!", false);
|
||||||
|
|
||||||
reactionStartTime = new Date();
|
reactionStartTime = new Date();
|
||||||
|
|
||||||
countdownBar = server.createBossBar(reactionString, BarColor.GREEN, BarStyle.SOLID);
|
countdownBar = server.createBossBar(reactionString, BarColor.GREEN, BarStyle.SOLID);
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
countdownBar.addPlayer(player);
|
countdownBar.addPlayer(player);
|
||||||
}
|
}
|
||||||
countdownBar.setVisible(true);
|
countdownBar.setVisible(true);
|
||||||
countdownTask = new BukkitRunnable()
|
countdownTask = new BukkitRunnable()
|
||||||
{
|
{
|
||||||
double seconds = 30;
|
double seconds = 30;
|
||||||
final double max = seconds;
|
final double max = seconds;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if ((seconds -= 1) == 0)
|
if ((seconds -= 1) == 0)
|
||||||
{
|
{
|
||||||
endReaction(null);
|
endReaction(null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
countdownBar.setProgress(seconds / max);
|
countdownBar.setProgress(seconds / max);
|
||||||
if (!countdownBar.getColor().equals(BarColor.YELLOW) && seconds / max <= 0.25)
|
if (!countdownBar.getColor().equals(BarColor.YELLOW) && seconds / max <= 0.25)
|
||||||
{
|
{
|
||||||
countdownBar.setColor(BarColor.YELLOW);
|
countdownBar.setColor(BarColor.YELLOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskTimer(plugin, 0, 20);
|
}.runTaskTimer(plugin, 0, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endReaction(String winner)
|
public void endReaction(String winner)
|
||||||
{
|
{
|
||||||
countdownTask.cancel();
|
countdownTask.cancel();
|
||||||
countdownBar.removeAll();
|
countdownBar.removeAll();
|
||||||
countdownBar = null;
|
countdownBar = null;
|
||||||
reactionString = "";
|
reactionString = "";
|
||||||
|
|
||||||
if (winner != null)
|
if (winner != null)
|
||||||
{
|
{
|
||||||
Date currentTime = new Date();
|
Date currentTime = new Date();
|
||||||
long seconds = (currentTime.getTime() - reactionStartTime.getTime()) / 1000;
|
long seconds = (currentTime.getTime() - reactionStartTime.getTime()) / 1000;
|
||||||
FUtil.bcastMsg(prefix + ChatColor.GREEN + winner + ChatColor.AQUA + " won in " + seconds + " seconds!", false);
|
FUtil.bcastMsg(prefix + ChatColor.GREEN + winner + ChatColor.AQUA + " won in " + seconds + " seconds!", false);
|
||||||
startReactionTimer();
|
startReactionTimer();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.bcastMsg(prefix + ChatColor.RED + "No one reacted fast enough", false);
|
FUtil.bcastMsg(prefix + ChatColor.RED + "No one reacted fast enough", false);
|
||||||
startReactionTimer();
|
startReactionTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
if (ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean())
|
if (ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean())
|
||||||
{
|
{
|
||||||
reactions.cancel();
|
reactions.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getShopPrefix()
|
public String getShopPrefix()
|
||||||
{
|
{
|
||||||
return FUtil.colorize(ConfigEntry.SHOP_PREFIX.getString());
|
return FUtil.colorize(ConfigEntry.SHOP_PREFIX.getString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getShopTitle()
|
public String getShopTitle()
|
||||||
{
|
{
|
||||||
return FUtil.colorize(ConfigEntry.SHOP_TITLE.getString());
|
return FUtil.colorize(ConfigEntry.SHOP_TITLE.getString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Inventory generateShopGUI(PlayerData playerData)
|
public Inventory generateShopGUI(PlayerData playerData)
|
||||||
{
|
{
|
||||||
Inventory gui = server.createInventory(null, 36, getShopTitle());
|
Inventory gui = server.createInventory(null, 36, getShopTitle());
|
||||||
for (int slot = 0; slot < 36; slot++)
|
for (int slot = 0; slot < 36; slot++)
|
||||||
{
|
{
|
||||||
ItemStack blank = new ItemStack(Material.WHITE_STAINED_GLASS_PANE);
|
ItemStack blank = new ItemStack(Material.WHITE_STAINED_GLASS_PANE);
|
||||||
ItemMeta meta = blank.getItemMeta();
|
ItemMeta meta = blank.getItemMeta();
|
||||||
assert meta != null;
|
assert meta != null;
|
||||||
meta.setDisplayName(" ");
|
meta.setDisplayName(" ");
|
||||||
blank.setItemMeta(meta);
|
blank.setItemMeta(meta);
|
||||||
gui.setItem(slot, blank);
|
gui.setItem(slot, blank);
|
||||||
}
|
}
|
||||||
for (ShopItem shopItem : ShopItem.values())
|
for (ShopItem shopItem : ShopItem.values())
|
||||||
{
|
{
|
||||||
ItemStack item = shopGUIItem(shopItem, playerData);
|
ItemStack item = shopGUIItem(shopItem, playerData);
|
||||||
gui.setItem(shopItem.getSlot(), item);
|
gui.setItem(shopItem.getSlot(), item);
|
||||||
}
|
}
|
||||||
// Coins
|
// Coins
|
||||||
ItemStack coins = new ItemStack(Material.GOLD_NUGGET);
|
ItemStack coins = new ItemStack(Material.GOLD_NUGGET);
|
||||||
ItemMeta meta = coins.getItemMeta();
|
ItemMeta meta = coins.getItemMeta();
|
||||||
assert meta != null;
|
assert meta != null;
|
||||||
meta.setDisplayName(FUtil.colorize("&c&lYou have &e&l" + playerData.getCoins() + "&c&l coins"));
|
meta.setDisplayName(FUtil.colorize("&c&lYou have &e&l" + playerData.getCoins() + "&c&l coins"));
|
||||||
coins.setItemMeta(meta);
|
coins.setItemMeta(meta);
|
||||||
gui.setItem(35, coins);
|
gui.setItem(35, coins);
|
||||||
return gui;
|
return gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Inventory generateLoginMessageGUI(Player player)
|
public Inventory generateLoginMessageGUI(Player player)
|
||||||
{
|
{
|
||||||
Inventory gui = server.createInventory(null, 36, LOGIN_MESSAGE_GUI_TITLE);
|
Inventory gui = server.createInventory(null, 36, LOGIN_MESSAGE_GUI_TITLE);
|
||||||
int slot = 0;
|
int slot = 0;
|
||||||
for (String loginMessage : ConfigEntry.SHOP_LOGIN_MESSAGES.getStringList())
|
for (String loginMessage : ConfigEntry.SHOP_LOGIN_MESSAGES.getStringList())
|
||||||
{
|
{
|
||||||
ItemStack icon = new ItemStack(Material.NAME_TAG);
|
ItemStack icon = new ItemStack(Material.NAME_TAG);
|
||||||
ItemMeta meta = icon.getItemMeta();
|
ItemMeta meta = icon.getItemMeta();
|
||||||
assert meta != null;
|
assert meta != null;
|
||||||
meta.setDisplayName(FUtil.colorize(plugin.rm.craftLoginMessage(player, loginMessage)));
|
meta.setDisplayName(FUtil.colorize(plugin.rm.craftLoginMessage(player, loginMessage)));
|
||||||
icon.setItemMeta(meta);
|
icon.setItemMeta(meta);
|
||||||
gui.setItem(slot, icon);
|
gui.setItem(slot, icon);
|
||||||
slot++;
|
slot++;
|
||||||
}
|
}
|
||||||
ItemStack clear = new ItemStack(Material.BARRIER);
|
ItemStack clear = new ItemStack(Material.BARRIER);
|
||||||
ItemMeta meta = clear.getItemMeta();
|
ItemMeta meta = clear.getItemMeta();
|
||||||
assert meta != null;
|
assert meta != null;
|
||||||
meta.setDisplayName(ChatColor.RED + "Clear login message");
|
meta.setDisplayName(ChatColor.RED + "Clear login message");
|
||||||
clear.setItemMeta(meta);
|
clear.setItemMeta(meta);
|
||||||
gui.setItem(35, clear);
|
gui.setItem(35, clear);
|
||||||
return gui;
|
return gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRealItem(PlayerData data, ShopItem shopItem, PlayerInventory inventory, ItemStack realItem)
|
public boolean isRealItem(PlayerData data, ShopItem shopItem, PlayerInventory inventory, ItemStack realItem)
|
||||||
{
|
{
|
||||||
return isRealItem(data, shopItem, inventory.getItemInMainHand(), realItem) || isRealItem(data, shopItem, inventory.getItemInOffHand(), realItem);
|
return isRealItem(data, shopItem, inventory.getItemInMainHand(), realItem) || isRealItem(data, shopItem, inventory.getItemInOffHand(), realItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRealItem(PlayerData data, ShopItem shopItem, ItemStack givenItem, ItemStack realItem)
|
public boolean isRealItem(PlayerData data, ShopItem shopItem, ItemStack givenItem, ItemStack realItem)
|
||||||
{
|
{
|
||||||
if (!data.hasItem(shopItem) || !givenItem.getType().equals(realItem.getType()))
|
if (!data.hasItem(shopItem) || !givenItem.getType().equals(realItem.getType()))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemMeta givenMeta = givenItem.getItemMeta();
|
ItemMeta givenMeta = givenItem.getItemMeta();
|
||||||
ItemMeta realMeta = realItem.getItemMeta();
|
ItemMeta realMeta = realItem.getItemMeta();
|
||||||
|
|
||||||
assert givenMeta != null;
|
assert givenMeta != null;
|
||||||
assert realMeta != null;
|
assert realMeta != null;
|
||||||
return givenMeta.getDisplayName().equals(realMeta.getDisplayName()) && Objects.equals(givenMeta.getLore(), realMeta.getLore());
|
return givenMeta.getDisplayName().equals(realMeta.getDisplayName()) && Objects.equals(givenMeta.getLore(), realMeta.getLore());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getLightningRod()
|
public ItemStack getLightningRod()
|
||||||
{
|
{
|
||||||
ItemStack itemStack = new ItemStack(Material.BLAZE_ROD);
|
ItemStack itemStack = new ItemStack(Material.BLAZE_ROD);
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
assert itemMeta != null;
|
assert itemMeta != null;
|
||||||
itemMeta.setDisplayName(FUtil.colorize("&bL&3i&bg&3h&bt&3i&bn&3g &b&bR&3o&bd"));
|
itemMeta.setDisplayName(FUtil.colorize("&bL&3i&bg&3h&bt&3i&bn&3g &b&bR&3o&bd"));
|
||||||
itemMeta.setLore(Arrays.asList(ChatColor.AQUA + "Strike others down with the power of lightning.", ChatColor.RED + ChatColor.ITALIC.toString() + "The classic way to exterminate annoyances."));
|
itemMeta.setLore(Arrays.asList(ChatColor.AQUA + "Strike others down with the power of lightning.", ChatColor.RED + ChatColor.ITALIC.toString() + "The classic way to exterminate annoyances."));
|
||||||
itemMeta.addEnchant(Enchantment.CHANNELING, 1, false);
|
itemMeta.addEnchant(Enchantment.CHANNELING, 1, false);
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getGrapplingHook()
|
public ItemStack getGrapplingHook()
|
||||||
{
|
{
|
||||||
ItemStack itemStack = new ItemStack(Material.FISHING_ROD);
|
ItemStack itemStack = new ItemStack(Material.FISHING_ROD);
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
assert itemMeta != null;
|
assert itemMeta != null;
|
||||||
itemMeta.setDisplayName(ChatColor.YELLOW + "Grappling Hook");
|
itemMeta.setDisplayName(ChatColor.YELLOW + "Grappling Hook");
|
||||||
itemMeta.setLore(Collections.singletonList(ChatColor.GREEN + "be spider-man but ghetto"));
|
itemMeta.setLore(Collections.singletonList(ChatColor.GREEN + "be spider-man but ghetto"));
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getFireBall()
|
public ItemStack getFireBall()
|
||||||
{
|
{
|
||||||
ItemStack itemStack = new ItemStack(Material.FIRE_CHARGE);
|
ItemStack itemStack = new ItemStack(Material.FIRE_CHARGE);
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
assert itemMeta != null;
|
assert itemMeta != null;
|
||||||
itemMeta.setDisplayName(ChatColor.RED + "Fire Ball");
|
itemMeta.setDisplayName(ChatColor.RED + "Fire Ball");
|
||||||
itemMeta.setLore(Collections.singletonList(ChatColor.GOLD + "Yeet this at people"));
|
itemMeta.setLore(Collections.singletonList(ChatColor.GOLD + "Yeet this at people"));
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getRideablePearl()
|
public ItemStack getRideablePearl()
|
||||||
{
|
{
|
||||||
ItemStack itemStack = new ItemStack(Material.ENDER_PEARL);
|
ItemStack itemStack = new ItemStack(Material.ENDER_PEARL);
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
assert itemMeta != null;
|
assert itemMeta != null;
|
||||||
itemMeta.setDisplayName(ChatColor.DARK_PURPLE + "Rideable Ender Pearl");
|
itemMeta.setDisplayName(ChatColor.DARK_PURPLE + "Rideable Ender Pearl");
|
||||||
itemMeta.setLore(Arrays.asList(ChatColor.LIGHT_PURPLE + "What the title says.", "", ChatColor.WHITE + ChatColor.ITALIC.toString() + "TotalFreedom is not responsible for any injuries", ChatColor.WHITE + ChatColor.ITALIC.toString() + "sustained while using this item."));
|
itemMeta.setLore(Arrays.asList(ChatColor.LIGHT_PURPLE + "What the title says.", "", ChatColor.WHITE + ChatColor.ITALIC.toString() + "TotalFreedom is not responsible for any injuries", ChatColor.WHITE + ChatColor.ITALIC.toString() + "sustained while using this item."));
|
||||||
itemMeta.addEnchant(Enchantment.BINDING_CURSE, 1, false);
|
itemMeta.addEnchant(Enchantment.BINDING_CURSE, 1, false);
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getStackingPotato()
|
public ItemStack getStackingPotato()
|
||||||
{
|
{
|
||||||
ItemStack itemStack = new ItemStack(Material.POTATO);
|
ItemStack itemStack = new ItemStack(Material.POTATO);
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
assert itemMeta != null;
|
assert itemMeta != null;
|
||||||
itemMeta.setDisplayName(ChatColor.YELLOW + "Stacking Potato");
|
itemMeta.setDisplayName(ChatColor.YELLOW + "Stacking Potato");
|
||||||
itemMeta.setLore(Collections.singletonList(ChatColor.GREEN + "Left click to ride a mob, right click to put a mob on your head."));
|
itemMeta.setLore(Collections.singletonList(ChatColor.GREEN + "Left click to ride a mob, right click to put a mob on your head."));
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getClownFish()
|
public ItemStack getClownFish()
|
||||||
{
|
{
|
||||||
ItemStack itemStack = new ItemStack(Material.TROPICAL_FISH);
|
ItemStack itemStack = new ItemStack(Material.TROPICAL_FISH);
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
assert itemMeta != null;
|
assert itemMeta != null;
|
||||||
itemMeta.setDisplayName(ChatColor.GOLD + "Clown Fish");
|
itemMeta.setDisplayName(ChatColor.GOLD + "Clown Fish");
|
||||||
itemMeta.setLore(Collections.singletonList(ChatColor.AQUA + ":clown:"));
|
itemMeta.setLore(Collections.singletonList(ChatColor.AQUA + ":clown:"));
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canAfford(int price, int coins)
|
public boolean canAfford(int price, int coins)
|
||||||
{
|
{
|
||||||
return coins >= price;
|
return coins >= price;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int amountNeeded(int price, int coins)
|
public int amountNeeded(int price, int coins)
|
||||||
{
|
{
|
||||||
return price - coins;
|
return price - coins;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack shopGUIItem(ShopItem item, PlayerData data)
|
public ItemStack shopGUIItem(ShopItem item, PlayerData data)
|
||||||
{
|
{
|
||||||
ItemStack itemStack = new ItemStack(item.getIcon());
|
ItemStack itemStack = new ItemStack(item.getIcon());
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
assert itemMeta != null;
|
assert itemMeta != null;
|
||||||
itemMeta.setDisplayName(item.getColoredName());
|
itemMeta.setDisplayName(item.getColoredName());
|
||||||
int price = item.getCost();
|
int price = item.getCost();
|
||||||
int coins = data.getCoins();
|
int coins = data.getCoins();
|
||||||
boolean canAfford = canAfford(price, coins);
|
boolean canAfford = canAfford(price, coins);
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
if (!data.hasItem(item))
|
if (!data.hasItem(item))
|
||||||
{
|
{
|
||||||
lore.add(ChatColor.GOLD + "Price: " + (canAfford ? ChatColor.DARK_GREEN : ChatColor.RED) + price);
|
lore.add(ChatColor.GOLD + "Price: " + (canAfford ? ChatColor.DARK_GREEN : ChatColor.RED) + price);
|
||||||
if (!canAfford)
|
if (!canAfford)
|
||||||
{
|
{
|
||||||
lore.add(ChatColor.RED + "You can not afford this item!");
|
lore.add(ChatColor.RED + "You can not afford this item!");
|
||||||
lore.add(ChatColor.RED + "You need " + amountNeeded(price, coins) + " more coins to buy this item.");
|
lore.add(ChatColor.RED + "You need " + amountNeeded(price, coins) + " more coins to buy this item.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lore.add(ChatColor.RED + "You already purchased this item.");
|
lore.add(ChatColor.RED + "You already purchased this item.");
|
||||||
}
|
}
|
||||||
itemMeta.setLore(lore);
|
itemMeta.setLore(lore);
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onShopGUIClick(InventoryClickEvent event)
|
public void onShopGUIClick(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
if (!(event.getWhoClicked() instanceof Player))
|
if (!(event.getWhoClicked() instanceof Player))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Inventory inventory = event.getInventory();
|
Inventory inventory = event.getInventory();
|
||||||
if (inventory.getSize() != 36 || !event.getView().getTitle().equals(getShopTitle()))
|
if (inventory.getSize() != 36 || !event.getView().getTitle().equals(getShopTitle()))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
ShopItem shopItem = getShopItem(event.getSlot());
|
ShopItem shopItem = getShopItem(event.getSlot());
|
||||||
if (shopItem == null)
|
if (shopItem == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player)event.getWhoClicked();
|
Player player = (Player)event.getWhoClicked();
|
||||||
PlayerData playerData = plugin.pl.getData(player);
|
PlayerData playerData = plugin.pl.getData(player);
|
||||||
int price = shopItem.getCost();
|
int price = shopItem.getCost();
|
||||||
int coins = playerData.getCoins();
|
int coins = playerData.getCoins();
|
||||||
|
|
||||||
if (playerData.hasItem(shopItem) || !canAfford(price, coins))
|
if (playerData.hasItem(shopItem) || !canAfford(price, coins))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
playerData.giveItem(shopItem);
|
playerData.giveItem(shopItem);
|
||||||
playerData.setCoins(coins - price);
|
playerData.setCoins(coins - price);
|
||||||
plugin.pl.save(playerData);
|
plugin.pl.save(playerData);
|
||||||
|
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
|
|
||||||
player.sendMessage(getShopPrefix() + " " + ChatColor.GREEN + "Successfully purchased the \"" + shopItem.getColoredName() + ChatColor.GREEN + "\" for " + ChatColor.GOLD + price + ChatColor.GREEN + "!");
|
player.sendMessage(getShopPrefix() + " " + ChatColor.GREEN + "Successfully purchased the \"" + shopItem.getColoredName() + ChatColor.GREEN + "\" for " + ChatColor.GOLD + price + ChatColor.GREEN + "!");
|
||||||
|
|
||||||
if (shopItem.getCommand() != null)
|
if (shopItem.getCommand() != null)
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.GREEN + "Run " + shopItem.getCommand() + " to get one!");
|
player.sendMessage(ChatColor.GREEN + "Run " + shopItem.getCommand() + " to get one!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onLoginMessageGUIClick(InventoryClickEvent event)
|
public void onLoginMessageGUIClick(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
if (!(event.getWhoClicked() instanceof Player))
|
if (!(event.getWhoClicked() instanceof Player))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Inventory inventory = event.getInventory();
|
Inventory inventory = event.getInventory();
|
||||||
if (inventory.getSize() != 36 || !event.getView().getTitle().equals(LOGIN_MESSAGE_GUI_TITLE))
|
if (inventory.getSize() != 36 || !event.getView().getTitle().equals(LOGIN_MESSAGE_GUI_TITLE))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
int slot = event.getSlot();
|
int slot = event.getSlot();
|
||||||
|
|
||||||
Player player = (Player)event.getWhoClicked();
|
Player player = (Player)event.getWhoClicked();
|
||||||
PlayerData data = plugin.pl.getData(player);
|
PlayerData data = plugin.pl.getData(player);
|
||||||
|
|
||||||
if (slot == 35)
|
if (slot == 35)
|
||||||
{
|
{
|
||||||
data.setLoginMessage(null);
|
data.setLoginMessage(null);
|
||||||
plugin.pl.save(data);
|
plugin.pl.save(data);
|
||||||
player.sendMessage(ChatColor.GREEN + "Removed your login message");
|
player.sendMessage(ChatColor.GREEN + "Removed your login message");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String message = ConfigEntry.SHOP_LOGIN_MESSAGES.getStringList().get(slot);
|
String message = ConfigEntry.SHOP_LOGIN_MESSAGES.getStringList().get(slot);
|
||||||
data.setLoginMessage(message);
|
data.setLoginMessage(message);
|
||||||
plugin.pl.save(data);
|
plugin.pl.save(data);
|
||||||
player.sendMessage(ChatColor.GREEN + "Your login message is now the following:\n" + plugin.rm.craftLoginMessage(player, message));
|
player.sendMessage(ChatColor.GREEN + "Your login message is now the following:\n" + plugin.rm.craftLoginMessage(player, message));
|
||||||
}
|
}
|
||||||
|
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShopItem getShopItem(int slot)
|
public ShopItem getShopItem(int slot)
|
||||||
{
|
{
|
||||||
for (ShopItem shopItem : ShopItem.values())
|
for (ShopItem shopItem : ShopItem.values())
|
||||||
{
|
{
|
||||||
if (shopItem.getSlot() == slot)
|
if (shopItem.getSlot() == slot)
|
||||||
{
|
{
|
||||||
return shopItem;
|
return shopItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -136,7 +136,7 @@ public class FUtil
|
|||||||
|
|
||||||
public static boolean isExecutive(String name)
|
public static boolean isExecutive(String name)
|
||||||
{
|
{
|
||||||
return ConfigEntry.SERVER_OWNERS.getStringList().contains(name) || ConfigEntry.SERVER_EXECUTIVES.getStringList().contains(name);
|
return ConfigEntry.SERVER_OWNERS.getStringList().contains(name) || ConfigEntry.SERVER_EXECUTIVES.getStringList().contains(name) || ConfigEntry.SERVER_ASSTISTANT_EXECUTIVES.getStringList().contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isDeveloper(Player player)
|
public static boolean isDeveloper(Player player)
|
||||||
|
@ -1,114 +1,114 @@
|
|||||||
package me.totalfreedom.totalfreedommod.util;
|
package me.totalfreedom.totalfreedommod.util;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
public class History
|
public class History
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
public static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
public static void reportHistory(final CommandSender sender, final String username)
|
public static void reportHistory(final CommandSender sender, final String username)
|
||||||
{
|
{
|
||||||
new BukkitRunnable()
|
new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
UUID uuid = UUIDFetcher.fetch(username);
|
UUID uuid = UUIDFetcher.fetch(username);
|
||||||
if (uuid != null)
|
if (uuid != null)
|
||||||
{
|
{
|
||||||
Gson gson = new GsonBuilder().create();
|
Gson gson = new GsonBuilder().create();
|
||||||
String compactUuid = uuid.toString().replace("-", "");
|
String compactUuid = uuid.toString().replace("-", "");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//UUIDs or playernames actually work with this one
|
//UUIDs or playernames actually work with this one
|
||||||
//TODO: fix the stupid api on how it's not working name histories
|
//TODO: fix the stupid api on how it's not working name histories
|
||||||
//URL url = new URL("https://api.ashcon.app/mojang/v2/user/" + compactUuid);
|
//URL url = new URL("https://api.ashcon.app/mojang/v2/user/" + compactUuid);
|
||||||
URL url = new URL("https://api.mojang.com/user/profiles/" + compactUuid + "/names");
|
URL url = new URL("https://api.mojang.com/user/profiles/" + compactUuid + "/names");
|
||||||
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
|
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
|
||||||
//conn.setRequestProperty("User-Agent", "");
|
//conn.setRequestProperty("User-Agent", "");
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||||
FName[] oldNames = gson.fromJson(reader, FName[].class);
|
FName[] oldNames = gson.fromJson(reader, FName[].class);
|
||||||
if (oldNames == null)
|
if (oldNames == null)
|
||||||
{
|
{
|
||||||
FSync.playerMsg(sender, ChatColor.RED + "Player not found!");
|
FSync.playerMsg(sender, ChatColor.RED + "Player not found!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
conn.disconnect();
|
conn.disconnect();
|
||||||
Arrays.sort(oldNames);
|
Arrays.sort(oldNames);
|
||||||
printHistory(sender, oldNames);
|
printHistory(sender, oldNames);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
FSync.playerMsg(sender, ChatColor.RED + "Error, see logs for more details.");
|
FSync.playerMsg(sender, ChatColor.RED + "Error, see logs for more details.");
|
||||||
FLog.severe(ex);
|
FLog.severe(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FSync.playerMsg(sender, ChatColor.RED + "Player not found!");
|
FSync.playerMsg(sender, ChatColor.RED + "Player not found!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskAsynchronously(TotalFreedomMod.getPlugin());
|
}.runTaskAsynchronously(TotalFreedomMod.getPlugin());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void printHistory(CommandSender sender, FName[] oldNames)
|
private static void printHistory(CommandSender sender, FName[] oldNames)
|
||||||
{
|
{
|
||||||
if (oldNames.length == 1)
|
if (oldNames.length == 1)
|
||||||
{
|
{
|
||||||
FSync.playerMsg(sender, ChatColor.GREEN + oldNames[0].getName() + ChatColor.GOLD + " has never changed their name.");
|
FSync.playerMsg(sender, ChatColor.GREEN + oldNames[0].getName() + ChatColor.GOLD + " has never changed their name.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FSync.playerMsg(sender, ChatColor.GOLD + "Original name: " + ChatColor.GREEN + oldNames[0].getName());
|
FSync.playerMsg(sender, ChatColor.GOLD + "Original name: " + ChatColor.GREEN + oldNames[0].getName());
|
||||||
for (int i = 1; i < oldNames.length; i++)
|
for (int i = 1; i < oldNames.length; i++)
|
||||||
{
|
{
|
||||||
Date date = new Date(oldNames[i].getChangedToAt());
|
Date date = new Date(oldNames[i].getChangedToAt());
|
||||||
String formattedDate = dateFormat.format(date);
|
String formattedDate = dateFormat.format(date);
|
||||||
FSync.playerMsg(sender, ChatColor.BLUE + formattedDate + ChatColor.GOLD + " changed to " + ChatColor.GREEN + oldNames[i].getName());
|
FSync.playerMsg(sender, ChatColor.BLUE + formattedDate + ChatColor.GOLD + " changed to " + ChatColor.GREEN + oldNames[i].getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FName implements Comparable<FName>
|
private static class FName implements Comparable<FName>
|
||||||
{
|
{
|
||||||
private final String name;
|
private final String name;
|
||||||
private final long changedToAt;
|
private final long changedToAt;
|
||||||
|
|
||||||
//Added constructor because otherwise there's no way name or changedToAt would have been anything other than null.
|
//Added constructor because otherwise there's no way name or changedToAt would have been anything other than null.
|
||||||
public FName(String name, long changedToAt)
|
public FName(String name, long changedToAt)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.changedToAt = changedToAt;
|
this.changedToAt = changedToAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(FName other)
|
public int compareTo(FName other)
|
||||||
{
|
{
|
||||||
return Long.compare(this.changedToAt, other.changedToAt);
|
return Long.compare(this.changedToAt, other.changedToAt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getChangedToAt()
|
public long getChangedToAt()
|
||||||
{
|
{
|
||||||
return changedToAt;
|
return changedToAt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,68 +1,68 @@
|
|||||||
package me.totalfreedom.totalfreedommod.util;
|
package me.totalfreedom.totalfreedommod.util;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
// UUIDFetcher retrieves UUIDs from usernames via web requests to Mojang.
|
// UUIDFetcher retrieves UUIDs from usernames via web requests to Mojang.
|
||||||
public class UUIDFetcher
|
public class UUIDFetcher
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft";
|
private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft";
|
||||||
|
|
||||||
public static UUID fetch(String name)
|
public static UUID fetch(String name)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Gson gson = new GsonBuilder().create();
|
Gson gson = new GsonBuilder().create();
|
||||||
UUID uuid;
|
UUID uuid;
|
||||||
String body = gson.toJson(name);
|
String body = gson.toJson(name);
|
||||||
URL url = new URL(PROFILE_URL);
|
URL url = new URL(PROFILE_URL);
|
||||||
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
|
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
|
||||||
connection.setRequestMethod("POST");
|
connection.setRequestMethod("POST");
|
||||||
connection.setRequestProperty("Content-Type", "application/json");
|
connection.setRequestProperty("Content-Type", "application/json");
|
||||||
connection.setUseCaches(false);
|
connection.setUseCaches(false);
|
||||||
connection.setDoInput(true);
|
connection.setDoInput(true);
|
||||||
connection.setDoOutput(true);
|
connection.setDoOutput(true);
|
||||||
OutputStream stream = connection.getOutputStream();
|
OutputStream stream = connection.getOutputStream();
|
||||||
stream.write(body.getBytes());
|
stream.write(body.getBytes());
|
||||||
stream.flush();
|
stream.flush();
|
||||||
stream.close();
|
stream.close();
|
||||||
FetchedUuid[] id = gson.fromJson(
|
FetchedUuid[] id = gson.fromJson(
|
||||||
new InputStreamReader(connection.getInputStream()),
|
new InputStreamReader(connection.getInputStream()),
|
||||||
FetchedUuid[].class);
|
FetchedUuid[].class);
|
||||||
|
|
||||||
if (id.length == 0 || id[0].getID() == null)
|
if (id.length == 0 || id[0].getID() == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String idd = id[0].getID();
|
String idd = id[0].getID();
|
||||||
uuid = UUID.fromString(idd.substring(0, 8) + "-" + idd.substring(8, 12)
|
uuid = UUID.fromString(idd.substring(0, 8) + "-" + idd.substring(8, 12)
|
||||||
+ "-" + idd.substring(12, 16) + "-" + idd.substring(16, 20) + "-"
|
+ "-" + idd.substring(12, 16) + "-" + idd.substring(16, 20) + "-"
|
||||||
+ idd.substring(20, 32));
|
+ idd.substring(20, 32));
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
FLog.severe(ex);
|
FLog.severe(ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FetchedUuid
|
private static class FetchedUuid
|
||||||
{
|
{
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
public String getID()
|
public String getID()
|
||||||
{
|
{
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -35,6 +35,9 @@ server:
|
|||||||
|
|
||||||
# All players who show up as executive
|
# All players who show up as executive
|
||||||
executives: [ ]
|
executives: [ ]
|
||||||
|
|
||||||
|
# All players who show up as assistant executive
|
||||||
|
assistant_executives: []
|
||||||
|
|
||||||
# All those who can manage the master builder list
|
# All those who can manage the master builder list
|
||||||
master_builder_management: [ ]
|
master_builder_management: [ ]
|
||||||
|
Loading…
Reference in New Issue
Block a user