Merge remote-tracking branch 'refs/remotes/origin/develop' into update/ssm

This commit is contained in:
Sam 2016-09-22 17:11:25 +01:00
commit f6acedba5f
100 changed files with 7715 additions and 2567 deletions

View File

@ -2,7 +2,24 @@ package mineplex.core.common;
public enum MinecraftVersion
{
ALL,
Version1_9,
Version1_8
ALL("Any"),
Version1_9("1.9"),
Version1_8("1.8"),
;
private final String _friendlyName;
MinecraftVersion(String friendlyName)
{
_friendlyName = friendlyName;
}
public String friendlyName()
{
return _friendlyName;
}
public static MinecraftVersion fromInt(int version)
{
return version <= 47 ? Version1_8 : Version1_9;
}
}

View File

@ -0,0 +1,55 @@
package mineplex.core.common.util;
import java.util.function.Predicate;
public class UtilLambda
{
/**
* This will return a {@link Predicate} which will return true <b>if and only if</b> all of the supplied Predicates
* return true
* @param predicates The Predicates to test against
* @return The resulting criterion
*/
@SafeVarargs
public static <T> Predicate<T> and(Predicate<T>... predicates)
{
return t ->
{
for (Predicate<T> predicate : predicates)
{
if (!predicate.test(t))
{
return false;
}
}
return true;
};
}
/**
* This will return a {@link Predicate} which will return true <b>if and only if</b> one of the the supplied Predicates
* return true
* @param predicates The Predicates to test against
* @return The resulting criterion
*/
@SafeVarargs
public static <T> Predicate<T> or(Predicate<T>... predicates)
{
return t ->
{
for (Predicate<T> predicate : predicates)
{
if (predicate.test(t))
{
return true;
}
}
return false;
};
}
public static <T> Predicate<T> not(Predicate<T> predicate)
{
return t -> !predicate.test(t);
}
}

View File

@ -16,6 +16,7 @@ import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory;
@ -28,17 +29,7 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.util.BlockIterator;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
import java.util.*;
public class UtilPlayer
{
@ -962,6 +953,51 @@ public class UtilPlayer
ALLOWED_COMMANDS.remove(player.getUniqueId());
}
/**
* Check if the player is at least the specified amount of blocks in the air
* while provided block types are ignored.
*
* @see #isInAir(Player, int, Set)
*/
public static boolean isInAir(Player player, int minAir, Material... exclude)
{
EnumSet<Material> excludeSet = EnumSet.noneOf(Material.class);
if (exclude != null) excludeSet.addAll(Arrays.asList(exclude));
return isInAir(player, minAir, excludeSet);
}
/**
* Check if the player is at least the specified amount of blocks in the air
* while provided block types are ignored.
*
* @param player The Player to check
* @param minAir The min amount of Blocks to count as in the air
* @param exclude that are being ignored and count as Air
*
* @return if the Player is in the air
*/
public static boolean isInAir(Player player, int minAir, Set<Material> exclude)
{
Block block = player.getLocation().getBlock();
int i = 0;
while (i < minAir)
{
if (block.getType() != Material.AIR)
{
if (exclude.contains(block.getType()))
{
continue;
}
return false;
}
block = block.getRelative(BlockFace.DOWN);
i++;
}
return true;
}
/**
* Sends a formatted clickable accept or deny (or view) message to a player
* Both ACCEPT and DENY will always be sent, but VIEW will only be sent when <code>viewCommand</code> is not null

View File

@ -32,10 +32,6 @@
<artifactId>mineplex-serverdata</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>

View File

@ -10,7 +10,6 @@ import java.util.Set;
import java.util.UUID;
import mineplex.core.common.DummyEntity;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.event.CustomTagEvent;
import mineplex.core.packethandler.IPacketHandler;
@ -47,14 +46,7 @@ import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.plugin.java.JavaPlugin;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.access.IViolationInfo;
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
import fr.neatmonster.nocheatplus.hooks.NCPHook;
import fr.neatmonster.nocheatplus.hooks.NCPHookManager;
public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
public class CustomTagFix extends MiniPlugin implements IPacketHandler
{
private Map<UUID, Map<Integer, Integer[]>> _entityMap = new HashMap<>();
private Map<UUID, Map<Integer, String>> _entityNameMap = new HashMap<>();
@ -63,9 +55,6 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
private Set<UUID> _loggedIn = new HashSet<>();
private Set<Integer> _ignoreIds = new HashSet<>();
private Map<UUID, Long> _exemptTimeMap = new HashMap<>();
private Map<UUID, NautHashMap<CheckType, Long>> _doubleStrike = new HashMap<>();
public CustomTagFix(JavaPlugin plugin, PacketHandler packetHandler)
{
super("Custom Tag Fix", plugin);
@ -73,10 +62,6 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
packetHandler.addPacketHandler(this, true, PacketPlayOutEntityDestroy.class, PacketPlayOutEntityMetadata.class,
PacketPlayOutSpawnEntity.class, PacketPlayOutSpawnEntityLiving.class, PacketPlayOutNamedEntitySpawn.class,
PacketPlayInUseEntity.class, PacketPlayOutAttachEntity.class, PacketPlayOutNewAttachEntity.class);
// NCPHookManager.addHook(CheckType.MOVING_SURVIVALFLY, this);
// NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this);
NCPHookManager.addHook(CheckType.ALL, this);
}
@EventHandler
@ -97,82 +82,6 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
player.setCustomNameVisible(false);
}
@EventHandler
public void ncpExempt(final PlayerToggleFlightEvent event)
{
long ignoreTime = System.currentTimeMillis() + 1500;
if (_exemptTimeMap.containsKey(event.getPlayer().getUniqueId()))
{
_exemptTimeMap.put(event.getPlayer().getUniqueId(),
Math.max(ignoreTime, _exemptTimeMap.get(event.getPlayer().getUniqueId())));
return;
}
try
{
NCPExemptionManager.exemptPermanently(event.getPlayer());
}
catch (Exception exception)
{
}
_exemptTimeMap.put(event.getPlayer().getUniqueId(), ignoreTime);
}
@EventHandler
public void ncpExemptVelocity(final PlayerVelocityEvent event)
{
long ignoreTime = System.currentTimeMillis() + (long) (event.getVelocity().length() * 1500);
if (_exemptTimeMap.containsKey(event.getPlayer().getUniqueId()))
{
_exemptTimeMap.put(event.getPlayer().getUniqueId(),
Math.max(ignoreTime, _exemptTimeMap.get(event.getPlayer().getUniqueId())));
return;
}
_exemptTimeMap.put(event.getPlayer().getUniqueId(), ignoreTime);
}
@EventHandler
public void unexempt(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Iterator<Entry<UUID, Long>> iterator = _exemptTimeMap.entrySet().iterator(); iterator.hasNext(); )
{
final Entry<UUID, Long> entry = iterator.next();
if (System.currentTimeMillis() > entry.getValue())
{
iterator.remove();
}
}
for (Iterator<Entry<UUID, NautHashMap<CheckType, Long>>> iterator = _doubleStrike.entrySet().iterator(); iterator
.hasNext(); )
{
Entry<UUID, NautHashMap<CheckType, Long>> entry = iterator.next();
for (Iterator<Entry<CheckType, Long>> innerIterator = entry.getValue().entrySet().iterator(); innerIterator
.hasNext(); )
{
final Entry<CheckType, Long> entry2 = innerIterator.next();
if (System.currentTimeMillis() > entry2.getValue())
{
innerIterator.remove();
}
}
if (entry.getValue() == null || entry.getValue().size() == 0)
iterator.remove();
}
}
@EventHandler
public void cleanMap(UpdateEvent event)
{
@ -624,45 +533,4 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
}
});
}
@Override
public String getHookName()
{
return "Mineplex Hook";
}
@Override
public String getHookVersion()
{
return "Latest";
}
@Override
public boolean onCheckFailure(CheckType checkType, Player player, IViolationInfo violationInfo)
{
boolean failure = false;
if (checkType == CheckType.MOVING_SURVIVALFLY || checkType == CheckType.MOVING_PASSABLE)
{
failure = _exemptTimeMap.containsKey(player.getUniqueId());
if (failure)
MovingData.getData(player).clearFlyData();
}
// This is the second strike system.
if (!failure)
{
if (!_doubleStrike.containsKey(player.getUniqueId())
|| !_doubleStrike.get(player.getUniqueId()).containsKey(checkType.getParent()))
failure = true;
if (!_doubleStrike.containsKey(player.getUniqueId()))
_doubleStrike.put(player.getUniqueId(), new NautHashMap<CheckType, Long>());
_doubleStrike.get(player.getUniqueId()).put(checkType.getParent(), System.currentTimeMillis() + 5000);
}
return failure;
}
}

View File

@ -3,8 +3,11 @@ package mineplex.core;
import mineplex.core.common.util.UtilServer;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
@ -13,7 +16,11 @@ import java.util.Map;
*/
public class Managers
{
private static final Map<Class<?>, Object> MANAGER_MAP = Collections.synchronizedMap(new HashMap<>());
private static final Object LOCK = new Object();
private static final Map<Class<?>, Object> MANAGER_MAP = new HashMap<>();
private static final LinkedList<Class<?>> INSTANTIATING = new LinkedList<>();
/**
* Gets a Manager ({@link MiniPlugin}) based on its class
@ -23,70 +30,141 @@ public class Managers
*/
public static <T extends MiniPlugin> T get(Class<T> clazz)
{
Object result = MANAGER_MAP.get(clazz);
Object result;
synchronized (LOCK)
{
result = MANAGER_MAP.get(clazz);
}
return clazz.cast(result);
}
/**
* Gets the given module, and initializes if necessary
* @param clazz
* @param <T>
* @return
*/
public static <T extends MiniPlugin> T require(Class<T> clazz)
{
if (MANAGER_MAP.containsKey(clazz))
Object result = null;
synchronized (LOCK)
{
return get(clazz);
}
try
{
ReflectivelyCreateMiniPlugin annotation = clazz.getAnnotation(ReflectivelyCreateMiniPlugin.class);
if (annotation != null)
if (!MANAGER_MAP.containsKey(clazz))
{
Constructor<T> defaultConstructor = clazz.getDeclaredConstructor();
defaultConstructor.setAccessible(true);
return defaultConstructor.newInstance();
if (INSTANTIATING.contains(clazz))
{
List<Class<?>> all = new ArrayList<>(INSTANTIATING);
all.add(clazz);
throw new IllegalStateException("Circular instantiation: " + all);
}
INSTANTIATING.add(clazz);
try
{
ReflectivelyCreateMiniPlugin annotation = clazz.getAnnotation(ReflectivelyCreateMiniPlugin.class);
if (annotation != null)
{
Constructor<T> defaultConstructor = clazz.getDeclaredConstructor();
defaultConstructor.setAccessible(true);
result = defaultConstructor.newInstance();
}
}
catch (ReflectiveOperationException ex)
{
if (!UtilServer.isTestServer())
{
System.out.println("============== WARNING ==============");
System.out.println(" ");
System.out.println(" ");
System.out.println(" ");
System.out.println("Failed to reflectively create MiniPlugin. How did this happen?");
ex.printStackTrace(System.out);
System.out.println(" ");
System.out.println(" ");
System.out.println(" ");
System.out.println("============== WARNING ==============");
}
else
{
throw new RuntimeException("Failed to reflectively create MiniPlugin", ex);
}
}
if (INSTANTIATING.pollLast() != clazz)
{
throw new IllegalArgumentException("Wot");
}
}
else
{
result = MANAGER_MAP.get(clazz);
}
}
catch (ReflectiveOperationException ex)
{
ex.printStackTrace(System.out);
}
return null;
return clazz.cast(result);
}
public static void put(MiniPlugin manager)
{
if (manager == null) throw new NullPointerException("Manager cannot be null");
if (MANAGER_MAP.containsKey(manager.getClass()))
synchronized (LOCK)
{
if (!UtilServer.isTestServer())
if (MANAGER_MAP.containsKey(manager.getClass()))
{
System.out.println("============== WARNING ==============");
System.out.println(" ");
System.out.println(" ");
System.out.println(" ");
System.out.println("Attempted to register " + manager.getClass().getName() + ", but it was already registered");
new Exception("Stack trace").printStackTrace(System.out);
System.out.println(" ");
System.out.println(" ");
System.out.println(" ");
System.out.println("============== WARNING ==============");
}
else
{
throw new IllegalArgumentException("Manager " + manager.getClass().getName() + " is already registered");
if (!UtilServer.isTestServer())
{
System.out.println("============== WARNING ==============");
System.out.println(" ");
System.out.println(" ");
System.out.println(" ");
System.out.println("Attempted to register " + manager.getClass().getName() + ", but it was already registered");
new Exception("Stack trace").printStackTrace(System.out);
System.out.println(" ");
System.out.println(" ");
System.out.println(" ");
System.out.println("============== WARNING ==============");
}
else
{
throw new IllegalArgumentException("Manager " + manager.getClass().getName() + " is already registered");
}
}
MANAGER_MAP.put(manager.getClass(), manager);
}
MANAGER_MAP.put(manager.getClass(), manager);
}
public static void put(MiniPlugin manager, Class<? extends MiniPlugin> type)
{
if (manager == null) throw new NullPointerException("Manager cannot be null");
if (!type.isAssignableFrom(manager.getClass())) throw new IllegalArgumentException(manager.getClass().getName() + " is not a subclass of " + type.getName());
if (MANAGER_MAP.containsKey(type)) throw new IllegalArgumentException("Manager " + type.getName() + " is already registered");
MANAGER_MAP.put(type, manager);
synchronized (LOCK)
{
if (MANAGER_MAP.containsKey(type))
{
if (!UtilServer.isTestServer())
{
System.out.println("============== WARNING ==============");
System.out.println(" ");
System.out.println(" ");
System.out.println(" ");
System.out.println("Attempted to register " + type.getName() + ", but it was already registered");
new Exception("Stack trace").printStackTrace(System.out);
System.out.println(" ");
System.out.println(" ");
System.out.println(" ");
System.out.println("============== WARNING ==============");
}
else
{
throw new IllegalArgumentException("Manager " + type.getName() + " is already registered");
}
}
MANAGER_MAP.put(type, manager);
}
}
}

View File

@ -1,10 +0,0 @@
package mineplex.core;
import fr.neatmonster.nocheatplus.config.ConfigManager;
public class NCPDataManFix
{
public NCPDataManFix() {
//ConfigManager.getConfigFile().set("data.consistencychecks.suppresswarnings", true);
}
}

View File

@ -3,9 +3,11 @@ package mineplex.core;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.UtilMath;
import mineplex.core.incognito.IncognitoManager;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
@ -113,47 +115,8 @@ public class PlayerSelector
return entity -> world == null || entity.getWorld().equals(world);
}
/**
* This will return a {@link Predicate} which will return true <b>if and only if</b> all of the supplied Predicates
* return true
* @param predicates The Predicates to test against
* @return The resulting criterion
*/
@SafeVarargs
public static <T> Predicate<T> and(Predicate<T>... predicates)
public static Predicate<Player> within(Location center, double radius)
{
return t ->
{
for (Predicate<T> predicate : predicates)
{
if (!predicate.test(t))
{
return false;
}
}
return true;
};
}
/**
* This will return a {@link Predicate} which will return true <b>if and only if</b> one of the the supplied Predicates
* return true
* @param predicates The Predicates to test against
* @return The resulting criterion
*/
@SafeVarargs
public static <T> Predicate<T> or(Predicate<T>... predicates)
{
return t ->
{
for (Predicate<T> predicate : predicates)
{
if (predicate.test(t))
{
return true;
}
}
return false;
};
return player -> UtilMath.offset(player.getLocation(), center) <= radius;
}
}

View File

@ -0,0 +1,104 @@
package mineplex.core;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import sun.net.www.protocol.http.HttpURLConnection;
import javax.net.ssl.HttpsURLConnection;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
@ReflectivelyCreateMiniPlugin
public class TimingsFix extends MiniPlugin
{
private static final Gson GSON = new Gson();
private TimingsFix()
{
super("Timings Fix");
URL.setURLStreamHandlerFactory(protocol ->
{
if (protocol.equals("http"))
{
return new sun.net.www.protocol.http.Handler()
{
@Override
protected URLConnection openConnection(URL u) throws IOException
{
if (u.getHost().contains("paste.ubuntu.com"))
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
return new HttpURLConnection(u, null, this)
{
@Override
public OutputStream getOutputStream()
{
return baos;
}
@Override
public InputStream getInputStream()
{
return bais;
}
@Override
public String getHeaderField(String name)
{
if (name.equals("Location"))
{
try
{
String request = new String(baos.toByteArray(), StandardCharsets.UTF_8);
request = request.substring("poster=Spigot&syntax=text&content=".length());
request = URLDecoder.decode(request, "UTF-8");
URL url = new URL("https://timings.spigotmc.org/paste");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setInstanceFollowRedirects(false);
connection.getOutputStream().write(request.getBytes(StandardCharsets.UTF_8));
connection.getOutputStream().close();
JsonObject object = GSON.fromJson(new InputStreamReader(connection.getInputStream()), JsonObject.class);
return "http://paste.ubuntu.com/" + object.get("key").getAsString() + "/";
}
catch (Throwable e)
{
e.printStackTrace();
return "http://paste.ubuntu.com/0/";
}
}
return null;
}
};
}
return super.openConnection(u);
}
@Override
protected URLConnection openConnection(URL u, Proxy p) throws IOException
{
return super.openConnection(u, p);
}
};
}
return null;
});
}
}

View File

@ -996,7 +996,75 @@ public enum Achievement
new String[]{"Speed Builders.SpeediestBuilderizer"},
new String[]{"Perfect a build in less than 10 seconds"},
new int[]{1},
AchievementCategory.SPEED_BUILDERS);
AchievementCategory.SPEED_BUILDERS),
// OITQP
QUIVER_PAYLOAD_BLOSSOM("Flowering Blossom", 2000,
new String[]{"One in the Quiver Payload.Blossom"},
new String[]{"Get 4 kills with a single Pyromancer ultimate."},
new int[]{1},
AchievementCategory.ONE_IN_THE_QUIVER_PAYLOAD),
QUIVER_PAYLOAD_STEADY_HANDS("Steady Hands", 2000,
new String[]{"One in the Quiver Payload.SteadyHands"},
new String[]{"Get 10 triple kills."},
new int[]{10},
AchievementCategory.ONE_IN_THE_QUIVER_PAYLOAD),
QUIVER_PAYLOAD_ASSASSIN("Way of the Assassin", 2000,
new String[]{"One in the Quiver Payload.Assassin"},
new String[]{"Get 5 kills with a single use of Ancient Blade."},
new int[]{1},
AchievementCategory.ONE_IN_THE_QUIVER_PAYLOAD),
QUIVER_PAYLOAD_UNSTOPPABLE("Unstoppable", 2000,
new String[]{"One in the Quiver Payload.Unstoppable"},
new String[]{"Get shot by 100 arrows while using the Berserker ultimate."},
new int[]{100},
AchievementCategory.ONE_IN_THE_QUIVER_PAYLOAD),
QUIVER_PAYLOAD_BOW("What bow?", 2000,
new String[]{"One in the Quiver Payload.Bow"},
new String[]{"Get 10 kills in a single game without firing an arrow."},
new int[]{1},
AchievementCategory.ONE_IN_THE_QUIVER_PAYLOAD),
// Skyfall
SKYFALL_GAMES_WINS("Skyfaller", 600,
new String[]{"Skyfall.Wins"},
new String[]{"Win 30 games of Skyfall"},
new int[]{30},
AchievementCategory.SKYFALL),
SKYFALL_GAMES_LIGHT_WEIGHT("Light Weight", 1000,
new String[]{"Skyfall.NoArmor"},
new String[]{"Win a game without wearing any armor"},
new int[]{1},
AchievementCategory.SKYFALL),
SKYFALL_GAMES_BLOODLUST("Bloodlust", 1200,
new String[]{"Skyfall.Bloodlust"},
new String[]{"Kill 3 other players in the first minute"},
new int[]{1},
AchievementCategory.SKYFALL),
SKYFALL_KILLS_IN_AIR("Aeronaught", 1200,
new String[]{"Skyfall.Aeronaught"},
new String[]{"Get 10 kills while flying"},
new int[]{10},
AchievementCategory.SKYFALL),
SKYFALL_RINGS("I love Booster Rings <3", 1200,
new String[]{"Skyfall.Rings"},
new String[]{"Fly through 1000 Booster Rings"},
new int[]{1000},
AchievementCategory.SKYFALL),
SKYFALL_GAMES_LOOT("Loot Hoarder", 800,
new String[]{"Skyfall.SupplyDropsOpened"},
new String[]{"Be the first to open 20 Supply Drops"},
new int[]{20},
AchievementCategory.SKYFALL);
private String _name;
private String[] _desc;

View File

@ -169,9 +169,16 @@ public enum AchievementCategory
SPEED_BUILDERS("Speed Builders", null,
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED, null, new StatDisplay("Perfect Builds", "PerfectBuild")},
Material.QUARTZ_BLOCK, 0, GameCategory.CLASSICS, null, false, GameDisplay.SpeedBuilders.getGameId());
Material.QUARTZ_BLOCK, 0, GameCategory.CLASSICS, null, false, GameDisplay.SpeedBuilders.getGameId()),
ONE_IN_THE_QUIVER_PAYLOAD("One in the Quiver Payload", null,
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED},
Material.EXPLOSIVE_MINECART, 0, GameCategory.CLASSICS, "Sky Warrior Kit", false, GameDisplay.QuiverPayload.getGameId()),
SKYFALL("Skyfall", null,
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED, null, new StatDisplay("Booster Rings", "Rings")},
Material.BOW, 0, GameCategory.SURVIVAL, null, false, GameDisplay.Skyfall.getGameId());
private String _name;
private String[] _statsToPull;
private StatDisplay[] _statDisplays;

View File

