fixed some teleportation bugs and a bit of cleanup
This commit is contained in:
parent
e88736c1aa
commit
d92f817efc
@ -62,4 +62,14 @@ public class DelayedTask extends MiniClientPlugin<DelayedTaskClient>
|
|||||||
{
|
{
|
||||||
return new DelayedTaskClient(Bukkit.getPlayer(player));
|
return new DelayedTaskClient(Bukkit.getPlayer(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean HasTask(Player player, String task)
|
||||||
|
{
|
||||||
|
return Get(player).getStartTime(task) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean HasTask(String player, String task)
|
||||||
|
{
|
||||||
|
return HasTask(Bukkit.getPlayer(player), task);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,6 @@ import mineplex.game.clans.clans.redis.ClanLoadCommandHandler;
|
|||||||
import mineplex.game.clans.clans.regions.ClansRegions;
|
import mineplex.game.clans.clans.regions.ClansRegions;
|
||||||
import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
|
import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
|
||||||
import mineplex.game.clans.clans.siege.SiegeManager;
|
import mineplex.game.clans.clans.siege.SiegeManager;
|
||||||
import mineplex.game.clans.clans.stuck.StuckManager;
|
|
||||||
import mineplex.game.clans.clans.supplyDrop.SupplyDropManager;
|
import mineplex.game.clans.clans.supplyDrop.SupplyDropManager;
|
||||||
import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager;
|
import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager;
|
||||||
import mineplex.game.clans.clans.war.WarManager;
|
import mineplex.game.clans.clans.war.WarManager;
|
||||||
@ -281,7 +280,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
|||||||
new ObserverManager(plugin, _condition, this);
|
new ObserverManager(plugin, _condition, this);
|
||||||
|
|
||||||
new ClanEnergyTracker(plugin, this);
|
new ClanEnergyTracker(plugin, this);
|
||||||
new StuckManager(this);
|
|
||||||
|
|
||||||
// new ClansAlphaManager(this, taskManager);
|
// new ClansAlphaManager(this, taskManager);
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
package mineplex.game.clans.clans.commands;
|
package mineplex.game.clans.clans.commands;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -9,7 +10,6 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
@ -20,7 +20,6 @@ import mineplex.core.common.util.Callback;
|
|||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilBlock;
|
import mineplex.core.common.util.UtilBlock;
|
||||||
import mineplex.core.common.util.UtilInput;
|
import mineplex.core.common.util.UtilInput;
|
||||||
import mineplex.core.common.util.UtilMath;
|
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.common.util.UtilTextMiddle;
|
import mineplex.core.common.util.UtilTextMiddle;
|
||||||
@ -372,6 +371,13 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (DelayedTask.Instance.HasTask(caller, "Spawn Teleport"))
|
||||||
|
{
|
||||||
|
_clansManager.message(caller, "You are already unsticking yourself.");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ClanTerritory territory = Plugin.getClanUtility().getClaim(caller.getLocation());
|
ClanTerritory territory = Plugin.getClanUtility().getClaim(caller.getLocation());
|
||||||
|
|
||||||
String clanName = Plugin.getClanUtility().getClanByPlayer(caller) == null ? null : Plugin.getClanUtility().getClanByPlayer(caller).getName();
|
String clanName = Plugin.getClanUtility().getClanByPlayer(caller) == null ? null : Plugin.getClanUtility().getClanByPlayer(caller).getName();
|
||||||
@ -913,7 +919,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!Recharge.Instance.use(caller, "Home Teleport", 5 * 60 * 1000, true, false))
|
if (!Recharge.Instance.usable(caller, "Home Teleport", true))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -921,6 +927,8 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
DelayedTask.Instance.doDelay(caller, "Home Teleport", new Callback<DelayedTaskClient>() {
|
DelayedTask.Instance.doDelay(caller, "Home Teleport", new Callback<DelayedTaskClient>() {
|
||||||
public void run(DelayedTaskClient player)
|
public void run(DelayedTaskClient player)
|
||||||
{
|
{
|
||||||
|
Recharge.Instance.use(caller, "Home Teleport", 5 * 60 * 1000, true, false);
|
||||||
|
|
||||||
// Do
|
// Do
|
||||||
Plugin.getTeleport().TP(caller, clan.getHome().add(0, 1, 0));
|
Plugin.getTeleport().TP(caller, clan.getHome().add(0, 1, 0));
|
||||||
|
|
||||||
|
@ -1,109 +0,0 @@
|
|||||||
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(35, TimeUnit.SECONDS, 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, F.main("Clans", "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, F.main("Clans", "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());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,77 @@
|
|||||||
|
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.Callback;
|
||||||
|
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.delayedtask.DelayedTask;
|
||||||
|
import mineplex.core.delayedtask.DelayedTaskClient;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
|
import mineplex.game.clans.spawn.Spawn;
|
||||||
|
|
||||||
|
public class ClansSpawnCommand extends CommandBase<Spawn>
|
||||||
|
{
|
||||||
|
public ClansSpawnCommand(Spawn spawn)
|
||||||
|
{
|
||||||
|
super(spawn, Rank.ALL, "spawn", "stuck", "unstick", "unstuck");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Execute(Player caller, String[] args)
|
||||||
|
{
|
||||||
|
if (DelayedTask.Instance.HasTask(caller, "Spawn Teleport"))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans", "You are already teleporting to Spawn."));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Recharge.Instance.usable(caller, "Spawn Teleport", true))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()) != null && !ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()).Owner.equals("Borderlands") &&
|
||||||
|
!ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()).Owner.equals("Shops") && !ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()).Owner.equals("Spawn"))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans", "You must be in the Wilderness/Borderlands/Shops/Spawn to use this command."));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DelayedTask.Instance.doDelay(caller, "Spawn Teleport", new Callback<DelayedTaskClient>() {
|
||||||
|
public void run(DelayedTaskClient player)
|
||||||
|
{
|
||||||
|
// Do
|
||||||
|
|
||||||
|
if (Math.random() < .5)
|
||||||
|
{
|
||||||
|
caller.teleport(Spawn.getEastSpawn());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
caller.teleport(Spawn.getWestSpawn());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inform
|
||||||
|
Plugin.getClansManager().getTutorials().sendTutorialMsg(caller, F.main("Clans", "You have been teleported to Spawn."));
|
||||||
|
}
|
||||||
|
}, new Callback<DelayedTaskClient>() {
|
||||||
|
public void run(DelayedTaskClient client)
|
||||||
|
{
|
||||||
|
UtilTextMiddle.display("", "Teleporting to Spawn in " + F.elem(UtilTime.MakeStr(Math.max(0, client.getTimeLeft("Spawn 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."));
|
||||||
|
}
|
||||||
|
}, 2 * 60 * 1000, false);
|
||||||
|
}
|
||||||
|
}
|
@ -1,48 +0,0 @@
|
|||||||
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.ClansManager;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()) != null && !ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()).Owner.equals("Borderlands") &&
|
|
||||||
!ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()).Owner.equals("Shops") && !ClansManager.getInstance().getClanUtility().getClaim(caller.getLocation()).Owner.equals("Spawn"))
|
|
||||||
{
|
|
||||||
UtilPlayer.message(caller, F.main("Clans", "You must be in the Wilderness/Borderlands/Shops/Spawn to use this command."));
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -50,7 +50,7 @@ public class ChitauriScepter extends LegendaryItem
|
|||||||
{
|
{
|
||||||
if ((System.currentTimeMillis() - _lastBlock) < 98 && (System.currentTimeMillis() - _interactWait) >= 98)
|
if ((System.currentTimeMillis() - _lastBlock) < 98 && (System.currentTimeMillis() - _interactWait) >= 98)
|
||||||
{
|
{
|
||||||
if (Recharge.Instance.use(wielder, getDisplayName(), 4000, true, true))
|
if (Recharge.Instance.use(wielder, "Chitauri Scepter", 4000, true, true))
|
||||||
{
|
{
|
||||||
fire(wielder);
|
fire(wielder);
|
||||||
|
|
||||||
@ -93,11 +93,12 @@ public class ChitauriScepter extends LegendaryItem
|
|||||||
{
|
{
|
||||||
if (entity != player)
|
if (entity != player)
|
||||||
{
|
{
|
||||||
ClansManager.getInstance().getDamageManager().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, damage, true,
|
ClansManager.getInstance().getDamageManager().NewDamageEvent(entity, player, null,
|
||||||
true, false, getDisplayName(), getDisplayName());
|
DamageCause.CUSTOM, damage, true, true, false,
|
||||||
|
player.getName(), "Chitauri Scepter");
|
||||||
|
|
||||||
UtilPlayer.message(entity, F.main("Clans", F.elem(entity.getName()) + " hit you with a " + getDisplayName() + C.mBody + "."));
|
UtilPlayer.message(entity, F.main("Clans", F.elem(entity.getName()) + " hit you with a " + F.elem("Chitauri Scepter") + C.mBody + "."));
|
||||||
UtilPlayer.message(player, F.main("Clans", "You hit " + F.elem(player.getName()) + " with your " + getDisplayName() + C.mBody + "."));
|
UtilPlayer.message(player, F.main("Clans", "You hit " + F.elem(player.getName()) + " with your " + F.elem("Chitauri Scepter") + C.mBody + "."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ import mineplex.core.common.util.UtilTime.TimeUnit;
|
|||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.game.clans.clans.ClansManager;
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
|
import mineplex.game.clans.clans.stuck.commands.ClansSpawnCommand;
|
||||||
import mineplex.core.common.weight.WeightSet;
|
import mineplex.core.common.weight.WeightSet;
|
||||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||||
import mineplex.minecraft.game.classcombat.item.event.WebTossEvent;
|
import mineplex.minecraft.game.classcombat.item.event.WebTossEvent;
|
||||||
@ -77,6 +78,8 @@ public class Spawn extends MiniPlugin
|
|||||||
_spawns = new WeightSet<Location>(getEastSpawn(), getWestSpawn());
|
_spawns = new WeightSet<Location>(getEastSpawn(), getWestSpawn());
|
||||||
_shops = new WeightSet<Location>(getNorthTown(), getSouthTown());
|
_shops = new WeightSet<Location>(getNorthTown(), getSouthTown());
|
||||||
_clansManager = clansManager;
|
_clansManager = clansManager;
|
||||||
|
|
||||||
|
addCommand(new ClansSpawnCommand(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -537,4 +540,9 @@ public class Spawn extends MiniPlugin
|
|||||||
_songWestLast = System.currentTimeMillis();
|
_songWestLast = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClansManager getClansManager()
|
||||||
|
{
|
||||||
|
return _clansManager;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user