Merge remote-tracking branch 'remotes/origin/clans_custom_gear' into clans-beta

This commit is contained in:
Shaun Bennett 2015-08-26 15:01:44 -07:00
commit e4c48e5f3f
5 changed files with 96 additions and 10 deletions

View File

@ -68,6 +68,7 @@ public class ClansGame extends MiniPlugin
return;
for (Player cur : UtilServer.getPlayers())
{
if (Clans.getClanUtility().isSafe(cur.getLocation()))
{
long lastDamager = Clans.getCombatManager().Get(cur).GetLastCombat();
@ -80,6 +81,7 @@ public class ClansGame extends MiniPlugin
Clans.getCondition().Factory().Custom("Unsafe", cur, cur, ConditionType.CUSTOM, 1, 0, false, Material.FIRE, (byte)0, true);
}
}
}
}
@EventHandler

View File

@ -47,6 +47,7 @@ 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.MapCommand;
import mineplex.game.clans.clans.commands.RegionsCommand;
import mineplex.game.clans.clans.commands.ServerTimeCommand;
import mineplex.game.clans.clans.loot.LootManager;
import mineplex.game.clans.clans.map.ItemMapManager;
@ -220,12 +221,18 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
public void addCommands()
{
addCommand(new ClansCommand(this));
addCommand(new RegionsCommand(this));
addCommand(new ClansChatCommand(this));
addCommand(new ClansAllyChatCommand(this));
addCommand(new ServerTimeCommand(this));
addCommand(new ClanManagementCommand(this));
addCommand(new MapCommand(this));
}
public ClansRegions getClanRegions()
{
return _clanRegions;
}
public ItemMapManager getItemMapManager()
{

View File

@ -0,0 +1,30 @@
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.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.regions.ClansRegions;
public class RegionsCommand extends CommandBase<ClansManager>
{
private ClansManager _manager;
public RegionsCommand(ClansManager plugin)
{
super(plugin, Rank.ADMIN, "region-reset");
_manager = plugin;
}
@Override
public void Execute(Player caller, String[] args)
{
UtilPlayer.message(caller, F.main("Regions", "Resetting clans regions!"));
_manager.getClanRegions().resetRegions();
}
}

View File

@ -1,5 +1,8 @@
package mineplex.game.clans.clans.regions;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.bukkit.Bukkit;
@ -15,10 +18,12 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.packethandler.PacketPlayOutWorldBorder;
import mineplex.game.clans.clans.ClanInfo;
@ -51,19 +56,47 @@ public class ClansRegions extends MiniPlugin
}
public void initializeRegions()
{
initializeRegions(false);
}
public void initializeRegions(boolean overrideCreation)
{
Location worldCenter = new Location(_world, 0, 0, 0);
// Initialize Spawn faction and claims
Set<Location> spawns = Spawn.getInstance().getSpawnLocations();
Location[] spawnsArray = spawns.toArray(new Location[spawns.size()]);
Location[] shopsArray = {Spawn.getEastShop(), Spawn.getWestShop()};
claimArea("Spawn", SPAWN_RADIUS, 0, true, spawnsArray);
claimArea("Shops", SHOP_RADIUS, 0, true, shopsArray);
claimArea("Spawn", SPAWN_RADIUS, 0, true, overrideCreation, new Location[]{Spawn.getNorthSpawn(), Spawn.getSouthSpawn()});
claimArea("Shops", SHOP_RADIUS, 0, true, overrideCreation, new Location[]{Spawn.getEastShop(), Spawn.getWestShop()});
// Initialize Fields and Borderlands factions and claims
claimArea("Fields", FIELDS_RADIUS, 0, false, worldCenter);
claimArea("Borderlands", BORDERLANDS_RADIUS, 32, false, worldCenter);
claimArea("Fields", FIELDS_RADIUS, 0, false, overrideCreation, worldCenter);
claimArea("Borderlands", BORDERLANDS_RADIUS, 32, false, overrideCreation, worldCenter);
}
public void resetRegions()
{
clearClaims("Spawn");
clearClaims("Shops");
clearClaims("Fields");
clearClaims("Borderlands");
initializeRegions(true);
}
private void clearClaims(String name)
{
System.out.println("Clearing claims for " + name + "!");
ClanInfo clan = _manager.getClan(name);
if (clan != null)
{
for (String chunk : clan.getClaimSet())
{
_manager.getClaimMap().remove(chunk);
}
clan.getClaimSet().clear();
_manager.getClanDataAccess().getRepository().removeTerritoryClaims(clan.getId());
}
}
/**
@ -75,11 +108,12 @@ public class ClansRegions extends MiniPlugin
* @param claimOffset - the initial offset in claim (creating a 'hole' with chunk offset radius)
* @param safe - whether the chunk claimed is considered a 'safe' (pvp-free) region.
*/
private void claimArea(final String clanName, final int chunkRadius, final int claimOffset, final boolean safe, final Location... locations)
private void claimArea(final String clanName, final int chunkRadius, final int claimOffset, final boolean safe,
boolean overrideCreation, final Location... locations)
{
final ClanInfo clan = _manager.getClan(clanName);
if (clan == null)
if (clan == null )
{
_manager.getClanDataAccess().create("ClansRegions", clanName, true, new Callback<ClanInfo>()
{
@ -102,6 +136,13 @@ public class ClansRegions extends MiniPlugin
}
});
}
else if (overrideCreation)
{
for (Location location : locations)
{
claimArea(clan, location, chunkRadius, claimOffset, safe);
}
}
}
private void claimArea(ClanInfo clan, Location location, int chunkRadius, int claimOffset, boolean safe)

View File

@ -43,6 +43,7 @@ public class ClanRepository extends RepositoryBase
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 = ?;";
private static String DELETE_CLAN_TERRITORY = "DELETE FROM clanTerritory WHERE clanId = ? AND serverId = ? AND chunk = ?;";
private static String DELETE_CLAN_ALL_TERRITORY = "DELETE FROM clanTerritory WHERE clanId = ? AND serverId = ?;";
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 = ?;";
@ -346,6 +347,11 @@ public class ClanRepository extends RepositoryBase
{
executeUpdate(DELETE_CLAN_TERRITORY, new ColumnInt("clanId", clanId), new ColumnInt("serverId", _serverId), new ColumnVarChar("chunk", 100, chunk));
}
public void removeTerritoryClaims(int clanId)
{
executeUpdate(DELETE_CLAN_ALL_TERRITORY, new ColumnInt("clanId", clanId), new ColumnInt("serverId", _serverId));
}
public void updateClan(int clanId, String name, String desc, String home, boolean admin, int energy, int kills, int murder, int deaths, int warWins, int warLosses, Timestamp lastOnline)
{