Stop using static with Siege Manager
This commit is contained in:
parent
c484a80a14
commit
2c05743f62
@ -276,7 +276,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
_clanDisplay = new ClansDisplay(plugin, this);
|
||||
_clanGame = new ClansGame(plugin, this);
|
||||
_clanUtility = new ClansUtility(this);
|
||||
_tutorial = new TutorialManager(plugin, clientManager, donationManager, chat, hologramManager, _npcManager, _taskManager);
|
||||
_tutorial = new TutorialManager(plugin, clientManager, donationManager, chat, hologramManager, this, _npcManager, _taskManager);
|
||||
_itemMapManager = new ItemMapManager(this, _tutorial, _worldEvent);
|
||||
new TntGeneratorManager(plugin, this);
|
||||
new SupplyDropManager(plugin, this);
|
||||
|
@ -33,11 +33,8 @@ import net.minecraft.server.v1_8_R3.Material;
|
||||
public class SiegeManager extends MiniPlugin
|
||||
{
|
||||
private ClansManager _clansManager;
|
||||
|
||||
private OutpostManager _outpostManager;
|
||||
|
||||
public static SiegeManager Instance;
|
||||
|
||||
public NautHashMap<Integer, SiegeWeapon> LiveSiegeWeapons = new NautHashMap<>();
|
||||
public NautHashMap<Integer, SiegeWeapon> UnsyncedSiegeWeapons = new NautHashMap<>();
|
||||
|
||||
@ -55,9 +52,7 @@ public class SiegeManager extends MiniPlugin
|
||||
|
||||
_outpostManager = new OutpostManager(clans, this);
|
||||
|
||||
Instance = this;
|
||||
|
||||
_repository = new SiegeWeaponRepository(clans.getPlugin());
|
||||
_repository = new SiegeWeaponRepository(clans.getPlugin(), this);
|
||||
|
||||
_outpostManager.loadOutposts();
|
||||
|
||||
|
@ -44,23 +44,27 @@ public class SiegeWeaponRepository extends MinecraftRepository
|
||||
|
||||
private static final String DELETE_WEAPON = "DELETE FROM clansSiegeWeapons WHERE uniqueId=?;";
|
||||
|
||||
public SiegeWeaponRepository(JavaPlugin plugin)
|
||||
private SiegeManager _siegeManager;
|
||||
|
||||
public SiegeWeaponRepository(JavaPlugin plugin, SiegeManager siegeManager)
|
||||
{
|
||||
super(plugin, DBPool.getAccount());
|
||||
|
||||
_siegeManager = siegeManager;
|
||||
}
|
||||
|
||||
public void deleteWeapon(final int uniqueId)
|
||||
{
|
||||
System.out.println("Siege Repo> Deleting weapon " + uniqueId);
|
||||
|
||||
SiegeManager.Instance.runAsync(() ->
|
||||
_siegeManager.runAsync(() ->
|
||||
executeUpdate(DELETE_WEAPON, new ColumnInt("uniqueId", uniqueId))
|
||||
);
|
||||
}
|
||||
|
||||
public void getWeaponById(final int uniqueId, final Callback<SiegeWeaponToken> callback)
|
||||
{
|
||||
SiegeManager.Instance.runAsync(() ->
|
||||
_siegeManager.runAsync(() ->
|
||||
executeQuery(GET_WEAPON_BY_ID, resultSet -> {
|
||||
SiegeWeaponToken token = new SiegeWeaponToken();
|
||||
|
||||
@ -75,7 +79,7 @@ public class SiegeWeaponRepository extends MinecraftRepository
|
||||
|
||||
public void getWeaponsByServer(final int serverId, final Callback<List<SiegeWeaponToken>> callback)
|
||||
{
|
||||
SiegeManager.Instance.runAsync(() ->
|
||||
_siegeManager.runAsync(() ->
|
||||
executeQuery(GET_WEAPONS_BY_SERVER, resultSet -> {
|
||||
List<SiegeWeaponToken> tokens = Lists.newArrayList();
|
||||
|
||||
@ -95,7 +99,7 @@ public class SiegeWeaponRepository extends MinecraftRepository
|
||||
|
||||
public void getWeaponsByClan(final ClanInfo clan, final Callback<List<SiegeWeaponToken>> callback)
|
||||
{
|
||||
SiegeManager.Instance.runAsync(() ->
|
||||
_siegeManager.runAsync(() ->
|
||||
executeQuery(GET_WEAPONS_BY_CLAN, resultSet -> {
|
||||
List<SiegeWeaponToken> tokens = Lists.newArrayList();
|
||||
|
||||
@ -117,7 +121,7 @@ public class SiegeWeaponRepository extends MinecraftRepository
|
||||
{
|
||||
token.UniqueId = columns.getInt("uniqueId");
|
||||
token.Location = UtilWorld.strToLoc(columns.getString("location"));
|
||||
token.OwnerClan = SiegeManager.Instance.getClansManager().getClanUtility().getClanById(columns.getInt("ownerClan"));
|
||||
token.OwnerClan = _siegeManager.getClansManager().getClanUtility().getClanById(columns.getInt("ownerClan"));
|
||||
token.WeaponType = columns.getByte("weaponType");
|
||||
token.Health = columns.getShort("health");
|
||||
token.Yaw = columns.getShort("yaw");
|
||||
@ -131,7 +135,7 @@ public class SiegeWeaponRepository extends MinecraftRepository
|
||||
{
|
||||
System.out.println("Siege Repo> Updating weapon " + token.UniqueId);
|
||||
|
||||
SiegeManager.Instance.runAsync(() ->
|
||||
_siegeManager.runAsync(() ->
|
||||
executeUpdate(UPDATE_WEAPON,
|
||||
new ColumnInt("health", token.Health),
|
||||
new ColumnInt("yaw", token.Yaw),
|
||||
@ -144,10 +148,10 @@ public class SiegeWeaponRepository extends MinecraftRepository
|
||||
{
|
||||
System.out.println("Siege Repo> Inserting new weapon " + token.UniqueId);
|
||||
|
||||
SiegeManager.Instance.runAsync(() ->
|
||||
_siegeManager.runAsync(() ->
|
||||
executeUpdate(INSERT_WEAPON,
|
||||
new ColumnInt("uniqueId", token.UniqueId),
|
||||
new ColumnInt("serverId", SiegeManager.Instance.getClansManager().getServerId()),
|
||||
new ColumnInt("serverId", _siegeManager.getClansManager().getServerId()),
|
||||
new ColumnVarChar("location", 30, UtilWorld.locToStr(token.Location)),
|
||||
new ColumnInt("ownerClan", token.OwnerClan.getId()),
|
||||
new ColumnInt("weaponType", token.WeaponType),
|
||||
@ -192,7 +196,7 @@ public class SiegeWeaponRepository extends MinecraftRepository
|
||||
@Override
|
||||
protected void initialize()
|
||||
{
|
||||
SiegeManager.Instance.runAsync(() ->
|
||||
_siegeManager.runAsync(() ->
|
||||
executeUpdate(CREATE)
|
||||
);
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ 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.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.siege.SiegeManager;
|
||||
import mineplex.game.clans.message.ClansMessageManager;
|
||||
import mineplex.game.clans.tutorial.command.TutorialCommand;
|
||||
import mineplex.game.clans.tutorial.gui.TutorialShop;
|
||||
@ -37,7 +39,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, TaskManager taskManager)
|
||||
public TutorialManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, Chat chat, HologramManager hologram, ClansManager clansManager, NpcManager npcManager, TaskManager taskManager)
|
||||
{
|
||||
super("Clans Tutorial", plugin);
|
||||
|
||||
@ -48,7 +50,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, taskManager));
|
||||
addTutorial(TutorialType.MAIN, new ClansMainTutorial(plugin, clansManager, _clansMessageManager, hologram, npcManager, taskManager));
|
||||
|
||||
chat.AddFilter(event -> {
|
||||
if (inTutorial(event.getPlayer()))
|
||||
|
@ -3,19 +3,14 @@ package mineplex.game.clans.tutorial.tutorials.clans;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
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;
|
||||
import mineplex.game.clans.clans.event.PreEnergyShopBuyEvent;
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -30,17 +25,30 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.task.TaskManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent;
|
||||
import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent;
|
||||
import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent;
|
||||
import mineplex.game.clans.clans.event.PreEnergyShopBuyEvent;
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import mineplex.game.clans.clans.siege.SiegeManager;
|
||||
import mineplex.game.clans.economy.GoldManager;
|
||||
import mineplex.game.clans.message.ClansMessageManager;
|
||||
import mineplex.game.clans.spawn.Spawn;
|
||||
@ -57,8 +65,6 @@ 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
|
||||
{
|
||||
@ -79,7 +85,7 @@ public class ClansMainTutorial extends Tutorial
|
||||
);
|
||||
|
||||
|
||||
public ClansMainTutorial(JavaPlugin plugin, ClansMessageManager message, HologramManager hologram, NpcManager npcManager, TaskManager taskManager)
|
||||
public ClansMainTutorial(JavaPlugin plugin, ClansManager clansManager, ClansMessageManager message, HologramManager hologram, NpcManager npcManager, TaskManager taskManager)
|
||||
{
|
||||
super(plugin, message, hologram, "Clans Tutorial", "main", Material.DIAMOND_SWORD, (byte) 0);
|
||||
|
||||
@ -100,7 +106,7 @@ public class ClansMainTutorial extends Tutorial
|
||||
// _repository = new TutorialRepository(ClansManager.getInstance().getClientManager());
|
||||
|
||||
addObjective(new ClanObjective(this, plugin));
|
||||
addObjective(new AttackEnemyObjective(this, plugin));
|
||||
addObjective(new AttackEnemyObjective(this, clansManager, plugin));
|
||||
addObjective(new ShopsObjective(this, npcManager, plugin));
|
||||
addObjective(new PurchaseItemsObjective(this, plugin));
|
||||
addObjective(new ClassesObjective(this, plugin));
|
||||
|
@ -30,6 +30,8 @@ import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.siege.SiegeManager;
|
||||
import mineplex.game.clans.clans.siege.weapon.Cannon;
|
||||
import mineplex.game.clans.tutorial.TutorialRegion;
|
||||
import mineplex.game.clans.tutorial.TutorialSession;
|
||||
@ -49,7 +51,7 @@ public class AttackEnemyObjective extends OrderedObjective<ClansMainTutorial>
|
||||
|
||||
private DefaultHashMap<String, List<Zombie>> _shooters;
|
||||
|
||||
public AttackEnemyObjective(ClansMainTutorial clansMainTutorial, JavaPlugin javaPlugin)
|
||||
public AttackEnemyObjective(ClansMainTutorial clansMainTutorial, ClansManager clansManager, JavaPlugin javaPlugin)
|
||||
{
|
||||
super(clansMainTutorial, javaPlugin, "Enemy Clans Tutorial", "Attack and raid this enemy!");
|
||||
|
||||
@ -66,7 +68,7 @@ public class AttackEnemyObjective extends OrderedObjective<ClansMainTutorial>
|
||||
40
|
||||
));
|
||||
addGoal(new ClanInfoGoal(this));
|
||||
addGoal(new MountCannonGoal(this));
|
||||
addGoal(new MountCannonGoal(this, clansManager));
|
||||
addGoal(new LoadCannonGoal(this));
|
||||
addGoal(new BlowUpWallGoal(this));
|
||||
addGoal(new StealEnemyPotatoesGoal(this));
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.siege.SiegeManager;
|
||||
import mineplex.game.clans.clans.siege.events.MountSiegeWeaponEvent;
|
||||
import mineplex.game.clans.clans.siege.weapon.Cannon;
|
||||
@ -21,7 +22,9 @@ import mineplex.game.clans.tutorial.tutorials.clans.objective.AttackEnemyObjecti
|
||||
|
||||
public class MountCannonGoal extends ObjectiveGoal<AttackEnemyObjective>
|
||||
{
|
||||
public MountCannonGoal(AttackEnemyObjective objective)
|
||||
private ClansManager _clansManager;
|
||||
|
||||
public MountCannonGoal(AttackEnemyObjective objective, ClansManager clansManager)
|
||||
{
|
||||
super(
|
||||
objective,
|
||||
@ -31,12 +34,14 @@ public class MountCannonGoal extends ObjectiveGoal<AttackEnemyObjective>
|
||||
+ "TNT Cannons are the best way to do destroy enemy bases!",
|
||||
DyeColor.BLACK
|
||||
);
|
||||
|
||||
_clansManager = clansManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customStart(Player player)
|
||||
{
|
||||
getObjective().getCannons().put(player.getName(), SiegeManager.Instance.spawnCannon(player, getObjective().getPlugin().getPoint(getObjective().getPlugin().getRegion(player), Point.CANNON), false));
|
||||
getObjective().getCannons().put(player.getName(), _clansManager.getSiegeManager().spawnCannon(player, getObjective().getPlugin().getPoint(getObjective().getPlugin().getRegion(player), Point.CANNON), false));
|
||||
getObjective().getCannons().get(player.getName()).SetForcedVelocity(0.4, 2.45);
|
||||
getObjective().getCannons().get(player.getName()).setInvincible(true);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user