@ -32,7 +32,7 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
public AchievementMainPage(AchievementManager plugin, StatsManager statsManager, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, String targetName, PlayerStats targetStats)
{
this(plugin, statsManager, shop, clientManager, donationManager, name, player, 9 * 4, targetName, targetStats);
this(plugin, statsManager, shop, clientManager, donationManager, name, player, 9 * 5, targetName, targetStats);
}
public AchievementMainPage(AchievementManager plugin, StatsManager statsManager, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, int size, String targetName, PlayerStats targetStats)
@ -50,7 +50,8 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
protected void buildPage()
{
ArrayList<Integer> pageLayout = new ItemLayout(
"XXXXOXOXO",
"XXOXOXOXO",
"OXOXOXOXO",
"OXOXOXOXO",
"OXOXOXOXO",
"OXOXOXOXO").getItemSlots();

View File

@ -8,6 +8,7 @@ import com.mineplex.anticheat.api.GameEndEvent;
import com.mineplex.anticheat.api.GameStartEvent;
import com.mineplex.anticheat.api.MineplexLink;
import com.mineplex.anticheat.api.PlayerViolationEvent;
import com.mineplex.anticheat.checks.Check;
import mineplex.core.Managers;
import mineplex.core.MiniPlugin;
import mineplex.core.PlayerSelector;
@ -144,6 +145,9 @@ public class AntiHack extends MiniPlugin
private Set<Player> _pendingBan = new HashSet<>();
// These are the GWEN checks to ignore when handling PlayerViolationEvent
private HashSet<Class<? extends Check>> _ignoredChecks = new HashSet<>();
@SuppressWarnings("Convert2streamapi")
private AntiHack()
{
@ -251,22 +255,23 @@ public class AntiHack extends MiniPlugin
return;
}
List<Player> targets = PlayerSelector.selectPlayers(PlayerSelector.and(
PlayerSelector.NOT_VANISHED,
PlayerSelector.hasAnyRank(false,
Rank.ALL,
Rank.ULTRA,
Rank.HERO,
Rank.LEGEND,
Rank.TITAN,
Rank.TWITCH,
Rank.YOUTUBE_SMALL,
Rank.YOUTUBE,
Rank.MEDIA,
Rank.ADMIN,
Rank.DEVELOPER,
Rank.OWNER,
Rank.LT
List<Player> targets = PlayerSelector.selectPlayers(
UtilLambda.and(
PlayerSelector.NOT_VANISHED,
PlayerSelector.hasAnyRank(false,
Rank.ALL,
Rank.ULTRA,
Rank.HERO,
Rank.LEGEND,
Rank.TITAN,
Rank.TWITCH,
Rank.YOUTUBE_SMALL,
Rank.YOUTUBE,
Rank.MEDIA,
Rank.ADMIN,
Rank.DEVELOPER,
Rank.OWNER,
Rank.LT
),
player -> !_stalking.contains(player.getUniqueId()),
player -> _stalkingCooldown.getIfPresent(player.getUniqueId()) == null,
@ -653,6 +658,9 @@ public class AntiHack extends MiniPlugin
@EventHandler
public void on(PlayerViolationEvent event)
{
if (_ignoredChecks.contains(event.getCheckClass()))
return;
AntiHackAction.getAction(event.getCheckClass()).handle(event);
}
@ -992,6 +1000,9 @@ public class AntiHack extends MiniPlugin
@EventHandler
public void onHack(PlayerViolationEvent event)
{
if (_ignoredChecks.contains(event.getCheckClass()))
return;
if (event.shouldTellStaff())
{
CheckThresholds thresholds = CHECKS.get(event.getHackType());
@ -1157,6 +1168,25 @@ public class AntiHack extends MiniPlugin
System.out.println("MAC Strict: " + strict);
}
/**
* Add a GWEN Anticheat class to the ignored checks.
* All violation events for these checks will be ignored
* @param check The class of the check to ignore
*/
public void addIgnoredCheck(Class<? extends Check> check)
{
_ignoredChecks.add(check);
}
/**
* Reset the set of ignored checks. In the case that checks are being ignored for a specific game,
* this should be called when the game finishes.
*/
public void resetIgnoredChecks()
{
_ignoredChecks.clear();
}
public boolean isStrict()
{
return _strict;

View File

@ -3,6 +3,8 @@ package mineplex.core.antihack.actions;
import com.mineplex.anticheat.api.PlayerViolationEvent;
import com.mineplex.anticheat.checks.combat.KillauraTypeA;
import com.mineplex.anticheat.checks.combat.KillauraTypeD;
import com.mineplex.anticheat.checks.move.Glide;
import com.mineplex.anticheat.checks.move.Speed;
import mineplex.core.common.util.UtilServer;
import org.bukkit.event.Listener;
@ -22,6 +24,8 @@ public abstract class AntiHackAction implements Listener
{
ACTIONS.put(KillauraTypeA.class, new ImmediateBanAction(200));
ACTIONS.put(KillauraTypeD.class, new BanwaveAction(2000));
ACTIONS.put(Glide.class, new ImmediateBanAction(10000));
ACTIONS.put(Speed.class, new ImmediateBanAction(10000));
}
private int _vl;

View File

@ -22,7 +22,7 @@ class ImmediateBanAction extends AntiHackAction
{
server = server.substring(0, server.indexOf('-'));
}
Managers.get(AntiHack.class).doBan(event.getPlayer(), "[GWEN] Hacking - " + AntiHack.CHECKS.get(event.getHackType()).getFriendlyName() + " [" + server + "]");
Managers.get(AntiHack.class).doBan(event.getPlayer(), "[GWEN] Hacking [" + server + "]");
}
}
}

View File

@ -17,9 +17,14 @@ import mineplex.core.bonuses.gui.buttons.PowerPlayClubButton;
import mineplex.core.bonuses.redis.VoteHandler;
import mineplex.core.bonuses.redis.VotifierCommand;
import mineplex.core.common.Rank;
import mineplex.core.common.util.*;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
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.donation.DonationManager;
import mineplex.core.donation.GiveDonorData;
import mineplex.core.facebook.FacebookManager;
@ -31,12 +36,12 @@ import mineplex.core.inventory.InventoryManager;
import mineplex.core.npc.Npc;
import mineplex.core.npc.NpcManager;
import mineplex.core.pet.PetManager;
import mineplex.core.playwire.PlayWireManager;
import mineplex.core.poll.PollManager;
import mineplex.core.powerplayclub.PowerPlayClubRepository;
import mineplex.core.recharge.Recharge;
import mineplex.core.reward.RewardManager;
import mineplex.core.stats.StatsManager;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.thank.ThankManager;
import mineplex.core.treasure.TreasureType;
import mineplex.core.updater.UpdateType;
@ -68,7 +73,13 @@ import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.*;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Queue;
import java.util.TimeZone;
import java.util.UUID;
public class BonusManager extends MiniClientPlugin<BonusClientData> implements ILoginProcessor
{
@ -105,14 +116,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
public void updateOffSet()
{
_repository.getTimeOffset(new Callback<Long>() {
@Override
public void run(Long data)
{
timeOffSet = data;
}
});
_repository.getTimeOffset(data -> timeOffSet = data);
}
private BonusRepository _repository;
@ -126,6 +130,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
private StatsManager _statsManager;
private FacebookManager _facebookManager;
private YoutubeManager _youtubeManager;
private PlayWireManager _playWireManager;
private PowerPlayClubRepository _powerPlayClubRepository;
private ThankManager _thankManager;
public boolean _enabled;
@ -159,18 +164,18 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
System.out.print("VOTIFIER: ");
System.out.print("DONATION MANAGER - > " + _donationManager.toString());
_voteList = new ArrayList<String>();
_voteList = new ArrayList<>();
_voteList.add("http://vote1.mineplex.com");
_voteList.add("http://vote2.mineplex.com");
_voteList.add("http://vote3.mineplex.com");
_coinQueue = new LinkedList<GiveDonorData>();
_gemQueue = new LinkedList<GiveDonorData>();
_coinQueue = new LinkedList<>();
_gemQueue = new LinkedList<>();
updateOffSet();
}
public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager, FacebookManager facebookManager, YoutubeManager youtubeManager, GadgetManager gadgetManager, ThankManager thankManager)
public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, PlayWireManager playWireManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager, FacebookManager facebookManager, YoutubeManager youtubeManager, GadgetManager gadgetManager, ThankManager thankManager)
{
super("Bonus", plugin);
_repository = new BonusRepository(plugin, this, donationManager);
@ -192,17 +197,18 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
_statsManager = statsManager;
_facebookManager = facebookManager;
_youtubeManager = youtubeManager;
_playWireManager = playWireManager;
_powerPlayClubRepository = new PowerPlayClubRepository(plugin, _clientManager);
_voteList = new ArrayList<String>();
_voteList = new ArrayList<>();
_voteList.add("http://vote1.mineplex.com");
_voteList.add("http://vote2.mineplex.com");
_voteList.add("http://vote3.mineplex.com");
_canVote = true;
_coinQueue = new LinkedList<GiveDonorData>();
_gemQueue = new LinkedList<GiveDonorData>();
_coinQueue = new LinkedList<>();
_gemQueue = new LinkedList<>();
if (npcManager != null)
@ -215,8 +221,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
else
{
_enabled = true;
// _carlNpc.getEntity().setCustomName("");
// _carlNpc.getEntity().setCustomNameVisible(false);
_animation = new AnimationCarl(_carlNpc.getEntity());
_animation.setRunning(false);
}
@ -228,11 +232,9 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
clientManager.addStoredProcedureLoginProcessor(this);
ServerCommandManager.getInstance().registerCommandType("VotifierCommand", VotifierCommand.class,
new VoteHandler(this));
ServerCommandManager.getInstance().registerCommandType("VotifierCommand", VotifierCommand.class, new VoteHandler(this));
updateOffSet();
// updateStreakRecord();
}
@Override
@ -253,79 +255,22 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
updateOffSet();
}
// @EventHandler
// public void updateStreak(UpdateEvent event)
// {
// if (event.getType() != UpdateType.MIN_16)
// return;
//
// updateStreakRecord();
// }
//
// private void updateStreakRecord()
// {
// _repository.getDailyStreakRecord(new Callback<StreakRecord>()
// {
// @Override
// public void run(StreakRecord data)
// {
// _dailyStreak = data;
// }
// });
//
// _repository.getVoteStreakRecord(new Callback<StreakRecord>()
// {
// @Override
// public void run(StreakRecord data)
// {
// _voteStreak = data;
// }
// });
// }
//
// public StreakRecord getDailyStreak()
// {
// return _dailyStreak;
// }
//
// public StreakRecord getVoteStreak()
// {
// return _voteStreak;
// }
public void handleVote(final Player player, final int shardsReceived)
{
final int accountId = _clientManager.getAccountId(player);
runAsync(new Runnable()
runAsync(() -> _repository.getClientData(accountId, data -> runSync(() ->
{
@Override
public void run()
{
_repository.getClientData(accountId, new Callback<BonusClientData>()
{
@Override
public void run(final BonusClientData data)
{
runSync(new Runnable()
{
@Override
public void run()
{
BonusClientData oldData = Get(player);
if (oldData != null) data.setHologram(oldData.getHologram());
Set(player, data);
BonusClientData oldData = Get(player);
if (oldData != null) data.setHologram(oldData.getHologram());
Set(player, data);
_statsManager.incrementStat(player, "Global.DailyVote", 1);
addPendingExplosion(player, player.getName());
UtilPlayer.message(player, F.main("Carl", "Thanks for voting for Mineplex!"));
UtilPlayer.message(player, F.main("Carl", "You received " + F.elem("1 Carl Spinner Ticket") + "!"));
}
});
}
});
}
});
_statsManager.incrementStat(player, "Global.DailyVote", 1);
addPendingExplosion(player, player.getName());
UtilPlayer.message(player, F.main("Carl", "Thanks for voting for Mineplex!"));
UtilPlayer.message(player, F.main("Carl", "You received " + F.elem("1 Carl Spinner Ticket") + "!"));
})));
}
@ -439,23 +384,19 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (timeTillDailyBonus(player) > 0)
result.run(false);
getRepository().attemptDailyBonus(player, new Callback<Boolean>()
getRepository().attemptDailyBonus(player, r ->
{
@Override
public void run(Boolean r)
if (r)
{
if (r)
{
incrementDailyStreak(player);
awardBonus(player, amount);
updateCreeperVisual(player, true, C.cAqua);
UtilPlayer.message(player, F.main("Carl", "Come back tomorrow for more!"));
incrementDailyStreak(player);
awardBonus(player, amount);
updateCreeperVisual(player, true, C.cAqua);
UtilPlayer.message(player, F.main("Carl", "Come back tomorrow for more!"));
_statsManager.incrementStat(player, "Global.DailyReward", 1);
}
result.run(r);
_statsManager.incrementStat(player, "Global.DailyReward", 1);
}
result.run(r);
});
}
@ -483,20 +424,16 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (timeTillRankBonus(player) > 0)
result.run(false);
getRepository().attemptRankBonus(player, new Callback<Boolean>()
getRepository().attemptRankBonus(player, aBoolean ->
{
@Override
public void run(Boolean aBoolean)
if (aBoolean)
{
if (aBoolean)
{
awardBonus(player, getRankBonusAmount(player));
updateCreeperVisual(player, true, C.cAqua);
UtilPlayer.message(player, F.main("Carl", "Come back next month for more!"));
}
result.run(aBoolean);
awardBonus(player, getRankBonusAmount(player));
updateCreeperVisual(player, true, C.cAqua);
UtilPlayer.message(player, F.main("Carl", "Come back next month for more!"));
}
result.run(aBoolean);
});
}
@ -513,19 +450,15 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
{
final int accountId = _clientManager.Get(player).getAccountId();
_repository.attemptAddTickets(accountId, clientData, -1, new Callback<Boolean>()
_repository.attemptAddTickets(accountId, clientData, -1, data ->
{
@Override
public void run(Boolean data)
if (data)
{
if (data)
{
new SpinGui(_plugin, player, _rewardManager, BonusManager.this).openInventory();
}
else
{
UtilPlayer.message(player, F.main("Carl", "There was an error processing your request. Try again later"));
}
new SpinGui(_plugin, player, _rewardManager, BonusManager.this).openInventory();
}
else
{
UtilPlayer.message(player, F.main("Carl", "There was an error processing your request. Try again later"));
}
});
}
@ -741,7 +674,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (oldChests > 0)
{
//_inventoryManager.addItemToInventory(player, TreasureType.OLD.getItemName(), oldChests);
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(oldChests + " Old Chests")));
_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.OLD.getItemName()), oldChests));
}
@ -749,14 +681,12 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (ancientChests > 0)
{
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(ancientChests + " Ancient Chests")));
//_inventoryManager.addItemToInventory(player, TreasureType.ANCIENT.getItemName(), ancientChests);
_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.ANCIENT.getItemName()), ancientChests));
}
if (mythicalChests > 0)
{
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(mythicalChests + " Mythical Chests")));
//_inventoryManager.addItemToInventory(player, TreasureType.MYTHICAL.getItemName(), mythicalChests);
_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.MYTHICAL.getItemName()), mythicalChests));
}
@ -769,22 +699,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (gold > 0)
{
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(gold + " Gold")));
/*
_donationManager.rewardGold(new Callback<Boolean>()
{
@Override
public void run(Boolean data)
{
if (data)
{
}
else
{
UtilPlayer.message(player, F.main("Carl", "Failed to process Gold"));
}
}
}, "Earned", player.getName(), coreClient.getAccountId(), gold, true);
*/
}
if (coins > 0)
@ -797,29 +711,18 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
{
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(tickets + " Carl Spin Ticket")));
final int accountId = _clientManager.Get(player).getAccountId();
runAsync(new Runnable()
runAsync(() ->
{
@Override
public void run()
try
{
try
{
final int newTickets = DSL.using(DBPool.getAccount(), SQLDialect.MYSQL).update(Tables.bonus).set(Tables.bonus.tickets, Tables.bonus.tickets.add(tickets)).
where(Tables.bonus.accountId.eq(accountId)).returning(Tables.bonus.tickets).fetchOne().getTickets();
runSync(new Runnable()
{
@Override
public void run()
{
bonusClient.setTickets(newTickets);
}
});
}
catch (Exception e)
{
System.out.println("Failed to award ticket to player: " + player);
e.printStackTrace();
}
final int newTickets = DSL.using(DBPool.getAccount(), SQLDialect.MYSQL).update(Tables.bonus).set(Tables.bonus.tickets, Tables.bonus.tickets.add(tickets)).
where(Tables.bonus.accountId.eq(accountId)).returning(Tables.bonus.tickets).fetchOne().getTickets();
runSync(() -> bonusClient.setTickets(newTickets));
}
catch (Exception e)
{
System.out.println("Failed to award ticket to player: " + player);
e.printStackTrace();
}
});
}
@ -841,7 +744,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (entity.equals(_carlNpc.getEntity()))
{
updateDailyStreak(event.getPlayer());
new BonusGui(_plugin, event.getPlayer(), this, _rewardManager, _facebookManager, _youtubeManager, _thankManager).openInventory();
new BonusGui(_plugin, event.getPlayer(), this, _rewardManager, _facebookManager, _youtubeManager, _thankManager, _playWireManager).openInventory();
}
}
@ -857,7 +760,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (event.getEntity().equals(_carlNpc.getEntity()))
{
updateDailyStreak(player);
new BonusGui(_plugin, player, this, _rewardManager, _facebookManager, _youtubeManager, _thankManager).openInventory();
new BonusGui(_plugin, player, this, _rewardManager, _facebookManager, _youtubeManager, _thankManager, _playWireManager).openInventory();
}
}
}
@ -898,14 +801,10 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
@EventHandler
public void join(final PlayerJoinEvent event)
{
runSyncLater(new Runnable()
runSyncLater(() ->
{
@Override
public void run()
{
if (event.getPlayer().isOnline())
updateCreeperVisual(event.getPlayer(), true, C.cAqua);
}
if (event.getPlayer().isOnline())
updateCreeperVisual(event.getPlayer(), true, C.cAqua);
}, 10);
}
@ -951,7 +850,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (availableRewards > 0)
{
// Hologram
// String name = "Carl the Creeper";
String text = rewardPrefix + availableRewards + " Reward" + (availableRewards > 1 ? "s" : "") + " to Claim";
hologram.setText(text);
@ -1034,24 +932,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
clientData.getHologram().stop();
// Save streaks
runAsync(new Runnable()
{
@Override
public void run()
{
_repository.saveStreak(clientData.getAccountId(), clientData);
}
});
// This shouldnt be necessary anymore
// runAsync(new Runnable()
// {
// @Override
// public void run()
// {
// clientData.getRecord().store();
// }
// });
runAsync(() -> _repository.saveStreak(clientData.getAccountId(), clientData));
super.UnloadPlayer(event);
}
@ -1080,14 +961,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
@EventHandler
public void Join(final PlayerJoinEvent event)
{
runSyncLater(new Runnable()
{
@Override
public void run()
{
_showCarl.put(event.getPlayer().getName(), true);
}
}, 200);
runSyncLater(() -> _showCarl.put(event.getPlayer().getName(), true), 200);
}
@EventHandler
@ -1130,21 +1004,17 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
final GiveDonorData gemData = _gemQueue.poll();
if (gemData != null && gemData.getAttempts() < 10)
{
_donationManager.RewardGems(new Callback<Boolean>()
_donationManager.RewardGems(data ->
{
@Override
public void run(Boolean data)
if (data)
{
if (data)
{
System.out.println("Successfully processed " + gemData.getGiveAmount() + " gems for " + gemData.getPlayerName());
}
else
{
gemData.incrementAttempts();
System.out.println("Failed to process gems for " + gemData.getPlayerName() + " adding to back of queue. Attempts: " + gemData.getAttempts());
_gemQueue.add(gemData);
}
System.out.println("Successfully processed " + gemData.getGiveAmount() + " gems for " + gemData.getPlayerName());
}
else
{
gemData.incrementAttempts();
System.out.println("Failed to process gems for " + gemData.getPlayerName() + " adding to back of queue. Attempts: " + gemData.getAttempts());
_gemQueue.add(gemData);
}
}, "Earned", gemData.getPlayerName(), gemData.getUuid(), gemData.getGiveAmount());
}
@ -1153,21 +1023,17 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
final GiveDonorData coinData = _coinQueue.poll();
if (coinData != null && coinData.getAttempts() < 10)
{
_donationManager.RewardCoins(new Callback<Boolean>()
_donationManager.RewardCoins(data ->
{
@Override
public void run(Boolean data)
if (data)
{
if (data)
{
System.out.println("Successfully processed " + coinData.getGiveAmount() + " coins for " + coinData.getPlayerName());
}
else
{
coinData.incrementAttempts();
System.out.println("Failed to process coins for " + coinData.getPlayerName() + " adding to back of queue. Attempts: " + coinData.getAttempts());
_coinQueue.add(coinData);
}
System.out.println("Successfully processed " + coinData.getGiveAmount() + " coins for " + coinData.getPlayerName());
}
else
{
coinData.incrementAttempts();
System.out.println("Failed to process coins for " + coinData.getPlayerName() + " adding to back of queue. Attempts: " + coinData.getAttempts());
_coinQueue.add(coinData);
}
}, "Earned", coinData.getPlayerName(), coinData.getAccountId(), coinData.getGiveAmount());
}
@ -1231,4 +1097,8 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
return _inventoryManager;
}
public PlayWireManager getPlayWireManager()
{
return _playWireManager;
}
}

View File

@ -17,7 +17,7 @@ public class GuiCommand extends CommandBase<BonusManager>
@Override
public void Execute(Player caller, String[] args)
{
new BonusGui(Plugin.getPlugin(), caller, Plugin, Plugin.getRewardManager(), Plugin.getFacebookManager(), Plugin.getYoutubeManager(), Plugin.getThankManager()).openInventory();
new BonusGui(Plugin.getPlugin(), caller, Plugin, Plugin.getRewardManager(), Plugin.getFacebookManager(), Plugin.getYoutubeManager(), Plugin.getThankManager(), Plugin.getPlayWireManager()).openInventory();
}
}

View File

@ -4,6 +4,7 @@ import mineplex.core.bonuses.BonusManager;
import mineplex.core.bonuses.gui.buttons.*;
import mineplex.core.facebook.FacebookManager;
import mineplex.core.gui.SimpleGui;
import mineplex.core.playwire.PlayWireManager;
import mineplex.core.reward.RewardManager;
import mineplex.core.thank.ThankManager;
import mineplex.core.youtube.YoutubeManager;
@ -12,34 +13,46 @@ import org.bukkit.plugin.Plugin;
public class BonusGui extends SimpleGui
{
private BonusManager manager;
public BonusGui(Plugin plugin, Player player, BonusManager manager, RewardManager rewardManager, FacebookManager facebookManager, YoutubeManager youtubeManager, ThankManager thankManager)
private final int VOTE_SLOT = 10;
private final int RANK_BONUS_SLOT = 12;
private final int DAILY_BONUS_SLOT = 14;
private final int POLL_SLOT = 16;
private final int FACEBOOK_SLOT = 19;
private final int CLAIM_TIPS_SLOT = 25;
private final int POWER_PLAY_SLOT = 21;
private final int CARL_SPINNER_SLOT = 23;
private final int YOUTUBE_SLOT = 29;
private final int TWITTER_SLOT = 33;
private final int PLAY_WIRE_SLOT = 31;
private static final int INV_SIZE = 45;
public BonusGui(Plugin plugin, Player player, BonusManager manager, RewardManager rewardManager, FacebookManager facebookManager, YoutubeManager youtubeManager, ThankManager thankManager, PlayWireManager playWireManager)
{
super(plugin, player, player.getName() + "'s Bonuses", 5 * 9);
super(plugin, player, player.getName() + "'s Bonuses", INV_SIZE);
setItem(VOTE_SLOT, new VoteButton(plugin, player, this, manager));
this.manager = manager;
setItem(RANK_BONUS_SLOT, new RankBonusButton(getPlugin(), player, this, manager));
setItem(10, new VoteButton(plugin, player, this, manager));
setItem(12, new RankBonusButton(getPlugin(), player, this, manager));
setItem(14, new DailyBonusButton(getPlugin(), player, this, manager));
setItem(DAILY_BONUS_SLOT, new DailyBonusButton(getPlugin(), player, this, manager));
setItem(16, new PollButton(getPlugin(), player, manager.getPollManager(), manager.getClientManager(), this, manager));
setItem(POLL_SLOT, new PollButton(getPlugin(), player, manager.getPollManager(), manager.getClientManager(), this, manager));
setItem(19, new FacebookButton(player, facebookManager));
setItem(FACEBOOK_SLOT, new FacebookButton(player, facebookManager));
setItem(21, new YoutubeButton(player, youtubeManager));
setItem(YOUTUBE_SLOT, new YoutubeButton(player, youtubeManager));
setItem(23, new TwitterButton(player));
setItem(TWITTER_SLOT, new TwitterButton(player));
setItem(25, new ClaimTipsButton(getPlugin(), player, this, manager, thankManager));
setItem(CLAIM_TIPS_SLOT, new ClaimTipsButton(getPlugin(), player, this, manager, thankManager));
setItem(29, new PowerPlayClubButton(player, manager));
setItem(POWER_PLAY_SLOT, new PowerPlayClubButton(player, manager));
setItem(33, new CarlSpinButton(getPlugin(), player, manager, rewardManager));
setItem(CARL_SPINNER_SLOT, new CarlSpinButton(getPlugin(), player, manager, rewardManager));
setItem(PLAY_WIRE_SLOT, new PlayWireButton(playWireManager, player));
}
@Override

View File

@ -0,0 +1,89 @@
package mineplex.core.bonuses.gui.buttons;
import mineplex.core.common.util.C;
import mineplex.core.gui.GuiItem;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.playwire.PlayWireManager;
import mineplex.core.recharge.Recharge;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
/**
*
*/
public class PlayWireButton implements GuiItem
{
private static final ItemStack DISABLED_ICON = new ItemBuilder(Material.REDSTONE_BLOCK)
.setTitle(C.cGreen + C.Bold + "Watch an Ad!")
.addLore(
C.cWhite + "You have already redeemed your",
C.cWhite + "250 Shards for watching the Ad!",
" ",
C.cWhite + "You can watch it again, but you won't earn any shards!",
" ",
C.cWhite + "You can watch the Ad once every 12 hours.",
" ",
C.cWhite + "Ads help us keep Mineplex awesome",
C.cRedB + "Be sure to have your AdBlocker disabled!",
" ",
C.cGreen + "Click to watch the Ad now!"
)
.build();
private static final ItemStack ENABLED_ICON = new ItemBuilder(Material.TRIPWIRE_HOOK)
.setTitle(C.cGreen + C.Bold + "Watch an Ad!")
.addLore(
C.cYellow + "Earn a 250 Shard Reward",
C.cWhite + "by checking out our partner's Advertisement",
" ",
C.cWhite + "You can watch the Ad once every 12 hours.",
" ",
C.cWhite + "Ads help us keep Mineplex awesome",
C.cRedB + "Be sure to have your AdBlocker disabled!",
" ",
C.cGreen + "Click to watch the Ad now!"
)
.build();
private final Player _player;
private final PlayWireManager _manager;
public PlayWireButton(PlayWireManager manager, Player player)
{
_manager = manager;
_player = player;
}
@Override
public ItemStack getObject()
{
return _manager.canRedeem(_player) ? ENABLED_ICON : DISABLED_ICON;
}
@Override
public void click(ClickType clickType)
{
if(!Recharge.Instance.use(_player, "PlayWire Ad", 1000, false, false))
{
return;
}
_manager.getPlugin().getServer().dispatchCommand(_manager.getPlugin().getServer().getConsoleSender(), "adlink " + _player.getName());
_player.closeInventory();
}
@Override
public void setup()
{
}
@Override
public void close()
{
}
}

View File

@ -4,6 +4,7 @@ import com.mineplex.spigot.ChunkAddEntityEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.PlayerSelector;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.common.util.UtilLambda;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTasks;
@ -665,7 +666,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
if (entity.isValid())
{
for (Player player : PlayerSelector.selectPlayers(
PlayerSelector.and(
UtilLambda.and(
PlayerSelector.inWorld(entity.getWorld()),
OfflinePlayer::isOnline,
tester

View File

@ -82,6 +82,8 @@ public enum GameDisplay
Valentines("Valentines Vendetta", Material.LEATHER, (byte)0, GameCategory.EXTRA, 61),
Skyfall("Skyfall", Material.DIAMOND_BOOTS, (byte)0, GameCategory.SURVIVAL, 62),
Basketball("Hoops", Material.SLIME_BALL, (byte)0, GameCategory.EXTRA, 63),
QuiverPayload("One in the Quiver Payload", Material.ARROW, (byte)0, GameCategory.ARCADE, 64),

View File

@ -0,0 +1,53 @@
package mineplex.core.playwire;
import mineplex.core.common.util.UtilTime.TimeUnit;
/**
*
*/
public class PlayWireClientData
{
private long _redeemTime;
private int _streak;
public PlayWireClientData(long date)
{
_redeemTime = date;
long curr = System.currentTimeMillis();
if (_redeemTime <= 0)
{
_streak = 0;
}
}
public long getRedeemTime()
{
return _redeemTime;
}
public void setRedeemTime(long date)
{
long old = _redeemTime;
_redeemTime = date;
if (_redeemTime - old > TimeUnit.DAYS.getMilliseconds() * 2)
{
_streak = 0;
} else
{
setStreak(getStreak() + 1);
}
}
public int getStreak()
{
return _streak;
}
public void setStreak(int streak)
{
_streak = streak;
}
}

View File

@ -0,0 +1,26 @@
package mineplex.core.playwire;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
/**
*
*/
public class PlayWireCommand implements CommandExecutor
{
private PlayWireManager _manager;
public PlayWireCommand(PlayWireManager manager)
{
_manager = manager;
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args)
{
_manager.onCommand(args);
return true;
}
}

View File

@ -0,0 +1,123 @@
package mineplex.core.playwire;
import mineplex.core.Managers;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.treasure.TreasureType;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.UUID;
/**
*
*/
public class PlayWireManager extends MiniDbClientPlugin<PlayWireClientData>
{
private final long COOL_DOWN = TimeUnit.HOURS.getMilliseconds() * 12;
private static final int REWARD_MESSAGE_DELAY_SECONDS = 10;
private final DonationManager _donationManager;
private final PlayWireRepository _repository;
public PlayWireManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
{
super("PlayWire", plugin, clientManager);
_donationManager = donationManager;
_repository = new PlayWireRepository(this);
getPlugin().getCommand("playwire").setExecutor(new PlayWireCommand(this));
}
@Override
public String getQuery(int accountId, String uuid, String name)
{
return "SELECT `redeemed` FROM `play_wire` WHERE `accountId`=" + accountId + ";";
}
public boolean canRedeem(Player player)
{
PlayWireClientData data = Get(player);
long now = System.currentTimeMillis();
return data == null || data.getRedeemTime() == -1 || (now - data.getRedeemTime()) > COOL_DOWN;
}
public void attemptRedeem(Player player)
{
if (!canRedeem(player))
{
player.sendMessage(ResponseType.UNCOUNTED.getMessage());
return;
}
PlayWireClientData client = Get(player);
client.setRedeemTime(System.currentTimeMillis());
if(client.getStreak() == 7)
{
//
Managers.get(InventoryManager.class).addItemToInventory(player, TreasureType.ANCIENT.getItemName(), 1);
} else if(client.getStreak() == 14)
{
Managers.get(InventoryManager.class).addItemToInventory(player, TreasureType.ANCIENT.getItemName(), 1);
client.setStreak(0);
}
_repository.attemptPlayWire(player, client, () ->
{
_donationManager.RewardCoinsLater("Watching Ad", player, 250);
Bukkit.getScheduler().runTaskLater(getClientManager().getPlugin(), () -> UtilPlayer.message(player, ResponseType.COUNTED.getMessage()), REWARD_MESSAGE_DELAY_SECONDS * 20L);
});
}
public void onCommand(String[] args)
{
String argument = args[0];
String target = args[1];
ResponseType response = ResponseType.valueOf(argument.toUpperCase());
Player player = Bukkit.getPlayer(target);
if (player == null)
{
getPlugin().getLogger().severe("PLAY WIRE PLAYER NOT FOUND ERROR: PlayerName: " + target);
return;
}
if (response == ResponseType.COUNTED)
{
attemptRedeem(player);
} else
{
player.sendMessage(response.getMessage());
}
}
@Override
public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException
{
boolean hasRow = resultSet.next();
if (hasRow)
{
PlayWireClientData client = new PlayWireClientData(resultSet.getLong(1));
client.setStreak(resultSet.getInt(2));
Set(uuid, client);
} else
{
Set(uuid, new PlayWireClientData(-1));
}
}
@Override
protected PlayWireClientData addPlayer(UUID uuid)
{
return new PlayWireClientData(-1);
}
}

View File

@ -0,0 +1,52 @@
package mineplex.core.playwire;
import mineplex.serverdata.database.DBPool;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
/**
* Totally original code I wrote, did not copy it from YouTubeRepo, no sir.
*/
public class PlayWireRepository
{
private static final String INSERT_LAST_REDEEMED = "INSERT INTO `play_wire` VALUES(?,?,?) ON DUPLICATE KEY UPDATE `redeemed` = ?, `streak` = ?";
private final PlayWireManager _manager;
public PlayWireRepository(PlayWireManager manager)
{
_manager = manager;
}
public void attemptPlayWire(Player player, PlayWireClientData client, Runnable runnable)
{
int accountId = _manager.getClientManager().Get(player).getAccountId();
Bukkit.getScheduler().runTaskAsynchronously(_manager.getPlugin(), () ->
{
try (Connection connection = DBPool.getAccount().getConnection())
{
PreparedStatement statement = connection.prepareStatement(INSERT_LAST_REDEEMED);
statement.setInt(1, accountId);
statement.setLong(2, client.getRedeemTime());
statement.setInt(3, client.getStreak());
statement.setLong(4, client.getRedeemTime());
statement.setInt(5, client.getStreak());
statement.executeUpdate();
runnable.run();
} catch (SQLException e)
{
e.printStackTrace();
}
});
}
}

View File

@ -0,0 +1,28 @@
package mineplex.core.playwire;
import mineplex.core.common.util.F;
/**
*
*/
public enum ResponseType
{
COUNTED(F.main("Carl", "Rewarded " + F.elem("250 Treasure Shards") + " for watching the Ad")),
UNCOUNTED(F.main("Carl", "You already watched the Ad within the past 12 hours!")),
BLOCKED(F.main("Carl", "You have an AdBlocker on, but tried to watch the Ad! Ssssssslight problem there!")),
UNFILLED(F.main("Carl", "Ssssomething went wrong with the Ad, we'll get it sorted ASAP.")),;
private String _message;
ResponseType(String message)
{
_message = message;
}
public String getMessage()
{
return _message;
}
}

View File

@ -2,6 +2,7 @@ package mineplex.game.clans;
import mineplex.core.CustomTagFix;
import mineplex.core.FoodDupeFix;
import mineplex.core.TimingsFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.AntiHack;
@ -91,6 +92,8 @@ public class Clans extends JavaPlugin
_clientManager = new CoreClientManager(this, webServerAddress);
CommandCenter.Instance.setClientManager(_clientManager);
require(TimingsFix.class);
ItemStackFactory.Initialize(this, false);
DelayedTask.Initialize(this);

View File

@ -1,3 +1,5 @@
name: ClansHub
main: mineplex.clanshub.ClansHub
version: 0.1
version: 0.1
commands:
playwire:

View File

@ -55,6 +55,7 @@ import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import mineplex.core.pet.PetManager;
import mineplex.core.playerCount.PlayerCountManager;
import mineplex.core.playwire.PlayWireManager;
import mineplex.core.poll.PollManager;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.Preference;
@ -189,7 +190,8 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter
FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager);
YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager);
_bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, thankManager);
PlayWireManager playWireManager = new PlayWireManager(plugin, clientManager, donationManager);
_bonusManager = new BonusManager(plugin, clientManager, playWireManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, thankManager);
World world = _spawn.getWorld();
_treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _gadgetManager, _blockRestore, hologramManager, statsManager, _bonusManager.getRewardManager());

View File

@ -1,4 +1,6 @@
name: Hub
main: mineplex.hub.Hub
version: 0.1
loadbefore: [MineplexAnticheat]
loadbefore: [MineplexAnticheat]
commands:
playwire:

View File

@ -48,6 +48,7 @@ import mineplex.core.party.PartyManager;
import mineplex.core.personalServer.PersonalServerManager;
import mineplex.core.pet.PetManager;
import mineplex.core.playerCount.PlayerCountManager;
import mineplex.core.playwire.PlayWireManager;
import mineplex.core.poll.PollManager;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.Preference;
@ -199,8 +200,9 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager);
YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager);
PlayWireManager playWireManager = new PlayWireManager(plugin, clientManager, donationManager);
_bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, thankManager);
_bonusManager = new BonusManager(plugin, clientManager, playWireManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _gadgetManager, thankManager);
_treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _gadgetManager, _blockRestore, hologramManager, statsManager, _bonusManager.getRewardManager());
CosmeticManager cosmeticManager = new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager, boosterManager);

