Merge branch 'clans-beta' of ssh://184.154.0.242:7999/min/Mineplex into clans-beta

This commit is contained in:
NewGarbo 2015-11-26 13:17:28 +00:00
commit e5fa59b8da
5 changed files with 60 additions and 43 deletions

View File

@ -1096,5 +1096,29 @@ public class ClansUtility
return true;
}
public void invite(Player caller, ClanInfo clan, Player target)
{
if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
{
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can send invites."));
return;
}
if (target.getName().equals(caller.getName()))
{
UtilPlayer.message(caller, F.main("Clans", "You cannot invite yourself."));
return;
}
// Inform
clan.inform(F.name(caller.getName()) + " invited " + F.name(target.getName()) + " to join your Clan.", caller.getName());
UtilPlayer.message(caller, F.main("Clans", "You invited " + F.name(target.getName()) + " to join your Clan."));
UtilPlayer.message(target, F.main("Clans", F.name(caller.getName()) + " invited you to join " + F.elem("Clan " + clan.getName()) + "."));
UtilPlayer.message(target, F.main("Clans", "Type " + F.elem("/c join " + clan.getName()) + " to accept!"));
// Task
Clans.getClanDataAccess().invite(clan, target.getName(), caller.getName());
}
}

View File

@ -17,10 +17,12 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.Clans;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClanRole;
import mineplex.game.clans.clans.ClansBlacklist;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClansUtility;
import mineplex.game.clans.clans.ClientClan;
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
import mineplex.game.clans.tutorials.TutorialManager;
@ -299,12 +301,6 @@ public class ClansCommand extends CommandBase<ClansManager>
return;
}
if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
{
UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can send invites."));
return;
}
if (args.length < 2)
{
UtilPlayer.message(caller, F.main("Clans", "You did not input an invitee."));
@ -313,21 +309,8 @@ public class ClansCommand extends CommandBase<ClansManager>
Player target = UtilPlayer.searchOnline(caller, args[1], true);
if (target == null) return;
if (target.getName().equals(caller.getName()))
{
UtilPlayer.message(caller, F.main("Clans", "You cannot invite yourself."));
return;
}
// Inform
clan.inform(F.name(caller.getName()) + " invited " + F.name(target.getName()) + " to join your Clan.", caller.getName());
UtilPlayer.message(caller, F.main("Clans", "You invited " + F.name(target.getName()) + " to join your Clan."));
UtilPlayer.message(target, F.main("Clans", F.name(caller.getName()) + " invited you to join " + F.elem("Clan " + clan.getName()) + "."));
UtilPlayer.message(target, F.main("Clans", "Type " + F.elem("/c join " + clan.getName()) + " to accept!"));
// Task
Plugin.getClanDataAccess().invite(clan, target.getName(), caller.getName());
Plugin.getClanUtility().invite(caller, clan, target);
}
public void join(final Player caller, String[] args)

View File

@ -43,7 +43,7 @@ public class ClanInvitePage extends ClanPageBase
{
if (index <= 54 && getPlugin().getClan(player) == null)
{
addPlayerButton(index, player);
addPlayerButton(index, player, clanInfo);
index++;
}
}
@ -59,22 +59,22 @@ public class ClanInvitePage extends ClanPageBase
addBackButton();
}
private void addPlayerButton(int slot, Player player)
private void addPlayerButton(int slot, final Player target, final ClanInfo clan)
{
String itemName = C.cGreenB + player.getName();
String itemName = C.cGreenB + target.getName();
ArrayList<String> lore = new ArrayList<String>(5);
lore.add(" ");
lore.add(" ");
lore.add(ChatColor.RESET + C.cGray + "Left Click " + C.cWhite + "Invite Player");
ItemStack item = UtilSkull.getPlayerHead(player.getName(), itemName, lore);
ItemStack item = UtilSkull.getPlayerHead(target.getName(), itemName, lore);
addButton(slot, item, new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
getPlugin().getClanUtility().invite(getPlayer(), clan, target);
}
});
}

View File

