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

Conflicts:
	Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java
This commit is contained in:
NewGarbo 2016-02-02 22:02:06 +00:00
commit 9086188280
12 changed files with 259 additions and 39 deletions

7
.gitignore vendored
View File

@ -60,4 +60,9 @@ target/
# IntelliJ IDEA Files
*.iml
.idea/
.idea/
# Eclipse
.settings/
.classpath
.project

View File

@ -464,6 +464,11 @@ public class UtilBlock
return getHighest(world, x, z, null);
}
public static Block getHighest(World world, Location location)
{
return getHighest(world, location.getBlockX(), location.getBlockZ(), null);
}
public static Block getHighest(World world, int x, int z, HashSet<Material> ignore)
{
Block block = world.getHighestBlockAt(x, z);

View File

@ -1,15 +1,19 @@
package mineplex.core.common.util;
import java.util.Collection;
import java.util.List;
import java.util.function.Predicate;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.util.Vector;
import com.google.common.collect.Lists;
public class UtilWorld
{
public static World getWorld(String world)
@ -194,4 +198,15 @@ public class UtilWorld
return vec.toLocation(world);
}
private static List<Block> branch(Location origin)
{
return Lists.newArrayList(origin.getBlock(),
origin.getBlock().getRelative(BlockFace.DOWN),
origin.getBlock().getRelative(BlockFace.UP),
origin.getBlock().getRelative(BlockFace.NORTH),
origin.getBlock().getRelative(BlockFace.EAST),
origin.getBlock().getRelative(BlockFace.SOUTH),
origin.getBlock().getRelative(BlockFace.WEST));
}
}

View File

@ -67,6 +67,7 @@ public class ClanInfo
private HashMap<String, ClanWarData> _warOut = new HashMap<String, ClanWarData>();
// Temporary
private NautHashMap<String, Long> _recentlyLeft = new NautHashMap<>();
private NautHashMap<String, Long> _inviteeMap = new NautHashMap<String, Long>();
private NautHashMap<String, String> _inviterMap = new NautHashMap<String, String>();
private List<UUID> _onlinePlayers = new ArrayList<UUID>();
@ -76,6 +77,7 @@ public class ClanInfo
public ClansManager Clans;
private BedStatus _bedStatus = null;
public ClanInfo(ClansManager clans, ClanToken token)
{
@ -800,4 +802,9 @@ public class ClanInfo
{
return _bedStatus == BedStatus.DESTROYED ? C.cRed + "Destroyed" : (_bedStatus == BedStatus.DOESNT_EXIST ? C.cWhite + "None" : (_bedStatus == BedStatus.EXISTS_AND_OBSTRUCTED ? C.cRed + "Obstructed" : (_bedStatus == BedStatus.EXISTS_AND_UNOBSTRUCTED ? C.cGreen + UtilWorld.locToStrClean(_home) : "N/A")));
}
public void left(String name)
{
_recentlyLeft.put(name, System.currentTimeMillis());
}
}

View File