View File

@ -739,6 +739,11 @@ public class ServerManager extends MiniPlugin implements BrawlShopProvider
return _serverNpcShopMap.get("Speed Builders");
}
public ServerNpcShop getOITQPShop()
{
return _serverNpcShopMap.get("OITQ Payload");
}
public ServerNpcShop getBlockHuntShop()
{
return _serverNpcShopMap.get("Block Hunt");
@ -746,7 +751,7 @@ public class ServerManager extends MiniPlugin implements BrawlShopProvider
public ServerNpcShop getBetaShop()
{
return _serverNpcShopMap.get("Beta Games");
return _serverNpcShopMap.get("Skyfall BETA");
}
public ServerNpcShop getUHCShop()

View File

@ -58,13 +58,14 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "The least correct builder is eliminated.",
}, "SB", "Speed_Builders", new SelectSBButton(this));
add(5, Material.BOOK_AND_QUILL, C.cYellowB + "Draw My Thing " + C.cGray + "Pictionary", new String[]
add(5, Material.BOW, C.cYellowB + "OITQ Payload " + C.cGray + "Fast Paced Tug of War", new String[]
{
(_extraValue ? C.cAquaB : C.cWhiteB) + "NEW GAME",
C.Reset + "",
C.Reset + "Players take turns at drawing a random",
C.Reset + "word. Whoever guesses it within the time",
C.Reset + "limit gets some points!",
}, "DMT", "Draw_My_Thing", new SelectDMTButton(this));
C.Reset + "1.9 Team-Based Combat Game",
C.Reset + "Keep the Payload away from your base",
C.Reset + "or die trying!",
}, "OITQP", "OITQ_Payload", new SelectOITQPButton(this));
add(7, Material.TNT, C.cYellowB + "Dragon Escape " + C.cGray + "Fast Paced Parkour", new String[]
{
@ -158,7 +159,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "the Hunters!",
}, "BH", "Block_Hunt", new SelectBHButton(this));
add(28, Material.TNT, C.cYellowB + "MineStrike " + C.cGray + "Team Survival", new String[]
add(27, Material.TNT, C.cYellowB + "MineStrike " + C.cGray + "Team Survival", new String[]
{
C.Reset + "",
C.Reset + "One team must defend two bomb sites from",
@ -166,13 +167,13 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "and blow them up!",
}, "MS", "MineStrike", new SelectMSButton(this));
add(30, _superSmashCycle.get(_ssmIndex).clone(), null, null, new String[] {"SSM", "SSM2"}, "Smash_Mobs", new SelectSSMButton(this));
add(29, _superSmashCycle.get(_ssmIndex).clone(), null, null, new String[] {"SSM", "SSM2"}, "Smash_Mobs", new SelectSSMButton(this));
String[] games = new String[] {"MIN", "DR", "DE", "PB", "TF", "RUN", "SN", "DT", "SQ", "SA", "SS",
"OITQ", "BBB", "MB", "EVO", "GLD", "BL"};
add(32, _minigameCycle.get(_minigameIndex).clone(), null, null, games, "Arcade", new SelectMINButton(this));
add(31, _minigameCycle.get(_minigameIndex).clone(), null, null, games, "Arcade", new SelectMINButton(this));
add(34, Material.WOOD, C.cYellowB + "Master Builders " + C.cGray + "Creative Build", new String[]
add(33, Material.WOOD, C.cYellowB + "Master Builders " + C.cGray + "Creative Build", new String[]
{
C.Reset + "",
C.Reset + "Players are given a Build Theme and ",
@ -180,6 +181,14 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "to create a masterpiece!",
}, "BLD", "Master_Builders", new SelectBLDButton(this));
add(35, Material.BOOK_AND_QUILL, C.cYellowB + "Draw My Thing " + C.cGray + "Pictionary", new String[]
{
C.Reset + "",
C.Reset + "Players take turns at drawing a random",
C.Reset + "word. Whoever guesses it within the time",
C.Reset + "limit gets some points!",
}, "DMT", "Draw_My_Thing", new SelectDMTButton(this));
add(39, Material.SKULL_ITEM, (byte) 3, C.cYellowB + "Player Servers " + C.cGray + "Player Hosted Games", new String[]
{
C.Reset + "",
@ -197,13 +206,15 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "and raid others!",
}, "Clans", null, new SelectCLANSButton(this));
add(41, Material.BREWING_STAND_ITEM, C.cYellowB + "One in the Quiver " + C.cGray + "Payload", new String[]
add(41, Material.BREWING_STAND_ITEM, C.cYellowB + "Skyfall " + C.cGray + "Elytra Game", new String[]
{
(_extraValue ? C.cAquaB : C.cWhiteB) + "BETA GAME",
C.Reset + "",
C.Reset + "1.9 Team-Based Combat Game",
C.Reset + "Keep the Payload away from your base",
C.Reset + "or die trying!",
}, "BETA", null, new SelectBETAButton(this));
C.Reset + "1.9 Game, 1.8 PVP",
C.Reset + "Fly through sky islands,",
C.Reset + "collect gear and defeat",
C.Reset + "all enemies.",
}, "BETA", "Beta_Games", new SelectBETAButton(this));
}
private void add(int slot, Material material, String title, String[] lore, String serverTag, String boosterGroup, IButton button)
@ -570,6 +581,11 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
getPlugin().getSpeedBuildersShop().attemptShopOpen(player);
}
public void openOITQP(Player player)
{
getPlugin().getOITQPShop().attemptShopOpen(player);
}
public void openDMT(Player player)
{
getPlugin().getDrawMyThingShop().attemptShopOpen(player);

View File

@ -0,0 +1,23 @@
package mineplex.hub.server.ui.button;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.shop.item.IButton;
import mineplex.hub.server.ui.ServerGameMenu;
public class SelectOITQPButton implements IButton
{
private ServerGameMenu _menu;
public SelectOITQPButton(ServerGameMenu menu)
{
_menu = menu;
}
@Override
public void onClick(Player player, ClickType clickType)
{
_menu.openOITQP(player);
}
}

View File

@ -1,4 +1,6 @@
name: Arcade
main: nautilus.game.arcade.Arcade
version: 0.1
loadbefore: [MineplexAnticheat]
loadbefore: [MineplexAnticheat]
commands:
playwire:

View File

@ -19,9 +19,5 @@
<artifactId>mineplex-minecraft-game-classcombat</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -3,6 +3,7 @@ package nautilus.game.arcade;
import mineplex.core.CustomTagFix;
import mineplex.core.FoodDupeFix;
import mineplex.core.PacketsInteractionFix;
import mineplex.core.TimingsFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.AntiHack;
@ -102,6 +103,8 @@ public class Arcade extends JavaPlugin
CommandCenter.Instance.setClientManager(_clientManager);
require(ProfileCacheManager.class);
require(TimingsFix.class);
ItemStackFactory.Initialize(this, false);
Recharge.Initialize(this);

View File

@ -2,6 +2,7 @@ package nautilus.game.arcade;
import mineplex.core.Managers;
import mineplex.core.MiniPlugin;
import mineplex.core.PlayerSelector;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
@ -17,6 +18,8 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilLambda;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.cosmetic.CosmeticManager;
@ -46,6 +49,7 @@ import mineplex.core.npc.NpcManager;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.party.PartyManager;
import mineplex.core.pet.PetManager;
import mineplex.core.playwire.PlayWireManager;
import mineplex.core.poll.PollManager;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager;
@ -65,6 +69,8 @@ import mineplex.core.teleport.Teleport;
import mineplex.core.thank.ThankManager;
import mineplex.core.timing.TimingManager;
import mineplex.core.titangiveaway.TitanGiveawayManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.valentines.ValentinesGiftManager;
import mineplex.core.youtube.YoutubeManager;
import mineplex.minecraft.game.classcombat.Class.ClassManager;
@ -336,7 +342,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
new GameStatManager(this);
FacebookManager facebookManager = new FacebookManager(plugin, clientManager, donationManager, inventoryManager);
YoutubeManager youtubeManager = new YoutubeManager(plugin, clientManager, donationManager);
_bonusManager = new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _cosmeticManager.getGadgetManager(), thankManager);
PlayWireManager playWireManager = new PlayWireManager(plugin, clientManager, donationManager);
_bonusManager = new BonusManager(plugin, clientManager, playWireManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, facebookManager, youtubeManager, _cosmeticManager.getGadgetManager(), thankManager);
new GameLootManager(this, petManager, _bonusManager.getRewardManager());
_spectatorManager = new GameSpectatorManager(this);
_gameWorldManager = new GameWorldManager(this);
@ -1960,6 +1967,22 @@ public class ArcadeManager extends MiniPlugin implements IRelation
}
}
@EventHandler
public void teleportPlayersToSpawn(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTEST)
return;
PlayerSelector
.selectPlayers(
UtilLambda.and(
PlayerSelector.inWorld(Bukkit.getWorld("world")),
UtilLambda.not(PlayerSelector.within(GetLobby().GetSpawn(), 70))
)
)
.forEach(player -> player.teleport(GetLobby().GetSpawn()));
}
@EventHandler
public void clearGameTeams(GameStateChangeEvent event)
{

View File

@ -59,7 +59,7 @@ import nautilus.game.arcade.game.games.monstermaze.MonsterMaze;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.paintball.Paintball;
import nautilus.game.arcade.game.games.quiver.Quiver;
import nautilus.game.arcade.game.games.quiver.QuiverPayload;
import nautilus.game.arcade.game.games.quiver.QuiverTeamBase;
import nautilus.game.arcade.game.games.quiver.QuiverTeams;
import nautilus.game.arcade.game.games.quiver.modes.BunnyHop;
import nautilus.game.arcade.game.games.rings.ElytraRings;
@ -70,6 +70,7 @@ import nautilus.game.arcade.game.games.sheep.SheepGame;
import nautilus.game.arcade.game.games.sheep.modes.EweHeroes;
import nautilus.game.arcade.game.games.sheep.modes.OverpoweredSheepQuest;
import nautilus.game.arcade.game.games.sheep.modes.SmashSheep;
import nautilus.game.arcade.game.games.skyfall.Skyfall;
import nautilus.game.arcade.game.games.skywars.SoloSkywars;
import nautilus.game.arcade.game.games.skywars.TeamSkywars;
import nautilus.game.arcade.game.games.skywars.modes.OverpoweredSkywars;
@ -158,7 +159,7 @@ public enum GameType
OldMineWare(OldMineWare.class, GameDisplay.OldMineWare),
Paintball(Paintball.class, GameDisplay.Paintball),
Quiver(Quiver.class, GameDisplay.Quiver),
QuiverPayload(QuiverPayload.class, GameDisplay.QuiverPayload),
QuiverPayload(QuiverTeamBase.class, GameDisplay.QuiverPayload),
QuiverTeams(QuiverTeams.class, GameDisplay.QuiverTeams),
Runner(Runner.class, GameDisplay.Runner),
SearchAndDestroy(SearchAndDestroy.class, GameDisplay.SearchAndDestroy),
@ -195,6 +196,7 @@ public enum GameType
MonsterMaze(MonsterMaze.class, GameDisplay.MonsterMaze),
MonsterLeague(MonsterLeague.class, GameDisplay.MonsterLeague),
Gladiators(Gladiators.class, GameDisplay.Gladiators),
Skyfall(Skyfall.class, GameDisplay.Skyfall),
BouncyBalls(BouncyBalls.class, GameDisplay.BouncyBalls),

View File

@ -1,7 +1,51 @@
package nautilus.game.arcade.game;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import org.apache.commons.lang3.tuple.Triple;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
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.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Hanging;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.scoreboard.NameTagVisibility;
import org.bukkit.scoreboard.Team;
import org.bukkit.util.Vector;
import com.google.common.collect.Lists;
import com.mojang.authlib.GameProfile;
import mineplex.core.Managers;
import mineplex.core.antihack.AntiHack;
import mineplex.core.common.util.C;
@ -9,6 +53,7 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTabTitle;
@ -63,50 +108,12 @@ import nautilus.game.arcade.wineffect.WinEffectManager;
import nautilus.game.arcade.world.WorldData;
import net.minecraft.server.v1_8_R3.EntityItem;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
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.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Hanging;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.scoreboard.NameTagVisibility;
import org.bukkit.scoreboard.Team;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
public abstract class Game implements Listener
{
private final static int MAX_TICK_SPEED_MEASUREMENT = 40;
public long getGameLiveTime()
{
return _gameLiveTime;
@ -290,6 +297,8 @@ public abstract class Game implements Listener
public boolean PlaySoundGameStart = true;
public double XpMult = 1;
public boolean SpeedMeasurement = false;
// Chat Stats
public final ChatStatData Kills = new ChatStatData("Kills", "Kills", true);
@ -369,6 +378,8 @@ public abstract class Game implements Listener
public WinEffectManager WinEffectManager = new WinEffectManager();
private Map<Class<? extends Module>, Module> _modules = new HashMap<>();
private HashMap<UUID, LinkedList<Triple<Double, Double, Double>>> _playerPastLocs = new HashMap<>();
public Game(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc)
{
@ -2210,8 +2221,94 @@ public abstract class Game implements Listener
public void disable()
{
Managers.get(AntiHack.class).resetIgnoredChecks();
}
@EventHandler
public void registerLocs(UpdateEvent event)
{
if (!SpeedMeasurement)
return;
if (event.getType() != UpdateType.TICK)
return;
for (Player player : GetPlayers(true))
{
if (!_playerPastLocs.containsKey(player.getUniqueId()))
_playerPastLocs.put(player.getUniqueId(), new LinkedList<>());
LinkedList<Triple<Double, Double, Double>> locList = _playerPastLocs.get(player.getUniqueId());
locList.add(Triple.of(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ()));
if (locList.size() > MAX_TICK_SPEED_MEASUREMENT)
locList.removeFirst();
}
}
/**
* The players Location while the specified amount of ticks ago
*
* @param player to check
* @param ticksAgo amount of time ago
* @return Location of the specified time
*/
public Location getPastLocation(Player player, int ticksAgo)
{
if (!SpeedMeasurement)
{
throw new IllegalStateException("Speed Measurements are not enabled");
}
if (!IsAlive(player))
{
throw new IllegalArgumentException("this only works for ingame players");
}
if (ticksAgo > MAX_TICK_SPEED_MEASUREMENT)
{
throw new IllegalArgumentException("ticksAgo needs to be 1 - 40");
}
if (!_playerPastLocs.containsKey(player.getUniqueId()))
return player.getLocation();
int tick = MAX_TICK_SPEED_MEASUREMENT - ticksAgo;
LinkedList<Triple<Double, Double, Double>> pastLocs = _playerPastLocs.get(player.getUniqueId());
if (pastLocs.size() < tick)
return player.getLocation();
Triple<Double, Double, Double> triple = _playerPastLocs.get(player.getUniqueId()).get(tick);
return new Location(player.getWorld(), triple.getLeft(), triple.getMiddle(), triple.getRight(), player.getLocation().getYaw(), player.getLocation().getPitch());
}
/**
* The Vector of movement for the specified time
*
* @param player to check
* @param ticksAgo amount of time ago
* @return vector of movement
*/
public Vector getMovement(Player player, int ticksAgo)
{
Location past = getPastLocation(player, ticksAgo);
return player.getLocation().toVector().subtract(past.clone().toVector());
}
/**
* The amount of blocks moved for the specified time
*
* @param player
* @param ticksAgo amount of time ago
* @return blocks moved
*/
public double getSpeed(Player player, int ticksAgo)
{
Location past = getPastLocation(player, ticksAgo);
return UtilMath.offset(past, player.getLocation());
}
public void cleanupModules()
{
for (Module module : this._modules.values())

View File

@ -23,10 +23,8 @@ import nautilus.game.arcade.game.games.minestrike.items.guns.Gun;
import nautilus.game.arcade.game.games.minestrike.items.guns.GunStats;
import nautilus.game.arcade.game.games.minestrike.items.guns.Shotgun;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -324,4 +322,4 @@ public class ShopManager
}
}
}
}
}

View File

@ -0,0 +1,208 @@
package nautilus.game.arcade.game.games.quiver;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import mineplex.core.common.MinecraftVersion;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.quiver.kits.KitBarrage;
import nautilus.game.arcade.game.games.quiver.kits.KitBeserker;
import nautilus.game.arcade.game.games.quiver.kits.KitNecromancer;
import nautilus.game.arcade.game.games.quiver.kits.KitNewNinja;
import nautilus.game.arcade.game.games.quiver.kits.KitPyromancer;
import nautilus.game.arcade.game.games.quiver.kits.KitSkyWarrior;
import nautilus.game.arcade.game.games.quiver.module.ModuleKillstreak;
import nautilus.game.arcade.game.games.quiver.module.ModuleKitNPCS;
import nautilus.game.arcade.game.games.quiver.module.ModulePowerup;
import nautilus.game.arcade.game.games.quiver.module.ModuleSpawnBarrier;
import nautilus.game.arcade.game.games.quiver.module.ModuleSuperArrow;
import nautilus.game.arcade.game.games.quiver.module.ModuleUltimate;
import nautilus.game.arcade.game.games.quiver.module.QuiverTeamModule;
import nautilus.game.arcade.game.games.quiver.module.game.QuiverPayload;
import nautilus.game.arcade.game.modules.VersionModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.stats.WinWithoutBowStatTracker;
public class QuiverTeamBase extends TeamGame
{
//private static final String CUSTOM_LOCATION_GAME_KOTH = "KOTH";
public static final String OVERTIME = C.cGold + "!!! " + C.cDRedB + "OVERTIME" + C.cGold + " !!!";
private Map<Class<? extends QuiverTeamModule>, QuiverTeamModule> _modules = new HashMap<>();
public QuiverTeamBase(ArcadeManager manager)
{
this(manager, new Kit[] {
new KitBeserker(manager), new KitNewNinja(manager), new KitBarrage(manager), new KitSkyWarrior(manager), new KitPyromancer(manager), new KitNecromancer(manager),
});
}
@SuppressWarnings("unchecked")
public QuiverTeamBase(ArcadeManager manager, Kit[] kits)
{
super(manager, GameType.QuiverPayload, kits, new String[] {});
this.PlayersPerTeam = 5;
this.DeathOut = false;
this.DamageSelf = false;
this.DamageTeamSelf = false;
this.DamageFall = false;
this.TeamArmor = true;
this.TeamArmorHotbar = true;
this.HungerSet = 20;
registerStatTrackers(new WinWithoutBowStatTracker(this, "Bow"));
registerChatStats(
Kills,
Deaths,
KDRatio,
BlankLine,
Assists,
DamageTaken,
DamageDealt
);
getQuiverTeamModule(ModuleSuperArrow.class);
getQuiverTeamModule(ModuleKitNPCS.class);
getQuiverTeamModule(ModulePowerup.class);
getQuiverTeamModule(ModuleUltimate.class);
getQuiverTeamModule(ModuleSpawnBarrier.class);
getQuiverTeamModule(ModuleKillstreak.class);
registerModule(new VersionModule(MinecraftVersion.Version1_9, "One in the Quiver Payload requires Minecraft 1.9!"));
// if (WorldData.GetCustomLocs(CUSTOM_LOCATION_GAME_KOTH) != null)
// {
// getQuiverTeamModule(QuiverKOTH.class);
// return;
// }
// There was no game identifier in the map. Use Payload as the default
getQuiverTeamModule(QuiverPayload.class);
}
@Override
@EventHandler
public void ScoreboardUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
{
return;
}
for (QuiverTeamModule module : _modules.values())
{
module.updateScoreboard();
}
}
@EventHandler
public void onGameStateChange(GameStateChangeEvent event)
{
if (event.GetState() == GameState.Prepare)
{
for (QuiverTeamModule module : _modules.values())
{
module.setup();
}
}
else if (event.GetState() == GameState.End)
{
for (QuiverTeamModule module : _modules.values())
{
module.finish();
}
}
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (!IsLive())
{
return;
}
for (QuiverTeamModule module : _modules.values())
{
module.update(event.getType());
}
}
public double getGems(GemAwardReason reason)
{
return 0.5;
}
public <T extends QuiverTeamModule> T getQuiverTeamModule(Class<T> clazz)
{
if (!_modules.containsKey(clazz))
{
try
{
_modules.put(clazz, clazz.getConstructor(QuiverTeamBase.class).newInstance(this));
}
catch (Exception e)
{
e.printStackTrace();
}
}
return clazz.cast(_modules.get(clazz));
}
public static enum GemAwardReason
{
KILL, ASSIST, KILLSTEAK, WIN
}
@EventHandler
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
if (!UtilServer.isTestServer())
{
return;
}
String cmd = event.getMessage();
Player player = event.getPlayer();
if (cmd.startsWith("/max"))
{
event.setCancelled(true);
getQuiverTeamModule(ModuleUltimate.class).incrementUltimate(player, 100);
}
else if (cmd.startsWith("/win"))
{
event.setCancelled(true);
WinnerTeam = GetTeam(event.getPlayer());
AnnounceEnd(WinnerTeam);
SetState(GameState.End);
}
else if (cmd.startsWith("/ks"))
{
event.setCancelled(true);
ModuleKillstreak killstreak = getQuiverTeamModule(ModuleKillstreak.class);
killstreak.getKillstreakAmount().put(player.getUniqueId(), Integer.parseInt(cmd.split(" ")[1]));
killstreak.getKillstreakTime().put(player.getUniqueId(), System.currentTimeMillis());
}
}
}

View File

@ -1,122 +0,0 @@
package nautilus.game.arcade.game.games.quiver.data;
import org.bukkit.Color;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.quiver.Quiver;
import nautilus.game.arcade.game.games.quiver.QuiverPayload;
public class PowerupGenerator
{
private static final int ARROWS_TO_GIVE = 1;
private static final int FIREWORK_VIEW_DISTANCE = 10;
private QuiverPayload _game;
private Location _location;
private Item _item;
private long _lastPickup;
private long _respawnDelay;
public PowerupGenerator(QuiverPayload game, Location location, long respawnDelay)
{
_game = game;
_location = location;
_lastPickup = System.currentTimeMillis();
_respawnDelay = respawnDelay;
_location.getBlock().getRelative(BlockFace.DOWN).setType(Material.IRON_BLOCK);
}
public void update()
{
if (_item != null)
{
if (!_item.isValid())
{
_item.remove();
_item = null;
}
return;
}
if (UtilTime.elapsed(_lastPickup, _respawnDelay))
{
_item = _location.getWorld().dropItem(_location, new ItemStack(Material.ARROW));
_item.setVelocity(new Vector(0, 1, 0));
_item.getLocation().getBlock().getRelative(BlockFace.DOWN).setType(Material.GOLD_BLOCK);
playFirework();
}
}
public void pickup(Player player, Item item)
{
if (_item == null)
{
return;
}
if (!_item.equals(item))
{
return;
}
if (!_game.IsAlive(player))
{
return;
}
GameTeam gameTeam = _game.GetTeam(player);
if (gameTeam == null)
{
return;
}
_item.remove();
_item = null;
_lastPickup = System.currentTimeMillis();
_location.getBlock().getRelative(BlockFace.DOWN).setType(Material.IRON_BLOCK);
player.sendMessage(F.main("Game", "You collected the resupply powerup."));
playFirework();
ItemStack itemStack = Quiver.SUPER_ARROW.clone();
itemStack.setAmount(ARROWS_TO_GIVE);
player.getInventory().addItem(itemStack);
}
private void playFirework()
{
for (Player player : UtilServer.getPlayers())
{
if (UtilMath.offset(_location, player.getLocation()) < FIREWORK_VIEW_DISTANCE)
{
UtilFirework.packetPlayFirework(player, _location, Type.BALL_LARGE, Color.YELLOW, false, true);
}
}
}
}

