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

This commit is contained in:
Shaun Bennett 2015-11-26 00:20:41 -05:00
commit 389956240b
4 changed files with 168 additions and 5 deletions

View File

@ -209,7 +209,7 @@ public class ClansGame extends MiniPlugin
event.setCancelled(true);
// Inform
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You can not break blocks in " + _clans.getClanUtility().getOwnerStringRel(event.getBlock().getLocation(), event.getPlayer()) + "'s Territory."));
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You can not break blocks in " + _clans.getClanUtility().getOwnerStringRel(event.getBlock().getLocation(), event.getPlayer()) + C.mBody + "'s Territory."));
}
// Disallow Recruit Chest
@ -239,7 +239,7 @@ public class ClansGame extends MiniPlugin
event.setCancelled(true);
// Inform
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You can not break blocks in " + _clans.getClanUtility().getOwnerStringRel(event.getBlock().getLocation(), event.getPlayer()) + "'s Territory." + mimic));
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You can not break blocks in " + _clans.getClanUtility().getOwnerStringRel(event.getBlock().getLocation(), event.getPlayer()) + C.mBody + "'s Territory." + mimic));
}
@EventHandler
@ -415,7 +415,7 @@ public class ClansGame extends MiniPlugin
event.setCancelled(true);
// Inform
UtilPlayer.message(player, F.main("Clans", "You cannot use items in " + _clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getLocation(), player) + "." + mimic));
UtilPlayer.message(player, F.main("Clans", "You cannot use items in " + _clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getLocation(), player) + C.mBody + "'s Territory." + mimic));
return;
}
@ -434,7 +434,7 @@ public class ClansGame extends MiniPlugin
event.setCancelled(true);
// Inform
UtilPlayer.message(player, F.main("Clans", "You cannot use items in " + _clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getLocation(), player) + "'s Territory." + mimic));
UtilPlayer.message(player, F.main("Clans", "You cannot use items in " + _clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getLocation(), player) + C.mBody + "'s Territory." + mimic));
return;
}
@ -451,7 +451,7 @@ public class ClansGame extends MiniPlugin
event.setCancelled(true);
// Inform
UtilPlayer.message(player, F.main("Clans", "You cannot place blocks in " + _clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getRelative(event.getBlockFace()).getLocation(), player) + "'s Territory." + mimic));
UtilPlayer.message(player, F.main("Clans", "You cannot place blocks in " + _clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getRelative(event.getBlockFace()).getLocation(), player) + C.mBody + "'s Territory." + mimic));
return;
}

View File

@ -0,0 +1,15 @@
package mineplex.game.clans.clans.stuck;
import org.bukkit.Location;
public class StuckClient
{
public Location StartLoc = null;
public long UnstickStartTime = -1;
public long UnstickEndTime = -1;
public long getTimeLeft()
{
return UnstickEndTime - System.currentTimeMillis();
}
}

View File

@ -0,0 +1,109 @@
package mineplex.game.clans.clans.stuck;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.MiniClientPlugin;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.stuck.commands.StuckCommand;
import mineplex.game.clans.spawn.Spawn;
public class StuckManager extends MiniClientPlugin<StuckClient>
{
public static final long UNSTICK_WAIT_TIME = UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS);
public StuckManager(ClansManager clans)
{
super("Stuck Handler", clans.getPlugin());
}
@Override
public void addCommands()
{
addCommand(new StuckCommand(this));
}
@Override
protected StuckClient AddPlayer(String player)
{
return new StuckClient();
}
public void unstick(Player player)
{
Get(player).UnstickStartTime = System.currentTimeMillis();
Get(player).UnstickEndTime = Get(player).UnstickStartTime + UNSTICK_WAIT_TIME;
Get(player).StartLoc = player.getLocation();
}
public boolean isUnsticking(Player caller)
{
return Get(caller).UnstickStartTime != -1;
}
@EventHandler
public void updateTeleport(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTER)
{
for (Player player : Bukkit.getOnlinePlayers())
{
if (isUnsticking(player))
{
if (player.getLocation().distance(Get(player).StartLoc) >= 0.75)
{
cancelTeleport(player);
break;
}
UtilTextMiddle.display("", "Teleporting to Spawn in " + F.elem(UtilTime.MakeStr(Get(player).getTimeLeft())), 0, 20, 60, player);
if (Get(player).getTimeLeft() <= 500)
{
teleport(player);
}
}
}
}
}
private void cancelTeleport(Player player)
{
UtilPlayer.message(player, "You have moved, and cancelled the teleport.");
Get(player).UnstickStartTime = -1;
Get(player).UnstickEndTime = -1;
Get(player).StartLoc = null;
}
private void teleport(Player player)
{
Recharge.Instance.use(player, "Spawn Teleport", UtilTime.convert(15, TimeUnit.MINUTES, TimeUnit.MILLISECONDS), false, false);
UtilPlayer.message(player, "You have been teleported to Spawn.");
Get(player).UnstickStartTime = -1;
Get(player).UnstickEndTime = -1;
Get(player).StartLoc = null;
if (Math.random() < .5)
{
player.teleport(Spawn.getEastSpawn());
}
else
{
player.teleport(Spawn.getWestSpawn());
}
}
}

View File

@ -0,0 +1,39 @@
package mineplex.game.clans.clans.stuck.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.core.common.util.UtilTime;
import mineplex.core.recharge.Recharge;
import mineplex.game.clans.clans.stuck.StuckManager;
public class StuckCommand extends CommandBase<StuckManager>
{
public StuckCommand(StuckManager plugin)
{
super(plugin, Rank.ALL, "spawn", "stuck", "unstick", "unstuck");
}
@Override
public void Execute(Player caller, String[] args)
{
if (Plugin.isUnsticking(caller))
{
UtilPlayer.message(caller, F.main("Clans", "You are already teleporting to Spawn."));
return;
}
if (!Recharge.Instance.usable(caller, "Spawn Teleport", true))
{
return;
}
UtilPlayer.message(caller, F.main("Clans", "Teleporting to Spawn... Please do not move for " + F.elem(UtilTime.MakeStr(StuckManager.UNSTICK_WAIT_TIME))) + ".");
Plugin.unstick(caller);
}
}