@ -39,7 +39,7 @@ import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.chat.Chat;
import mineplex.core.chat.MessageData;
import mineplex.core.common.Pair;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
@ -75,7 +75,6 @@ import mineplex.game.clans.clans.commands.ClanManagementCommand;
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.ClansLoginManager;
import mineplex.game.clans.clans.commands.KillCommand;
import mineplex.game.clans.clans.commands.MapCommand;
import mineplex.game.clans.clans.commands.RegionsCommand;
@ -97,6 +96,7 @@ import mineplex.game.clans.clans.stuck.StuckManager;
import mineplex.game.clans.clans.supplyDrop.SupplyDropManager;
import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager;
import mineplex.game.clans.clans.war.WarManager;
import mineplex.game.clans.clans.warpoints.WarPointEvasion;
import mineplex.game.clans.clans.worldevent.WorldEventManager;
import mineplex.game.clans.core.ClanDeleteCommand;
import mineplex.game.clans.core.ClanLoadCommand;
@ -199,6 +199,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
// private NautHashMap<String, ClanInfo> _clanMemberNameMap = new
// NautHashMap<String, ClanInfo>();
private NautHashMap<UUID, ClanInfo> _clanMemberUuidMap = new NautHashMap<UUID, ClanInfo>();
private NautHashMap<UUID, Pair<ClanInfo, Long>> _clanMemberLeftMap = new NautHashMap<>();
private NautHashMap<String, ClanTerritory> _claimMap = new NautHashMap<String, ClanTerritory>();
private NautHashMap<String, Long> _unclaimMap = new NautHashMap<String, Long>();
@ -257,6 +258,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
_explosion = new Explosion(plugin, blockRestore);
new WarPointEvasion(plugin);
// new ClansLoginManager(getPlugin(), clientManager, _serverName);
_clanShop = new ClanShop(this, clientManager, donationManager);
@ -584,6 +587,13 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
{
player.setOp(true);
}
if(player.getInventory().getHelmet() != null) { //Reset helmet to fix 1 damage bug
ItemStack helmet = player.getInventory().getHelmet().clone();
player.getInventory().setHelmet(null);
runSyncLater(() -> {
player.getInventory().setHelmet(helmet);
}, 5L);
}
}
@EventHandler
@ -1136,4 +1146,19 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
ClansPlayerDeathEvent clansPlayerDeathEvent = new ClansPlayerDeathEvent(event, playerClan, killerClan);
Bukkit.getServer().getPluginManager().callEvent(clansPlayerDeathEvent);
}
public void justLeft(UUID uniqueId, ClanInfo clan)
{
_clanMemberLeftMap.put(uniqueId, Pair.create(clan, System.currentTimeMillis()));
}
public Pair<ClanInfo, Long> leftRecently(UUID uniqueId, long time)
{
if (_clanMemberLeftMap.containsKey(uniqueId) && (System.currentTimeMillis() - _clanMemberLeftMap.get(uniqueId).getRight()) <= time)
{
return Pair.create(_clanMemberLeftMap.get(uniqueId).getLeft(), time - (System.currentTimeMillis() - _clanMemberLeftMap.get(uniqueId).getRight()));
}
return null;
}
}

View File

@ -632,6 +632,8 @@ public class ClansUtility
// Inform
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You left " + F.elem("Clan " + clan.getName()) + "."));
clan.inform(F.name(caller.getName()) + " has left your Clan.", null);
clan.left(caller.getName());
}
});
}
@ -677,8 +679,8 @@ public class ClansUtility
if (!data)
{
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "There was an error processing your request. Try again later"));
}else
}
else
{
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You disbanded your Clan."));
}

View File

