Fix cloaking conditions being stuck enabled after expiring naturally, fix fissure being able to duplicate blocks with physics (sand, gravel), fix Magnetic Maul pulling mounts allowing users to fly, prevent mount dismounting resulting in players going through walls, and improve visibility system
This commit is contained in:
parent
eecf960613
commit
f05fb3d0e0
@ -16,6 +16,7 @@ import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
@ -283,6 +284,15 @@ public class BlockRestore extends MiniPlugin
|
||||
{
|
||||
_restoreMaps.remove(blockRestore);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPhysics(BlockPhysicsEvent event)
|
||||
{
|
||||
if (_blocks.containsKey(event.getBlock()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable()
|
||||
@ -295,4 +305,4 @@ public class BlockRestore extends MiniPlugin
|
||||
|
||||
restoreAll();
|
||||
}
|
||||
}
|
||||
}
|
@ -5,24 +5,70 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class VisibilityManager extends MiniPlugin
|
||||
{
|
||||
private final Map<Player, Map<Player, Set<String>>> _visibility = new HashMap<>();
|
||||
|
||||
private VisibilityManager(JavaPlugin plugin)
|
||||
private VisibilityManager()
|
||||
{
|
||||
super("Visibility Manager", plugin);
|
||||
super("Visibility Manager");
|
||||
|
||||
addCommand(new CommandBase<VisibilityManager>(this, Rank.ADMIN, "visdebug")
|
||||
{
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
Player target = caller;
|
||||
if (args.length > 0)
|
||||
{
|
||||
if (Bukkit.getPlayer(args[0]) != null)
|
||||
{
|
||||
target = Bukkit.getPlayer(args[0]);
|
||||
}
|
||||
}
|
||||
|
||||
caller.sendMessage(target.getName() + " (Bukkit):");
|
||||
caller.sendMessage(caller.getName() + " Observing " + target.getName() + ": " + caller.canSee(target));
|
||||
caller.sendMessage(target.getName() + " Observing " + caller.getName() + ": " + target.canSee(caller));
|
||||
caller.sendMessage(target.getName() + " (Mineplex):");
|
||||
caller.sendMessage(caller.getName() + " Observing " + target.getName() + ": " + canSee(caller, target));
|
||||
caller.sendMessage(target.getName() + " Observing " + caller.getName() + ": " + canSee(target, caller));
|
||||
caller.sendMessage(caller.getName() + " Data (Mineplex):");
|
||||
_visibility.get(caller).entrySet().forEach(entry ->
|
||||
{
|
||||
caller.sendMessage("- " + entry.getKey().getName() + ":");
|
||||
entry.getValue().forEach(reason ->
|
||||
{
|
||||
caller.sendMessage(" - " + reason);
|
||||
});
|
||||
});
|
||||
if (caller.getEntityId() != target.getEntityId())
|
||||
{
|
||||
caller.sendMessage(target.getName() + " Data (Mineplex):");
|
||||
_visibility.get(target).entrySet().forEach(entry ->
|
||||
{
|
||||
caller.sendMessage("- " + entry.getKey().getName() + ":");
|
||||
entry.getValue().forEach(reason ->
|
||||
{
|
||||
caller.sendMessage(" - " + reason);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean canSee(Player viewer, Player target)
|
||||
@ -32,6 +78,14 @@ public class VisibilityManager extends MiniPlugin
|
||||
|
||||
public void refreshVisibility(Player viewer, Player target)
|
||||
{
|
||||
if (viewer == null || target == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (viewer.getEntityId() == target.getEntityId())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (canSee(viewer, target))
|
||||
{
|
||||
viewer.showPlayer(target);
|
||||
@ -44,6 +98,14 @@ public class VisibilityManager extends MiniPlugin
|
||||
|
||||
public void hidePlayer(Player viewer, Player target, String reason)
|
||||
{
|
||||
if (viewer == null || target == null || reason == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (viewer.getEntityId() == target.getEntityId())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Set<String> reasons = _visibility.get(viewer).computeIfAbsent(target, (p) -> new HashSet<>());
|
||||
if (reasons.contains(reason))
|
||||
{
|
||||
@ -55,6 +117,14 @@ public class VisibilityManager extends MiniPlugin
|
||||
|
||||
public void showPlayer(Player viewer, Player target, String reason)
|
||||
{
|
||||
if (viewer == null || target == null || reason == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (viewer.getEntityId() == target.getEntityId())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Set<String> reasons = _visibility.get(viewer).get(target);
|
||||
if (reasons == null)
|
||||
{
|
||||
|
@ -23,6 +23,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.bukkit.inventory.HorseInventory;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.spigotmc.event.entity.EntityDismountEvent;
|
||||
|
||||
import mineplex.core.MiniDbClientPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
@ -513,6 +514,18 @@ public class MountManager extends MiniDbClientPlugin<MountOwnerData>
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDismount(EntityDismountEvent event)
|
||||
{
|
||||
if (_spawnedMounts.containsKey(event.getDismounted()) && event.getEntity() instanceof Player)
|
||||
{
|
||||
runSyncLater(() ->
|
||||
{
|
||||
event.getEntity().teleport(event.getDismounted());
|
||||
}, 1L);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuery(int accountId, String uuid, String name)
|
||||
|
@ -87,6 +87,10 @@ public class MagneticMaul extends LegendaryItem
|
||||
{
|
||||
continue; // Skip pulling self
|
||||
}
|
||||
if (entity.getPassenger() != null && entity.getPassenger().getEntityId() == player.getEntityId())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
double otherDistance = player.getLocation().distance(entity.getLocation());
|
||||
double otherTargetDistance = target.distance(entity.getLocation());
|
||||
|
@ -83,6 +83,7 @@ public class Blink extends SkillActive
|
||||
|
||||
//Deblink
|
||||
if (_loc.containsKey(player) && _blinkTime.containsKey(player))
|
||||
{
|
||||
if (!UtilTime.elapsed(_blinkTime.get(player), 5000))
|
||||
{
|
||||
//Require 500ms after blink to deblink
|
||||
@ -90,7 +91,8 @@ public class Blink extends SkillActive
|
||||
Deblink(player, level);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -144,7 +146,9 @@ public class Blink extends SkillActive
|
||||
//Modify Range
|
||||
curRange -= 0.4;
|
||||
if (curRange < 0)
|
||||
{
|
||||
curRange = 0;
|
||||
}
|
||||
|
||||
//Destination
|
||||
Location loc = getDestination(player, curRange);
|
||||
@ -238,4 +242,4 @@ public class Blink extends SkillActive
|
||||
{
|
||||
return player.getLocation().add(player.getLocation().getDirection().multiply(range).add(new Vector(0, 0.4, 0)));
|
||||
}
|
||||
}
|
||||
}
|
@ -142,18 +142,18 @@ public class Flash extends SkillActive
|
||||
boolean newTargetSlabIsBottom = false;
|
||||
boolean aboveTargetSlabIsBottom = false;
|
||||
|
||||
if(newTargetIsSlab && curRange < 0.5)
|
||||
if (newTargetIsSlab && curRange < 0.5)
|
||||
{
|
||||
int newTargetData = (int) newTarget.getBlock().getData();
|
||||
|
||||
if(newTargetData <= 7) newTargetSlabIsBottom = true;
|
||||
if (newTargetData <= 7) newTargetSlabIsBottom = true;
|
||||
}
|
||||
|
||||
if(aboveTargetIsSlab && curRange < 0.25)
|
||||
if (aboveTargetIsSlab && curRange < 0.25)
|
||||
{
|
||||
int aboveTargetData = (int) aboveTarget.getBlock().getData();
|
||||
|
||||
if(aboveTargetData <= 7) aboveTargetSlabIsBottom = true;
|
||||
if (aboveTargetData <= 7) aboveTargetSlabIsBottom = true;
|
||||
}
|
||||
|
||||
if ((!newTargetSlabIsBottom &&
|
||||
@ -188,7 +188,9 @@ public class Flash extends SkillActive
|
||||
}
|
||||
|
||||
if (curRange > 0)
|
||||
{
|
||||
player.teleport(loc);
|
||||
}
|
||||
|
||||
player.setFallDistance(0);
|
||||
|
||||
|
@ -97,16 +97,19 @@ public class FissureData
|
||||
_loc.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
|
||||
|
||||
//Slow
|
||||
for (Player cur : block.getWorld().getPlayers()) {
|
||||
if(UtilPlayer.isSpectator(cur)) continue;
|
||||
for (Player cur : block.getWorld().getPlayers())
|
||||
{
|
||||
if (UtilPlayer.isSpectator(cur)) continue;
|
||||
|
||||
if (!cur.equals(_player))
|
||||
{
|
||||
if (UtilMath.offset(block.getLocation().add(0.5, 0.5, 0.5), cur.getLocation()) < 1.5)
|
||||
{
|
||||
//Condition
|
||||
Host.Factory.Condition().Factory().Slow("Fissure", cur, _player, 1 + _level, 1, false, true, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,7 +164,8 @@ public class FissureData
|
||||
up.getWorld().playEffect(up.getLocation(), Effect.STEP_SOUND, block.getTypeId());
|
||||
|
||||
//Damage
|
||||
for (Player cur : up.getWorld().getPlayers()) {
|
||||
for (Player cur : up.getWorld().getPlayers())
|
||||
{
|
||||
if (UtilPlayer.isSpectator(cur))
|
||||
continue;
|
||||
|
||||
@ -174,7 +178,8 @@ public class FissureData
|
||||
}
|
||||
|
||||
//Damage
|
||||
if (!_hit.contains(cur))
|
||||
if (!_hit.contains(cur))
|
||||
{
|
||||
if (UtilMath.offset(up.getLocation().add(0.5, 0.5, 0.5), cur.getLocation()) < 1.8)
|
||||
{
|
||||
_hit.add(cur);
|
||||
@ -189,6 +194,7 @@ public class FissureData
|
||||
//Inform
|
||||
UtilPlayer.message(cur, F.main(Host.GetClassType().name(), F.name(_player.getName()) +" hit you with " + F.skill(Host.GetName(_level)) + "."));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Next Column
|
||||
@ -210,4 +216,4 @@ public class FissureData
|
||||
_loc = null;
|
||||
_startLoc = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -308,6 +308,11 @@ public class Condition
|
||||
|
||||
return _ticks <= 0;
|
||||
}
|
||||
|
||||
public boolean needsForceRemove()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public ConditionManager GetManager()
|
||||
{
|
||||
|
@ -19,4 +19,4 @@ public class ConditionActive
|
||||
_condition = newCon;
|
||||
newCon.Apply();
|
||||
}
|
||||
}
|
||||
}
|
@ -6,22 +6,6 @@ import java.util.LinkedList;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||
import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent;
|
||||
import mineplex.minecraft.game.core.condition.events.ConditionExpireEvent;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -31,12 +15,27 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
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.minecraft.game.core.condition.Condition.ConditionType;
|
||||
import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent;
|
||||
import mineplex.minecraft.game.core.condition.events.ConditionExpireEvent;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
|
||||
public class ConditionManager extends MiniPlugin
|
||||
{
|
||||
private ConditionFactory _factory;
|
||||
@ -104,7 +103,7 @@ public class ConditionManager extends MiniPlugin
|
||||
|
||||
//Add Condition
|
||||
if (!_conditions.containsKey(newCon.GetEnt()))
|
||||
_conditions.put(newCon.GetEnt(), new LinkedList<Condition>());
|
||||
_conditions.put(newCon.GetEnt(), new LinkedList<>());
|
||||
|
||||
_conditions.get(newCon.GetEnt()).add(newCon);
|
||||
|
||||
@ -136,7 +135,7 @@ public class ConditionManager extends MiniPlugin
|
||||
public ConditionActive GetIndicatorType(Condition newCon)
|
||||
{
|
||||
if (!_activeConditions.containsKey(newCon.GetEnt()))
|
||||
_activeConditions.put(newCon.GetEnt(), new LinkedList<ConditionActive>());
|
||||
_activeConditions.put(newCon.GetEnt(), new LinkedList<>());
|
||||
|
||||
for (ConditionActive ind : _activeConditions.get(newCon.GetEnt()))
|
||||
if (ind.GetCondition().GetType() == newCon.GetType())
|
||||
@ -152,7 +151,7 @@ public class ConditionManager extends MiniPlugin
|
||||
|
||||
//Get Inds
|
||||
if (!_activeConditions.containsKey(newCon.GetEnt()))
|
||||
_activeConditions.put(newCon.GetEnt(), new LinkedList<ConditionActive>());
|
||||
_activeConditions.put(newCon.GetEnt(), new LinkedList<>());
|
||||
|
||||
LinkedList<ConditionActive> entInds = _activeConditions.get(newCon.GetEnt());
|
||||
|
||||
@ -169,9 +168,17 @@ public class ConditionManager extends MiniPlugin
|
||||
//Not Additive
|
||||
|
||||
if (!active.GetCondition().IsExpired())
|
||||
{
|
||||
if (active.GetCondition().IsBetterOrEqual(newCon, newCon.IsAdd()))
|
||||
{
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (active.GetCondition().needsForceRemove())
|
||||
{
|
||||
active.GetCondition().Remove();
|
||||
}
|
||||
active.SetCondition(newCon);
|
||||
}
|
||||
|
||||
@ -195,6 +202,10 @@ public class ConditionManager extends MiniPlugin
|
||||
ConditionExpireEvent conditionExpireEvent = new ConditionExpireEvent(cond);
|
||||
UtilServer.CallEvent(conditionExpireEvent);
|
||||
conditionIterator.remove();
|
||||
if (cond.needsForceRemove())
|
||||
{
|
||||
cond.Remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -215,13 +226,21 @@ public class ConditionManager extends MiniPlugin
|
||||
if (replacement == null)
|
||||
{
|
||||
conditionIndicatorIterator.remove();
|
||||
if (conditionIndicator.GetCondition().needsForceRemove())
|
||||
{
|
||||
conditionIndicator.GetCondition().Remove();
|
||||
}
|
||||
|
||||
//Inform
|
||||
if (conditionIndicator.GetCondition().GetInformOff() != null)
|
||||
{
|
||||
UtilPlayer.message(conditionIndicator.GetCondition().GetEnt(), F.main("Condition", conditionIndicator.GetCondition().GetInformOff()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateActive(conditionIndicator, replacement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -380,7 +399,9 @@ public class ConditionManager extends MiniPlugin
|
||||
return;
|
||||
|
||||
for (Condition cond : _conditions.get(target))
|
||||
{
|
||||
if (reason == null || cond.GetReason().equals(reason))
|
||||
{
|
||||
if (type == null || cond.GetType() == type)
|
||||
{
|
||||
cond.Expire();
|
||||
@ -388,6 +409,8 @@ public class ConditionManager extends MiniPlugin
|
||||
Condition best = GetBestCondition(target, cond.GetType());
|
||||
if (best != null) best.Apply();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean HasCondition(LivingEntity target, ConditionType type, String reason)
|
||||
@ -396,9 +419,15 @@ public class ConditionManager extends MiniPlugin
|
||||
return false;
|
||||
|
||||
for (Condition cond : _conditions.get(target))
|
||||
{
|
||||
if (reason == null || cond.GetReason().equals(reason))
|
||||
{
|
||||
if (type == null || cond.GetType() == type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -507,41 +536,4 @@ public class ConditionManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Debug(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (event.getPlayer().getName().equals("Chiss"))
|
||||
{
|
||||
if (event.getMessage().equals("/debugcond1"))
|
||||
{
|
||||
_factory.Regen("Debug", event.getPlayer(), event.getPlayer(), 30, 0, false, false, false);
|
||||
event.getPlayer().sendMessage("Regen 1 for 30s");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (event.getMessage().equals("/debugcond2"))
|
||||
{
|
||||
_factory.Regen("Debug", event.getPlayer(), event.getPlayer(), 15, 1, false, false, false);
|
||||
event.getPlayer().sendMessage("Regen 2 for 15s");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (event.getMessage().equals("/debugcond3"))
|
||||
{
|
||||
_factory.Regen("Debug", event.getPlayer(), event.getPlayer(), 5, 2, false, false, false);
|
||||
event.getPlayer().sendMessage("Regen 3 for 5s");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (event.getMessage().equals("/debugcond4"))
|
||||
{
|
||||
_factory.Slow("Debug", event.getPlayer(), event.getPlayer(), 5, 0, true, false, false, false);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (event.getMessage().equals("/debugcond5"))
|
||||
{
|
||||
_factory.Ignite("Debug", event.getPlayer(), event.getPlayer(), 5, true, false);
|
||||
event.getPlayer().sendMessage("Regen 1 for 30s");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -25,6 +25,12 @@ public class Cloak extends Condition
|
||||
_informOn = "You are now invisible.";
|
||||
_informOff = "You are no longer invisible.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsForceRemove()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Add()
|
||||
|
Loading…
Reference in New Issue
Block a user