Code cleanup

This commit is contained in:
Telesphoreo 2022-01-30 15:03:47 -06:00
parent d4761d4386
commit 4a05d90c17
25 changed files with 191 additions and 97 deletions

View File

@ -1,6 +1,6 @@
name: Gradle name: Gradle
on: [push] on: [ push ]
jobs: jobs:
build: build:

View File

@ -1,2 +1,3 @@
# Plex # Plex
A new freedom plugin. A new freedom plugin.

View File

@ -8,7 +8,7 @@ import org.bukkit.Bukkit;
public class DataUtils public class DataUtils
{ {
/* PLEX PLAYER METHODS */ /* PLEX PLAYER METHODS */
public static boolean hasPlayedBefore(UUID uuid) public static boolean hasPlayedBefore(UUID uuid)
{ {
@ -61,7 +61,9 @@ public class DataUtils
if (Plex.get().getStorageType() == StorageType.MONGODB) if (Plex.get().getStorageType() == StorageType.MONGODB)
{ {
Plex.get().getMongoPlayerData().save(plexPlayer); Plex.get().getMongoPlayerData().save(plexPlayer);
} else { }
else
{
Plex.get().getSqlPlayerData().insert(plexPlayer); Plex.get().getSqlPlayerData().insert(plexPlayer);
} }
} }

View File

@ -54,7 +54,9 @@ public class SQLPlayerData
String rankName = set.getString("rank").toUpperCase(); String rankName = set.getString("rank").toUpperCase();
long coins = set.getLong("coins"); long coins = set.getLong("coins");
boolean vanished = set.getBoolean("vanished"); boolean vanished = set.getBoolean("vanished");
List<String> ips = new Gson().fromJson(set.getString("ips"), new TypeToken<List<String>>(){}.getType()); List<String> ips = new Gson().fromJson(set.getString("ips"), new TypeToken<List<String>>()
{
}.getType());
plexPlayer.setName(name); plexPlayer.setName(name);
plexPlayer.setLoginMSG(loginMSG); plexPlayer.setLoginMSG(loginMSG);
plexPlayer.setPrefix(prefix); plexPlayer.setPrefix(prefix);

View File

@ -5,6 +5,7 @@ import dev.plex.rank.enums.Rank;
public @interface CheckPermission public @interface CheckPermission
{ {
String permission() default ""; String permission() default "";
Rank rank() default Rank.IMPOSTOR; Rank rank() default Rank.IMPOSTOR;
} }

View File

@ -24,7 +24,7 @@ public class AdventureCMD extends PlexCommand
@Override @Override
public Component execute(CommandSender sender, String[] args) public Component execute(CommandSender sender, String[] args)
{ {
Player player = (Player) sender; Player player = (Player)sender;
if (args.length == 0) if (args.length == 0)
{ {
if (isConsole(sender)) if (isConsole(sender))

View File

@ -51,7 +51,7 @@ public class BanCMD extends PlexCommand
{ {
if (!isConsole(sender)) if (!isConsole(sender))
{ {
PlexPlayer plexPlayer1 = getPlexPlayer((Player) sender); PlexPlayer plexPlayer1 = getPlexPlayer((Player)sender);
if (!plexPlayer1.getRankFromString().isAtLeast(plexPlayer.getRankFromString())) if (!plexPlayer1.getRankFromString().isAtLeast(plexPlayer.getRankFromString()))
{ {
return tl("higherRankThanYou"); return tl("higherRankThanYou");

View File

@ -23,7 +23,7 @@ public class CreativeCMD extends PlexCommand
@Override @Override
public Component execute(CommandSender sender, String[] args) public Component execute(CommandSender sender, String[] args)
{ {
Player player = (Player) sender; Player player = (Player)sender;
if (args.length == 0) if (args.length == 0)
{ {
if (isConsole(sender)) if (isConsole(sender))

View File

@ -44,7 +44,8 @@ public class NameHistoryCMD extends PlexCommand
if (offlinePlayer != null) if (offlinePlayer != null)
{ {
uuid = offlinePlayer.getUniqueId(); uuid = offlinePlayer.getUniqueId();
} else }
else
{ {
uuid = MojangUtils.getUUID(username); uuid = MojangUtils.getUUID(username);
} }
@ -68,7 +69,8 @@ public class NameHistoryCMD extends PlexCommand
.append(Component.text("-").color(NamedTextColor.DARK_GRAY)) .append(Component.text("-").color(NamedTextColor.DARK_GRAY))
.append(Component.space()) .append(Component.space())
.append(Component.text(DATE_FORMAT.format(entry.getValue())).color(NamedTextColor.GOLD))); .append(Component.text(DATE_FORMAT.format(entry.getValue())).color(NamedTextColor.GOLD)));
} else }
else
{ {
historyList.add( historyList.add(
Component.text(entry.getKey()).color(NamedTextColor.GOLD) Component.text(entry.getKey()).color(NamedTextColor.GOLD)

View File

@ -12,7 +12,6 @@ import java.util.List;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@CommandPermissions(level = Rank.OP, permission = "plex.plex", source = RequiredCommandSource.ANY) @CommandPermissions(level = Rank.OP, permission = "plex.plex", source = RequiredCommandSource.ANY)

View File

@ -21,7 +21,7 @@ public class PunishmentsCMD extends PlexCommand
@Override @Override
public Component execute(CommandSender sender, String[] args) public Component execute(CommandSender sender, String[] args)
{ {
new PunishmentMenu().openInv(((Player) sender), 0); new PunishmentMenu().openInv(((Player)sender), 0);
return null; return null;
} }

View File

@ -23,7 +23,7 @@ public class SpectatorCMD extends PlexCommand
@Override @Override
public Component execute(CommandSender sender, String[] args) public Component execute(CommandSender sender, String[] args)
{ {
Player player = (Player) sender; Player player = (Player)sender;
if (args.length == 0) if (args.length == 0)
{ {
if (isConsole(sender)) if (isConsole(sender))

View File

@ -23,7 +23,7 @@ public class SurvivalCMD extends PlexCommand
@Override @Override
public Component execute(CommandSender sender, String[] args) public Component execute(CommandSender sender, String[] args)
{ {
Player player = (Player) sender; Player player = (Player)sender;
if (args.length == 0) if (args.length == 0)
{ {
if (isConsole(sender)) if (isConsole(sender))

View File

@ -14,10 +14,7 @@ import dev.plex.util.PlexUtils;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@CommandParameters(name = "unban", usage = "/<command> <player>", description = "Unbans a player, offline or online") @CommandParameters(name = "unban", usage = "/<command> <player>", description = "Unbans a player, offline or online")

View File

@ -1,13 +1,9 @@
package dev.plex.listener.impl; package dev.plex.listener.impl;
import dev.plex.listener.PlexListener; import dev.plex.listener.PlexListener;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent; import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.jetbrains.annotations.NotNull;
public class LoginListener extends PlexListener public class LoginListener extends PlexListener
{ {

View File

@ -25,7 +25,8 @@ public class PunishedPlayerMenu extends AbstractMenu
private final List<Inventory> inventories = Lists.newArrayList(); private final List<Inventory> inventories = Lists.newArrayList();
public PunishedPlayerMenu(PunishedPlayer player) { public PunishedPlayerMenu(PunishedPlayer player)
{
super("§c§lPunishments"); super("§c§lPunishments");
this.punishedPlayer = player; this.punishedPlayer = player;
for (int i = 0; i <= punishedPlayer.getPunishments().size() / 53; i++) for (int i = 0; i <= punishedPlayer.getPunishments().size() / 53; i++)
@ -53,11 +54,13 @@ public class PunishedPlayerMenu extends AbstractMenu
} }
} }
public List<Inventory> getInventory() { public List<Inventory> getInventory()
{
return inventories; return inventories;
} }
public void openInv(Player player, int index) { public void openInv(Player player, int index)
{
int currentItemIndex = 0; int currentItemIndex = 0;
int currentInvIndex = 0; int currentInvIndex = 0;
for (Punishment punishment : punishedPlayer.getPunishments()) for (Punishment punishment : punishedPlayer.getPunishments())
@ -68,7 +71,8 @@ public class PunishedPlayerMenu extends AbstractMenu
break; break;
} }
if (currentItemIndex == inv.getSize() - 1) { if (currentItemIndex == inv.getSize() - 1)
{
currentInvIndex++; currentInvIndex++;
currentItemIndex = 0; currentItemIndex = 0;
inv = inventories.get(currentInvIndex); inv = inventories.get(currentInvIndex);
@ -91,34 +95,61 @@ public class PunishedPlayerMenu extends AbstractMenu
@EventHandler @EventHandler
public void onClick(InventoryClickEvent event) public void onClick(InventoryClickEvent event)
{ {
if (event.getClickedInventory() == null) return; if (event.getClickedInventory() == null)
{
return;
}
Inventory inv = event.getClickedInventory(); Inventory inv = event.getClickedInventory();
if (!isValidInventory(inv)) return; if (!isValidInventory(inv))
if (event.getCurrentItem() == null) return; {
return;
}
if (event.getCurrentItem() == null)
{
return;
}
ItemStack item = event.getCurrentItem(); ItemStack item = event.getCurrentItem();
event.setCancelled(true); event.setCancelled(true);
if (item.getType() == Material.FEATHER) if (item.getType() == Material.FEATHER)
{ {
if (item.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.LIGHT_PURPLE + "Next Page")) if (item.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.LIGHT_PURPLE + "Next Page"))
{ {
if (getCurrentInventoryIndex(inv) + 1 > inventories.size() - 1) return; if (getCurrentInventoryIndex(inv) + 1 > inventories.size() - 1)
if (inventories.get(getCurrentInventoryIndex(inv) + 1).getContents().length == 0) return; {
openInv((Player) event.getWhoClicked(), getCurrentInventoryIndex(inv) + 1); return;
} else if (item.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.LIGHT_PURPLE + "Previous Page")) }
if (inventories.get(getCurrentInventoryIndex(inv) + 1).getContents().length == 0)
{
return;
}
openInv((Player)event.getWhoClicked(), getCurrentInventoryIndex(inv) + 1);
}
else if (item.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.LIGHT_PURPLE + "Previous Page"))
{ {
if (getCurrentInventoryIndex(inv) - 1 < 0) return; if (getCurrentInventoryIndex(inv) - 1 < 0)
if (getCurrentInventoryIndex(inv) - 1 > inventories.size() - 1) return; {
if (inventories.get(getCurrentInventoryIndex(inv) - 1).getContents().length == 0) return; return;
openInv((Player) event.getWhoClicked(), getCurrentInventoryIndex(inv) - 1); }
if (getCurrentInventoryIndex(inv) - 1 > inventories.size() - 1)
{
return;
}
if (inventories.get(getCurrentInventoryIndex(inv) - 1).getContents().length == 0)
{
return;
}
openInv((Player)event.getWhoClicked(), getCurrentInventoryIndex(inv) - 1);
} }
} else if (item.getType() == Material.BARRIER) }
else if (item.getType() == Material.BARRIER)
{ {
new PunishmentMenu().openInv((Player) event.getWhoClicked(), 0); new PunishmentMenu().openInv((Player)event.getWhoClicked(), 0);
} else if (item.getType() == Material.PLAYER_HEAD) }
else if (item.getType() == Material.PLAYER_HEAD)
{ {
SkullMeta meta = (SkullMeta) item.getItemMeta(); SkullMeta meta = (SkullMeta)item.getItemMeta();
OfflinePlayer player = meta.getOwningPlayer(); OfflinePlayer player = meta.getOwningPlayer();
assert player != null; assert player != null;
PunishedPlayer punishedPlayer = PlayerCache.getPunishedPlayer(player.getUniqueId()) == null ? null : PlayerCache.getPunishedPlayer(player.getUniqueId()); PunishedPlayer punishedPlayer = PlayerCache.getPunishedPlayer(player.getUniqueId()) == null ? null : PlayerCache.getPunishedPlayer(player.getUniqueId());

View File

@ -22,7 +22,8 @@ public class PunishmentMenu extends AbstractMenu
private List<Inventory> inventories = Lists.newArrayList(); private List<Inventory> inventories = Lists.newArrayList();
public PunishmentMenu() { public PunishmentMenu()
{
super("§c§lPunishments"); super("§c§lPunishments");
for (int i = 0; i <= Bukkit.getOnlinePlayers().size() / 53; i++) for (int i = 0; i <= Bukkit.getOnlinePlayers().size() / 53; i++)
{ {
@ -43,11 +44,13 @@ public class PunishmentMenu extends AbstractMenu
} }
} }
public List<Inventory> getInventory() { public List<Inventory> getInventory()
{
return inventories; return inventories;
} }
public void openInv(Player player, int index) { public void openInv(Player player, int index)
{
int currentItemIndex = 0; int currentItemIndex = 0;
int currentInvIndex = 0; int currentInvIndex = 0;
for (Player players : Bukkit.getOnlinePlayers()) for (Player players : Bukkit.getOnlinePlayers())
@ -58,7 +61,8 @@ public class PunishmentMenu extends AbstractMenu
break; break;
} }
if (currentItemIndex == inv.getSize() - 1) { if (currentItemIndex == inv.getSize() - 1)
{
currentInvIndex++; currentInvIndex++;
currentItemIndex = 0; currentItemIndex = 0;
inv = inventories.get(currentInvIndex); inv = inventories.get(currentInvIndex);
@ -66,7 +70,7 @@ public class PunishmentMenu extends AbstractMenu
ItemStack item = new ItemStack(Material.PLAYER_HEAD); ItemStack item = new ItemStack(Material.PLAYER_HEAD);
SkullMeta meta = (SkullMeta) item.getItemMeta(); SkullMeta meta = (SkullMeta)item.getItemMeta();
meta.setOwningPlayer(players); meta.setOwningPlayer(players);
meta.setDisplayName(ChatColor.YELLOW + players.getName()); meta.setDisplayName(ChatColor.YELLOW + players.getName());
item.setItemMeta(meta); item.setItemMeta(meta);
@ -81,31 +85,57 @@ public class PunishmentMenu extends AbstractMenu
@EventHandler @EventHandler
public void onClick(InventoryClickEvent event) public void onClick(InventoryClickEvent event)
{ {
if (event.getClickedInventory() == null) return; if (event.getClickedInventory() == null)
{
return;
}
Inventory inv = event.getClickedInventory(); Inventory inv = event.getClickedInventory();
if (!isValidInventory(inv)) return; if (!isValidInventory(inv))
if (event.getCurrentItem() == null) return; {
return;
}
if (event.getCurrentItem() == null)
{
return;
}
ItemStack item = event.getCurrentItem(); ItemStack item = event.getCurrentItem();
event.setCancelled(true); event.setCancelled(true);
if (item.getType() == Material.FEATHER) if (item.getType() == Material.FEATHER)
{ {
if (item.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.LIGHT_PURPLE + "Next Page")) if (item.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.LIGHT_PURPLE + "Next Page"))
{ {
if (getCurrentInventoryIndex(inv) + 1 > inventories.size() - 1) return; if (getCurrentInventoryIndex(inv) + 1 > inventories.size() - 1)
if (inventories.get(getCurrentInventoryIndex(inv) + 1).getContents().length == 0) return; {
openInv((Player) event.getWhoClicked(), getCurrentInventoryIndex(inv) + 1); return;
} else if (item.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.LIGHT_PURPLE + "Previous Page")) }
if (inventories.get(getCurrentInventoryIndex(inv) + 1).getContents().length == 0)
{
return;
}
openInv((Player)event.getWhoClicked(), getCurrentInventoryIndex(inv) + 1);
}
else if (item.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.LIGHT_PURPLE + "Previous Page"))
{ {
if (getCurrentInventoryIndex(inv) - 1 < 0) return; if (getCurrentInventoryIndex(inv) - 1 < 0)
if (getCurrentInventoryIndex(inv) - 1 > inventories.size() - 1) return; {
if (inventories.get(getCurrentInventoryIndex(inv) - 1).getContents().length == 0) return; return;
openInv((Player) event.getWhoClicked(), getCurrentInventoryIndex(inv) - 1); }
if (getCurrentInventoryIndex(inv) - 1 > inventories.size() - 1)
{
return;
}
if (inventories.get(getCurrentInventoryIndex(inv) - 1).getContents().length == 0)
{
return;
}
openInv((Player)event.getWhoClicked(), getCurrentInventoryIndex(inv) - 1);
} }
} else if (item.getType() == Material.PLAYER_HEAD) }
else if (item.getType() == Material.PLAYER_HEAD)
{ {
SkullMeta meta = (SkullMeta) item.getItemMeta(); SkullMeta meta = (SkullMeta)item.getItemMeta();
OfflinePlayer player = meta.getOwningPlayer(); OfflinePlayer player = meta.getOwningPlayer();
assert player != null; assert player != null;
PunishedPlayer punishedPlayer = PlayerCache.getPunishedPlayer(player.getUniqueId()) == null ? null : PlayerCache.getPunishedPlayer(player.getUniqueId()); PunishedPlayer punishedPlayer = PlayerCache.getPunishedPlayer(player.getUniqueId()) == null ? null : PlayerCache.getPunishedPlayer(player.getUniqueId());
@ -115,11 +145,10 @@ public class PunishmentMenu extends AbstractMenu
event.getWhoClicked().closeInventory(); event.getWhoClicked().closeInventory();
return; return;
} }
new PunishedPlayerMenu(punishedPlayer).openInv((Player) event.getWhoClicked(), 0); new PunishedPlayerMenu(punishedPlayer).openInv((Player)event.getWhoClicked(), 0);
} }
} }
public int getCurrentInventoryIndex(Inventory inventory) public int getCurrentInventoryIndex(Inventory inventory)

View File

@ -69,7 +69,8 @@ public class PlexPlayer
this.rank = ""; this.rank = "";
} }
public String displayName() { public String displayName()
{
return PlainTextComponentSerializer.plainText().serialize(player.displayName()); return PlainTextComponentSerializer.plainText().serialize(player.displayName());
} }

View File

@ -68,9 +68,12 @@ public class PunishedPlayer
File file = new File(folder, getUuid() + ".json"); File file = new File(folder, getUuid() + ".json");
if (!file.exists()) if (!file.exists())
{ {
try { try
{
file.createNewFile(); file.createNewFile();
} catch (IOException e) { }
catch (IOException e)
{
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -86,24 +89,32 @@ public class PunishedPlayer
if (isNotEmpty(file)) if (isNotEmpty(file))
{ {
try { try
{
JSONTokener tokener = new JSONTokener(new FileInputStream(file)); JSONTokener tokener = new JSONTokener(new FileInputStream(file));
JSONObject object = new JSONObject(tokener); JSONObject object = new JSONObject(tokener);
object.getJSONObject(getUuid()).getJSONArray("punishments").forEach(obj -> { object.getJSONObject(getUuid()).getJSONArray("punishments").forEach(obj ->
{
Punishment punishment = Punishment.fromJson(obj.toString()); Punishment punishment = Punishment.fromJson(obj.toString());
punishments.add(punishment); punishments.add(punishment);
}); });
} catch (FileNotFoundException e) { }
catch (FileNotFoundException e)
{
e.printStackTrace(); e.printStackTrace();
} }
} }
return punishments; return punishments;
} }
private boolean isNotEmpty(File file) { private boolean isNotEmpty(File file)
try { {
try
{
return !FileUtils.readFileToString(file, StandardCharsets.UTF_8).trim().isEmpty(); return !FileUtils.readFileToString(file, StandardCharsets.UTF_8).trim().isEmpty();
} catch (IOException e) { }
catch (IOException e)
{
e.printStackTrace(); e.printStackTrace();
} }
return false; return false;

View File

@ -29,7 +29,8 @@ public class PunishmentManager
{ {
File file = player.getPunishmentsFile(); File file = player.getPunishmentsFile();
try { try
{
if (isNotEmpty(file)) if (isNotEmpty(file))
{ {
JSONTokener tokener = new JSONTokener(new FileInputStream(file)); JSONTokener tokener = new JSONTokener(new FileInputStream(file));
@ -40,7 +41,9 @@ public class PunishmentManager
writer.append(object.toString(8)); writer.append(object.toString(8));
writer.flush(); writer.flush();
writer.close(); writer.close();
} else { }
else
{
JSONObject object = new JSONObject(); JSONObject object = new JSONObject();
Map<String, List<String>> punishments = Maps.newHashMap(); Map<String, List<String>> punishments = Maps.newHashMap();
@ -56,15 +59,21 @@ public class PunishmentManager
writer.close(); writer.close();
} }
} catch (IOException e) { }
catch (IOException e)
{
e.printStackTrace(); e.printStackTrace();
} }
} }
private boolean isNotEmpty(File file) { private boolean isNotEmpty(File file)
try { {
try
{
return !FileUtils.readFileToString(file, StandardCharsets.UTF_8).trim().isEmpty(); return !FileUtils.readFileToString(file, StandardCharsets.UTF_8).trim().isEmpty();
} catch (IOException e) { }
catch (IOException e)
{
e.printStackTrace(); e.printStackTrace();
} }
return false; return false;
@ -76,15 +85,18 @@ public class PunishmentManager
{ {
Ban ban = new Ban(punishment.getPunished(), (punishment.getPunisher() == null ? null : punishment.getPunisher()), "", punishment.getReason(), punishment.getEndDate()); Ban ban = new Ban(punishment.getPunished(), (punishment.getPunisher() == null ? null : punishment.getPunisher()), "", punishment.getReason(), punishment.getEndDate());
Plex.get().getBanManager().executeBan(ban); Plex.get().getBanManager().executeBan(ban);
} else if (punishment.getType() == PunishmentType.FREEZE) }
else if (punishment.getType() == PunishmentType.FREEZE)
{ {
player.setFrozen(true); player.setFrozen(true);
Date now = new Date(); Date now = new Date();
Date then = punishment.getEndDate(); Date then = punishment.getEndDate();
long seconds = TimeUnit.MILLISECONDS.toSeconds(then.getTime() - now.getTime()); long seconds = TimeUnit.MILLISECONDS.toSeconds(then.getTime() - now.getTime());
new BukkitRunnable() { new BukkitRunnable()
{
@Override @Override
public void run() { public void run()
{
if (!player.isFrozen()) if (!player.isFrozen())
{ {
this.cancel(); this.cancel();
@ -97,16 +109,18 @@ public class PunishmentManager
}.runTaskLater(Plex.get(), 20 * seconds); }.runTaskLater(Plex.get(), 20 * seconds);
}
} else if (punishment.getType() == PunishmentType.MUTE) else if (punishment.getType() == PunishmentType.MUTE)
{ {
player.setMuted(true); player.setMuted(true);
Date now = new Date(); Date now = new Date();
Date then = punishment.getEndDate(); Date then = punishment.getEndDate();
long seconds = TimeUnit.MILLISECONDS.toSeconds(then.getTime() - now.getTime()); long seconds = TimeUnit.MILLISECONDS.toSeconds(then.getTime() - now.getTime());
new BukkitRunnable() { new BukkitRunnable()
{
@Override @Override
public void run() { public void run()
{
player.setMuted(false); player.setMuted(false);
} }
}.runTaskLater(Plex.get(), 20 * seconds); }.runTaskLater(Plex.get(), 20 * seconds);

View File

@ -11,11 +11,13 @@ public abstract class AbstractService implements IService
this.asynchronous = async; this.asynchronous = async;
} }
public boolean isRepeating() { public boolean isRepeating()
{
return repeating; return repeating;
} }
public boolean isAsynchronous() { public boolean isAsynchronous()
{
return asynchronous; return asynchronous;
} }
} }

View File

@ -2,7 +2,6 @@ package dev.plex.services;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import dev.plex.Plex; import dev.plex.Plex;
import dev.plex.services.impl.BanService;
import dev.plex.services.impl.GameRuleService; import dev.plex.services.impl.GameRuleService;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

View File

@ -8,12 +8,14 @@ import org.bukkit.Bukkit;
public class BanService extends AbstractService public class BanService extends AbstractService
{ {
public BanService() { public BanService()
{
super(true, true); super(true, true);
} }
@Override @Override
public void run() { public void run()
{
for (Ban ban : Plex.get().getBanManager().getActiveBans()) for (Ban ban : Plex.get().getBanManager().getActiveBans())
{ {
if (new Date().after(ban.getEndDate())) if (new Date().after(ban.getEndDate()))
@ -25,7 +27,8 @@ public class BanService extends AbstractService
} }
@Override @Override
public int repeatInSeconds() { public int repeatInSeconds()
{
return 10; return 10;
} }
} }

View File

@ -35,7 +35,8 @@ public class MojangUtils
.insert(13, "-") .insert(13, "-")
.insert(18, "-") .insert(18, "-")
.insert(23, "-").toString()); .insert(23, "-").toString());
} catch (IOException e) }
catch (IOException e)
{ {
e.printStackTrace(); e.printStackTrace();
return null; return null;
@ -63,12 +64,14 @@ public class MojangUtils
Instant instant = Instant.ofEpochMilli(dateTime); Instant instant = Instant.ofEpochMilli(dateTime);
LocalDateTime time = LocalDateTime.ofInstant(instant, ZoneId.of("America/Los_Angeles")); LocalDateTime time = LocalDateTime.ofInstant(instant, ZoneId.of("America/Los_Angeles"));
names.put(name, time); names.put(name, time);
} else }
else
{ {
names.put(name, null); names.put(name, null);
} }
}); });
} catch (IOException e) }
catch (IOException e)
{ {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -14,7 +14,8 @@ public abstract class AbstractMenu implements Listener
Plex.get().getServer().getPluginManager().registerEvents(this, Plex.get()); Plex.get().getServer().getPluginManager().registerEvents(this, Plex.get());
} }
public String getName() { public String getName()
{
return name; return name;
} }
} }