@ -1,10 +1,17 @@
package mineplex.game.clans.clans.commands;
import java.util.Collections;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.google.common.collect.Lists;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
@ -13,6 +20,7 @@ import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilInput;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
@ -30,6 +38,7 @@ import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClientClan;
import mineplex.game.clans.clans.event.ClanJoinEvent;
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
import mineplex.game.clans.core.repository.ClanTerritory;
import net.minecraft.server.v1_8_R3.EnumDirection;
public class ClansCommand extends CommandBase<ClansManager>
@ -105,6 +114,8 @@ public class ClansCommand extends CommandBase<ClansManager>
else if (args[0].equalsIgnoreCase("sethome"))
homeSet(caller);
else if (args[0].equalsIgnoreCase("stuck"))
stuck(caller);
/*
* else if (args[0].equalsIgnoreCase("enemy") || args[0].equals("e"))
@ -211,6 +222,8 @@ public class ClansCommand extends CommandBase<ClansManager>
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c map <toggle>", "View Clan Map", Rank.ALL));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/cc (Message)", "Clan Chat (Toggle)", Rank.ALL));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c stuck", "Teleports you to the nearest Wilderness location", Rank.ALL));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c promote <player>", "Promote Player in Clan", Rank.MODERATOR));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c demote <player>", "Demote Player in Clan", Rank.MODERATOR));
@ -242,6 +255,12 @@ public class ClansCommand extends CommandBase<ClansManager>
return;
}
if (Plugin.leftRecently(caller.getUniqueId(), 20 * 60 * 1000) != null)
{
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot create a Clan for " + C.mTime + UtilTime.MakeStr(Plugin.leftRecently(caller.getUniqueId(), 20 * 60 * 1000).getRight()) + C.mBody + "."));
return;
}
/*
* TODO if (!client.canJoin()) { _manager.getTutorials().sendTutorialMsg(caller,
* F.main("Clans", "You cannot join a Clan for " + C.mTime +
@ -344,6 +363,83 @@ public class ClansCommand extends CommandBase<ClansManager>
Plugin.getClanUtility().invite(caller, clan, target);
}
public void stuck(final Player caller)
{
ClanTerritory territory = Plugin.getClanUtility().getClaim(caller.getLocation());
String clanName = Plugin.getClanUtility().getClanByPlayer(caller) == null ? null : Plugin.getClanUtility().getClanByPlayer(caller).getName();
if (territory == null || territory.Safe || territory.Owner.equals(clanName))
{
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must be in another Clan's territory to use this."));
return;
}
DelayedTask.Instance.doDelay(caller, "Wilderness Teleport", new Callback<DelayedTaskClient>() {
public void run(DelayedTaskClient player)
{
// Do
Location loc = getWildLoc(player.getPlayer().getLocation());
if (loc == null)
{
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Error whilst finding location to teleport to."));
return;
}
player.getPlayer().teleport(loc);
// Inform
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You have been teleported to the Wilderness."));
}
}, new Callback<DelayedTaskClient>() {
public void run(DelayedTaskClient client)
{
UtilTextMiddle.display("", "Teleporting to Wilderness in " + F.elem(UtilTime.MakeStr(Math.max(0, client.getTimeLeft("Wilderness Teleport")))), 0, 5, 0, client.getPlayer());
}
}, new Callback<DelayedTaskClient>() {
public void run(DelayedTaskClient client)
{
UtilPlayer.message(client.getPlayer(), F.main("Clans", "Teleport has been cancelled due to movement."));
}
}, 7 * 1000, false);
}
public Location getWildLoc(Location origin)
{
Chunk wildLoc = origin.getChunk();
List<Chunk> worldChunks = Lists.newArrayList(origin.getWorld().getLoadedChunks());
Collections.sort(
worldChunks,
(c1, c2) ->
(int) ((int)
origin.distance(
UtilBlock.getHighest(origin.getWorld(),
c1.getBlock(7, origin.getBlockY(), 7).getLocation()
).getLocation())
-
origin.distance(
UtilBlock.getHighest(origin.getWorld(),
c2.getBlock(7, origin.getBlockY(), 7).getLocation()
).getLocation())
)
);
for (Chunk chunk : worldChunks)
{
if (Plugin.getClanUtility().getClaim(chunk) == null)
{
return chunk.getBlock(6, UtilBlock.getHighest(origin.getWorld(), chunk.getBlock(6, 0, 6).getLocation()).getY(), 6).getLocation();
}
}
return null;
}
public void join(final Player caller, String[] args)
{
if (Plugin.getClanMemberUuidMap().containsKey(caller.getUniqueId()))
@ -352,6 +448,12 @@ public class ClansCommand extends CommandBase<ClansManager>
return;
}
if (Plugin.leftRecently(caller.getUniqueId(), 20 * 60 * 1000) != null)
{
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.MakeStr(Plugin.leftRecently(caller.getUniqueId(), 20 * 60 * 1000).getRight()) + C.mBody + "."));
return;
}
if (!Plugin.Get(caller).canJoin())
{
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.convertString(System.currentTimeMillis() - Plugin.Get(caller).getDelay(), 1, TimeUnit.FIT) + C.mBody + "."));
@ -438,6 +540,8 @@ public class ClansCommand extends CommandBase<ClansManager>
// Inform
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You left " + F.elem("Clan " + clan.getName()) + "."));
clan.inform(F.name(caller.getName()) + " has left your Clan.", null);
_manager.justLeft(caller.getUniqueId(), clan);
}
});
}

View File

@ -25,9 +25,9 @@ import mineplex.core.scoreboard.elements.ScoreboardElement;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClanTips.TipType;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClansUtility;
import mineplex.game.clans.clans.ClanTips.TipType;
import mineplex.game.clans.clans.event.ClanDisbandedEvent;
import mineplex.game.clans.clans.event.ClansPlayerDeathEvent;
import mineplex.game.clans.clans.war.command.WarPointsCommand;
@ -38,7 +38,7 @@ import mineplex.game.clans.core.war.ClanWarData;
public class WarManager extends MiniPlugin implements ScoreboardElement
{
public static final int WAR_START_POINTS = 0;
public static final int WAR_FINISH_POINTS = 20;
public static final int WAR_FINISH_POINTS = 25;
public static final long INVADE_LENGTH = 60000L * 30; // 30 Minutes
public static final long WAR_COOLDOWN = 60000L * 30; // 30 Minutes
@ -117,11 +117,18 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
@EventHandler
public void handleDeath(final ClansPlayerDeathEvent event)
{
if (event.getPlayer() != null && event.getPlayer().getClan() != null)
ClanInfo deathClan = event.getPlayer().getClan();
if (deathClan == null)
{
deathClan = _clansManager.leftRecently(event.getPlayer().getPlayer().getUniqueId(), 60000) == null ? deathClan : _clansManager.leftRecently(event.getPlayer().getPlayer().getUniqueId(), 60000).getLeft();
}
if (event.getPlayer() != null && deathClan != null)
{
if (event.getKiller() != null && event.getKiller().getClan() != null)
{
final ClanInfo clan = event.getPlayer().getClan();
final ClanInfo clan = deathClan;
final ClanInfo killerClan = event.getKiller().getClan();
ClanWarData war = clan.getWarData(killerClan);

View File

@ -0,0 +1,52 @@
package mineplex.game.clans.clans.warpoints;
import com.google.common.collect.Maps;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent;
import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent;
import org.bukkit.Chunk;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashMap;
public class WarPointEvasion extends MiniPlugin{
private HashMap<Chunk, Long> _cooldown;
private final long COOLDOWN_TIME = 1000 * 60 * 30;
public WarPointEvasion(JavaPlugin plugin) {
super("WP Evasion", plugin);
_cooldown = Maps.newHashMap();
}
@EventHandler
public void updateCooldown(UpdateEvent event) {
if(!event.getType().equals(UpdateType.SEC)) return;
_cooldown.keySet().stream().filter(chunk -> UtilTime.elapsed(_cooldown.get(chunk), COOLDOWN_TIME)).forEach(chunk -> _cooldown.remove(chunk));
}
@EventHandler
public void onClaim(PlayerPreClaimTerritoryEvent event) {
Chunk chunk = event.getClaimedChunk();
if(_cooldown.containsKey(chunk)) {
event.setCancelled(true);
event.getClaimer().sendMessage(F.main("Clans", "You cannot claim this chunk for another " + UtilTime.convertString(System.currentTimeMillis() - _cooldown.get(chunk), 1, UtilTime.TimeUnit.MINUTES)));
}
}
@EventHandler
public void onunClaim(PlayerUnClaimTerritoryEvent event) {
Chunk chunk = event.getUnClaimedChunk();
if(_cooldown.containsKey(chunk)) {
// Error maybe?
_cooldown.remove(chunk);
}
_cooldown.put(chunk, System.currentTimeMillis());
}
}

View File

@ -130,7 +130,10 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
// TODO: Introduce configurable non-hardcoded values for generation
// weights?
_attributeWeights = new WeightSet<Integer>(new Weight<Integer>(3, 3), new Weight<Integer>(20, 2), new Weight<Integer>(77, 1));
_typeWeights = new WeightSet<ItemType>(new Weight<ItemType>(10, ItemType.LEGENDARY), new Weight<ItemType>(45, ItemType.ARMOR), new Weight<ItemType>(23, ItemType.WEAPON), new Weight<ItemType>(22, ItemType.BOW));
_typeWeights = new WeightSet<ItemType>(new Weight<ItemType>(6, ItemType.LEGENDARY),
new Weight<ItemType>(46, ItemType.ARMOR),
new Weight<ItemType>(25, ItemType.WEAPON),
new Weight<ItemType>(23, ItemType.BOW));
// Weapon-based attributes
_weaponAttributes = new WeightSet<Class<? extends ItemAttribute>>(FrostedAttribute.class, SharpAttribute.class, JaggedAttribute.class, HasteAttribute.class, FlamingAttribute.class, ConqueringAttribute.class);

View File

@ -44,7 +44,6 @@
<configuration>
<artifactSet>
<excludes>
<exclude>commons-codec:commons-codec</exclude>
<exclude>com.google.code.gson:gson</exclude>
<exclude>com.mineplex:spigot</exclude>
</excludes>

View File

@ -122,7 +122,7 @@
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.7.2</version>
<version>2.6.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
@ -177,32 +177,28 @@
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>net.md-5</groupId>
<artifactId>
scriptus
</artifactId>
<versionRange>
[0.3.1,)
</versionRange>
<goals>
<goal>describe</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>net.md-5</groupId>
<artifactId>scriptus</artifactId>
<versionRange>[0.3.1,)</versionRange>
<goals>
<goal>describe</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>