Merge pull request #7 from nickreesdev/master

Bug fixes
This commit is contained in:
Braydon 2021-02-20 00:05:42 -05:00 committed by GitHub
commit 2b3d34debf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 77 additions and 76 deletions

View File

@ -35,7 +35,7 @@ public class Arcade extends MGZPlugin {
@Startup
public void loadArcade() {
new PlayerDataManager(this);
arcadeManager = new ArcadeManager(this, traveller);
arcadeManager = new ArcadeManager(this, traveler);
new ScoreboardHandler(this, ArcadeScoreboard.class, 3L);

View File

@ -32,7 +32,7 @@ import zone.themcgamer.core.common.scheduler.ScheduleType;
import zone.themcgamer.core.common.scheduler.event.SchedulerEvent;
import zone.themcgamer.core.module.Module;
import zone.themcgamer.core.module.ModuleInfo;
import zone.themcgamer.core.traveller.ServerTraveller;
import zone.themcgamer.core.traveler.ServerTraveler;
import zone.themcgamer.core.world.MGZWorld;
import java.io.File;
@ -57,9 +57,9 @@ public class ArcadeManager extends Module {
private boolean mapsLoaded;
private MapVotingManager mapVotingManager;
public ArcadeManager(JavaPlugin plugin, ServerTraveller traveller) {
public ArcadeManager(JavaPlugin plugin, ServerTraveler traveler) {
super(plugin);
new LobbyManager(plugin, this, traveller);
new LobbyManager(plugin, this, traveler);
gameManager = new GameManager(plugin);
game = gameManager.getGames().get(0);
MapManager mapManager = new MapManager(plugin);

View File

@ -34,7 +34,7 @@ import zone.themcgamer.core.common.SkullTexture;
import zone.themcgamer.core.common.Style;
import zone.themcgamer.core.module.Module;
import zone.themcgamer.core.module.ModuleInfo;
import zone.themcgamer.core.traveller.ServerTraveller;
import zone.themcgamer.core.traveler.ServerTraveler;
import zone.themcgamer.data.Rank;
import java.util.Optional;
@ -67,12 +67,12 @@ public class LobbyManager extends Module {
.addLoreLine("&7Click to go back to a lobby server").toItemStack();
private final ArcadeManager arcadeManager;
private final ServerTraveller traveller;
private final ServerTraveler traveler;
public LobbyManager(JavaPlugin plugin, ArcadeManager arcadeManager, ServerTraveller traveller) {
public LobbyManager(JavaPlugin plugin, ArcadeManager arcadeManager, ServerTraveler traveler) {
super(plugin);
this.arcadeManager = arcadeManager;
this.traveller = traveller;
this.traveler = traveler;
}
@EventHandler
@ -127,7 +127,7 @@ public class LobbyManager extends Module {
}
new TimeVoteMenu(player).open();
} else if (item.isSimilar(GO_BACK_LOBBY))
traveller.sendPlayer(player,"Hub");
traveler.sendPlayer(player,"Hub");
}
@EventHandler

View File

@ -10,7 +10,7 @@ import zone.themcgamer.core.kingdom.command.KingdomCommand;
import zone.themcgamer.core.module.Module;
import zone.themcgamer.core.module.ModuleInfo;
import zone.themcgamer.core.plugin.MGZPlugin;
import zone.themcgamer.core.traveller.ServerTraveller;
import zone.themcgamer.core.traveler.ServerTraveler;
import zone.themcgamer.data.Rank;
import zone.themcgamer.data.jedis.data.ServerGroup;
import zone.themcgamer.data.jedis.repository.RedisRepository;
@ -28,7 +28,7 @@ public class KingdomManager extends Module {
private final ServerGroupRepository serverGroupRepository;
public KingdomManager(JavaPlugin plugin, ServerTraveller traveller) {
public KingdomManager(JavaPlugin plugin, ServerTraveler traveler) {
super(plugin);
serverGroupRepository = RedisRepository.getRepository(ServerGroupRepository.class).orElse(null);
// JedisCommandHandler.getInstance().addListener(jedisCommand -> {
@ -40,7 +40,7 @@ public class KingdomManager extends Module {
// for (Player player : Bukkit.getOnlinePlayers()) {
// if (!server.getName().equals(player.getName() + "-1"))
// continue;
// traveller.sendPlayer(player, server);
// traveler.sendPlayer(player, server);
// }
// }
// });

View File

@ -19,7 +19,7 @@ import zone.themcgamer.core.plugin.command.BuildDataCommand;
import zone.themcgamer.core.plugin.command.PluginsCommand;
import zone.themcgamer.core.server.ServerManager;
import zone.themcgamer.core.task.TaskManager;
import zone.themcgamer.core.traveller.ServerTraveller;
import zone.themcgamer.core.traveler.ServerTraveler;
import zone.themcgamer.core.update.ServerUpdater;
import zone.themcgamer.data.jedis.JedisController;
import zone.themcgamer.data.jedis.data.server.MinecraftServer;
@ -49,7 +49,7 @@ public abstract class MGZPlugin extends JavaPlugin {
protected JedisController jedisController;
protected MySQLController mySQLController;
protected CommandManager commandManager;
protected ServerTraveller traveller;
protected ServerTraveler traveler;
protected BadSportSystem badSportSystem;
protected NametagManager nametagManager;
@ -170,9 +170,9 @@ public abstract class MGZPlugin extends JavaPlugin {
nametagManager = new NametagManager(this);
AccountManager accountManager = new AccountManager(this, mySQLController, nametagManager);
traveller = new ServerTraveller(this);
new ServerUpdater(this, traveller);
new ServerManager(this, traveller);
traveler = new ServerTraveler(this);
new ServerUpdater(this, traveler);
new ServerManager(this, traveler);
badSportSystem = new BadSportSystem(this, mySQLController, accountManager);
AccountManager.addMiniAccount(new TaskManager(this));

View File

@ -10,7 +10,7 @@ import zone.themcgamer.core.module.Module;
import zone.themcgamer.core.module.ModuleInfo;
import zone.themcgamer.core.plugin.MGZPlugin;
import zone.themcgamer.core.server.command.*;
import zone.themcgamer.core.traveller.ServerTraveller;
import zone.themcgamer.core.traveler.ServerTraveler;
import zone.themcgamer.data.jedis.command.JedisCommandHandler;
import zone.themcgamer.data.jedis.command.impl.ServerRestartCommand;
import zone.themcgamer.data.jedis.data.server.MinecraftServer;
@ -24,13 +24,13 @@ import zone.themcgamer.data.jedis.repository.impl.ServerGroupRepository;
*/
@ModuleInfo(name = "Server Manager")
public class ServerManager extends Module {
public ServerManager(JavaPlugin plugin, ServerTraveller traveller) {
public ServerManager(JavaPlugin plugin, ServerTraveler traveler) {
super(plugin);
ServerGroupRepository serverGroupRepository = RedisRepository.getRepository(ServerGroupRepository.class).orElse(null);
MinecraftServerRepository minecraftServerRepository = RedisRepository.getRepository(MinecraftServerRepository.class).orElse(null);
registerCommand(new MonitorCommand());
registerCommand(new ServerCommand(traveller, minecraftServerRepository));
registerCommand(new HubCommand(traveller));
registerCommand(new ServerCommand(traveler, minecraftServerRepository));
registerCommand(new HubCommand(traveler));
registerCommand(new RestartCommand(this, serverGroupRepository, minecraftServerRepository));
registerCommand(new StopCommand(this));
@ -41,7 +41,7 @@ public class ServerManager extends Module {
if (!((ServerRestartCommand) jedisCommand).getServerId().equals(minecraftServer.getId()))
return;
try {
traveller.sendAll("Hub", "&6" + minecraftServer.getName() + " &7is restarting");
traveler.sendAll("Hub", "&6" + minecraftServer.getName() + " &7is restarting");
} catch (IllegalArgumentException ignored) {}
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () ->
minecraftServer.setState(ServerState.RESTARTING), 10L);

View File

@ -5,20 +5,20 @@ import org.bukkit.entity.Player;
import zone.themcgamer.core.command.Command;
import zone.themcgamer.core.command.CommandProvider;
import zone.themcgamer.core.common.Style;
import zone.themcgamer.core.traveller.ServerTraveller;
import zone.themcgamer.core.traveler.ServerTraveler;
/**
* @author Braydon
*/
@AllArgsConstructor
public class HubCommand {
private final ServerTraveller traveller;
private final ServerTraveler traveler;
@Command(name = "hub", aliases = { "lobby" }, description = "Join a random hub", playersOnly = true)
public void onCommand(CommandProvider command) {
Player player = command.getPlayer();
try {
traveller.sendPlayer(player, "Hub");
traveler.sendPlayer(player, "Hub");
} catch (Exception ex) {
player.sendMessage(Style.error("Server", "&7Could not find an available hub to send you to!"));
}

View File

@ -9,7 +9,7 @@ import zone.themcgamer.core.command.Command;
import zone.themcgamer.core.command.CommandProvider;
import zone.themcgamer.core.common.Style;
import zone.themcgamer.core.plugin.MGZPlugin;
import zone.themcgamer.core.traveller.ServerTraveller;
import zone.themcgamer.core.traveler.ServerTraveler;
import zone.themcgamer.data.jedis.data.server.MinecraftServer;
import zone.themcgamer.data.jedis.repository.impl.MinecraftServerRepository;
@ -21,7 +21,7 @@ import java.util.Optional;
*/
@AllArgsConstructor
public class ServerCommand {
private final ServerTraveller traveller;
private final ServerTraveler traveler;
private final MinecraftServerRepository minecraftServerRepository;
@Command(name = "server", aliases = { "join", "play" }, description = "Join a server", playersOnly = true)
@ -53,7 +53,7 @@ public class ServerCommand {
return;
}
try {
traveller.sendPlayer(player, minecraftServer);
traveler.sendPlayer(player, minecraftServer);
} catch (Exception ex) {
player.sendMessage(Style.error("Server", "&7Cannot join &6" + minecraftServer.getName() + " &7at this time: &b" + ex.getLocalizedMessage()));
}

View File

@ -1,4 +1,4 @@
package zone.themcgamer.core.traveller;
package zone.themcgamer.core.traveler;
import com.cryptomorin.xseries.XSound;
import net.md_5.bungee.api.chat.ComponentBuilder;
@ -27,12 +27,12 @@ import java.util.stream.Collectors;
/**
* @author Braydon
*/
@ModuleInfo(name = "Server Traveller")
public class ServerTraveller extends Module {
@ModuleInfo(name = "Server Traveler")
public class ServerTraveler extends Module {
private final ServerGroupRepository serverGroupRepository;
private final MinecraftServerRepository minecraftServerRepository;
public ServerTraveller(JavaPlugin plugin) {
public ServerTraveler(JavaPlugin plugin) {
super(plugin);
serverGroupRepository = RedisRepository.getRepository(ServerGroupRepository.class).orElse(null);
minecraftServerRepository = RedisRepository.getRepository(MinecraftServerRepository.class).orElse(null);
@ -130,7 +130,7 @@ public class ServerTraveller extends Module {
if (MGZPlugin.getMinecraftServer().equals(server))
throw new IllegalArgumentException("Player is already connected");
if (inform) {
player.sendMessage(new ComponentBuilder(Style.main("Traveller", "Connecting to &6" + server.getName()))
player.sendMessage(new ComponentBuilder(Style.main("Traveler", "Connecting to &6" + server.getName()))
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(MiscUtils.arrayToString(
Style.color("&7Server Id: &6" + server.getId()),
Style.color("&7Type: &6" + server.getGroup().getName())

View File

@ -6,7 +6,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import zone.themcgamer.core.module.Module;
import zone.themcgamer.core.module.ModuleInfo;
import zone.themcgamer.core.plugin.MGZPlugin;
import zone.themcgamer.core.traveller.ServerTraveller;
import zone.themcgamer.core.traveler.ServerTraveler;
import zone.themcgamer.data.jedis.data.server.MinecraftServer;
import zone.themcgamer.data.jedis.data.server.ServerState;
@ -27,15 +27,15 @@ import java.util.concurrent.ThreadLocalRandom;
public class ServerUpdater extends Module {
private static final long CHECK_DELAY = 60L * 20L; // 1 Minute
private final ServerTraveller traveller;
private final ServerTraveler traveler;
private boolean updatePendingRestart;
private long updateFoundTime;
private int restartDelay;
public ServerUpdater(JavaPlugin plugin, ServerTraveller traveller) {
public ServerUpdater(JavaPlugin plugin, ServerTraveler traveler) {
super(plugin);
this.traveller = traveller;
this.traveler = traveler;
// Creating the jars directory
File jarsDirectory = new File(File.separator + "home" + File.separator + "minecraft" + File.separator + "upload" + File.separator + "jars");
@ -92,7 +92,7 @@ public class ServerUpdater extends Module {
private void update() {
MinecraftServer minecraftServer = MGZPlugin.getMinecraftServer();
try {
traveller.sendAll("Hub", "&6" + minecraftServer.getName() + " &7is being updated");
traveler.sendAll("Hub", "&6" + minecraftServer.getName() + " &7is being updated");
} catch (IllegalArgumentException ignored) {}
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> minecraftServer.setState(ServerState.UPDATING), 10L);
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), Bukkit::shutdown, 40L);

View File

@ -54,7 +54,7 @@ public class Hub extends MGZPlugin {
new BasicRankComponent(),
new BasicNameComponent()
});
new KingdomManager(this, traveller);
new KingdomManager(this, traveler);
AccountManager.addMiniAccount(new DeliveryManManager(this, mySQLController, true));

View File

@ -30,13 +30,14 @@ import zone.themcgamer.core.account.Account;
import zone.themcgamer.core.account.AccountManager;
import zone.themcgamer.core.account.menu.ProfileMenu;
import zone.themcgamer.core.common.*;
import zone.themcgamer.core.cooldown.CooldownHandler;
import zone.themcgamer.core.world.MGZWorld;
import zone.themcgamer.data.jedis.cache.CacheRepository;
import zone.themcgamer.data.jedis.cache.impl.PlayerStatusCache;
import zone.themcgamer.data.jedis.repository.RedisRepository;
import zone.themcgamer.hub.Hub;
import zone.themcgamer.hub.menu.HubsMenu;
import zone.themcgamer.hub.menu.TravellerMenu;
import zone.themcgamer.hub.menu.TravelerMenu;
import zone.themcgamer.hub.menu.cosmetics.VanityMainMenu;
import java.util.ArrayList;
@ -48,8 +49,8 @@ import java.util.Optional;
* @author Braydon
*/
public class PlayerListener implements Listener {
private static final ItemStack TRAVELLER = new ItemBuilder(XMaterial.COMPASS)
.setName("§a§lTraveller §8» §7Select game")
private static final ItemStack TRAVELER = new ItemBuilder(XMaterial.COMPASS)
.setName("§a§lTraveler §8» §7Select game")
.setLore("§7Click to teleport to a game!")
.toItemStack();
private static final ItemStack HUB_SELECTOR = new ItemBuilder(XMaterial.BEACON)
@ -80,7 +81,7 @@ public class PlayerListener implements Listener {
Player player = event.getPlayer();
PlayerUtils.reset(player, true, true, GameMode.ADVENTURE);
player.getInventory().setItem(0, TRAVELLER);
player.getInventory().setItem(0, TRAVELER);
player.getInventory().setItem(1, HUB_SELECTOR);
player.getInventory().setItem(4, COSMETICS);
player.getInventory().setItem(7, SETTINGS);
@ -93,7 +94,7 @@ public class PlayerListener implements Listener {
int online = 0;
Optional<CacheRepository> cacheRepository = RedisRepository.getRepository(CacheRepository.class);
if (cacheRepository.isPresent())
online+= cacheRepository.get().getCached().stream().filter(cacheItem -> cacheItem instanceof PlayerStatusCache).count();
online += cacheRepository.get().getCached().stream().filter(cacheItem -> cacheItem instanceof PlayerStatusCache).count();
for (int i = 0; i < 5; i++)
player.sendMessage("");
@ -104,22 +105,22 @@ public class PlayerListener implements Listener {
List<BaseComponent> components = new ArrayList<>();
components.addAll(Arrays.asList(new ComponentBuilder(Style.color(" ")).create()));
components.addAll(Arrays.asList(new ComponentBuilder(Style.color("§d§lSTORE"))
.event(new ClickEvent(ClickEvent.Action.OPEN_URL,"https://store.mcgamerzone.net"))
.event(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://store.mcgamerzone.net"))
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Style.color("§dClick to visit our webstore.")).create()))
.create()));
components.addAll(Arrays.asList(new ComponentBuilder(Style.color(" §8\u25AA ")).create()));
components.addAll(Arrays.asList(new ComponentBuilder(Style.color("&e&lSITE"))
.event(new ClickEvent(ClickEvent.Action.OPEN_URL,"https://mcgamerzone.net"))
.event(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://mcgamerzone.net"))
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Style.color("&eClick to visit our website!")).create()))
.create()));
components.addAll(Arrays.asList(new ComponentBuilder(Style.color(" §8\u25AA ")).create()));
components.addAll(Arrays.asList(new ComponentBuilder(Style.color("&a&lVOTE"))
.event(new ClickEvent(ClickEvent.Action.OPEN_URL,"https://vote.mcgamerzone.net"))
.event(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://vote.mcgamerzone.net"))
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Style.color("&aClick to vote for us!")).create()))
.create()));
components.addAll(Arrays.asList(new ComponentBuilder(Style.color(" §8\u25AA ")).create()));
components.addAll(Arrays.asList(new ComponentBuilder(Style.color("&9&lDISCORD"))
.event(new ClickEvent(ClickEvent.Action.OPEN_URL,"https://discord.mcgamerzone.net"))
.event(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://discord.mcgamerzone.net"))
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Style.color("&9Click to join our community!")).create()))
.create()));
player.sendMessage(components.toArray(new BaseComponent[0]));
@ -142,8 +143,8 @@ public class PlayerListener implements Listener {
ItemStack item = event.getItem();
if (item == null)
return;
if (item.isSimilar(TRAVELLER))
new TravellerMenu(player).open();
if (item.isSimilar(TRAVELER))
new TravelerMenu(player).open();
else if (item.isSimilar(HUB_SELECTOR))
new HubsMenu(player).open();
else if (item.isSimilar(COSMETICS))
@ -189,19 +190,19 @@ public class PlayerListener implements Listener {
@EventHandler
private void onPortal(EntityPortalEnterEvent event) {
Entity entity = event.getEntity();
if (entity instanceof Player) {
Player player = (Player) entity;
MGZWorld world = MGZWorld.get(Bukkit.getWorlds().get(0));
Location spawn = world.getDataPoint("PORTAL_SPAWN");
if (spawn != null)
spawn.setYaw(MathUtils.getFacingYaw(spawn, world.getDataPoints("LOOK_AT")));
else spawn = hub.getSpawn();
player.teleport(spawn);
new TravellerMenu(player).open();
player.playSound(player.getEyeLocation(), XSound.ENTITY_PLAYER_LEVELUP.parseSound(), 0.9f, 1f);
}
if (!(entity instanceof Player))
return;
if (!CooldownHandler.canUse(((Player) entity), "Hub Portal", 500, false))
return;
Player player = (Player) entity;
MGZWorld world = MGZWorld.get(Bukkit.getWorlds().get(0));
Location spawn = world.getDataPoint("PORTAL_SPAWN");
if (spawn != null)
spawn.setYaw(MathUtils.getFacingYaw(spawn, world.getDataPoints("LOOK_AT")));
else spawn = hub.getSpawn();
player.teleport(spawn);
new TravelerMenu(player).open();
player.playSound(player.getEyeLocation(), XSound.ENTITY_PLAYER_LEVELUP.parseSound(), 0.9f, 1f);
}
@EventHandler

View File

@ -38,7 +38,7 @@ public class GameKitsMenu extends Menu {
set(0, 1, new Button(new ItemBuilder(game.getIcon(), 1)
.setName("§6§l" + game.getName())
.setLore(lore)
.toItemStack(), event -> new TravellerMenu(player).open()));
.toItemStack(), event -> new TravelerMenu(player).open()));
KitManager kitManager = Module.getModule(KitManager.class);
if (kitManager == null)

View File

@ -14,7 +14,7 @@ import zone.themcgamer.core.common.menu.MenuType;
import zone.themcgamer.core.common.menu.UpdatableMenu;
import zone.themcgamer.core.module.Module;
import zone.themcgamer.core.plugin.MGZPlugin;
import zone.themcgamer.core.traveller.ServerTraveller;
import zone.themcgamer.core.traveler.ServerTraveler;
import zone.themcgamer.data.Rank;
import zone.themcgamer.data.jedis.data.server.MinecraftServer;
@ -80,9 +80,9 @@ public class HubsMenu extends UpdatableMenu {
return;
}
close();
ServerTraveller traveller = Module.getModule(ServerTraveller.class);
if (traveller != null)
traveller.sendPlayer(player, server.getName());
ServerTraveler traveler = Module.getModule(ServerTraveler.class);
if (traveler != null)
traveler.sendPlayer(player, server.getName());
}));
}
}

View File

@ -11,7 +11,7 @@ import zone.themcgamer.core.common.menu.MenuType;
import zone.themcgamer.core.common.menu.UpdatableMenu;
import zone.themcgamer.core.game.MGZGame;
import zone.themcgamer.core.module.Module;
import zone.themcgamer.core.traveller.ServerTraveller;
import zone.themcgamer.core.traveler.ServerTraveler;
import zone.themcgamer.data.jedis.data.server.MinecraftServer;
import java.util.ArrayList;
@ -21,13 +21,13 @@ import java.util.Optional;
/**
* @author Braydon
*/
public class TravellerMenu extends UpdatableMenu {
public class TravelerMenu extends UpdatableMenu {
private static final String[] ARROW_COLORS = new String[] { "§2", "§6", "§c" };
private int arrowIndex, randomGameIndex;
public TravellerMenu(Player player) {
super(player, "Traveller", 6, MenuType.CHEST, 700L);
public TravelerMenu(Player player) {
super(player, "Traveler", 6, MenuType.CHEST, 700L);
}
@Override
@ -150,11 +150,11 @@ public class TravellerMenu extends UpdatableMenu {
private void sendToGame(MGZGame game) {
Optional<MinecraftServer> optionalMinecraftServer = game.getBestServer().filter(MinecraftServer::isRunning);
if (optionalMinecraftServer.isEmpty()) {
player.sendMessage(Style.error("Traveller", "§7There is no available game server found, please try again in a moment."));
player.sendMessage(Style.error("Traveler", "§7There is no available game server found, please try again in a moment."));
return;
}
ServerTraveller traveller = Module.getModule(ServerTraveller.class);
if (traveller != null)
traveller.sendPlayer(player, optionalMinecraftServer.get());
ServerTraveler traveler = Module.getModule(ServerTraveler.class);
if (traveler != null)
traveler.sendPlayer(player, optionalMinecraftServer.get());
}
}