A lot of bug fixes

This commit is contained in:
Shaun Bennett 2016-04-04 16:45:20 +10:00
parent 543719b95d
commit 02f774ce94
8 changed files with 79 additions and 73 deletions

View File

@ -175,8 +175,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
private ClansBlacklist _blacklist;
private Playtime _playTracker;
private mineplex.game.clans.legacytutorial.TutorialManager _tutorialManager;
private TutorialManager _tutorial;
private mineplex.game.clans.legacytutorial.TutorialManager _legacyTutorial;
private ClassManager _classManager;
@ -197,6 +198,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
private WarPointEvasion _warPointEvasion;
private ObserverManager _observerManager;
private Punish _punish;
private TaskManager _taskManager;
private int _inviteExpire = 2;
private int _nameMin = 3;
@ -258,7 +260,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
_worldEvent = new WorldEventManager(plugin, this, _damageManager, _lootManager, blockRestore, _clanRegions, null);
TaskManager taskManager = new TaskManager(plugin, _clientManager, webServerAddress);
_taskManager = new TaskManager(plugin, _clientManager, webServerAddress);
ClanTips = new ClanTips(plugin, this, preferencesManager);
@ -269,8 +271,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
_clanDisplay = new ClansDisplay(plugin, this);
_clanGame = new ClansGame(plugin, this);
_clanUtility = new ClansUtility(this);
TutorialManager tutorial = new TutorialManager(plugin, clientManager, donationManager, chat, hologramManager, _npcManager);
_itemMapManager = new ItemMapManager(this, tutorial, _worldEvent);
_tutorial = new TutorialManager(plugin, clientManager, donationManager, chat, hologramManager, _npcManager, _taskManager);
_itemMapManager = new ItemMapManager(this, _tutorial, _worldEvent);
new TntGeneratorManager(plugin, this);
new SupplyDropManager(plugin, this);
@ -300,7 +302,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
new ClanEnergyTracker(plugin, this);
// new StuckManager(this);
new ClansBetaManager(this, taskManager);
new ClansBetaManager(this, _taskManager);
new PotatoManager(plugin, this);
@ -334,9 +336,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
_playTracker = new Playtime(this, statsManager);
_tutorialManager = new mineplex.game.clans.legacytutorial.TutorialManager(plugin, _playTracker, _goldManager, taskManager, donationManager, preferencesManager, this, packetHandler);
_legacyTutorial = new mineplex.game.clans.legacytutorial.TutorialManager(plugin, _playTracker, _goldManager, _taskManager, donationManager, preferencesManager, this, packetHandler);
_scoreboard = new ClansScoreboardManager(plugin, this, _warManager, _worldEvent, tutorial, clientManager, donationManager);
_scoreboard = new ClansScoreboardManager(plugin, this, _warManager, _worldEvent, _tutorial, clientManager, donationManager);
_clanDataAccess = new ClansDataAccessLayer(this, _scoreboard);
for (ClanToken token : _clanDataAccess.getRepository().retrieveClans())
@ -436,9 +438,14 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
return _disguiseManager;
}
public mineplex.game.clans.legacytutorial.TutorialManager getTutorials()
public mineplex.game.clans.legacytutorial.TutorialManager getLegacyTutorial()
{
return _tutorialManager;
return _legacyTutorial;
}
public TutorialManager getTutorial()
{
return _tutorial;
}
public NpcManager getNPCManager()
@ -598,7 +605,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
for (Player other : UtilServer.getPlayers())
{
if (_tutorialManager.isInTutorial(other))
if (_tutorial.inTutorial(other))
{
// Don't display join message if player in tutorial.
continue;
@ -621,7 +628,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
for (Player other : UtilServer.getPlayers())
{
if (_tutorialManager.isInTutorial(other))
if (_tutorial.inTutorial(other))
{
// Don't display quit message if player in tutorial.
continue;
@ -646,7 +653,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
for (Player other : UtilServer.getPlayers())
{
if (_tutorialManager.isInTutorial(other))
if (_tutorial.inTutorial(other))
{
// Don't display leave message if player in tutorial.
continue;
@ -1170,16 +1177,10 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
}
Rank rank = _clientManager.Get(event.getPlayer()).GetRank();
if (!event.getPlayer().isOp() && !event.getPlayer().isWhitelisted() && !rank.has(Rank.LEGEND))
if (UtilServer.getPlayers().length >= UtilServer.getServer().getMaxPlayers() && !rank.has(Rank.ADMIN) && !event.getPlayer().isWhitelisted() && !event.getPlayer().isOp())
{
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Clans is currently in Legend+ only Alpha!");
// event.setKickMessage("This server is whitelisted!");
event.setKickMessage("Clans is currently in Legend+ only Alpha!");
}
else if (UtilServer.getPlayers().length >= UtilServer.getServer().getMaxPlayers() && !rank.has(Rank.ADMIN) && !event.getPlayer().isWhitelisted() && !event.getPlayer().isOp())
{
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Clans Alpha is full! Try again soon");
event.setKickMessage("Clans Alpha is full! Try again soon");
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Clans Beta is full! Try again soon");
event.setKickMessage("Clans Beta is full! Try again soon");
}
}

View File

@ -69,7 +69,7 @@ public class ClansRegions extends MiniPlugin
claimArea("Spawn", SPAWN_RADIUS, 0, false, true, new Location[] { Spawn.getNorthSpawn(), Spawn.getSouthSpawn() });
claimArea("Shops", 2, 0, true, false, new Location[]{Spawn.getWestTownCenter(), Spawn.getEastTownCenter()});
claimArea("Shops", SHOP_RADIUS, 2, false, false, new Location[]{Spawn.getWestTownCenter(), Spawn.getEastTownCenter()});
claimArea("Shops", SHOP_RADIUS, 3, false, false, new Location[]{Spawn.getWestTownCenter(), Spawn.getEastTownCenter()});
// Initialize Fields and Borderlands factions and claims
claimArea("Fields", FIELDS_RADIUS, 0, false, true, worldCenter);
@ -149,34 +149,16 @@ public class ClansRegions extends MiniPlugin
{
if (clan != null)
{
_manager.getClanDataAccess().delete(clan, status -> {
_manager.getClanDataAccess().create("ClansRegions", clanName, true, new Callback<ClanInfo>()
{
@Override
public void run(ClanInfo data)
{
if (data != null)
{
for (Location location : locations)
{
claimArea(data, location, chunkRadius, claimOffset, addNegative, safe);
log(String.format("Initialized %s faction territory and creation!", clanName));
}
debugClan(clanName);
}
else
{
System.out.println("Clans Regions error!");
System.out.println("Seek out help!");
}
}
});
});
for (Location location : locations)
{
claimArea(clan, location, chunkRadius, claimOffset, addNegative, safe);
log(String.format("Initialized %s faction territory and creation!", clanName));
}
debugClan(clanName);
return;
}
_manager.getClanDataAccess().create("ClansRegions", clanName, true, new Callback<ClanInfo>()
{
@Override

View File

@ -186,7 +186,7 @@ public class KingHill extends WorldEvent
public void announceStart()
{
for(Player player : UtilServer.getPlayers()) {
if(_clansManager.getTutorials().isInTutorial(player)) continue;
if(_clansManager.getTutorial().inTutorial(player)) continue;
UtilTextMiddle.display(C.cGreen + getName(), UtilWorld.locToStrClean(getCenterLocation()), 10, 100, 40, player);
player.sendMessage(F.main("Event", F.elem(getName()) + " has started at coordinates " + F.elem(UtilWorld.locToStrClean(getCenterLocation()))));

View File

@ -511,7 +511,7 @@ public class UndeadCamp extends WorldEvent
public void announceStart()
{
for(Player player : UtilServer.getPlayers()) {
if(ClansManager.getInstance().getTutorials().isInTutorial(player)) continue;
if(ClansManager.getInstance().getTutorial().inTutorial(player)) continue;
UtilTextMiddle.display(C.cGreen + getName(), UtilWorld.locToStrClean(getCenterLocation()), 10, 100, 40, player);
player.sendMessage(F.main("Event", F.elem(getName()) + " has started at coordinates " + F.elem(UtilWorld.locToStrClean(getCenterLocation()))));

View File

@ -281,10 +281,7 @@ public class Spawn extends MiniPlugin
event.setRespawnLocation(getSpawnLocation());
}
/**
* Ensure player spawns into a Spawn location if it's their first time on the server.
* @param event
*/
/*
@EventHandler
public void onPlayerFirstJoin(PlayerJoinEvent event)
{
@ -293,6 +290,7 @@ public class Spawn extends MiniPlugin
teleport(event.getPlayer(), getSpawnLocation(), 2); // Teleport player to spawn after 2-tick delay to prevent on-join bug
}
}
*/
/**
* Prevent creatures from spawning inside Spawn
@ -493,7 +491,7 @@ public class Spawn extends MiniPlugin
return _clansManager.getCondition().HasCondition(player, ConditionType.CUSTOM, COMBAT_TAG_NAME);
}
private void teleport(final Player player, final Location location, int delay)
public void teleport(final Player player, final Location location, int delay)
{
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() {
@Override

View File

@ -81,10 +81,12 @@ public abstract class Tutorial implements Listener, ObjectiveListener
session.setRegion(region);
_playerSessionMap.put(player, session);
onStart(player);
// Start at first objective!
setObjective(player, 0);
onStart(player);
_objectives.forEach(objective -> objective.setup(player, region));
}

View File

@ -22,6 +22,7 @@ import mineplex.core.hologram.HologramManager;
import mineplex.core.npc.NpcManager;
import mineplex.core.scoreboard.ScoreboardManager;
import mineplex.core.scoreboard.elements.ScoreboardElement;
import mineplex.core.task.TaskManager;
import mineplex.game.clans.message.ClansMessageManager;
import mineplex.game.clans.tutorial.command.TutorialCommand;
import mineplex.game.clans.tutorial.gui.TutorialShop;
@ -36,7 +37,7 @@ public class TutorialManager extends MiniPlugin implements ScoreboardElement
private EnumMap<TutorialType, Tutorial> _tutorialMap;
private EnumMap<TutorialType, TutorialShop> _shopMap; // Don't need to do anything with shops currently
public TutorialManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, Chat chat, HologramManager hologram, NpcManager npcManager)
public TutorialManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, Chat chat, HologramManager hologram, NpcManager npcManager, TaskManager taskManager)
{
super("Clans Tutorial", plugin);
@ -47,7 +48,7 @@ public class TutorialManager extends MiniPlugin implements ScoreboardElement
_tutorialMap = new EnumMap<TutorialType, Tutorial>(TutorialType.class);
_shopMap = new EnumMap<TutorialType, TutorialShop>(TutorialType.class);
addTutorial(TutorialType.MAIN, new ClansMainTutorial(plugin, _clansMessageManager, hologram, npcManager));
addTutorial(TutorialType.MAIN, new ClansMainTutorial(plugin, _clansMessageManager, hologram, npcManager, taskManager));
chat.AddFilter(event -> {
if (inTutorial(event.getPlayer()))

View File

@ -8,6 +8,7 @@ import java.util.UUID;
import mineplex.core.hologram.Hologram;
import mineplex.core.common.util.*;
import mineplex.core.task.TaskManager;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent;
import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent;
@ -38,6 +39,7 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent;
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.message.ClansMessageManager;
import mineplex.game.clans.spawn.Spawn;
import mineplex.game.clans.tutorial.Tutorial;
@ -53,6 +55,7 @@ import mineplex.game.clans.tutorial.tutorials.clans.objective.FieldsObjective;
import mineplex.game.clans.tutorial.tutorials.clans.objective.FinalObjective;
import mineplex.game.clans.tutorial.tutorials.clans.objective.PurchaseItemsObjective;
import mineplex.game.clans.tutorial.tutorials.clans.objective.ShopsObjective;
import mineplex.game.clans.tutorial.tutorials.clans.repository.TutorialRepository;
//import mineplex.game.clans.tutorial.tutorials.clans.repository.TutorialRepository;
public class ClansMainTutorial extends Tutorial
@ -63,10 +66,11 @@ public class ClansMainTutorial extends Tutorial
private TutorialMapManager _mapManager;
private List<Player> _fireworks;
// private TutorialRepository _repository;
private TaskManager _taskManager;
public ClansMainTutorial(JavaPlugin plugin, ClansMessageManager message, HologramManager hologram, NpcManager npcManager)
public ClansMainTutorial(JavaPlugin plugin, ClansMessageManager message, HologramManager hologram, NpcManager npcManager, TaskManager taskManager)
{
super(plugin, message, hologram, "Clans Tutorial", "Clans.MainTutorial", Material.DIAMOND_SWORD, (byte) 0);
super(plugin, message, hologram, "Clans Tutorial", "main", Material.DIAMOND_SWORD, (byte) 0);
_fireworks = new ArrayList<Player>();
@ -80,6 +84,7 @@ public class ClansMainTutorial extends Tutorial
}
_mapManager = new TutorialMapManager(plugin, this, getWorldManager().getTutorialWorld(), -10, 0, 117, 127);
_taskManager = taskManager;
// _repository = new TutorialRepository(ClansManager.getInstance().getClientManager());
@ -98,11 +103,12 @@ public class ClansMainTutorial extends Tutorial
{
_fireworks.add(player);
UtilTextMiddle.display(C.cYellow + "Congratulations", "You have completed the Tutorial!", 10, 60, 10, player);
Bukkit.getScheduler().runTaskLater(getPlugin(), () -> {
_fireworks.remove(player);
getMessage().removePlayer(player);
getMessage().removePlayer(player);
player.teleport(Spawn.getNorthSpawn());
player.teleport(Spawn.getNorthSpawn());
UtilInv.Clear(player);
ClansManager.getInstance().getItemMapManager().setMap(player);
@ -112,6 +118,17 @@ public class ClansMainTutorial extends Tutorial
//ClansManager.getInstance().getPvpTimer().unpause(player);
_taskManager.completedTask(new Callback<Boolean>()
{
@Override
public void run(Boolean data)
{
GoldManager.getInstance().addGold(player, 32000);
UtilPlayer.message(player, F.main("Clans", "You have earned " + F.elem(32000 + " Gold") + " for finishing the tutorial!"));
}
}, player, getTaskIdentifier());
/*
ClansManager.getInstance().runAsync(() -> {
_repository.SetTimesPlayed(player.getUniqueId(), _repository.GetTimesPlayed(player.getUniqueId()) + 1);
@ -124,7 +141,7 @@ public class ClansMainTutorial extends Tutorial
if (times == 1)
{
GoldManager.getInstance().addGold(player, 32000);
UtilPlayer.message(player, F.main("Clans", "You have recieved " + F.elem(32000 + " Gold") + " for finishing the tutorial!"));
UtilPlayer.message(player, F.main("Clans", "You have earned " + F.elem(32000 + " Gold") + " for finishing the tutorial!"));
}
UtilInv.give(player, Material.COOKIE);
@ -424,16 +441,21 @@ public class ClansMainTutorial extends Tutorial
@EventHandler
public void onJoin(PlayerJoinEvent event)
{
start(event.getPlayer());
// ClansManager.getInstance().runAsync(() -> {
// if (_repository.GetTimesPlayed(event.getPlayer().getUniqueId()) == 0)
// {
// ClansManager.getInstance().runSync(() -> start(event.getPlayer()));
// }
// });
/*
ClansManager.getInstance().runAsync(() -> {
if (_repository.GetTimesPlayed(event.getPlayer().getUniqueId()) == 0)
{
ClansManager.getInstance().runSync(() -> start(event.getPlayer()));
}
});
*/
if (!_taskManager.hasCompletedTask(event.getPlayer(), getTaskIdentifier()))
{
start(event.getPlayer());
}
else if (!event.getPlayer().hasPlayedBefore() || !event.getPlayer().getLocation().getWorld().equals(Spawn.getSpawnWorld()))
{
Spawn.getInstance().teleport(event.getPlayer(), Spawn.getInstance().getSpawnLocation(), 2);
}
}
@EventHandler