Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex
This commit is contained in:
commit
ea30645d42
@ -11,6 +11,7 @@
|
||||
<orderEntry type="library" name="commons-codec" level="project" />
|
||||
<orderEntry type="library" name="commons-io" level="project" />
|
||||
<orderEntry type="module" module-name="Mineplex.ServerData" />
|
||||
<orderEntry type="library" name="httpcore" level="project" />
|
||||
<orderEntry type="library" name="httpclient" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
</module>
|
@ -11,6 +11,7 @@
|
||||
<orderEntry type="module" module-name="Mineplex.Core.Common" />
|
||||
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.ClassCombat" />
|
||||
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.Core" />
|
||||
<orderEntry type="module" module-name="Mineplex.ServerData" />
|
||||
<orderEntry type="library" name="craftbukkit" level="project" />
|
||||
</component>
|
||||
</module>
|
@ -1,8 +1,6 @@
|
||||
package mineplex.game.clans.clans;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
@ -71,13 +69,12 @@ public class ClanEnergyManager extends MiniPlugin implements Runnable
|
||||
_shop.attemptShopOpen(player);
|
||||
}
|
||||
|
||||
// TODO DEBUG
|
||||
@EventHandler
|
||||
public void command(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (event.getMessage().startsWith("/energyshop"))
|
||||
{
|
||||
openShop(event.getPlayer());
|
||||
}
|
||||
}
|
||||
// @EventHandler
|
||||
// public void command(PlayerCommandPreprocessEvent event)
|
||||
// {
|
||||
// if (event.getMessage().startsWith("/energyshop"))
|
||||
// {
|
||||
// openShop(event.getPlayer());
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||
import mineplex.game.clans.clans.repository.tokens.ClanAllianceToken;
|
||||
import mineplex.game.clans.clans.repository.tokens.ClanEnemyToken;
|
||||
import mineplex.game.clans.clans.repository.tokens.ClanMemberToken;
|
||||
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
|
||||
import mineplex.game.clans.clans.repository.tokens.ClanToken;
|
||||
@ -54,11 +55,11 @@ public class ClanInfo
|
||||
private long _dateCreated = 0;
|
||||
private long _lastOnline = 0;
|
||||
|
||||
private NautHashMap<String, Boolean> _allyMap = new NautHashMap<String, Boolean>();
|
||||
|
||||
// Loaded from Client
|
||||
private NautHashMap<String, Role> _memberMap = new NautHashMap<String, Role>();
|
||||
private NautHashMap<String, Boolean> _allyMap = new NautHashMap<String, Boolean>();
|
||||
private HashSet<String> _claimSet = new HashSet<String>();
|
||||
private EnemyData _enemyData;
|
||||
|
||||
// Temporary
|
||||
private NautHashMap<String, Long> _inviteeMap = new NautHashMap<String, Long>();
|
||||
@ -106,6 +107,16 @@ public class ClanInfo
|
||||
{
|
||||
_allyMap.put(allianceToken.ClanName, allianceToken.Trusted);
|
||||
}
|
||||
|
||||
updateEnemy(token.EnemyToken);
|
||||
}
|
||||
|
||||
public void updateEnemy(ClanEnemyToken enemyToken)
|
||||
{
|
||||
if (enemyToken != null)
|
||||
{
|
||||
_enemyData = new EnemyData(enemyToken.EnemyName, enemyToken.Initiator, enemyToken.Score, enemyToken.Kills, enemyToken.TimeFormed);
|
||||
}
|
||||
}
|
||||
|
||||
public int getClaims()
|
||||
@ -215,7 +226,8 @@ public class ClanInfo
|
||||
stringList.add(F.value("Clan Energy", "" + energy));
|
||||
// stringList.add(F.value("Max Energy", "" + getEnergyMax()));
|
||||
stringList.add(F.value("Energy Drain/Hour", "" + costPerHour));
|
||||
stringList.add(F.value("Hours Left", "" + energy / costPerHour));
|
||||
if (costPerHour > 0)
|
||||
stringList.add(F.value("Hours Left", "" + energy / costPerHour));
|
||||
stringList.add(" ");
|
||||
|
||||
// Ally String
|
||||
@ -259,6 +271,27 @@ public class ClanInfo
|
||||
return stringList;
|
||||
}
|
||||
|
||||
public LinkedList<String> mEnemy()
|
||||
{
|
||||
LinkedList<String> stringList = new LinkedList<String>();
|
||||
|
||||
if (_enemyData == null)
|
||||
{
|
||||
stringList.add(F.main("Clans", "You do not have an enemy!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
stringList.add(F.main("Clans", "Enemy Details"));
|
||||
String enemyName = _enemyData.getEnemyName();
|
||||
EnemyData otherEnemyData = Clans.getClanUtility().getClanByClanName(enemyName).getEnemyData();
|
||||
stringList.add(F.value("Enemy", _enemyData.getEnemyName()));
|
||||
stringList.add(F.value("Formed", _enemyData.getRelativeTimeFormed()));
|
||||
stringList.add(F.value("War Score", _enemyData.getScore() + " : " + otherEnemyData.getScore()));
|
||||
}
|
||||
|
||||
return stringList;
|
||||
}
|
||||
|
||||
public LinkedList<String> mTerritory()
|
||||
{
|
||||
LinkedList<String> stringList = new LinkedList<String>();
|
||||
@ -422,6 +455,16 @@ public class ClanInfo
|
||||
{
|
||||
return _energy;
|
||||
}
|
||||
|
||||
public EnemyData getEnemyData()
|
||||
{
|
||||
return _enemyData;
|
||||
}
|
||||
|
||||
public boolean hasEnemy()
|
||||
{
|
||||
return _enemyData != null;
|
||||
}
|
||||
|
||||
public void adjustEnergy(int energy)
|
||||
{
|
||||
@ -440,7 +483,6 @@ public class ClanInfo
|
||||
|
||||
public int getEnergyMax()
|
||||
{
|
||||
// TODO
|
||||
// 10080 = 7 days of minutes
|
||||
return 1440 + (getEnergyCostPerMinute() * 10080);
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.game.clans.clans;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
@ -10,6 +12,7 @@ import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.game.clans.clans.ClanInfo.Role;
|
||||
import mineplex.game.clans.clans.repository.ClanRepository;
|
||||
import mineplex.game.clans.clans.repository.ClanTerritory;
|
||||
import mineplex.game.clans.clans.repository.tokens.ClanEnemyToken;
|
||||
import mineplex.game.clans.clans.repository.tokens.ClanToken;
|
||||
|
||||
public class ClansDataAccessLayer
|
||||
@ -152,6 +155,26 @@ public class ClansDataAccessLayer
|
||||
_manager.log("Added Ally for [" + cB.getName() + "] and [" + cA.getName() + "] by [" + player + "].");
|
||||
}
|
||||
|
||||
public void enemy(ClanInfo clan, ClanInfo otherClan, String player)
|
||||
{
|
||||
_repository.addEnemy(clan.getId(), otherClan.getId());
|
||||
Date currDate = new Date();
|
||||
|
||||
ClanEnemyToken clanEnemyToken = new ClanEnemyToken();
|
||||
clanEnemyToken.Initiator = true;
|
||||
clanEnemyToken.TimeFormed = currDate;
|
||||
clanEnemyToken.EnemyName = otherClan.getName();
|
||||
clan.updateEnemy(clanEnemyToken);
|
||||
|
||||
ClanEnemyToken otherClanEnemyToken = new ClanEnemyToken();
|
||||
otherClanEnemyToken.Initiator = false;
|
||||
otherClanEnemyToken.TimeFormed = currDate;
|
||||
otherClanEnemyToken.EnemyName = clan.getName();
|
||||
otherClan.updateEnemy(otherClanEnemyToken);
|
||||
|
||||
_manager.log("Added Enemy for [" + clan.getName() + "] and [" + otherClan.getName() + "] by [" + player + "].");
|
||||
}
|
||||
|
||||
public boolean trust(ClanInfo ownerClan, ClanInfo otherClan, String player)
|
||||
{
|
||||
if (!ownerClan.getAllyMap().containsKey(otherClan.getName()))
|
||||
@ -277,6 +300,21 @@ public class ClansDataAccessLayer
|
||||
//Log
|
||||
_manager.log("Set Home for [" + clan.getName() + "] to " + UtilWorld.locToStrClean(loc) + " by [" + player + "].");
|
||||
}
|
||||
|
||||
public void updateEnemy(ClanInfo clan, ClanInfo otherClan)
|
||||
{
|
||||
assert clan.getEnemyData() != null && otherClan.getEnemyData() != null;
|
||||
assert clan.getEnemyData().getEnemyName() == otherClan.getName() && otherClan.getEnemyData().getEnemyName() == clan.getName();
|
||||
|
||||
ClanInfo initiator = clan.getEnemyData().isInitiator() ? clan : otherClan;
|
||||
EnemyData iData = initiator.getEnemyData();
|
||||
ClanInfo other = clan == initiator ? otherClan : clan;
|
||||
EnemyData oData = other.getEnemyData();
|
||||
_repository.updateEnemy(initiator.getId(), other.getId(), iData.getScore(), oData.getScore(), iData.getKills(), oData.getKills());
|
||||
|
||||
//Log
|
||||
_manager.log("Updated Enemy Data for [" + clan.getName() + ", " + otherClan.getName() + "]");
|
||||
}
|
||||
|
||||
public void updateEnergy(ClanInfo clan)
|
||||
{
|
||||
|
@ -23,9 +23,6 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.blockrestore.BlockRestoreData;
|
||||
import mineplex.core.common.util.C;
|
||||
@ -38,12 +35,14 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.creature.event.CreatureSpawnCustomEvent;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClanInfo.Role;
|
||||
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
public class ClansGame extends MiniPlugin
|
||||
{
|
||||
@ -172,7 +171,7 @@ public class ClansGame extends MiniPlugin
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void BlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (event.isCancelled() || event.getPlayer().getWorld().getEnvironment() != Environment.NORMAL)
|
||||
if (event.isCancelled() || event.getPlayer().getWorld().getEnvironment() != Environment.NORMAL || event.getPlayer().getGameMode() == GameMode.CREATIVE)
|
||||
return;
|
||||
|
||||
String mimic = Clans.Get(event.getPlayer()).getMimic();
|
||||
|
@ -34,10 +34,12 @@ import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||
import mineplex.game.clans.clans.commands.ClansAllyChatCommand;
|
||||
import mineplex.game.clans.clans.commands.ClansChatCommand;
|
||||
import mineplex.game.clans.clans.commands.ClansCommand;
|
||||
import mineplex.game.clans.clans.commands.ServerTimeCommand;
|
||||
import mineplex.game.clans.clans.repository.ClanTerritory;
|
||||
import mineplex.game.clans.clans.repository.tokens.ClanMemberToken;
|
||||
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
|
||||
import mineplex.game.clans.clans.repository.tokens.ClanToken;
|
||||
import mineplex.game.clans.clans.war.WarManager;
|
||||
import mineplex.game.clans.fields.Field;
|
||||
import mineplex.game.clans.gameplay.Gameplay;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
||||
@ -71,6 +73,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
private ConditionManager _condition;
|
||||
private ClassCombatShop _classShop;
|
||||
private ClassManager _classManager;
|
||||
private WarManager _warManager;
|
||||
|
||||
private int _inviteExpire = 2;
|
||||
private int _nameMin = 3;
|
||||
@ -135,6 +138,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
ClassShopManager shopManager = new ClassShopManager(plugin, _classManager, skillManager, itemFactory, achievementManager, _clientManager);
|
||||
_classShop = new ClassCombatShop(shopManager, _clientManager, donationManager, true, "Class Shop");
|
||||
|
||||
_warManager = new WarManager(plugin, this);
|
||||
|
||||
ClanEnergyManager clanEnergyManager = new ClanEnergyManager(plugin, this, clientManager, donationManager);
|
||||
|
||||
for (ClanToken token : _clanDataAccess.getRepository().retrieveClans())
|
||||
@ -156,6 +161,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
addCommand(new ClansCommand(this));
|
||||
addCommand(new ClansChatCommand(this));
|
||||
addCommand(new ClansAllyChatCommand(this));
|
||||
addCommand(new ServerTimeCommand(this));
|
||||
}
|
||||
|
||||
public int getInviteExpire()
|
||||
@ -484,6 +490,11 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
return _classShop;
|
||||
}
|
||||
|
||||
public WarManager getWarManager()
|
||||
{
|
||||
return _warManager;
|
||||
}
|
||||
|
||||
public int convertGoldToEnergy(int gold)
|
||||
{
|
||||
return gold * 4;
|
||||
|
@ -0,0 +1,76 @@
|
||||
package mineplex.game.clans.clans;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
|
||||
public class EnemyData
|
||||
{
|
||||
private String _enemy;
|
||||
private boolean _initiator;
|
||||
private int _score;
|
||||
private int _kills;
|
||||
private Date _timeFormed;
|
||||
|
||||
public EnemyData(String enemy, boolean initiator, int score, int kills, Date timeFormed)
|
||||
{
|
||||
_enemy = enemy;
|
||||
_initiator = initiator;
|
||||
_score = score;
|
||||
_kills = kills;
|
||||
_timeFormed = timeFormed;
|
||||
}
|
||||
|
||||
public String getEnemyName()
|
||||
{
|
||||
return _enemy;
|
||||
}
|
||||
|
||||
public int getScore()
|
||||
{
|
||||
return _score;
|
||||
}
|
||||
|
||||
public int getKills()
|
||||
{
|
||||
return _kills;
|
||||
}
|
||||
|
||||
public void addDeath()
|
||||
{
|
||||
addScore(-1);
|
||||
}
|
||||
|
||||
public void addKill()
|
||||
{
|
||||
addScore(1);
|
||||
addKills(1);
|
||||
}
|
||||
|
||||
private void addScore(int add)
|
||||
{
|
||||
_score = Math.max(0, Math.min(_score + 1, 40));
|
||||
}
|
||||
|
||||
private void addKills(int add)
|
||||
{
|
||||
_kills++;
|
||||
}
|
||||
|
||||
public boolean isInitiator()
|
||||
{
|
||||
return _initiator;
|
||||
}
|
||||
|
||||
public Date getTimeFormed()
|
||||
{
|
||||
return _timeFormed;
|
||||
}
|
||||
|
||||
public String getRelativeTimeFormed()
|
||||
{
|
||||
long timeFormed = _timeFormed.getTime();
|
||||
long currentTime = System.currentTimeMillis();
|
||||
return UtilTime.convertString(System.currentTimeMillis() - timeFormed, 1, UtilTime.TimeUnit.FIT);
|
||||
}
|
||||
}
|
@ -14,8 +14,8 @@ import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClanInfo.Role;
|
||||
@ -97,6 +97,9 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
else if (args[0].equalsIgnoreCase("sethome"))
|
||||
homeSet(caller);
|
||||
|
||||
else if (args[0].equalsIgnoreCase("enemy") || args[0].equals("e"))
|
||||
enemy(caller, args);
|
||||
|
||||
else if (args[0].equalsIgnoreCase("territory") || args[0].equalsIgnoreCase("t"))
|
||||
infoTerritory(caller, args);
|
||||
|
||||
@ -110,6 +113,43 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
infoClan(caller, args[0]);
|
||||
}
|
||||
|
||||
public void enemy(Player caller, String[] args)
|
||||
{
|
||||
if (args.length == 2)
|
||||
{
|
||||
ClanInfo playerClan = Plugin.getClanUtility().getClanByPlayer(caller);
|
||||
ClanInfo otherClan = Plugin.getClanUtility().searchClan(caller, args[1], true);
|
||||
|
||||
if (playerClan == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
|
||||
return;
|
||||
}
|
||||
else if (otherClan == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
attemptEnemy(caller, playerClan, otherClan);
|
||||
}
|
||||
else
|
||||
{
|
||||
infoEnemy(caller);
|
||||
}
|
||||
}
|
||||
|
||||
private void attemptEnemy(Player caller, ClanInfo initiatorClan, ClanInfo otherClan)
|
||||
{
|
||||
Plugin.getWarManager().attemptEnemy(caller, initiatorClan, otherClan);
|
||||
}
|
||||
|
||||
private void infoEnemy(Player caller)
|
||||
{
|
||||
ClanInfo playerClan = Plugin.getClanUtility().getClanByPlayer(caller);
|
||||
|
||||
UtilPlayer.message(caller, playerClan.mEnemy());
|
||||
}
|
||||
|
||||
public void commandChat(Player caller, String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
|
@ -0,0 +1,22 @@
|
||||
package mineplex.game.clans.clans.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
|
||||
public class ServerTimeCommand extends CommandBase<ClansManager>
|
||||
{
|
||||
public ServerTimeCommand(ClansManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "servertime", "t");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
UtilPlayer.message(caller, Plugin.getWarManager().mServerTime());
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ package mineplex.game.clans.clans.repository;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -16,6 +17,7 @@ import mineplex.core.database.column.ColumnLong;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.repository.tokens.ClanAllianceToken;
|
||||
import mineplex.game.clans.clans.repository.tokens.ClanEnemyToken;
|
||||
import mineplex.game.clans.clans.repository.tokens.ClanMemberToken;
|
||||
import mineplex.game.clans.clans.repository.tokens.ClanTerritoryToken;
|
||||
import mineplex.game.clans.clans.repository.tokens.ClanToken;
|
||||
@ -30,6 +32,7 @@ public class ClanRepository extends RepositoryBase
|
||||
private static String RETRIEVE_START_CLAN_INFO = "SELECT c.id, c.name, c.description, c.home, c.admin, c.energy, c.dateCreated, c.lastOnline, ct.chunk, ct.safe FROM clans AS c LEFT JOIN clanTerritory AS ct ON ct.clanId = c.id WHERE c.serverName = ?;";
|
||||
private static String RETRIEVE_CLAN_MEMBER_INFO = "SELECT c.name, a.name, a.uuid, clanRole FROM accountClan AS ac INNER JOIN accounts AS a ON a.id = ac.accountId INNER JOIN clans AS c on c.id = ac.clanId WHERE c.serverName = ?;";
|
||||
private static String RETRIEVE_CLAN_ALLIANCE_INFO = "SELECT c.name, cOther.name, ca.trusted FROM clanAlliances AS ca INNER JOIN clans AS c ON c.id = ca.clanId INNER JOIN clans as cOther ON cOther.id = ca.otherClanId WHERE c.serverName = ?;";
|
||||
private static String RETRIEVE_CLAN_ENEMY_INFO = "SELECT c.name, cOther.name, clanScore, otherClanScore, clanKills, otherClanKills, timeFormed FROM clanEnemies AS ce INNER JOIN clans AS c ON c.id = ce.clanId INNER JOIN clans as cOther ON cOther.id = ce.otherClanId WHERE c.serverName = ?;";
|
||||
|
||||
private static String DELETE_CLAN_MEMBER = "DELETE aC FROM accountClan AS aC INNER JOIN accounts ON accounts.id = aC.accountId WHERE aC.clanId = ? AND accounts.name = ?;";
|
||||
private static String DELETE_CLAN_MEMBERS = "DELETE FROM accountClan WHERE clanId = ?;";
|
||||
@ -37,16 +40,19 @@ public class ClanRepository extends RepositoryBase
|
||||
private static String DELETE_CLAN_TERRITORIES = "DELETE FROM clanTerritory WHERE clanId = ?;";
|
||||
private static String DELETE_CLAN_ALLIANCE = "DELETE FROM clanAlliances WHERE clanId = ? AND otherClanId = ?;";
|
||||
private static String DELETE_CLAN_ALLIANCES = "DELETE FROM clanAlliances WHERE clanId = ? OR otherClanId = ?;";
|
||||
private static String DELETE_CLAN_ENEMY = "DELETE FROM clanEnemies WHERE clanId = ? OR otherClanId = ?;";
|
||||
private static String DELETE_CLAN = "DELETE FROM clans WHERE id = ?;";
|
||||
|
||||
private static String ADD_CLAN = "INSERT INTO clans (serverName, name, description, home, admin, dateCreated, energy, lastOnline) VALUES (?, ?, ?, ?, ?, now(), ?, now());";
|
||||
private static String ADD_CLAN_MEMBER = "INSERT INTO accountClan (accountId, clanId, clanRole) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.name = ?;";
|
||||
private static String ADD_CLAN_ALLIANCE = "INSERT INTO clanAlliances (clanId, otherClanId, trusted) VALUES (?, ?, ?);";
|
||||
private static String ADD_CLAN_ENEMY = "INSERT INTO clanEnemies (clanId, otherClanId, timeFormed) VALUES (?, ?, now());";
|
||||
private static String ADD_CLAN_TERRITORY = "INSERT INTO clanTerritory (clanId, serverName, chunk, safe) VALUES (?, ?, ?, ?);";
|
||||
|
||||
private static String UPDATE_CLAN = "UPDATE clans SET name = ?, description = ?, home = ?, admin = ?, energy = ?, lastOnline = ? WHERE id = ?;";
|
||||
private static String UPDATE_CLAN_MEMBER = "UPDATE accountClan AS AC INNER JOIN accounts ON accounts.id = AC.accountId SET AC.clanRole = ? WHERE AC.clanId = ? AND accounts.name = ?;";
|
||||
private static String UPDATE_CLAN_ALLIANCE = "UPDATE clanAlliances SET trusted = ? WHERE clanId = ? AND otherClanId = ?;";
|
||||
private static String UPDATE_CLAN_ENEMY = "UPDATE clanEnemies SET clanScore = ?, otherClanScore = ?, clanKills = ?, otherClanKills = ? WHERE clanId = ? AND otherClanId = ?;";
|
||||
private static String UPDATE_CLAN_TERRITORY = "UPDATE clanTerritory SET safe = ? WHERE serverName = ? AND chunk = ?;";
|
||||
|
||||
private String _serverName;
|
||||
@ -149,6 +155,44 @@ public class ClanRepository extends RepositoryBase
|
||||
}
|
||||
|
||||
}, new ColumnVarChar("serverName", 100, _serverName));
|
||||
|
||||
executeQuery(RETRIEVE_CLAN_ENEMY_INFO, new ResultSetCallable()
|
||||
{
|
||||
@Override
|
||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
while (resultSet.next())
|
||||
{
|
||||
ClanEnemyToken clanToken = new ClanEnemyToken();
|
||||
ClanEnemyToken otherClanToken = new ClanEnemyToken();
|
||||
|
||||
//c.name, cOther.name, clanScore, otherClanScore, clanKills, otherClanKills
|
||||
String clanName = resultSet.getString(1);
|
||||
String otherClanName = resultSet.getString(2);
|
||||
int clanScore = resultSet.getInt(3);
|
||||
int otherClanScore = resultSet.getInt(4);
|
||||
int clanKills = resultSet.getInt(5);
|
||||
int otherClanKills = resultSet.getInt(6);
|
||||
Date timeFormed = resultSet.getTimestamp(7);
|
||||
|
||||
clanToken.EnemyName = otherClanName;
|
||||
clanToken.Score = clanScore;
|
||||
clanToken.Kills = clanKills;
|
||||
clanToken.Initiator = true;
|
||||
clanToken.TimeFormed = timeFormed;
|
||||
|
||||
otherClanToken.EnemyName = clanName;
|
||||
otherClanToken.Score = otherClanScore;
|
||||
otherClanToken.Kills = otherClanKills;
|
||||
otherClanToken.Initiator = false;
|
||||
otherClanToken.TimeFormed = timeFormed;
|
||||
|
||||
clans.get(clanName).EnemyToken = clanToken;
|
||||
clans.get(otherClanName).EnemyToken = otherClanToken;
|
||||
}
|
||||
}
|
||||
|
||||
}, new ColumnVarChar("serverName", 100, _serverName));
|
||||
|
||||
return clans.values();
|
||||
}
|
||||
@ -163,6 +207,7 @@ public class ClanRepository extends RepositoryBase
|
||||
executeUpdate(DELETE_CLAN_MEMBERS, new ColumnInt("clanid", clanId));
|
||||
executeUpdate(DELETE_CLAN_TERRITORIES, new ColumnInt("clanid", clanId));
|
||||
executeUpdate(DELETE_CLAN_ALLIANCES, new ColumnInt("clanid", clanId), new ColumnInt("clanid", clanId));
|
||||
executeUpdate(DELETE_CLAN_ENEMY, new ColumnInt("clanid", clanId));
|
||||
executeUpdate(DELETE_CLAN, new ColumnInt("clanid", clanId));
|
||||
}
|
||||
|
||||
@ -218,6 +263,11 @@ public class ClanRepository extends RepositoryBase
|
||||
executeUpdate(ADD_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnVarChar("serverName", 100, _serverName), new ColumnVarChar("chunk", 100, chunk), new ColumnBoolean("safe", safe));
|
||||
}
|
||||
|
||||
public void addEnemy(int clanId, int otherClanId)
|
||||
{
|
||||
executeUpdate(ADD_CLAN_ENEMY, new ColumnInt("clanId", clanId), new ColumnInt("otherClanId", otherClanId));
|
||||
}
|
||||
|
||||
public void removeTerritoryClaim(int clanId, String chunk)
|
||||
{
|
||||
executeUpdate(DELETE_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnVarChar("serverName", 100, _serverName), new ColumnVarChar("chunk", 100, chunk));
|
||||
@ -228,6 +278,13 @@ public class ClanRepository extends RepositoryBase
|
||||
executeUpdate(UPDATE_CLAN, new ColumnVarChar("name", 100, name), new ColumnVarChar("desc", 100, desc), new ColumnVarChar("home", 100, home), new ColumnBoolean("admin", admin), new ColumnInt("energy", energy), new ColumnLong("lastOnline", lastOnline), new ColumnInt("clanId", clanId));
|
||||
}
|
||||
|
||||
public void updateEnemy(int clanId, int otherClanId, int clanScore, int otherClanScore, int clanKills, int otherClanKills)
|
||||
{
|
||||
executeUpdate(UPDATE_CLAN_ENEMY, new ColumnInt("clanId", clanId), new ColumnInt("otherClanId", otherClanId),
|
||||
new ColumnInt("clanScore", clanScore), new ColumnInt("otherClanScore", otherClanScore), new ColumnInt("clanKills", clanKills),
|
||||
new ColumnInt("otherClanKills", otherClanKills), new ColumnInt("clanId", clanId), new ColumnInt("otherClanId", otherClanId));
|
||||
}
|
||||
|
||||
public void updateTerritoryClaim(String chunk, boolean safe)
|
||||
{
|
||||
executeUpdate(UPDATE_CLAN_TERRITORY, new ColumnBoolean("safe", safe), new ColumnVarChar("serverName", 100, _serverName), new ColumnVarChar("chunk", 100, chunk));
|
||||
|
@ -0,0 +1,12 @@
|
||||
package mineplex.game.clans.clans.repository.tokens;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class ClanEnemyToken
|
||||
{
|
||||
public boolean Initiator;
|
||||
public String EnemyName;
|
||||
public int Score;
|
||||
public int Kills;
|
||||
public Date TimeFormed;
|
||||
}
|
@ -13,6 +13,8 @@ public class ClanToken
|
||||
public int Energy;
|
||||
public long DateCreated;
|
||||
public long LastOnline;
|
||||
|
||||
public ClanEnemyToken EnemyToken;
|
||||
|
||||
public List<ClanMemberToken> Members = new ArrayList<ClanMemberToken>();
|
||||
public List<ClanTerritoryToken> Territories = new ArrayList<ClanTerritoryToken>();
|
||||
|
@ -0,0 +1,197 @@
|
||||
package mineplex.game.clans.clans.war;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
|
||||
public class WarManager extends MiniPlugin
|
||||
{
|
||||
private static final int INVADE_ENEMY_DATE = Calendar.SATURDAY;
|
||||
private static final int CREATE_ENEMY_DATE = Calendar.SUNDAY;
|
||||
|
||||
private final ClansManager _clansManager;
|
||||
|
||||
public WarManager(JavaPlugin plugin, ClansManager clansManager)
|
||||
{
|
||||
super("War Manager", plugin);
|
||||
_clansManager = clansManager;
|
||||
}
|
||||
|
||||
public void attemptEnemy(Player player, ClanInfo initiatingClan, ClanInfo otherClan)
|
||||
{
|
||||
attemptEnemy(player, initiatingClan, otherClan, true);
|
||||
}
|
||||
|
||||
public void attemptEnemy(Player player, ClanInfo initiatingClan, ClanInfo otherClan, boolean notify)
|
||||
{
|
||||
String notifyMessage = null;
|
||||
|
||||
if (!isEnemyTime())
|
||||
{
|
||||
notifyMessage = "Enemies cannot be formed at this time. Please see mineplex.com/clans for info";
|
||||
}
|
||||
else if (initiatingClan.getEnemyData() != null)
|
||||
{
|
||||
notifyMessage = "Your clan already has an enemy.";
|
||||
}
|
||||
else if (otherClan.getEnemyData() != null)
|
||||
{
|
||||
notifyMessage = "The clan " + F.elem(otherClan.getName()) + " already has an enemy.";
|
||||
}
|
||||
else
|
||||
{
|
||||
_clansManager.getClanDataAccess().enemy(initiatingClan, otherClan, player.getName());
|
||||
_clansManager.messageClan(initiatingClan, F.main("Clans", "Your clan is now enemies with " + F.elem(otherClan.getName())));
|
||||
_clansManager.messageClan(otherClan, F.main("Clans", "Your clan is now enemies with " + F.elem(initiatingClan.getName())));
|
||||
}
|
||||
|
||||
if (notify && notifyMessage != null)
|
||||
UtilPlayer.message(player, F.main("Clans", notifyMessage));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleDeath(PlayerDeathEvent event)
|
||||
{
|
||||
Player player = event.getEntity();
|
||||
Player killer = player.getKiller();
|
||||
|
||||
ClanInfo playerClan = _clansManager.getClan(player);
|
||||
ClanInfo killerClan = _clansManager.getClan(killer);
|
||||
|
||||
if (playerClan != null && killerClan != null)
|
||||
{
|
||||
if (playerClan.getEnemyData() != null && playerClan.getEnemyData().getEnemyName().equalsIgnoreCase(killerClan.getName()))
|
||||
{
|
||||
if (isWarInProgress())
|
||||
{
|
||||
playerClan.getEnemyData().addDeath();
|
||||
killerClan.getEnemyData().addKill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Can enemies be formed at the current time
|
||||
*
|
||||
* Enemy forming will happen once a week during a set period
|
||||
*/
|
||||
private boolean isEnemyTime()
|
||||
{
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
|
||||
|
||||
if (dayOfWeek == CREATE_ENEMY_DATE)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isInvadeTime()
|
||||
{
|
||||
Calendar c = Calendar.getInstance();
|
||||
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
|
||||
|
||||
if (dayOfWeek == INVADE_ENEMY_DATE)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isWarInProgress()
|
||||
{
|
||||
return !isInvadeTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the starting time of when enemies can be formed next
|
||||
* @return The enemy start time in the form of {@link java.util.Date}
|
||||
*/
|
||||
private Date getNextEnemyTime()
|
||||
{
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.set(Calendar.DAY_OF_WEEK, CREATE_ENEMY_DATE);
|
||||
c.set(Calendar.HOUR_OF_DAY, 0);
|
||||
c.set(Calendar.MINUTE, 0);
|
||||
c.set(Calendar.SECOND, 0);
|
||||
|
||||
c.add(Calendar.DATE, 7);
|
||||
|
||||
return c.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the starting time of the next enemy invasion
|
||||
* @return The invasion start time in the form of {@link java.util.Date}
|
||||
*/
|
||||
private Date getNextInvadeTime()
|
||||
{
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.set(Calendar.DAY_OF_WEEK, INVADE_ENEMY_DATE);
|
||||
c.set(Calendar.HOUR_OF_DAY, 0);
|
||||
c.set(Calendar.MINUTE, 0);
|
||||
c.set(Calendar.SECOND, 0);
|
||||
|
||||
c.add(Calendar.DATE, 7);
|
||||
|
||||
return c.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the current server time information to the player
|
||||
*/
|
||||
public LinkedList<String> mServerTime()
|
||||
{
|
||||
LinkedList<String> messageList = new LinkedList<String>();
|
||||
|
||||
messageList.add(F.main("Clans", "Server Time;"));
|
||||
Date currDate = new Date();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy");
|
||||
|
||||
messageList.add(F.value("Server Time", dateFormat.format(currDate)));
|
||||
|
||||
if (isInvadeTime())
|
||||
{
|
||||
messageList.add(F.elem("Winning clans can invade enemies right now"));
|
||||
}
|
||||
else
|
||||
{
|
||||
long next = getNextInvadeTime().getTime();
|
||||
long currTime = System.currentTimeMillis();
|
||||
|
||||
messageList.add(F.value("Enemy Invasion", UtilTime.convertString(next - currTime, 1, UtilTime.TimeUnit.FIT)));
|
||||
}
|
||||
|
||||
if (isEnemyTime())
|
||||
{
|
||||
messageList.add(F.elem("Enemies can be formed at this time"));
|
||||
}
|
||||
else
|
||||
{
|
||||
long next = getNextEnemyTime().getTime();
|
||||
long currTime = System.currentTimeMillis();
|
||||
|
||||
messageList.add(F.value("Can Form Enemies In", UtilTime.convertString(next - currTime, 1, UtilTime.TimeUnit.FIT)));
|
||||
}
|
||||
|
||||
return messageList;
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@
|
||||
<orderEntry type="module" module-name="Mineplex.Core" />
|
||||
<orderEntry type="module" module-name="Mineplex.Core.Common" />
|
||||
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.ClassCombat" />
|
||||
<orderEntry type="library" name="gson" level="project" />
|
||||
<orderEntry type="module" module-name="Mineplex.Minecraft.Game.Core" />
|
||||
<orderEntry type="library" name="craftbukkit" level="project" />
|
||||
<orderEntry type="module" module-name="Mineplex.ServerData" />
|
||||
@ -19,5 +20,6 @@
|
||||
<orderEntry type="library" name="commons-pool2" level="project" />
|
||||
<orderEntry type="module" module-name="Mineplex.Database" />
|
||||
<orderEntry type="library" name="jooq" level="project" />
|
||||
<orderEntry type="library" name="jedis" level="project" />
|
||||
</component>
|
||||
</module>
|
@ -11,13 +11,14 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@ -31,11 +32,15 @@ import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import net.minecraft.server.v1_7_R4.Packet;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
|
||||
import net.minecraft.server.v1_7_R4.WatchableObject;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.Rank;
|
||||
@ -43,13 +48,13 @@ import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.MapUtil;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilBlockText;
|
||||
import mineplex.core.common.util.UtilBlockText.TextAlign;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilBlockText;
|
||||
import mineplex.core.common.util.UtilBlockText.TextAlign;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.cosmetic.event.ActivateGemBoosterEvent;
|
||||
@ -57,8 +62,8 @@ import mineplex.core.donation.Donor;
|
||||
import mineplex.core.event.CustomTagEvent;
|
||||
import mineplex.core.packethandler.IPacketHandler;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.core.packethandler.PacketVerifier;
|
||||
import mineplex.core.packethandler.PacketInfo;
|
||||
import mineplex.core.packethandler.PacketVerifier;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
@ -71,10 +76,6 @@ import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.kit.KitAvailability;
|
||||
import nautilus.game.arcade.kit.KitSorter;
|
||||
import net.minecraft.server.v1_7_R4.Packet;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
|
||||
import net.minecraft.server.v1_7_R4.WatchableObject;
|
||||
|
||||
public class GameLobbyManager implements Listener, IPacketHandler
|
||||
{
|
||||
@ -1301,4 +1302,30 @@ public class GameLobbyManager implements Listener, IPacketHandler
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* DEBUG
|
||||
*/
|
||||
@EventHandler
|
||||
public void command(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if (event.getMessage().startsWith("/enable"))
|
||||
{
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
player.setFlying(true);
|
||||
player.setFlySpeed(0.1f);
|
||||
((CraftPlayer) player).getHandle().spectating = true;
|
||||
((CraftPlayer) player).getHandle().k = false;
|
||||
}
|
||||
else if (event.getMessage().startsWith("/disable"))
|
||||
{
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.setFlying(false);
|
||||
player.setFlySpeed(0.1f);
|
||||
((CraftPlayer) player).getHandle().spectating = false;
|
||||
((CraftPlayer) player).getHandle().k = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user