View File

@ -1,101 +0,0 @@
package nautilus.game.arcade.game.games.quiver.data;
import java.util.Set;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam;
public class SpawnBarrier
{
private Game _game;
private GameTeam _gameTeam;
private Set<Location> _barriers;
public SpawnBarrier(Game game, GameTeam gameTeam, Set<Location> barriers)
{
_game = game;
_gameTeam = gameTeam;
_barriers = barriers;
for (Location location : _barriers)
{
location.getBlock().setType(Material.AIR);
}
}
public void update()
{
for (Player player : _game.GetPlayers(true))
{
if (UtilPlayer.isSpectator(player))
{
continue;
}
if (_game.GetTeam(player).equals(_gameTeam))
{
continue;
}
for (Location location : _gameTeam.GetSpawns())
{
if (UtilMath.offset(player.getLocation(), location) < 5)
{
_game.Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.VOID, 9001, false, true, true, _game.GetName(), "Spawn Shield");
}
}
for (Location location : _barriers)
{
if (UtilMath.offset(player.getLocation(), location) < 4)
{
UtilAction.velocity(player, UtilAlg.getTrajectory(location, player.getLocation()).normalize().setY(0.4));
}
}
}
}
public void playParticles()
{
for (Player player : _game.GetPlayers(true))
{
if (UtilPlayer.isSpectator(player))
{
continue;
}
if (_game.GetTeam(player).equals(_gameTeam))
{
continue;
}
for (Location location : _barriers)
{
UtilParticle.PlayParticle(ParticleType.BARRIER, location.clone().add(0, 0.5, 0), 0, 0, 0, 0.1F, 1, ViewDist.SHORT, player);
}
}
}
public GameTeam getGameTeam()
{
return _gameTeam;
}
public Set<Location> getBlocks()
{
return _barriers;
}
}

View File

@ -15,7 +15,8 @@ import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.quiver.Quiver;
import nautilus.game.arcade.game.games.quiver.QuiverPayload;
import nautilus.game.arcade.game.games.quiver.QuiverTeamBase;
import nautilus.game.arcade.game.games.quiver.module.ModuleUltimate;
import nautilus.game.arcade.game.games.quiver.ultimates.UltimateBarrage;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
@ -131,9 +132,9 @@ public class KitBarrage extends ProgressingKit
return;
}
QuiverPayload quiverPayload = (QuiverPayload) Manager.GetGame();
QuiverTeamBase game = (QuiverTeamBase) Manager.GetGame();
quiverPayload.resetUltimate(Bukkit.getPlayer(player), true);
game.getQuiverTeamModule(ModuleUltimate.class).resetUltimate(Bukkit.getPlayer(player), true);
}
@Override

View File

@ -15,7 +15,8 @@ import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.quiver.Quiver;
import nautilus.game.arcade.game.games.quiver.QuiverPayload;
import nautilus.game.arcade.game.games.quiver.QuiverTeamBase;
import nautilus.game.arcade.game.games.quiver.module.ModuleUltimate;
import nautilus.game.arcade.game.games.quiver.ultimates.UltimateBeserker;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
@ -100,7 +101,7 @@ public class KitBeserker extends ProgressingKit
public KitBeserker(ArcadeManager manager)
{
super(manager, "Berserker", "quiverbeserker", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND);
super(manager, "Berserker", "quiverbeserker", KitAvailability.Gem, 4000, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND);
}
@Override
@ -126,9 +127,9 @@ public class KitBeserker extends ProgressingKit
return;
}
QuiverPayload quiverPayload = (QuiverPayload) Manager.GetGame();
QuiverTeamBase game = (QuiverTeamBase) Manager.GetGame();
quiverPayload.resetUltimate(Bukkit.getPlayer(player), true);
game.getQuiverTeamModule(ModuleUltimate.class).resetUltimate(Bukkit.getPlayer(player), true);
}
@Override

View File

@ -15,7 +15,8 @@ import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.quiver.Quiver;
import nautilus.game.arcade.game.games.quiver.QuiverPayload;
import nautilus.game.arcade.game.games.quiver.QuiverTeamBase;
import nautilus.game.arcade.game.games.quiver.module.ModuleUltimate;
import nautilus.game.arcade.game.games.quiver.ultimates.UltimateNecromancer;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
@ -99,7 +100,7 @@ public class KitNecromancer extends ProgressingKit
public KitNecromancer(ArcadeManager manager)
{
super(manager, "Necromancer", "quivernecromancer", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND);
super(manager, "Necromancer", "quivernecromancer", KitAvailability.Gem, 4000, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND);
}
@ -126,9 +127,9 @@ public class KitNecromancer extends ProgressingKit
return;
}
QuiverPayload quiverPayload = (QuiverPayload) Manager.GetGame();
QuiverTeamBase game = (QuiverTeamBase) Manager.GetGame();
quiverPayload.resetUltimate(Bukkit.getPlayer(player), true);
game.getQuiverTeamModule(ModuleUltimate.class).resetUltimate(Bukkit.getPlayer(player), true);
}
@Override

View File

@ -11,7 +11,8 @@ import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.quiver.QuiverPayload;
import nautilus.game.arcade.game.games.quiver.QuiverTeamBase;
import nautilus.game.arcade.game.games.quiver.module.ModuleUltimate;
import nautilus.game.arcade.game.games.quiver.ultimates.UltimateNinja;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
@ -98,7 +99,7 @@ public class KitNewNinja extends ProgressingKit
public KitNewNinja(ArcadeManager manager)
{
super(manager, "Ninja", "quivernewninja", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND);
super(manager, "Ninja", "quivernewninja", KitAvailability.Gem, 6000, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND);
}
@Override
@ -117,9 +118,9 @@ public class KitNewNinja extends ProgressingKit
return;
}
QuiverPayload quiverPayload = (QuiverPayload) Manager.GetGame();
QuiverTeamBase game = (QuiverTeamBase) Manager.GetGame();
quiverPayload.resetUltimate(Bukkit.getPlayer(player), true);
game.getQuiverTeamModule(ModuleUltimate.class).resetUltimate(Bukkit.getPlayer(player), true);
}
@Override

View File

@ -15,7 +15,8 @@ import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.quiver.Quiver;
import nautilus.game.arcade.game.games.quiver.QuiverPayload;
import nautilus.game.arcade.game.games.quiver.QuiverTeamBase;
import nautilus.game.arcade.game.games.quiver.module.ModuleUltimate;
import nautilus.game.arcade.game.games.quiver.ultimates.UltimatePyromancer;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
@ -102,7 +103,7 @@ public class KitPyromancer extends ProgressingKit
public KitPyromancer(ArcadeManager manager)
{
super(manager, "Pyromancer", "quiverpyromancer", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND);
super(manager, "Pyromancer", "quiverpyromancer", KitAvailability.Gem, 6000, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND);
}
@ -129,9 +130,9 @@ public class KitPyromancer extends ProgressingKit
return;
}
QuiverPayload quiverPayload = (QuiverPayload) Manager.GetGame();
QuiverTeamBase game = (QuiverTeamBase) Manager.GetGame();
quiverPayload.resetUltimate(Bukkit.getPlayer(player), true);
game.getQuiverTeamModule(ModuleUltimate.class).resetUltimate(Bukkit.getPlayer(player), true);
}
@Override

View File

@ -1,4 +1,4 @@
package nautilus.game.arcade.game.games.quiver.kits;
package nautilus.game.arcade.game.games.quiver.kits;
import java.util.UUID;
@ -8,6 +8,7 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.achievement.Achievement;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilServer;
@ -15,7 +16,8 @@ import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.quiver.Quiver;
import nautilus.game.arcade.game.games.quiver.QuiverPayload;
import nautilus.game.arcade.game.games.quiver.QuiverTeamBase;
import nautilus.game.arcade.game.games.quiver.module.ModuleUltimate;
import nautilus.game.arcade.game.games.quiver.ultimates.UltimateSkyWarrior;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
@ -112,10 +114,21 @@ public class KitSkyWarrior extends ProgressingKit
new ItemBuilder(Material.IRON_AXE).setUnbreakable(true).build(),
new ItemBuilder(Material.BOW).setUnbreakable(true).build(),
};
private static final Achievement[] ACHIEVEMENTS =
{
Achievement.QUIVER_PAYLOAD_ASSASSIN,
Achievement.QUIVER_PAYLOAD_BLOSSOM,
Achievement.QUIVER_PAYLOAD_BOW,
Achievement.QUIVER_PAYLOAD_STEADY_HANDS,
Achievement.QUIVER_PAYLOAD_UNSTOPPABLE
};
public KitSkyWarrior(ArcadeManager manager)
{
super(manager, "Sky Warrior", "quiverskywarrior", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND);
super(manager, "Sky Warrior", "quiverskywarrior", KitAvailability.Achievement, 5000, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND);
setAchievementRequirements(ACHIEVEMENTS);
}
@Override
@ -141,9 +154,9 @@ public class KitSkyWarrior extends ProgressingKit
return;
}
QuiverPayload quiverPayload = (QuiverPayload) Manager.GetGame();
QuiverTeamBase game = (QuiverTeamBase) Manager.GetGame();
quiverPayload.resetUltimate(Bukkit.getPlayer(player), true);
game.getQuiverTeamModule(ModuleUltimate.class).resetUltimate(Bukkit.getPlayer(player), true);
}
@Override

View File

@ -0,0 +1,264 @@
package nautilus.game.arcade.game.games.quiver.module;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilFirework;
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.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextTop;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.quiver.QuiverTeamBase;
public class ModuleCapturePoint extends QuiverTeamModule
{
private static final String DATA_POINT_CENTER = "BLACK";
private static final String DATA_POINT_CICRLE = "GRAY";
private static final double CIRCLE_INCREMENTATION = Math.PI / 40;
private static final int TO_CAPTURE = 25;
private static final float ULTIMATE_PERCENTAGE_CAPTURE = 0.2F;
private Location _centre;
private Location _circlePoint;
private Block _beaconColour;
private double _radius;
private int _redPlayers;
private int _bluePlayers;
// The amount a team has captured is represented as an integer with -25
// being Team A and 25 being Team B has captured.
private int _capture;
private int _captureToReturn;
private GameTeam _capturedTeam;
private CaptureState _captureState;
public ModuleCapturePoint(QuiverTeamBase base)
{
super(base);
}
@Override
public void setup()
{
_centre = getBase().WorldData.GetDataLocs(DATA_POINT_CENTER).get(0);
_circlePoint = getBase().WorldData.GetDataLocs(DATA_POINT_CICRLE).get(0);
_beaconColour = _centre.getBlock().getRelative(BlockFace.DOWN);
_beaconColour.setType(Material.STAINED_GLASS);
_radius = UtilMath.offset2d(_centre, _circlePoint);
_capture = 0;
_captureToReturn = 0;
_captureState = CaptureState.NONE;
}
@SuppressWarnings("deprecation")
@Override
public void update(UpdateType updateType)
{
if (updateType != UpdateType.FAST)
{
return;
}
Bukkit.broadcastMessage(_captureState.name() + " " + _capture);
GameTeam gameTeamA = getBase().GetTeam(ChatColor.RED), gameTeamB = getBase().GetTeam(ChatColor.AQUA);
int gameTeamACount = 0, gameTeamBCount = 0;
for (Player player : UtilPlayer.getNearby(_centre, _radius))
{
if (UtilPlayer.isSpectator(player))
{
continue;
}
GameTeam gameTeam = getBase().GetTeam(player);
if (gameTeamA.equals(gameTeam))
{
gameTeamACount++;
}
else
{
gameTeamBCount++;
}
getBase().getQuiverTeamModule(ModuleUltimate.class).incrementUltimate(player, ULTIMATE_PERCENTAGE_CAPTURE);
}
_redPlayers = gameTeamACount;
_bluePlayers = gameTeamBCount;
displayParticles();
if (gameTeamACount > gameTeamBCount && gameTeamBCount == 0)
{
if (!gameTeamA.equals(_capturedTeam))
{
_capture += gameTeamACount;
_captureState = CaptureState.CAPTURING;
}
else
{
returnTo();
}
}
else if (gameTeamACount < gameTeamBCount && gameTeamACount == 0)
{
if (!gameTeamB.equals(_capturedTeam))
{
_capture -= gameTeamBCount;
_captureState = CaptureState.CAPTURING;
}
else
{
returnTo();
}
}
else
{
if (gameTeamACount > 0 && gameTeamBCount > 0)
{
_captureState = CaptureState.CONTESTED;
}
else
{
returnTo();
}
displayProgress();
return;
}
displayProgress();
GameTeam mostPlayers = null;
if (_capture == TO_CAPTURE)
{
mostPlayers = gameTeamA;
_captureToReturn = TO_CAPTURE;
}
else if (_capture == -TO_CAPTURE)
{
mostPlayers = gameTeamB;
_captureToReturn = -TO_CAPTURE;
}
if (mostPlayers != null && _captureState != CaptureState.CAPTURED)
{
_capturedTeam = mostPlayers;
_captureState = CaptureState.CAPTURED;
_beaconColour.setData(_capturedTeam.GetColorData());
UtilFirework.playFirework(_centre, Type.BALL_LARGE, _capturedTeam.GetColorBase(), false, false);
UtilServer.broadcast(mostPlayers.GetFormattedName() + " Captured The Point!");
}
}
@Override
public void finish()
{
}
public static enum CaptureState
{
NONE, CONTESTED, CAPTURING, CAPTURED;
}
private void returnTo()
{
if (_capture == _captureToReturn)
{
return;
}
if (_capture > _captureToReturn)
{
_capture--;
}
else
{
_capture++;
}
_captureState = _capturedTeam == null ? CaptureState.NONE : CaptureState.CAPTURED;
}
private void displayParticles()
{
for (double t = 0; t < 2 * Math.PI; t += CIRCLE_INCREMENTATION)
{
double x = _radius * Math.cos(t);
double z = _radius * Math.sin(t);
_centre.add(x, 0.5, z);
if (UtilBlock.airFoliage(_centre.getBlock()))
{
UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, _centre, 0.05F, 0.05F, 0.05F, 0.001F, 1, ViewDist.NORMAL);
}
_centre.subtract(x, 0.5, z);
}
}
private void displayProgress()
{
String progress;
if (_capture == 0)
{
progress = C.cWhite;
}
else if (_capture > 0)
{
progress = C.cRed;
}
else
{
progress = C.cAqua;
}
for (int i = 0; i < TO_CAPTURE; i++)
{
if (i == Math.abs(_capture))
{
progress += _captureState == CaptureState.CONTESTED ? C.cPurple : C.cWhite;
}
progress += "";
}
UtilTextTop.display(C.cRed + _redPlayers + " " + progress + " " + C.cAqua + _bluePlayers, UtilServer.getPlayers());
}
public GameTeam getCapturedTeam()
{
return _capturedTeam;
}
public CaptureState getState()
{
return _captureState;
}
}

View File

@ -0,0 +1,159 @@
package nautilus.game.arcade.game.games.quiver.module;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.quiver.QuiverTeamBase;
import nautilus.game.arcade.game.games.quiver.QuiverTeamBase.GemAwardReason;
public class ModuleKillstreak extends QuiverTeamModule
{
private static final long KILLSTREAK_TIME_PERIOD = 1500;
private static final long TEAM_KILL_MINIMUM_DELAY = 20000;
private static final int TEAM_KILL_MINIMUM_PLAYERS = 6;
private Map<UUID, Integer> _killstreakAmount = new HashMap<>();
private Map<UUID, Long> _killstreamLast = new HashMap<>();
private long _lastTeamKill;
public ModuleKillstreak(QuiverTeamBase base)
{
super(base);
}
@Override
public void setup()
{
}
@Override
public void update(UpdateType updateType)
{
if (updateType != UpdateType.FAST)
{
return;
}
if (getBase().GetPlayers(true).size() >= TEAM_KILL_MINIMUM_PLAYERS)
{
for (GameTeam gameTeam : getBase().GetTeamList())
{
if (!UtilTime.elapsed(_lastTeamKill, TEAM_KILL_MINIMUM_DELAY))
{
break;
}
boolean gameTeamKill = true;
for (Player player : gameTeam.GetPlayers(false))
{
if (!UtilPlayer.isSpectator(player))
{
gameTeamKill = false;
}
}
if (gameTeamKill)
{
String message = gameTeam.GetColor() + C.Bold + "DOMINATION";
UtilTextMiddle.display(message, "", 10, 30, 10);
UtilServer.broadcast(message);
_lastTeamKill = System.currentTimeMillis();
}
}
}
for (Player player : getBase().GetPlayers(true))
{
if (_killstreamLast.containsKey(player.getUniqueId()) && _killstreakAmount.containsKey(player.getUniqueId()))
{
long lastKill = _killstreamLast.get(player.getUniqueId());
int kills = _killstreakAmount.get(player.getUniqueId());
if (UtilTime.elapsed(lastKill, KILLSTREAK_TIME_PERIOD))
{
if (kills > 1)
{
String name = null;
switch (kills)
{
case 3:
name = "TRIPLE";
break;
case 4:
name = "QUADRA";
break;
case 5:
name = "PENTA";
break;
case 6:
name = "HEXA";
break;
case 7:
name = "SEPTA";
break;
case 8:
name = "OCTA";
break;
case 9:
name = "NONA";
break;
case 10:
name = "DECA";
break;
}
if (kills >= 3)
{
getBase().AddStat(player, "SteadyHands", 1, false, false);
}
if (name != null)
{
for (Player other : UtilServer.getPlayers())
{
other.playSound(other.getLocation(), Sound.ENDERDRAGON_GROWL, 1F + kills, 1f + kills);
}
getBase().AddGems(player, getBase().getGems(GemAwardReason.KILLSTEAK) * kills, name + " Killstreak", true, true);
UtilServer.broadcast(C.cGreenB + player.getName() + C.cWhite + " got a " + C.cGreenB + name + " KILL" + C.cWhite + "!");
}
}
_killstreakAmount.put(player.getUniqueId(), 0);
}
}
}
}
@Override
public void finish()
{
}
public Map<UUID, Integer> getKillstreakAmount()
{
return _killstreakAmount;
}
public Map<UUID, Long> getKillstreakTime()
{
return _killstreamLast;
}
}

View File

@ -0,0 +1,116 @@
package nautilus.game.arcade.game.games.quiver.module;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.quiver.QuiverTeamBase;
import nautilus.game.arcade.kit.ProgressingKit;
public class ModuleKitNPCS extends QuiverTeamModule implements Listener
{
private static final String DATA_POINT_KIT_RED = "ORANGE";
private static final String DATA_POINT_KIT_BLUE = "LIGHT_BLUE";
private Map<Entity, ProgressingKit> _kitNPC = new HashMap<>();
public ModuleKitNPCS(QuiverTeamBase base)
{
super(base);
}
@Override
public void setup()
{
getBase().Manager.registerEvents(this);
getBase().CreatureAllowOverride = true;
spawnKitNPCs(getBase().WorldData.GetDataLocs(DATA_POINT_KIT_RED), getBase().GetTeam(ChatColor.RED));
spawnKitNPCs(getBase().WorldData.GetDataLocs(DATA_POINT_KIT_BLUE), getBase().GetTeam(ChatColor.AQUA));
getBase().CreatureAllowOverride = false;
}
@Override
public void update(UpdateType updateType)
{
}
@Override
public void finish()
{
UtilServer.Unregister(this);
}
@EventHandler
public void onEntityCombust(EntityCombustEvent event)
{
if (isKitNPC(event.getEntity()))
{
event.setCancelled(true);
}
}
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event)
{
if (isKitNPC(event.getRightClicked()) && !UtilPlayer.isSpectator(event.getPlayer()))
{
ProgressingKit progressingKit = _kitNPC.get(event.getRightClicked());
getBase().Manager.getProgressionKitManager().entityClick(event.getPlayer(), progressingKit);
}
}
@EventHandler
public void onCustomDamage(CustomDamageEvent event)
{
if (isKitNPC(event.GetDamageeEntity()))
{
event.SetCancelled("Kit NPC");
}
}
private void spawnKitNPCs(List<Location> locations, GameTeam gameTeam)
{
int i = 0;
Location spawnsAverage = UtilAlg.getAverageLocation(gameTeam.GetSpawns()).subtract(0, 1, 0);
for (Location location : locations)
{
if (i >= getBase().GetKits().length)
{
break;
}
Entity entity = getBase().GetKits()[i].SpawnEntity(location);
ProgressingKit progressingKit = (ProgressingKit) getBase().GetKits()[i++];
UtilEnt.CreatureLook(entity, spawnsAverage);
_kitNPC.put(entity, progressingKit);
}
}
private boolean isKitNPC(Entity entity)
{
return _kitNPC.containsKey(entity);
}
}

View File

