commit
67adf94341
@ -27,20 +27,20 @@ public class DonationRepository extends MinecraftRepository
|
|||||||
private static String CREATE_GEM_TRANSACTION_TABLE = "CREATE TABLE IF NOT EXISTS accountGemTransactions (id INT NOT NULL AUTO_INCREMENT, accountId INT, reason VARCHAR(100), gems INT, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id));";
|
private static String CREATE_GEM_TRANSACTION_TABLE = "CREATE TABLE IF NOT EXISTS accountGemTransactions (id INT NOT NULL AUTO_INCREMENT, accountId INT, reason VARCHAR(100), gems INT, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id));";
|
||||||
private static String INSERT_COIN_TRANSACTION = "INSERT INTO accountCoinTransactions(accountId, reason, coins) VALUES(?, ?, ?);";
|
private static String INSERT_COIN_TRANSACTION = "INSERT INTO accountCoinTransactions(accountId, reason, coins) VALUES(?, ?, ?);";
|
||||||
private static String UPDATE_ACCOUNT_COINS = "UPDATE accounts SET coins = coins + ? WHERE id = ?;";
|
private static String UPDATE_ACCOUNT_COINS = "UPDATE accounts SET coins = coins + ? WHERE id = ?;";
|
||||||
private static String UPDATE_ACCOUNT_GOLD = "UPDATE accounts SET gold = gold + ? WHERE id = ?;";
|
private static String UPDATE_ACCOUNT_GOLD = "UPDATE accounts SET gold = gold + ? WHERE id = ? && gold >= ?;";
|
||||||
private static String SET_ACCOUNT_GOLD = "UPDATE accounts SET gold = ? WHERE id = ?;";
|
private static String SET_ACCOUNT_GOLD = "UPDATE accounts SET gold = ? WHERE id = ?;";
|
||||||
private static String UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_ = "UPDATE accounts SET gems = ?, coins = ? WHERE id = ? AND gems IS NULL AND coins IS NULL;";
|
private static String UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_ = "UPDATE accounts SET gems = ?, coins = ? WHERE id = ? AND gems IS NULL AND coins IS NULL;";
|
||||||
|
|
||||||
private String _webAddress;
|
private String _webAddress;
|
||||||
|
|
||||||
public DonationRepository(JavaPlugin plugin, String webAddress)
|
public DonationRepository(JavaPlugin plugin, String webAddress)
|
||||||
{
|
{
|
||||||
super(plugin, DBPool.getAccount());
|
super(plugin, DBPool.getAccount());
|
||||||
|
|
||||||
_webAddress = webAddress;
|
_webAddress = webAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PurchaseKnownSalesPackage(final Callback<TransactionResponse> callback, String name, final String uuid, final int cost, final int salesPackageId)
|
public void PurchaseKnownSalesPackage(final Callback<TransactionResponse> callback, String name, final String uuid, final int cost, final int salesPackageId)
|
||||||
{
|
{
|
||||||
final PurchaseToken token = new PurchaseToken();
|
final PurchaseToken token = new PurchaseToken();
|
||||||
token.AccountName = name;
|
token.AccountName = name;
|
||||||
@ -61,7 +61,7 @@ public class DonationRepository extends MinecraftRepository
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
handleDatabaseCall(new DatabaseRunnable(new Runnable()
|
handleDatabaseCall(new DatabaseRunnable(new Runnable()
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
@ -70,7 +70,7 @@ public class DonationRepository extends MinecraftRepository
|
|||||||
}
|
}
|
||||||
}), "Error purchasing known sales package in DonationRepository : ");
|
}), "Error purchasing known sales package in DonationRepository : ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PurchaseUnknownSalesPackage(final Callback<TransactionResponse> callback, final String name, final int accountId, final String packageName, final CurrencyType currencyType, final int cost)
|
public void PurchaseUnknownSalesPackage(final Callback<TransactionResponse> callback, final String name, final int accountId, final String packageName, final CurrencyType currencyType, final int cost)
|
||||||
{
|
{
|
||||||
final UnknownPurchaseToken token = new UnknownPurchaseToken();
|
final UnknownPurchaseToken token = new UnknownPurchaseToken();
|
||||||
@ -96,7 +96,7 @@ public class DonationRepository extends MinecraftRepository
|
|||||||
executeUpdate(UPDATE_ACCOUNT_GOLD, new ColumnInt("gold", -cost), new ColumnInt("id", accountId));
|
executeUpdate(UPDATE_ACCOUNT_GOLD, new ColumnInt("gold", -cost), new ColumnInt("id", accountId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable()
|
Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -107,7 +107,7 @@ public class DonationRepository extends MinecraftRepository
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
handleDatabaseCall(new DatabaseRunnable(new Runnable()
|
handleDatabaseCall(new DatabaseRunnable(new Runnable()
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
@ -116,18 +116,18 @@ public class DonationRepository extends MinecraftRepository
|
|||||||
}
|
}
|
||||||
}), "Error purchasing unknown sales package in DonationRepository : ");
|
}), "Error purchasing unknown sales package in DonationRepository : ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void gemReward(final Callback<Boolean> callback, final String giver, String name, final String uuid, final int greenGems)
|
public void gemReward(final Callback<Boolean> callback, final String giver, String name, final String uuid, final int greenGems)
|
||||||
{
|
{
|
||||||
final GemRewardToken token = new GemRewardToken();
|
final GemRewardToken token = new GemRewardToken();
|
||||||
token.Source = giver;
|
token.Source = giver;
|
||||||
token.Name = name;
|
token.Name = name;
|
||||||
token.Amount = greenGems;
|
token.Amount = greenGems;
|
||||||
|
|
||||||
final Callback<Boolean> extraCallback = new Callback<Boolean>()
|
final Callback<Boolean> extraCallback = new Callback<Boolean>()
|
||||||
{
|
{
|
||||||
public void run(final Boolean response)
|
public void run(final Boolean response)
|
||||||
{
|
{
|
||||||
Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable()
|
Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -138,7 +138,7 @@ public class DonationRepository extends MinecraftRepository
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
handleDatabaseCall(new DatabaseRunnable(new Runnable()
|
handleDatabaseCall(new DatabaseRunnable(new Runnable()
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
@ -147,14 +147,14 @@ public class DonationRepository extends MinecraftRepository
|
|||||||
}
|
}
|
||||||
}), "Error updating player gem amount in DonationRepository : ");
|
}), "Error updating player gem amount in DonationRepository : ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rewardCoins(final Callback<Boolean> callback, final String giver, String name, final int accountId, final int coins)
|
public void rewardCoins(final Callback<Boolean> callback, final String giver, String name, final int accountId, final int coins)
|
||||||
{
|
{
|
||||||
final GemRewardToken token = new GemRewardToken();
|
final GemRewardToken token = new GemRewardToken();
|
||||||
token.Source = giver;
|
token.Source = giver;
|
||||||
token.Name = name;
|
token.Name = name;
|
||||||
token.Amount = coins;
|
token.Amount = coins;
|
||||||
|
|
||||||
final Callback<Boolean> extraCallback = new Callback<Boolean>()
|
final Callback<Boolean> extraCallback = new Callback<Boolean>()
|
||||||
{
|
{
|
||||||
public void run(final Boolean response)
|
public void run(final Boolean response)
|
||||||
@ -164,7 +164,7 @@ public class DonationRepository extends MinecraftRepository
|
|||||||
//executeUpdate(UPDATE_ACCOUNT_COINS, new ColumnInt("coins", coins), new ColumnInt("id", accountId));
|
//executeUpdate(UPDATE_ACCOUNT_COINS, new ColumnInt("coins", coins), new ColumnInt("id", accountId));
|
||||||
//executeUpdate(INSERT_COIN_TRANSACTION, new ColumnInt("id", accountId), new ColumnVarChar("reason", 100, "Rewarded by " + giver), new ColumnInt("coins", coins));
|
//executeUpdate(INSERT_COIN_TRANSACTION, new ColumnInt("id", accountId), new ColumnVarChar("reason", 100, "Rewarded by " + giver), new ColumnInt("coins", coins));
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable()
|
Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -175,7 +175,7 @@ public class DonationRepository extends MinecraftRepository
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
handleDatabaseCall(new DatabaseRunnable(new Runnable()
|
handleDatabaseCall(new DatabaseRunnable(new Runnable()
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
@ -184,21 +184,26 @@ public class DonationRepository extends MinecraftRepository
|
|||||||
}
|
}
|
||||||
}), "Error updating player coin amount in DonationRepository : ");
|
}), "Error updating player coin amount in DonationRepository : ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rewardGold(final Callback<Boolean> callback, final String giver, final String name, final int accountId, final int gold)
|
public void rewardGold(final Callback<Boolean> callback, final String giver, final String name, final int accountId, final int gold)
|
||||||
{
|
{
|
||||||
handleDatabaseCall(new DatabaseRunnable(new Runnable()
|
handleDatabaseCall(new DatabaseRunnable(new Runnable()
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
boolean success = executeUpdate(UPDATE_ACCOUNT_GOLD, new ColumnInt("gold", gold), new ColumnInt("id", accountId)) > 0;
|
ColumnInt min = new ColumnInt("gold", gold < 0 ? -gold : 0);
|
||||||
|
boolean success = executeUpdate(UPDATE_ACCOUNT_GOLD, new ColumnInt("gold", gold), new ColumnInt("id", accountId), min) > 0;
|
||||||
callback.run(success);
|
callback.run(success);
|
||||||
}
|
}
|
||||||
}), "Error updating player gold amount in DonationRepository : ");
|
}), "Error updating player gold amount in DonationRepository : ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGold(final Callback<Boolean> callback, final String giver, final String name, final int accountId, final int gold)
|
public void setGold(final Callback<Boolean> callback, final String giver, final String name, final int accountId, final int gold)
|
||||||
{
|
{
|
||||||
|
if (gold < 0)
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("gold cannot be negative");
|
||||||
|
}
|
||||||
handleDatabaseCall(new DatabaseRunnable(new Runnable()
|
handleDatabaseCall(new DatabaseRunnable(new Runnable()
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
@ -208,7 +213,7 @@ public class DonationRepository extends MinecraftRepository
|
|||||||
}
|
}
|
||||||
}), "Error updating player gold amount in DonationRepository : ");
|
}), "Error updating player gold amount in DonationRepository : ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initialize()
|
protected void initialize()
|
||||||
{
|
{
|
||||||
@ -240,12 +245,12 @@ public class DonationRepository extends MinecraftRepository
|
|||||||
public Donor retrieveDonorInfo(ResultSet resultSet) throws SQLException
|
public Donor retrieveDonorInfo(ResultSet resultSet) throws SQLException
|
||||||
{
|
{
|
||||||
Donor donor = new Donor();
|
Donor donor = new Donor();
|
||||||
|
|
||||||
while (resultSet.next())
|
while (resultSet.next())
|
||||||
{
|
{
|
||||||
donor.setGold(resultSet.getInt(1));
|
donor.setGold(resultSet.getInt(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
return donor;
|
return donor;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -276,7 +276,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
|||||||
_clanDisplay = new ClansDisplay(plugin, this);
|
_clanDisplay = new ClansDisplay(plugin, this);
|
||||||
_clanGame = new ClansGame(plugin, this);
|
_clanGame = new ClansGame(plugin, this);
|
||||||
_clanUtility = new ClansUtility(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);
|
_itemMapManager = new ItemMapManager(this, _tutorial, _worldEvent);
|
||||||
new TntGeneratorManager(plugin, this);
|
new TntGeneratorManager(plugin, this);
|
||||||
new SupplyDropManager(plugin, this);
|
new SupplyDropManager(plugin, this);
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package mineplex.game.clans.clans.siege;
|
package mineplex.game.clans.clans.siege;
|
||||||
|
|
||||||
import java.util.Stack;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -23,7 +21,6 @@ import mineplex.core.common.util.UtilTime;
|
|||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.game.clans.clans.ClansManager;
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
import mineplex.game.clans.clans.siege.commands.CommandSiegeSupplies;
|
|
||||||
import mineplex.game.clans.clans.siege.outpost.OutpostManager;
|
import mineplex.game.clans.clans.siege.outpost.OutpostManager;
|
||||||
import mineplex.game.clans.clans.siege.repository.SiegeWeaponRepository;
|
import mineplex.game.clans.clans.siege.repository.SiegeWeaponRepository;
|
||||||
import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken;
|
import mineplex.game.clans.clans.siege.repository.tokens.SiegeWeaponToken;
|
||||||
@ -36,11 +33,8 @@ import net.minecraft.server.v1_8_R3.Material;
|
|||||||
public class SiegeManager extends MiniPlugin
|
public class SiegeManager extends MiniPlugin
|
||||||
{
|
{
|
||||||
private ClansManager _clansManager;
|
private ClansManager _clansManager;
|
||||||
|
|
||||||
private OutpostManager _outpostManager;
|
private OutpostManager _outpostManager;
|
||||||
|
|
||||||
public static SiegeManager Instance;
|
|
||||||
|
|
||||||
public NautHashMap<Integer, SiegeWeapon> LiveSiegeWeapons = new NautHashMap<>();
|
public NautHashMap<Integer, SiegeWeapon> LiveSiegeWeapons = new NautHashMap<>();
|
||||||
public NautHashMap<Integer, SiegeWeapon> UnsyncedSiegeWeapons = new NautHashMap<>();
|
public NautHashMap<Integer, SiegeWeapon> UnsyncedSiegeWeapons = new NautHashMap<>();
|
||||||
|
|
||||||
@ -58,11 +52,7 @@ public class SiegeManager extends MiniPlugin
|
|||||||
|
|
||||||
_outpostManager = new OutpostManager(clans, this);
|
_outpostManager = new OutpostManager(clans, this);
|
||||||
|
|
||||||
addCommand(new CommandSiegeSupplies(_outpostManager));
|
_repository = new SiegeWeaponRepository(clans.getPlugin(), this);
|
||||||
|
|
||||||
Instance = this;
|
|
||||||
|
|
||||||
_repository = new SiegeWeaponRepository(clans.getPlugin());
|
|
||||||
|
|
||||||
_outpostManager.loadOutposts();
|
_outpostManager.loadOutposts();
|
||||||
|
|
||||||
@ -188,8 +178,6 @@ public class SiegeManager extends MiniPlugin
|
|||||||
|
|
||||||
private void saveSiegeWeapons()
|
private void saveSiegeWeapons()
|
||||||
{
|
{
|
||||||
final Stack<Runnable> queue = new Stack<>();
|
|
||||||
|
|
||||||
for (final SiegeWeapon weapon : LiveSiegeWeapons.values())
|
for (final SiegeWeapon weapon : LiveSiegeWeapons.values())
|
||||||
{
|
{
|
||||||
final SiegeWeaponToken token = weapon.toToken();
|
final SiegeWeaponToken token = weapon.toToken();
|
||||||
@ -197,28 +185,10 @@ public class SiegeManager extends MiniPlugin
|
|||||||
if (UnsyncedSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId)))
|
if (UnsyncedSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
queue.push(() -> {
|
runAsync(() -> {
|
||||||
_repository.updateWeapon(token);
|
_repository.updateWeapon(token);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
runAsync(() -> {
|
|
||||||
while (!queue.isEmpty())
|
|
||||||
{
|
|
||||||
queue.pop().run();
|
|
||||||
}
|
|
||||||
|
|
||||||
_repository.getWeaponsByServer(_clansManager.getServerId(), tokens -> {
|
|
||||||
tokens.forEach(token -> {
|
|
||||||
if (!LiveSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId)) && !UnsyncedSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId)))
|
|
||||||
{
|
|
||||||
System.out.println("LiveSiegeWeapons no longer contains old weapon " + token.UniqueId + ", deleting.");
|
|
||||||
_repository.deleteWeapon(token.UniqueId);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
package mineplex.game.clans.clans.siege.commands;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import mineplex.core.command.CommandBase;
|
|
||||||
import mineplex.core.common.Rank;
|
|
||||||
import mineplex.core.common.util.F;
|
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
|
||||||
import mineplex.game.clans.clans.siege.outpost.Outpost;
|
|
||||||
import mineplex.game.clans.clans.siege.outpost.OutpostManager;
|
|
||||||
import mineplex.game.clans.clans.siege.weapon.Cannon;
|
|
||||||
|
|
||||||
public class CommandSiegeSupplies extends CommandBase<OutpostManager>
|
|
||||||
{
|
|
||||||
public CommandSiegeSupplies(OutpostManager plugin)
|
|
||||||
{
|
|
||||||
super(plugin, Rank.MODERATOR, "siege");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void Execute(Player caller, String[] args)
|
|
||||||
{
|
|
||||||
ItemStack outpost = new ItemStack(Outpost.OUTPOST_ITEM);
|
|
||||||
ItemStack cannons = new ItemStack(Cannon.CANNON_ITEM);
|
|
||||||
|
|
||||||
outpost.setAmount(64);
|
|
||||||
cannons.setAmount(64);
|
|
||||||
|
|
||||||
caller.getInventory().addItem(outpost);
|
|
||||||
caller.getInventory().addItem(cannons);
|
|
||||||
|
|
||||||
UtilPlayer.message(caller, F.main("Clans", "Received supplies for a siege."));
|
|
||||||
}
|
|
||||||
}
|
|
@ -44,23 +44,27 @@ public class SiegeWeaponRepository extends MinecraftRepository
|
|||||||
|
|
||||||
private static final String DELETE_WEAPON = "DELETE FROM clansSiegeWeapons WHERE uniqueId=?;";
|
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());
|
super(plugin, DBPool.getAccount());
|
||||||
|
|
||||||
|
_siegeManager = siegeManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteWeapon(final int uniqueId)
|
public void deleteWeapon(final int uniqueId)
|
||||||
{
|
{
|
||||||
System.out.println("Siege Repo> Deleting weapon " + uniqueId);
|
System.out.println("Siege Repo> Deleting weapon " + uniqueId);
|
||||||
|
|
||||||
SiegeManager.Instance.runAsync(() ->
|
_siegeManager.runAsync(() ->
|
||||||
executeUpdate(DELETE_WEAPON, new ColumnInt("uniqueId", uniqueId))
|
executeUpdate(DELETE_WEAPON, new ColumnInt("uniqueId", uniqueId))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getWeaponById(final int uniqueId, final Callback<SiegeWeaponToken> callback)
|
public void getWeaponById(final int uniqueId, final Callback<SiegeWeaponToken> callback)
|
||||||
{
|
{
|
||||||
SiegeManager.Instance.runAsync(() ->
|
_siegeManager.runAsync(() ->
|
||||||
executeQuery(GET_WEAPON_BY_ID, resultSet -> {
|
executeQuery(GET_WEAPON_BY_ID, resultSet -> {
|
||||||
SiegeWeaponToken token = new SiegeWeaponToken();
|
SiegeWeaponToken token = new SiegeWeaponToken();
|
||||||
|
|
||||||
@ -75,7 +79,7 @@ public class SiegeWeaponRepository extends MinecraftRepository
|
|||||||
|
|
||||||
public void getWeaponsByServer(final int serverId, final Callback<List<SiegeWeaponToken>> callback)
|
public void getWeaponsByServer(final int serverId, final Callback<List<SiegeWeaponToken>> callback)
|
||||||
{
|
{
|
||||||
SiegeManager.Instance.runAsync(() ->
|
_siegeManager.runAsync(() ->
|
||||||
executeQuery(GET_WEAPONS_BY_SERVER, resultSet -> {
|
executeQuery(GET_WEAPONS_BY_SERVER, resultSet -> {
|
||||||
List<SiegeWeaponToken> tokens = Lists.newArrayList();
|
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)
|
public void getWeaponsByClan(final ClanInfo clan, final Callback<List<SiegeWeaponToken>> callback)
|
||||||
{
|
{
|
||||||
SiegeManager.Instance.runAsync(() ->
|
_siegeManager.runAsync(() ->
|
||||||
executeQuery(GET_WEAPONS_BY_CLAN, resultSet -> {
|
executeQuery(GET_WEAPONS_BY_CLAN, resultSet -> {
|
||||||
List<SiegeWeaponToken> tokens = Lists.newArrayList();
|
List<SiegeWeaponToken> tokens = Lists.newArrayList();
|
||||||
|
|
||||||
@ -117,7 +121,7 @@ public class SiegeWeaponRepository extends MinecraftRepository
|
|||||||
{
|
{
|
||||||
token.UniqueId = columns.getInt("uniqueId");
|
token.UniqueId = columns.getInt("uniqueId");
|
||||||
token.Location = UtilWorld.strToLoc(columns.getString("location"));
|
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.WeaponType = columns.getByte("weaponType");
|
||||||
token.Health = columns.getShort("health");
|
token.Health = columns.getShort("health");
|
||||||
token.Yaw = columns.getShort("yaw");
|
token.Yaw = columns.getShort("yaw");
|
||||||
@ -131,7 +135,7 @@ public class SiegeWeaponRepository extends MinecraftRepository
|
|||||||
{
|
{
|
||||||
System.out.println("Siege Repo> Updating weapon " + token.UniqueId);
|
System.out.println("Siege Repo> Updating weapon " + token.UniqueId);
|
||||||
|
|
||||||
SiegeManager.Instance.runAsync(() ->
|
_siegeManager.runAsync(() ->
|
||||||
executeUpdate(UPDATE_WEAPON,
|
executeUpdate(UPDATE_WEAPON,
|
||||||
new ColumnInt("health", token.Health),
|
new ColumnInt("health", token.Health),
|
||||||
new ColumnInt("yaw", token.Yaw),
|
new ColumnInt("yaw", token.Yaw),
|
||||||
@ -144,10 +148,10 @@ public class SiegeWeaponRepository extends MinecraftRepository
|
|||||||
{
|
{
|
||||||
System.out.println("Siege Repo> Inserting new weapon " + token.UniqueId);
|
System.out.println("Siege Repo> Inserting new weapon " + token.UniqueId);
|
||||||
|
|
||||||
SiegeManager.Instance.runAsync(() ->
|
_siegeManager.runAsync(() ->
|
||||||
executeUpdate(INSERT_WEAPON,
|
executeUpdate(INSERT_WEAPON,
|
||||||
new ColumnInt("uniqueId", token.UniqueId),
|
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 ColumnVarChar("location", 30, UtilWorld.locToStr(token.Location)),
|
||||||
new ColumnInt("ownerClan", token.OwnerClan.getId()),
|
new ColumnInt("ownerClan", token.OwnerClan.getId()),
|
||||||
new ColumnInt("weaponType", token.WeaponType),
|
new ColumnInt("weaponType", token.WeaponType),
|
||||||
@ -192,7 +196,7 @@ public class SiegeWeaponRepository extends MinecraftRepository
|
|||||||
@Override
|
@Override
|
||||||
protected void initialize()
|
protected void initialize()
|
||||||
{
|
{
|
||||||
SiegeManager.Instance.runAsync(() ->
|
_siegeManager.runAsync(() ->
|
||||||
executeUpdate(CREATE)
|
executeUpdate(CREATE)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ public class WeaponProjectile implements Listener
|
|||||||
|
|
||||||
if (!newEvent.isCancelled())
|
if (!newEvent.isCancelled())
|
||||||
{
|
{
|
||||||
new Crater(_weapon, this, UtilBlock.nearestFloor(_projectileEntity.getLocation()), _attributes._craterSize, _attributes._craterChanceOfAir, _attributes._craterDoFire);
|
new Crater(_weapon, this, _projectileEntity.getLocation(), _attributes._craterSize, _attributes._craterChanceOfAir, _attributes._craterDoFire);
|
||||||
}
|
}
|
||||||
|
|
||||||
UtilServer.getServer().getOnlinePlayers().forEach(player -> player.playSound(_projectileEntity.getLocation(), Sound.EXPLODE, 1.f, 1.f));
|
UtilServer.getServer().getOnlinePlayers().forEach(player -> player.playSound(_projectileEntity.getLocation(), Sound.EXPLODE, 1.f, 1.f));
|
||||||
|
@ -23,6 +23,8 @@ import mineplex.core.npc.NpcManager;
|
|||||||
import mineplex.core.scoreboard.ScoreboardManager;
|
import mineplex.core.scoreboard.ScoreboardManager;
|
||||||
import mineplex.core.scoreboard.elements.ScoreboardElement;
|
import mineplex.core.scoreboard.elements.ScoreboardElement;
|
||||||
import mineplex.core.task.TaskManager;
|
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.message.ClansMessageManager;
|
||||||
import mineplex.game.clans.tutorial.command.TutorialCommand;
|
import mineplex.game.clans.tutorial.command.TutorialCommand;
|
||||||
import mineplex.game.clans.tutorial.gui.TutorialShop;
|
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, Tutorial> _tutorialMap;
|
||||||
private EnumMap<TutorialType, TutorialShop> _shopMap; // Don't need to do anything with shops currently
|
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);
|
super("Clans Tutorial", plugin);
|
||||||
|
|
||||||
@ -48,7 +50,7 @@ public class TutorialManager extends MiniPlugin implements ScoreboardElement
|
|||||||
_tutorialMap = new EnumMap<TutorialType, Tutorial>(TutorialType.class);
|
_tutorialMap = new EnumMap<TutorialType, Tutorial>(TutorialType.class);
|
||||||
_shopMap = new EnumMap<TutorialType, TutorialShop>(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 -> {
|
chat.AddFilter(event -> {
|
||||||
if (inTutorial(event.getPlayer()))
|
if (inTutorial(event.getPlayer()))
|
||||||
|
@ -3,19 +3,14 @@ package mineplex.game.clans.tutorial.tutorials.clans;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import org.bukkit.Bukkit;
|
||||||
import mineplex.core.hologram.Hologram;
|
import org.bukkit.DyeColor;
|
||||||
import mineplex.core.common.util.*;
|
import org.bukkit.Effect;
|
||||||
import mineplex.core.task.TaskManager;
|
import org.bukkit.GameMode;
|
||||||
import mineplex.game.clans.clans.ClanInfo;
|
import org.bukkit.Location;
|
||||||
import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent;
|
import org.bukkit.Material;
|
||||||
import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent;
|
import org.bukkit.Sound;
|
||||||
import mineplex.game.clans.clans.event.PreEnergyShopBuyEvent;
|
|
||||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
|
||||||
import org.bukkit.*;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -30,17 +25,30 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilAlg;
|
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.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilTextMiddle;
|
||||||
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.hologram.HologramManager;
|
import mineplex.core.hologram.HologramManager;
|
||||||
import mineplex.core.npc.NpcManager;
|
import mineplex.core.npc.NpcManager;
|
||||||
|
import mineplex.core.task.TaskManager;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import mineplex.game.clans.clans.ClanInfo;
|
||||||
import mineplex.game.clans.clans.ClansManager;
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent;
|
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.gui.events.ClansButtonClickEvent;
|
||||||
|
import mineplex.game.clans.clans.siege.SiegeManager;
|
||||||
import mineplex.game.clans.economy.GoldManager;
|
import mineplex.game.clans.economy.GoldManager;
|
||||||
import mineplex.game.clans.message.ClansMessageManager;
|
import mineplex.game.clans.message.ClansMessageManager;
|
||||||
import mineplex.game.clans.spawn.Spawn;
|
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.FinalObjective;
|
||||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.PurchaseItemsObjective;
|
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.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
|
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);
|
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());
|
// _repository = new TutorialRepository(ClansManager.getInstance().getClientManager());
|
||||||
|
|
||||||
addObjective(new ClanObjective(this, plugin));
|
addObjective(new ClanObjective(this, plugin));
|
||||||
addObjective(new AttackEnemyObjective(this, plugin));
|
addObjective(new AttackEnemyObjective(this, clansManager, plugin));
|
||||||
addObjective(new ShopsObjective(this, npcManager, plugin));
|
addObjective(new ShopsObjective(this, npcManager, plugin));
|
||||||
addObjective(new PurchaseItemsObjective(this, plugin));
|
addObjective(new PurchaseItemsObjective(this, plugin));
|
||||||
addObjective(new ClassesObjective(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.recharge.Recharge;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
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.clans.siege.weapon.Cannon;
|
||||||
import mineplex.game.clans.tutorial.TutorialRegion;
|
import mineplex.game.clans.tutorial.TutorialRegion;
|
||||||
import mineplex.game.clans.tutorial.TutorialSession;
|
import mineplex.game.clans.tutorial.TutorialSession;
|
||||||
@ -49,7 +51,7 @@ public class AttackEnemyObjective extends OrderedObjective<ClansMainTutorial>
|
|||||||
|
|
||||||
private DefaultHashMap<String, List<Zombie>> _shooters;
|
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!");
|
super(clansMainTutorial, javaPlugin, "Enemy Clans Tutorial", "Attack and raid this enemy!");
|
||||||
|
|
||||||
@ -66,7 +68,7 @@ public class AttackEnemyObjective extends OrderedObjective<ClansMainTutorial>
|
|||||||
40
|
40
|
||||||
));
|
));
|
||||||
addGoal(new ClanInfoGoal(this));
|
addGoal(new ClanInfoGoal(this));
|
||||||
addGoal(new MountCannonGoal(this));
|
addGoal(new MountCannonGoal(this, clansManager));
|
||||||
addGoal(new LoadCannonGoal(this));
|
addGoal(new LoadCannonGoal(this));
|
||||||
addGoal(new BlowUpWallGoal(this));
|
addGoal(new BlowUpWallGoal(this));
|
||||||
addGoal(new StealEnemyPotatoesGoal(this));
|
addGoal(new StealEnemyPotatoesGoal(this));
|
||||||
|
@ -9,6 +9,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
import mineplex.core.common.util.UtilInv;
|
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.SiegeManager;
|
||||||
import mineplex.game.clans.clans.siege.events.MountSiegeWeaponEvent;
|
import mineplex.game.clans.clans.siege.events.MountSiegeWeaponEvent;
|
||||||
import mineplex.game.clans.clans.siege.weapon.Cannon;
|
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 class MountCannonGoal extends ObjectiveGoal<AttackEnemyObjective>
|
||||||
{
|
{
|
||||||
public MountCannonGoal(AttackEnemyObjective objective)
|
private ClansManager _clansManager;
|
||||||
|
|
||||||
|
public MountCannonGoal(AttackEnemyObjective objective, ClansManager clansManager)
|
||||||
{
|
{
|
||||||
super(
|
super(
|
||||||
objective,
|
objective,
|
||||||
@ -31,12 +34,14 @@ public class MountCannonGoal extends ObjectiveGoal<AttackEnemyObjective>
|
|||||||
+ "TNT Cannons are the best way to do destroy enemy bases!",
|
+ "TNT Cannons are the best way to do destroy enemy bases!",
|
||||||
DyeColor.BLACK
|
DyeColor.BLACK
|
||||||
);
|
);
|
||||||
|
|
||||||
|
_clansManager = clansManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void customStart(Player player)
|
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()).SetForcedVelocity(0.4, 2.45);
|
||||||
getObjective().getCannons().get(player.getName()).setInvincible(true);
|
getObjective().getCannons().get(player.getName()).setInvincible(true);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user