Merge remote-tracking branch 'origin/clans/beta' into clans/beta
# Conflicts: # Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java # Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/OutpostRepository.java # Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/repository/SiegeWeaponRepository.java
This commit is contained in:
commit
876a568bd0
@ -1,5 +1,7 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class RGBData
|
||||
{
|
||||
private double _red;
|
||||
@ -50,4 +52,19 @@ public class RGBData
|
||||
+ "green=" + (int) (_green * 255) + ", "
|
||||
+ "blue=" + (int) (_blue * 255) + "]";
|
||||
}
|
||||
|
||||
public Vector ToVector()
|
||||
{
|
||||
return new Vector(Math.max(0.001, _red), _green, _blue);
|
||||
}
|
||||
|
||||
public RGBData Darken()
|
||||
{
|
||||
return new RGBData(getFullRed() - 25, getFullGreen() - 25, getFullBlue() - 25);
|
||||
}
|
||||
|
||||
public RGBData Lighten()
|
||||
{
|
||||
return new RGBData(getFullRed() + 25, getFullGreen() + 25, getFullBlue() + 25);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package mineplex.core.common.util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
@ -3,14 +3,20 @@ package mineplex.core.common.util;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class UtilCollections
|
||||
{
|
||||
public static Random Random = new Random();
|
||||
|
||||
@SafeVarargs
|
||||
public static <E> NautArrayList<E> newNautList(E... elements)
|
||||
{
|
||||
@ -60,17 +66,6 @@ public class UtilCollections
|
||||
}
|
||||
}
|
||||
|
||||
public static <E> void forEachFilter(E[] elements, Function<E, Boolean> filter, Consumer<E> consumer)
|
||||
{
|
||||
for (int i = 0; i < elements.length; i++)
|
||||
{
|
||||
if (filter.apply(elements[i]).booleanValue())
|
||||
{
|
||||
consumer.accept(elements[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static <E> void forEach(E[] elements, Consumer<E> consumer)
|
||||
{
|
||||
for (int i = 0; i < elements.length; i++)
|
||||
@ -78,17 +73,20 @@ public class UtilCollections
|
||||
consumer.accept(elements[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public static <E> void forEach(E[] elements, BiConsumer<Integer, E> consumer)
|
||||
{
|
||||
for (int i = 0; i < elements.length; i++)
|
||||
{
|
||||
consumer.accept(Integer.valueOf(i), elements[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public static <E> void addAll(E[] elements, Collection<E> collection)
|
||||
{
|
||||
forEach(elements, collection::add);
|
||||
}
|
||||
|
||||
public static <E> void addAll(E[] elements, Function<E, Boolean> filter, Collection<E> collection)
|
||||
{
|
||||
forEachFilter(elements, filter, collection::add);
|
||||
}
|
||||
|
||||
public static void loop(int min, int max, Consumer<Integer> consumer)
|
||||
{
|
||||
for (int i = min; i < max; i++)
|
||||
@ -177,7 +175,7 @@ public class UtilCollections
|
||||
return Arrays.copyOf(array, size);
|
||||
}
|
||||
|
||||
public static Object[] ensureSize(Object[] array, int size)
|
||||
public static <T> T[] ensureSize(T[] array, int size)
|
||||
{
|
||||
if (array.length <= size)
|
||||
{
|
||||
@ -186,4 +184,60 @@ public class UtilCollections
|
||||
|
||||
return Arrays.copyOf(array, size);
|
||||
}
|
||||
|
||||
public static byte random(byte[] array)
|
||||
{
|
||||
return array[Random.nextInt(array.length)];
|
||||
}
|
||||
|
||||
public static short random(short[] array)
|
||||
{
|
||||
return array[Random.nextInt(array.length)];
|
||||
}
|
||||
|
||||
public static char random(char[] array)
|
||||
{
|
||||
return array[Random.nextInt(array.length)];
|
||||
}
|
||||
|
||||
public static boolean random(boolean[] array)
|
||||
{
|
||||
return array[Random.nextInt(array.length)];
|
||||
}
|
||||
|
||||
public static int random(int[] array)
|
||||
{
|
||||
return array[Random.nextInt(array.length)];
|
||||
}
|
||||
|
||||
public static long random(long[] array)
|
||||
{
|
||||
return array[Random.nextInt(array.length)];
|
||||
}
|
||||
|
||||
public static double random(double[] array)
|
||||
{
|
||||
return array[Random.nextInt(array.length)];
|
||||
}
|
||||
|
||||
public static float random(float[] array)
|
||||
{
|
||||
return array[Random.nextInt(array.length)];
|
||||
}
|
||||
|
||||
public static <T> T random(T[] array)
|
||||
{
|
||||
return array[Random.nextInt(array.length)];
|
||||
}
|
||||
|
||||
public static <T> Collection<? extends T> toList(T[] array)
|
||||
{
|
||||
return Lists.newArrayList(array);
|
||||
}
|
||||
|
||||
public static <T1, T2> boolean equal(T1[] array1, T2[] array2)
|
||||
{
|
||||
return Arrays.equals(array1, array2);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ public class UtilColor
|
||||
public static final RGBData RgbRed = hexToRgb(0xee0100);
|
||||
public static final RGBData RgbGold = hexToRgb(0xffd014);
|
||||
public static final RGBData RgbLightBlue = hexToRgb(0x61fff7);
|
||||
public static final RGBData RgbLightRed = hexToRgb(0xeb1c1c);
|
||||
public static final RGBData RgbPurple = hexToRgb(0x9c17a3);
|
||||
|
||||
public static byte chatColorToClayData(ChatColor chatColor)
|
||||
{
|
||||
|
@ -0,0 +1,29 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.java.sk89q.jnbt.NBTInputStream;
|
||||
import com.java.sk89q.jnbt.NamedTag;
|
||||
|
||||
public class UtilOfflinePlayer
|
||||
{
|
||||
public static ItemStack loadOfflineInventory(File file)
|
||||
{
|
||||
try (NBTInputStream stream = new NBTInputStream(new FileInputStream(file)))
|
||||
{
|
||||
NamedTag tag = stream.readNamedTag();
|
||||
|
||||
System.out.println(tag);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -8,12 +8,18 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import mineplex.core.vanish.events.PreVanishEvent;
|
||||
|
||||
public class UtilServer
|
||||
{
|
||||
@ -89,9 +95,19 @@ public class UtilServer
|
||||
return (double)getPlayers().length / (double)UtilServer.getServer().getMaxPlayers();
|
||||
}
|
||||
|
||||
public static void registerEvents(Listener listener)
|
||||
public static void RegisterEvents(Listener listener)
|
||||
{
|
||||
getPluginManager().registerEvents(listener, getPluginManager().getPlugins()[0]);
|
||||
getPluginManager().registerEvents(listener, getPlugin());
|
||||
}
|
||||
|
||||
public static void Unregister(Listener listener)
|
||||
{
|
||||
HandlerList.unregisterAll(listener);
|
||||
}
|
||||
|
||||
public static Plugin getPlugin()
|
||||
{
|
||||
return getPluginManager().getPlugins()[0];
|
||||
}
|
||||
|
||||
public static PluginManager getPluginManager()
|
||||
@ -99,8 +115,28 @@ public class UtilServer
|
||||
return getServer().getPluginManager();
|
||||
}
|
||||
|
||||
public static void callEvent(Event event)
|
||||
public static <T extends Event> T callEvent(T event)
|
||||
{
|
||||
getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
public static void repeat(BukkitRunnable runnable, long time)
|
||||
{
|
||||
runnable.runTaskTimer(getPlugin(), time, time);
|
||||
}
|
||||
|
||||
public static boolean IsOnline(String name)
|
||||
{
|
||||
return !UtilStreams.IsEmpty(getPlayersCollection().stream().filter(player -> player.getName().equals(name)));
|
||||
}
|
||||
|
||||
public static Player GetPlayer(String name)
|
||||
{
|
||||
return UtilStreams.GetFirst(getPlayersCollection().stream().filter(player -> player.getName().equals(name)));
|
||||
}
|
||||
|
||||
public static OfflinePlayer GetOffline(String player)
|
||||
{
|
||||
return getServer().getOfflinePlayer(player);
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class UtilShapes
|
||||
|
||||
return circleblocks;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the block at the exact corners, will return a diagonal.
|
||||
*
|
||||
|
@ -0,0 +1,42 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class UtilStreams
|
||||
{
|
||||
public static boolean IsEmpty(Stream<?> stream)
|
||||
{
|
||||
return Sum(stream) != 0;
|
||||
}
|
||||
|
||||
public static int Sum(Stream<?> stream)
|
||||
{
|
||||
return stream.mapToInt(v -> 1).sum();
|
||||
}
|
||||
|
||||
public static Object[] ToArray(Stream<? extends Object> stream)
|
||||
{
|
||||
return stream.toArray();
|
||||
}
|
||||
|
||||
public static <T> T Get(int index, Stream<T> stream)
|
||||
{
|
||||
if (Sum(stream) < index + 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (T) ToArray(stream)[index];
|
||||
}
|
||||
|
||||
public static <T> T GetFirst(Stream<T> stream)
|
||||
{
|
||||
return Get(0, stream);
|
||||
}
|
||||
|
||||
public static <T> T GetLast(Stream<T> stream)
|
||||
{
|
||||
return Get(Sum(stream) + 1, stream);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class UtilTrig
|
||||
{
|
||||
public static List<Vector> GetCirclePoints(Vector origin, int points, double radius)
|
||||
{
|
||||
List<Vector> list = new LinkedList<>();
|
||||
|
||||
double slice = 2 * Math.PI / points;
|
||||
|
||||
for (int point = 0; point < points; point++)
|
||||
{
|
||||
double angle = slice * point;
|
||||
list.add(new Vector(origin.getX() + radius * Math.cos(angle), 0, origin.getZ() + radius * Math.sin(angle)));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static ArrayList<Location> GetSpherePoints(Location loc, double radius, double height, boolean hollow, double addition)
|
||||
{
|
||||
ArrayList<Location> circleblocks = new ArrayList<Location>();
|
||||
double cx = loc.getBlockX();
|
||||
double cy = loc.getBlockY();
|
||||
double cz = loc.getBlockZ();
|
||||
|
||||
for (double y = cy - radius; y < cy + radius; y += addition)
|
||||
{
|
||||
for (double x = cx - radius; x <= cx + radius; x += addition)
|
||||
{
|
||||
for (double z = cz - radius; z <= cz + radius; z += addition)
|
||||
{
|
||||
double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (cy - y) * (cy - y);
|
||||
|
||||
if (dist < radius * radius && !(hollow && dist < (radius - 1) * (radius - 1)))
|
||||
{
|
||||
Location l = new Location(loc.getWorld(), x, y, z);
|
||||
circleblocks.add(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return circleblocks;
|
||||
}
|
||||
|
||||
public static List<Vector> GetSpherePoints(Vector vector, double radius, double height, boolean hollow, double addition)
|
||||
{
|
||||
List<Vector> circleblocks = new ArrayList<>();
|
||||
double cx = vector.getX();
|
||||
double cy = vector.getY();
|
||||
double cz = vector.getZ();
|
||||
|
||||
for (double y = cy - radius; y < cy + radius; y += addition)
|
||||
{
|
||||
for (double x = cx - radius; x <= cx + radius; x += addition)
|
||||
{
|
||||
for (double z = cz - radius; z <= cz + radius; z += addition)
|
||||
{
|
||||
double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (cy - y) * (cy - y);
|
||||
|
||||
if (dist < radius * radius && !(hollow && dist < (radius - 1) * (radius - 1)))
|
||||
{
|
||||
Vector l = new Vector(x, y, z);
|
||||
circleblocks.add(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return circleblocks;
|
||||
}
|
||||
}
|
@ -62,4 +62,14 @@ public class DelayedTask extends MiniClientPlugin<DelayedTaskClient>
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -118,12 +118,12 @@ public class ClansDisplay extends MiniPlugin
|
||||
if (relation == ClanRelation.ALLY_TRUST) ownerString += " " + C.mBody + "(" + C.mElem + "Trusted" + C.mBody + ")";
|
||||
}
|
||||
|
||||
if (_clansManager.getNetherManager().isInNether(player))
|
||||
{
|
||||
_clansManager.message(player, "You are not allowed to claim territory in " + F.clansNether("The Nether") + ".");
|
||||
|
||||
ownerString = C.cRed + "The Nether";
|
||||
}
|
||||
// if (_clansManager.getNetherManager().isInNether(player))
|
||||
// {
|
||||
// _clansManager.message(player, "You are not allowed to claim territory in " + F.clansNether("The Nether") + ".");
|
||||
//
|
||||
// ownerString = C.cRed + "The Nether";
|
||||
// }
|
||||
|
||||
UtilTextMiddle.display("", ownerString, 0, 25, 10, player);
|
||||
UtilPlayer.message(player, F.main("Territory", ownerString));
|
||||
|
@ -1,17 +1,15 @@
|
||||
package mineplex.game.clans.clans;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.common.util.UtilOfflinePlayer;
|
||||
|
||||
public class Test
|
||||
{
|
||||
public static void main(String[] args) throws IOException
|
||||
{
|
||||
System.out.println(UtilWorld.locToStr(new Location(null, 30, 30, 30)));
|
||||
|
||||
|
||||
System.out.println("wtf");
|
||||
UtilOfflinePlayer.loadOfflineInventory(new File("M:/Clans/a797d3ef-dd25-4e18-a002-6537b19b3603.dat"));
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
package mineplex.game.clans.clans.commands;
|
||||
|
||||
import java.util.Collections;
|
||||
@ -9,7 +10,6 @@ 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;
|
||||
|
||||
@ -20,7 +20,6 @@ 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;
|
||||
@ -365,9 +364,16 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
|
||||
public void stuck(final Player caller)
|
||||
{
|
||||
if (_clansManager.getNetherManager().isInNether(caller))
|
||||
// if (_clansManager.getNetherManager().isInNether(caller))
|
||||
// {
|
||||
// _clansManager.message(caller, "You are not allowed to free yourself in " + F.clansNether("The Nether") + ".");
|
||||
//
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (DelayedTask.Instance.HasTask(caller, "Spawn Teleport"))
|
||||
{
|
||||
_clansManager.message(caller, "You are not allowed to free yourself in " + F.clansNether("The Nether") + ".");
|
||||
_clansManager.message(caller, "You are already unsticking yourself.");
|
||||
|
||||
return;
|
||||
}
|
||||
@ -804,24 +810,24 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
return;
|
||||
}
|
||||
|
||||
if (_clansManager.getNetherManager().isInNether(caller))
|
||||
{
|
||||
_clansManager.message(caller, "You are not allowed to claim territory in " + F.clansNether("The Nether") + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
// if (_clansManager.getNetherManager().isInNether(caller))
|
||||
// {
|
||||
// _clansManager.message(caller, "You are not allowed to claim territory in " + F.clansNether("The Nether") + ".");
|
||||
//
|
||||
// return;
|
||||
// }
|
||||
|
||||
Plugin.getClanUtility().claim(caller);
|
||||
}
|
||||
|
||||
public void unclaim(Player caller, String[] args)
|
||||
{
|
||||
if (_clansManager.getNetherManager().isInNether(caller))
|
||||
{
|
||||
_clansManager.message(caller, "You are not allowed to unclaim territory in " + F.clansNether("The Nether") + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
// if (_clansManager.getNetherManager().isInNether(caller))
|
||||
// {
|
||||
// _clansManager.message(caller, "You are not allowed to unclaim territory in " + F.clansNether("The Nether") + ".");
|
||||
//
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
@ -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;
|
||||
}
|
||||
@ -921,6 +927,8 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
DelayedTask.Instance.doDelay(caller, "Home Teleport", new Callback<DelayedTaskClient>() {
|
||||
public void run(DelayedTaskClient player)
|
||||
{
|
||||
Recharge.Instance.use(caller, "Home Teleport", 30 * 60 * 1000, true, false);
|
||||
|
||||
// Do
|
||||
Plugin.getTeleport().TP(caller, clan.getHome().add(0, 1, 0));
|
||||
|
||||
@ -937,7 +945,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
{
|
||||
UtilPlayer.message(client.getPlayer(), F.main("Clans", "Teleport has been cancelled due to movement."));
|
||||
}
|
||||
}, (Plugin.getClanUtility().getClaim(caller.getLocation()) != null ? 30 : 20) * 1000, false);
|
||||
}, 15 * 1000, false);
|
||||
}
|
||||
|
||||
public void homeSet(Player caller)
|
||||
@ -959,12 +967,12 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
return;
|
||||
}
|
||||
|
||||
if (_clansManager.getNetherManager().isInNether(caller))
|
||||
{
|
||||
_clansManager.message(caller, "You are not allowed to set your Clan Home in " + F.clansNether("The Nether") + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
// if (_clansManager.getNetherManager().isInNether(caller))
|
||||
// {
|
||||
// _clansManager.message(caller, "You are not allowed to set your Clan Home in " + F.clansNether("The Nether") + ".");
|
||||
//
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN)
|
||||
{
|
||||
@ -1088,12 +1096,12 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
|
||||
if (clan == null) return;
|
||||
|
||||
if (_clansManager.getNetherManager().isInNether(caller))
|
||||
{
|
||||
_clansManager.message(caller, "You are currently in " + F.clansNether("The Nether") + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
// if (_clansManager.getNetherManager().isInNether(caller))
|
||||
// {
|
||||
// _clansManager.message(caller, "You are currently in " + F.clansNether("The Nether") + ".");
|
||||
//
|
||||
// return;
|
||||
// }
|
||||
|
||||
_clansManager.getTutorials().sendTutorialMsg(caller, clan.mTerritory());
|
||||
}
|
||||
|
@ -23,12 +23,12 @@ public class ClanTerritoryButton extends ClanButton
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
if (_clansManager.getNetherManager().isInNether(player))
|
||||
{
|
||||
_clansManager.message(player, "You are not allowed to do anything with Territory while in " + F.clansNether("The Nether") + ".");
|
||||
player.closeInventory();
|
||||
return;
|
||||
}
|
||||
// if (_clansManager.getNetherManager().isInNether(player))
|
||||
// {
|
||||
// _clansManager.message(player, "You are not allowed to do anything with Territory while in " + F.clansNether("The Nether") + ".");
|
||||
// player.closeInventory();
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (clickType == ClickType.LEFT)
|
||||
{
|
||||
|
@ -0,0 +1,23 @@
|
||||
package mineplex.game.clans.clans.invsee;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.invsee.commands.InvseeCommand;
|
||||
|
||||
public class Invsee extends MiniPlugin
|
||||
{
|
||||
private ClansManager _clansManager;
|
||||
|
||||
public Invsee(ClansManager clansManager)
|
||||
{
|
||||
super("Inventory Viewer", clansManager.getPlugin());
|
||||
|
||||
_clansManager = clansManager;
|
||||
}
|
||||
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new InvseeCommand(this));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package mineplex.game.clans.clans.invsee.commands;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
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.UtilServer;
|
||||
import mineplex.game.clans.clans.invsee.Invsee;
|
||||
import mineplex.game.clans.clans.invsee.ui.InvseeInventory;
|
||||
|
||||
public class InvseeCommand extends CommandBase<Invsee>
|
||||
{
|
||||
public InvseeCommand(Invsee plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "invsee");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
String name = args[0];
|
||||
|
||||
OfflinePlayer player;
|
||||
|
||||
if (UtilServer.IsOnline(name))
|
||||
{
|
||||
player = UtilServer.GetPlayer(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
player = UtilServer.GetOffline(name);
|
||||
}
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "Specified player is neither online nor is offline. Perhaps they changed their name?"));
|
||||
return;
|
||||
}
|
||||
|
||||
new InvseeInventory(player).ShowTo(caller);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
package mineplex.game.clans.clans.invsee.ui;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilCollections;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class InvseeInventory implements Listener
|
||||
{
|
||||
private OfflinePlayer _player;
|
||||
private Inventory _inventory;
|
||||
|
||||
private boolean _online;
|
||||
|
||||
private Player _admin;
|
||||
|
||||
public InvseeInventory(OfflinePlayer player)
|
||||
{
|
||||
_online = (_player = player) instanceof Player;
|
||||
|
||||
_inventory = UtilServer.getServer().createInventory(null, 54, player.getName() + " " + (_online ? C.cGreen + "ONLINE" : C.cRed + "OFFLINE"));
|
||||
|
||||
UtilServer.RegisterEvents(this);
|
||||
}
|
||||
|
||||
public void ShowTo(Player admin)
|
||||
{
|
||||
_admin = admin;
|
||||
admin.openInventory(_inventory);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void quit(PlayerQuitEvent event)
|
||||
{
|
||||
if (_online && event.getPlayer().equals(_player))
|
||||
{
|
||||
_admin.closeInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_online)
|
||||
{
|
||||
if (!UtilCollections.equal(_inventory.getContents(), ((Player) _player).getInventory().getContents()))
|
||||
{
|
||||
_inventory.setContents(((Player) _player).getInventory().getContents());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void inventoryClick(InventoryClickEvent event)
|
||||
{
|
||||
if (event.getClickedInventory().equals(_inventory))
|
||||
{
|
||||
if (_online)
|
||||
{
|
||||
((Player) _player).getInventory().setContents(_inventory.getContents());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void closeInventory(InventoryCloseEvent event)
|
||||
{
|
||||
if (event.getInventory().equals(_inventory))
|
||||
{
|
||||
UtilServer.Unregister(this);
|
||||
|
||||
if (!_online)
|
||||
{
|
||||
// save offline inv
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -438,6 +438,19 @@ public class ItemMapManager extends MiniPlugin
|
||||
event.getEntity().remove();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeMap(Player player)
|
||||
{
|
||||
for (int slot = 0; slot < player.getInventory().getSize(); slot++)
|
||||
{
|
||||
ItemStack item = player.getInventory().getItem(slot);
|
||||
|
||||
if (item != null && item.getType() == Material.MAP && item.getDurability() >= _mapId && item.getDurability() <= _mapId + 100)
|
||||
{
|
||||
player.getInventory().setItem(slot, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ClansUtility getClansUtility()
|
||||
{
|
||||
|
@ -14,6 +14,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerPortalEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -27,6 +28,8 @@ import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilCollections;
|
||||
import mineplex.core.common.util.UtilFile;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
@ -119,15 +122,24 @@ public class NetherManager extends MiniPlugin
|
||||
Player player = event.getPlayer();
|
||||
ItemStack item = player.getItemInHand();
|
||||
|
||||
if (player.getGameMode() == GameMode.CREATIVE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!block.getWorld().equals(_netherWorld))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getGameMode() == GameMode.CREATIVE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_portals
|
||||
.stream()
|
||||
.filter(portal -> UtilAlg.getAverageBlockLocation(portal.getToBlocks()).distance(block.getLocation()) < 15)
|
||||
.limit(1)
|
||||
.forEach(portal -> {
|
||||
UtilPlayer.message(player, F.main("Clans", "You are not allowed to break this block."));
|
||||
event.setCancelled(true);
|
||||
});
|
||||
|
||||
if (!item.getType().equals(Material.GOLD_PICKAXE))
|
||||
{
|
||||
@ -144,9 +156,60 @@ public class NetherManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void placeBlock(BlockPlaceEvent event)
|
||||
{
|
||||
Block block = event.getBlock();
|
||||
Player player = event.getPlayer();
|
||||
ItemStack item = player.getItemInHand();
|
||||
|
||||
if (player.getGameMode() == GameMode.CREATIVE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!block.getWorld().equals(_netherWorld))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UtilItem.isFromNether(item))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Clans", "You can only place blocks here that come from " + F.clansNether("The Nether") + "."));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
_portals
|
||||
.stream()
|
||||
.filter(portal -> UtilAlg.getAverageBlockLocation(portal.getToBlocks()).distance(block.getLocation()) < 15)
|
||||
.limit(1)
|
||||
.forEach(portal -> {
|
||||
UtilPlayer.message(player, F.main("Clans", "You are not allowed to place blocks here."));
|
||||
event.setCancelled(true);
|
||||
});
|
||||
|
||||
if (block.getType().equals(Material.OBSIDIAN) || block.getType().equals(Material.PORTAL))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Clans", "You are not allowed to place blocks here."));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() == UpdateType.FAST)
|
||||
{
|
||||
UtilServer.getPlayersCollection()
|
||||
.stream()
|
||||
.filter(player -> player.getWorld().equals(_netherWorld))
|
||||
.forEach(player -> {
|
||||
player.setCompassTarget(new Location(_netherWorld, -200.d + UtilMath.r(400), player.getLocation().getY(), -200.d + UtilMath.r(400)));
|
||||
_clansManager.getItemMapManager().removeMap(player);
|
||||
});
|
||||
}
|
||||
if (event.getType() == UpdateType.SLOW)
|
||||
{
|
||||
_portals.forEach(portal -> {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.game.clans.clans.nether;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
@ -18,6 +19,9 @@ public class Portal
|
||||
private List<Block> _toPortalBlocks;
|
||||
private List<Block> _toObsidianBlocks;
|
||||
|
||||
private List<Block> _fromBlocks;
|
||||
private List<Block> _toBlocks;
|
||||
|
||||
private Location _toOut;
|
||||
|
||||
public final boolean Success;
|
||||
@ -74,6 +78,14 @@ public class Portal
|
||||
}
|
||||
}
|
||||
|
||||
_fromBlocks = new ArrayList<>();
|
||||
_toBlocks = new ArrayList<>();
|
||||
|
||||
_fromBlocks.addAll(_fromObsidianBlocks);
|
||||
_fromBlocks.addAll(_fromPortalBlocks);
|
||||
_toBlocks.addAll(_toObsidianBlocks);
|
||||
_toBlocks.addAll(_toPortalBlocks);
|
||||
|
||||
Success = true;
|
||||
}
|
||||
|
||||
@ -102,6 +114,16 @@ public class Portal
|
||||
return _toObsidianBlocks;
|
||||
}
|
||||
|
||||
public List<Block> getFromBlocks()
|
||||
{
|
||||
return _fromBlocks;
|
||||
}
|
||||
|
||||
public List<Block> getToBlocks()
|
||||
{
|
||||
return _toBlocks;
|
||||
}
|
||||
|
||||
private boolean isValidPortalBlock(Block block)
|
||||
{
|
||||
return block.getType() == Material.OBSIDIAN || block.getType() == Material.PORTAL;
|
||||
|
@ -45,10 +45,10 @@ public class ScoreboardElementPlayer implements ScoreboardElement
|
||||
|
||||
}
|
||||
|
||||
if (_clansManager.getNetherManager().isInNether(player))
|
||||
{
|
||||
regionString = C.cRed + "The Nether";
|
||||
}
|
||||
// if (_clansManager.getNetherManager().isInNether(player))
|
||||
// {
|
||||
// regionString = C.cRed + "The Nether";
|
||||
// }
|
||||
|
||||
output.add(regionString);
|
||||
|
||||
|
@ -170,12 +170,12 @@ public class SiegeManager extends MiniPlugin
|
||||
|
||||
public boolean trySpawnCannon(Player player, Location location)
|
||||
{
|
||||
if (_clansManager.getNetherManager().isInNether(player))
|
||||
{
|
||||
_clansManager.message(player, "You are not allowed to place this in " + F.clansNether("The Nether") + ".");
|
||||
|
||||
return false;
|
||||
}
|
||||
// if (_clansManager.getNetherManager().isInNether(player))
|
||||
// {
|
||||
// _clansManager.message(player, "You are not allowed to place this in " + F.clansNether("The Nether") + ".");
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
|
||||
if (!_clansManager.isInClan(player))
|
||||
{
|
||||
@ -205,12 +205,12 @@ public class SiegeManager extends MiniPlugin
|
||||
|
||||
public boolean trySpawnCatapult(Player player, Location location)
|
||||
{
|
||||
if (_clansManager.getNetherManager().isInNether(player))
|
||||
{
|
||||
_clansManager.message(player, "You are not allowed to place this in " + F.clansNether("The Nether") + ".");
|
||||
|
||||
return false;
|
||||
}
|
||||
// if (_clansManager.getNetherManager().isInNether(player))
|
||||
// {
|
||||
// _clansManager.message(player, "You are not allowed to place this in " + F.clansNether("The Nether") + ".");
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
|
||||
if (!_clansManager.isInClan(player))
|
||||
{
|
||||
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
@ -19,10 +18,10 @@ import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Door;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@ -48,6 +47,7 @@ import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTrig;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import mineplex.core.hologram.HologramInteraction;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
@ -61,13 +61,11 @@ import mineplex.game.clans.clans.siege.outpost.build.OutpostBlock;
|
||||
import mineplex.game.clans.clans.siege.repository.tokens.OutpostToken;
|
||||
import mineplex.game.clans.core.repository.ClanTerritory;
|
||||
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
|
||||
|
||||
public class Outpost implements Listener
|
||||
{
|
||||
protected static final long MAX_LIFETIME = 30 * 60 * 1000; // 30 minutes
|
||||
public static final ItemStack OUTPOST_ITEM = new ItemBuilder(Material.NETHERRACK, 1).setRawTitle(C.cBlue + "Outpost").setLore(C.cWhite + "It appears to be a contraption of some sort!").build();
|
||||
public static final byte OUTPOST_BLOCK_DATA = (byte) 137;
|
||||
|
||||
public static final long PREP_TIME = 2 * 60 * 1000;
|
||||
|
||||
@ -140,20 +138,11 @@ public class Outpost implements Listener
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
if (_ownerClan.isMember(player))
|
||||
{
|
||||
if (_ownerClan.isMember(player) || _state != OutpostState.LIVE)
|
||||
return;
|
||||
}
|
||||
|
||||
if (_state != OutpostState.LIVE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (clickType == ClickType.LEFT || clickType == ClickType.SHIFT_LEFT)
|
||||
{
|
||||
kill();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
@ -169,9 +158,9 @@ public class Outpost implements Listener
|
||||
|
||||
_state = token.OutpostState;
|
||||
|
||||
_circleStages = new LoopIterator<Vector>(circleAround(new Vector(0., 0., 0.), 40, .6d));
|
||||
_circleStages = new LoopIterator<Vector>(UtilTrig.GetCirclePoints(new Vector(0., 0., 0.), 40, .6d));
|
||||
|
||||
List<Vector> reverse = circleAround(new Vector(0., 0., 0.), 40, .6d);
|
||||
List<Vector> reverse = UtilTrig.GetCirclePoints(new Vector(0., 0., 0.), 40, .6d);
|
||||
Collections.reverse(reverse);
|
||||
_reverseCircleStages = new LoopIterator<Vector>(reverse);
|
||||
|
||||
@ -184,6 +173,19 @@ public class Outpost implements Listener
|
||||
|
||||
_nameHolograms.forEach(Hologram::start);
|
||||
|
||||
_nameHolograms.forEach(hologram ->
|
||||
hologram.setInteraction((player, click) ->
|
||||
UtilBlock.getInRadius(hologram.getLocation(), 2, 2).forEach((block, dist) -> {
|
||||
if (block.getType() == Material.IRON_DOOR)
|
||||
{
|
||||
Door door = (Door) block.getState();
|
||||
|
||||
door.setOpen(!door.isOpen());
|
||||
}
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
_lifetimeLeft.start();
|
||||
}
|
||||
}
|
||||
@ -221,33 +223,24 @@ public class Outpost implements Listener
|
||||
|
||||
_outpostManager.getRepository().insertOutpost(toToken());
|
||||
|
||||
_circleStages = new LoopIterator<Vector>(circleAround(new Vector(0., 0., 0.), 40, .6d));
|
||||
_circleStages = new LoopIterator<Vector>(UtilTrig.GetCirclePoints(new Vector(0., 0., 0.), 40, .6d));
|
||||
|
||||
List<Vector> reverse = circleAround(new Vector(0., 0., 0.), 40, .6d);
|
||||
List<Vector> reverse = UtilTrig.GetCirclePoints(new Vector(0., 0., 0.), 40, .6d);
|
||||
Collections.reverse(reverse);
|
||||
_reverseCircleStages = new LoopIterator<Vector>(reverse);
|
||||
|
||||
UtilServer.registerEvents(this);
|
||||
UtilServer.RegisterEvents(this);
|
||||
|
||||
_lifetimeLeft = new Hologram(outpostManager.getClansManager().getHologramManager(), _origin.clone().add(0.5, 1.5, 0.5), "Despawning in " + F.time(UtilTime.MakeStr(MAX_LIFETIME)));
|
||||
_lifetimeLeft.setInteraction(new HologramInteraction()
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
if (_ownerClan.isMember(player))
|
||||
{
|
||||
if (_ownerClan.isMember(player) || _state != OutpostState.LIVE)
|
||||
return;
|
||||
}
|
||||
|
||||
if (_state != OutpostState.LIVE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (clickType == ClickType.LEFT || clickType == ClickType.SHIFT_LEFT)
|
||||
{
|
||||
kill();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -282,24 +275,16 @@ public class Outpost implements Listener
|
||||
do
|
||||
{
|
||||
if (event.getClickedBlock() == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (!UtilItem.isDoor(event.getClickedBlock().getType()))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (_ownerClan.isMember(event.getPlayer()))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (UtilAlg.inBoundingBox(event.getClickedBlock().getLocation(), _startCorner.clone().subtract(.5, 0, .5), _endCorner))
|
||||
{
|
||||
@ -311,19 +296,13 @@ public class Outpost implements Listener
|
||||
}
|
||||
|
||||
if (getState() != OutpostState.AWAITING)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UtilEvent.isAction(event, ActionType.R_BLOCK))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (getLifetime() <= 2000)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_ownerClan.equals(_ownerClan.Clans.getClanUtility().getClanByPlayer(event.getPlayer())))
|
||||
{
|
||||
@ -354,13 +333,9 @@ public class Outpost implements Listener
|
||||
UtilTextMiddle.display("Siege", "Your Outpost has been destroyed", 20, 100, 20, _ownerClan.getOnlinePlayersArray());
|
||||
|
||||
if (getState() == OutpostState.AWAITING)
|
||||
{
|
||||
cleanup();
|
||||
}
|
||||
else
|
||||
{
|
||||
kill();
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -389,13 +364,9 @@ public class Outpost implements Listener
|
||||
UtilTextMiddle.display("Siege", "Your Outpost has been destroyed", 20, 100, 20, _ownerClan.getOnlinePlayersArray());
|
||||
|
||||
if (getState() == OutpostState.AWAITING)
|
||||
{
|
||||
cleanup();
|
||||
}
|
||||
else
|
||||
{
|
||||
kill();
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -405,7 +376,7 @@ public class Outpost implements Listener
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You may not break blocks in Outposts."));
|
||||
event.setCancelled(true);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -422,9 +393,7 @@ public class Outpost implements Listener
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (UtilAlg.inBoundingBox(event.getBlock().getLocation(), _startCorner.clone().subtract(.5, 0, .5), _endCorner))
|
||||
{
|
||||
@ -460,23 +429,15 @@ public class Outpost implements Listener
|
||||
RGBData color = UtilColor.RgbLightBlue;
|
||||
|
||||
for (int x = -_type._size; x <= _type._size; x++)
|
||||
{
|
||||
for (int z = -_type._size; z <= _type._size; z++)
|
||||
{
|
||||
if (x == -_type._size || x == _type._size || z == -_type._size || z == _type._size)
|
||||
{
|
||||
UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, UtilBlock.getHighest(_origin.getWorld(), _origin.clone().add(x + .5, .1, z + .5).getBlockX(), _origin.clone().add(x + .5, .1, z + .5).getBlockZ()).getLocation().add(0.5, 0, 0.5), new Vector(color.getRed(), color.getGreen(), color.getBlue()), 1f, 0, ViewDist.NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (_lifetimeLeft != null)
|
||||
{
|
||||
_lifetimeLeft.setText("Despawning in " + F.time(UtilTime.MakeStr(MAX_LIFETIME - (System.currentTimeMillis() - _timeSpawned))));
|
||||
}
|
||||
|
||||
if (_state == OutpostState.CONSTRUCTING)
|
||||
{
|
||||
@ -491,24 +452,16 @@ public class Outpost implements Listener
|
||||
Iterator<String> iterator = _buildQueue.keySet().iterator();
|
||||
|
||||
if (iterator.hasNext())
|
||||
{
|
||||
_buildQueue.remove(iterator.next()).set();
|
||||
}
|
||||
}
|
||||
|
||||
// Forcefield
|
||||
RGBData color = UtilColor.RgbLightBlue;
|
||||
|
||||
for (int x = _forceFieldStart.getBlockX(); x <= _forceFieldEnd.getBlockX(); x++)
|
||||
{
|
||||
for (int z = _forceFieldStart.getBlockZ(); z <= _forceFieldEnd.getBlockZ(); z++)
|
||||
{
|
||||
if (x == _forceFieldStart.getBlockX() || x == _forceFieldEnd.getBlockX() || z == _forceFieldStart.getBlockZ() || z == _forceFieldEnd.getBlockZ())
|
||||
{
|
||||
UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, new Location(_core.getWorld(), x + .5, UtilBlock.getHighest(_core.getWorld(), x, z).getY() + .15, z + .5), new Vector(color.getRed(), color.getGreen(), color.getBlue()), 1f, 0, ViewDist.NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RGBData next = _fader.next();
|
||||
@ -540,9 +493,7 @@ public class Outpost implements Listener
|
||||
public void forcefield(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST || getState() != OutpostState.CONSTRUCTING)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UtilServer.getPlayersCollection().stream()
|
||||
.filter(player -> !_ownerClan.isMember(player))
|
||||
@ -572,7 +523,6 @@ public class Outpost implements Listener
|
||||
|
||||
//Inform nearby Clans
|
||||
for (int chunkX = -3; chunkX < 3; chunkX++)
|
||||
{
|
||||
for (int chunkZ = -3; chunkZ < 3; chunkZ++)
|
||||
{
|
||||
ClanTerritory territory = _ownerClan.Clans.getClanUtility().getClaim(_origin.getWorld().getChunkAt(_origin.getChunk().getX() + chunkX, _origin.getChunk().getZ() + chunkZ));
|
||||
@ -585,26 +535,10 @@ public class Outpost implements Listener
|
||||
UtilTextMiddle.display("Siege", "A Siege has been declared on your Clan!", 20, 100, 20, clan.getOnlinePlayersArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_nameHolograms.forEach(Hologram::start);
|
||||
}
|
||||
|
||||
private List<Vector> circleAround(Vector origin, int points, double radius)
|
||||
{
|
||||
List<Vector> list = new LinkedList<>();
|
||||
|
||||
double slice = 2 * Math.PI / points;
|
||||
|
||||
for (int point = 0; point < points; point++)
|
||||
{
|
||||
double angle = slice * point;
|
||||
list.add(new Vector(origin.getX() + radius * Math.cos(angle), 0, origin.getZ() + radius * Math.sin(angle)));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public void kill()
|
||||
{
|
||||
_state = OutpostState.DESTRUCTING;
|
||||
|
@ -57,7 +57,7 @@ public class OutpostManager extends MiniPlugin
|
||||
|
||||
_clansManager = clansManager;
|
||||
|
||||
_repository= new OutpostRepository(clansManager.getPlugin(), this);
|
||||
_repository = new OutpostRepository(clansManager.getPlugin(), this);
|
||||
|
||||
_removalQueue = new ArrayList<>();
|
||||
}
|
||||
@ -66,26 +66,18 @@ public class OutpostManager extends MiniPlugin
|
||||
public void onPlaceBlock(BlockPlaceEvent event)
|
||||
{
|
||||
if (event.getItemInHand().isSimilar(Outpost.OUTPOST_ITEM))
|
||||
{
|
||||
if (spawnOutpost(event.getPlayer(), event.getBlock().getLocation(), OutpostType.MK_I))
|
||||
{
|
||||
event.getBlock().setData((byte) Outpost.OUTPOST_BLOCK_DATA);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!spawnOutpost(event.getPlayer(), event.getBlock().getLocation(), OutpostType.MK_III))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean spawnOutpost(Player player, Location location, OutpostType type)
|
||||
{
|
||||
if (_clansManager.getNetherManager().isInNether(player))
|
||||
{
|
||||
_clansManager.message(player, "You are not allowed to place this in " + F.clansNether("The Nether") + ".");
|
||||
|
||||
return false;
|
||||
}
|
||||
// if (_clansManager.getNetherManager().isInNether(player))
|
||||
// {
|
||||
// _clansManager.message(player, "You are not allowed to place this in " + F.clansNether("The Nether") + ".");
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
|
||||
if (!_clansManager.isInClan(player))
|
||||
{
|
||||
@ -129,7 +121,6 @@ public class OutpostManager extends MiniPlugin
|
||||
}
|
||||
|
||||
for (int x = -4; x < 4; x++)
|
||||
{
|
||||
for (int z = -4; z < 4; z++)
|
||||
{
|
||||
Chunk chunk = location.getWorld().getChunkAt(location.getChunk().getX() + x, location.getChunk().getZ() + z);
|
||||
@ -145,12 +136,10 @@ public class OutpostManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean gut = false;
|
||||
|
||||
for (int x = -6; x < 6; x++)
|
||||
{
|
||||
for (int z = -6; z < 6; z++)
|
||||
{
|
||||
Chunk chunk = location.getWorld().getChunkAt(location.getChunk().getX() + x, location.getChunk().getZ() + z);
|
||||
@ -168,7 +157,6 @@ public class OutpostManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* das ist schlecht */
|
||||
if (!gut)
|
||||
@ -178,9 +166,7 @@ public class OutpostManager extends MiniPlugin
|
||||
}
|
||||
|
||||
for (int x = -type._size; x < type._size; x++)
|
||||
{
|
||||
for (int y = -1; y < type._ySize; y++)
|
||||
{
|
||||
for (int z = -type._size; z < type._size; z++)
|
||||
{
|
||||
Location loc = location.clone().add(x, y, z);
|
||||
@ -191,8 +177,6 @@ public class OutpostManager extends MiniPlugin
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_outposts.put(clan.getName(), new Outpost(this, clan, location, type));
|
||||
_idToOutpost.put(_outposts.get(clan.getName()).getUniqueId(), _outposts.get(clan.getName()));
|
||||
@ -204,67 +188,43 @@ public class OutpostManager extends MiniPlugin
|
||||
public void onBlockFall(EntityChangeBlockEvent event)
|
||||
{
|
||||
if (event.getEntity().hasMetadata("ClansOutpost"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClaim(PlayerClaimTerritoryEvent event)
|
||||
{
|
||||
for (Outpost outpost : _outposts.values())
|
||||
{
|
||||
if (outpost.getBounds().b(UtilAlg.toBoundingBox(event.getClaimedChunk().getBlock(0, 0, 0).getLocation(), event.getClaimedChunk().getBlock(15, 254, 15).getLocation())))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
UtilPlayer.message(event.getClaimer(), F.main("Clans", "You cannot claim this territory as it overlaps with " + F.elem(outpost.getOwner().getName()) + "'s Outpost."));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
for (Outpost outpost : _outposts.values())
|
||||
{
|
||||
if (outpost.getState() != OutpostState.DEAD)
|
||||
{
|
||||
if (outpost.getState() == OutpostState.CONSTRUCTING ? event.getType() == UpdateType.TICK : event.getType() == UpdateType.TICK)
|
||||
{
|
||||
outpost.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
_outposts.values()
|
||||
.stream()
|
||||
.filter(outpost -> outpost.getState() == OutpostState.CONSTRUCTING ? event.getType() == UpdateType.TICK : event.getType() == UpdateType.TICK)
|
||||
.forEach(Outpost::update);
|
||||
|
||||
if (event.getType() == UpdateType.FASTER)
|
||||
{
|
||||
if (!_removalQueue.isEmpty())
|
||||
{
|
||||
HandlerList.unregisterAll(_idToOutpost.remove(Integer.valueOf(_outposts.remove(_removalQueue.remove(0)).getUniqueId())));
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getType() == UpdateType.TWOSEC)
|
||||
{
|
||||
for (Outpost outpost : _outposts.values())
|
||||
{
|
||||
if (outpost.getState() == OutpostState.LIVE && outpost.getLifetime() > Outpost.MAX_LIFETIME)
|
||||
{
|
||||
outpost.kill();
|
||||
}
|
||||
}
|
||||
}
|
||||
_outposts.values()
|
||||
.stream()
|
||||
.filter(outpost -> outpost.getState() == OutpostState.LIVE && outpost.getLifetime() > Outpost.MAX_LIFETIME)
|
||||
.forEach(Outpost::kill);
|
||||
}
|
||||
|
||||
public Outpost Get(ClanInfo clan)
|
||||
{
|
||||
if (clan == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return _outposts.get(clan.getName().toLowerCase());
|
||||
return clan == null ? null : _outposts.get(clan.getName().toLowerCase());
|
||||
}
|
||||
|
||||
public void queueForRemoval(String name)
|
||||
@ -316,10 +276,7 @@ public class OutpostManager extends MiniPlugin
|
||||
});
|
||||
|
||||
if (post != null)
|
||||
{
|
||||
post.run();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -327,33 +284,28 @@ public class OutpostManager extends MiniPlugin
|
||||
{
|
||||
final Stack<Runnable> queue = new Stack<>();
|
||||
|
||||
for (final Outpost outpost : _outposts.values())
|
||||
{
|
||||
_outposts.values().forEach(outpost -> {
|
||||
final OutpostToken token = outpost.toToken();
|
||||
|
||||
queue.push(() -> {
|
||||
_repository.updateOutpost(token);
|
||||
});
|
||||
}
|
||||
|
||||
runAsync(() -> {
|
||||
while (!queue.isEmpty())
|
||||
{
|
||||
queue.pop().run();
|
||||
}
|
||||
queue.push(() -> _repository.updateOutpost(token));
|
||||
});
|
||||
|
||||
runAsync(() -> {
|
||||
_repository.getOutpostsByServer(_clansManager.getServerId(), tokens -> {
|
||||
while (!queue.isEmpty())
|
||||
queue.pop().run();
|
||||
});
|
||||
|
||||
runAsync(() ->
|
||||
_repository.getOutpostsByServer(_clansManager.getServerId(), tokens ->
|
||||
tokens.forEach(token -> {
|
||||
if (!_idToOutpost.containsKey(Integer.valueOf(token.UniqueId)))
|
||||
{
|
||||
System.out.println("[OUTPOSTS] OUTPOST [" + token.UniqueId + "] NO LONGER EXISTS, DELETING");
|
||||
_repository.deleteOutpost(token.UniqueId);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public OutpostRepository getRepository()
|
||||
|
@ -312,7 +312,7 @@ public class Cannon extends SiegeWeapon
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Fire(WeaponProjectile projectile)
|
||||
public void CustomFire(WeaponProjectile projectile)
|
||||
{
|
||||
projectile.setLocation(projectile.getLocation().add(.0, .2, .0));
|
||||
|
||||
@ -321,7 +321,7 @@ public class Cannon extends SiegeWeapon
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNextState()
|
||||
public String GetNextState()
|
||||
{
|
||||
if (getAmmunition() > 0)
|
||||
{
|
||||
@ -337,7 +337,7 @@ public class Cannon extends SiegeWeapon
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void Tick()
|
||||
protected void CustomTick()
|
||||
{
|
||||
updateInventory();
|
||||
|
||||
@ -348,7 +348,7 @@ public class Cannon extends SiegeWeapon
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double[] getProjectileVelocity()
|
||||
protected double[] GetProjectileVelocity()
|
||||
{
|
||||
int firepower = getPowerLevel();
|
||||
|
||||
@ -357,21 +357,21 @@ public class Cannon extends SiegeWeapon
|
||||
|
||||
if (firepower == 1)
|
||||
{
|
||||
hMult = 0.6;
|
||||
hMult = 1.2;
|
||||
yAdd = 0.5;
|
||||
}
|
||||
else if (firepower == 2)
|
||||
{
|
||||
hMult = 1;
|
||||
hMult = 1.7;
|
||||
yAdd = 0.55;
|
||||
}
|
||||
else if (firepower >= 3)
|
||||
{
|
||||
hMult = 1.5;
|
||||
hMult = 2.35;
|
||||
yAdd = 0.6;
|
||||
}
|
||||
|
||||
return new double[] { hMult, yAdd };
|
||||
return new double[] { yAdd, hMult };
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ public class Catapult extends SiegeWeapon
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Fire(WeaponProjectile projectile)
|
||||
public void CustomFire(WeaponProjectile projectile)
|
||||
{
|
||||
projectile.setLocation(projectile.getLocation().add(.0, 2.7, .0));
|
||||
|
||||
@ -257,7 +257,7 @@ public class Catapult extends SiegeWeapon
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNextState()
|
||||
public String GetNextState()
|
||||
{
|
||||
if (System.currentTimeMillis() - _lastFired < 4500)
|
||||
{
|
||||
@ -273,7 +273,7 @@ public class Catapult extends SiegeWeapon
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void Tick()
|
||||
protected void CustomTick()
|
||||
{
|
||||
if (getProjectile() != null)
|
||||
{
|
||||
@ -282,7 +282,7 @@ public class Catapult extends SiegeWeapon
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double[] getProjectileVelocity()
|
||||
protected double[] GetProjectileVelocity()
|
||||
{
|
||||
int firepower = getPowerLevel();
|
||||
|
||||
|
@ -61,71 +61,69 @@ import mineplex.game.clans.items.legendaries.WindBlade;
|
||||
|
||||
public abstract class SiegeWeapon implements Listener
|
||||
{
|
||||
// Constants
|
||||
protected final int _maxHealth;
|
||||
protected final byte _weaponTypeIdentifier;
|
||||
|
||||
// Managers
|
||||
protected ClansManager _clans;
|
||||
protected SiegeManager _siegeManager;
|
||||
|
||||
protected int _uniqueId;
|
||||
|
||||
protected ClanInfo _ownerClan;
|
||||
protected final String _name;
|
||||
protected final int _maxHealth;
|
||||
protected int _health;
|
||||
|
||||
protected Inventory _inventory;
|
||||
protected AccessRule _inventoryAccess;
|
||||
|
||||
private Hologram _infoHologram;
|
||||
private BarrierCollisionBox _collisionBox;
|
||||
// Info
|
||||
protected final int _uniqueId;
|
||||
|
||||
protected final ClanInfo _ownerClan;
|
||||
protected final Location _location;
|
||||
protected final String _name;
|
||||
|
||||
private final NautHashMap<String, WeaponStateInfo> _registeredStates;
|
||||
private String _currentState;
|
||||
protected int _health;
|
||||
protected String _currentState;
|
||||
protected boolean _alive = true;
|
||||
|
||||
// Mechanics
|
||||
protected final NautArrayList<Entity> _comprisedOf;
|
||||
|
||||
// Friendly-name mapping to index in _comprisedOf for easier management of entities.
|
||||
protected final NautHashMap<String, Entity> _entityMapping;
|
||||
protected Player _rider;
|
||||
protected Inventory _inventory;
|
||||
protected AccessRule _inventoryAccess;
|
||||
protected BarrierCollisionBox _collisionBox;
|
||||
|
||||
private boolean _isRideable;
|
||||
private AccessRule _mountAccess;
|
||||
protected AccessRule _fireAccess;
|
||||
|
||||
protected int _baseDamage;
|
||||
|
||||
private AccessRule _fireAccess;
|
||||
|
||||
// Firing stuff
|
||||
|
||||
protected boolean _invertRotation;
|
||||
|
||||
private Material _firepowerType;
|
||||
private Material _ammunitionType;
|
||||
|
||||
private NautArrayList<Integer> _firepowerSlots;
|
||||
private int _ammunitionSlot;
|
||||
|
||||
private int _maxAmmunition;
|
||||
private int _maxFirepowerPerSlot;
|
||||
|
||||
private int _boundingBoxSize;
|
||||
|
||||
private ProjectileAttributes _projectileAttributes;
|
||||
private WeaponProjectile _projectile;
|
||||
|
||||
protected float _rotSpeed = 20.f;
|
||||
|
||||
private long _lastRight = -1;
|
||||
private long _lastLeft = -1;
|
||||
protected int _boundingBoxSize;
|
||||
|
||||
protected double _yaw;
|
||||
|
||||
protected Player _rider;
|
||||
protected long _lastRight = -1;
|
||||
protected long _lastLeft = -1;
|
||||
protected long _lastFired = -1;
|
||||
|
||||
protected long _lastFired;
|
||||
// Display
|
||||
protected Hologram _infoHologram;
|
||||
|
||||
protected boolean _alive = true;
|
||||
// Utility
|
||||
protected final NautHashMap<String, WeaponStateInfo> _registeredStates;
|
||||
protected final NautHashMap<String, Entity> _entityMapping;
|
||||
|
||||
protected final byte _weaponTypeIdentifier;
|
||||
// Customizability
|
||||
protected boolean _isRideable;
|
||||
protected boolean _invertRotation;
|
||||
protected AccessRule _mountAccess;
|
||||
|
||||
protected float _rotSpeed = 20.f;
|
||||
|
||||
protected int _ammunitionSlot;
|
||||
protected Material _ammunitionType;
|
||||
protected int _maxAmmunition;
|
||||
|
||||
protected NautArrayList<Integer> _firepowerSlots;
|
||||
protected Material _firepowerType;
|
||||
protected int _maxFirepowerPerSlot;
|
||||
|
||||
protected int _baseDamage;
|
||||
|
||||
protected ProjectileAttributes _projectileAttributes;
|
||||
protected WeaponProjectile _projectile;
|
||||
|
||||
public SiegeWeapon(int maxHealth, String name, SiegeWeaponToken token, ClansManager clansManager, SiegeManager siegeManager)
|
||||
{
|
||||
@ -146,7 +144,7 @@ public abstract class SiegeWeapon implements Listener
|
||||
_infoHologram = new Hologram(ClansManager.getInstance().getHologramManager(), _location.clone().add(.5, 3, .5), _name + " Health", getDisplayHealth());
|
||||
_infoHologram.start();
|
||||
|
||||
UtilServer.registerEvents(this);
|
||||
UtilServer.RegisterEvents(this);
|
||||
|
||||
_clans = clansManager;
|
||||
|
||||
@ -183,77 +181,29 @@ public abstract class SiegeWeapon implements Listener
|
||||
_clans = clansManager;
|
||||
}
|
||||
|
||||
public int getBaseDamage()
|
||||
{
|
||||
return _baseDamage;
|
||||
}
|
||||
|
||||
public ClanInfo getOwner()
|
||||
{
|
||||
return _ownerClan;
|
||||
}
|
||||
|
||||
public ClansManager getClans()
|
||||
{
|
||||
return _clans;
|
||||
}
|
||||
|
||||
protected void damage(Player player)
|
||||
{
|
||||
int health = getHandDamage(player);
|
||||
|
||||
removeHealth(health);
|
||||
|
||||
UtilTextMiddle.display(UtilText.possesive(_ownerClan.getName(), _name), C.cRed + "-" + health, 0, 10, 0, player);
|
||||
}
|
||||
|
||||
protected int getHandDamage(Player player)
|
||||
protected int calculateDamage(Player player)
|
||||
{
|
||||
ItemStack stack = player.getItemInHand();
|
||||
PlayerGear gear = _clans.getGearManager().getPlayerGear(player);
|
||||
|
||||
if (stack == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (gear.getWeapon() != null && gear.getWeapon() instanceof LegendaryItem)
|
||||
{
|
||||
if (gear.getWeapon() instanceof AlligatorsTooth)
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
else if (gear.getWeapon() instanceof GiantsBroadsword)
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
else if (gear.getWeapon() instanceof HyperAxe)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
else if (gear.getWeapon() instanceof MagneticMaul)
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
else if (gear.getWeapon() instanceof WindBlade)
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
return (int) UtilItem.getAttackDamage(stack.getType());
|
||||
}
|
||||
|
||||
protected void ResetEntities()
|
||||
{
|
||||
}
|
||||
|
||||
protected abstract void FindEntities();
|
||||
|
||||
protected abstract double[] getProjectileVelocity();
|
||||
|
||||
protected abstract String getNextState();
|
||||
|
||||
protected void enableInventory(Inventory inventory, AccessRule accessRule)
|
||||
{
|
||||
_inventory = inventory;
|
||||
@ -286,7 +236,7 @@ public abstract class SiegeWeapon implements Listener
|
||||
_collisionBox.registerLeft((block, player) -> handleLeftClick(player));
|
||||
}
|
||||
|
||||
private void updateWeapon()
|
||||
private void update()
|
||||
{
|
||||
if (getEntity("WEAPON") == null || getEntity("PLAYERMOUNT") == null)
|
||||
{
|
||||
@ -295,24 +245,15 @@ public abstract class SiegeWeapon implements Listener
|
||||
}
|
||||
|
||||
if (_inventory != null)
|
||||
{
|
||||
checkInventory();
|
||||
}
|
||||
|
||||
_rider = (Player) getEntity("PLAYERMOUNT").getPassenger();
|
||||
|
||||
if (!getNextState().equals(_currentState))
|
||||
{
|
||||
setState(getNextState());
|
||||
}
|
||||
if (!GetNextState().equals(_currentState))
|
||||
setState(GetNextState());
|
||||
|
||||
if (_projectile != null)
|
||||
{
|
||||
if (_projectile.hasDied())
|
||||
{
|
||||
_projectile = null;
|
||||
}
|
||||
}
|
||||
if (_projectile != null && _projectile.hasDied())
|
||||
_projectile = null;
|
||||
|
||||
ArmorStand armorStand = (ArmorStand) getEntity("WEAPON");
|
||||
double standYaw = _yaw % 360;
|
||||
@ -321,43 +262,30 @@ public abstract class SiegeWeapon implements Listener
|
||||
{
|
||||
double riderYaw = (getRider().getLocation().getYaw() + (_invertRotation ? 180 : 0)) % 360;
|
||||
|
||||
// riderYaw = 350 and standYaw = 20
|
||||
// dif should be -30 and not 330
|
||||
double dif = riderYaw - standYaw;
|
||||
if (dif > 180) dif -= 360;
|
||||
if (dif < -180) dif += 360;
|
||||
|
||||
double yaw = (float) ((float)standYaw + Math.min(dif / _rotSpeed, 4f));
|
||||
|
||||
_yaw = yaw;
|
||||
|
||||
armorStand.setHeadPose(new EulerAngle(0, Math.toRadians(PreRotate(_yaw)), 0));
|
||||
armorStand.setHeadPose(new EulerAngle(0, Math.toRadians(CustomRotate(_yaw = yaw)), 0));
|
||||
}
|
||||
}
|
||||
|
||||
// Firing
|
||||
|
||||
protected boolean canBeFired()
|
||||
{
|
||||
return getPowerLevel() > 0 && getAmmunition() > 0 && _projectile == null;
|
||||
}
|
||||
|
||||
protected WeaponProjectile getProjectile()
|
||||
{
|
||||
return _projectile;
|
||||
}
|
||||
|
||||
private void fire(Player player)
|
||||
{
|
||||
_lastFired = System.currentTimeMillis();
|
||||
|
||||
double[] vel = getProjectileVelocity();
|
||||
|
||||
_projectile = new WeaponProjectile(this, _location.clone().add(.5, 0, .5), _projectileAttributes, ((ArmorStand) getEntity("WEAPON")).getHeadPose().getY(), vel[0], vel[1]);
|
||||
double[] vel = GetProjectileVelocity();
|
||||
|
||||
_inventory.clear();
|
||||
|
||||
Fire(_projectile);
|
||||
CustomFire(_projectile = new WeaponProjectile(this, _location.clone().add(.5, 0, .5), _projectileAttributes, ((ArmorStand) getEntity("WEAPON")).getHeadPose().getY(), vel[0], vel[1]));
|
||||
}
|
||||
|
||||
protected void setFireRule(AccessRule rule)
|
||||
@ -400,65 +328,20 @@ public abstract class SiegeWeapon implements Listener
|
||||
_projectileAttributes = projectileAttributes;
|
||||
}
|
||||
|
||||
protected int getAmmunition()
|
||||
{
|
||||
ItemStack item = _inventory.getItem(_ammunitionSlot);
|
||||
|
||||
if (item != null && item.getType().equals(_ammunitionType))
|
||||
{
|
||||
return item.getAmount();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected int getPowerLevel()
|
||||
{
|
||||
int power = 0;
|
||||
|
||||
for (int slot : _firepowerSlots)
|
||||
{
|
||||
ItemStack item = _inventory.getItem(slot);
|
||||
|
||||
if (item == null || !item.getType().equals(_firepowerType))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
power += _inventory.getItem(slot).getAmount();
|
||||
}
|
||||
|
||||
return power / 4;
|
||||
}
|
||||
|
||||
// Riding
|
||||
|
||||
public Player getRider()
|
||||
{
|
||||
return _rider;
|
||||
}
|
||||
|
||||
protected boolean isRiding(Player player)
|
||||
{
|
||||
return player.equals(getRider());
|
||||
}
|
||||
|
||||
public int getUniqueId()
|
||||
{
|
||||
return _uniqueId;
|
||||
}
|
||||
|
||||
protected void setRideable(AccessRule accessRule)
|
||||
{
|
||||
_isRideable = true;
|
||||
_mountAccess = accessRule;
|
||||
}
|
||||
|
||||
// Internal
|
||||
|
||||
public void kill()
|
||||
{
|
||||
Cleanup();
|
||||
CustomCleanup();
|
||||
|
||||
_comprisedOf.forEach(Entity::remove);
|
||||
|
||||
@ -475,12 +358,12 @@ public abstract class SiegeWeapon implements Listener
|
||||
|
||||
private void handleMount(Player player)
|
||||
{
|
||||
if (!OverrideMount(player))
|
||||
if (!CustomMount(player))
|
||||
{
|
||||
getEntity("PLAYERMOUNT").setPassenger(player);
|
||||
}
|
||||
|
||||
OnMount(player);
|
||||
CustomOnMount(player);
|
||||
}
|
||||
|
||||
private void handleInventoryOpen(Player player)
|
||||
@ -504,7 +387,7 @@ public abstract class SiegeWeapon implements Listener
|
||||
|
||||
_lastRight = System.currentTimeMillis();
|
||||
|
||||
RightClick(player);
|
||||
CustomRightClick(player);
|
||||
|
||||
if (_isRideable && _mountAccess.allow(AccessType.RCLICK_BB, player))
|
||||
{
|
||||
@ -550,7 +433,7 @@ public abstract class SiegeWeapon implements Listener
|
||||
|
||||
_lastLeft = System.currentTimeMillis();
|
||||
|
||||
LeftClick(player);
|
||||
CustomLeftClick(player);
|
||||
|
||||
if (_isRideable && _mountAccess.allow(AccessType.LCLICK_BB, player))
|
||||
{
|
||||
@ -572,56 +455,29 @@ public abstract class SiegeWeapon implements Listener
|
||||
|
||||
if (!_ownerClan.isMember(player))
|
||||
{
|
||||
damage(player);
|
||||
int health = calculateDamage(player);
|
||||
|
||||
removeHealth(health);
|
||||
|
||||
UtilTextMiddle.display(UtilText.possesive(_ownerClan.getName(), _name), C.cRed + "-" + health, 0, 10, 0, player);
|
||||
}
|
||||
}
|
||||
|
||||
// Methods for implementation by sub-classes
|
||||
|
||||
protected void Tick()
|
||||
{
|
||||
}
|
||||
|
||||
protected void OnMount(Player player)
|
||||
{
|
||||
}
|
||||
|
||||
protected void LeftClick(Player player)
|
||||
{
|
||||
}
|
||||
|
||||
protected void RightClick(Player player)
|
||||
{
|
||||
}
|
||||
|
||||
protected double PreRotate(double yaw)
|
||||
{
|
||||
return yaw;
|
||||
}
|
||||
|
||||
protected void Cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
protected void UpdateState(String state)
|
||||
{
|
||||
}
|
||||
|
||||
protected boolean CustomDismountCheck(Player player, Entity entity)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean OverrideMount(Player player)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void Fire(WeaponProjectile projectile)
|
||||
{
|
||||
}
|
||||
|
||||
// Entity Management
|
||||
protected abstract double[] GetProjectileVelocity();
|
||||
protected abstract String GetNextState();
|
||||
protected abstract void FindEntities();
|
||||
protected void ResetEntities() { return; }
|
||||
protected void CustomTick() { return; }
|
||||
protected void CustomOnMount(Player player) { return; }
|
||||
protected void CustomLeftClick(Player player) { return; }
|
||||
protected void CustomRightClick(Player player) { return; }
|
||||
protected void CustomCleanup() { return; }
|
||||
protected void CustomUpdateState(String state) { return; }
|
||||
protected void CustomFire(WeaponProjectile projectile) { return; }
|
||||
protected double CustomRotate(double yaw) { return yaw; }
|
||||
protected boolean CustomDismount(Player player, Entity entity) { return false; }
|
||||
protected boolean CustomMount(Player player) { return false; }
|
||||
|
||||
protected final void addEntity(Entity entity, String uniqueName)
|
||||
{
|
||||
@ -645,8 +501,6 @@ public abstract class SiegeWeapon implements Listener
|
||||
return _entityMapping.get(uniqueName);
|
||||
}
|
||||
|
||||
// Health Management
|
||||
|
||||
public final int getHealth()
|
||||
{
|
||||
return _health;
|
||||
@ -664,9 +518,7 @@ public abstract class SiegeWeapon implements Listener
|
||||
_infoHologram.setText(_name + " Health", getDisplayHealth());
|
||||
|
||||
if (_health == 0)
|
||||
{
|
||||
kill();
|
||||
}
|
||||
}
|
||||
|
||||
public final void removeHealth(int health)
|
||||
@ -679,22 +531,13 @@ public abstract class SiegeWeapon implements Listener
|
||||
setHealth(_health + health);
|
||||
}
|
||||
|
||||
//State Management
|
||||
|
||||
public final void setState(String state)
|
||||
{
|
||||
Validate.isTrue(_registeredStates.containsKey(state), "Provided state has not yet been registered.");
|
||||
|
||||
((ArmorStand) getEntity("WEAPON")).setHelmet(new ItemStack(_registeredStates.get(state).getType(), 1, (short) 0, (byte) _registeredStates.get(state).getData()));
|
||||
|
||||
_currentState = state;
|
||||
|
||||
UpdateState(state);
|
||||
}
|
||||
|
||||
public final String getState()
|
||||
{
|
||||
return _currentState;
|
||||
CustomUpdateState(_currentState = state);
|
||||
}
|
||||
|
||||
public final void setStateInfo(String state, WeaponStateInfo info)
|
||||
@ -705,9 +548,7 @@ public abstract class SiegeWeapon implements Listener
|
||||
public final WeaponStateInfo getStateInfo(String state)
|
||||
{
|
||||
if (!_registeredStates.containsKey(state))
|
||||
{
|
||||
_registeredStates.put(state, new WeaponStateInfo(Material.STONE, (byte) 101));
|
||||
}
|
||||
|
||||
return _registeredStates.get(state);
|
||||
}
|
||||
@ -719,27 +560,19 @@ public abstract class SiegeWeapon implements Listener
|
||||
ItemStack item = _inventory.getItem(slot);
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (slot == _ammunitionSlot)
|
||||
{
|
||||
if (item.getType() != _ammunitionType)
|
||||
{
|
||||
if (CustomInventoryValid(slot, item))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (getRider() != null)
|
||||
{
|
||||
getRider().getInventory().addItem(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
_location.getWorld().dropItem(_location, item);
|
||||
}
|
||||
|
||||
_inventory.setItem(slot, null);
|
||||
}
|
||||
@ -748,13 +581,9 @@ public abstract class SiegeWeapon implements Listener
|
||||
if (item.getAmount() > _maxAmmunition)
|
||||
{
|
||||
if (getRider() != null)
|
||||
{
|
||||
getRider().getInventory().addItem(new ItemStack(_ammunitionType, item.getAmount() - _maxAmmunition));
|
||||
}
|
||||
else
|
||||
{
|
||||
_location.getWorld().dropItem(_location, item);
|
||||
}
|
||||
|
||||
_inventory.setItem(slot, new ItemStack(_ammunitionType, _maxAmmunition));
|
||||
}
|
||||
@ -765,18 +594,12 @@ public abstract class SiegeWeapon implements Listener
|
||||
if (item.getType() != _firepowerType)
|
||||
{
|
||||
if (CustomInventoryValid(slot, item))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (getRider() != null)
|
||||
{
|
||||
getRider().getInventory().addItem(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
_location.getWorld().dropItem(_location, item);
|
||||
}
|
||||
|
||||
_inventory.setItem(slot, null);
|
||||
}
|
||||
@ -785,13 +608,9 @@ public abstract class SiegeWeapon implements Listener
|
||||
if (item.getAmount() > _maxFirepowerPerSlot)
|
||||
{
|
||||
if (getRider() != null)
|
||||
{
|
||||
getRider().getInventory().addItem(new ItemStack(_firepowerType, item.getAmount() - _maxFirepowerPerSlot));
|
||||
}
|
||||
else
|
||||
{
|
||||
_location.getWorld().dropItem(_location, item);
|
||||
}
|
||||
|
||||
_inventory.setItem(slot, new ItemStack(_firepowerType, _maxFirepowerPerSlot));
|
||||
}
|
||||
@ -800,26 +619,18 @@ public abstract class SiegeWeapon implements Listener
|
||||
else
|
||||
{
|
||||
if (CustomInventoryValid(slot, item))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (getRider() != null)
|
||||
{
|
||||
getRider().getInventory().addItem(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
_location.getWorld().dropItem(_location, item);
|
||||
}
|
||||
|
||||
_inventory.setItem(slot, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Events
|
||||
|
||||
@EventHandler
|
||||
public void onSiegeWeaponExplode(SiegeWeaponExplodeEvent event)
|
||||
{
|
||||
@ -837,56 +648,33 @@ public abstract class SiegeWeapon implements Listener
|
||||
public void onDamage(EntityDamageEvent event)
|
||||
{
|
||||
if (_comprisedOf.contains(event.getEntity()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onDmg(EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (!_comprisedOf.contains(event.getEntity()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getDamager() instanceof Player)
|
||||
{
|
||||
if (!_comprisedOf.contains(event.getEntity()) && event.getDamager() instanceof Player)
|
||||
handleLeftClick((Player) event.getDamager());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCloseInv(InventoryCloseEvent event)
|
||||
{
|
||||
if (!event.getInventory().equals(_inventory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClansManager.getInstance().runSyncLater(() -> {
|
||||
if (event.getPlayer().getInventory().equals(_inventory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (canBeFired())
|
||||
{
|
||||
if (!event.getPlayer().getInventory().equals(_inventory) && canBeFired())
|
||||
UtilTextMiddle.display(_name + " Ready", "Power Level: " + C.cGreen + UtilText.repeat("▌", getPowerLevel()) + C.cRed + UtilText.repeat("▌", _maxFirepowerPerSlot - getPowerLevel()), 20, 100, 20, (Player) event.getPlayer());
|
||||
}
|
||||
}, 3L);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDismount(EntityDismountEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player)
|
||||
{
|
||||
if (event.getDismounted().equals(getEntity("PLAYERMOUNT")) || CustomDismountCheck((Player) event.getEntity(), event.getDismounted()))
|
||||
{
|
||||
if (event.getEntity() instanceof Player && (event.getDismounted().equals(getEntity("PLAYERMOUNT")) || CustomDismount((Player) event.getEntity(), event.getDismounted())))
|
||||
dismount((Player) event.getEntity());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -931,12 +719,7 @@ public abstract class SiegeWeapon implements Listener
|
||||
|
||||
public boolean inProtection(Block block)
|
||||
{
|
||||
if (block.getLocation().distance(_location) < _boundingBoxSize + 1.65 && block.getLocation().getY() <= _location.getY() + 2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return block.getLocation().distance(_location) < _boundingBoxSize + 1.65 && block.getLocation().getY() <= _location.getY() + 2;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -953,22 +736,18 @@ public abstract class SiegeWeapon implements Listener
|
||||
public void chunkUnload(ChunkUnloadEvent event)
|
||||
{
|
||||
if (_comprisedOf.stream().anyMatch(entity -> entity.getLocation().getChunk().equals(event.getChunk())))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
updateWeapon();
|
||||
update();
|
||||
|
||||
Tick();
|
||||
CustomTick();
|
||||
}
|
||||
|
||||
public Location getLocation()
|
||||
@ -980,7 +759,70 @@ public abstract class SiegeWeapon implements Listener
|
||||
{
|
||||
return _boundingBoxSize;
|
||||
}
|
||||
|
||||
|
||||
public int getBaseDamage()
|
||||
{
|
||||
return _baseDamage;
|
||||
}
|
||||
|
||||
public ClanInfo getOwner()
|
||||
{
|
||||
return _ownerClan;
|
||||
}
|
||||
|
||||
public ClansManager getClans()
|
||||
{
|
||||
return _clans;
|
||||
}
|
||||
|
||||
protected WeaponProjectile getProjectile()
|
||||
{
|
||||
return _projectile;
|
||||
}
|
||||
|
||||
protected int getAmmunition()
|
||||
{
|
||||
ItemStack item = _inventory.getItem(_ammunitionSlot);
|
||||
|
||||
if (item != null && item.getType().equals(_ammunitionType))
|
||||
return item.getAmount();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected int getPowerLevel()
|
||||
{
|
||||
int power = 0;
|
||||
|
||||
for (int slot : _firepowerSlots)
|
||||
{
|
||||
ItemStack item = _inventory.getItem(slot);
|
||||
|
||||
if (item == null || !item.getType().equals(_firepowerType))
|
||||
continue;
|
||||
|
||||
power += _inventory.getItem(slot).getAmount();
|
||||
}
|
||||
|
||||
return power / 4;
|
||||
}
|
||||
|
||||
public int getUniqueId()
|
||||
{
|
||||
return _uniqueId;
|
||||
}
|
||||
|
||||
public Player getRider()
|
||||
{
|
||||
return _rider;
|
||||
}
|
||||
|
||||
public final String getState()
|
||||
{
|
||||
return _currentState;
|
||||
}
|
||||
|
||||
public SiegeWeaponToken toToken()
|
||||
{
|
||||
SiegeWeaponToken token = new SiegeWeaponToken();
|
||||
|
@ -54,7 +54,7 @@ public class BarrierCollisionBox implements Listener
|
||||
{
|
||||
setBlocks();
|
||||
|
||||
UtilServer.registerEvents(this);
|
||||
UtilServer.RegisterEvents(this);
|
||||
}
|
||||
|
||||
public void Destruct()
|
||||
|
@ -1,15 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -237,7 +237,7 @@ public class Gameplay extends MiniPlugin
|
||||
HashSet<Block> remove = new HashSet<Block>();
|
||||
|
||||
for (Block cur : _bucketWater.keySet())
|
||||
if (UtilTime.elapsed(_bucketWater.get(cur), 2000)) remove.add(cur);
|
||||
if (UtilTime.elapsed(_bucketWater.get(cur).longValue(), 2000)) remove.add(cur);
|
||||
|
||||
for (Block cur : remove)
|
||||
_bucketWater.remove(cur);
|
||||
|
@ -1,23 +1,22 @@
|
||||
package mineplex.game.clans.items;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.game.clans.items.attributes.AttributeContainer;
|
||||
import mineplex.game.clans.items.attributes.ItemAttribute;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.game.clans.items.attributes.AttributeContainer;
|
||||
import mineplex.game.clans.items.attributes.ItemAttribute;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
/**
|
||||
* Represents a customizable wrapper for an {@link ItemStack}, enabling the
|
||||
* possession of special abilities, attributes, and triggers on item.
|
||||
@ -25,7 +24,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
* @author MrTwiggy
|
||||
*
|
||||
*/
|
||||
public class CustomItem
|
||||
public class CustomItem implements Listener
|
||||
{
|
||||
|
||||
private static final ChatColor TITLE_COLOR = ChatColor.GOLD; // Chat color
|
||||
@ -69,6 +68,8 @@ public class CustomItem
|
||||
_material = material;
|
||||
_attributes = new AttributeContainer();
|
||||
_uuid = UUID.randomUUID().toString();
|
||||
|
||||
UtilServer.RegisterEvents(this);
|
||||
}
|
||||
|
||||
public CustomItem(Material material)
|
||||
|
@ -16,6 +16,9 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -29,6 +32,8 @@ import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.weight.Weight;
|
||||
import mineplex.core.common.weight.WeightSet;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.packethandler.IPacketHandler;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
@ -56,14 +61,17 @@ import mineplex.game.clans.items.attributes.weapon.JaggedAttribute;
|
||||
import mineplex.game.clans.items.attributes.weapon.SharpAttribute;
|
||||
import mineplex.game.clans.items.commands.GearCommand;
|
||||
import mineplex.game.clans.items.economy.GoldToken;
|
||||
import mineplex.core.common.weight.Weight;
|
||||
import mineplex.core.common.weight.WeightSet;
|
||||
import mineplex.game.clans.items.legendaries.AlligatorsTooth;
|
||||
import mineplex.game.clans.items.legendaries.EnergyCrossbow;
|
||||
import mineplex.game.clans.items.legendaries.GiantsBroadsword;
|
||||
import mineplex.game.clans.items.legendaries.HyperAxe;
|
||||
import mineplex.game.clans.items.legendaries.LegendaryItem;
|
||||
import mineplex.game.clans.items.legendaries.MagneticMaul;
|
||||
import mineplex.game.clans.items.legendaries.MeridianScepter;
|
||||
import mineplex.game.clans.items.legendaries.WindBlade;
|
||||
import mineplex.game.clans.items.rares.Crossbow;
|
||||
import mineplex.game.clans.items.rares.RareItem;
|
||||
import mineplex.game.clans.items.rares.RunedPickaxe;
|
||||
import mineplex.game.clans.items.smelting.SmeltingListener;
|
||||
import mineplex.game.clans.items.ui.GearShop;
|
||||
import mineplex.serverdata.serialization.RuntimeTypeAdapterFactory;
|
||||
@ -99,18 +107,21 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
// currently in Creative gamemode
|
||||
|
||||
// Legendary generation
|
||||
private WeightSet<Class<? extends LegendaryItem>> _legendaryWeights;
|
||||
public WeightSet<Class<? extends LegendaryItem>> LegendaryWeights;
|
||||
|
||||
// Rare generation
|
||||
public WeightSet<Class<? extends RareItem>> RareWeights;
|
||||
|
||||
// Weapon generation
|
||||
private WeightSet<Material> _weaponTypes;
|
||||
public WeightSet<Material> WeaponTypes;
|
||||
|
||||
// Armor generation
|
||||
private WeightSet<Material> _armorTypes;
|
||||
public WeightSet<Material> ArmorTypes;
|
||||
|
||||
// Attribute generation
|
||||
private WeightSet<Class<? extends ItemAttribute>> _weaponAttributes;
|
||||
private WeightSet<Class<? extends ItemAttribute>> _armorAttributes;
|
||||
private WeightSet<Class<? extends ItemAttribute>> _bowAttributes;
|
||||
public WeightSet<Class<? extends ItemAttribute>> WeaponAttributes;
|
||||
public WeightSet<Class<? extends ItemAttribute>> ArmorAttributes;
|
||||
public WeightSet<Class<? extends ItemAttribute>> BowAttributes;
|
||||
|
||||
// Attribute Masks
|
||||
private EnumSet<Material> _maskAttributes;
|
||||
@ -136,24 +147,26 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
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);
|
||||
WeaponAttributes = new WeightSet<Class<? extends ItemAttribute>>(FrostedAttribute.class, SharpAttribute.class, JaggedAttribute.class, HasteAttribute.class, FlamingAttribute.class, ConqueringAttribute.class);
|
||||
|
||||
// Armor-based attributes
|
||||
_armorAttributes = new WeightSet<Class<? extends ItemAttribute>>(SlantedAttribute.class, ReinforcedAttribute.class, ConqueringArmorAttribute.class, PaddedAttribute.class, LavaAttribute.class);
|
||||
ArmorAttributes = new WeightSet<Class<? extends ItemAttribute>>(SlantedAttribute.class, ReinforcedAttribute.class, ConqueringArmorAttribute.class, PaddedAttribute.class, LavaAttribute.class);
|
||||
|
||||
// Bow-based attributes
|
||||
_bowAttributes = new WeightSet<Class<? extends ItemAttribute>>(HeavyArrowsAttribute.class, HuntingAttribute.class, InverseAttribute.class, LeechingAttribute.class, RecursiveAttribute.class, ScorchingAttribute.class, SlayingAttribute.class);
|
||||
BowAttributes = new WeightSet<Class<? extends ItemAttribute>>(HeavyArrowsAttribute.class, HuntingAttribute.class, InverseAttribute.class, LeechingAttribute.class, RecursiveAttribute.class, ScorchingAttribute.class, SlayingAttribute.class);
|
||||
|
||||
// Weapon material types
|
||||
_weaponTypes = new WeightSet<Material>(Material.DIAMOND_SWORD, Material.GOLD_SWORD, Material.IRON_SWORD, Material.DIAMOND_AXE, Material.GOLD_AXE, Material.IRON_AXE);
|
||||
WeaponTypes = new WeightSet<Material>(Material.DIAMOND_SWORD, Material.GOLD_SWORD, Material.IRON_SWORD, Material.DIAMOND_AXE, Material.GOLD_AXE, Material.IRON_AXE);
|
||||
|
||||
// Armor material types
|
||||
_armorTypes = new WeightSet<Material>(Material.DIAMOND_HELMET, Material.DIAMOND_CHESTPLATE, Material.DIAMOND_LEGGINGS, Material.DIAMOND_BOOTS, Material.IRON_HELMET, Material.IRON_CHESTPLATE, Material.IRON_LEGGINGS, Material.IRON_BOOTS, Material.GOLD_HELMET, Material.GOLD_CHESTPLATE, Material.GOLD_LEGGINGS, Material.GOLD_BOOTS);
|
||||
ArmorTypes = new WeightSet<Material>(Material.DIAMOND_HELMET, Material.DIAMOND_CHESTPLATE, Material.DIAMOND_LEGGINGS, Material.DIAMOND_BOOTS, Material.IRON_HELMET, Material.IRON_CHESTPLATE, Material.IRON_LEGGINGS, Material.IRON_BOOTS, Material.GOLD_HELMET, Material.GOLD_CHESTPLATE, Material.GOLD_LEGGINGS, Material.GOLD_BOOTS);
|
||||
|
||||
// TODO: Initialize list of attributes and types
|
||||
|
||||
// Initialize various LegendaryItem types
|
||||
_legendaryWeights = new WeightSet<Class<? extends LegendaryItem>>(AlligatorsTooth.class, WindBlade.class, GiantsBroadsword.class, HyperAxe.class, MagneticMaul.class);
|
||||
LegendaryWeights = new WeightSet<Class<? extends LegendaryItem>>(MeridianScepter.class, EnergyCrossbow.class, AlligatorsTooth.class, WindBlade.class, GiantsBroadsword.class, HyperAxe.class, MagneticMaul.class);
|
||||
|
||||
RareWeights = new WeightSet<Class<? extends RareItem>>(RunedPickaxe.class, Crossbow.class);
|
||||
// TODO: Add rest of legendaries, find better way?
|
||||
|
||||
// Register listeners
|
||||
@ -163,15 +176,15 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
// Initialize attribute types factory for JSON handling of polymorphism.
|
||||
RuntimeTypeAdapterFactory<ItemAttribute> attributeFactory = RuntimeTypeAdapterFactory.of(ItemAttribute.class);
|
||||
|
||||
for (Class<? extends ItemAttribute> attributeType : _armorAttributes.elements())
|
||||
for (Class<? extends ItemAttribute> attributeType : ArmorAttributes.elements())
|
||||
{
|
||||
attributeFactory.registerSubtype(attributeType);
|
||||
}
|
||||
for (Class<? extends ItemAttribute> attributeType : _weaponAttributes.elements())
|
||||
for (Class<? extends ItemAttribute> attributeType : WeaponAttributes.elements())
|
||||
{
|
||||
attributeFactory.registerSubtype(attributeType);
|
||||
}
|
||||
for (Class<? extends ItemAttribute> attributeType : _bowAttributes.elements())
|
||||
for (Class<? extends ItemAttribute> attributeType : BowAttributes.elements())
|
||||
{
|
||||
attributeFactory.registerSubtype(attributeType);
|
||||
}
|
||||
@ -181,8 +194,14 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
RuntimeTypeAdapterFactory<CustomItem> customItemType = RuntimeTypeAdapterFactory.of(CustomItem.class);
|
||||
customItemType.registerSubtype(CustomItem.class);
|
||||
customItemType.registerSubtype(LegendaryItem.class);
|
||||
customItemType.registerSubtype(RareItem.class);
|
||||
customItemType.registerSubtype(GoldToken.class);
|
||||
for (Class<? extends CustomItem> itemType : _legendaryWeights.elements())
|
||||
for (Class<? extends CustomItem> itemType : LegendaryWeights.elements())
|
||||
{
|
||||
customItemType.registerSubtype(itemType);
|
||||
}
|
||||
|
||||
for (Class<? extends RareItem> itemType : RareWeights.elements())
|
||||
{
|
||||
customItemType.registerSubtype(itemType);
|
||||
}
|
||||
@ -238,6 +257,15 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void quit(PlayerQuitEvent event)
|
||||
{
|
||||
if (_playerGears.get(event.getPlayer().getName()) != null)
|
||||
{
|
||||
HandlerList.unregisterAll(_playerGears.get(event.getPlayer().getName()).getWeapon());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player - the player whose {@link PlayerGear} set is to be fetched.
|
||||
* @return the cached or newly instantiated {@link PlayerGear} associated
|
||||
@ -264,15 +292,15 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
|
||||
if (itemType == ItemType.LEGENDARY)
|
||||
{
|
||||
factory.setLegendary(_legendaryWeights.generateRandom());
|
||||
factory.setLegendary(LegendaryWeights.generateRandom());
|
||||
}
|
||||
else if (itemType == ItemType.ARMOR)
|
||||
{
|
||||
factory.setType(_armorTypes.generateRandom());
|
||||
factory.setType(ArmorTypes.generateRandom());
|
||||
}
|
||||
else if (itemType == ItemType.WEAPON)
|
||||
{
|
||||
factory.setType(_weaponTypes.generateRandom());
|
||||
factory.setType(WeaponTypes.generateRandom());
|
||||
}
|
||||
else if (itemType == ItemType.BOW)
|
||||
{
|
||||
@ -323,13 +351,13 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
switch (type)
|
||||
{
|
||||
case ARMOR:
|
||||
sampleAttribute = instantiate(_armorAttributes.generateRandom());
|
||||
sampleAttribute = instantiate(ArmorAttributes.generateRandom());
|
||||
break;
|
||||
case WEAPON:
|
||||
sampleAttribute = instantiate(_weaponAttributes.generateRandom());
|
||||
sampleAttribute = instantiate(WeaponAttributes.generateRandom());
|
||||
break;
|
||||
case BOW:
|
||||
sampleAttribute = instantiate(_bowAttributes.generateRandom());
|
||||
sampleAttribute = instantiate(BowAttributes.generateRandom());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -549,7 +577,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
}
|
||||
}
|
||||
|
||||
if (ci != null && _legendaryWeights.elements().contains(ci.getClass()))
|
||||
if (ci != null && LegendaryWeights.elements().contains(ci.getClass()))
|
||||
{
|
||||
lore.add(C.cWhite + "Original Owner: " + C.cYellow + (ci.OriginalOwner == null ? "You" : Bukkit.getOfflinePlayer(UUID.fromString(ci.OriginalOwner)).getName()));
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ public enum ItemType
|
||||
{
|
||||
LEGENDARY,
|
||||
|
||||
RARE,
|
||||
|
||||
ARMOR,
|
||||
|
||||
WEAPON,
|
||||
|
@ -5,6 +5,7 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -29,11 +30,11 @@ public class PlayerGear
|
||||
private String _playerName; // Name of player who owns the gear
|
||||
|
||||
// Cached custom item information for player's gear
|
||||
private CustomItem weapon;
|
||||
private CustomItem helmet;
|
||||
private CustomItem chestplate;
|
||||
private CustomItem leggings;
|
||||
private CustomItem boots;
|
||||
private CustomItem _weapon;
|
||||
private CustomItem _helmet;
|
||||
private CustomItem _chestplate;
|
||||
private CustomItem _leggings;
|
||||
private CustomItem _boots;
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
@ -160,60 +161,61 @@ public class PlayerGear
|
||||
{
|
||||
ItemStack weaponItem = getPlayer().getInventory().getItemInHand();
|
||||
|
||||
if (!itemsMatch(weapon, weaponItem))
|
||||
if (!itemsMatch(_weapon, weaponItem))
|
||||
{
|
||||
weapon = parseItem(weaponItem);
|
||||
HandlerList.unregisterAll(_weapon);
|
||||
_weapon = parseItem(weaponItem);
|
||||
}
|
||||
|
||||
return weapon;
|
||||
return _weapon;
|
||||
}
|
||||
|
||||
public CustomItem getHelmet()
|
||||
{
|
||||
ItemStack helmetItem = getPlayer().getInventory().getHelmet();
|
||||
|
||||
if (!itemsMatch(helmet, helmetItem))
|
||||
if (!itemsMatch(_helmet, helmetItem))
|
||||
{
|
||||
helmet = parseItem(helmetItem);
|
||||
_helmet = parseItem(helmetItem);
|
||||
}
|
||||
|
||||
return helmet;
|
||||
return _helmet;
|
||||
}
|
||||
|
||||
public CustomItem getChestplate()
|
||||
{
|
||||
ItemStack chestplateItem = getPlayer().getInventory().getChestplate();
|
||||
|
||||
if (!itemsMatch(chestplate, chestplateItem))
|
||||
if (!itemsMatch(_chestplate, chestplateItem))
|
||||
{
|
||||
chestplate = parseItem(chestplateItem);
|
||||
_chestplate = parseItem(chestplateItem);
|
||||
}
|
||||
|
||||
return chestplate;
|
||||
return _chestplate;
|
||||
}
|
||||
|
||||
public CustomItem getLeggings()
|
||||
{
|
||||
ItemStack leggingsItem = getPlayer().getInventory().getLeggings();
|
||||
|
||||
if (!itemsMatch(leggings, leggingsItem))
|
||||
if (!itemsMatch(_leggings, leggingsItem))
|
||||
{
|
||||
leggings = parseItem(leggingsItem);
|
||||
_leggings = parseItem(leggingsItem);
|
||||
}
|
||||
|
||||
return leggings;
|
||||
return _leggings;
|
||||
}
|
||||
|
||||
public CustomItem getBoots()
|
||||
{
|
||||
ItemStack bootsItem = getPlayer().getInventory().getBoots();
|
||||
|
||||
if (!itemsMatch(boots, bootsItem))
|
||||
if (!itemsMatch(_boots, bootsItem))
|
||||
{
|
||||
boots = parseItem(bootsItem);
|
||||
_boots = parseItem(bootsItem);
|
||||
}
|
||||
|
||||
return boots;
|
||||
return _boots;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,9 +3,9 @@ package mineplex.game.clans.items;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.game.clans.items.attributes.ItemAttribute;
|
||||
import mineplex.game.clans.items.legendaries.LegendaryItem;
|
||||
import mineplex.game.clans.items.rares.RareItem;
|
||||
|
||||
/**
|
||||
* Quick little guide on how to use this thing:
|
||||
@ -75,6 +75,28 @@ public class RareItemFactory
|
||||
return this;
|
||||
}
|
||||
|
||||
public RareItemFactory setRare(Class<? extends RareItem> rare)
|
||||
{
|
||||
if (_itemType.equals(ItemType.RARE))
|
||||
{
|
||||
try
|
||||
{
|
||||
_item = rare.newInstance();
|
||||
_material = _item.getMaterial();
|
||||
}
|
||||
catch (InstantiationException | IllegalAccessException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RuntimeException("Unexpected call to setRare(RareType)");
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public RareItemFactory setSuperPrefix(Class<? extends ItemAttribute> superPrefix)
|
||||
{
|
||||
_superPrefix = superPrefix;
|
||||
|
@ -1,30 +1,60 @@
|
||||
package mineplex.game.clans.items.legendaries;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.RGBData;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilCollections;
|
||||
import mineplex.core.common.util.UtilColor;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.common.util.UtilTrig;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
|
||||
public class EnergyCrossbow extends LegendaryItem
|
||||
{
|
||||
private static final long COOLDOWN = 30000;
|
||||
|
||||
private long _lastFire = System.currentTimeMillis();
|
||||
private long _interactWait;
|
||||
|
||||
private static List<Vector> _preCalculatedSphere;
|
||||
|
||||
{
|
||||
ClansManager.getInstance().runAsync(() ->
|
||||
_preCalculatedSphere = UtilTrig.GetSpherePoints(new Vector(0, 0, 0), 1.8d, 1.8d, true, .4d)
|
||||
);
|
||||
}
|
||||
|
||||
public EnergyCrossbow()
|
||||
{
|
||||
super("Energy Crossbow", UtilText.splitLinesToArray(new String[] {
|
||||
C.cWhite + "This deadly tooth was stolen from a nest of reptillian beasts long ago. "
|
||||
+ "Legends say that the holder is granted the underwater agility of an Alligator",
|
||||
" ",
|
||||
"#" + C.cYellow + "Right-Click" + C.cWhite + " to use" + C.cGreen + " Swim"
|
||||
}, LineFormat.LORE), Material.RECORD_4);
|
||||
C.cWhite + "Legend says "
|
||||
+ " ",
|
||||
"#" + C.cYellow + "Right-Click" + C.cWhite + " to fire Crossbow."
|
||||
}, LineFormat.LORE), Material.RECORD_6);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -32,22 +62,126 @@ public class EnergyCrossbow extends LegendaryItem
|
||||
{
|
||||
if ((System.currentTimeMillis() - _lastBlock) < 98 && (System.currentTimeMillis() - _interactWait) >= 98)
|
||||
{
|
||||
if ((System.currentTimeMillis() - _lastFire) >= COOLDOWN)
|
||||
if (Recharge.Instance.use(wielder, "Crossbow", 6500, true, true))
|
||||
{
|
||||
fire(wielder);
|
||||
|
||||
_interactWait = System.currentTimeMillis();
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(wielder, F.main("Clans", "Energy Crossbow is cooling down!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fire(Player wielder)
|
||||
private void fire(final Player player)
|
||||
{
|
||||
final Arrow arrow = wielder.shootArrow();
|
||||
UtilServer.RegisterEvents(new Listener() {
|
||||
private Location _lastLoc;
|
||||
|
||||
private Arrow _arrow;
|
||||
private Player _player;
|
||||
|
||||
private RGBData[] colors = { UtilColor.RgbLightRed, UtilColor.RgbLightRed.Lighten(), UtilColor.RgbLightRed.Darken() };
|
||||
|
||||
{
|
||||
_player = player;
|
||||
|
||||
Arrow arrow = _player.shootArrow();
|
||||
|
||||
arrow.setVelocity(arrow.getVelocity().multiply(3.4444444444444));
|
||||
|
||||
arrow.setShooter(_player);
|
||||
|
||||
_arrow = arrow;
|
||||
|
||||
_player.playSound(_arrow.getLocation(), Sound.BAT_TAKEOFF, 0.1f, 2.f);
|
||||
_player.playSound(_arrow.getLocation(), Sound.ZOMBIE_WOODBREAK, 0.5f, .5f);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (_arrow == null || _arrow.isDead())
|
||||
{
|
||||
HandlerList.unregisterAll(this);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (_lastLoc != null)
|
||||
{
|
||||
Location lastLoc = _lastLoc.clone();
|
||||
|
||||
while (UtilMath.offset(lastLoc, _arrow.getLocation()) > 0.1)
|
||||
{
|
||||
lastLoc.add(UtilAlg.getTrajectory(lastLoc, _arrow.getLocation()).multiply(0.1));
|
||||
|
||||
UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, lastLoc, UtilCollections.random(colors).ToVector(), 1f, 0, ViewDist.MAX);
|
||||
}
|
||||
}
|
||||
|
||||
_lastLoc = _arrow.getLocation();
|
||||
}
|
||||
|
||||
private void hit()
|
||||
{
|
||||
HandlerList.unregisterAll(this);
|
||||
|
||||
for (Vector vector : _preCalculatedSphere)
|
||||
{
|
||||
UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, _arrow.getLocation().add(vector), UtilColor.RgbLightRed.ToVector(), 1.0f, 0, ViewDist.MAX);
|
||||
}
|
||||
|
||||
HashMap<LivingEntity, Double> targets = UtilEnt.getInRadius(_arrow.getLocation(), 3.d);
|
||||
for (LivingEntity entity : targets.keySet())
|
||||
{
|
||||
if (entity.equals(_arrow.getShooter()))
|
||||
continue;
|
||||
|
||||
ClansManager.getInstance().getDamageManager().NewDamageEvent(entity, _player, _arrow,
|
||||
DamageCause.CUSTOM, 8, true, true, false,
|
||||
_player.getName(), "Energy Crossbow");
|
||||
}
|
||||
|
||||
_arrow.remove();
|
||||
_arrow = null;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void projectileHit(ProjectileHitEvent event)
|
||||
{
|
||||
if (!event.getEntity().equals(_arrow))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClansManager.getInstance().runSyncLater(this::hit, 1);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void entityHurt(EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (!event.getDamager().equals(_arrow))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getEntity().equals(_arrow.getShooter()) || !(event.getEntity() instanceof LivingEntity))
|
||||
{
|
||||
_arrow.remove();
|
||||
_arrow = null;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
ClansManager.getInstance().getDamageManager().NewDamageEvent((LivingEntity) event.getEntity(), _player, _arrow,
|
||||
DamageCause.CUSTOM, 1.5d, true, true, false,
|
||||
_player.getName(), "Energy Crossbow");
|
||||
|
||||
hit();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
_lastFire = System.currentTimeMillis();
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
public class HyperAxe extends LegendaryItem
|
||||
{
|
||||
public static final long ATTACK_RATE_DURATION = 200;
|
||||
public static final long ATTACK_RATE_DURATION = 1000 / 17;
|
||||
private static ValueDistribution amountGen = generateDistribution(0, 3); // [1, 4] speed amount
|
||||
private static ValueDistribution durationGen = generateDistribution(80, 320); // [4, 16] seconds speed duration
|
||||
|
||||
@ -20,11 +20,10 @@ public class HyperAxe extends LegendaryItem
|
||||
private int _speedDuration;
|
||||
|
||||
private long _lastAttack;
|
||||
public long timeSinceLastAttack() { return System.currentTimeMillis() - _lastAttack; }
|
||||
|
||||
public HyperAxe()
|
||||
{
|
||||
super("Hyper Axe", new String[]{
|
||||
super("Hyper Axe", new String[] {
|
||||
C.cWhite + "Of all the weapons known to man,",
|
||||
C.cWhite + "none is more prevalent than the",
|
||||
C.cWhite + "Hyper Axe. Infused with rabbit's",
|
||||
@ -43,10 +42,9 @@ public class HyperAxe extends LegendaryItem
|
||||
@Override
|
||||
public void update(Player wielder)
|
||||
{
|
||||
if (isHoldingRightClick() && canBuff())
|
||||
if (isHoldingRightClick() && canBuff(wielder))
|
||||
{
|
||||
buffPlayer(wielder);
|
||||
_lastAttack = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,9 +54,9 @@ public class HyperAxe extends LegendaryItem
|
||||
if (timeSinceLastAttack() >= ATTACK_RATE_DURATION)
|
||||
{
|
||||
event.SetIgnoreRate(true);
|
||||
// log("Ignoring rate!");
|
||||
|
||||
event.AddMod("Hyper Axe", 1);
|
||||
event.AddMod("Hyper Axe", 9);
|
||||
_lastAttack = System.currentTimeMillis();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -66,18 +64,22 @@ public class HyperAxe extends LegendaryItem
|
||||
}
|
||||
}
|
||||
|
||||
public long timeSinceLastAttack()
|
||||
{
|
||||
return System.currentTimeMillis() - _lastAttack;
|
||||
}
|
||||
|
||||
private void buffPlayer(Player wielder)
|
||||
{
|
||||
if (!Recharge.Instance.use(wielder, "Hyper Rush", 16000, true, true))
|
||||
return;
|
||||
Recharge.Instance.use(wielder, "Hyper Rush", 16000, true, false);
|
||||
|
||||
// Give player speed buff
|
||||
wielder.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, _speedDuration, _speedAmount));
|
||||
log("Buffing");
|
||||
}
|
||||
|
||||
private boolean canBuff()
|
||||
private boolean canBuff(Player wielder)
|
||||
{
|
||||
return true; // TODO: Implement cooldown? (None specified in docs, sounds OP)
|
||||
return Recharge.Instance.usable(wielder, "Hyper Rush", true);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,209 @@
|
||||
package mineplex.game.clans.items.legendaries;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.RGBData;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilCollections;
|
||||
import mineplex.core.common.util.UtilColor;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilShapes;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
|
||||
public class MeridianScepter extends LegendaryItem
|
||||
{
|
||||
private long _lastFire = System.currentTimeMillis();
|
||||
private long _interactWait;
|
||||
|
||||
private RGBData[] colors = { UtilColor.RgbPurple, UtilColor.RgbPurple.Lighten(), UtilColor.RgbPurple.Darken() };
|
||||
|
||||
public MeridianScepter()
|
||||
{
|
||||
super("Meridian Scepter", UtilText.splitLinesToArray(new String[] {
|
||||
C.cWhite + "Legend says "
|
||||
+ " ",
|
||||
"#" + C.cYellow + "Right-Click" + C.cWhite + " to use Scepter."
|
||||
}, LineFormat.LORE), Material.RECORD_7);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Player wielder)
|
||||
{
|
||||
if ((System.currentTimeMillis() - _lastBlock) < 98 && (System.currentTimeMillis() - _interactWait) >= 98)
|
||||
{
|
||||
if (Recharge.Instance.use(wielder, "Meridian Scepter", 4000, true, true))
|
||||
{
|
||||
fire(wielder);
|
||||
|
||||
_interactWait = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fire(final Player player)
|
||||
{
|
||||
final Location projectile = player.getEyeLocation();
|
||||
final Location origin = player.getEyeLocation();
|
||||
final Vector direction = player.getEyeLocation().getDirection().normalize().multiply(0.25);
|
||||
final int maxRange = 50;
|
||||
final int maxDings = maxRange * 4;
|
||||
final int damage = 6;
|
||||
|
||||
UtilServer.repeat(new BukkitRunnable()
|
||||
{
|
||||
private int dingsDone;
|
||||
private Location previousLocation = projectile;
|
||||
|
||||
private void burst()
|
||||
{
|
||||
for (Entity cur : projectile.getWorld().getEntities())
|
||||
{
|
||||
if (cur == player || !(cur instanceof LivingEntity) || (cur instanceof Player && UtilPlayer.isSpectator(cur)))
|
||||
continue;
|
||||
|
||||
LivingEntity entity = (LivingEntity) cur;
|
||||
|
||||
Location eLoc = entity.getLocation();
|
||||
|
||||
// If they are less than 0.5 blocks away
|
||||
if (eLoc.clone().add(0, projectile.getY() - eLoc.getY(), 0).distance(projectile) <= 0.7)
|
||||
{
|
||||
// If it is in their body height
|
||||
if (Math.abs((eLoc.getY() + (entity.getEyeHeight() / 1.5)) - projectile.getY()) <= entity
|
||||
.getEyeHeight() / 2)
|
||||
{
|
||||
if (entity != player)
|
||||
{
|
||||
ClansManager.getInstance().getDamageManager().NewDamageEvent(entity, player, null,
|
||||
DamageCause.CUSTOM, damage, true, true, false,
|
||||
player.getName(), "Meridian Scepter");
|
||||
|
||||
UtilPlayer.message(entity, F.main("Clans", F.elem(entity.getName()) + " hit you with a " + F.elem("Meridian Scepter") + C.mBody + "."));
|
||||
UtilPlayer.message(player, F.main("Clans", "You hit " + F.elem(player.getName()) + " with your " + F.elem("Meridian Scepter") + C.mBody + "."));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
playParticle(projectile, previousLocation);
|
||||
|
||||
cancel();
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
if (dingsDone >= maxDings || !player.isOnline())
|
||||
{
|
||||
burst();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
Player closestPlayer = null;
|
||||
double dist = 0;
|
||||
|
||||
for (Player closest : UtilServer.getPlayers())
|
||||
{
|
||||
if (!closest.getWorld().equals(projectile.getWorld()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Location loc = closest.getLocation();
|
||||
|
||||
if (closest != player)
|
||||
{
|
||||
double dist1 = loc.distance(origin);
|
||||
if (dist1 < maxRange + 10)
|
||||
{
|
||||
double dist2 = projectile.distance(loc);
|
||||
if (closestPlayer == null || dist2 < dist)
|
||||
{
|
||||
double dist3 = projectile.clone().add(direction).distance(loc);
|
||||
|
||||
if (dist3 < dist2)
|
||||
{
|
||||
closestPlayer = closest;
|
||||
dist = dist2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (closestPlayer != null)
|
||||
{
|
||||
Vector newDirection = closestPlayer.getLocation().add(0, 1, 0).toVector()
|
||||
.subtract(projectile.toVector());
|
||||
|
||||
direction.add(newDirection.normalize().multiply(0.01)).normalize().multiply(0.25);
|
||||
}
|
||||
|
||||
projectile.add(direction);
|
||||
|
||||
for (Entity cur : projectile.getWorld().getEntities())
|
||||
{
|
||||
if (cur == player || !(cur instanceof LivingEntity)
|
||||
|| (cur instanceof Player && UtilPlayer.isSpectator(cur)))
|
||||
continue;
|
||||
|
||||
LivingEntity ent = (LivingEntity) cur;
|
||||
|
||||
Location eLoc = ent.getLocation();
|
||||
|
||||
// If they are less than 0.5 blocks away
|
||||
if (eLoc.clone().add(0, projectile.getY() - eLoc.getY(), 0).distance(projectile) <= 0.7)
|
||||
{
|
||||
// If it is in their body height
|
||||
if (Math.abs((eLoc.getY() + (ent.getEyeHeight() / 1.5)) - projectile.getY()) <= ent.getEyeHeight() / 2)
|
||||
{
|
||||
burst();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (UtilBlock.solid(projectile.getBlock()))
|
||||
{
|
||||
burst();
|
||||
return;
|
||||
}
|
||||
|
||||
playParticle(projectile, previousLocation);
|
||||
previousLocation = projectile.clone();
|
||||
|
||||
dingsDone++;
|
||||
}
|
||||
|
||||
projectile.getWorld().playSound(projectile, Sound.BLAZE_BREATH, 0.2F, 1f);
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
private void playParticle(Location start, Location end)
|
||||
{
|
||||
for (Location loc : UtilShapes.getLinesDistancedPoints(start, end, 0.06))
|
||||
{
|
||||
UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, loc, UtilCollections.random(colors).ToVector(), 1f, 0, ViewDist.LONG);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package mineplex.game.clans.items.rares;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
|
||||
public class Crossbow extends RareItem
|
||||
{
|
||||
private static final Material LOADED_TYPE = Material.COMMAND_MINECART;
|
||||
private static final Material UNLOADED_TYPE = Material.RECORD_6;
|
||||
|
||||
private long _lastFire = System.currentTimeMillis();
|
||||
private long _interactWait;
|
||||
|
||||
public Crossbow()
|
||||
{
|
||||
super("Crossbow", UtilText.splitLinesToArray(new String[] {
|
||||
"#" + C.cYellow + "Right-Click" + C.cWhite + " to fire Crossbow."
|
||||
}, LineFormat.LORE), UNLOADED_TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Player wielder)
|
||||
{
|
||||
if (UtilInv.contains(wielder, Material.ARROW, (byte) 0, 1))
|
||||
{
|
||||
wielder.getItemInHand().setType(LOADED_TYPE);
|
||||
}
|
||||
else
|
||||
{
|
||||
wielder.getItemInHand().setType(UNLOADED_TYPE);
|
||||
}
|
||||
|
||||
if ((System.currentTimeMillis() - _lastBlock) < 98 && (System.currentTimeMillis() - _interactWait) >= 98)
|
||||
{
|
||||
if (UtilInv.remove(wielder, Material.ARROW, (byte) 0, 1))
|
||||
{
|
||||
if (Recharge.Instance.use(wielder, "Crossbow", 4000, true, true))
|
||||
{
|
||||
fire(wielder);
|
||||
|
||||
_interactWait = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fire(final Player player)
|
||||
{
|
||||
Arrow arrow = player.shootArrow();
|
||||
|
||||
arrow.setShooter(player);
|
||||
|
||||
_lastFire = System.currentTimeMillis();
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package mineplex.game.clans.items.rares;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import mineplex.game.clans.items.CustomItem;
|
||||
import mineplex.game.clans.items.generation.ValueDistribution;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
public class RareItem extends CustomItem
|
||||
{
|
||||
public final long BLOCK_COOLDOWN = 200l; // Right clicking activates right click for 200ms
|
||||
|
||||
protected long _lastBlock; // Timestamp of last block from wielder
|
||||
public long timeSinceLastBlock() { return System.currentTimeMillis() - _lastBlock; }
|
||||
|
||||
public RareItem(String name, String[] description, Material material)
|
||||
{
|
||||
super(name, description, material);
|
||||
|
||||
_lastBlock = 0l;
|
||||
}
|
||||
|
||||
public void update(Player wielder)
|
||||
{
|
||||
// Leave implementation to potential subtypes
|
||||
}
|
||||
|
||||
public void preUpdate(Player wielder)
|
||||
{
|
||||
}
|
||||
|
||||
public void onAttack(CustomDamageEvent event, Player wielder)
|
||||
{
|
||||
// Leave implementation to potential subtypes
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttack(CustomDamageEvent event)
|
||||
{
|
||||
if (event.GetDamagerPlayer(true) != null)
|
||||
{
|
||||
onAttack(event, event.GetDamagerPlayer(true));
|
||||
}
|
||||
|
||||
super.onAttack(event);
|
||||
}
|
||||
|
||||
public void onInteract(PlayerInteractEvent event)
|
||||
{
|
||||
Action action = event.getAction();
|
||||
|
||||
if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
_lastBlock = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
super.onInteract(event);
|
||||
}
|
||||
|
||||
public boolean isHoldingRightClick()
|
||||
{
|
||||
return timeSinceLastBlock() <= BLOCK_COOLDOWN;
|
||||
}
|
||||
|
||||
protected void log(String message)
|
||||
{
|
||||
System.out.println("[Custom Item - " + _displayName + "] " + message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param minValue - the minimum value for attribute value range
|
||||
* @param maxValue - the maximum value for attribute value range
|
||||
* @return newly instantiated {@link ValueDistribution} for attribute values in range [{@code minValue}. {@code maxValue}].
|
||||
*/
|
||||
public static ValueDistribution generateDistribution(double minValue, double maxValue)
|
||||
{
|
||||
return new ValueDistribution(minValue, maxValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a {@link PotionEffect} to {@code player} with specified {@code type}, {@code amplifier} (power) and
|
||||
* {@code tickDuration} of the effect.
|
||||
* @param player - the player to receive the potion effect
|
||||
* @param type - the type of potion to apply
|
||||
* @param tickDuration - the duration (in ticks) to apply the potion for
|
||||
* @param amplifier - the amplifier (level/power, zero-based) of the potion effect
|
||||
*/
|
||||
public static void grantPotionEffect(Player player, PotionEffectType type, int tickDuration, int amplifier)
|
||||
{
|
||||
player.removePotionEffect(type);
|
||||
player.addPotionEffect(new PotionEffect(type, amplifier, tickDuration));
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package mineplex.game.clans.items.rares;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.RGBData;
|
||||
import mineplex.core.common.util.UtilCollections;
|
||||
import mineplex.core.common.util.UtilColor;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilShapes;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.items.PlayerGear;
|
||||
|
||||
public class RunedPickaxe extends RareItem
|
||||
{
|
||||
private long _lastFire = System.currentTimeMillis();
|
||||
private long _interactWait;
|
||||
|
||||
private long _instamineEnabled;
|
||||
|
||||
private RGBData[] colors = { UtilColor.RgbLightBlue, UtilColor.RgbLightBlue.Lighten(), UtilColor.RgbLightBlue.Darken() };
|
||||
|
||||
public RunedPickaxe()
|
||||
{
|
||||
super("Runed Pickaxe", UtilText.splitLinesToArray(new String[] {
|
||||
"#" + C.cYellow + "Right-Click" + C.cWhite + " to use " + F.elem("Instant mine") + "."
|
||||
}, LineFormat.LORE), Material.RECORD_8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Player wielder)
|
||||
{
|
||||
if ((System.currentTimeMillis() - _lastBlock) < 98 && (System.currentTimeMillis() - _interactWait) >= 98)
|
||||
{
|
||||
if (Recharge.Instance.use(wielder, "Instant Mine", 30000, true, true))
|
||||
{
|
||||
fire(wielder);
|
||||
|
||||
_interactWait = System.currentTimeMillis();
|
||||
|
||||
_instamineEnabled = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void blockDamage(BlockDamageEvent event)
|
||||
{
|
||||
PlayerGear gear = ClansManager.getInstance().getGearManager().getPlayerGear(event.getPlayer());
|
||||
|
||||
if (gear.getWeapon() == this && !UtilTime.elapsed(_instamineEnabled, 12000))
|
||||
{
|
||||
event.setInstaBreak(true);
|
||||
|
||||
event.getBlock().getWorld().playEffect(event.getBlock().getLocation(), Effect.STEP_SOUND, event.getBlock().getType(), 10);
|
||||
|
||||
event.getPlayer().playSound(event.getBlock().getLocation(), Sound.LAVA_POP, 1.f, 1.f);
|
||||
}
|
||||
}
|
||||
|
||||
private void fire(final Player player)
|
||||
{
|
||||
}
|
||||
|
||||
private void playParticle(Location start, Location end)
|
||||
{
|
||||
for (Location loc : UtilShapes.getLinesDistancedPoints(start, end, 0.06))
|
||||
{
|
||||
UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, loc, UtilCollections.random(colors).ToVector(), 1f, 0, ViewDist.LONG);
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
@ -12,6 +14,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilCollections;
|
||||
import mineplex.core.common.util.UtilUI;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
@ -40,13 +43,16 @@ import mineplex.game.clans.items.attributes.weapon.HasteAttribute;
|
||||
import mineplex.game.clans.items.attributes.weapon.JaggedAttribute;
|
||||
import mineplex.game.clans.items.attributes.weapon.SharpAttribute;
|
||||
import mineplex.game.clans.items.legendaries.AlligatorsTooth;
|
||||
import mineplex.game.clans.items.legendaries.EnergyCrossbow;
|
||||
import mineplex.game.clans.items.legendaries.GiantsBroadsword;
|
||||
import mineplex.game.clans.items.legendaries.HyperAxe;
|
||||
import mineplex.game.clans.items.legendaries.LegendaryItem;
|
||||
import mineplex.game.clans.items.legendaries.MagneticMaul;
|
||||
import mineplex.game.clans.items.legendaries.MeridianScepter;
|
||||
import mineplex.game.clans.items.legendaries.WindBlade;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
import mineplex.game.clans.items.rares.Crossbow;
|
||||
import mineplex.game.clans.items.rares.RareItem;
|
||||
import mineplex.game.clans.items.rares.RunedPickaxe;
|
||||
|
||||
public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
{
|
||||
@ -74,6 +80,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
private List<Class<? extends ItemAttribute>> _bowSuffixes;
|
||||
|
||||
private List<Class<? extends LegendaryItem>> _legendaryItems;
|
||||
private List<Class<? extends RareItem>> _rareItems;
|
||||
|
||||
private List<Material> _weaponTypes;
|
||||
private List<Material> _armorTypes;
|
||||
@ -98,7 +105,9 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
}
|
||||
};
|
||||
|
||||
_legendaryItems = Arrays.<Class<? extends LegendaryItem>> asList(AlligatorsTooth.class, WindBlade.class, GiantsBroadsword.class, HyperAxe.class, MagneticMaul.class);
|
||||
_legendaryItems = Arrays.<Class<? extends LegendaryItem>> asList(MeridianScepter.class, EnergyCrossbow.class, AlligatorsTooth.class, WindBlade.class, GiantsBroadsword.class, HyperAxe.class, MagneticMaul.class);
|
||||
|
||||
_rareItems = Arrays.<Class<? extends RareItem>> asList(Crossbow.class, RunedPickaxe.class);
|
||||
|
||||
_armorSuperPrefixes = Arrays.<Class<? extends ItemAttribute>> asList(LavaAttribute.class);
|
||||
_armorPrefixes = Arrays.<Class<? extends ItemAttribute>> asList(PaddedAttribute.class, ReinforcedAttribute.class, SlantedAttribute.class);
|
||||
@ -141,7 +150,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
{
|
||||
Triple<Boolean, String, Material> stage2 = doStageTwo();
|
||||
|
||||
if (stage2.getLeft())
|
||||
if (stage2.getLeft().booleanValue())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -156,7 +165,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
{
|
||||
Triple<Boolean, String, Material> stage3 = doStageThree();
|
||||
|
||||
if (stage3.getLeft())
|
||||
if (stage3.getLeft().booleanValue())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -214,8 +223,10 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
{
|
||||
String stageTitle;
|
||||
|
||||
int[] indices = UtilUI.getIndicesFor(4, 1, 1);
|
||||
|
||||
stageTitle = "1. Select Item Type";
|
||||
addButton(9 + 1, Material.GOLD_RECORD, 0, C.cGold + "Legendary", new IButton()
|
||||
addButton(indices[0], Material.GOLD_RECORD, 0, C.cGold + "Legendary", new IButton()
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
@ -225,17 +236,17 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
}
|
||||
}, _factory != null && ItemType.LEGENDARY.equals(_factory.getItemType()), new String[] { _factory != null && ItemType.LEGENDARY.equals(_factory.getItemType()) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
|
||||
addButton(9 + 3, Material.DIAMOND_AXE, 0, C.cDAqua + "Weapon", new IButton()
|
||||
addButton(indices[1], Material.RECORD_8, 0, C.cAqua + "Rare", new IButton()
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_factory = RareItemFactory.begin(ItemType.WEAPON);
|
||||
_factory = RareItemFactory.begin(ItemType.RARE);
|
||||
performNext();
|
||||
buildPage();
|
||||
}
|
||||
}, _factory != null && ItemType.WEAPON.equals(_factory.getItemType()), new String[] { _factory != null && ItemType.WEAPON.equals(_factory.getItemType()) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
}, _factory != null && ItemType.RARE.equals(_factory.getItemType()), new String[] { _factory != null && ItemType.RARE.equals(_factory.getItemType()) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
|
||||
addButton(9 + 5, Material.DIAMOND_CHESTPLATE, 0, C.cDGreen + "Armor", new IButton()
|
||||
addButton(indices[2], Material.DIAMOND_CHESTPLATE, 0, C.cDGreen + "Armor", new IButton()
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
@ -245,7 +256,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
}
|
||||
}, _factory != null && ItemType.ARMOR.equals(_factory.getItemType()), new String[] { _factory != null && ItemType.ARMOR.equals(_factory.getItemType()) ? C.cGreen + "Selected" : C.cRed + "Not Selected" });
|
||||
|
||||
addButton(9 + 7, Material.BOW, 0, C.cDGreen + "Bow", new IButton()
|
||||
addButton(indices[3], Material.BOW, 0, C.cDGreen + "Bow", new IButton()
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
@ -262,15 +273,47 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
{
|
||||
String stageTitle = "Fatal Error";
|
||||
Material stageMaterial = null;
|
||||
boolean _return = false;
|
||||
boolean $return = false;
|
||||
|
||||
if (_factory == null || _factory.getItemType() == null)
|
||||
{
|
||||
performBack();
|
||||
return Triple.of(true, stageTitle, stageMaterial);
|
||||
return Triple.of(Boolean.valueOf(true), stageTitle, stageMaterial);
|
||||
}
|
||||
|
||||
if (_factory.getItemType().equals(ItemType.LEGENDARY))
|
||||
if (_factory.getItemType().equals(ItemType.RARE))
|
||||
{
|
||||
stageTitle = "2. Select Rare Item";
|
||||
stageMaterial = _factory.getMaterial() == null ? stageMaterial : _factory.getMaterial();
|
||||
|
||||
int[] indices = UtilUI.getIndicesFor(_rareItems.size(), 1);
|
||||
|
||||
int index = 0;
|
||||
for (final Class<? extends RareItem> rare : _rareItems)
|
||||
{
|
||||
final RareItem item = rare.newInstance();
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
|
||||
lore.addAll(UtilCollections.toList(item.getDescription()));
|
||||
|
||||
lore.add(" ");
|
||||
lore.add(item.getDisplayName().equals(_factory.getWrapper() == null ? null : _factory.getWrapper().getDisplayName()) ? C.cGreen + "Selected" : C.cRed + "Not Selected");
|
||||
|
||||
addButton(indices[index], item.toItemStack().getType(), 0, C.cAqua + item.getDisplayName(), new IButton()
|
||||
{
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_factory.setRare(rare);
|
||||
performNext();
|
||||
buildPage();
|
||||
}
|
||||
}, item.getDisplayName().equals(_factory.getWrapper() == null ? null : _factory.getWrapper().getDisplayName()), lore.toArray(new String[lore.size()]));
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
else if (_factory.getItemType().equals(ItemType.LEGENDARY))
|
||||
{
|
||||
stageTitle = "2. Select Legendary Item";
|
||||
stageMaterial = _factory.getMaterial() == null ? stageMaterial : _factory.getMaterial();
|
||||
@ -369,13 +412,13 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
_factory.setType(Material.BOW);
|
||||
_stage = 2;
|
||||
buildPage();
|
||||
_return = true;
|
||||
$return = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Triple.of(_return, stageTitle, stageMaterial);
|
||||
return Triple.of(Boolean.valueOf($return), stageTitle, stageMaterial);
|
||||
}
|
||||
|
||||
private Triple<Boolean, String, Material> doStageThree() throws InstantiationException, IllegalAccessException
|
||||
@ -385,12 +428,12 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
if (_factory.getMaterial() == null)
|
||||
{
|
||||
performBack();
|
||||
return Triple.of(true, null, null);
|
||||
return Triple.of(Boolean.valueOf(true), null, null);
|
||||
}
|
||||
|
||||
Material stageMaterial = _factory.getMaterial();
|
||||
|
||||
if (_factory.getItemType().equals(ItemType.LEGENDARY))
|
||||
if (_factory.getItemType().equals(ItemType.LEGENDARY) || _factory.getItemType().equals(ItemType.RARE))
|
||||
{
|
||||
finish();
|
||||
stageTitle = "The End";
|
||||
@ -481,7 +524,7 @@ public class GearPage extends ShopPageBase<GearManager, GearShop>
|
||||
}
|
||||
}
|
||||
|
||||
return Triple.of(false, stageTitle, stageMaterial);
|
||||
return Triple.of(Boolean.valueOf(false), stageTitle, stageMaterial);
|
||||
}
|
||||
|
||||
private Pair<String, Material> doStageFour() throws InstantiationException, IllegalAccessException
|
||||
|
@ -39,10 +39,10 @@ import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.common.weight.WeightSet;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.core.common.weight.WeightSet;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||
import mineplex.minecraft.game.classcombat.item.event.WebTossEvent;
|
||||
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||
@ -537,4 +537,9 @@ public class Spawn extends MiniPlugin
|
||||
_songWestLast = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
public ClansManager getClansManager()
|
||||
{
|
||||
return _clansManager;
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,9 @@ package mineplex.minecraft.game.classcombat.Skill.Assassin;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -15,16 +13,16 @@ import org.bukkit.event.block.Action;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
|
||||
import mineplex.minecraft.game.classcombat.Skill.SkillActive;
|
||||
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillTeleportEvent;
|
||||
@ -157,16 +155,19 @@ public class Flash extends SkillActive
|
||||
|
||||
if(aboveTargetData <= 7) aboveTargetSlabIsBottom = true;
|
||||
}
|
||||
|
||||
// Doors
|
||||
if (UtilItem.is(newTarget.getBlock(), UtilItem.ItemCategory.DOOR))
|
||||
|
||||
if ((!newTargetSlabIsBottom &&
|
||||
!UtilItem.isBoundless(aboveTarget.getBlock().getType())
|
||||
|| (!aboveTargetSlabIsBottom)
|
||||
&& !UtilItem.isBoundless(aboveTarget.getBlock().getType())))
|
||||
break;
|
||||
|
||||
if ((!newTargetSlabIsBottom && UtilBlock.fullSolid(newTarget.getBlock())) || (!aboveTargetSlabIsBottom && UtilBlock.fullSolid(aboveTarget.getBlock())))
|
||||
if (!UtilItem.isBoundless(newTarget.getBlock().getType()) && UtilItem.isBoundless(aboveTarget.getBlock().getType())
|
||||
|| !UtilItem.isBoundless(aboveTarget.getBlock().getType()) && !UtilItem.isBoundless(newTarget.getBlock().getType()))
|
||||
break;
|
||||
|
||||
|
||||
//Progress Forwards
|
||||
curRange += 0.2;
|
||||
curRange += 0.1;
|
||||
|
||||
//Smoke Trail
|
||||
UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, newTarget.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1,
|
||||
@ -180,7 +181,12 @@ public class Flash extends SkillActive
|
||||
|
||||
//Destination
|
||||
Location loc = getDestination(player, curRange);
|
||||
|
||||
|
||||
if (UtilItem.isBoundless(UtilAlg.moveForward(loc, 0.15d, player.getLocation().getYaw(), false).getBlock().getType()))
|
||||
{
|
||||
loc = UtilAlg.moveForward(loc, 0.25d, player.getLocation().getYaw(), true);
|
||||
}
|
||||
|
||||
if (curRange > 0)
|
||||
player.teleport(loc);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user