@ -0,0 +1,507 @@
package nautilus.game.arcade.game.games.quiver.module;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.vehicle.VehicleDamageEvent;
import org.bukkit.event.vehicle.VehicleEnterEvent;
import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
import org.bukkit.event.vehicle.VehicleMoveEvent;
import org.bukkit.material.MaterialData;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scoreboard.Team;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextTop;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.quiver.QuiverTeamBase;
public class ModulePayload extends QuiverTeamModule implements Listener
{
private static final double PAYLOAD_CAPTURE_RANGE = 4;
private static final float PAYLOAD_VELOCITY = 0.2F;
private static final int PAYLOAD_MARKER_MAX_DISTANCE = 2;
private static final int PAYLOAD_RENGERATION_DURATION = 3 * 20;
private static final int PAYLOAD_RENGERATION_AMPLIFIER = 1;
private static final float ULTIMATE_PERCENTAGE_PAYLOAD = 0.2F;
private static final String DATA_POINT_MARKER_START = "PINK";
public static final String DATA_POINT_RED = "RED";
public static final String DATA_POINT_BLUE = "BLUE";
public static final String DATA_POINT_PAYLOAD = "BLACK";
private Minecart _minecart;
private GameTeam _teamDirection;
private int _targetIndex;
private boolean _hasMoved;
private boolean _recentlyChanged;
private double _totalDistance;
private List<Location> _pathMarkers = new ArrayList<>();
private PayloadState _payloadState;
private Team _payloadTeam;
public ModulePayload(QuiverTeamBase base)
{
super(base);
_payloadState = PayloadState.NONE;
}
@Override
public void setup()
{
getBase().Manager.registerEvents(this);
_payloadTeam = getBase().GetScoreboard().getHandle().registerNewTeam("payloadTeam");
_minecart = getBase().WorldData.World.spawn(getBase().WorldData.GetDataLocs(DATA_POINT_PAYLOAD).get(0), Minecart.class);
_minecart.spigot().forceGlowing(true);
_minecart.setDisplayBlock(new MaterialData(Material.TNT));
_payloadTeam.addEntry(_minecart.getUniqueId().toString());
/*
* The payload which is represented as a minecart follows a linear path
* connecting the two gameTeam's bases. The logic used to calculate the
* path that the minecart takes is done below.
*
* Initially we need to get a constant point we will use to start our
* calculations. This is a DATA_POINT_MARKER_START coloured data point.
* This is placed at the red gameTeam's base, at the end of the track.
*/
Location start = getBase().WorldData.GetDataLocs(DATA_POINT_MARKER_START).get(0);
Location last = start;
ArrayList<Location> dataPoints = new ArrayList<>();
/*
* The dataPoints ArrayList is an unordered list of all the data points.
* We add the start location and all red and blue data points.
*
* We use red and blue data points so that it is easier for the builders
* to see which direction the minecart would move when a certain
* gameTeam moved the minecart.
*
* Data points are placed above the track, they should be placed at
* intervals along the track where it is ensured that the next data
* point along the track is the closest relative to all other data
* points in the map as well on any point where the track curves.
*
*/
dataPoints.add(start);
dataPoints.addAll(getBase().WorldData.GetDataLocs(DATA_POINT_RED));
dataPoints.addAll(getBase().WorldData.GetDataLocs(DATA_POINT_BLUE));
/*
* While there are locations still left in the list, we search for the
* nearest different data point and add it to a new list, this list
* contains all the data points sorted in the correct order of the
* track's path.
*/
while (!dataPoints.isEmpty())
{
Location dataPoint = UtilAlg.findClosest(last, dataPoints);
_pathMarkers.add(dataPoint);
dataPoints.remove(dataPoint);
last = dataPoint;
}
/*
* We need to calculate the total linear distance between all the stored
* data points. This is used later when displaying the Dragon/Wither
* progression bar.
*/
for (int i = 1; i < _pathMarkers.size(); i++)
{
_totalDistance += UtilMath.offset(_pathMarkers.get(i - 1), _pathMarkers.get(i));
}
}
@Override
public void update(UpdateType updateType)
{
if (updateType != UpdateType.FAST || _minecart == null)
{
return;
}
if (_payloadState.equals(PayloadState.RESTARTING))
{
UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, _minecart.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 1, 10, ViewDist.LONG);
return;
}
/*
* In order to determine which direction the payload will move we
* calculate how many players are within PAYLOAD_CAPURE_RANGE blocks of
* the payload.
*/
int gameTeamACount = 0, gameTeamBCount = 0;
for (Player player : UtilPlayer.getNearby(_minecart.getLocation(), PAYLOAD_CAPTURE_RANGE))
{
GameTeam gameTeam = getBase().GetTeam(player);
if (getBase().GetTeamList().get(0).equals(gameTeam))
{
gameTeamACount++;
}
else
{
gameTeamBCount++;
}
player.removePotionEffect(PotionEffectType.REGENERATION);
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, PAYLOAD_RENGERATION_DURATION, PAYLOAD_RENGERATION_AMPLIFIER));
getBase().getQuiverTeamModule(ModuleUltimate.class).incrementUltimate(player, ULTIMATE_PERCENTAGE_PAYLOAD);
}
UtilTextTop.display(getTopBar(), UtilServer.getPlayers());
/*
* _recentlyChanged is used to show that on the targetIndex needs to be
* updated as the payload's direction has changed.
*/
if (gameTeamACount > gameTeamBCount && gameTeamBCount == 0)
{
if (_teamDirection != null)
{
if (!_teamDirection.equals(getBase().GetTeamList().get(0)))
{
setMinecartTeam(getBase().GetTeamList().get(0));
_recentlyChanged = true;
}
}
_teamDirection = getBase().GetTeamList().get(0);
}
else if (gameTeamACount < gameTeamBCount && gameTeamACount == 0)
{
if (_teamDirection != null)
{
if (!_teamDirection.equals(getBase().GetTeamList().get(1)))
{
setMinecartTeam(getBase().GetTeamList().get(1));
_recentlyChanged = true;
}
}
_teamDirection = getBase().GetTeamList().get(1);
}
else
{
if (gameTeamACount > 0 && gameTeamBCount > 0)
{
_payloadState = PayloadState.CONTESTED;
}
else
{
_payloadState = PayloadState.NONE;
}
setMinecartTeam(_payloadState);
UtilAction.zeroVelocity(_minecart);
return;
}
setMinecartTeam(_teamDirection);
_payloadState = PayloadState.MOVING;
if (_teamDirection.equals(getBase().GetTeamList().get(0)))
{
// If the minecart has never moved
if (!_hasMoved)
{
_targetIndex = _pathMarkers.size() / 2;
}
else if (isMinecartNearMarker(_pathMarkers.get(_targetIndex)) || _recentlyChanged)
{
_targetIndex++;
_recentlyChanged = false;
}
}
else
{
// If the minecart has never moved
if (!_hasMoved)
{
_targetIndex = _pathMarkers.size() / 2 - 2;
}
else if (isMinecartNearMarker(_pathMarkers.get(_targetIndex)) || _recentlyChanged)
{
_targetIndex--;
_recentlyChanged = false;
}
}
/*
* The minecart's velocity is set to the vector between the the
* minecart's current location and the next data point it will reach.
*/
_minecart.setVelocity(UtilAlg.getTrajectory(_minecart.getLocation(), _pathMarkers.get(_targetIndex)).normalize().multiply(PAYLOAD_VELOCITY));
_hasMoved = true;
}
@Override
public void finish()
{
UtilServer.Unregister(this);
}
public boolean isMinecartNearMarker(Location marker)
{
return isMinecartNearMarker(marker, PAYLOAD_MARKER_MAX_DISTANCE);
}
public boolean isMinecartNearMarker(Location marker, double distance)
{
return UtilMath.offset(_minecart.getLocation(), marker) < distance;
}
public double getTrackDistanceToMarker(Location marker)
{
return getTrackDistanceToMarker(marker, _teamDirection);
}
public double getTrackDistanceToMarker(Location marker, GameTeam gameTeam)
{
double distance = 0;
if (_minecart == null)
{
return distance;
}
if (gameTeam == null)
{
return _totalDistance / 2;
}
if (_targetIndex > _pathMarkers.size() - 1 || _targetIndex < 0)
{
return distance;
}
if (gameTeam.equals(_teamDirection))
{
distance += UtilMath.offset(_minecart.getLocation(), _pathMarkers.get(_targetIndex));
}
if (getBase().GetTeamList().get(0).equals(gameTeam))
{
if (!gameTeam.equals(_teamDirection))
{
if (_targetIndex < _pathMarkers.size() - 1)
{
distance += UtilMath.offset(_minecart.getLocation(), _pathMarkers.get(_targetIndex + 1));
}
else
{
distance += UtilMath.offset(_minecart.getLocation(), _pathMarkers.get(_pathMarkers.size() - 1));
}
}
for (int i = _targetIndex + 1; i < _pathMarkers.size(); i++)
{
distance += UtilMath.offset(_pathMarkers.get(i - 1), _pathMarkers.get(i));
}
}
else
{
if (!gameTeam.equals(_teamDirection))
{
if (_targetIndex > 0)
{
distance += UtilMath.offset(_minecart.getLocation(), _pathMarkers.get(_targetIndex - 1));
}
else
{
// distance += UtilMath.offset(_minecart.getLocation(),
// _pathMarkers.get(0));
}
}
for (int i = _targetIndex - 1; i >= 0; i--)
{
distance += UtilMath.offset(_pathMarkers.get(i + 1), _pathMarkers.get(i));
}
}
return distance;
}
public Location getDestination(GameTeam gameTeam)
{
if (getBase().GetTeamList().get(0).equals(gameTeam))
{
return _pathMarkers.get(_pathMarkers.size() - 1);
}
return _pathMarkers.get(0);
}
public void resetMinecart()
{
_payloadState = PayloadState.RESTARTING;
setMinecartTeam(_payloadState);
_hasMoved = false;
_recentlyChanged = false;
UtilAction.zeroVelocity(_minecart);
}
@EventHandler
public void onVehicleEntityCollision(VehicleEntityCollisionEvent event)
{
if (event.getVehicle() instanceof Minecart)
{
event.setCollisionCancelled(true);
event.setCancelled(true);
}
}
@EventHandler
public void onVehicleDamage(VehicleDamageEvent event)
{
if (event.getVehicle() instanceof Minecart)
{
event.setCancelled(true);
}
}
@EventHandler
public void onVehicleEnter(VehicleEnterEvent event)
{
if (event.getVehicle() instanceof Minecart)
{
event.setCancelled(true);
}
}
@EventHandler
public void onVehicleMove(VehicleMoveEvent event)
{
Vehicle vehicle = event.getVehicle();
if (vehicle instanceof Minecart && vehicle.getVelocity().lengthSquared() > (PAYLOAD_VELOCITY * PAYLOAD_VELOCITY))
{
vehicle.setVelocity(vehicle.getVelocity().normalize().multiply(PAYLOAD_VELOCITY));
}
}
public void setMinecartTeam(GameTeam gameTeam)
{
_payloadTeam.setPrefix(gameTeam.GetColor().toString());
}
public void setMinecartTeam(PayloadState payloadState)
{
switch (payloadState)
{
case RESTARTING:
_payloadTeam.setPrefix(C.cGreen);
break;
case CONTESTED:
_payloadTeam.setPrefix(C.cPurple);
break;
case NONE:
_payloadTeam.setPrefix(C.cWhite);
break;
default:
break;
}
}
public String getTopBar()
{
String progress = C.cAqua;
GameTeam gameTeamA = getBase().GetTeamList().get(0);
int percentage = (int) (((int) getTrackDistanceToMarker(getDestination(gameTeamA), gameTeamA) / _totalDistance) * 100);
boolean switched = false;
if (_teamDirection == null)
{
percentage = 50;
}
for (int i = 0; i < 25; i++)
{
if (percentage / 4 == i)
{
switched = true;
progress += C.cWhite + "" + C.cRed;
}
else if (switched)
{
progress += "<";
}
else
{
progress += ">";
}
}
return C.cAqua + "" + C.cWhite + "[ " + progress + C.cWhite + " ]" + C.cRed + "";
}
public void setState(PayloadState payloadState)
{
_payloadState = payloadState;
}
public Minecart getMinecart()
{
return _minecart;
}
public PayloadState getState()
{
return _payloadState;
}
public GameTeam getTeamDirection()
{
return _teamDirection;
}
public List<Location> getPathMarkers()
{
return _pathMarkers;
}
public static enum PayloadState
{
NONE, MOVING, CONTESTED, RESTARTING;
}
}

View File

@ -0,0 +1,184 @@
package nautilus.game.arcade.game.games.quiver.module;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.Color;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.quiver.Quiver;
import nautilus.game.arcade.game.games.quiver.QuiverTeamBase;
public class ModulePowerup extends QuiverTeamModule implements Listener
{
private static final int ARROWS_TO_GIVE = 1;
private static final int FIREWORK_VIEW_DISTANCE = 10;
private static final String DATA_POINT_POWERUP = "YELLOW";
private Set<PowerupData> _data = new HashSet<>();
private long _respawnDelay;
public ModulePowerup(QuiverTeamBase base)
{
super(base);
_respawnDelay = 20000;
}
@Override
public void setup()
{
getBase().Manager.registerEvents(this);
for (Location location : getBase().WorldData.GetDataLocs(DATA_POINT_POWERUP))
{
_data.add(new PowerupData(location));
}
}
@Override
public void update(UpdateType updateType)
{
if (updateType != UpdateType.SEC)
{
return;
}
for (PowerupData data : _data)
{
data.update();
}
}
@Override
public void finish()
{
UtilServer.Unregister(this);
}
public void setRespawnDelay(long respawnDelay)
{
_respawnDelay = respawnDelay;
}
private void playFirework(Location location)
{
for (Player player : UtilServer.getPlayers())
{
if (UtilMath.offset(location, player.getLocation()) < FIREWORK_VIEW_DISTANCE)
{
UtilFirework.packetPlayFirework(player, location, Type.BALL_LARGE, Color.YELLOW, false, true);
}
}
}
@EventHandler
public void onPlayerPickupItem(PlayerPickupItemEvent event)
{
for (PowerupData data : _data)
{
data.pickup(event.getPlayer(), event.getItem());
}
}
private class PowerupData
{
private Location _location;
private Item _item;
private long _lastPickup;
public PowerupData(Location location)
{
_location = location;
_lastPickup = System.currentTimeMillis();
location.getBlock().getRelative(BlockFace.DOWN).setType(Material.IRON_BLOCK);
}
public void update()
{
if (_item != null)
{
if (!_item.isValid())
{
_item.remove();
_item = null;
}
return;
}
if (UtilTime.elapsed(_lastPickup, _respawnDelay))
{
_item = _location.getWorld().dropItem(_location, new ItemStack(Material.ARROW));
_item.setVelocity(new Vector(0, 1, 0));
_item.getLocation().getBlock().getRelative(BlockFace.DOWN).setType(Material.GOLD_BLOCK);
playFirework(_location);
}
}
public void pickup(Player player, Item item)
{
if (_item == null)
{
return;
}
if (!_item.equals(item))
{
return;
}
if (UtilPlayer.isSpectator(player))
{
return;
}
GameTeam gameTeam = getBase().GetTeam(player);
if (gameTeam == null)
{
return;
}
_item.remove();
_item = null;
_lastPickup = System.currentTimeMillis();
_location.getBlock().getRelative(BlockFace.DOWN).setType(Material.IRON_BLOCK);
player.sendMessage(F.main("Game", "You collected the resupply powerup."));
playFirework(_location);
ItemStack itemStack = Quiver.SUPER_ARROW.clone();
itemStack.setAmount(ARROWS_TO_GIVE);
player.getInventory().addItem(itemStack);
}
}
}

View File

@ -0,0 +1,142 @@
package nautilus.game.arcade.game.games.quiver.module;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
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.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.quiver.QuiverTeamBase;
public class ModuleSpawnBarrier extends QuiverTeamModule implements Listener
{
private static final int DAMAGE_RADIUS = 5;
private static final int VELOCITY_RADIUS = 4;
private static final String CUSTOM_LOCATION_BARRIER_RED = "73";
private static final String CUSTOM_LOCATION_BARRIER_BLUE = "21";
private Map<GameTeam, List<Location>> _barriers = new HashMap<>();
public ModuleSpawnBarrier(QuiverTeamBase base)
{
super(base);
}
@Override
public void setup()
{
getBase().Manager.registerEvents(this);
_barriers.put(getBase().GetTeam(ChatColor.RED), getBase().WorldData.GetCustomLocs(CUSTOM_LOCATION_BARRIER_RED));
_barriers.put(getBase().GetTeam(ChatColor.AQUA), getBase().WorldData.GetCustomLocs(CUSTOM_LOCATION_BARRIER_BLUE));
for (List<Location> list : _barriers.values())
{
for (Location location : list)
{
location.getBlock().setType(Material.AIR);
}
}
}
@Override
public void update(UpdateType updateType)
{
if (updateType == UpdateType.FAST)
{
for (GameTeam gameTeam : _barriers.keySet())
{
for (Player player : getBase().GetPlayers(true))
{
if (UtilPlayer.isSpectator(player))
{
continue;
}
if (getBase().GetTeam(player).equals(gameTeam))
{
continue;
}
for (Location location : gameTeam.GetSpawns())
{
if (UtilMath.offset(player.getLocation(), location) < DAMAGE_RADIUS)
{
getBase().Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.VOID, 9001, false, true, true, getBase().GetName(), "Spawn Shield");
}
}
for (Location location : _barriers.get(gameTeam))
{
if (UtilMath.offset(player.getLocation(), location) < VELOCITY_RADIUS)
{
UtilAction.velocity(player, UtilAlg.getTrajectory(location, player.getLocation()).normalize().setY(0.4));
}
}
}
}
}
else if (updateType == UpdateType.SEC)
{
for (GameTeam gameTeam : _barriers.keySet())
{
for (Player player : getBase().GetPlayers(true))
{
if (UtilPlayer.isSpectator(player))
{
continue;
}
if (getBase().GetTeam(player).equals(gameTeam))
{
continue;
}
for (Location location : _barriers.get(gameTeam))
{
UtilParticle.PlayParticle(ParticleType.BARRIER, location.clone().add(0, 0.5, 0), 0, 0, 0, 0.1F, 1, ViewDist.SHORT, player);
}
}
}
}
}
@Override
public void finish()
{
UtilServer.Unregister(this);
}
@EventHandler
public void onCustomDamage(CustomDamageEvent event)
{
if (event.GetDamageeEntity() instanceof Player)
{
Player player = event.GetDamageePlayer();
if (UtilMath.offset(player.getLocation(), UtilAlg.findClosest(player.getLocation(), getBase().GetTeam(player).GetSpawns())) < DAMAGE_RADIUS)
{
event.SetCancelled("Spawn Shield");
}
}
}
}

View File

@ -0,0 +1,116 @@
package nautilus.game.arcade.game.games.quiver.module;
import org.bukkit.Material;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.quiver.Quiver;
import nautilus.game.arcade.game.games.quiver.QuiverTeamBase;
import nautilus.game.arcade.game.games.quiver.kits.KitNewNinja;
public class ModuleSuperArrow extends QuiverTeamModule implements Listener
{
private static final String SUPER_ARROW_DAMAGE_SOURCE = "Projectile";
public static final String SUPER_ARROW_DAMAGE_REASON = "Instagib";
private static final double SUPER_ARROW_DAMAGE_MOD = 9001;
private static final int RESPAWN_ARROW_GIVE_DELAY = 20;
public ModuleSuperArrow(QuiverTeamBase base)
{
super(base);
}
@Override
public void setup()
{
getBase().Manager.registerEvents(this);
}
@Override
public void update(UpdateType updateType)
{
}
@Override
public void finish()
{
UtilServer.Unregister(this);
}
@EventHandler
public void onCustomDamage(CustomDamageEvent event)
{
if (event.GetDamageeEntity() instanceof Player)
{
if (event.GetProjectile() != null)
{
if (event.GetProjectile() instanceof Arrow)
{
event.AddMod(SUPER_ARROW_DAMAGE_SOURCE, SUPER_ARROW_DAMAGE_REASON, SUPER_ARROW_DAMAGE_MOD, false);
event.SetKnockback(false);
}
}
}
}
@EventHandler
public void onCombatDeath(CombatDeathEvent event)
{
if (event.GetEvent().getEntity() == null || !event.GetLog().GetKiller().IsPlayer())
{
return;
}
if (!(event.GetEvent().getEntity() instanceof Player))
{
return;
}
Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
Player killed = (Player) event.GetEvent().getEntity();
if (player == null)
{
return;
}
player.getInventory().addItem(Quiver.SUPER_ARROW);
if (getBase().GetKit(killed) instanceof KitNewNinja)
{
return;
}
new BukkitRunnable()
{
@Override
public void run()
{
if (!killed.getInventory().contains(Material.ARROW))
{
killed.getInventory().addItem(Quiver.SUPER_ARROW);
}
}
}.runTaskLater(getBase().Manager.getPlugin(), (long) (getBase().DeathSpectateSecs * 20 + RESPAWN_ARROW_GIVE_DELAY));
}
@EventHandler
public void onProjectileHit(ProjectileHitEvent event)
{
if (event.getEntity() instanceof Arrow)
{
event.getEntity().remove();
}
}
}

View File

@ -0,0 +1,243 @@
package nautilus.game.arcade.game.games.quiver.module;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerToggleSneakEvent;
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.util.UtilTextBottom;
import mineplex.core.updater.UpdateType;
import mineplex.minecraft.game.core.combat.CombatComponent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.game.games.quiver.QuiverTeamBase;
import nautilus.game.arcade.game.games.quiver.ultimates.UltimatePerk;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
public class ModuleUltimate extends QuiverTeamModule implements Listener
{
private static final int ULTIMATE_PERCENTAGE_INCREASE_KILL = 5;
private static final int ULTIMATE_PERCENTAGE_INCREASE_ASSIST = 2;
private Map<UUID, Float> _ultimatePercentage = new HashMap<>();
private boolean _colouredMessage;
public ModuleUltimate(QuiverTeamBase base)
{
super(base);
}
@Override
public void setup()
{
getBase().Manager.registerEvents(this);
}
@Override
public void update(UpdateType updateType)
{
if (updateType != UpdateType.SEC)
{
return;
}
_colouredMessage = !_colouredMessage;
for (Player player : getBase().GetPlayers(true))
{
Kit kit = getBase().GetKit(player);
if (kit == null || UtilPlayer.isSpectator(player))
{
continue;
}
if (!_ultimatePercentage.containsKey(player.getUniqueId()))
{
_ultimatePercentage.put(player.getUniqueId(), 0F);
}
double percentage = _ultimatePercentage.get(player.getUniqueId());
if (percentage >= 100)
{
UtilTextBottom.display((_colouredMessage ? C.cWhiteB : C.cAquaB) + "ULTIMATE READY (PRESS SNEAK)", player);
player.setExp(0.999F);
player.setLevel(100);
continue;
}
String percentageFormatted = new DecimalFormat("0.0").format(percentage);
UtilTextBottom.displayProgress("Ultimate", percentage / 100, percentageFormatted + "%", player);
player.setExp((float) percentage / 100);
player.setLevel((int) percentage);
for (Perk perk : kit.GetPerks())
{
if (perk instanceof UltimatePerk)
{
UltimatePerk ultimate = (UltimatePerk) perk;
if (ultimate.isUsingUltimate(player))
{
continue;
}
incrementUltimate(player, ultimate.getChargePassive());
}
}
}
}
@Override
public void finish()
{
UtilServer.Unregister(this);
for (UUID uuid : _ultimatePercentage.keySet())
{
Player player = UtilPlayer.searchExact(uuid);
for (Perk perk : getBase().GetKit(player).GetPerks())
{
if (!(perk instanceof UltimatePerk))
{
continue;
}
UltimatePerk ultimate = (UltimatePerk) perk;
if (ultimate.isUsingUltimate(player))
{
ultimate.cancel(player);
}
}
}
}
@EventHandler
public void onCombatDeath(CombatDeathEvent event)
{
if (event.GetEvent().getEntity() == null || event.GetLog().GetKiller() == null)
{
return;
}
if (!(event.GetEvent().getEntity() instanceof Player))
{
return;
}
Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
if (player == null)
{
return;
}
incrementUltimate(player, ULTIMATE_PERCENTAGE_INCREASE_KILL);
for (CombatComponent combatComponent : event.GetLog().GetAttackers())
{
if (event.GetLog().GetKiller() != null && combatComponent.equals(event.GetLog().GetKiller()))
{
continue;
}
if (combatComponent.IsPlayer())
{
Player assitedPlayer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
if (assitedPlayer != null)
{
incrementUltimate(assitedPlayer, ULTIMATE_PERCENTAGE_INCREASE_ASSIST);
}
}
}
}
public void incrementUltimate(Player player, float percentage)
{
ProgressingKit kit = (ProgressingKit) getBase().GetKit(player);
for (Perk perk : kit.getPerks()[kit.getUpgradeLevel(player.getUniqueId())])
{
if (perk instanceof UltimatePerk)
{
UltimatePerk ultimate = (UltimatePerk) perk;
if (ultimate.isUsingUltimate(player))
{
return;
}
}
}
_ultimatePercentage.put(player.getUniqueId(), _ultimatePercentage.get(player.getUniqueId()) + percentage);
}
public void resetUltimate(Player player, boolean inform)
{
if (inform)
{
player.sendMessage(F.main("Game", "Your Ultimate charge has been reset!"));
}
_ultimatePercentage.put(player.getUniqueId(), 0F);
}
@EventHandler
public void onPlayerToggleSneak(PlayerToggleSneakEvent event)
{
if (!getBase().IsLive())
{
return;
}
Player player = event.getPlayer();
ProgressingKit kit = (ProgressingKit) getBase().GetKit(player);
if (!event.isSneaking())
{
return;
}
if (kit == null || UtilPlayer.isSpectator(player))
{
return;
}
if (_ultimatePercentage.get(player.getUniqueId()) < 100)
{
return;
}
for (Perk perk : kit.getPerks()[kit.getUpgradeLevel(player.getUniqueId())])
{
if (perk instanceof UltimatePerk)
{
UltimatePerk ultimate = (UltimatePerk) perk;
if (ultimate.isUsable(player))
{
ultimate.activate(player);
resetUltimate(player, false);
}
}
}
}
}

View File

@ -0,0 +1,32 @@
package nautilus.game.arcade.game.games.quiver.module;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.game.games.quiver.QuiverTeamBase;
public abstract class QuiverTeamModule
{
private QuiverTeamBase _base;
public QuiverTeamModule(QuiverTeamBase base)
{
_base = base;
}
public abstract void setup();
public abstract void update(UpdateType updateType);
public abstract void finish();
public void updateScoreboard()
{
}
public QuiverTeamBase getBase()
{
return _base;
}
}

View File

@ -0,0 +1,150 @@
package nautilus.game.arcade.game.games.quiver.module.game;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Bukkit;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.quiver.QuiverTeamBase;
import nautilus.game.arcade.game.games.quiver.module.ModuleCapturePoint;
import nautilus.game.arcade.game.games.quiver.module.ModuleCapturePoint.CaptureState;
import nautilus.game.arcade.game.games.quiver.module.QuiverTeamModule;
import nautilus.game.arcade.scoreboard.GameScoreboard;
public class QuiverKOTH extends QuiverTeamModule
{
private static final long OVERTIME_TIME_INITIAL = 3000;
private static final long OVERTIME_TIME_DECREASE = 10;
private ModuleCapturePoint _capturePoint;
private boolean _isOvertime;
private long _lastNotCaptured;
private long _overtimeTime;
private Map<GameTeam, Float> _teamScore = new HashMap<>();
public QuiverKOTH(QuiverTeamBase base)
{
super(base);
_capturePoint = getBase().getQuiverTeamModule(ModuleCapturePoint.class);
_overtimeTime = OVERTIME_TIME_INITIAL;
}
@Override
public void updateScoreboard()
{
GameScoreboard scoreboard = getBase().GetScoreboard();
scoreboard.writeNewLine();
scoreboard.write(C.cGoldB + "Capture Point");
if (_capturePoint.getCapturedTeam() == null)
{
scoreboard.write("None");
}
else
{
scoreboard.write(_capturePoint.getCapturedTeam().GetFormattedName() + "");
}
if (getBase().IsLive())
{
for (GameTeam gameTeam : _teamScore.keySet())
{
float percentage = Math.min(_teamScore.get(gameTeam), 100);
scoreboard.writeNewLine();
scoreboard.write(gameTeam.GetColor() + C.Bold + "Team " + gameTeam.getDisplayName());
scoreboard.write(percentage + "%");
}
}
scoreboard.writeNewLine();
scoreboard.draw();
}
@Override
public void setup()
{
for (GameTeam gameTeam : getBase().GetTeamList())
{
_teamScore.put(gameTeam, 0F);
}
}
@Override
public void update(UpdateType updateType)
{
if (updateType != UpdateType.FAST)
{
return;
}
if (_capturePoint.getCapturedTeam() == null)
{
return;
}
_teamScore.put(_capturePoint.getCapturedTeam(), _teamScore.get(_capturePoint.getCapturedTeam()) + 0.5F);
if (_capturePoint.getState() != CaptureState.CAPTURED)
{
_lastNotCaptured = System.currentTimeMillis();
}
if (_isOvertime)
{
_overtimeTime -= OVERTIME_TIME_DECREASE;
}
for (GameTeam gameTeam : _teamScore.keySet())
{
float percentage = _teamScore.get(gameTeam);
if (percentage >= 100)
{
CaptureState state = _capturePoint.getState();
if (_isOvertime && !UtilTime.elapsed(_lastNotCaptured, _overtimeTime))
{
Bukkit.broadcastMessage(UtilTime.MakeStr(_overtimeTime - (System.currentTimeMillis() - _lastNotCaptured)));
return;
}
if (!_isOvertime && state != CaptureState.CAPTURED)
{
_isOvertime = true;
String message = QuiverTeamBase.OVERTIME;
UtilTextMiddle.display(message, "", 10, 30, 10);
UtilServer.broadcast(message);
_teamScore.put(gameTeam, 99.9F);
return;
}
getBase().AnnounceEnd(gameTeam);
getBase().SetState(GameState.End);
}
}
}
@Override
public void finish()
{
}
}

View File