@ -49,14 +49,14 @@ public class ClansRegions extends MiniPlugin
Location worldCenter = new Location(_world, 0, 0, 0);
// Initialize Spawn faction and claims
claimArea("Spawn", SPAWN_RADIUS, 0, false, new Location[]{Spawn.getEastSpawn(), Spawn.getWestSpawn()});
claimArea("Shops", SHOP_RADIUS, 1, false, new Location[]{Spawn.getNorthTownCenter(), Spawn.getSouthTownCenter()});
claimArea("Shops", SHOP_RADIUS, 0, true, new Location[]{Spawn.getNorthTownCenter(), Spawn.getSouthTownCenter()});
claimArea("Spawn", SPAWN_RADIUS, 0, false, true, new Location[]{Spawn.getEastSpawn(), Spawn.getWestSpawn()});
claimArea("Shops", SHOP_RADIUS, 2, false, false, new Location[]{Spawn.getNorthTownCenter(), Spawn.getSouthTownCenter()});
claimArea("Shops", SHOP_RADIUS, 0, true, false, new Location[]{Spawn.getNorthTownCenter(), Spawn.getSouthTownCenter()});
// 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, true, worldCenter);
claimArea("Borderlands", BORDERLANDS_RADIUS, 32, false, true, worldCenter);
//debugClan("Spawn");
//debugClan("Shops");
@ -120,7 +120,7 @@ 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, final boolean addNegative, final Location... locations)
{
final ClanInfo clan = _manager.getClan(clanName);
@ -135,7 +135,7 @@ public class ClansRegions extends MiniPlugin
{
for (Location location : locations)
{
claimArea(data, location, chunkRadius, claimOffset, safe);
claimArea(data, location, chunkRadius, claimOffset, addNegative, safe);
log(String.format("Initialized %s faction territory and creation!", clanName));
}
@ -153,7 +153,7 @@ public class ClansRegions extends MiniPlugin
{
for (Location location : locations)
{
claimArea(clan, location, chunkRadius, claimOffset, safe);
claimArea(clan, location, chunkRadius, claimOffset, addNegative, safe);
}
}
}
@ -163,24 +163,34 @@ public class ClansRegions extends MiniPlugin
claimArea(clanName, chunkRadius, claimOffset, 0, safe, locations);
}*/
private void claimArea(ClanInfo clan, Location location, int chunkRadius, int claimOffset, boolean safe)
private void claimArea(ClanInfo clan, Location location, int chunkRadius, int claimOffset, boolean addNegative, boolean safe)
{
int chunkX = location.getChunk().getX();
int chunkZ = location.getChunk().getZ();
Set<String> chunks = new HashSet<String>();
for (int xOffset = -chunkRadius - 1; xOffset <= chunkRadius; xOffset++)
int start = addNegative ? -chunkRadius - 1 : -chunkRadius;
for (int xOffset = start; xOffset <= chunkRadius; xOffset++)
{
for (int zOffset = -chunkRadius - 1; zOffset <= chunkRadius; zOffset++)
for (int zOffset = start; zOffset <= chunkRadius; zOffset++)
{
int x = chunkX + xOffset;
int z = chunkZ + zOffset;
Chunk chunk = location.getWorld().getChunkAt(x, z);
String chunkStr = UtilWorld.chunkToStr(chunk);
if (((xOffset < 0 && Math.abs(xOffset) < (claimOffset + 1)) || (xOffset >= 0 && xOffset < claimOffset)) &&
((zOffset < 0 && Math.abs(zOffset) < (claimOffset + 1)) || (zOffset >= 0 && zOffset < claimOffset)))
continue;
if (addNegative)
{
if (((xOffset < 0 && Math.abs(xOffset) < (claimOffset + 1)) || (xOffset >= 0 && xOffset < claimOffset)) &&
((zOffset < 0 && Math.abs(zOffset) < (claimOffset + 1)) || (zOffset >= 0 && zOffset < claimOffset)))
continue;
}
else
{
if ((Math.abs(xOffset) < claimOffset) && (Math.abs(zOffset) < claimOffset))
continue;
}
if (_manager.getClaimMap().containsKey(chunkStr))
{

View File

@ -409,7 +409,7 @@ public class Spawn extends MiniPlugin
public static Location getNorthTownCenter()
{
return new Location(getSpawnWorld(), 6, 75, -311);
return new Location(getSpawnWorld(), 7, 75, -311);
}
public static Location getEastSpawn()