@ -0,0 +1,438 @@
package nautilus.game.arcade.game.games.quiver.module.game;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.Listener;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
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.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.quiver.QuiverTeamBase;
import nautilus.game.arcade.game.games.quiver.QuiverTeamBase.GemAwardReason;
import nautilus.game.arcade.game.games.quiver.module.ModulePayload;
import nautilus.game.arcade.game.games.quiver.module.ModulePayload.PayloadState;
import nautilus.game.arcade.game.games.quiver.module.QuiverTeamModule;
import nautilus.game.arcade.scoreboard.GameScoreboard;
public class QuiverPayload extends QuiverTeamModule implements Listener
{
private static final long GAME_TIMEOUT = 600000;
private static final int END_EFFECT_DELAY = 100;
private static final int END_EFFECT_TNT_AMOUNT = 8;
private static final int END_EFFECT_EXPLOSION_RADIUS = 5;
private static final int MAX_SCORE = 5;
private static final int PAYLOAD_RESPAWN_DELAY_TICKS = 7 * 20;
private ModulePayload _payload;
private Set<Block> _lastOvertimeTrack = new HashSet<>();
private Map<GameTeam, Integer> _teamScore = new HashMap<>();
private boolean _isEnding;
private boolean _isOvertime;
public QuiverPayload(QuiverTeamBase base)
{
super(base);
base.DeathSpectateSecs = 5;
_payload = getBase().getQuiverTeamModule(ModulePayload.class);
}
@Override
public void updateScoreboard()
{
GameScoreboard scoreboard = getBase().GetScoreboard();
scoreboard.reset();
scoreboard.writeNewLine();
scoreboard.write(C.cGoldB + "Payload");
GameTeam teamDirection = _payload.getTeamDirection();
PayloadState payloadState = _payload.getState();
if (payloadState.equals(PayloadState.CONTESTED))
{
scoreboard.write(C.cDPurpleB + "Contested");
}
else if (payloadState.equals(PayloadState.RESTARTING))
{
scoreboard.write("Respawning...");
}
else if (payloadState.equals(PayloadState.NONE))
{
scoreboard.write("None");
}
else if (teamDirection != null)
{
String distance = new DecimalFormat("0.0").format(_payload.getTrackDistanceToMarker(_payload.getDestination(teamDirection)));
scoreboard.write(teamDirection.GetFormattedName() + ChatColor.RESET + teamDirection.GetColor() + " (" + teamDirection.GetColor() + distance + "m)");
}
else
{
scoreboard.write("Loading...");
}
if (getBase().IsLive())
{
scoreboard.writeNewLine();
if (_isOvertime)
{
for (GameTeam gameTeam : _teamScore.keySet())
{
scoreboard.write(gameTeam.GetColor() + C.Bold + "Team " + gameTeam.getDisplayName());
int alivePlayers = 0;
for (Player player : gameTeam.GetPlayers(true))
{
if (UtilPlayer.isSpectator(player))
{
continue;
}
alivePlayers++;
}
scoreboard.write(alivePlayers + "/" + gameTeam.GetPlayers(true).size() + " Alive");
scoreboard.writeNewLine();
}
}
else
{
for (GameTeam gameTeam : _teamScore.keySet())
{
int score = Math.min(_teamScore.get(gameTeam), MAX_SCORE);
scoreboard.write(gameTeam.GetColor() + C.Bold + "Team " + gameTeam.getDisplayName());
scoreboard.write(score + " Point" + (score == 1 ? "" : "s") + " (" + (MAX_SCORE - score) + ")");
scoreboard.writeNewLine();
}
}
scoreboard.write(C.cRedB + "Game End");
if (_isOvertime)
{
scoreboard.write(QuiverTeamBase.OVERTIME);
}
else
{
scoreboard.write(UtilTime.MakeStr(GAME_TIMEOUT - (System.currentTimeMillis() - getBase().GetStateTime())));
}
}
else if (getBase().WinnerTeam != null)
{
scoreboard.writeNewLine();
scoreboard.write(getBase().WinnerTeam.GetFormattedName() + " Won!");
}
scoreboard.writeNewLine();
scoreboard.draw();
}
@Override
public void setup()
{
getBase().Manager.registerEvents(this);
for (GameTeam gameTeam : getBase().GetTeamList())
{
_teamScore.put(gameTeam, 0);
}
}
@Override
public void update(UpdateType updateType)
{
if (updateType != UpdateType.SEC)
{
return;
}
for (GameTeam gameTeam : _teamScore.keySet())
{
if (gameTeam.GetPlayers(true).isEmpty())
{
for (GameTeam otherTeam : _teamScore.keySet())
{
if (gameTeam.equals(otherTeam))
{
continue;
}
getBase().WinnerTeam = otherTeam;
awardWinGems();
displayEndEffect();
}
}
if (_payload.isMinecartNearMarker(_payload.getDestination(gameTeam)) && _payload.getTeamDirection().equals(gameTeam) && _payload.getState() != PayloadState.RESTARTING)
{
int score = _teamScore.get(gameTeam);
getBase().WinnerTeam = gameTeam;
_teamScore.put(gameTeam, ++score);
if (score == MAX_SCORE)
{
awardWinGems();
displayEndEffect();
}
else
{
String message = gameTeam.GetFormattedName() + " scored! Payload Respawning...";
UtilTextMiddle.display("", message, 10, 30, 10);
UtilServer.broadcast(message);
_payload.resetMinecart();
displayPointScoreEffect();
new BukkitRunnable()
{
Location toTeleport = getBase().WorldData.GetDataLocs(ModulePayload.DATA_POINT_PAYLOAD).get(0);
@Override
public void run()
{
UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _payload.getMinecart().getLocation().add(0, 1, 0), 0, 0, 0, 1, 1, ViewDist.LONG);
UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, toTeleport, 0, 0, 0, 1, 1, ViewDist.LONG);
_payload.getMinecart().teleport(toTeleport);
_payload.setState(PayloadState.NONE);
_payload.setMinecartTeam(_payload.getState());
}
}.runTaskLater(getBase().Manager.getPlugin(), PAYLOAD_RESPAWN_DELAY_TICKS);
}
}
}
if (_isOvertime)
{
List<Location> pathMarkers = _payload.getPathMarkers();
if (_lastOvertimeTrack.isEmpty())
{
_lastOvertimeTrack.add(pathMarkers.get(0).getBlock().getRelative(BlockFace.DOWN));
_lastOvertimeTrack.add(pathMarkers.get(pathMarkers.size() - 1).getBlock().getRelative(BlockFace.DOWN));
}
Set<Block> newTracks = new HashSet<>();
Minecart _minecart = _payload.getMinecart();
for (Block block : _lastOvertimeTrack)
{
if (_payload.isMinecartNearMarker(block.getLocation()))
{
Location locationA = UtilAlg.findClosest(_minecart.getLocation(), getBase().WorldData.GetDataLocs(ModulePayload.DATA_POINT_RED));
Location locationB = UtilAlg.findClosest(_minecart.getLocation(), getBase().WorldData.GetDataLocs(ModulePayload.DATA_POINT_BLUE));
if (UtilMath.offset(_minecart.getLocation(), locationA) < UtilMath.offset(_minecart.getLocation(), locationB))
{
getBase().WinnerTeam = getBase().GetTeam(ChatColor.AQUA);
}
else
{
getBase().WinnerTeam = getBase().GetTeam(ChatColor.RED);
}
_payload.setState(PayloadState.RESTARTING);
awardWinGems();
displayEndEffect();
return;
}
for (Block other : UtilBlock.getInRadius(block, 1.5).keySet())
{
if (other.getType() == Material.RAILS)
{
block.setType(Material.AIR);
newTracks.add(other);
UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.05F, 12, ViewDist.NORMAL);
}
}
}
_lastOvertimeTrack = newTracks;
}
if (UtilTime.elapsed(getBase().GetStateTime(), GAME_TIMEOUT) && !_isOvertime)
{
/*
* If a particular gameTeam has scored the most points they are the
* winners otherwise if all gameTeam's scores are the same, the game
* goes into overtime and after OVERTIME milliseconds the distance
* from the minecart and that gameTeams destination is used to
* determine the winner.
*/
int lastScore = -1;
boolean same = false;
for (GameTeam gameTeam : _teamScore.keySet())
{
int score = _teamScore.get(gameTeam);
if (lastScore == -1)
{
lastScore = score;
getBase().WinnerTeam = gameTeam;
}
else if (score > lastScore)
{
getBase().WinnerTeam = gameTeam;
}
else if (score == lastScore)
{
same = true;
}
}
if (same)
{
String subTitle = C.cRed + "The track will now shrink over time!";
UtilTextMiddle.display(QuiverTeamBase.OVERTIME, subTitle, 10, 30, 10);
UtilServer.broadcast(QuiverTeamBase.OVERTIME + " " + subTitle);
_isOvertime = true;
return;
}
getBase().AnnounceEnd(getBase().WinnerTeam);
getBase().SetState(GameState.End);
return;
}
}
@Override
public void finish()
{
UtilServer.Unregister(this);
}
public void displayPointScoreEffect()
{
if (_isEnding)
{
return;
}
Minecart minecart = _payload.getMinecart();
Location location = minecart.getLocation().add(0, 1, 0);
UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, location, 0, 0, 0, 1, 1, ViewDist.LONG);
UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, location, 0, 0, 0, 1, 200, ViewDist.LONG);
for (Player player : UtilPlayer.getNearby(minecart.getLocation(), 15))
{
if (!getBase().IsAlive(player))
{
continue;
}
UtilAction.velocity(player, UtilAlg.getTrajectory(location, player.getLocation()).normalize().multiply(UtilMath.offset(location, player.getLocation())).setY(1.5));
}
}
public void displayEndEffect()
{
if (_isEnding)
{
return;
}
Random random = new Random();
Minecart minecart = _payload.getMinecart();
_isEnding = true;
minecart.setDisplayBlock(null);
for (int i = 0; i < END_EFFECT_TNT_AMOUNT; i++)
{
TNTPrimed tntPrimed = minecart.getWorld().spawn(minecart.getLocation().add(0, 1, 0), TNTPrimed.class);
tntPrimed.setVelocity(new Vector(random.nextDouble() - 0.5, random.nextDouble() / 2, random.nextDouble() - 0.5));
tntPrimed.setFuseTicks((int) (END_EFFECT_DELAY / 2));
tntPrimed.setYield(END_EFFECT_EXPLOSION_RADIUS);
}
new BukkitRunnable()
{
@Override
public void run()
{
getBase().AnnounceEnd(getBase().WinnerTeam);
getBase().SetState(GameState.End);
}
}.runTaskLater(getBase().Manager.getPlugin(), END_EFFECT_DELAY);
}
private void awardWinGems()
{
for (Player player : getBase().GetPlayers(true))
{
if (!getBase().GetTeam(player).equals(getBase().WinnerTeam))
{
continue;
}
getBase().AddGems(player, getGems(GemAwardReason.WIN), "Winning Team", false, false);
}
}
public double getGems(GemAwardReason reason)
{
switch (reason)
{
case KILL:
return 1;
case ASSIST:
return 0.5;
case KILLSTEAK:
return 2;
case WIN:
return 10;
default:
break;
}
return 0;
}
}

View File

@ -7,17 +7,21 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.util.Vector;
public class UltimateBarrage extends Ultimate
public class UltimateBarrage extends UltimatePerk
{
private static final double CHARGE_PER_SECOND = 0.8;
private static final float CHARGE_PASSIVE = 0.8F;
private static final float CHARGE_PAYLOAD = 0.4F;
private static final float CHARGE_KILL = 5F;
private static final float CHARGE_ASSIST = 2F;
private static final float VELOCITY_MULTIPLIER = 3;
private int _arrows;
public UltimateBarrage(int arrows)
{
super("Arrow Barrage", new String[] {});
super("Arrow Barrage", new String[] {}, 0, CHARGE_PASSIVE, CHARGE_PAYLOAD, CHARGE_KILL, CHARGE_ASSIST);
_arrows = arrows;
}
@ -32,7 +36,7 @@ public class UltimateBarrage extends Ultimate
Player player = (Player) event.getEntity();
if (getLastUltimate().containsKey(player.getUniqueId()))
if (isUsingUltimate(player))
{
for (int i = 0; i < _arrows; i++)
{
@ -48,16 +52,4 @@ public class UltimateBarrage extends Ultimate
}
}
@Override
public double getChargeIncreasePerSecond()
{
return CHARGE_PER_SECOND;
}
@Override
public long getLength()
{
return 0;
}
}

View File

@ -12,19 +12,19 @@ import org.bukkit.inventory.ItemStack;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import mineplex.minecraft.game.core.damage.DamageChange;
import nautilus.game.arcade.game.games.quiver.module.ModuleSuperArrow;
public class UltimateBeserker extends Ultimate
public class UltimateBeserker extends UltimatePerk
{
private static final double CHARGE_PER_SECOND = 0.4;
private long _length;
private static final float CHARGE_PASSIVE = 0.4F;
private static final float CHARGE_PAYLOAD = 0.4F;
private static final float CHARGE_KILL = 5F;
private static final float CHARGE_ASSIST = 2F;
public UltimateBeserker(long length)
{
super("Berserker Shield", new String[] {});
_length = length;
super("Berserker Shield", new String[] {}, length, CHARGE_PASSIVE, CHARGE_PAYLOAD, CHARGE_KILL, CHARGE_ASSIST);
}
@EventHandler(priority = EventPriority.HIGHEST)
@ -34,13 +34,15 @@ public class UltimateBeserker extends Ultimate
{
return;
}
if (event.GetDamageePlayer() == null)
{
return;
}
if (!getLastUltimate().containsKey(event.GetDamageePlayer().getUniqueId()))
Player player = event.GetDamageePlayer();
if (!isUsingUltimate(player))
{
return;
}
@ -51,8 +53,10 @@ public class UltimateBeserker extends Ultimate
{
DamageChange damageChange = iterator.next();
if (damageChange.GetReason().equals("Instagib"))
if (damageChange.GetReason().equals(ModuleSuperArrow.SUPER_ARROW_DAMAGE_REASON))
{
Manager.GetGame().AddStat(player, "Unstoppable", 1, false, false);
iterator.remove();
}
}
@ -80,16 +84,4 @@ public class UltimateBeserker extends Ultimate
player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(color).build());
}
@Override
public double getChargeIncreasePerSecond()
{
return CHARGE_PER_SECOND;
}
@Override
public long getLength()
{
return _length;
}
}

View File

@ -25,21 +25,22 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.Game;
public class UltimateNecromancer extends Ultimate
public class UltimateNecromancer extends UltimatePerk
{
private static final double CHARGE_PER_SECOND = 0.4;
private long _length;
private static final float CHARGE_PASSIVE = 0.4F;
private static final float CHARGE_PAYLOAD = 0.4F;
private static final float CHARGE_KILL = 5F;
private static final float CHARGE_ASSIST = 2F;
private int _skeletons;
private Map<UUID, Set<LivingEntity>> _entities = new HashMap<>();
public UltimateNecromancer(long length, int skeletons)
{
super("Summon Undead", new String[] {});
super("Summon Undead", new String[] {}, length, CHARGE_PASSIVE, CHARGE_PAYLOAD, CHARGE_KILL, CHARGE_ASSIST);
_length = length;
_skeletons = skeletons;
}
@ -161,16 +162,4 @@ public class UltimateNecromancer extends Ultimate
return null;
}
@Override
public double getChargeIncreasePerSecond()
{
return CHARGE_PER_SECOND;
}
@Override
public long getLength()
{
return _length;
}
}

View File

@ -1,5 +1,9 @@
package nautilus.game.arcade.game.games.quiver.ultimates;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -11,21 +15,27 @@ import org.bukkit.potion.PotionEffectType;
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.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
public class UltimateNinja extends Ultimate
public class UltimateNinja extends UltimatePerk
{
private static final double CHARGE_PER_SECOND = 0.4;
private static final float CHARGE_PASSIVE = 0.4F;
private static final float CHARGE_PAYLOAD = 0.4F;
private static final float CHARGE_KILL = 5F;
private static final float CHARGE_ASSIST = 2F;
private static final int SPEED_AMPLIFIER = 1;
private long _length;
private Map<UUID, Integer> _kills = new HashMap<>();
public UltimateNinja(long length)
{
super("Ancient Blade", new String[] {});
_length = length;
super("Ancient Blade", new String[] {}, length, CHARGE_PASSIVE, CHARGE_PAYLOAD, CHARGE_KILL, CHARGE_ASSIST);
}
@EventHandler
@ -36,7 +46,7 @@ public class UltimateNinja extends Ultimate
return;
}
if (getLastUltimate().containsKey(event.GetDamagerPlayer(false).getUniqueId()) && event.GetDamagerPlayer(false).getItemInHand().getType() == Material.DIAMOND_SWORD)
if (isUsingUltimate(event.GetDamagerPlayer(false)) && event.GetDamagerPlayer(false).getItemInHand().getType() == Material.DIAMOND_SWORD)
{
event.AddMod(event.GetDamagerPlayer(false).getName(), GetName(), 9001, true);
}
@ -58,19 +68,46 @@ public class UltimateNinja extends Ultimate
{
super.cancel(player);
if (_kills.containsKey(player.getUniqueId()))
{
int kills = _kills.get(player.getUniqueId());
if (kills >= 5)
{
Manager.GetGame().AddStat(player, "Assassin", 1, true, false);
}
}
_kills.remove(player.getUniqueId());
player.getInventory().setItem(0, new ItemStack(Material.GOLD_SWORD));
}
@Override
public double getChargeIncreasePerSecond()
{
return CHARGE_PER_SECOND;
}
@EventHandler
public void onCombatDeath(CombatDeathEvent event)
{
if (event.GetEvent().getEntity() == null || event.GetLog().GetKiller() == null)
{
return;
}
@Override
public long getLength()
{
return _length;
}
if (!(event.GetEvent().getEntity() instanceof Player))
{
return;
}
Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
if (player == null)
{
return;
}
if (isUsingUltimate(player))
{
UUID uuid = player.getUniqueId();
_kills.putIfAbsent(uuid, 0);
_kills.put(uuid, _kills.get(uuid) + 1);
}
}
}

View File

@ -19,28 +19,37 @@ import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.quiver.Quiver;
import nautilus.game.arcade.game.games.quiver.kits.KitNewNinja;
import nautilus.game.arcade.kit.Perk;
public abstract class Ultimate extends Perk
public abstract class UltimatePerk extends Perk
{
private Map<UUID, Long> _lastUltimate = new HashMap<>();
private long _length;
private float _chargePassive;
private float _chargePayload;
private float _chargeKill;
private float _chargeAssist;
public Ultimate(String name, String[] perkDesc)
public UltimatePerk(String name, String[] perkDesc, long length, float chargePassive, float chargePayload, float chargeKill, float chargeAssist)
{
super(name, perkDesc);
_length = length;
_chargePassive = chargePassive;
_chargePayload = chargePayload;
_chargeKill = chargeKill;
_chargeAssist = chargeAssist;
}
public void activate(Player player)
{
_lastUltimate.put(player.getUniqueId(), System.currentTimeMillis());
if (!(Manager.GetGame().GetKit(player) instanceof KitNewNinja))
{
player.getInventory().addItem(Quiver.SUPER_ARROW);
}
player.getInventory().addItem(Quiver.SUPER_ARROW);
ChatColor teamColor = Manager.GetGame().GetTeam(player).GetColor();
UtilServer.broadcast(teamColor + C.Bold + player.getName() + C.cWhiteB + " activated their " + teamColor + C.Bold + GetName() + C.cWhiteB + ".");
@ -63,26 +72,24 @@ public abstract class Ultimate extends Perk
return true;
}
public abstract double getChargeIncreasePerSecond();
public abstract long getLength();
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST || getLength() == 0)
if (event.getType() != UpdateType.FAST || _length == 0)
{
return;
}
for (Player player : UtilServer.getPlayers())
{
if (!_lastUltimate.containsKey(player.getUniqueId()))
for (UUID uuid : _lastUltimate.keySet())
{
Player player = UtilPlayer.searchExact(uuid);
if (player == null)
{
continue;
}
if (UtilTime.elapsed(_lastUltimate.get(player.getUniqueId()), getLength()))
if (UtilTime.elapsed(_lastUltimate.get(uuid), _length))
{
cancel(player);
}
@ -99,7 +106,7 @@ public abstract class Ultimate extends Perk
Player player = (Player) event.GetEvent().getEntity();
if (!_lastUltimate.containsKey(player.getUniqueId()))
if (!isUsingUltimate(player))
{
return;
}
@ -118,9 +125,44 @@ public abstract class Ultimate extends Perk
}
}
}
public boolean isUsingUltimate(Player player)
{
return isUsingUltimate(player.getUniqueId());
}
public boolean isUsingUltimate(UUID uuid)
{
return _lastUltimate.containsKey(uuid);
}
public Map<UUID, Long> getLastUltimate()
{
return _lastUltimate;
}
public long getLength()
{
return _length;
}
public float getChargePassive()
{
return _chargePassive;
}
public float getChargePayload()
{
return _chargePayload;
}
public float getChargeKill()
{
return _chargeKill;
}
public float getChargeAssist()
{
return _chargeAssist;
}
}

View File

@ -7,6 +7,7 @@ import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
@ -15,21 +16,23 @@ import org.bukkit.util.Vector;
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.minecraft.game.core.combat.event.CombatDeathEvent;
public class UltimatePyromancer extends Ultimate
public class UltimatePyromancer extends UltimatePerk
{
private static final double CHARGE_PER_SECOND = 0.4;
private long _length;
private static final float CHARGE_PASSIVE = 0.4F;
private static final float CHARGE_PAYLOAD = 0.4F;
private static final float CHARGE_KILL = 5F;
private static final float CHARGE_ASSIST = 2F;
private Map<UUID, Integer> _tasks = new HashMap<>();
private Map<UUID, Integer> _kills = new HashMap<>();
public UltimatePyromancer(long length)
{
super("Fire Blossom", new String[] {});
_length = length;
super("Fire Blossom", new String[] {}, length, CHARGE_PASSIVE, CHARGE_PAYLOAD, CHARGE_KILL, CHARGE_ASSIST);
}
@Override
@ -61,20 +64,48 @@ public class UltimatePyromancer extends Ultimate
{
super.cancel(player);
if (_kills.containsKey(player.getUniqueId()))
{
int kills = _kills.get(player.getUniqueId());
if (kills >= 4)
{
Manager.GetGame().AddStat(player, "Blossom", 1, true, false);
}
}
_kills.remove(player.getUniqueId());
player.setWalkSpeed(0.2F);
Bukkit.getScheduler().cancelTask(_tasks.get(player.getUniqueId()));
}
@Override
public double getChargeIncreasePerSecond()
@EventHandler
public void onCombatDeath(CombatDeathEvent event)
{
return CHARGE_PER_SECOND;
}
if (event.GetEvent().getEntity() == null || event.GetLog().GetKiller() == null)
{
return;
}
@Override
public long getLength()
{
return _length;
}
if (!(event.GetEvent().getEntity() instanceof Player))
{
return;
}
Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
if (player == null)
{
return;
}
if (isUsingUltimate(player))
{
UUID uuid = player.getUniqueId();
_kills.putIfAbsent(uuid, 0);
_kills.put(uuid, _kills.get(uuid) + 1);
}
}
}

View File

@ -38,10 +38,15 @@ import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.quiver.Quiver;
public class UltimateSkyWarrior extends Ultimate
public class UltimateSkyWarrior extends UltimatePerk
{
private static final double CHARGE_PER_SECOND = 0.4;
private static final float CHARGE_PASSIVE = 0.4F;
private static final float CHARGE_PAYLOAD = 0.4F;
private static final float CHARGE_KILL = 5F;
private static final float CHARGE_ASSIST = 2F;
private static final int SHOTS = 3;
private static final long LAUNCHER_FIRE_DELAY = 500;
private static final long LAUNCHER_MAX_TIME = 15000;
private static final int Y_INCREASE = 10;
@ -56,7 +61,7 @@ public class UltimateSkyWarrior extends Ultimate
public UltimateSkyWarrior(double damageTeleport, double radiusTeleport, double damageLauncher, double radiusLauncher, int rangeLauncher)
{
super("Bombardment", new String[] {});
super("Bombardment", new String[] {}, 0, CHARGE_PASSIVE, CHARGE_PAYLOAD, CHARGE_KILL, CHARGE_ASSIST);
_damageTeleport = damageTeleport;
_radiusTeleport = radiusTeleport;
@ -85,7 +90,7 @@ public class UltimateSkyWarrior extends Ultimate
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, -10));
player.teleport(toTeleport);
_data.add(new SkyWarriorData(player, block, 3, UtilInv.getAmount(player, Material.ARROW), System.currentTimeMillis()));
_data.add(new SkyWarriorData(player, block, SHOTS, UtilInv.getAmount(player, Material.ARROW), System.currentTimeMillis()));
player.getInventory().clear();
@ -179,7 +184,7 @@ public class UltimateSkyWarrior extends Ultimate
@EventHandler
public void onPlayerMove(PlayerMoveEvent event)
{
if (!getLastUltimate().containsKey(event.getPlayer().getUniqueId()))
if (!isUsingUltimate(event.getPlayer().getUniqueId()))
{
return;
}
@ -265,18 +270,6 @@ public class UltimateSkyWarrior extends Ultimate
return true;
}
@Override
public double getChargeIncreasePerSecond()
{
return CHARGE_PER_SECOND;
}
@Override
public long getLength()
{
return 0;
}
private SkyWarriorData getData(Player player)
{
for (SkyWarriorData data : _data)

View File

@ -0,0 +1,485 @@
package nautilus.game.arcade.game.games.skyfall;
import java.util.ArrayList;
import java.util.LinkedList;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.hologram.Hologram;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState;
/**
* The BoosterRing is compatible with any game, so it may be used in any other game then Skyfall. <br/>
* This Object represents a single ring on the map which can boost players in their current direction.
*
* @author xXVevzZXx
*/
public class BoosterRing extends Crumbleable implements Listener
{
private static int MAX_RING_BOUNDS = 15;
private static int SEARCH_OUTER_RING_RANGE = 10;
private Game _host;
private BlockFace[] _blockFaces = new BlockFace[]{BlockFace.DOWN, BlockFace.UP, BlockFace.NORTH, BlockFace.EAST, BlockFace.WEST, BlockFace.SOUTH};
private Location _location;
private ArrayList<Location> _area;
private ArrayList<Location> _ring;
private float _boostStrength;
private boolean _disabled;
private Location _ringMiddle;
private ItemStack _material;
private long _disabledSince;
private long _disabledFor;
private Hologram _hologram;
private boolean _timer;
private LinkedList<Location> _sortedBorder;
private double _blocksToFill;
private BlockFace[] _faces = new BlockFace[2];
/**
* Standard Constructor for BoosterRing. <br/>
* This Constructor will initialize the ring and collect all blocks that are needed. <br/>
* A BoosterRing is created by setting the location param to a Location which is <br/>
* Inside the ring and only connects to the rings blocks at one BlockFace at a time.
*
* @param host is your game
* @param location Location inside the ring specified above
* @param boostStrength strenght of the boost
*/
public BoosterRing(Game host, Location location, float boostStrength)
{
_host = host;
_location = location;
_boostStrength = boostStrength;
_disabledSince = System.currentTimeMillis();
System.out.println("Registering Ring");
setupRing();
outerBlocks();
sortBlocks();
System.out.println("Ring size: " + _area.size());
Bukkit.getPluginManager().registerEvents(this, UtilServer.getPlugin());
_hologram = new Hologram(host.getArcadeManager().getHologramManager(), _ringMiddle, "");
_hologram.setViewDistance(300);
}
@EventHandler
public void deregister(GameStateChangeEvent event)
{
if (event.GetState() == GameState.Dead
|| event.GetState() == GameState.End)
{
HandlerList.unregisterAll(this);
}
}
public void outerBlocks()
{
_ring = new ArrayList<>();
Location[] locs = new Location[4];
BlockFace[] toCheck = new BlockFace[] {_faces[0], _faces[1], getOpposite(_faces[0]), getOpposite(_faces[1])};
int e = 0;
for (BlockFace face : toCheck)
{
int i = 0;
Block block = _ringMiddle.getBlock().getRelative(face);
while (i <= SEARCH_OUTER_RING_RANGE && block.getType() == Material.AIR)
{
block = block.getRelative(face);
i++;
}
locs[e] = block.getLocation();
e++;
}
Location a = new Location(locs[0].getWorld(), Math.min(Math.min(locs[0].getBlockX(), locs[1].getBlockX()), Math.min(locs[2].getBlockX(), locs[3].getBlockX())),
Math.min(Math.min(locs[0].getBlockY(), locs[1].getBlockY()), Math.min(locs[2].getBlockY(), locs[3].getBlockY())),
Math.min(Math.min(locs[0].getBlockZ(), locs[1].getBlockZ()), Math.min(locs[2].getBlockZ(), locs[3].getBlockZ())));
Location b = new Location(locs[0].getWorld(), Math.max(Math.max(locs[0].getBlockX(), locs[1].getBlockX()), Math.max(locs[2].getBlockX(), locs[3].getBlockX())),
Math.max(Math.max(locs[0].getBlockY(), locs[1].getBlockY()), Math.max(locs[2].getBlockY(), locs[3].getBlockY())),
Math.max(Math.max(locs[0].getBlockZ(), locs[1].getBlockZ()), Math.max(locs[2].getBlockZ(), locs[3].getBlockZ())));
for (Block boxblock : UtilBlock.getInBoundingBox(a, b, true))
{
if (boxblock.getType() == _material.getType() && boxblock.getData() == _material.getData().getData())
_ring.add(boxblock.getLocation());
}
}
public void sortBlocks()
{
BlockFace[] direction = new BlockFace[]{BlockFace.NORTH, BlockFace.SOUTH, BlockFace.WEST, BlockFace.EAST, BlockFace.UP, BlockFace.DOWN};
BlockFace[][] diagonal = new BlockFace[][]{
{BlockFace.NORTH, BlockFace.EAST}, {BlockFace.NORTH, BlockFace.WEST},
{BlockFace.SOUTH, BlockFace.EAST}, {BlockFace.SOUTH, BlockFace.WEST},
{BlockFace.UP, BlockFace.EAST}, {BlockFace.UP, BlockFace.WEST}, {BlockFace.UP, BlockFace.NORTH}, {BlockFace.UP, BlockFace.SOUTH},
{BlockFace.DOWN, BlockFace.EAST}, {BlockFace.DOWN, BlockFace.WEST}, {BlockFace.DOWN, BlockFace.NORTH}, {BlockFace.DOWN, BlockFace.SOUTH}};
ArrayList<Location> clone = (ArrayList<Location>) _ring.clone();
LinkedList<Location> locs = new LinkedList<>();
Location starter = clone.get(0);
Block block = starter.getBlock();
locs.add(block.getLocation());
int e = 0;
while (e < clone.size())
{
e++;
boolean cont = false;
for (BlockFace face : direction)
{
if (containsLoc(locs, block.getRelative(face).getLocation()))
continue;
if (block.getRelative(face).getType() == _material.getType()
&& block.getRelative(face).getData() == _material.getData().getData())
{
block = block.getRelative(face);
locs.add(block.getLocation());
cont = true;
break;
}
}
if (cont)
continue;
for (BlockFace[] first : diagonal)
{
Block tempBlock = block.getLocation().getBlock();
for (BlockFace face : first)
{
tempBlock = tempBlock.getRelative(face);
}
if (containsLoc(locs, tempBlock.getLocation()))
continue;
if (tempBlock.getType() == _material.getType()
&& tempBlock.getData() == _material.getData().getData())
{
block = tempBlock;
locs.add(block.getLocation());
break;
}
}
}
_sortedBorder = locs;
}
public void setupRing()
{
_area = new ArrayList<>();
ArrayList<Location> firstLine = new ArrayList<>();
BlockFace facing = null;
for (BlockFace face : _blockFaces)
{
if (_location.getBlock().getRelative(face).getType() == Material.AIR)
continue;
facing = getOpposite(face);
break;
}
firstLine.add(_location.clone());
_faces[0] = facing;
Block block = _location.getBlock().getRelative(facing);
while (block.getType() == Material.AIR)
{
firstLine.add(block.getLocation());
block = block.getRelative(facing);
}
_ringMiddle = firstLine.get(firstLine.size()/2);
BlockFace otherFace = null;
for (BlockFace face : _blockFaces)
{
if (face == getOpposite(facing) || face == facing)
continue;
Block middle = _ringMiddle.getBlock();
int i = 0;
while (middle.getType() == Material.AIR && i < MAX_RING_BOUNDS)
{
middle = middle.getRelative(face);
i++;
}
if (i < MAX_RING_BOUNDS)
{
otherFace = face;
break;
}
}
_faces[1] = otherFace;
BlockFace opposite = getOpposite(otherFace);
int i = 1;
for (Location loc : firstLine)
{
_area.add(loc.clone());
Block firstBlock = loc.getBlock().getRelative(otherFace);
while (firstBlock.getType() == Material.AIR)
{
_area.add(firstBlock.getLocation().clone());
firstBlock = firstBlock.getRelative(otherFace);
}
if (i == 1)
_material = new ItemStack(firstBlock.getType(), 1, firstBlock.getData(), firstBlock.getData());
Block secondBlock = loc.getBlock().getRelative(opposite);
while (secondBlock.getType() == Material.AIR)
{
_area.add(secondBlock.getLocation().clone());
secondBlock = secondBlock.getRelative(opposite);
}
i++;
}
}
private BlockFace getOpposite(BlockFace face)
{
if (face == BlockFace.UP) return BlockFace.DOWN;
if (face == BlockFace.DOWN) return BlockFace.UP;
if (face == BlockFace.NORTH) return BlockFace.SOUTH;
if (face == BlockFace.EAST) return BlockFace.WEST;
if (face == BlockFace.SOUTH) return BlockFace.NORTH;
if (face == BlockFace.WEST) return BlockFace.EAST;
return BlockFace.SELF;
}
@EventHandler
public void boostPlayer(UpdateEvent event)
{
if (_disabled)
return;
if (event.getType() != UpdateType.TICK)
return;
for (Player player : _host.GetPlayers(true))
{
if (!UtilPlayer.isGliding(player))
continue;
for (Location loc : _area)
{
if (player.getWorld() == loc.getWorld() && UtilMath.offset(player.getLocation(), loc) < 2)
{
applyBoost(player);
break;
}
}
}
}
public void applyBoost(Player player)
{
PlayerBoostRingEvent event = UtilServer.CallEvent(new PlayerBoostRingEvent(player, _boostStrength, this));
if (event.isCancelled())
return;
Vector vec = player.getEyeLocation().getDirection();
UtilAction.velocity(player, vec.multiply(event.getStrength()));
UtilFirework.playFirework(player.getEyeLocation(), Type.BALL_LARGE, Color.BLUE, true, false);
}
@EventHandler
public void ringBlockEffect(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
if (!_timer)
return;
if (!_disabled)
return;
double blocks = (double) _ring.size() / (double)(_disabledFor/1000);
_blocksToFill += blocks;
for (int i = 0; i < _blocksToFill; i++)
{
if (i >= _sortedBorder.size())
return;
_sortedBorder.get(i).getBlock().setTypeIdAndData(_material.getType().getId(), _material.getData().getData(), true);
}
}
@EventHandler
public void enableRing(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (!_disabled)
{
_hologram.stop();
return;
}
if (_timer)
{
if (!_hologram.isInUse())
_hologram.start();
_hologram.setText(UtilTime.MakeStr(_disabledSince + _disabledFor - System.currentTimeMillis()));
}
else
{
_hologram.stop();
}
if (UtilTime.elapsed(_disabledSince, _disabledFor))
enable();
}
public void disable()
{
disable(Long.MAX_VALUE, false);
}
public void disable(long time, Material mat, byte data, boolean showTimer)
{
disable(time, showTimer);
if (isCrumbledAway())
return;
UtilBlock.startQuickRecording();
for (Location loc : _ring)
{
UtilBlock.setQuick(loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), mat.getId(), data);
}
UtilBlock.stopQuickRecording();
}
public void disable(long time, boolean showTimer)
{
_timer = showTimer;
_disabledSince = System.currentTimeMillis();
_disabledFor = time;
_disabled = true;
_blocksToFill = 0;
}
public void enable()
{
_disabledFor = 0;
_disabled = false;
if (isCrumbledAway())
return;
UtilBlock.startQuickRecording();
for (Location loc : _ring)
{
UtilBlock.setQuick(loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), _material.getType().getId(), _material.getData().getData());
}
UtilBlock.stopQuickRecording();
}
public void setBoostStrength(float strenght)
{
_boostStrength = strenght;
}
public float getBoostStrength()
{
return _boostStrength;
}
public boolean isDisabled()
{
return _disabled;
}
public Location getMiddle()
{
return _ringMiddle;
}
public int getSize()
{
return SEARCH_OUTER_RING_RANGE;
}
public boolean containsLoc(LinkedList<Location> locations, Location location)
{
for (Location loc : locations)
{
if (loc.getBlockX() == location.getBlockX()
&& loc.getBlockY() == location.getBlockY()
&& loc.getBlockZ() == location.getBlockZ())
{
return true;
}
}
return false;
}
@Override
public void crumbledAway()
{
if (!isDisabled())
disable();
}
@Override
public ArrayList<Location> getBlocks()
{
return _ring;
}
}

View File

@ -0,0 +1,119 @@
package nautilus.game.arcade.game.games.skyfall;
import java.util.ArrayList;
import org.bukkit.Location;
import org.bukkit.Material;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilMath;
/**
* Crumbleable is a Superclass to create decayable/crumleable Objects like Sky Islands
*
* @author xXVevzZXx
*/
public abstract class Crumbleable
{
private boolean _crumble;
private ArrayList<Location> _initBlocks;
/**
* @see #crumble(int, Material...)
*/
public boolean crumble(int blocks)
{
return crumble(blocks, Material.AIR);
}
/**
* Lets the island crumble with the provided rate. <br/>
* <br/>
* Will call {@link #crumbledAway()} in subclasses if there are no blocks left to crumble.
* <br/>
*
* @param blocks blocks to crumble per call
* @param replacements blocks which will replace old blocks
*
* @return true if island is comepletely crumbled away
*/
public boolean crumble(int blocks, Material... replacements)
{
_crumble = true;
crumblePercentage();
Material material = replacements[UtilMath.r(replacements.length)];
if (getBlocks().isEmpty())
{
crumbledAway();
return true;
}
for (int i = 0; i < blocks; i++)
{
if (getBlocks().isEmpty())
{
crumbledAway();
return true;
}
Location toRemove = getBlocks().remove(UtilMath.r(getBlocks().size()));
if (toRemove.getBlock().getType() == Material.CHEST && getBlocks().size() > 25)
{
getBlocks().add(toRemove);
continue;
}
if (toRemove.getBlock().getType() == Material.AIR
|| toRemove.getBlock().getType() == Material.WATER
|| toRemove.getBlock().getType() == Material.STATIONARY_WATER
|| toRemove.getBlock().getType() == Material.LAVA
|| toRemove.getBlock().getType() == Material.STATIONARY_LAVA)
continue;
MapUtil.QuickChangeBlockAt(toRemove, material);
}
return false;
}
public boolean isCrumbling()
{
return _crumble;
}
public boolean isCrumbledAway()
{
return getBlocks().isEmpty();
}
/**
* @return the percentage of the crumbeled blocks.
*/
public double crumblePercentage()
{
if (_initBlocks == null)
_initBlocks = (ArrayList<Location>) getBlocks().clone();
try
{
return (getBlocks().size()/(_initBlocks.size()/100))/100;
}
catch (Exception e)
{
return 100;
}
}
/**
* Overrideable method which is called by
* {@link #crumble(int, Material...)} or {@link #crumble(int)}
* when there are no more blocks left to crumble.
*/
public void crumbledAway() {}
public abstract ArrayList<Location> getBlocks();
}

View File

@ -0,0 +1,129 @@
package nautilus.game.arcade.game.games.skyfall;
import org.bukkit.Color;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import nautilus.game.arcade.game.Game;
/**
* This Object represents an Arrow which will follow Players in a close range. <br/>
* <br/>
* The Object needs to be updated by using {@link #update()} in a prefered time interval,
* but needs to find a Target player first by using {@link #findPlayer()} in a prefered time interval.
*
* @author xXVevzZXx
*/
public class HomingArrow
{
private Player _shooter;
private Game _host;
private Arrow _arrow;
private Player _target;
private int _range;
private long _spawned;
private int _timeAlive;
private int _updates;
/**
* Standard Constructor of the HomingArrow
*
* @param shooter Player who shot the arrow
* @param host current game
* @param arrow fired arrow entity
* @param target Player (may be null)
* @param range of the arrow
* @param seondsAlive duration the Arrow will be active
*/
public HomingArrow(Player shooter, Game host, Arrow arrow, Player target, int range, int seondsAlive)
{
_shooter = shooter;
_host = host;
_arrow = arrow;
_target = target;
_range = range;
_spawned = System.currentTimeMillis();
_timeAlive = seondsAlive;
}
/**
* @return true if a Player was found
*/
public Player findPlayer()
{
for (Player player : _host.GetPlayers(true))
{
if (UtilMath.offset(player.getLocation(), _arrow.getLocation()) <= _range)
{
if (_shooter == player)
continue;
if (!UtilPlayer.isGliding(player))
continue;
_target = player;
return player;
}
}
return null;
}
/**
* You need to update the arrow as soon as a target is set or found by {@link #findPlayer()}}
*/
public void update()
{
if (canRemove())
return;
if (_target == null)
return;
Vector arrowToPlayer = _target.getLocation().add(0, 1, 0).toVector().subtract(_arrow.getLocation().toVector()).normalize();
int firework = 5;
if (_updates < (_timeAlive*20)*0.20)
{
firework = 15;
arrowToPlayer.multiply(1.5);
}
else if (_updates < (_timeAlive*20)*0.40)
{
firework = 10;
arrowToPlayer.multiply(1.6);
}
else if (_updates < (_timeAlive*20)*0.60)
arrowToPlayer.multiply(1.7);
else if (_updates < (_timeAlive*20)*0.80)
arrowToPlayer.multiply(1.8);
else
arrowToPlayer.multiply(1.9);
UtilAction.velocity(_arrow, arrowToPlayer);
if (_updates % firework == 0)
UtilFirework.playFirework(_arrow.getLocation(), Type.BALL, Color.RED, true, false);
_updates++;
}
public boolean foundPlayer()
{
return _target != null;
}
public boolean canRemove()
{
return UtilTime.elapsed(_spawned, 1000 * _timeAlive) || _arrow.isOnGround() || _arrow.isDead();
}
}

View File

@ -0,0 +1,201 @@
package nautilus.game.arcade.game.games.skyfall;
import java.util.ArrayList;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Chest;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.loot.ChestLoot;
/**
* The Island Object represents a flying Island <br/>
* which has it's own chests and is able to crumble away.
*
* @author xXVevzZXx
*/
public class Island extends Crumbleable
{
private Location _location;
private ArrayList<Location> _chests;
private ArrayList<Location> _blocks;
private ArrayList<Location> _lootedBlocks;
private int _bounds;
private int _height;
private ChestLoot _loot;
private BoosterRing _boosterRing;
/**
* @param location top middle location of the island
* @param bounds how many blocks to go in each direction
* @param height of the island
*/
public Island(Location location, int bounds, int height)
{
this(location, new ChestLoot(), bounds, height);
}
/**
* @param location top middle location of the island
* @param loot prefered {@link LootTable}
* @param bounds how many blocks to go in each direction
* @param height of the island
*/
public Island(Location location, LootTable loot, int bounds, int height)
{
this(location, loot.getloot(), bounds, height);
}
/**
* @param location top middle location of the island
* @param loot prefered {@link ChestLoot}
* @param bounds how many blocks to go in each direction
* @param height of the island
*/
public Island(Location location, ChestLoot loot, int bounds, int height)
{
_location = location;
_bounds = bounds;
_height = height;
_chests = new ArrayList<>();
_blocks = new ArrayList<>();
_lootedBlocks = new ArrayList<>();
_loot = loot;
registerBlocks();
}
public void fillLoot(Block block)
{
if (block.getType() != Material.CHEST
&& block.getType() != Material.TRAPPED_CHEST)
return;
if (_lootedBlocks.contains(block.getLocation()))
return;
_lootedBlocks.add(block.getLocation());
Chest chest = (Chest) block.getState();
Inventory inventory = chest.getBlockInventory();
inventory.clear();
int items = 3;
if (Math.random() > 0.50)
items++;
if (Math.random() > 0.65)
items++;
if (Math.random() > 0.80)
items++;
if (Math.random() > 0.95)
items++;
for (int i = 0; i < items; i++)
{
int trys = 0;
int slot = UtilMath.r(27);
while (inventory.getItem(slot) != null && trys <= 5)
{
trys++;
slot = UtilMath.r(27);
}
inventory.setItem(slot, _loot.getLoot());
}
}
public Location getLocation()
{
return _location;
}
public ArrayList<Location> getChests()
{
return _chests;
}
public int getBounds()
{
return _bounds;
}
public int getHeight()
{
return _height;
}
public boolean isOnIsland(Player player)
{
return isOnIsland(player.getLocation());
}
public boolean isOnIsland(Location location)
{
if (UtilMath.offset(location, _location) > _bounds)
return false;
for (int y = ((int) (Math.round(_location.getY()) - _height)); y <= _location.getBlockY(); y++)
{
if (location.getBlockY() == y)
return true;
}
return false;
}
@Override
public void crumbledAway()
{
if (_boosterRing != null)
{
if (!_boosterRing.isDisabled())
_boosterRing.disable();
}
}
public void registerBlocks()
{
for (Block block : UtilBlock.getInBoundingBox(_location.clone().add(_bounds, 0, _bounds), _location.clone().subtract(_bounds, _height, _bounds)))
{
if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST)
getChests().add(block.getLocation());
_blocks.add(block.getLocation());
}
}
public void refillChests()
{
_lootedBlocks.clear();
for (Location loc : _chests)
{
fillLoot(loc.getBlock());
}
}
public void setBoosterRing(BoosterRing ring)
{
_boosterRing = ring;
}
public BoosterRing getBoosterRing()
{
return _boosterRing;
}
@Override
public ArrayList<Location> getBlocks()
{
return _blocks;
}
}

View File

@ -0,0 +1,139 @@
package nautilus.game.arcade.game.games.skyfall;
import org.bukkit.Material;
import mineplex.core.common.util.F;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.loot.ChestLoot;
import mineplex.core.loot.RandomItem;
/**
* Can be converted into a {@link ChestLoot} Object.
*
* @author xXVevzZXx
*/
public class LootTable
{
public final static LootTable BASIC = new LootTable(
new RandomItem(Material.BAKED_POTATO, 30, 1, 3),
new RandomItem(Material.COOKED_BEEF, 30, 1, 2),
new RandomItem(Material.COOKED_CHICKEN, 30, 1, 2),
new RandomItem(Material.CARROT_ITEM, 30, 1, 3),
new RandomItem(Material.MUSHROOM_SOUP, 15, 1, 1),
new RandomItem(Material.WHEAT, 30, 1, 6),
new RandomItem(Material.APPLE, 30, 1, 4),
new RandomItem(Material.PORK, 30, 1, 4),
new RandomItem(Material.ROTTEN_FLESH, 40, 1, 6),
new RandomItem(Material.WOOD_AXE, 80),
new RandomItem(Material.WOOD_SWORD, 70),
new RandomItem(Material.STONE_AXE, 60),
new RandomItem(Material.STONE_SWORD, 30),
new RandomItem(Material.LEATHER_BOOTS, 30),
new RandomItem(Material.LEATHER_HELMET, 30),
new RandomItem(Material.LEATHER_LEGGINGS, 30),
new RandomItem(Material.GOLD_BOOTS, 25),
new RandomItem(Material.GOLD_HELMET, 25),
new RandomItem(Material.GOLD_LEGGINGS, 25),
new RandomItem(Material.CHAINMAIL_BOOTS, 20),
new RandomItem(Material.CHAINMAIL_HELMET, 20),
new RandomItem(Material.CHAINMAIL_LEGGINGS, 20),
new RandomItem(Material.FISHING_ROD, 30),
new RandomItem(Material.BOW, 20),
new RandomItem(Material.ARROW, 20, 1, 3),
new RandomItem(Material.SNOW_BALL, 30, 1, 2),
new RandomItem(Material.EGG, 30, 1, 2),
new RandomItem(Material.COMPASS, 20),
new RandomItem(Material.STICK, 30, 1, 2),
new RandomItem(Material.FLINT, 30, 1, 2),
new RandomItem(Material.FEATHER, 30, 1, 2),
new RandomItem(Material.GOLD_INGOT, 20),
new RandomItem(ItemStackFactory.Instance.CreateStack(
Material.TNT, (byte) 0, 1, F.item("Throwing TNT")), 15),
new RandomItem(Material.MUSHROOM_SOUP, 15),
new RandomItem(Material.BAKED_POTATO, 30, 1, 5),
new RandomItem(Material.MUSHROOM_SOUP, 30, 1, 1),
new RandomItem(Material.COOKED_BEEF, 30, 1, 3),
new RandomItem(Material.COOKED_CHICKEN, 30, 1, 3),
new RandomItem(Material.COOKED_FISH, 30, 1, 6),
new RandomItem(Material.GRILLED_PORK, 30, 1, 3),
new RandomItem(Material.COOKIE, 30),
new RandomItem(Material.PUMPKIN_PIE, 30, 1, 3),
new RandomItem(Material.APPLE, 30, 2, 6),
new RandomItem(Material.STONE_SWORD, 30),
new RandomItem(Material.IRON_AXE, 30),
new RandomItem(Material.IRON_INGOT, 30, 1, 2),
new RandomItem(Material.DIAMOND, 30)
);
public final static LootTable SUPPLY_DROP = new LootTable(
new RandomItem(Material.DIAMOND_HELMET, 10),
new RandomItem(Material.DIAMOND_LEGGINGS, 8),
new RandomItem(Material.DIAMOND_BOOTS, 10),
new RandomItem(Material.IRON_HELMET, 30),
new RandomItem(Material.IRON_LEGGINGS, 27),
new RandomItem(Material.IRON_BOOTS, 30),
new RandomItem(Material.IRON_SWORD, 24),
new RandomItem(Material.DIAMOND_SWORD, 8),
new RandomItem(Material.DIAMOND_AXE, 16)
// new RandomItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, 1, Enchantment.DAMAGE_ALL), 8),
// new RandomItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, 1, Enchantment.DAMAGE_ALL), 4),
//
// new RandomItem(new Potion(PotionType.INSTANT_HEAL, 2, true).toItemStack(1), 6),
// new RandomItem(new Potion(PotionType.INSTANT_DAMAGE, 1, true).toItemStack(1), 3),
// new RandomItem(new Potion(PotionType.SPEED, 1, true).toItemStack(1), 3),
// new RandomItem(new Potion(PotionType.STRENGTH, 2, false).toItemStack(1), 3)
);
private RandomItem[] _items;
private LootTable(RandomItem... items)
{
_items = items;
}
public RandomItem[] getItems()
{
return _items;
}
public ChestLoot getloot()
{
ChestLoot loot = new ChestLoot();
for (RandomItem item : _items)
{
loot.addLoot(item);
}
return loot;
}
public LootTable includes(LootTable table)
{
int size = _items.length + table.getItems().length;
RandomItem[] items = new RandomItem[size];
int i = 0;
for (RandomItem item : _items)
{
items[i] = item;
i++;
}
for (RandomItem item : table.getItems())
{
items[i] = item;
i++;
}
return new LootTable(items);
}
}

View File

@ -0,0 +1,91 @@
package nautilus.game.arcade.game.games.skyfall;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
/**
* Event which is triggered by Players flying through {@link BoosterRing}.
*
* @author xXVevzZXx
*/
public class PlayerBoostRingEvent extends PlayerEvent implements Cancellable
{
private boolean _cancelled;
private double _baseStrength;
private double _strength;
private BoosterRing _ring;
public PlayerBoostRingEvent(Player player, float strength, BoosterRing ring)
{
super(player);
_baseStrength = strength;
_strength = strength;
_ring = ring;
}
public void setStrength(double strenght)
{
_strength = strenght;
}
public void increaseStrength(double strenght)
{
_strength += strenght;
}
public void decreaseStrength(double strenght)
{
_strength -= strenght;
}
public void multiplyStrength(double multy)
{
_strength *= multy;
}
public double getStrength()
{
return _strength;
}
public double getBaseStrength()
{
return _baseStrength;
}
public BoosterRing getRing()
{
return _ring;
}
@Override
public boolean isCancelled()
{
return _cancelled;
}
@Override
public void setCancelled(boolean cancel)
{
_cancelled = cancel;
}
@Override
public HandlerList getHandlers()
{
return getHandlerList();
}
private static HandlerList _handlers = new HandlerList();
public static HandlerList getHandlerList()
{
return _handlers;
}
}

View File

@ -0,0 +1,102 @@
package nautilus.game.arcade.game.games.skyfall.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.skyfall.kits.perks.PerkAeronaught;
import nautilus.game.arcade.game.games.skyfall.kits.perks.PerkSlowDown;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
/**
* Kit which allows Players
* to use {@link PerkAeronaught}.
*
* @author xXVevzZXx
*/
public class KitAeronaught extends ProgressingKit
{
private static String DAMAGE = "Elytra Damage";
private static final Perk[][] PERKS =
{
{
new PerkSlowDown("Slow Down", 10),
new PerkAeronaught(DAMAGE, 0.45)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkAeronaught(DAMAGE, 0.46)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkAeronaught(DAMAGE, 0.47)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkAeronaught(DAMAGE, 0.48)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkAeronaught(DAMAGE, 0.49)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkAeronaught(DAMAGE, 0.50)
},
};
private static final String[][] UPGRADE_DETAILS =
{
{
increase(DAMAGE, "strength", 1)
},
{
increase(DAMAGE, "strength", 1)
},
{
increase(DAMAGE, "strength", 1)
},
{
increase(DAMAGE, "strength", 1)
},
{
increase(DAMAGE, "strength", 1)
},
};
private static final String[] DESCRIPTION =
{
C.cGray + "You are known for",
C.cGray + "your highly trained",
C.cGray + "fly combat skills",
"",
PERKS[0][1].GetDesc()[0]
};
private static final ItemStack IN_HAND = new ItemStack(Material.DIAMOND_SWORD);
private static final ItemStack PLAYER_ITEM = new ItemStack(Material.ELYTRA);
public KitAeronaught(ArcadeManager manager)
{
super(manager, "Aeronaught", "aeronaught", KitAvailability.Free, 0, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.SKELETON, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().setChestplate(PLAYER_ITEM);
}
@Override
public boolean showUpgrades()
{
return true;
}
}

View File

@ -0,0 +1,101 @@
package nautilus.game.arcade.game.games.skyfall.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.skyfall.kits.perks.PerkElytraBoost;
import nautilus.game.arcade.game.games.skyfall.kits.perks.PerkSlowDown;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
/**
* Kit which allows Players
* to use {@link PerkElytraBoost}.
*
* @author xXVevzZXx
*/
public class KitBooster extends ProgressingKit
{
private static String BOOST = "Elytra Boost";
private static final Perk[][] PERKS =
{
{
new PerkSlowDown("Slow Down", 10),
new PerkElytraBoost(BOOST, 30)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkElytraBoost(BOOST, 28)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkElytraBoost(BOOST, 26)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkElytraBoost(BOOST, 24)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkElytraBoost(BOOST, 22)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkElytraBoost(BOOST, 20)
},
};
private static final String[][] UPGRADE_DETAILS =
{
{
reduceCooldown(BOOST, 2)
},
{
reduceCooldown(BOOST, 2)
},
{
reduceCooldown(BOOST, 2)
},
{
reduceCooldown(BOOST, 2)
},
{
reduceCooldown(BOOST, 2)
},
};
private static final String[] DESCRIPTION =
{
C.cGray + "Recieves an upgraded Elytra",
C.cGray + "which has a inbuilt Jet Pack thruster",
"",
PERKS[0][1].GetDesc()[0]
};
private static final ItemStack IN_HAND = new ItemStack(Material.ELYTRA);
private static final ItemStack PLAYER_ITEM = new ItemStack(Material.ELYTRA);
public KitBooster(ArcadeManager manager)
{
super(manager, "Booster", "booster", KitAvailability.Free, 0, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.SKELETON, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().setChestplate(PLAYER_ITEM);
}
@Override
public boolean showUpgrades()
{
return true;
}
}

View File

@ -0,0 +1,102 @@
package nautilus.game.arcade.game.games.skyfall.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.skyfall.kits.perks.PerkDeadeye;
import nautilus.game.arcade.game.games.skyfall.kits.perks.PerkSlowDown;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
/**
* Kit which allows Players
* to use {@link PerkDeadeye}.
*
* @author xXVevzZXx
*/
public class KitDeadeye extends ProgressingKit
{
private static String DEADEYE = "Dead Eye";
private static final Perk[][] PERKS =
{
{
new PerkSlowDown("Slow Down", 10),
new PerkDeadeye(DEADEYE, 10)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkDeadeye(DEADEYE, 12)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkDeadeye(DEADEYE, 14)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkDeadeye(DEADEYE, 16)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkDeadeye(DEADEYE, 18)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkDeadeye(DEADEYE, 20)
},
};
private static final String[][] UPGRADE_DETAILS =
{
{
increaseNumber(DEADEYE, "range", 2, "Blocks")
},
{
increaseNumber(DEADEYE, "range", 2, "Blocks")
},
{
increaseNumber(DEADEYE, "range", 2, "Blocks")
},
{
increaseNumber(DEADEYE, "range", 2, "Blocks")
},
{
increaseNumber(DEADEYE, "range", 2, "Blocks")
},
};
private static final String[] DESCRIPTION =
{
C.cGray + "You have heat seeking",
C.cGray + "Arrows which will follow",
C.cGray + "other players",
"",
PERKS[0][1].GetDesc()[0]
};
private static final ItemStack IN_HAND = new ItemStack(Material.BOW);
private static final ItemStack PLAYER_ITEM = new ItemStack(Material.ELYTRA);
public KitDeadeye(ArcadeManager manager)
{
super(manager, "Deadeye", "deadeye", KitAvailability.Free, 0, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.SKELETON, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().setChestplate(PLAYER_ITEM);
}
@Override
public boolean showUpgrades()
{
return true;
}
}

View File

@ -0,0 +1,52 @@
package nautilus.game.arcade.game.games.skyfall.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.skyfall.kits.perks.PerkElytraKnockback;
import nautilus.game.arcade.game.games.skyfall.kits.perks.PerkSlowDown;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
/**
* Kit which allows Players
* to use {@link PerkElytraKnockback}.
*
* @author xXVevzZXx
*/
public class KitJouster extends ProgressingKit
{
private static final Perk[] PERKS =
{
new PerkSlowDown("Slow Down", 10),
new PerkElytraKnockback("Elytra Knockback")
};
private static final String[] DESCRIPTION =
{
C.cGray + "Your special swords",
C.cGray + "deal increased knockback",
"",
PERKS[1].GetDesc()[0]
};
private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD);
private static final ItemStack PLAYER_ITEM = new ItemStack(Material.ELYTRA);
public KitJouster(ArcadeManager manager)
{
super(manager, "Jouster", "jouster", KitAvailability.Free, 0, DESCRIPTION, PERKS, EntityType.SKELETON, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().setChestplate(PLAYER_ITEM);
}
}

View File

@ -0,0 +1,49 @@
package nautilus.game.arcade.game.games.skyfall.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.skyfall.kits.perks.PerkSlowDown;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
/**
* Testing kit for Skyfall.
*
* @author xXVevzZXx
*/
public class KitSkyfall extends ProgressingKit
{
private static final String[] DESCRIPTION =
{
C.cGray + "Professional Skyfaller",
C.cGray + "Noire is going to like you"
};
private static final Perk[] PERKS =
{
new PerkSlowDown("Slow Down", 10)
};
private static final ItemStack IN_HAND = new ItemStack(Material.ELYTRA);
private static final ItemStack PLAYER_ITEM = new ItemStack(Material.ELYTRA);
public KitSkyfall(ArcadeManager manager)
{
super(manager, "Skyfaller", "skyfaller", KitAvailability.Free, 0, DESCRIPTION, PERKS,
EntityType.SKELETON, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().setChestplate(PLAYER_ITEM);
}
}

View File

@ -0,0 +1,102 @@
package nautilus.game.arcade.game.games.skyfall.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.skyfall.kits.perks.PerkIncreaseBoosters;
import nautilus.game.arcade.game.games.skyfall.kits.perks.PerkSlowDown;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
/**
* Kit which allows Players
* to use {@link PerkIncreaseBoosters}.
*
* @author xXVevzZXx
*/
public class KitSpeeder extends ProgressingKit
{
private static String SPEED = "Ring Boost";
private static final Perk[][] PERKS =
{
{
new PerkSlowDown("Slow Down", 10),
new PerkIncreaseBoosters(SPEED, 1.1)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkIncreaseBoosters(SPEED, 1.15)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkIncreaseBoosters(SPEED, 1.2)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkIncreaseBoosters(SPEED, 1.25)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkIncreaseBoosters(SPEED, 1.3)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkIncreaseBoosters(SPEED, 1.35)
},
};
private static final String[][] UPGRADE_DETAILS =
{
{
increase(SPEED, "boost", 5)
},
{
increase(SPEED, "boost", 5)
},
{
increase(SPEED, "boost", 5)
},
{
increase(SPEED, "boost", 5)
},
{
increase(SPEED, "boost", 5)
},
};
private static final String[] DESCRIPTION =
{
C.cGray + "Increased Speed boosts",
C.cGray + "due to aerodynamic clothes.",
C.cGray + "Noire is going to like you.",
"",
PERKS[0][1].GetDesc()[0]
};
private static final ItemStack IN_HAND = new ItemStack(Material.ENDER_PEARL);
private static final ItemStack PLAYER_ITEM = new ItemStack(Material.ELYTRA);
public KitSpeeder(ArcadeManager manager)
{
super(manager, "Speeder", "speeder", KitAvailability.Free, 2000, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.SKELETON, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().setChestplate(PLAYER_ITEM);
}
@Override
public boolean showUpgrades()
{
return true;
}
}

View File

@ -0,0 +1,102 @@
package nautilus.game.arcade.game.games.skyfall.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.skyfall.kits.perks.PerkRemoveElytra;
import nautilus.game.arcade.game.games.skyfall.kits.perks.PerkSlowDown;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
/**
* Kit which allows Players
* to use {@link PerkRemoveElytra}.
*
* @author xXVevzZXx
*/
public class KitStunner extends ProgressingKit
{
private static String STUN = "Stunner";
private static final Perk[][] PERKS =
{
{
new PerkSlowDown("Slow Down", 10),
new PerkRemoveElytra(STUN, 1000)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkRemoveElytra(STUN, 1500)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkRemoveElytra(STUN, 2000)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkRemoveElytra(STUN, 2500)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkRemoveElytra(STUN, 3000)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkRemoveElytra(STUN, 3500)
},
};
private static final String[][] UPGRADE_DETAILS =
{
{
increaseNumber(STUN, "stun time", 0.5, "Seconds")
},
{
increaseNumber(STUN, "stun time", 0.5, "Seconds")
},
{
increaseNumber(STUN, "stun time", 0.5, "Seconds")
},
{
increaseNumber(STUN, "stun time", 0.5, "Seconds")
},
{
increaseNumber(STUN, "stun time", 0.5, "Seconds")
},
};
private static final String[] DESCRIPTION =
{
C.cGray + "Highly trained for",
C.cGray + "removing others Elytra",
"",
PERKS[0][1].GetDesc()[0]
};
private static final ItemStack IN_HAND = new ItemStack(Material.WEB);
private static final ItemStack PLAYER_ITEM = new ItemStack(Material.ELYTRA);
public KitStunner(ArcadeManager manager)
{
super(manager, "Stunner", "stunner", KitAvailability.Free, 0, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.SKELETON, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().setChestplate(PLAYER_ITEM);
}
@Override
public boolean showUpgrades()
{
return true;
}
}

View File

@ -0,0 +1,102 @@
package nautilus.game.arcade.game.games.skyfall.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.skyfall.kits.perks.PerkSlowDown;
import nautilus.game.arcade.game.games.skyfall.kits.perks.PerkSurefoot;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
/**
* Kit which allows Players
* to use {@link PerkSurefoot}.
*
* @author xXVevzZXx
*/
public class KitSurefoot extends ProgressingKit
{
private static String SUREFOOT = "Sure foot";
private static final Perk[][] PERKS =
{
{
new PerkSlowDown("Slow Down", 10),
new PerkSurefoot(SUREFOOT, 1F)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkSurefoot(SUREFOOT, 0.95F)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkSurefoot(SUREFOOT, 0.9F)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkSurefoot(SUREFOOT, 0.85F)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkSurefoot(SUREFOOT, 0.8F)
},
{
new PerkSlowDown("Slow Down", 10),
new PerkSurefoot(SUREFOOT, 0.75F)
},
};
private static final String[][] UPGRADE_DETAILS =
{
{
increase(SUREFOOT, "holdback", 5)
},
{
increase(SUREFOOT, "holdback", 5)
},
{
increase(SUREFOOT, "holdback", 5)
},
{
increase(SUREFOOT, "holdback", 5)
},
{
increase(SUREFOOT, "holdback", 5)
},
};
private static final String[] DESCRIPTION =
{
C.cGray + "You got some special shoes",
C.cGray + "which allow you to land safely",
C.cGray + "Noire is going to like you",
"",
PERKS[0][1].GetDesc()[0]
};
private static final ItemStack IN_HAND = new ItemStack(Material.LEATHER_BOOTS);
private static final ItemStack PLAYER_ITEM = new ItemStack(Material.ELYTRA);
public KitSurefoot(ArcadeManager manager)
{
super(manager, "Surefoot", "surefoot", KitAvailability.Free, 0, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.SKELETON, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().setChestplate(PLAYER_ITEM);
}
@Override
public boolean showUpgrades()
{
return true;
}
}

View File

@ -0,0 +1,55 @@
package nautilus.game.arcade.game.games.skyfall.kits.perks;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.kit.Perk;
/**
* Perk that increases the attack damage
* while the attacker is flying.
*
* @author xXVevzZXx
*/
public class PerkAeronaught extends Perk
{
private double _strength;
/**
* Standard Constructor for PerkAeronaught
*
* @param name of the perk
* @param strength multiplicator of damage
*/
public PerkAeronaught(String name, double strength)
{
super(name, new String[]
{
C.cWhite + "Deal " + C.cGreen + "+45%" + C.cWhite + " damage while flying"
});
_strength = strength;
}
@EventHandler
public void addDamage(CustomDamageEvent event)
{
if (Manager.GetGame() == null)
return;
Player player = event.GetDamagerPlayer(true);
if (!hasPerk(player))
return;
if (!UtilPlayer.isGliding(player))
return;
double damage = event.GetDamageInitial() * _strength;
event.AddMod(player.getName(), "Kit Damage", damage, true);
}
}

View File

@ -0,0 +1,88 @@
package nautilus.game.arcade.game.games.skyfall.kits.perks;
import java.util.ArrayList;
import java.util.Iterator;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityShootBowEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.skyfall.HomingArrow;
import nautilus.game.arcade.kit.Perk;
/**
* Perk that lets Players shot
* homing arrows which follow
* flying players as soon as they
* get in their range.
*
* @author xXVevzZXx
*/
public class PerkDeadeye extends Perk
{
private ArrayList<HomingArrow> _arrows = new ArrayList<>();
private int _range;
/**
* Standard Constructor for PerkDeadeye
*
* @param name of the perk
* @param range of the homing arrow
*/
public PerkDeadeye(String name, int range)
{
super(name, new String[]
{
C.cWhite + "Arrows will " + C.cGreen + "follow" + C.cWhite + " nearby flying enemies"
});
_range = range;
}
@EventHandler
public void arrowShoot(EntityShootBowEvent event)
{
if (!(event.getEntity() instanceof Player))
return;
Player shooter = (Player) event.getEntity();
if (!hasPerk(shooter))
return;
_arrows.add(new HomingArrow(shooter, Manager.GetGame(), (Arrow) event.getProjectile(), null, _range, 15));
}
@EventHandler
public void updateArrows(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
Iterator<HomingArrow> arrows = _arrows.iterator();
while (arrows.hasNext())
{
HomingArrow arrow = arrows.next();
if (!arrow.foundPlayer())
{
Player player = arrow.findPlayer();
if (player != null)
UtilPlayer.message(player, F.main(GetName(), "You have been targeted by a homing arrow!"));
continue;
}
arrow.update();
if (arrow.canRemove())
arrows.remove();
}
}
}

View File

@ -0,0 +1,107 @@
package nautilus.game.arcade.game.games.skyfall.kits.perks;
import org.bukkit.Color;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.kit.Perk;
/**
* Perk that allows people
* to double tap space to
* get a huge boost of
* momentum.
*
* @author xXVevzZXx
*/
public class PerkElytraBoost extends Perk
{
private int _cooldown;
/**
* Standard Constructor for PerkElytraboost
*
* @param name of the perk
* @param cooldown of the perk
*/
public PerkElytraBoost(String name, int cooldown)
{
super(name, new String[]
{
C.cYellow + "Double tap jump" + C.cWhite + " to use your " + C.cGreen +"Elytra Boost"
});
_cooldown = cooldown;
}
@EventHandler
public void enableFlight(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (Manager.GetGame() == null)
return;
for (Player player : Manager.GetGame().GetPlayers(true))
{
if (!hasPerk(player))
continue;
if (!UtilPlayer.isGliding(player) || !Recharge.Instance.usable(player, GetName()))
{
player.setAllowFlight(false);
return;
}
player.setAllowFlight(true);
}
}
@EventHandler
public void boost(PlayerToggleFlightEvent event)
{
Player player = event.getPlayer();
if (!hasPerk(player))
return;
if (!Recharge.Instance.use(player, GetName(), _cooldown * 1000, false, true))
return;
UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + "."));
player.setFlying(false);
Manager.runSyncLater(new Runnable()
{
@Override
public void run()
{
int i = 0;
while (i < 10 && !UtilPlayer.isGliding(player))
{
UtilPlayer.setGliding(player, true);
Vector vec = player.getEyeLocation().getDirection();
UtilAction.velocity(player, vec.multiply(2.5));
i++;
}
UtilFirework.playFirework(player.getEyeLocation(), Type.BALL_LARGE, Color.BLUE, true, false);
}
}, 4);
}
}

View File

@ -0,0 +1,51 @@
package nautilus.game.arcade.game.games.skyfall.kits.perks;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.kit.Perk;
/**
* Perk that allows Players to
* deal a increased amount of
* knockback to others Players
* while flying.
*
* @author xXVevzZXx
*/
public class PerkElytraKnockback extends Perk
{
/**
* Standard Constructor for PerkElytraKnockback
*
* @param name of the perk
*/
public PerkElytraKnockback(String name)
{
super(name, new String[]
{
C.cYellow + "Hitting Players " + C.cWhite + "will deal " + C.cGreen + "+100%" + C.cWhite + " Knockback"
});
}
@EventHandler
public void addKnockback(CustomDamageEvent event)
{
if (Manager.GetGame() == null)
return;
Player player = event.GetDamagerPlayer(true);
if (!hasPerk(player))
return;
if (!UtilPlayer.isGliding(player))
return;
event.AddKnockback("Kit Effect", event.getKnockbackValue()*2);
}
}

View File

@ -0,0 +1,41 @@
package nautilus.game.arcade.game.games.skyfall.kits.perks;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import nautilus.game.arcade.game.games.skyfall.BoosterRing;
import nautilus.game.arcade.game.games.skyfall.PlayerBoostRingEvent;
import nautilus.game.arcade.kit.Perk;
/**
* Perk that increases the
* momentum which Players get
* from {@link BoosterRing}.
*
* @author xXVevzZXx
*/
public class PerkIncreaseBoosters extends Perk
{
private double _strength;
public PerkIncreaseBoosters(String name, double strength)
{
super(name, new String[]
{
C.cWhite + "Boost rings give " + C.cGreen + "+10%" + C.cWhite + " extra boost"
});
_strength = strength;
}
@EventHandler
public void increaseBoost(PlayerBoostRingEvent event)
{
Player player = event.getPlayer();
if (!hasPerk(player))
return;
event.multiplyStrength(_strength);
}
}

View File

@ -0,0 +1,95 @@
package nautilus.game.arcade.game.games.skyfall.kits.perks;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.kit.Perk;
/**
* Perk that removes attacked
* Players Elytra for the
* specified amount of
* tim ein milliseconds.
*
* @author xXVevzZXx
*/
public class PerkRemoveElytra extends Perk
{
private HashMap<UUID, Long> _disabled = new HashMap<>();
private long _duration;
/**
* Standard Constructor for PerkRemoveElytra
*
* @param name of the perk
* @param duration of the removal
*/
public PerkRemoveElytra(String name, long duration)
{
super(name, new String[]
{
C.cWhite + "Dealing damage to flying enemies " + C.cGreen + "disables elytra" + C.cWhite + " for " + C.cGreen + (duration/1000) + " seconds"
});
_duration = duration;
}
@EventHandler
public void stunnEnemy(CustomDamageEvent event)
{
if (Manager.GetGame() == null)
return;
Player player = event.GetDamagerPlayer(true);
if (!hasPerk(player))
return;
Recharge.Instance.useForce(player, "Elytra Removal", _duration, true);
_disabled.put(event.GetDamageePlayer().getUniqueId(), System.currentTimeMillis() + _duration);
}
@EventHandler
public void updateElytras(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (Manager.GetGame() == null)
return;
for (Player player : Manager.GetGame().GetPlayers(true))
{
if (_disabled.containsKey(player.getUniqueId()))
{
if (System.currentTimeMillis() > _disabled.get(player.getUniqueId()))
{
player.getInventory().setChestplate(new ItemStack(Material.ELYTRA));
}
else
{
if (player.getInventory().getChestplate() != null)
{
UtilPlayer.message(player, F.main("Game", C.cRed + "You're Elytra is disabled!"));
}
player.getInventory().setChestplate(null);
}
}
}
}
}

View File

@ -0,0 +1,70 @@
package nautilus.game.arcade.game.games.skyfall.kits.perks;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.kit.Perk;
/**
* Perk that reduces the
* momentum of the using Player.
*
* @author xXVevzZXx
*/
public class PerkSlowDown extends Perk
{
private int _cooldown;
/**
* Standard Constructor for PerkSlowDown
*
* @param name of the perk
* @param cooldown of the perk usage
*/
public PerkSlowDown(String name, int cooldown)
{
super(name, new String[]
{
C.cWhite + "Press " + C.cYellow + "shift" + C.cWhite + " to slow down"
});
_cooldown = cooldown;
}
@EventHandler
public void slowDown(PlayerToggleSneakEvent event)
{
Player player = event.getPlayer();
if (!hasPerk(player))
return;
if (!UtilPlayer.isGliding(player))
return;
if (player.isSneaking())
return;
if (!Recharge.Instance.use(player, GetName(), _cooldown * 1000, false, true))
return;
UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + "."));
UtilAction.velocity(player, player.getEyeLocation().getDirection().multiply(-0.001));
Vector vec = player.getEyeLocation().getDirection();
double blocks = Manager.GetGame().getSpeed(player, 20);
double mult = blocks/40;
vec.multiply(mult);
UtilAction.velocity(player, vec);
}
}

View File

@ -0,0 +1,85 @@
package nautilus.game.arcade.game.games.skyfall.kits.perks;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.kit.Perk;
/**
* Perk that reduces the momentum
* of a Player while landing on
* an Island with an Elytra.
*
* @author xXVevzZXx
*/
public class PerkSurefoot extends Perk
{
private final static long MIN_AIRTIME = 2000;
private HashMap<UUID, Long> _lastGround = new HashMap<>();
private double _strength;
/**
* Standard Constructor for PerkSurefoot
*
* @param name of the perk
* @param strength of the reduced momentum
*/
public PerkSurefoot(String name, double strength)
{
super(name, new String[]
{
C.cGreen + "Reduced momentum" + C.cWhite + " when landing"
});
_strength = strength;
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (Manager.GetGame() == null)
return;
for (Player player : Manager.GetGame().GetPlayers(true))
{
if (!hasPerk(player))
continue;
if (!UtilPlayer.isGliding(player))
{
_lastGround.put(player.getUniqueId(), System.currentTimeMillis());
continue;
}
if (_lastGround.containsKey(player.getUniqueId()) && !UtilTime.elapsed(_lastGround.get(player.getUniqueId()), MIN_AIRTIME))
continue;
if (UtilPlayer.isInAir(player, 1, Material.STAINED_CLAY))
continue;
UtilAction.zeroVelocity(player);
Vector vec = Manager.GetGame().getMovement(player, 5);
UtilAction.velocity(player, vec.multiply(_strength/100));
UtilPlayer.setGliding(player, false);
}
}
}

View File

@ -0,0 +1,49 @@
package nautilus.game.arcade.game.games.skyfall.stats;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import mineplex.core.common.util.UtilPlayer;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.stats.StatTracker;
/**
* StatTracker which collects
* stats of kills in the air.
*
* @author xXVevzZXx
*/
public class AeronaughtStatTracker extends StatTracker<Game>
{
public AeronaughtStatTracker(Game game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCombatDeath(CombatDeathEvent event)
{
if (getGame().GetState() != Game.GameState.Live)
return;
if (event.GetLog().GetKiller() == null)
return;
if (!event.GetLog().GetKiller().IsPlayer())
return;
Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
if (player == null)
return;
if (!UtilPlayer.isGliding(player))
return;
addStat(player, "Aeronaught", 1, false, false);
}
}

View File

@ -0,0 +1,35 @@
package nautilus.game.arcade.game.games.skyfall.stats;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.skyfall.BoosterRing;
import nautilus.game.arcade.game.games.skyfall.PlayerBoostRingEvent;
import nautilus.game.arcade.stats.StatTracker;
/**
* StatTracker which collects
* stats of the amount of {@link BoosterRing}}
* Players flew trough.
*
* @author xXVevzZXx
*/
public class RingStatTracker extends StatTracker<Game>
{
public RingStatTracker(Game game)
{
super(game);
}
@EventHandler(priority=EventPriority.LOWEST)
public void ring(PlayerBoostRingEvent event)
{
if (event.isCancelled())
return;
addStat(event.getPlayer(), "Rings", 1, false, false);
}
}

View File

@ -95,7 +95,7 @@ public class KitEarth extends ProgressingKit
public KitEarth(ArcadeManager manager)
{
super(manager, "Earth", "skywarsearth", KitAvailability.Achievement, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND);
super(manager, "Earth", "skywarsearth", KitAvailability.Achievement, 5000, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND);
setAchievementRequirements(ACHIEVEMENTS);
}

View File

@ -1,11 +1,6 @@
package nautilus.game.arcade.game.games.uhc;
import com.mineplex.spigot.ChunkPreLoadEvent;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.access.IViolationInfo;
import fr.neatmonster.nocheatplus.hooks.NCPHook;
import fr.neatmonster.nocheatplus.hooks.NCPHookManager;
import mineplex.core.Managers;
import mineplex.core.account.CoreClient;
import mineplex.core.boosters.event.BoosterItemGiveEvent;
import mineplex.core.common.Pair;
@ -120,7 +115,7 @@ import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
public class UHC extends TeamGame implements NCPHook
public class UHC extends TeamGame
{
// The view distance of UHC. The amount of time and ram needed grows polynomially
public static final int VIEW_DISTANCE = 5;
@ -288,8 +283,6 @@ public class UHC extends TeamGame implements NCPHook
_healthObjective = Scoreboard.getScoreboard().registerNewObjective("Health", "health");
_healthObjective.setDisplaySlot(DisplaySlot.PLAYER_LIST);
NCPHookManager.addHook(CheckType.ALL, this);
registerModule(new TeamModule());
}
@ -727,7 +720,6 @@ public class UHC extends TeamGame implements NCPHook
MinecraftServer.getServer().worlds.add(((CraftWorld) WorldData.World).getHandle());
}
HandlerList.unregisterAll(_chunkLoadingThread);
NCPHookManager.removeHook(this);
// if (_chunkUnloadTaskId != -1)
// {
@ -1777,28 +1769,6 @@ public class UHC extends TeamGame implements NCPHook
}
}
@Override
public String getHookName()
{
return "UHC Hook";
}
@Override
public String getHookVersion()
{
return "0.0.1";
}
@Override
public boolean onCheckFailure(CheckType checkType, Player player, IViolationInfo iViolationInfo)
{
if (GetState() == GameState.Prepare)
{
return false;
}
return true;
}
private static int _gamesRun = 0;
@EventHandler

View File

@ -3,11 +3,13 @@ package nautilus.game.arcade.game.modules;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import mineplex.core.common.MinecraftVersion;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.portal.Portal;
/**
* This module functions as a checkpoint for any client connecting a game
@ -33,25 +35,20 @@ public class VersionModule extends Module
for (Player player : UtilServer.getPlayers())
{
if (!hasVersion(player))
if (UtilPlayer.getVersion(player) != _minecraftVersion)
{
player.kickPlayer(kickMessage);
UtilPlayer.message(player, C.cGold + C.Bold + "Please use Minecraft " + _minecraftVersion.friendlyName() + " or newer to play this game!");
Portal.getInstance().sendPlayerToServer(player, "Lobby");
}
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerJoin(PlayerJoinEvent event)
public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event)
{
if (!hasVersion(event.getPlayer()))
if (MinecraftVersion.fromInt(event.spigot().getVersion()) != _minecraftVersion)
{
event.getPlayer().kickPlayer(_kickMessage);
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, C.cGold + C.Bold + "Please use Minecraft " + _minecraftVersion.friendlyName() + " or newer to play this game!");
}
}
private boolean hasVersion(Player player)
{
return UtilPlayer.getVersion(player) == _minecraftVersion;
}
}

View File

@ -1,7 +1,29 @@
package nautilus.game.arcade.kit;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.scheduler.BukkitRunnable;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import mineplex.core.common.Rank;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C;
@ -24,26 +46,6 @@ import nautilus.game.arcade.shop.KitPackage;
import net.minecraft.server.v1_8_R3.EntityFireworks;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityStatus;
import net.minecraft.server.v1_8_R3.World;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* Kit wrapper for all new kits
@ -433,6 +435,11 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit
{
return C.cWhite + "Reduce the cooldown of " + C.cGreen + perk + C.cWhite + " by " + C.cGreen + time + C.cWhite + " seconds" + (time == 1 ? "" : "s") + ".";
}
public static String increaseNumber(String perk, String increasing, double value, String data)
{
return C.cWhite + "Increase the " + C.cGreen + increasing + C.cWhite + " of " + C.cGreen + perk + C.cWhite + " by " + C.cGreen + value + C.cWhite + " " + data + ".";
}
public static String increase(String perk, String increasing, double percentage)
{

View File

@ -5,6 +5,7 @@ import java.util.Iterator;
import java.util.List;
import mineplex.core.PlayerSelector;
import mineplex.core.common.util.UtilLambda;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.FireworkEffect.Type;
@ -415,7 +416,10 @@ public class GameManager implements Listener
public List<Player> getValidPlayersForGameStart()
{
return PlayerSelector.selectPlayers(
PlayerSelector.and(PlayerSelector.NOT_VANISHED, player -> !Manager.IsObserver(player))
UtilLambda.and(
PlayerSelector.NOT_VANISHED,
player -> !Manager.IsObserver(player)
)
);
}

View File

@ -68,12 +68,6 @@
<version>1.9</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus</artifactId>
<version>3.12.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>