Merge branches 'develop' and 'feature/report-v2' of github.com:Mineplex-LLC/Minecraft-PC into feature/report-v2

This commit is contained in:
Keir Nellyer 2016-09-12 10:11:31 +01:00
commit 5e5cb3284a
84 changed files with 5243 additions and 711 deletions

View File

@ -19,13 +19,6 @@ import java.util.*;
public class UtilServer
{
// Quite hacky. would be nice if we could have a "MineplexPlugin" interface
// which would define a getServerName() method and then implement it in
// whatever way needed.
// MineplexPlugin plugin = (MineplexPlugin) plugin.getClass().getDeclaredMethod("getMineplexPlugin").invoke(plugin);
// plugin.getServerName();
private static String _serverName;
public static Player[] getPlayers()
{
return getServer().getOnlinePlayers().toArray(new Player[0]);
@ -132,77 +125,16 @@ public class UtilServer
runnable.runTaskTimer(getPlugin(), time, time);
}
public static String getServerName()
{
if (_serverName == null)
{
try
{
Class<?> Portal = Class.forName("mineplex.core.portal.Portal");
Object instance = null;
List<Field> stringFields = Lists.newArrayList();
for (Field field : Portal.getDeclaredFields())
{
if (field.getType().equals(Portal))
{
field.setAccessible(true);
instance = field.get(null);
}
if (field.getType().equals(String.class))
{
stringFields.add(field);
}
}
for (Field field : stringFields)
{
field.setAccessible(true);
String value = (String) field.get(instance);
if (stringFields.size() > 1)
{
if (value.contains("-"))
{
_serverName = new String(value);
}
}
else
{
_serverName = new String(value);
}
}
if (_serverName == null)
{
_serverName = "UNKOWN";
System.out.println("ERROR: Could not get server name from Portal. Cause is most likely ambiguous fields in the class. Please revise UtilServer's method of getting the current server name.");
}
}
catch (Exception exception)
{
System.out.println("FATAL ERROR WHILE TRYING TO GET SERVER NAME");
exception.printStackTrace();
}
}
return _serverName;
}
public static String getServerNameFromConfig()
{
return getPlugin().getConfig().getString("serverstatus.name");
}
public static Collection<Player> GetPlayers()
{
return Lists.newArrayList(getPlayers());
}
public static String getServerName()
{
return getPlugin().getConfig().getString("serverstatus.name");
}
public static boolean isTestServer()
{
return getPlugin().getConfig().getString("serverstatus.group").equalsIgnoreCase("Testing");

View File

@ -0,0 +1,105 @@
package mineplex.core.common.util.particles.effects;
import java.util.Set;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
/**
* Creates a line of particles with customise able traits.
*
* Most noticeable with Blink skills.
*/
public class LineParticle
{
private Location _start;
private Vector _direction;
private Location _lastLocation;
private double _curRange;
private double _incrementedRange;
private double _maxRange;
private Set<Material> _ignoredTypes;
private ParticleType _particleType;
private Player[] _toDisplay;
public LineParticle(Location start, Vector direction, double incrementedRange, double maxRange, Set<Material> ignoredTypes, ParticleType particleType, Player... toDisplay)
{
this(start, null, direction, incrementedRange, maxRange, ignoredTypes, particleType, toDisplay);
}
public LineParticle(Location start, Location end, Vector direction, double incrementedRange, double maxRange, Set<Material> ignoredTypes, ParticleType particleType, Player... toDisplay)
{
_start = start;
_direction = direction;
_lastLocation = start;
_curRange = 0;
_incrementedRange = incrementedRange;
_maxRange = maxRange;
_ignoredTypes = ignoredTypes;
_particleType = particleType;
_toDisplay = toDisplay;
if (_direction == null)
{
direction = UtilAlg.getTrajectory(start, end).normalize();
}
}
/**
* Advances the line.
*
* @return true when the line has reached its target or has collided with a
* block with a type contained in _ignoredTypes.
*/
public boolean update()
{
boolean done = _curRange > _maxRange;
Location newTarget = _start.clone().add(new Vector(0, 0.2, 0)).add(_direction.clone().multiply(_curRange));
_lastLocation = newTarget;
if (!(UtilBlock.airFoliage(newTarget.getBlock()) || UtilBlock.airFoliage(newTarget.getBlock().getRelative(BlockFace.UP))))
{
if (_ignoredTypes == null)
{
done = true;
}
if (!_ignoredTypes.contains(newTarget.getBlock().getType()))
{
done = true;
}
}
_curRange += _incrementedRange;
UtilParticle.PlayParticle(_particleType, newTarget, 0, 0, 0, 0.001F, 1, ViewDist.LONG, _toDisplay);
return done;
}
public Location getLastLocation()
{
return _lastLocation;
}
public Location getDestination()
{
return _lastLocation.subtract(_direction);
}
}

View File

@ -0,0 +1,94 @@
package mineplex.core.common.util.particles.effects;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
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;
/**
* Creates a particle curve that bends towards a location.
*
* Most noticeable in Gladiators and TOITQ.
*/
public class ObjectiveParticle
{
private Location _current;
private Location _target;
private Vector _direction;
private float _turnMultipler;
private float _blocksToAdvance;
private float _particleOffset;
private int _particleCount;
private float _soundVolume;
private float _soundPitch;
private double _stopAtDistance;
private Sound _sound;
private ParticleType _particleType;
private Player[] _toDisplay;
public ObjectiveParticle(Location start, Vector startVector, Location target, Player... toDisplay)
{
this(start, startVector, target, 0.15F, 0.5F, 0.03F, 3, ParticleType.HAPPY_VILLAGER, 0.2F, 3F, null, 4, toDisplay);
}
public ObjectiveParticle(Location start, Vector startVector, Location target, float turnMutlipler, float blocksToAdvance, float particleOffset, int particleCount, ParticleType particleType,
float soundVolume, float soundPitch, Sound sound, double stopAtDistance, Player... toDisplay)
{
_current = start;
_target = target;
_turnMultipler = turnMutlipler;
_blocksToAdvance = blocksToAdvance;
_particleOffset = particleOffset;
_particleCount = particleCount;
_particleType = particleType;
_soundVolume = soundVolume;
_soundPitch = soundPitch;
_sound = sound;
_stopAtDistance = stopAtDistance;
_toDisplay = toDisplay;
_direction = startVector;
if (_direction.getY() < 0)
{
_direction.setY(0);
}
_direction.normalize();
}
/**
* Advances the curve.
*
* @return true when the curve is within _stopAtDistance blocks of the
* target.
*/
public boolean update()
{
_direction.add(UtilAlg.getTrajectory(_current, _target).multiply(_turnMultipler));
_direction.normalize();
_current.add(_direction.clone().multiply(_blocksToAdvance));
UtilParticle.PlayParticle(_particleType, _current, _particleOffset, _particleOffset, _particleOffset, 0, _particleCount, ViewDist.LONG, _toDisplay);
if (_sound != null)
{
for (Player player : _toDisplay)
{
player.playSound(_current, _sound, _soundVolume, _soundPitch);
}
}
return UtilMath.offset(_current, _target) < _stopAtDistance;
}
}

View File

@ -47,7 +47,7 @@
<dependency>
<groupId>com.mineplex</groupId>
<artifactId>anticheat</artifactId>
<version>1.1</version>
<version>1.2</version>
</dependency>
</dependencies>

View File

@ -235,14 +235,13 @@ public enum AchievementCategory
return _gameCategory;
}
public void addStats(CoreClientManager clientManager, StatsManager statsManager, List<String> lore, Player player, Player target)
public void addStats(CoreClientManager clientManager, StatsManager statsManager, List<String> lore, Player player, String targetName, PlayerStats targetStats)
{
addStats(clientManager, statsManager, lore, Integer.MAX_VALUE, player, target);
addStats(clientManager, statsManager, lore, Integer.MAX_VALUE, player, targetName, targetStats);
}
public void addStats(CoreClientManager clientManager, StatsManager statsManager, List<String> lore, int max, Player player, Player target)
public void addStats(CoreClientManager clientManager, StatsManager statsManager, List<String> lore, int max, Player player, String targetName, PlayerStats targetStats)
{
PlayerStats stats = statsManager.Get(target);
for (int i = 0; i < _statDisplays.length && i < max; i++)
{
// If the stat is null then just display a blank line instead
@ -260,7 +259,7 @@ public enum AchievementCategory
String displayName = _statDisplays[i].getDisplayName();
// Skip showing Losses, Kills, Deaths for other players
if (!clientManager.Get(player).GetRank().has(Rank.MODERATOR) && !player.equals(target) && (displayName.contains("Losses") || displayName.contains("Kills") || displayName.contains("Deaths") || displayName.equals("Time In Game") || displayName.equals("Games Played")))
if (!clientManager.Get(player).GetRank().has(Rank.MODERATOR) && !player.getName().equals(targetName) && (displayName.contains("Losses") || displayName.contains("Kills") || displayName.contains("Deaths") || displayName.equals("Time In Game") || displayName.equals("Games Played")))
continue;
double statNumber = 0;
@ -271,7 +270,7 @@ public enum AchievementCategory
if (_statDisplays[i].isFullStat())
{
for (String statName : _statDisplays[i].getStats())
statNumber += stats.getStat(statName);
statNumber += targetStats.getStat(statName);
}
else
{
@ -283,17 +282,17 @@ public enum AchievementCategory
{
if(statNumber == 0)
{
statNumber = stats.getStat(statToPull + "." + statName);
statNumber = targetStats.getStat(statToPull + "." + statName);
continue;
}
double stat = stats.getStat(statToPull + "." + statName);
double stat = targetStats.getStat(statToPull + "." + statName);
if(stat == 0)
statNumber = statNumber / 1;
else
statNumber = (double) statNumber / stat;
}
else
statNumber += stats.getStat(statToPull + "." + statName);
statNumber += targetStats.getStat(statToPull + "." + statName);
}
}
}

View File

@ -1,5 +1,6 @@
package mineplex.core.achievement;
import mineplex.core.stats.PlayerStats;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -18,10 +19,15 @@ import mineplex.core.incognito.IncognitoManager;
import mineplex.core.stats.StatsManager;
import mineplex.core.stats.event.StatChangeEvent;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
public class AchievementManager extends MiniPlugin
{
private static final List<String> NO_FAKE_LEVELS = Arrays.asList("samczsun");
private CoreClientManager _clientManager;
private IncognitoManager _incognitoManager;
private StatsManager _statsManager;
private EloManager _eloManager;
@ -41,6 +47,7 @@ public class AchievementManager extends MiniPlugin
_incognitoManager = incognitoManager;
_statsManager = statsManager;
_eloManager = eloManager;
_clientManager = clientManager;
_shop = new AchievementShop(this, _statsManager, clientManager, donationManager, "Achievement");
}
@ -50,17 +57,22 @@ public class AchievementManager extends MiniPlugin
}
public AchievementData get(UUID playerUUID, Achievement type)
{
return get(_statsManager.Get(playerUUID), type);
}
public AchievementData get(PlayerStats stats, Achievement type)
{
int exp = 0;
for (String stat : type.getStats())
{
exp += _statsManager.Get(playerUUID).getStat(stat);
exp += stats.getStat(stat);
}
return type.getLevelData(exp);
}
public EloManager getEloManager()
{
return _eloManager;
@ -127,12 +139,17 @@ public class AchievementManager extends MiniPlugin
public void openShop(Player player)
{
_shop.attemptShopOpen(player);
openShop(player, player);
}
public void openShop(Player player, Player target)
{
_shop.attemptShopOpen(player, target);
openShop(player, target.getName(), _statsManager.Get(target));
}
public void openShop(Player player, String targetName, PlayerStats targetStats)
{
_shop.attemptShopOpen(player, targetName, targetStats);
}
@EventHandler
@ -188,6 +205,11 @@ public class AchievementManager extends MiniPlugin
{
int level = get(sender, Achievement.GLOBAL_MINEPLEX_LEVEL).getLevel();
if (NO_FAKE_LEVELS.contains(sender.getName()))
{
return level;
}
if (sender.getName().equalsIgnoreCase("B2_mp"))
return 101;
@ -212,7 +234,12 @@ public class AchievementManager extends MiniPlugin
{
return Achievement.getExperienceString(getMineplexLevelNumber(sender, rank)) + " " + ChatColor.RESET;
}
public CoreClientManager getClientManager()
{
return _clientManager;
}
public void setShopEnabled(boolean var)
{
_shopEnabled = var;
@ -222,4 +249,9 @@ public class AchievementManager extends MiniPlugin
{
return _incognitoManager;
}
public StatsManager getStatsManager()
{
return _statsManager;
}
}

View File

@ -1,5 +1,6 @@
package mineplex.core.achievement.command;
import mineplex.core.stats.PlayerStats;
import org.bukkit.entity.Player;
import mineplex.core.achievement.AchievementManager;
@ -9,6 +10,8 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import java.sql.SQLException;
public class StatsCommand extends CommandBase<AchievementManager>
{
public StatsCommand(AchievementManager plugin)
@ -29,6 +32,7 @@ public class StatsCommand extends CommandBase<AchievementManager>
if (target == null)
{
if (Plugin.getClientManager().hasRank(caller, Rank.MODERATOR)) attemptOffline(caller, args);
return;
}
@ -43,4 +47,47 @@ public class StatsCommand extends CommandBase<AchievementManager>
Plugin.openShop(caller, target);
}
}
private void attemptOffline(Player caller, String[] args)
{
if (args.length == 0)
{
Plugin.openShop(caller);
}
else
{
UtilPlayer.message(caller, F.main("Stats", "Attempting to look up offline stats..."));
final String playerName = args[0];
Plugin.runAsync(() -> {
try
{
PlayerStats stats = Plugin.getStatsManager().getOfflinePlayerStats(playerName);
if (stats == null)
{
Plugin.runSync(() -> offlinePlayerNotFound(caller, playerName));
}
else
{
Plugin.runSync(() -> openShop(caller, playerName, stats));
}
} catch (SQLException e)
{
Plugin.runSync(() -> UtilPlayer.message(caller, F.main("Stats", "There was an error trying to look up offline player " + F.elem(playerName))));
e.printStackTrace();
}
});
}
}
private void offlinePlayerNotFound(Player caller, String searchName)
{
UtilPlayer.message(caller, F.main("Stats", "Offline Player " + F.elem(searchName) + " not found."));
}
private void openShop(Player caller, String searchName, PlayerStats playerStats)
{
Plugin.openShop(caller, searchName, playerStats);
}
}

View File

@ -1,5 +1,6 @@
package mineplex.core.achievement.ui;
import mineplex.core.stats.PlayerStats;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
@ -26,15 +27,15 @@ public class AchievementShop extends ShopBase<AchievementManager>
@Override
protected ShopPageBase<AchievementManager, ? extends ShopBase<AchievementManager>> buildPagesFor(Player player)
{
return BuildPagesFor(player, player);
return BuildPagesFor(player, player.getName(), getPlugin().getStatsManager().Get(player));
}
protected ShopPageBase<AchievementManager, ? extends ShopBase<AchievementManager>> BuildPagesFor(Player player, Player target)
protected ShopPageBase<AchievementManager, ? extends ShopBase<AchievementManager>> BuildPagesFor(Player player, String targetName, PlayerStats targetStats)
{
return new AchievementMainPage(getPlugin(), _statsManager, this, getClientManager(), getDonationManager(), target.getName() + "'s Stats", player, target);
return new AchievementMainPage(getPlugin(), _statsManager, this, getClientManager(), getDonationManager(), targetName + "'s Stats", player, targetName, targetStats);
}
public boolean attemptShopOpen(Player player, Player target)
public boolean attemptShopOpen(Player player, String targetName, PlayerStats targetStats)
{
if (!getOpenedShop().contains(player.getName()))
{
@ -46,7 +47,7 @@ public class AchievementShop extends ShopBase<AchievementManager>
openShopForPlayer(player);
if (!getPlayerPageMap().containsKey(player.getName()))
{
getPlayerPageMap().put(player.getName(), BuildPagesFor(player, target));
getPlayerPageMap().put(player.getName(), BuildPagesFor(player, targetName, targetStats));
}
openPageForPlayer(player, getOpeningPageForPlayer(player));

View File

@ -1,5 +1,6 @@
package mineplex.core.achievement.ui.button;
import mineplex.core.stats.PlayerStats;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
@ -19,22 +20,26 @@ public class ArcadeButton implements IButton
private StatsManager _statsManager;
private DonationManager _donationManager;
private CoreClientManager _clientManager;
private Player _target;
public ArcadeButton(AchievementShop shop, AchievementManager achievementManager, StatsManager statsManager, DonationManager donationManager, CoreClientManager clientManager, Player target)
private String _targetName;
private PlayerStats _targetStats;
public ArcadeButton(AchievementShop shop, AchievementManager achievementManager, StatsManager statsManager, DonationManager donationManager, CoreClientManager clientManager, String targetName, PlayerStats targetStats)
{
_shop = shop;
_achievementManager = achievementManager;
_statsManager = statsManager;
_donationManager = donationManager;
_clientManager = clientManager;
_target = target;
_targetName = targetName;
_targetStats = targetStats;
}
@Override
public void onClick(Player player, ClickType clickType)
{
_shop.openPageForPlayer(player, new ArcadeMainPage(_achievementManager, _statsManager, _shop, _clientManager, _donationManager, "Arcade Games", player, _target));
_shop.openPageForPlayer(player, new ArcadeMainPage(_achievementManager, _statsManager, _shop, _clientManager, _donationManager, "Arcade Games", player, _targetName, _targetStats));
player.playSound(player.getLocation(), Sound.CLICK, 1, 1);
}

View File

@ -1,5 +1,6 @@
package mineplex.core.achievement.ui.button;
import mineplex.core.stats.PlayerStats;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
@ -24,9 +25,11 @@ public class CategoryButton implements IButton
private StatsManager _statsManager;
private DonationManager _donationManager;
private CoreClientManager _clientManager;
private Player _target;
public CategoryButton(AchievementShop shop, AchievementManager achievementManager, StatsManager statsManager, AchievementCategory category, DonationManager donationManager, CoreClientManager clientManager, Player target)
private String _targetName;
private PlayerStats _targetStats;
public CategoryButton(AchievementShop shop, AchievementManager achievementManager, StatsManager statsManager, AchievementCategory category, DonationManager donationManager, CoreClientManager clientManager, String targetName, PlayerStats targetStats)
{
_category = category;
_shop = shop;
@ -34,13 +37,14 @@ public class CategoryButton implements IButton
_statsManager = statsManager;
_donationManager = donationManager;
_clientManager = clientManager;
_target = target;
_targetName = targetName;
_targetStats = targetStats;
}
@Override
public void onClick(Player player, ClickType clickType)
{
_shop.openPageForPlayer(player, new AchievementPage(_achievementManager, _statsManager, _category, _shop, _clientManager, _donationManager, player, _target));
_shop.openPageForPlayer(player, new AchievementPage(_achievementManager, _statsManager, _category, _shop, _clientManager, _donationManager, player, _targetName, _targetStats));
player.playSound(player.getLocation(), Sound.CLICK, 1, 1);
}

View File

@ -3,6 +3,7 @@ package mineplex.core.achievement.ui.page;
import java.util.ArrayList;
import java.util.List;
import mineplex.core.stats.PlayerStats;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -24,19 +25,22 @@ import mineplex.core.stats.StatsManager;
public class AchievementMainPage extends ShopPageBase<AchievementManager, AchievementShop>
{
protected Player _target;
protected StatsManager _statsManager;
public AchievementMainPage(AchievementManager plugin, StatsManager statsManager, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, Player target)
protected String _targetName;
protected PlayerStats _targetStats;
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, 9 * 4, player, target);
this(plugin, statsManager, shop, clientManager, donationManager, name, player, 9 * 4, targetName, targetStats);
}
public AchievementMainPage(AchievementManager plugin, StatsManager statsManager, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, int size, Player player, Player target)
public AchievementMainPage(AchievementManager plugin, StatsManager statsManager, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, int size, String targetName, PlayerStats targetStats)
{
super(plugin, shop, clientManager, donationManager, name, player, size);
_target = target;
_targetName = targetName;
_targetStats = targetStats;
_statsManager = statsManager;
buildPage();
@ -58,12 +62,12 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
continue;
CategoryButton button = new CategoryButton(getShop(), getPlugin(), _statsManager, category, getDonationManager(),
getClientManager(), _target);
getClientManager(), _targetName, _targetStats);
ArrayList<String> lore = new ArrayList<String>();
lore.add(" ");
category.addStats(getClientManager(), _statsManager, lore, category == AchievementCategory.GLOBAL ? 10 : 2,
getPlayer(), _target);
getPlayer(), _targetName, _targetStats);
lore.add(" ");
addAchievements(category, lore, 9);
lore.add(ChatColor.RESET + "Click for more details!");
@ -78,7 +82,7 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
protected void addArcadeButton(int slot)
{
ArcadeButton button = new ArcadeButton(getShop(), getPlugin(), _statsManager, getDonationManager(), getClientManager(), _target);
ArcadeButton button = new ArcadeButton(getShop(), getPlugin(), _statsManager, getDonationManager(), getClientManager(), _targetName, _targetStats);
ShopItem shopItem = new ShopItem(Material.BOW, (byte) 0, C.Bold + "Arcade Games", new String[] {" ", ChatColor.RESET + "Click for more!"}, 1, false, false);
addButton(slot, shopItem, button);
@ -96,7 +100,7 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
if (achievement.getMaxLevel() > 1)
continue;
AchievementData data = getPlugin().get(_target, achievement);
AchievementData data = getPlugin().get(_targetStats, achievement);
boolean finished = data.getLevel() >= achievement.getMaxLevel();
lore.add((finished ? C.cGreen : C.cRed) + achievement.getName());

View File

@ -10,12 +10,14 @@ import mineplex.core.achievement.AchievementData;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.achievement.ui.AchievementShop;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
import mineplex.core.elo.EloManager;
import mineplex.core.elo.EloManager.EloDivision;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.core.stats.PlayerStats;
import mineplex.core.stats.StatsManager;
import org.bukkit.ChatColor;
@ -33,17 +35,21 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
private AchievementCategory _category;
private StatsManager _statsManager;
private EloManager _eloManager;
private Player _target;
public AchievementPage(AchievementManager plugin, StatsManager statsManager, AchievementCategory category, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, Player target)
private String _targetName;
private PlayerStats _targetStats;
public AchievementPage(AchievementManager plugin, StatsManager statsManager, AchievementCategory category, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, String targetName, PlayerStats targetStats)
{
super(plugin, shop, clientManager, donationManager, category.getFriendlyName(), player);
_statsManager = statsManager;
_category = category;
_target = target;
_eloManager = plugin.getEloManager();
_targetName = targetName;
_targetStats = targetStats;
buildPage();
}
@ -60,7 +66,7 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
List<Achievement> achievements = getAchievements();
for (Achievement achievement : achievements)
{
AchievementData data = getPlugin().get(_target, achievement);
AchievementData data = getPlugin().get(_targetStats, achievement);
boolean singleLevel = achievement.isSingleLevel();
boolean hasUnlocked = data.getLevel() >= achievement.getMaxLevel();
@ -117,7 +123,7 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
{
String itemName = ChatColor.RESET + _category.getFriendlyName() + " Master Achievement";
masterAchievementLore.add(" ");
if (getPlayer().equals(_target))
if (getPlayer().getName().equalsIgnoreCase(_targetName))
{
if (_category.getReward() != null)
masterAchievementLore.add(C.cYellow + C.Bold + "Reward: " + ChatColor.RESET + _category.getReward());
@ -141,9 +147,9 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
{
AchievementMainPage page;
if (_category.getGameCategory() == AchievementCategory.GameCategory.ARCADE)
page = new ArcadeMainPage(getPlugin(), _statsManager, getShop(), getClientManager(), getDonationManager(), "Arcade Games", player, _target);
page = new ArcadeMainPage(getPlugin(), _statsManager, getShop(), getClientManager(), getDonationManager(), "Arcade Games", player, _targetName, _targetStats);
else
page = new AchievementMainPage(getPlugin(), _statsManager, getShop(), getClientManager(), getDonationManager(), _target.getName() + "'s Stats", player, _target);
page = new AchievementMainPage(getPlugin(), _statsManager, getShop(), getClientManager(), getDonationManager(), _targetName + "'s Stats", player, _targetName, _targetStats);
;
getShop().openPageForPlayer(getPlayer(), page);
@ -162,7 +168,7 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
String itemName = C.Bold + _category.getFriendlyName() + " Stats";
List<String> lore = new ArrayList<String>();
lore.add(" ");
_category.addStats(getClientManager(), _statsManager, lore, getPlayer(), _target);
_category.addStats(getClientManager(), _statsManager, lore, getPlayer(), _targetName, _targetStats);
ItemStack item = new ItemStack(material);
ItemMeta meta = item.getItemMeta();
@ -175,27 +181,31 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
private void addDivisionDisplay()
{
if (_category.getFriendlyName().startsWith("Global"))
return;
if (!_category.DisplayDivision || _category.GameId.length < 1)
return;
if (_category.GameId.length > 1)
Player target = UtilPlayer.searchExact(_targetName);
if (target != null)
{
for (int i = 0; i < _category.GameId.length; i++)
if (_category.getFriendlyName().startsWith("Global"))
return;
if (!_category.DisplayDivision || _category.GameId.length < 1)
return;
if (_category.GameId.length > 1)
{
int id = _category.GameId[i];
int elo = _eloManager.getElo(_target, id);
for (int i = 0; i < _category.GameId.length; i++)
{
int id = _category.GameId[i];
int elo = _eloManager.getElo(target, id);
ItemStack disp = EloDivision.getDivision(elo).getVisual(elo);
setItem(44 + i + 1, disp);
}
} else
{
int id = _category.GameId[0];
int elo = _eloManager.getElo(target, id);
ItemStack disp = EloDivision.getDivision(elo).getVisual(elo);
setItem(44 + i + 1, disp);
setItem(49, disp);
}
}
else
{
int id = _category.GameId[0];
int elo = _eloManager.getElo(_target, id);
ItemStack disp = EloDivision.getDivision(elo).getVisual(elo);
setItem(49, disp);
}
}
public List<Achievement> getAchievements()

View File

@ -2,6 +2,7 @@ package mineplex.core.achievement.ui.page;
import java.util.ArrayList;
import mineplex.core.stats.PlayerStats;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -21,11 +22,9 @@ import mineplex.core.stats.StatsManager;
public class ArcadeMainPage extends AchievementMainPage
{
public ArcadeMainPage(AchievementManager plugin, StatsManager statsManager, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, Player target)
public ArcadeMainPage(AchievementManager plugin, StatsManager statsManager, AchievementShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, String targetName, PlayerStats targetStats)
{
super(plugin, statsManager, shop, clientManager, donationManager, name, 9 * 5, player, target);
super(plugin, statsManager, shop, clientManager, donationManager, name, player, 9 * 5, targetName, targetStats);
}
@Override
@ -38,11 +37,11 @@ public class ArcadeMainPage extends AchievementMainPage
if (category.getGameCategory() != AchievementCategory.GameCategory.ARCADE)
continue;
CategoryButton button = new CategoryButton(getShop(), getPlugin(), _statsManager, category, getDonationManager(), getClientManager(), _target);
CategoryButton button = new CategoryButton(getShop(), getPlugin(), _statsManager, category, getDonationManager(), getClientManager(), _targetName, _targetStats);
ArrayList<String> lore = new ArrayList<String>();
lore.add(" ");
category.addStats(getClientManager(), _statsManager, lore, 2, getPlayer(), _target);
category.addStats(getClientManager(), _statsManager, lore, 2, getPlayer(), _targetName, _targetStats);
lore.add(" ");
addAchievements(category, lore, 9);
lore.add(" ");
@ -63,7 +62,7 @@ public class ArcadeMainPage extends AchievementMainPage
{
public void onClick(Player player, ClickType clickType)
{
getShop().openPageForPlayer(getPlayer(), new AchievementMainPage(getPlugin(), _statsManager, getShop(), getClientManager(), getDonationManager(), _target.getName() + "'s Stats", player, _target));
getShop().openPageForPlayer(getPlayer(), new AchievementMainPage(getPlugin(), _statsManager, getShop(), getClientManager(), getDonationManager(), _targetName + "'s Stats", player, _targetName, _targetStats));
player.playSound(player.getLocation(), Sound.CLICK, 1, 1);
}
});

View File

@ -62,13 +62,16 @@ import java.util.function.Predicate;
@ReflectivelyCreateMiniPlugin
public class AntiHack extends MiniPlugin
{
public static final Map<String, CheckThresholds> CHECKS = ImmutableMap.of(
"Killaura (Type A)", new CheckThresholds("Kill Aura", 25, 50),
"Killaura (Type B)", new CheckThresholds("High CPS", 0, Integer.MAX_VALUE),
"Killaura (Type C)", new CheckThresholds("Reach", Integer.MAX_VALUE, Integer.MAX_VALUE),
"Killaura (Type D)", new CheckThresholds("Kill Aura", 1000, 1500),
"BadPackets", new CheckThresholds("Regen", 1000, 2000)
);
public static final Map<String, CheckThresholds> CHECKS = ImmutableMap.<String, CheckThresholds>builder()
.put("Killaura (Type A)", new CheckThresholds("Kill Aura", 0, 25, 50))
.put("Killaura (Type B)", new CheckThresholds("High CPS", 0, 0, Integer.MAX_VALUE))
.put("Killaura (Type C)", new CheckThresholds("Reach", 0, Integer.MAX_VALUE, Integer.MAX_VALUE))
.put("Killaura (Type D)", new CheckThresholds("Kill Aura", 500, 1000, 1500))
.put("BadPackets", new CheckThresholds("Regen", 500, 1000, 2000))
.put("Glide", new CheckThresholds("Flying", 50, 100, 200)) // TODO: specific VL levels
.put("Speed", new CheckThresholds("Speed", 50, 100, 200)) // TODO: specific VL levels
.put("HeadRoll", new CheckThresholds("Illegal Movement", 0, 0, 0))
.build();
public static final String NAME = "Chiss";
public static final String USER_HAS_BEEN_BANNED = F.main("GWEN", "%s has been banned. I am always watching");
@ -148,7 +151,7 @@ public class AntiHack extends MiniPlugin
DisguiseManager disguiseManager = require(DisguiseManager.class);
this._thisServer = UtilServer.getServerNameFromConfig();
this._thisServer = UtilServer.getServerName();
_repository = new AntiHackRepository(this._thisServer);
_repository.initialize();
@ -176,6 +179,24 @@ public class AntiHack extends MiniPlugin
{
return UtilPlayer.isSpectator(player);
}
@Override
public double getTPS()
{
return MinecraftServer.getServer().recentTps[0]; // Return the average TPS from the last minute
}
@Override
public int getPing(Player player)
{
return Math.min(((CraftPlayer)player).getHandle().ping, 1000);
}
@Override
public boolean isUsingItem(Player player)
{
return ((CraftPlayer)player).getHandle().bS(); // See Anticheat javadoc
}
}, this._plugin, ServicePriority.Normal);
ServerCommandManager.getInstance().registerCommandType(MajorViolationCommand.class, violation ->
@ -333,7 +354,7 @@ public class AntiHack extends MiniPlugin
)
)
.addSibling(
new ChatComponentText(": " + violation.getMessage() + ". Please investigate!")
new ChatComponentText(": " + violation.getMessage() + ".")
.setChatModifier(
new ChatModifier()
.setColor(EnumChatFormat.YELLOW)
@ -408,7 +429,7 @@ public class AntiHack extends MiniPlugin
}
return component.addSibling(
new ChatComponentText(". Please investigate!")
new ChatComponentText(".")
.setChatModifier(
new ChatModifier()
.setColor(EnumChatFormat.YELLOW)
@ -455,10 +476,10 @@ public class AntiHack extends MiniPlugin
double baseDeg = 18;
Location center = player.getLocation().add(0, heightAdj, 0);
AntiHackGuardian north = new AntiHackGuardian(center.clone().add(0, 0, -radius), 0, 0, 0, 0, 0, 0);
AntiHackGuardian east = new AntiHackGuardian(center.clone().add(radius, 0, 0), 0, 0, 0, 0, 0, 0);
AntiHackGuardian south = new AntiHackGuardian(center.clone().add(0, 0, radius), 0, 0, 0, 0, 0, 0);
AntiHackGuardian west = new AntiHackGuardian(center.clone().add(-radius, 0, 0), 0, 0, 0, 0, 0, 0);
AntiHackGuardian north = new AntiHackGuardian(center.clone().add(0, 0, -radius), 0, 0, 0, 0, 0, 0, false);
AntiHackGuardian east = new AntiHackGuardian(center.clone().add(radius, 0, 0), 0, 0, 0, 0, 0, 0, false);
AntiHackGuardian south = new AntiHackGuardian(center.clone().add(0, 0, radius), 0, 0, 0, 0, 0, 0, false);
AntiHackGuardian west = new AntiHackGuardian(center.clone().add(-radius, 0, 0), 0, 0, 0, 0, 0, 0, false);
UtilEnt.CreatureLook(east.getEntity(), player);
UtilEnt.CreatureLook(west.getEntity(), player);
@ -973,7 +994,20 @@ public class AntiHack extends MiniPlugin
{
if (event.shouldTellStaff())
{
String key = event.getPlayer().getName() + "." + event.getHackType() + "." + CHECKS.get(event.getHackType()).getSeverity(event.getViolations()).toString();
CheckThresholds thresholds = CHECKS.get(event.getHackType());
if (thresholds == null)
{
thresholds = new CheckThresholds(event.getHackType(), 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
}
CheckThresholds.Severity severity = thresholds.getSeverity(event.getViolations());
if (severity == CheckThresholds.Severity.NONE)
{
return;
}
String key = event.getPlayer().getName() + "." + event.getHackType() + "." + severity.toString();
Integer pastVl = this._cooldown.getIfPresent(key);
if (pastVl != null)
{
@ -1005,7 +1039,7 @@ public class AntiHack extends MiniPlugin
if (_clientManager.Get(staff).GetRank().has(Rank.MODERATOR))
{
UtilPlayer.message(staff, C.cAqua + C.Scramble + "A" + ChatColor.RESET + C.cRed + C.Bold + " MAC > " + ChatColor.RESET + C.cYellow + report);
UtilPlayer.message(staff, C.cAqua + C.Scramble + "A" + ChatColor.RESET + C.cRed + C.Bold + " MAC > " + ChatColor.RESET + C.cGold + player.getName() + C.cYellow + " has extreme violation. Please investigate.");
UtilPlayer.message(staff, C.cAqua + C.Scramble + "A" + ChatColor.RESET + C.cRed + C.Bold + " MAC > " + ChatColor.RESET + C.cGold + player.getName() + C.cYellow + " has extreme violation.");
handled = true;
}

View File

@ -70,6 +70,11 @@ public class AntiHackGuardian implements Listener
private final double CENTER_Z;
public AntiHackGuardian(Location center, int maxX, int minX, int maxY, int minY, int maxZ, int minZ)
{
this(center,maxX,minX, maxY, minY, maxZ, minZ, true);
}
public AntiHackGuardian(Location center, int maxX, int minX, int maxY, int minY, int maxZ, int minZ, boolean hideForStaff)
{
UtilServer.RegisterEvents(this);
@ -107,6 +112,8 @@ public class AntiHackGuardian implements Listener
disguiseManager.disguise(this._disguise, player ->
{
if (!hideForStaff) return true;
// Don't let Builder -> Admin see it
Rank rank = clientManager.Get(player).GetRank();
if (rank.has(Rank.MAPDEV))

View File

@ -8,12 +8,14 @@ import net.minecraft.server.v1_8_R3.IChatBaseComponent;
public class CheckThresholds
{
private final String _friendlyName;
private final int _low;
private final int _med;
private final int _high;
public CheckThresholds(String friendlyName, int med, int high)
public CheckThresholds(String friendlyName, int low, int med, int high)
{
_friendlyName = friendlyName;
_low = low;
_med = med;
_high = high;
}
@ -39,14 +41,17 @@ public class CheckThresholds
{
return Severity.MEDIUM;
} else
} else if (violationLevel >= _low)
{
return Severity.LOW;
}
return Severity.NONE;
}
public enum Severity
{
NONE(EnumChatFormat.GREEN),
LOW(EnumChatFormat.GREEN),
MEDIUM(EnumChatFormat.GOLD),
HIGH(EnumChatFormat.RED),

View File

@ -2,6 +2,7 @@ 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 mineplex.core.common.util.UtilServer;
import org.bukkit.event.Listener;
@ -20,6 +21,7 @@ public abstract class AntiHackAction implements Listener
static
{
ACTIONS.put(KillauraTypeA.class, new ImmediateBanAction(200));
ACTIONS.put(KillauraTypeD.class, new BanwaveAction(2000));
}
private int _vl;

View File

@ -3,18 +3,17 @@ package mineplex.core.antihack.actions;
import com.mineplex.anticheat.api.PlayerViolationEvent;
import mineplex.core.Managers;
import mineplex.core.antihack.banwave.BanWaveManager;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import java.util.Date;
class BanwaveAction extends AntiHackAction
{
private Date nextBanWave;
private static final int BAN_DELAY_AVERAGE = 6 * 60 * 60 * 1000; // 6 hours
private static final int BAN_DELAY_VARIANCE_SPAN = 4 * 60 * 60 * 1000; // 4 hours total; 2 on either side
BanwaveAction(Date nextBanWave, int vl)
BanwaveAction(int vl)
{
super(vl);
this.nextBanWave = nextBanWave;
}
@Override
@ -22,13 +21,15 @@ class BanwaveAction extends AntiHackAction
{
if (event.getViolations() >= this.getMinVl())
{
// Delay bans by 6 hours +/- 2 hours for fuzzing
long banTime = System.currentTimeMillis() + BAN_DELAY_AVERAGE + (UtilMath.r(BAN_DELAY_VARIANCE_SPAN) - (BAN_DELAY_VARIANCE_SPAN / 2));
Managers.get(BanWaveManager.class).insertBanWaveInfo(
event.getPlayer(),
nextBanWave.getTime(),
banTime,
event.getCheckClass(),
event.getMessage(),
"[GWEN] Hacking [BanWave]",
event.getViolations(),
UtilServer.getServerNameFromConfig()
UtilServer.getServerName()
);
}
}

View File

@ -1,12 +1,9 @@
package mineplex.core.antihack.banwave;
import java.util.Objects;
public class BanWaveInfo
{
/**
* The unique id for this BanWaveInfo
*/
private int _id;
/**
* The account id for this BanWaveInfo
*/
@ -17,11 +14,6 @@ public class BanWaveInfo
*/
private long _timeToBan;
/**
* Whether this BanWaveInfo has been executed
*/
private boolean _banned;
/**
* The hack type
*/
@ -42,16 +34,6 @@ public class BanWaveInfo
*/
private String _server;
public int getId()
{
return _id;
}
public void setId(int id)
{
_id = id;
}
public int getAccountId()
{
return _accountId;
@ -72,16 +54,6 @@ public class BanWaveInfo
_timeToBan = timeToBan;
}
public boolean isBanned()
{
return _banned;
}
public void setBanned(boolean banned)
{
_banned = banned;
}
public String getHackType()
{
return _hackType;
@ -130,28 +102,18 @@ public class BanWaveInfo
BanWaveInfo that = (BanWaveInfo) o;
if (_id != that._id) return false;
if (_accountId != that._accountId) return false;
if (_timeToBan != that._timeToBan) return false;
if (_banned != that._banned) return false;
if (_vl != that._vl) return false;
if (_hackType != null ? !_hackType.equals(that._hackType) : that._hackType != null) return false;
if (_message != null ? !_message.equals(that._message) : that._message != null) return false;
return _server != null ? _server.equals(that._server) : that._server == null;
return Objects.equals(_accountId, that._accountId)
&& Objects.equals(_timeToBan, that._timeToBan)
&& Objects.equals(_vl, that._vl)
&& Objects.equals(_hackType, that._hackType)
&& Objects.equals(_message, that._message)
&& Objects.equals(_server, that._server);
}
@Override
public int hashCode()
{
int result = _id;
result = 31 * result + _accountId;
result = 31 * result + (int) (_timeToBan ^ (_timeToBan >>> 32));
result = 31 * result + (_banned ? 1 : 0);
result = 31 * result + (_hackType != null ? _hackType.hashCode() : 0);
result = 31 * result + (_message != null ? _message.hashCode() : 0);
result = 31 * result + _vl;
result = 31 * result + (_server != null ? _server.hashCode() : 0);
return result;
return Objects.hash(_accountId, _timeToBan, _hackType, _message, _vl, _server);
}
}

View File

@ -9,8 +9,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import java.util.List;
@ReflectivelyCreateMiniPlugin
public class BanWaveManager extends MiniPlugin
{
@ -28,28 +26,16 @@ public class BanWaveManager extends MiniPlugin
{
CoreClient client = require(CoreClientManager.class).Get(event.getPlayer());
List<BanWaveInfo> infos = _repository.getBanWaveInfo(client.getAccountId());
long now = System.currentTimeMillis();
boolean banned = false;
for (BanWaveInfo info : infos)
_repository.getPendingBanWaveInfo(client.getAccountId(), info ->
{
if (info.getTimeToBan() < now && !info.isBanned())
long now = System.currentTimeMillis();
if (info.getTimeToBan() < now)
{
banned = true;
require(AntiHack.class).doBanWave(event.getPlayer(), info.getMessage());
break;
}
}
if (banned)
{
for (BanWaveInfo info : infos)
{
_repository.flagDone(info);
}
}
});
});
}

View File

@ -1,5 +1,6 @@
package mineplex.core.antihack.banwave;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UtilServer;
import mineplex.core.database.MinecraftRepository;
import mineplex.serverdata.database.DBPool;
@ -7,27 +8,33 @@ import mineplex.serverdata.database.column.ColumnInt;
import mineplex.serverdata.database.column.ColumnLong;
import mineplex.serverdata.database.column.ColumnVarChar;
import java.util.ArrayList;
import java.util.List;
public class BanWaveRepository extends MinecraftRepository
{
private static final String TABLE_NAME = "banwave";
private static final String INITIALIZE_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" +
"id INT AUTO_INCREMENT, " +
"accountId INT NOT NULL, " +
private static final String INITIALIZE_PENDING_TABLE = "CREATE TABLE IF NOT EXISTS banwavePending (" +
"accountId INT(11) NOT NULL, " +
"timeToBan BIGINT UNSIGNED NOT NULL, " +
"banned TINYINT DEFAULT '0', " +
"hacktype VARCHAR(64), " +
"message VARCHAR(255), " +
"vl INT, " +
"server VARCHAR(32), " +
"PRIMARY KEY (id), " +
"INDEX (accountId))";
private static final String QUERY_BY_ACCOUNT = "SELECT * FROM " + TABLE_NAME + " WHERE accountId = ?";
private static final String INSERT_INTO_TABLE = "INSERT INTO " + TABLE_NAME + " (accountId, timeToBan, hacktype, message, vl, server) VALUES (?, ?, ?, ?, ?, ?)";
private static final String FLAG_DONE = "UPDATE " + TABLE_NAME + " SET banned = 1 WHERE id = ?";
"PRIMARY KEY (accountId)," +
"FOREIGN KEY (accountId) REFERENCES accounts(id))";
private static final String INITIALIZED_PROCESSED_TABLE = "CREATE TABLE IF NOT EXISTS banwaveProcessed (" +
"id INT NOT NULL AUTO_INCREMENT, " +
"accountId INT(11) NOT NULL, " +
"timeToBan BIGINT UNSIGNED NOT NULL, " +
"hacktype VARCHAR(64), " +
"message VARCHAR(255), " +
"vl INT, " +
"server VARCHAR(32), " +
"PRIMARY KEY (id)," +
"FOREIGN KEY (accountId) REFERENCES accounts(id))";
private static final String QUERY_PENDING = "SELECT * FROM banwavePending WHERE accountId = ?";
private static final String INSERT_PENDING = "INSERT IGNORE INTO banwavePending (accountId, timeToBan, hacktype, message, vl, server) VALUES (?, ?, ?, ?, ?, ?)";
private static final String PROCESS_WAVE_FOR_ACCOUNT = "INSERT INTO banwaveProcessed SELECT 0, accountId, timeToBan, hacktype, message, vl, server FROM banwavePending WHERE accountId = ?";
private static final String DELETE_PENDING = "DELETE FROM banwavePending WHERE accountId = ?";
BanWaveRepository()
{
@ -37,7 +44,7 @@ public class BanWaveRepository extends MinecraftRepository
@Override
protected void initialize()
{
executeUpdate(INITIALIZE_TABLE);
//executeUpdate(INITIALIZE_TABLE);
}
@Override
@ -46,34 +53,28 @@ public class BanWaveRepository extends MinecraftRepository
}
List<BanWaveInfo> getBanWaveInfo(int accountId)
void getPendingBanWaveInfo(int accountId, Callback<BanWaveInfo> callback)
{
List<BanWaveInfo> banWaveInfo = new ArrayList<>();
executeQuery(QUERY_BY_ACCOUNT, resultSet ->
executeQuery(QUERY_PENDING, resultSet ->
{
while (resultSet.next())
if (resultSet.next())
{
BanWaveInfo info = new BanWaveInfo();
info.setId(resultSet.getInt(1));
info.setAccountId(resultSet.getInt(2));
info.setTimeToBan(resultSet.getLong(3));
info.setBanned(resultSet.getInt(4) == 1);
info.setHackType(resultSet.getString(5));
info.setMessage(resultSet.getString(6));
info.setVl(resultSet.getInt(7));
info.setServer(resultSet.getString(8));
info.setAccountId(resultSet.getInt(1));
info.setTimeToBan(resultSet.getLong(2));
info.setHackType(resultSet.getString(3));
info.setMessage(resultSet.getString(4));
info.setVl(resultSet.getInt(5));
info.setServer(resultSet.getString(6));
banWaveInfo.add(info);
callback.run(info);
}
}, new ColumnInt("accountId", accountId));
return banWaveInfo;
}
void insertBanWaveInfo(int accountId, long timeToBan, String hackType, String message, int vl, String server)
{
executeInsert(INSERT_INTO_TABLE, null,
executeInsert(INSERT_PENDING, null,
new ColumnInt("accountId", accountId),
new ColumnLong("timeToBan", timeToBan),
new ColumnVarChar("hacktype", 64, hackType),
@ -85,6 +86,7 @@ public class BanWaveRepository extends MinecraftRepository
void flagDone(BanWaveInfo info)
{
executeUpdate(FLAG_DONE, new ColumnInt("id", info.getId()));
executeUpdate(PROCESS_WAVE_FOR_ACCOUNT, new ColumnInt("id", info.getAccountId()));
executeUpdate(DELETE_PENDING, new ColumnInt("id", info.getAccountId()));
}
}

View File

@ -28,9 +28,11 @@ import net.minecraft.server.v1_8_R3.EnumDirection;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutBed;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityVelocity;
import net.minecraft.server.v1_8_R3.PacketPlayOutMapChunk;
import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo;
@ -82,6 +84,10 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
// The map of which players should a disguise be shown to
private Map<DisguiseBase, Predicate<Player>> _disguisePlayerMap = new HashMap<>();
// todo understand how this works
private Map<Integer, PacketPlayOutEntityVelocity> _movePacketMap = new HashMap<>();
private Set<Integer> _goingUp = new HashSet<>();
private HashSet<String> _blockedNames = new HashSet<>();
private boolean _handlingPacket = false;
@ -98,7 +104,10 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
PacketPlayOutEntityMetadata.class,
PacketPlayOutSpawnEntityLiving.class,
PacketPlayOutUpdateAttributes.class,
PacketPlayOutEntityEquipment.class
PacketPlayOutEntityEquipment.class,
PacketPlayOutEntityVelocity.class,
PacketPlayOutEntity.PacketPlayOutRelEntityMove.class,
PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook.class
);
createBedChunk();
@ -431,6 +440,127 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
}
}
}
// honestly im not really sure how this works or what it's really meant to do
// it unbreaks squid in SSM though so I guess it's useful
// todo understand how it works
else if (packet instanceof PacketPlayOutEntityVelocity)
{
PacketPlayOutEntityVelocity velocityPacket = (PacketPlayOutEntityVelocity) packet;
// Only for viewers
if (velocityPacket.a == owner.getEntityId())
{
if (velocityPacket.c > 0)
_goingUp.add(velocityPacket.a);
}
else if (velocityPacket.b == 0 && velocityPacket.c == 0 && velocityPacket.d == 0)
{
return;
}
else if (_spawnPacketMap.containsKey(velocityPacket.a))
{
packetInfo.setCancelled(true);
}
}
else if (packet instanceof PacketPlayOutEntity.PacketPlayOutRelEntityMove)
{
final PacketPlayOutEntity.PacketPlayOutRelEntityMove movePacket = (PacketPlayOutEntity.PacketPlayOutRelEntityMove) packet;
// Only for viewers
if (movePacket.a == owner.getEntityId())
return;
if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c < 20)
{
_goingUp.remove(movePacket.a);
_movePacketMap.remove(movePacket.a);
}
if (!containsSpawnDisguise(owner, getActiveDisguise(movePacket.a)))
return;
final PacketPlayOutEntityVelocity velocityPacket = new PacketPlayOutEntityVelocity();
velocityPacket.a = movePacket.a;
velocityPacket.b = movePacket.b * 100;
velocityPacket.c = movePacket.c * 100;
velocityPacket.d = movePacket.d * 100;
if (_movePacketMap.containsKey(movePacket.a))
{
PacketPlayOutEntityVelocity lastVelocityPacket = _movePacketMap.get(movePacket.a);
velocityPacket.b = (int) (.8 * lastVelocityPacket.b);
velocityPacket.c = (int) (.8 * lastVelocityPacket.c);
velocityPacket.d = (int) (.8 * lastVelocityPacket.d);
}
_movePacketMap.put(movePacket.a, velocityPacket);
packetVerifier.bypassProcess(velocityPacket);
if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c > 20)
{
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
{
public void run()
{
packetVerifier.bypassProcess(velocityPacket);
}
});
}
if (getActiveDisguise(movePacket.a) instanceof DisguiseBlock)
{
}
}
else if (packet instanceof PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook)
{
final PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook movePacket = (PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook) packet;
// Only for viewers
if (movePacket.a == owner.getEntityId())
return;
if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c <= 20)
{
_goingUp.remove(movePacket.a);
_movePacketMap.remove(movePacket.a);
}
if (!containsSpawnDisguise(owner, getActiveDisguise(movePacket.a)))
return;
final PacketPlayOutEntityVelocity velocityPacket = new PacketPlayOutEntityVelocity();
velocityPacket.a = movePacket.a;
velocityPacket.b = movePacket.b * 100;
velocityPacket.c = movePacket.c * 100;
velocityPacket.d = movePacket.d * 100;
if (_movePacketMap.containsKey(movePacket.a))
{
PacketPlayOutEntityVelocity lastVelocityPacket = _movePacketMap.get(movePacket.a);
velocityPacket.b = (int) (.8 * lastVelocityPacket.b);
velocityPacket.c = (int) (.8 * lastVelocityPacket.c);
velocityPacket.d = (int) (.8 * lastVelocityPacket.d);
}
_movePacketMap.put(movePacket.a, velocityPacket);
packetVerifier.bypassProcess(velocityPacket);
if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c > 20)
{
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
{
public void run()
{
packetVerifier.bypassProcess(velocityPacket);
}
});
}
}
}
private void handlePacket(Packet packet, PacketVerifier verifier)

View File

@ -161,6 +161,9 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler
{
CoreClient client = _clients.Get(event.getPlayer());
if (!client.GetRank().has(event.getPlayer(), Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.TWITCH}, false))
return;
if (_redis.elementExists(client.getAccountId() + client.getName()))
{
DisguisePlayerBean bean = _redis.getElement(client.getAccountId() + client.getName());
@ -263,11 +266,6 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler
return this._punish;
}
public CosmeticManager getCostmeticManager()
{
return this._cosmetics;
}
public PreferencesManager getPreferencesManager()
{
return this._prefs;
@ -439,6 +437,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler
if (other.getName().equalsIgnoreCase(requestedUsername))
{
UtilPlayer.message(caller, C.cRed + F.main("Disguise", "This name is already in use!"));
_cannotJoin.remove(requestedUsername.toLowerCase());
return;
}
}

View File

@ -2,15 +2,13 @@ package mineplex.core.gadget.commands;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.donation.Donor;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.inventory.ClientInventory;
import mineplex.core.inventory.ClientItem;
import mineplex.core.mount.Mount;
import mineplex.core.pet.Pet;
import org.bukkit.entity.Player;
@ -72,54 +70,56 @@ public class LockCosmeticsCommand extends CommandBase<GadgetManager>
{
for (GadgetType type : GadgetType.values())
{
if (type == GadgetType.ITEM)
continue;
removeCosmetics(type, caller);
}
removeMounts(caller);
removePets(caller);
return;
}
ClientInventory clientInventory = _plugin.getInventoryManager().Get(caller);
Donor donor = _plugin.getDonationManager().Get(caller);
int removed = 0;
int amount = -1;
for (Gadget gadget : _plugin.getGadgets(gadgetType))
{
if (gadgetType == GadgetType.ITEM)
continue;
if (gadget.ownsGadget(caller))
if (gadget != null)
{
ClientItem clientItem = clientInventory.getClientItem(gadget.getName());
if (clientItem != null)
int i;
String[] names = new String[gadget.getAlternativePackageNames().length + 1];
for (i = 0; i < gadget.getAlternativePackageNames().length; i++)
{
clientInventory.removeItem(clientItem);
removed++;
names[i] = gadget.getAlternativePackageNames()[i];
}
names[i++] = gadget.getName();
for (String name : names)
{
if (donor.OwnsUnknownPackage(name))
{
donor.RemoveUnknownSalesPackagesOwned(name);
removed++;
}
}
}
}
UtilPlayer.message(caller, F.main("Cosmetics", "Removed all the " + gadgetType.name().toLowerCase()
.replace("_", " ") + " gadgets! (Removed " + C.cRed + removed + C.cGray + " " +
UtilText.plural("item", removed) + ")"));
UtilPlayer.message(caller, F.main("Lock Cosmetics", "Removed " + removed + F.elem(" " + gadgetType.getCategoryType()) + UtilText.plural(" item", removed) + "!"));
}
private void removeMounts(Player caller)
{
Donor donor = _plugin.getDonationManager().Get(caller);
int removed = 0;
ClientInventory clientInventory = _plugin.getInventoryManager().Get(caller);
for (Mount<?> mount : _plugin.getMountManager().getMounts())
{
if (mount.hasMount(caller))
if (donor.OwnsUnknownPackage(mount.getName()))
{
ClientItem clientItem = clientInventory.getClientItem(mount.getName());
if (clientItem != null)
{
clientInventory.removeItem(clientInventory.getClientItem(mount.getName()));
removed++;
}
donor.RemoveUnknownSalesPackagesOwned(mount.getName());
removed++;
}
else if (mount.hasMount(caller))
{
donor.RemoveUnknownSalesPackagesOwned(mount.getName());
removed++;
}
}
UtilPlayer.message(caller, F.main("Cosmetics", "Removed " + C.cRed + removed + C.cGray + " " +
UtilText.plural("mount", removed) + "!"));
UtilPlayer.message(caller, F.main("Lock Cosmetics", "Removed " + removed + UtilText.plural(" Mount", removed) + "!"));
}
private void removePets(Player caller)
@ -133,8 +133,7 @@ public class LockCosmeticsCommand extends CommandBase<GadgetManager>
removed++;
}
}
UtilPlayer.message(caller, F.main("Cosmetics", "Removed " + C.cRed + removed + C.cGray + " " +
UtilText.plural("pet", removed) + "!"));
UtilPlayer.message(caller, F.main("Lock Cosmetics", "Removed " + removed + UtilText.plural(" pet", removed) + "!"));
}
}

View File

@ -2,10 +2,10 @@ package mineplex.core.gadget.commands;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.donation.Donor;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
@ -65,47 +65,66 @@ public class UnlockCosmeticsCommand extends CommandBase<GadgetManager>
}
private void addCosmetics(GadgetType gadgetType, Player caller)
{
if (gadgetType == null)
{
for (GadgetType type : GadgetType.values())
{
addCosmetics(type, caller);
}
{
if (gadgetType == null)
{
for (GadgetType type : GadgetType.values())
{
addCosmetics(type, caller);
}
addMounts(caller);
addPets(caller);
return;
}
return;
}
Donor donor = _plugin.getDonationManager().Get(caller);
int added = 0;
int amount = 1;
for (Gadget gadget : _plugin.getGadgets(gadgetType))
{
if (gadgetType == GadgetType.ITEM)
amount = 20;
if (!gadget.ownsGadget(caller))
for (Gadget gadget : _plugin.getGadgets(gadgetType))
{
if (gadget != null)
{
_plugin.getInventoryManager().addItemToInventory(caller, gadget.getName(), amount);
added++;
boolean hasGadget = false;
int i;
String[] names = new String[gadget.getAlternativePackageNames().length + 1];
for (i = 0; i < gadget.getAlternativePackageNames().length; i++)
{
names[i] = gadget.getAlternativePackageNames()[i];
}
names[i++] = gadget.getName();
for (String name : names)
{
if (donor.OwnsUnknownPackage(name))
{
hasGadget = true;
}
}
if (!hasGadget)
{
donor.AddUnknownSalesPackagesOwned(gadget.getName());
added++;
}
}
}
UtilPlayer.message(caller, F.main("Cosmetics", "Added all the " + gadgetType.name().toLowerCase()
.replace("_", " ") + "! (Added " + C.cRed + added + C.cGray + " " +
UtilText.plural("item", added) + ")"));
}
UtilPlayer.message(caller, F.main("Unlock Cosmetics", "Added" + added + F.elem(" " + gadgetType.getCategoryType()) + UtilText.plural(" item", added) + "!"));
}
private void addMounts(Player caller)
{
Donor donor = _plugin.getDonationManager().Get(caller);
int added = 0;
for (Mount<?> mount : _plugin.getMountManager().getMounts())
{
if (!mount.hasMount(caller))
if (!donor.OwnsUnknownPackage(mount.getName()))
{
_plugin.getInventoryManager().addItemToInventory(caller, mount.getName(), 1);
donor.AddUnknownSalesPackagesOwned(mount.getName());
added++;
}
else if (!mount.hasMount(caller))
{
donor.AddUnknownSalesPackagesOwned(mount.getName());
added++;
}
}
UtilPlayer.message(caller, F.main("Cosmetics", "Added " + C.cRed + added + C.cGray + " " +
UtilText.plural("mount", added) + "!"));
UtilPlayer.message(caller, F.main("Unlock Cosmetics", "Added " + added + UtilText.plural(" mount", added) + "!"));
}
private void addPets(Player caller)
@ -119,7 +138,6 @@ public class UnlockCosmeticsCommand extends CommandBase<GadgetManager>
added++;
}
}
UtilPlayer.message(caller, F.main("Cosmetics", "Added " + C.cRed + added + C.cGray + " " +
UtilText.plural("pet", added) + "!"));
UtilPlayer.message(caller, F.main("Unlock Cosmetics", "Added " + added + UtilText.plural(" pet", added) + "!"));
}
}

View File

@ -83,6 +83,8 @@ public enum GameDisplay
Valentines("Valentines Vendetta", Material.LEATHER, (byte)0, GameCategory.EXTRA, 61),
Basketball("Hoops", Material.SLIME_BALL, (byte)0, GameCategory.EXTRA, 63),
QuiverPayload("One in the Quiver Payload", Material.ARROW, (byte)0, GameCategory.ARCADE, 64),
Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999),

View File

@ -56,21 +56,7 @@ public class ServerCommand extends CommandBase<Portal>
boolean deniedAccess = false;
String servUp = args[0].toUpperCase();
if (servUp.contains("HERO"))
{
if (playerRank.has(Rank.HERO))
Plugin.sendPlayerToServer(player, args[0]);
else
deniedAccess = true;
}
else if (servUp.contains("ULTRA") || servUp.contains("BETA"))
{
if (playerRank.has(Rank.ULTRA))
Plugin.sendPlayerToServer(player, args[0]);
else
deniedAccess = true;
}
else if (servUp.contains("STAFF"))
if (servUp.contains("STAFF"))
{
if (playerRank.has(Rank.HELPER))
Plugin.sendPlayerToServer(player, args[0]);

View File

@ -2,6 +2,7 @@ package mineplex.core.progression;
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.progression.data.PlayerKit;
import mineplex.core.progression.data.PlayerKitDataManager;
import org.bukkit.plugin.java.JavaPlugin;
@ -16,16 +17,23 @@ public class KitProgressionManager extends MiniClientPlugin<PlayerKit>
private PlayerKitDataManager _dataManager;
private KitProgressionRepository _kitProgressionRepository;
private DonationManager _donationManager;
private CoreClientManager _coreClientManager;
public KitProgressionManager(JavaPlugin plugin, CoreClientManager clientManager)
public KitProgressionManager(JavaPlugin plugin, DonationManager donationManager, CoreClientManager clientManager)
{
super("Kit Progression", plugin);
_dataManager = new PlayerKitDataManager();
_kitProgressionRepository = new KitProgressionRepository(this);
_donationManager = donationManager;
_coreClientManager = clientManager;
}
public DonationManager getDonationManager()
{
return _donationManager;
}
public CoreClientManager getClientManager()
{
return _coreClientManager;

View File

@ -285,4 +285,4 @@ public interface ProgressiveKit
ViewDist.NORMAL, displayTo);
}
}
}
}

View File

@ -0,0 +1,63 @@
package mineplex.core.progression.data;
import mineplex.core.server.util.TransactionResponse;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.F;
import mineplex.core.progression.KitProgressionManager;
import mineplex.core.progression.ProgressiveKit;
import mineplex.core.progression.math.Calculations;
import mineplex.core.shop.confirmation.ConfirmationCallback;
import mineplex.core.shop.confirmation.ConfirmationProcessor;
public class KitUpgradeProcessor implements ConfirmationProcessor
{
private KitProgressionManager _manager;
private Player _player;
private ProgressiveKit _kit;
private int _upgradeLevel;
public KitUpgradeProcessor(KitProgressionManager manager, Player player, ProgressiveKit kit, int upgradeLevel)
{
_manager = manager;
_player = player;
_kit = kit;
_upgradeLevel = upgradeLevel;
}
@Override
public void init(Inventory inventory)
{
}
@Override
public void process(ConfirmationCallback callback)
{
String packageName = _kit.getInternalName() + "." + _upgradeLevel;
int cost = Calculations.getGemsCost(_upgradeLevel);
// Use UnknownPackages for this right now as it handles overspending gems properly
_manager.getDonationManager().purchaseUnknownSalesPackage(data ->
{
if (data == TransactionResponse.Success)
{
_kit.upgrade(_upgradeLevel, _player.getUniqueId());
_player.playSound(_player.getLocation(), Sound.CAT_MEOW, 5.0f, 1.0f);
_player.sendMessage(F.main("Kit Progression", "Purchased upgrades for " + _kit.getDisplayName() + " level " + _upgradeLevel));
callback.resolve("Success! You now own this upgrade!");
}
else if (data == TransactionResponse.InsufficientFunds)
{
callback.reject("Insufficient funds!");
}
else
{
callback.reject("There was an error processing your transaction. Try again later");
}
}, _player, packageName, GlobalCurrency.GEM, cost, false);
}
}

View File

@ -0,0 +1,28 @@
package mineplex.core.progression.data;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.progression.KitProgressionManager;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
/*
* This is currently just used to open a confirmation menu and no other references should be made to this.
*/
public class KitUpgradeShop extends ShopBase<KitProgressionManager>
{
public KitUpgradeShop(KitProgressionManager plugin, CoreClientManager clientManager, DonationManager donationManager)
{
super(plugin, clientManager, donationManager, "Kit Upgrade");
}
@Override
protected ShopPageBase<KitProgressionManager, ? extends ShopBase<KitProgressionManager>> buildPagesFor(Player player)
{
return null;
}
}

View File

@ -1,14 +1,19 @@
package mineplex.core.progression.gui.buttons;
import mineplex.core.common.util.F;
import mineplex.core.menu.Menu;
import mineplex.core.progression.ProgressiveKit;
import java.util.UUID;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import java.util.UUID;
import mineplex.core.common.util.F;
import mineplex.core.menu.Menu;
import mineplex.core.progression.KitProgressionManager;
import mineplex.core.progression.ProgressiveKit;
import mineplex.core.progression.data.KitUpgradeProcessor;
import mineplex.core.progression.data.KitUpgradeShop;
import mineplex.core.shop.confirmation.ConfirmationPage;
/**
* @author Timothy Andis (TadahTech) on 4/7/2016.
@ -16,11 +21,13 @@ import java.util.UUID;
public class KitUpgradeButton extends KitButton
{
private KitProgressionManager _plugin;
private int _upgradeLevel;
public KitUpgradeButton(ProgressiveKit kit, ItemStack itemStack, int upgradeLevel)
public KitUpgradeButton(KitProgressionManager plugin, ProgressiveKit kit, ItemStack itemStack, int upgradeLevel)
{
super(kit, itemStack);
_plugin = plugin;
_upgradeLevel = upgradeLevel;
}
@ -35,15 +42,15 @@ public class KitUpgradeButton extends KitButton
player.sendMessage(F.main("Kit Progression", "You cannot purchase this upgrade!"));
return;
}
getKit().upgrade(_upgradeLevel, uuid);
player.playSound(player.getLocation(), Sound.CAT_MEOW, 5.0f, 1.0f);
player.sendMessage(F.main("Kit Progression", "Purchased upgrades for " + getKit().getDisplayName() + " level " + _upgradeLevel));
KitUpgradeShop shop = new KitUpgradeShop(_plugin, _plugin.getClientManager(), _plugin.getDonationManager());
KitUpgradeProcessor processor = new KitUpgradeProcessor(_plugin, player, getKit(), _upgradeLevel);
ConfirmationPage<KitProgressionManager, KitUpgradeShop> page = new ConfirmationPage<KitProgressionManager, KitUpgradeShop>(player, _plugin, shop, _plugin.getClientManager(), _plugin.getDonationManager(), processor, getItemStack());
shop.openPageForPlayer(player, page);
Menu.remove(uuid);
player.closeInventory();
//player.closeInventory();
}
}

View File

@ -2,6 +2,7 @@ package mineplex.core.progression.gui.buttons;
import com.google.common.collect.Lists;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.progression.KitProgressionManager;
import mineplex.core.progression.ProgressiveKit;
import mineplex.core.progression.gui.guis.KitInformationTrackerMenu;
import mineplex.core.progression.gui.guis.KitMenu;
@ -23,9 +24,9 @@ public class KitXPButton extends KitButton
private ItemStack _item;
public KitXPButton(ProgressiveKit kit, Player player)
public KitXPButton(ProgressiveKit kit, Player player, KitProgressionManager plugin)
{
super(kit, null);
super(kit, null, plugin);
ItemBuilder builder = new ItemBuilder(Material.EXP_BOTTLE);
builder.setTitle(ChatColor.YELLOW + "XP and Level");

View File

@ -63,7 +63,7 @@ public class KitDisplayMenu extends KitMenu
*/
private void setUpNextMenuButtons(Button[] buttons, Player player)
{
buttons[48] = new KitXPButton(getKit(), player);
buttons[48] = new KitXPButton(getKit(), player, getPlugin());
buttons[50] = new KitUpgradeMenuButton(getKit(), player, getPlugin());
}

View File

@ -1,6 +1,17 @@
package mineplex.core.progression.gui.guis;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.google.common.collect.Lists;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.menu.Button;
@ -11,15 +22,6 @@ import mineplex.core.progression.gui.buttons.KitUpgradeButton;
import mineplex.core.progression.gui.buttons.KitUpgradeDetailsButton;
import mineplex.core.progression.gui.buttons.misc.BackButton;
import mineplex.core.progression.math.Calculations;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* This is the secondary menu access by either the Enchantment table or XP Bottle
@ -174,8 +176,8 @@ public class KitInformationTrackerMenu extends KitMenu
itemStack.addLore("Costs " + C.cGreen + Calculations.getGemsCost(index) + C.cGray + " gems");
itemStack.addLore(C.cRed + "You cannot purchase this upgrade!");
}
KitUpgradeButton upgradeButton = new KitUpgradeButton(getKit(), itemStack.build(), index);
KitUpgradeButton upgradeButton = new KitUpgradeButton(getPlugin(), getKit(), itemStack.build(), index);
buttons[i] = upgradeButton;
}
return;

View File

@ -591,7 +591,7 @@ public class RewardManager
UnknownPackageReward reward =
new UnknownPackageReward(_donationManager, gadget.getGadgetType().getCategoryType(), displayName,
gadget.getName(), display, rarity,
weight, shards);
weight, shards, gadget.getAlternativePackageNames());
addReward(type, reward);
return reward;
}

View File

@ -19,6 +19,7 @@ public class UnknownPackageReward extends Reward
private String _header;
private String _name;
private String _packageName;
private String[] _alternativeNames;
public UnknownPackageReward(DonationManager donationManager, String header, String name, String packageName, ItemStack itemStack, RewardRarity rarity, int weight, int shardValue)
{
@ -28,6 +29,18 @@ public class UnknownPackageReward extends Reward
_name = name;
_packageName = packageName;
_itemStack = itemStack;
_alternativeNames = new String[]{};
}
public UnknownPackageReward(DonationManager donationManager, String header, String name, String packageName, ItemStack itemStack, RewardRarity rarity, int weight, int shardValue, String... alternativeNames)
{
super(rarity, weight, shardValue);
_donationManager = donationManager;
_header = header;
_name = name;
_packageName = packageName;
_itemStack = itemStack;
_alternativeNames = alternativeNames;
}
@Override
@ -46,8 +59,22 @@ public class UnknownPackageReward extends Reward
System.out.println("Could not give reward " + _packageName + " to Offline Player: " + player.getName());
return false;
}
return !_donationManager.Get(player).OwnsUnknownPackage(_packageName);
boolean hasItem = false;
if (_donationManager.Get(player).OwnsUnknownPackage(_packageName))
{
hasItem = true;
}
else
{
for (String altName : _alternativeNames)
{
if (_donationManager.Get(player).OwnsUnknownPackage(altName))
{
hasItem = true;
}
}
}
return !hasItem;
}
@Override

View File

@ -1,6 +1,7 @@
package mineplex.hub.server;
import mineplex.core.common.Rank;
import mineplex.serverdata.data.MinecraftServer;
public class ServerInfo
{
@ -12,9 +13,15 @@ public class ServerInfo
public String ServerType;
public String Game;
public Rank HostRank = Rank.ALL;
public MinecraftServer Server;
public int getAvailableSlots()
{
return MaxPlayers - CurrentPlayers;
}
public boolean isDevServer()
{
return Name.contains("-Dev-");
}
}

View File

@ -357,6 +357,7 @@ public class ServerManager extends MiniPlugin implements BrawlShopProvider
}
ServerInfo serverInfo = _serverInfoMap.get(serverStatus.getName());
serverInfo.Server = serverStatus;
serverInfo.MOTD = args.length > 0 ? args[0] : serverStatus.getMotd();
serverInfo.CurrentPlayers = serverStatus.getPlayerCount();
serverInfo.MaxPlayers = serverStatus.getMaxPlayerCount();
@ -563,7 +564,10 @@ public class ServerManager extends MiniPlugin implements BrawlShopProvider
{
if (isInProgress(server))
continue;
if (server.isDevServer())
continue;
if (results.size() >= count) break;
if (server.getAvailableSlots() > requiredSlots)
@ -742,7 +746,7 @@ public class ServerManager extends MiniPlugin implements BrawlShopProvider
public ServerNpcShop getBetaShop()
{
return _serverNpcShopMap.get("Beta Monster Maze");
return _serverNpcShopMap.get("Beta Games");
}
public ServerNpcShop getUHCShop()

View File

@ -71,12 +71,20 @@ public class ServerSorter implements Comparator<ServerInfo>
if (b.CurrentPlayers > a.CurrentPlayers)
return 1;
if (Integer.parseInt(a.Name.split("-")[1]) < Integer.parseInt(b.Name.split("-")[1]))
return -1;
else if (Integer.parseInt(a.Name.split("-")[1]) > Integer.parseInt(b.Name.split("-")[1]))
return 1;
return 0;
boolean isDevServerA = a.isDevServer();
boolean isDevServerB = b.isDevServer();
int serverIdA = Integer.parseInt(a.Name.substring(a.Name.lastIndexOf('-') + 1));
int serverIdB = Integer.parseInt(b.Name.substring(b.Name.lastIndexOf('-') + 1));
if (isDevServerA && isDevServerB)
return Integer.compare(serverIdA, serverIdB);
else if (isDevServerA)
return -1;
else if (isDevServerB)
return 1;
else
return Integer.compare(serverIdA, serverIdB);
}
}

View File

@ -169,7 +169,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
add(30, _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", "BB", "MB", "EVO", "GLD", "BL"};
"OITQ", "BBB", "MB", "EVO", "GLD", "BL"};
add(32, _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[]
@ -197,12 +197,12 @@ 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 + "Monster Maze " + C.cGray + "Snow Sprint", new String[]
add(41, Material.BREWING_STAND_ITEM, C.cYellowB + "One in the Quiver " + C.cGray + "Payload", new String[]
{
C.Reset + "",
C.Reset + "Run along a maze avoiding",
C.Reset + "evil monsters. Get to the",
C.Reset + "Safe-Pad or be killed!",
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));
}
@ -262,7 +262,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Super Paintball",
C.Reset + "Turf Wars",
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl").setHideInfo(true));
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.GOLD_BOOTS)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
@ -278,7 +280,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Super Paintball",
C.Reset + "Turf Wars",
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl").setHideInfo(true));
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.DRAGON_EGG)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
@ -294,7 +298,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Super Paintball",
C.Reset + "Turf Wars",
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl").setHideInfo(true));
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.BOW)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
@ -310,7 +316,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Super Paintball",
C.Reset + "Turf Wars",
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl").setHideInfo(true));
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.LEATHER_BOOTS)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
@ -326,9 +334,11 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Super Paintball",
C.Reset + "Turf Wars",
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl").setHideInfo(true));
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.MILK_BUCKET)
_minigameCycle.add(new ItemBuilder(Material.EMERALD)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
C.Reset + "Play all of these fun minigames and more!",
C.Reset + "",
@ -342,9 +352,11 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Super Paintball",
C.Reset + "Turf Wars",
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl").setHideInfo(true));
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.MILK_BUCKET)
_minigameCycle.add(new ItemBuilder(Material.LAVA_BUCKET)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
C.Reset + "Play all of these fun minigames and more!",
C.Reset + "",
@ -358,7 +370,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Super Paintball",
C.Reset + "Turf Wars",
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl").setHideInfo(true));
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.DIAMOND_BARDING)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
@ -374,7 +388,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + C.Bold + C.cGreen + "Super Paintball",
C.Reset + "Turf Wars",
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl").setHideInfo(true));
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.STAINED_CLAY, 1, (byte) 14)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
@ -390,7 +406,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Super Paintball",
C.Reset + C.Bold + C.cGreen + "Turf Wars",
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl").setHideInfo(true));
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.IRON_BOOTS)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
@ -406,7 +424,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Super Paintball",
C.Reset + "Turf Wars",
C.Reset + C.Bold + C.cGreen + "Death Tag",
C.Reset + "Bacon Brawl").setHideInfo(true));
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.PORK)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
@ -422,7 +442,45 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Super Paintball",
C.Reset + "Turf Wars",
C.Reset + "Death Tag",
C.Reset + C.Bold + C.cGreen + "Bacon Brawl").setHideInfo(true));
C.Reset + C.Bold + C.cGreen + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.EGG)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
C.Reset + "Play all of these fun minigames and more!",
C.Reset + "",
C.Reset + "Super Spleef",
C.Reset + "Runner",
C.Reset + "Dragons",
C.Reset + "One in the Quiver",
C.Reset + "Dragon Escape",
C.Reset + "Sneaky Assassins",
C.Reset + "Micro Battle",
C.Reset + "Super Paintball",
C.Reset + "Turf Wars",
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl",
C.Reset + C.Bold + C.cGreen + "Bawk Bawk Battles",
C.Reset + "Monster Maze").setHideInfo(true));
_minigameCycle.add(new ItemBuilder(Material.EMPTY_MAP)
.setTitle(C.Reset + C.Bold + C.cYellow + "Arcade " + C.cGray + "Mixed Games").addLore(C.Reset + "",
C.Reset + "Play all of these fun minigames and more!",
C.Reset + "",
C.Reset + "Super Spleef",
C.Reset + "Runner",
C.Reset + "Dragons",
C.Reset + "One in the Quiver",
C.Reset + "Dragon Escape",
C.Reset + "Sneaky Assassins",
C.Reset + "Micro Battle",
C.Reset + "Super Paintball",
C.Reset + "Turf Wars",
C.Reset + "Death Tag",
C.Reset + "Bacon Brawl",
C.Reset + "Bawk Bawk Battles",
C.Reset + C.Bold + C.cGreen + "Monster Maze").setHideInfo(true));
}
private void createSuperSmashCycle()

View File

@ -3,7 +3,9 @@ package mineplex.hub.server.ui;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -15,10 +17,6 @@ import org.bukkit.inventory.meta.SkullMeta;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.donation.DonationManager;
import mineplex.core.game.GameDisplay;
import mineplex.core.itemstack.ItemStackFactory;
@ -32,6 +30,8 @@ import mineplex.hub.server.ui.button.JoinServerButton;
public class ServerNpcPage extends ShopPageInventory<ServerManager, ServerNpcShop> implements IServerPage
{
private static final int MAX_FULL_SERVERS = 3;
// Shop Item Messages
private static final String MESSAGE_BETA_GET_ULTRA = ChatColor.RESET + C.Line + "Get Ultra to join Tournament servers!";
private static final String MESSAGE_JOIN = ChatColor.RESET + C.Line + "Click to Join";
@ -47,10 +47,10 @@ public class ServerNpcPage extends ShopPageInventory<ServerManager, ServerNpcSho
private IButton[] _buttons;
private ItemStack[] _items;
public ServerNpcPage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, String serverGroupName)
public ServerNpcPage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, String serverGroupName)
{
super(plugin, shop, clientManager, donationManager, name, player, 54);
_serverGroupName = serverGroupName;
buildPage();
@ -90,34 +90,7 @@ public class ServerNpcPage extends ShopPageInventory<ServerManager, ServerNpcSho
}
}
private void showClock(long milliseconds, boolean beta)
{
if (!beta)
{
return;
}
int seconds = (int) (milliseconds / 1000);
String timeLeft = UtilTime.convertString(milliseconds, 0, UtilTime.TimeUnit.FIT);
byte data = (byte) (milliseconds - (seconds * 1000) > 500 ? 15 : 14);
ShopItem item = new ShopItem(Material.WOOL, data, C.cGreen + C.Bold + "Advertisement", null, new String[] {
ChatColor.RESET + timeLeft + " Remaining...",
ChatColor.RESET + "",
ChatColor.RESET + C.cGreen + "Do you love playing on Mineplex?",
ChatColor.RESET + "If you do, please consider purchasing a premium rank",
ChatColor.RESET + "from the store! Money goes towards running servers",
ChatColor.RESET + "and creating exciting new games for everyone!",
ChatColor.RESET + "",
ChatColor.RESET + C.cYellow + "Purchasing a Rank disables this advertisement.",
ChatColor.RESET + "",
ChatColor.RESET + C.cGreen + "www.mineplex.com/shop"
}, seconds, false, false);
addItemStack(22, item);
}
private ShopItem buildShopItem(ServerInfo serverInfo, int slotsNeeded)
private ShopItem buildShopItem(ServerInfo serverInfo, int slotsNeeded, boolean isDev)
{
boolean ownsUltraPackage = getDonationManager().Get(getPlayer()).OwnsUnknownPackage(serverInfo.ServerType + " ULTRA") || getClient().GetRank().has(Rank.ULTRA);
Material status = Material.REDSTONE_BLOCK;
@ -127,7 +100,7 @@ public class ServerNpcPage extends ShopPageInventory<ServerManager, ServerNpcSho
String wait = (serverInfo.Game == null || serverInfo.ServerType.equalsIgnoreCase("Competitive")) ? null : MESSAGE_WAIT;
if (isStarting(serverInfo) && (serverInfo.MaxPlayers - serverInfo.CurrentPlayers) >= slotsNeeded)
status = Material.EMERALD_BLOCK;
status = isDev ? Material.COMMAND : Material.EMERALD_BLOCK;
else if (isInProgress(serverInfo))
status = Material.GOLD_BLOCK;
@ -137,7 +110,7 @@ public class ServerNpcPage extends ShopPageInventory<ServerManager, ServerNpcSho
lore.add(ChatColor.RESET + C.cYellow + "Game: " + C.cWhite + serverInfo.Game);
if (serverInfo.Map != null && !serverInfo.ServerType.equalsIgnoreCase("Competitive"))
lore.add(ChatColor.RESET + C.cYellow + "Map: " + C.cWhite + serverInfo.Map);
lore.add(ChatColor.RESET + C.cYellow + "Map: " + C.cWhite + serverInfo.Map);
lore.add(ChatColor.RESET + C.cYellow + "Players: " + C.cWhite + serverInfo.CurrentPlayers + "/" + serverInfo.MaxPlayers);
lore.add(ChatColor.RESET + "");
@ -186,50 +159,46 @@ public class ServerNpcPage extends ShopPageInventory<ServerManager, ServerNpcSho
}
else if (!serverInfo.MOTD.contains("Open in"))
{
if (isDev)
{
lore.add(ChatColor.RESET + C.cRed + "Warning: This is a test server run by a developer");
lore.add(ChatColor.RESET + C.cRed + "It may contain unreleased updates");
}
lore.add(MESSAGE_JOIN);
}
}
}
return new ShopItem(status, ChatColor.RESET + C.cGreen + C.Line + C.Bold + "Server " + serverInfo.Name.split("-")[1], lore.toArray(new String[lore.size()]), serverInfo.CurrentPlayers, false);
return new ShopItem(status, ChatColor.RESET + C.cGreen + C.Line + C.Bold + "Server " + serverInfo.Name.substring(serverInfo.Name.indexOf('-') + 1), lore.toArray(new String[lore.size()]), serverInfo.CurrentPlayers, false);
}
private void buildAvailableServerPage(List<ServerInfo> serverList, int slotsNeeded)
{
int serversToShow = 7;
int greenCount = 0;
int yellowCount = 0;
int maxFull = 3;
int greenStartSlot = 18 + ((9 - serversToShow) / 2);
boolean showGreen = true;
boolean hasDevServers = false;
for (Iterator<ServerInfo> iterator = serverList.iterator(); iterator.hasNext(); )
{
ServerInfo serverInfo = iterator.next();
if (serverInfo.isDevServer())
{
if (TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - serverInfo.Server.getCurrentTime()) < 5)
{
if (!isInProgress(serverInfo))
{
hasDevServers = true;
break;
}
}
else
{
iterator.remove();
}
}
}
boolean beta = serverList.size() > 0 && serverList.get(0).Name.contains("BETA");
boolean tournament = serverList.size() > 0 && serverList.get(0).Name.contains("T_");
boolean privateServer = serverList.size() > 0 && serverList.get(0).ServerType.equals("Player");
boolean ownsUltraPackage = getClient().GetRank().has(Rank.ULTRA) || (serverList.size() > 0 && getDonationManager().Get(getPlayer()).OwnsUnknownPackage(serverList.get(0).ServerType + " ULTRA"));
long portalTime = getPlugin().getMillisecondsUntilPortal(getPlayer(), beta);
if (portalTime > 0)
{
showClock(portalTime, beta);
showGreen = false;
}
else if (tournament && !ownsUltraPackage)
{
ShopItem item = new ShopItem(Material.REDSTONE_BLOCK, (byte)0, ChatColor.RESET + C.Bold + "Tournament Servers", null, new String[] {
ChatColor.RESET + "",
ChatColor.RESET + C.cAqua + "Ultra and Hero players have",
ChatColor.RESET + C.cAqua + "access to our Tournament servers!",
ChatColor.RESET + "",
ChatColor.RESET + "",
ChatColor.RESET + "Visit " + C.cGreen + "www.mineplex.com/shop" + C.cWhite + "!"
}, 1, false, false);
addItemStack(22, item);
return;
}
else if (privateServer)
if (privateServer)
{
int staffSlot = 0;
int slot = 18;
@ -257,70 +226,136 @@ public class ServerNpcPage extends ShopPageInventory<ServerManager, ServerNpcSho
}
return;
}
int fullCount = 0;
for (ServerInfo serverInfo : serverList)
int gamesInProgress = 0;
if (!hasDevServers)
{
int slot = greenCount + greenStartSlot;
int normalSlotStart = 19;
int normalSlotEnd = 25;
int currentNormalSlot = normalSlotStart;
int fullCount = 0;
if (isStarting(serverInfo) && hasEnoughSlots(serverInfo, slotsNeeded) && greenCount < serversToShow)
for (ServerInfo serverInfo : serverList)
{
if (showGreen)
if (isStarting(serverInfo) && hasEnoughSlots(serverInfo, slotsNeeded))
{
boolean full = serverInfo.MaxPlayers - serverInfo.CurrentPlayers <= 0;
if (full && fullCount >= maxFull)
continue;
ShopItem shopItem = buildShopItem(serverInfo, slotsNeeded);
greenCount++;
if (full && fullCount >= MAX_FULL_SERVERS)
continue;
ShopItem shopItem = buildShopItem(serverInfo, slotsNeeded, false);
if (serverInfo.MOTD.contains("Open in"))
addItemStack(slot, shopItem);
addItemStack(currentNormalSlot, shopItem);
else
{
addButton(slot, shopItem, new JoinServerButton(this, getPlugin(), serverInfo, getPlayer()));
}
addButton(currentNormalSlot, shopItem, new JoinServerButton(this, getPlugin(), serverInfo, getPlayer()));
if (full)
fullCount++;
currentNormalSlot++;
if (currentNormalSlot > normalSlotEnd)
break;
}
else if (isInProgress(serverInfo))
{
gamesInProgress++;
}
}
else if (isInProgress(serverInfo))
if (currentNormalSlot <= normalSlotEnd)
for (int i = currentNormalSlot; i <= normalSlotEnd; i++)
{
addItemStack(i, null);
}
}
else
{
int normalSlotStart = 10;
int normalSlotEnd = 16;
int currentNormalSlot = normalSlotStart;
int normalFullCount = 0;
int devSlotStart = 28;
int devSlotEnd = 34;
int currentDevSlot = devSlotStart;
int devFullCount = 0;
for (ServerInfo serverInfo : serverList)
{
yellowCount++;
boolean isDevServer = serverInfo.isDevServer();
if (isStarting(serverInfo) && hasEnoughSlots(serverInfo, slotsNeeded))
{
if (isDevServer && currentDevSlot > devSlotEnd)
continue;
else if (!isDevServer && currentNormalSlot > normalSlotEnd)
continue;
boolean full = serverInfo.MaxPlayers - serverInfo.CurrentPlayers <= 0;
if (full)
{
if (isDevServer && devFullCount >= MAX_FULL_SERVERS)
continue;
else if (!isDevServer && normalFullCount >= MAX_FULL_SERVERS)
continue;
}
ShopItem shopItem = buildShopItem(serverInfo, slotsNeeded, isDevServer);
if (serverInfo.MOTD.contains("Open in"))
addItemStack(isDevServer ? currentDevSlot : currentNormalSlot, shopItem);
else
addButton(isDevServer ? currentDevSlot : currentNormalSlot, shopItem, new JoinServerButton(this, getPlugin(), serverInfo, getPlayer()));
if (full)
{
if (isDevServer)
devFullCount++;
else
normalFullCount++;
}
if (isDevServer)
currentDevSlot++;
else
currentNormalSlot++;
}
else if (isInProgress(serverInfo))
{
gamesInProgress++;
}
}
if (currentNormalSlot <= normalSlotEnd)
for (int i = currentNormalSlot; i <= normalSlotEnd; i++)
{
addItemStack(i, null);
}
if (currentDevSlot <= devSlotEnd)
for (int i = currentDevSlot; i <= devSlotEnd; i++)
{
addItemStack(i, null);
}
}
if(showGreen) {
addButton(40, new ShopItem(Material.GOLD_BLOCK, C.cAqua + yellowCount + " Game" + (yellowCount == 1 ? "" : "s") + " In Progress", new String[]{MESSAGE_SPECTATE}, yellowCount > 64 ? 64 : yellowCount, false), new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
_onMainPage = false;
}
});
addButton(4, ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BLOCK, (byte) 0, 1, C.cGreen + "Click to join instantly!"), new IButton() {
@Override
public void onClick(Player player, ClickType clickType) {
getPlugin().selectServer(player, _serverGroupName);
}
});
}
// Clear empty slots
if (showGreen)
addButton(40, new ShopItem(Material.GOLD_BLOCK, C.cAqua + gamesInProgress + " Game" + (gamesInProgress == 1 ? "" : "s") + " In Progress", new String[]{MESSAGE_SPECTATE}, gamesInProgress > 64 ? 64 : gamesInProgress, false), new IButton()
{
for (int i = greenCount + greenStartSlot; i < greenStartSlot + serversToShow; i++)
@Override
public void onClick(Player player, ClickType clickType)
{
addItemStack(i, null);
_onMainPage = false;
}
}
});
addButton(4, ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BLOCK, (byte) 0, 1, C.cGreen + "Click to join instantly!"), new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
getPlugin().selectServer(player, _serverGroupName);
}
});
}
public void addItemStack(int slot, ItemStack item)
@ -414,14 +449,14 @@ public class ServerNpcPage extends ShopPageInventory<ServerManager, ServerNpcSho
private void buildInProgressServerPage(List<ServerInfo> serverList, int slotsNeeded)
{
int slot = 9;
ArrayList<ServerInfo> inProgress = new ArrayList<ServerInfo>();
for (ServerInfo serverInfo : serverList)
{
if (isInProgress(serverInfo))
{
ShopItem shopItem = buildShopItem(serverInfo, slotsNeeded);
ShopItem shopItem = buildShopItem(serverInfo, slotsNeeded, false);
addButton(slot, shopItem, new JoinServerButton(this, getPlugin(), serverInfo, getPlayer()));
inProgress.add(serverInfo);
@ -436,20 +471,20 @@ public class ServerNpcPage extends ShopPageInventory<ServerManager, ServerNpcSho
slot += 9;
}
ShopItem shopItem = buildShopItem(serverInfo, slotsNeeded);
ShopItem shopItem = buildShopItem(serverInfo, slotsNeeded, false);
addButton(slot, shopItem, new JoinServerButton(this, getPlugin(), serverInfo, getPlayer()));
slot++;
}
addBackBed(4);
}
private void addBackBed(int slot)
{
addButton(slot, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]
{}, 1, false), new IButton()
{}, 1, false), new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
@ -470,13 +505,13 @@ public class ServerNpcPage extends ShopPageInventory<ServerManager, ServerNpcSho
{
System.out.println("Selecting server :" + serverInfo.Name);
int slots = getPlugin().getRequiredSlots(player, serverInfo.ServerType);
if (serverInfo.getAvailableSlots() < slots && !(getDonationManager().Get(getPlayer()).OwnsUnknownPackage(serverInfo.ServerType + " ULTRA") || getClient().GetRank().has(Rank.ULTRA)))
{
playDenySound(player);
return;
}
getPlugin().selectServer(player, serverInfo);
}

View File

@ -47,6 +47,12 @@ public class MinecraftServer
public int getDonorsOnline() { return _donorsOnline; }
private long _startUpDate;
private long _currentTime;
public long getCurrentTime()
{
return this._currentTime;
}
/**
* Class constructor
@ -76,6 +82,7 @@ public class MinecraftServer
_port = port;
_donorsOnline = donorsOnline;
_startUpDate = startUpDate;
_currentTime = System.currentTimeMillis();
}
/**

View File

@ -51,28 +51,28 @@ public class ItemCommand extends CommandBase<SalesPackageManager>
if (uuid != null)
{
if (category.equalsIgnoreCase("ITEM"))
Plugin.getDonationManager().PurchaseUnknownSalesPackage(new Callback<TransactionResponse>()
{
Plugin.getInventoryManager().addItemToInventoryForOffline(new Callback<Boolean>()
public void run(TransactionResponse data)
{
public void run(Boolean success)
if (category.equalsIgnoreCase("ITEM"))
{
if (success)
Plugin.getInventoryManager().addItemToInventoryForOffline(new Callback<Boolean>()
{
UtilPlayer.message(caller, F.main(Plugin.getName(), playerName + " received " + amount + " " + itemName + "."));
}
else
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "ERROR processing " + playerName + " " + amount + " " + itemName + "."));
}
public void run(Boolean success)
{
if (success)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), playerName + " received " + amount + " " + itemName + "."));
}
else
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "ERROR processing " + playerName + " " + amount + " " + itemName + "."));
}
}
}, uuid, itemName, amount);
}
}, uuid, itemName, amount);
}
else
{
Plugin.getDonationManager().PurchaseUnknownSalesPackage(new Callback<TransactionResponse>()
{
public void run(TransactionResponse data)
else
{
if (data == TransactionResponse.Success || data == TransactionResponse.AlreadyOwns)
{
@ -83,8 +83,8 @@ public class ItemCommand extends CommandBase<SalesPackageManager>
UtilPlayer.message(caller, F.main(Plugin.getName(), "ERROR processing " + playerName + " " + amount + " " + itemName + "."));
}
}
}, playerName, client.getAccountId(), (amount == 1 ? itemName : itemName + " " + amount), GlobalCurrency.GEM, 0, false);
}
}
}, playerName, client.getAccountId(), (amount == 1 ? itemName : itemName + " " + amount), GlobalCurrency.GEM, 0, false);
}
else
caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!"));

View File

@ -376,7 +376,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_punishmentManager = punish;
_kitProgressionManager = new KitProgressionManager(getPlugin(), clientManager);
_kitProgressionManager = new KitProgressionManager(getPlugin(), donationManager, clientManager);
_progressionKitManager = new ProgressingKitManager(this);
_serverUptimeManager = new ServerUptimeManager(this);
@ -511,17 +511,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
}
}
int spectatorCount = 0;
for (Player players : UtilServer.getPlayersCollection())
{
if (isVanished(players))
{
spectatorCount++;
}
}
scoreboard.get(ArcadeScoreboardLine.PLAYERS_VALUE).write(UtilServer.getPlayers().length - spectatorCount + "/" + GetPlayerFull());
scoreboard.get(ArcadeScoreboardLine.PLAYERS_VALUE).write( _gameManager.getValidPlayersForGameStart().size() + "/" + GetPlayerFull());
scoreboard.get(ArcadeScoreboardLine.GEM_VALUE).write(donationManager.Get(scoreboard.getOwner()).getBalance(GlobalCurrency.GEM));
if (GetGame() != null)

View File

@ -59,6 +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.QuiverTeams;
import nautilus.game.arcade.game.games.quiver.modes.BunnyHop;
import nautilus.game.arcade.game.games.rings.ElytraRings;
@ -157,6 +158,7 @@ public enum GameType
OldMineWare(OldMineWare.class, GameDisplay.OldMineWare),
Paintball(Paintball.class, GameDisplay.Paintball),
Quiver(Quiver.class, GameDisplay.Quiver),
QuiverPayload(QuiverPayload.class, GameDisplay.QuiverPayload),
QuiverTeams(QuiverTeams.class, GameDisplay.QuiverTeams),
Runner(Runner.class, GameDisplay.Runner),
SearchAndDestroy(SearchAndDestroy.class, GameDisplay.SearchAndDestroy),

View File

@ -5,17 +5,29 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import mineplex.core.common.Pair;
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.UtilTime;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
@ -31,19 +43,6 @@ import nautilus.game.arcade.stats.SharpShooterStatTracker;
import nautilus.game.arcade.stats.WinWithoutBowStatTracker;
import nautilus.game.arcade.stats.WinWithoutDyingStatTracker;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
public class Quiver extends SoloGame
{
private ArrayList<QuiverScore> _ranks = new ArrayList<QuiverScore>();
@ -52,7 +51,10 @@ public class Quiver extends SoloGame
private HashMap<Player, Long> _deathTime = new HashMap<Player, Long>();
private Objective _scoreObj;
public static final ItemStack SUPER_ARROW = new ItemBuilder(Material.ARROW).setTitle(C.cYellow + "Super Arrow").build();
@SuppressWarnings("unchecked")
public Quiver(ArcadeManager manager)
{
this(manager, new Kit[]
@ -62,6 +64,12 @@ public class Quiver extends SoloGame
new KitEnchanter(manager),
new KitSlamShot(manager),
new KitNinja(manager)
// new KitBeserker(manager),
// new KitNewNinja(manager),
// new KitBarrage(manager),
// new KitHeadHunter(manager),
// new KitPyromancer(manager),
// new KitNecromancer(manager),
}, GameType.Quiver);
registerStatTrackers(
@ -81,6 +89,7 @@ public class Quiver extends SoloGame
);
}
@SuppressWarnings("deprecation")
public Quiver(ArcadeManager manager, Kit[] kits, GameType type)
{
super(manager, type, kits,
@ -97,8 +106,6 @@ public class Quiver extends SoloGame
this.DamageSelf = false;
this.DamageTeamSelf = true;
this.PrepareFreeze = false;
this.BlockBreakAllow.add(102);
this.BlockBreakAllow.add(20);
this.BlockBreakAllow.add(Material.STAINED_GLASS_PANE.getId());
this.BlockBreakAllow.add(Material.STAINED_GLASS.getId());
@ -116,7 +123,7 @@ public class Quiver extends SoloGame
for (Player player : GetPlayers(true))
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)0, 1, F.item("Super Arrow")));
player.getInventory().addItem(SUPER_ARROW);
player.playSound(player.getLocation(), Sound.PISTON_EXTEND, 3f, 2f);
}
}
@ -150,7 +157,7 @@ public class Quiver extends SoloGame
public void run()
{
if (!player.getInventory().contains(Material.ARROW))
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)0, 1, F.item("Super Arrow")));
player.getInventory().addItem(SUPER_ARROW);
}
}, 10);
@ -173,18 +180,18 @@ public class Quiver extends SoloGame
Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
if (player == null) return;
int amount = 1;
if (GetKit(player) instanceof KitSlamShot)
{
if (Manager.GetCondition().HasCondition(event.GetEvent().getEntity(), ConditionType.FALLING, null))
{
amount = 2;
}
}
// int amount = 1;
//
// if (GetKit(player) instanceof KitSlamShot)
// {
// if (Manager.GetCondition().HasCondition(event.GetEvent().getEntity(), ConditionType.FALLING, null))
// {
// amount = 2;
// }
// }
//New Arrow
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)0, amount, F.item("Super Arrow")));
player.getInventory().addItem(SUPER_ARROW);
player.playSound(player.getLocation(), Sound.PISTON_EXTEND, 3f, 2f);
//Score
@ -280,17 +287,14 @@ public class Quiver extends SoloGame
@EventHandler
public void ArrowDamage(CustomDamageEvent event)
{
if (!(event.GetDamagerEntity(true) instanceof Arrow)
&& !(event.GetDamagerEntity(true) instanceof Player)
&& (event.GetDamagerEntity(true) instanceof Entity))
{
event.setCancelled(true);
return;
}
{
if (event.GetProjectile() == null)
return;
if (!(event.GetProjectile() instanceof Arrow))
{
return;
}
event.AddMod("Projectile", "Instagib", 9001, false);
event.SetKnockback(false);
@ -312,6 +316,7 @@ public class Quiver extends SoloGame
Scoreboard.writeNewLine();
//Write New
Scoreboard.writeGroup(_ranks, score -> Pair.create(C.cGreen + score.Player.getName(), score.Kills), true);
Scoreboard.draw();

View File

@ -0,0 +1,122 @@
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

@ -0,0 +1,101 @@
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

@ -0,0 +1,144 @@
package nautilus.game.arcade.game.games.quiver.kits;
import java.util.UUID;
import org.bukkit.Bukkit;
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 mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilServer;
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.ultimates.UltimateBarrage;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkDoubleJump;
import nautilus.game.arcade.kit.perks.PerkFletcher;
public class KitBarrage extends ProgressingKit
{
private static final String[] DESCRIPTION = {
"Oooo look an arrow... ooo look an arrow...",
"",
"Gain an arrow every " + C.cGreen + "5" + C.cWhite + " seconds.",
"",
C.cGreenB + "ULTIMATE",
"When you fire your next arrow you fire an additional",
C.cGreen + "10" + C.cWhite + " arrows."
};
private static final String DOUBLE_JUMP = "Double Jump";
private static final String ULTIMATE = "Ultimate";
private static final String SUPER_ARROW = "Super Arrow";
private static final Perk[][] PERKS = {
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkFletcher(5, 1, true, -1, true, SUPER_ARROW),
new UltimateBarrage(10)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkFletcher(5, 1, true, -1, true, SUPER_ARROW),
new UltimateBarrage(12)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkFletcher(5, 1, true, -1, true, SUPER_ARROW),
new UltimateBarrage(14)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkFletcher(5, 1, true, -1, true, SUPER_ARROW),
new UltimateBarrage(16)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkFletcher(5, 1, true, -1, true, SUPER_ARROW),
new UltimateBarrage(18)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkFletcher(5, 1, true, -1, true, SUPER_ARROW),
new UltimateBarrage(20)
}
};
private static final String[][] UPGRADE_DETAILS = {
{
increaseArrows(2),
},
{
increaseArrows(2),
},
{
increaseArrows(2),
},
{
increaseArrows(2),
},
{
increaseArrows(2),
},
};
private static final String increaseArrows(int arrows)
{
return C.cWhite + "Increase arrows fired from " + C.cGreen + ULTIMATE + C.cWhite + " by " + C.cGreen + arrows + C.cWhite + ".";
}
private static final ItemStack IN_HAND = new ItemStack(Material.IRON_AXE);
private static final ItemStack[] PLAYER_ITEMS = {
new ItemBuilder(Material.IRON_AXE).setUnbreakable(true).build(),
new ItemBuilder(Material.BOW).setUnbreakable(true).build(),
};
public KitBarrage(ArcadeManager manager)
{
super(manager, "Barrage", "quiverbarrage", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(PLAYER_ITEMS);
if (Manager.GetGame().GetState() == GameState.Live)
{
player.getInventory().addItem(Quiver.SUPER_ARROW);
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), () -> UtilInv.Update(player), 10);
}
}
@Override
public void onSelected(UUID player)
{
super.onSelected(player);
if (!Manager.GetGame().IsLive())
{
return;
}
QuiverPayload quiverPayload = (QuiverPayload) Manager.GetGame();
quiverPayload.resetUltimate(Bukkit.getPlayer(player), true);
}
@Override
public boolean showUpgrades()
{
return true;
}
}

View File

@ -0,0 +1,139 @@
package nautilus.game.arcade.game.games.quiver.kits;
import java.util.UUID;
import org.bukkit.Bukkit;
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 mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilServer;
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.ultimates.UltimateBeserker;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkDoubleJump;
import nautilus.game.arcade.kit.perks.PerkStrength;
public class KitBeserker extends ProgressingKit
{
private static final String[] DESCRIPTION = {
"Missed your arrow? Not a big deal.",
"",
"Deal " + C.cGreen + "+1" + C.cWhite + " more damage",
"",
C.cGreenB + "ULTIMATE",
"You equip " + C.cGreen + "iron" + C.cWhite + " chestplate, leggings and boots.",
"Arrows do not one hit you.",
"Lasts for " + C.cGreen + "6" + C.cWhite + " seconds."
};
private static final String DOUBLE_JUMP = "Double Jump";
private static final String ULTIMATE = "Ultimate";
private static final String DURATION = "Duration";
private static final Perk[][] PERKS = {
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkStrength(1),
new UltimateBeserker(6000)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkStrength(1),
new UltimateBeserker(6500)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkStrength(1),
new UltimateBeserker(7000)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkStrength(1),
new UltimateBeserker(7500)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkStrength(1),
new UltimateBeserker(8000)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkStrength(1),
new UltimateBeserker(8500)
}
};
private static final String[][] UPGRADE_DETAILS = {
{
increase(ULTIMATE, DURATION, 12)
},
{
increase(ULTIMATE, DURATION, 12)
},
{
increase(ULTIMATE, DURATION, 12)
},
{
increase(ULTIMATE, DURATION, 12)
},
{
increase(ULTIMATE, DURATION, 12)
},
};
private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD);
private static final ItemStack[] PLAYER_ITEMS = {
new ItemBuilder(Material.IRON_SWORD).setUnbreakable(true).build(),
new ItemBuilder(Material.BOW).setUnbreakable(true).build(),
};
public KitBeserker(ArcadeManager manager)
{
super(manager, "Berserker", "quiverbeserker", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(PLAYER_ITEMS);
if (Manager.GetGame().GetState() == GameState.Live)
{
player.getInventory().addItem(Quiver.SUPER_ARROW);
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), () -> UtilInv.Update(player), 10);
}
}
@Override
public void onSelected(UUID player)
{
super.onSelected(player);
if (!Manager.GetGame().IsLive())
{
return;
}
QuiverPayload quiverPayload = (QuiverPayload) Manager.GetGame();
quiverPayload.resetUltimate(Bukkit.getPlayer(player), true);
}
@Override
public boolean showUpgrades()
{
return true;
}
}

View File

@ -1,5 +1,10 @@
package nautilus.game.arcade.game.games.quiver.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 mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInv;
@ -13,22 +18,17 @@ import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkArrowRebound;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class KitEnchanter extends ProgressingKit
{
private static final String[] DESCRIPTION = {
"3 Kills, 1 Arrow.",
"",
"Arrows bounce " + C.cGreen + "2" + C.cWhite + " times upon hitting your target"
"Arrows bounce " + C.cGreen + "once" + C.cWhite + " upon hitting your target"
};
private static final Perk[] PERKS = {
new PerkArrowRebound(2, 1.2f)
};
new PerkArrowRebound(1, 1.2F, 1)
};
private static final ItemStack IN_HAND = new ItemStack(Material.BOW);

View File

@ -38,7 +38,6 @@ public class KitLeaper extends ProgressingKit
public KitLeaper(ArcadeManager manager)
{
super(manager, "Jumper", "quiverjumper", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND);
}
@Override

View File

@ -0,0 +1,139 @@
package nautilus.game.arcade.game.games.quiver.kits;
import java.util.UUID;
import org.bukkit.Bukkit;
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 mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilServer;
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.ultimates.UltimateNecromancer;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkDoubleJump;
import nautilus.game.arcade.kit.perks.PerkLifestealArrows;
public class KitNecromancer extends ProgressingKit
{
private static final String[] DESCRIPTION = {
"Spooky scary skeletons",
"",
"Successful arrow hits restore " + C.cGreen + "2" + C.cWhite + " hearts.",
"",
C.cGreenB + "ULTIMATE",
"Summon " + C.cGreen + "4 Undead Minions" + C.cWhite + " that shoot at other players",
"Lasts for " + C.cGreen + "10" + C.cWhite + " seconds."
};
private static final String DOUBLE_JUMP = "Double Jump";
private static final String ULTIMATE = "Ultimate";
private static final String DURATION = "Duration";
private static final Perk[][] PERKS = {
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkLifestealArrows(8),
new UltimateNecromancer(10000, 4)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkLifestealArrows(8),
new UltimateNecromancer(10500, 4)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkLifestealArrows(8),
new UltimateNecromancer(11000, 4)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkLifestealArrows(8),
new UltimateNecromancer(11500, 4)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkLifestealArrows(8),
new UltimateNecromancer(12000, 4)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkLifestealArrows(8),
new UltimateNecromancer(12500, 4)
}
};
private static final String[][] UPGRADE_DETAILS = {
{
increase(ULTIMATE, DURATION, 10)
},
{
increase(ULTIMATE, DURATION, 10)
},
{
increase(ULTIMATE, DURATION, 10)
},
{
increase(ULTIMATE, DURATION, 10)
},
{
increase(ULTIMATE, DURATION, 10)
},
};
private static final ItemStack IN_HAND = new ItemStack(Material.BONE);
private static final ItemStack[] PLAYER_ITEMS = {
new ItemBuilder(Material.IRON_AXE).setUnbreakable(true).build(),
new ItemBuilder(Material.BOW).setUnbreakable(true).build(),
};
public KitNecromancer(ArcadeManager manager)
{
super(manager, "Necromancer", "quivernecromancer", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(PLAYER_ITEMS);
if (Manager.GetGame().GetState() == GameState.Live)
{
player.getInventory().addItem(Quiver.SUPER_ARROW);
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), () -> UtilInv.Update(player), 10);
}
}
@Override
public void onSelected(UUID player)
{
super.onSelected(player);
if (!Manager.GetGame().IsLive())
{
return;
}
QuiverPayload quiverPayload = (QuiverPayload) Manager.GetGame();
quiverPayload.resetUltimate(Bukkit.getPlayer(player), true);
}
@Override
public boolean showUpgrades()
{
return true;
}
}

View File

@ -0,0 +1,130 @@
package nautilus.game.arcade.game.games.quiver.kits;
import java.util.UUID;
import org.bukkit.Bukkit;
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 mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.quiver.QuiverPayload;
import nautilus.game.arcade.game.games.quiver.ultimates.UltimateNinja;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkDash;
import nautilus.game.arcade.kit.perks.PerkDoubleJump;
public class KitNewNinja extends ProgressingKit
{
private static final String[] DESCRIPTION = {
"Zip zap boing around the map!",
"You do not spawn with an arrow!",
"",
C.cYellow + "Right-click " + C.cGreen + "Sword" + C.cWhite + " to dash.",
"",
C.cGreenB + "ULTIMATE",
"Your " + C.cGreen + "Gold Sword" + C.cWhite + " changes into a " + C.cGreen + "Diamond Sword" + C.cWhite + ".",
"This new sword kills players in " + C.cRedB + "ONE" + C.cWhite + " hit!",
"Lasts for " + C.cGreen + "6" + C.cWhite + " seconds."
};
private static final String DOUBLE_JUMP = "Double Jump";
private static final String ULTIMATE = "Ultimate";
private static final String DURATION = "Duration";
private static final Perk[][] PERKS = {
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkDash(5000, 10, 8),
new UltimateNinja(6000)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkDash(5000, 10, 8),
new UltimateNinja(6500)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkDash(5000, 10, 8),
new UltimateNinja(7000)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkDash(5000, 10, 8),
new UltimateNinja(7500)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkDash(5000, 10, 8),
new UltimateNinja(8000)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkDash(5000, 10, 8),
new UltimateNinja(8500)
}
};
private static final String[][] UPGRADE_DETAILS = {
{
increase(ULTIMATE, DURATION, 12)
},
{
increase(ULTIMATE, DURATION, 12)
},
{
increase(ULTIMATE, DURATION, 12)
},
{
increase(ULTIMATE, DURATION, 12)
},
{
increase(ULTIMATE, DURATION, 12)
},
};
private static final ItemStack IN_HAND = new ItemStack(Material.GOLD_SWORD);
private static final ItemStack[] PLAYER_ITEMS = {
new ItemBuilder(Material.GOLD_SWORD).setUnbreakable(true).build(),
new ItemBuilder(Material.BOW).setUnbreakable(true).build(),
};
public KitNewNinja(ArcadeManager manager)
{
super(manager, "Ninja", "quivernewninja", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(PLAYER_ITEMS);
}
@Override
public void onSelected(UUID player)
{
super.onSelected(player);
if (!Manager.GetGame().IsLive())
{
return;
}
QuiverPayload quiverPayload = (QuiverPayload) Manager.GetGame();
quiverPayload.resetUltimate(Bukkit.getPlayer(player), true);
}
@Override
public boolean showUpgrades()
{
return true;
}
}

View File

@ -0,0 +1,142 @@
package nautilus.game.arcade.game.games.quiver.kits;
import java.util.UUID;
import org.bukkit.Bukkit;
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 mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilServer;
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.ultimates.UltimatePyromancer;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkDoubleJump;
import nautilus.game.arcade.kit.perks.PerkFireArrows;
public class KitPyromancer extends ProgressingKit
{
private static final String[] DESCRIPTION = {
"Hot! Hot! Hot!",
"",
"When your arrows land, players within " + C.cGreen + "2" + C.cWhite + " blocks are set on",
"fire for " + C.cGreen + "3" + C.cWhite + " seconds.",
"",
C.cGreenB + "ULTIMATE",
"You begin to fire " + C.cGreen + "20" + C.cWhite + " arrows per second in all directions around you.",
"During this time you have " + C.cGreen + "75%" + C.cWhite + " reduced movement speed and are",
"unable to jump.",
"Lasts for " + C.cGreen + "5" + C.cWhite + " seconds"
};
private static final String DOUBLE_JUMP = "Double Jump";
private static final String ULTIMATE = "Ultimate";
private static final String DURATION = "Duration";
private static final Perk[][] PERKS = {
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkFireArrows(3, 60),
new UltimatePyromancer(5000)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkFireArrows(3, 60),
new UltimatePyromancer(5500)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkFireArrows(3, 60),
new UltimatePyromancer(6000)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkFireArrows(3, 60),
new UltimatePyromancer(6500)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkFireArrows(3, 60),
new UltimatePyromancer(7000)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkFireArrows(2, 60),
new UltimatePyromancer(7500)
}
};
private static final String[][] UPGRADE_DETAILS = {
{
increase(ULTIMATE, DURATION, 10)
},
{
increase(ULTIMATE, DURATION, 10)
},
{
increase(ULTIMATE, DURATION, 10)
},
{
increase(ULTIMATE, DURATION, 10)
},
{
increase(ULTIMATE, DURATION, 10)
},
};
private static final ItemStack IN_HAND = new ItemStack(Material.BLAZE_POWDER);
private static final ItemStack[] PLAYER_ITEMS = {
new ItemBuilder(Material.IRON_AXE).setUnbreakable(true).build(),
new ItemBuilder(Material.BOW).setUnbreakable(true).build(),
};
public KitPyromancer(ArcadeManager manager)
{
super(manager, "Pyromancer", "quiverpyromancer", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(PLAYER_ITEMS);
if (Manager.GetGame().GetState() == GameState.Live)
{
player.getInventory().addItem(Quiver.SUPER_ARROW);
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), () -> UtilInv.Update(player), 10);
}
}
@Override
public void onSelected(UUID player)
{
super.onSelected(player);
if (!Manager.GetGame().IsLive())
{
return;
}
QuiverPayload quiverPayload = (QuiverPayload) Manager.GetGame();
quiverPayload.resetUltimate(Bukkit.getPlayer(player), true);
}
@Override
public boolean showUpgrades()
{
return true;
}
}

View File

@ -0,0 +1,154 @@
package nautilus.game.arcade.game.games.quiver.kits;
import java.util.UUID;
import org.bukkit.Bukkit;
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 mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilServer;
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.ultimates.UltimateSkyWarrior;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkDoubleJump;
import nautilus.game.arcade.kit.perks.PerkSpeed;
public class KitSkyWarrior extends ProgressingKit
{
private static final String[] DESCRIPTION = {
"We\'ll see you in the sky.",
"",
"Gain permanent Speed I",
"",
C.cGreenB + "ULTIMATE",
"You fly up into the air and are given a launcher.",
"Clicking the launcher fires a Astral Arrow.",
"When it hits a block a pulse of energy is fired",
"damaging all players within " + C.cGreen + "5" + C.cWhite + " blocks",
"for " + C.cGreen + "10" + C.cWhite + " damage.",
"",
"Total of " + C.cRed + "3" + C.cWhite + " uses!",
"",
"Once all arrows are fired you teleport to a random",
"teammate dealing damage to all players within",
C.cGreen + "10" + C.cWhite + " blocks for " + C.cGreen + "5" + C.cWhite + " damage."
};
private static final String DOUBLE_JUMP = "Double Jump";
private static final String ULTIMATE = "Ultimate";
private static final String DAMAGE = "Damage";
private static final String DAMAGE_TELEPORT = "Teleportation Damage";
private static final Perk[][] PERKS = {
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkSpeed(0),
new UltimateSkyWarrior(5, 10, 10, 5, 30)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkSpeed(0),
new UltimateSkyWarrior(5.5, 10, 11, 5, 30)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkSpeed(0),
new UltimateSkyWarrior(6, 10, 12, 5, 30)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkSpeed(0),
new UltimateSkyWarrior(6.5, 10, 13, 5, 30)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkSpeed(0),
new UltimateSkyWarrior(7, 10, 14, 5, 30)
},
{
new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true),
new PerkSpeed(0),
new UltimateSkyWarrior(7.5, 10, 15, 5, 30)
}
};
private static final String[][] UPGRADE_DETAILS = {
{
increase(ULTIMATE, DAMAGE, 10),
increase(ULTIMATE, DAMAGE_TELEPORT, 10),
},
{
increase(ULTIMATE, DAMAGE, 10),
increase(ULTIMATE, DAMAGE_TELEPORT, 10),
},
{
increase(ULTIMATE, DAMAGE, 10),
increase(ULTIMATE, DAMAGE_TELEPORT, 10),
},
{
increase(ULTIMATE, DAMAGE, 10),
increase(ULTIMATE, DAMAGE_TELEPORT, 10),
},
{
increase(ULTIMATE, DAMAGE, 10),
increase(ULTIMATE, DAMAGE_TELEPORT, 10),
},
};
private static final ItemStack IN_HAND = new ItemStack(Material.FEATHER);
private static final ItemStack[] PLAYER_ITEMS = {
new ItemBuilder(Material.IRON_AXE).setUnbreakable(true).build(),
new ItemBuilder(Material.BOW).setUnbreakable(true).build(),
};
public KitSkyWarrior(ArcadeManager manager)
{
super(manager, "Sky Warrior", "quiverskywarrior", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(PLAYER_ITEMS);
if (Manager.GetGame().GetState() == GameState.Live)
{
player.getInventory().addItem(Quiver.SUPER_ARROW);
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), () -> UtilInv.Update(player), 10);
}
}
@Override
public void onSelected(UUID player)
{
super.onSelected(player);
if (!Manager.GetGame().IsLive())
{
return;
}
QuiverPayload quiverPayload = (QuiverPayload) Manager.GetGame();
quiverPayload.resetUltimate(Bukkit.getPlayer(player), true);
}
@Override
public boolean showUpgrades()
{
return true;
}
}

View File

@ -25,9 +25,9 @@ public class KitSlamShot extends ProgressingKit
};
private static final Perk[] PERKS = {
new PerkSeismicSlamOITQ()
new PerkSeismicSlamOITQ()
};
private static final ItemStack IN_HAND = new ItemStack(Material.DIAMOND_SPADE);
private static final ItemStack[] PLAYER_ITEMS = {

View File

@ -0,0 +1,126 @@
package nautilus.game.arcade.game.games.quiver.ultimates;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
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
{
private Map<UUID, Long> _lastUltimate = new HashMap<>();
public Ultimate(String name, String[] perkDesc)
{
super(name, perkDesc);
}
public void activate(Player player)
{
_lastUltimate.put(player.getUniqueId(), System.currentTimeMillis());
if (!(Manager.GetGame().GetKit(player) instanceof KitNewNinja))
{
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 + ".");
for (Player other : UtilServer.getPlayers())
{
other.playSound(other.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 0);
}
}
public void cancel(Player player)
{
_lastUltimate.remove(player.getUniqueId());
player.playSound(player.getLocation(), Sound.BLAZE_DEATH, 1, 0);
}
public boolean isUsable(Player player)
{
return true;
}
public abstract double getChargeIncreasePerSecond();
public abstract long getLength();
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST || getLength() == 0)
{
return;
}
for (Player player : UtilServer.getPlayers())
{
if (!_lastUltimate.containsKey(player.getUniqueId()))
{
continue;
}
if (UtilTime.elapsed(_lastUltimate.get(player.getUniqueId()), getLength()))
{
cancel(player);
}
}
}
@EventHandler
public void onCombatDeath(CombatDeathEvent event)
{
if (!(event.GetEvent().getEntity() instanceof Player))
{
return;
}
Player player = (Player) event.GetEvent().getEntity();
if (!_lastUltimate.containsKey(player.getUniqueId()))
{
return;
}
cancel(player);
}
@EventHandler
public void onGameStateChange(GameStateChangeEvent event)
{
if (event.GetState() != GameState.End)
{
for (UUID uuid : _lastUltimate.keySet())
{
cancel(UtilPlayer.searchExact(uuid));
}
}
}
public Map<UUID, Long> getLastUltimate()
{
return _lastUltimate;
}
}

View File

@ -0,0 +1,63 @@
package nautilus.game.arcade.game.games.quiver.ultimates;
import org.bukkit.Sound;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.util.Vector;
public class UltimateBarrage extends Ultimate
{
private static final double CHARGE_PER_SECOND = 0.8;
private static final float VELOCITY_MULTIPLIER = 3;
private int _arrows;
public UltimateBarrage(int arrows)
{
super("Arrow Barrage", new String[] {});
_arrows = arrows;
}
@EventHandler
public void onEntityShootBow(EntityShootBowEvent event)
{
if (event.isCancelled() || !(event.getEntity() instanceof Player))
{
return;
}
Player player = (Player) event.getEntity();
if (getLastUltimate().containsKey(player.getUniqueId()))
{
for (int i = 0; i < _arrows; i++)
{
Vector random = new Vector((Math.random() - 0.5) / 3, (Math.random() - 0.5) / 3, (Math.random() - 0.5) / 3);
Arrow arrow = player.launchProjectile(Arrow.class);
arrow.setCritical(true);
arrow.setVelocity(player.getLocation().getDirection().add(random).multiply(VELOCITY_MULTIPLIER));
player.getWorld().playSound(player.getLocation(), Sound.SHOOT_ARROW, 1F, 1F);
}
cancel(player);
}
}
@Override
public double getChargeIncreasePerSecond()
{
return CHARGE_PER_SECOND;
}
@Override
public long getLength()
{
return 0;
}
}

View File

@ -0,0 +1,95 @@
package nautilus.game.arcade.game.games.quiver.ultimates;
import java.util.Iterator;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.inventory.ItemStack;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import mineplex.minecraft.game.core.damage.DamageChange;
public class UltimateBeserker extends Ultimate
{
private static final double CHARGE_PER_SECOND = 0.4;
private long _length;
public UltimateBeserker(long length)
{
super("Berserker Shield", new String[] {});
_length = length;
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onCustomDamage(CustomDamageEvent event)
{
if (event.isCancelled())
{
return;
}
if (event.GetDamageePlayer() == null)
{
return;
}
if (!getLastUltimate().containsKey(event.GetDamageePlayer().getUniqueId()))
{
return;
}
Iterator<DamageChange> iterator = event.GetDamageMod().iterator();
while (iterator.hasNext())
{
DamageChange damageChange = iterator.next();
if (damageChange.GetReason().equals("Instagib"))
{
iterator.remove();
}
}
}
@Override
public void activate(Player player)
{
super.activate(player);
player.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
player.getInventory().setLeggings(new ItemStack(Material.IRON_LEGGINGS));
player.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS));
}
@Override
public void cancel(Player player)
{
super.cancel(player);
Color color = Manager.GetGame().GetTeam(player).GetColorBase();
player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(color).build());
player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(color).build());
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

@ -0,0 +1,176 @@
package nautilus.game.arcade.game.games.quiver.ultimates;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.inventory.ItemStack;
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.damage.CustomDamageEvent;
import nautilus.game.arcade.game.Game;
public class UltimateNecromancer extends Ultimate
{
private static final double CHARGE_PER_SECOND = 0.4;
private long _length;
private int _skeletons;
private Map<UUID, Set<LivingEntity>> _entities = new HashMap<>();
public UltimateNecromancer(long length, int skeletons)
{
super("Summon Undead", new String[] {});
_length = length;
_skeletons = skeletons;
}
@EventHandler
public void onEntityDamage(EntityDamageEvent event)
{
for (Set<LivingEntity> entityList : _entities.values())
{
for (LivingEntity livingEntity : entityList)
{
if (event.getEntity().equals(livingEntity))
{
event.setCancelled(true);
event.getEntity().setFireTicks(0);
}
}
}
}
@EventHandler
public void onEntityTarget(EntityTargetEvent event)
{
for (Set<LivingEntity> livingEntities : _entities.values())
{
if (event.getTarget() instanceof Player && livingEntities.contains(event.getEntity()))
{
Game game = Manager.GetGame();
Player source = getPlayerFromEntity(event.getEntity());
Player targetPlayer = (Player) event.getTarget();
if (game.GetTeam(targetPlayer).equals(game.GetTeam(source)))
{
event.setCancelled(true);
}
}
}
}
@EventHandler
public void onCustomDamage(CustomDamageEvent event)
{
if (event.GetProjectile() != null)
{
if (event.GetProjectile() instanceof Arrow)
{
LivingEntity livingEntity = event.GetDamagerEntity(true);
for (UUID uuid : _entities.keySet())
{
Set<LivingEntity> entities = _entities.get(uuid);
Player player = UtilPlayer.searchExact(uuid);
for (LivingEntity livingEntity2 : entities)
{
if (livingEntity.equals(livingEntity2))
{
event.SetDamager(player);
}
}
}
}
}
}
@Override
public void activate(Player player)
{
super.activate(player);
Set<LivingEntity> entities = new HashSet<>();
Manager.GetGame().CreatureAllowOverride = true;
for (int i = 0; i < _skeletons; i++)
{
LivingEntity livingEntity = player.getWorld().spawn(player.getLocation().add((Math.random() - 0.5) * 3, 0, (Math.random() - 0.5) * 3), Skeleton.class);
livingEntity.getEquipment().setItemInHand(new ItemStack(Material.BOW));
entities.add(livingEntity);
UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, livingEntity.getEyeLocation(), 1F, 1F, 1F, 0.1F, 20, ViewDist.NORMAL);
((Creature) livingEntity).setTarget(UtilPlayer.getClosest(livingEntity.getLocation(), Manager.GetGame().GetTeam(player).GetPlayers(true)));
}
Manager.GetGame().CreatureAllowOverride = false;
_entities.put(player.getUniqueId(), entities);
}
@Override
public void cancel(Player player)
{
super.cancel(player);
for (LivingEntity entity : _entities.get(player.getUniqueId()))
{
entity.getEquipment().clear();
entity.remove();
}
_entities.remove(player.getUniqueId());
}
public Player getPlayerFromEntity(Entity entity)
{
for (UUID uuid : _entities.keySet())
{
Set<LivingEntity> livingEntities = _entities.get(uuid);
for (LivingEntity livingEntity : livingEntities)
{
if (livingEntity.equals(livingEntity))
{
return UtilPlayer.searchExact(uuid);
}
}
}
return null;
}
@Override
public double getChargeIncreasePerSecond()
{
return CHARGE_PER_SECOND;
}
@Override
public long getLength()
{
return _length;
}
}

View File

@ -0,0 +1,76 @@
package nautilus.game.arcade.game.games.quiver.ultimates;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
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.minecraft.game.core.damage.CustomDamageEvent;
public class UltimateNinja extends Ultimate
{
private static final double CHARGE_PER_SECOND = 0.4;
private static final int SPEED_AMPLIFIER = 1;
private long _length;
public UltimateNinja(long length)
{
super("Ancient Blade", new String[] {});
_length = length;
}
@EventHandler
public void onCustomDamage(CustomDamageEvent event)
{
if (event.GetCause() != DamageCause.ENTITY_ATTACK)
{
return;
}
if (getLastUltimate().containsKey(event.GetDamagerPlayer(false).getUniqueId()) && event.GetDamagerPlayer(false).getItemInHand().getType() == Material.DIAMOND_SWORD)
{
event.AddMod(event.GetDamagerPlayer(false).getName(), GetName(), 9001, true);
}
}
@Override
public void activate(Player player)
{
super.activate(player);
player.getInventory().setItem(0, new ItemStack(Material.DIAMOND_SWORD));
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, (int) ((_length / 1000) * 20), SPEED_AMPLIFIER));
UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, player.getEyeLocation(), 0, 0, 0, 1F, 100, ViewDist.NORMAL);
}
@Override
public void cancel(Player player)
{
super.cancel(player);
player.getInventory().setItem(0, new ItemStack(Material.GOLD_SWORD));
}
@Override
public double getChargeIncreasePerSecond()
{
return CHARGE_PER_SECOND;
}
@Override
public long getLength()
{
return _length;
}
}

View File

@ -0,0 +1,80 @@
package nautilus.game.arcade.game.games.quiver.ultimates;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
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;
public class UltimatePyromancer extends Ultimate
{
private static final double CHARGE_PER_SECOND = 0.4;
private long _length;
private Map<UUID, Integer> _tasks = new HashMap<>();
public UltimatePyromancer(long length)
{
super("Fire Blossom", new String[] {});
_length = length;
}
@Override
public void activate(Player player)
{
super.activate(player);
player.setWalkSpeed(0.05F);
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, (int) ((getLength() / 1000) * 20), -10));
_tasks.put(player.getUniqueId(), (new BukkitRunnable()
{
@Override
public void run()
{
UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, player.getLocation().add(0, 0.5, 0), 2F, 0, 2F, 0.01F, 5, ViewDist.LONG);
UtilParticle.PlayParticleToAll(ParticleType.FLAME, player.getLocation().add(0, 0.5, 0), 2F, 0, 2F, 0.01F, 5, ViewDist.LONG);
Arrow arrow = player.launchProjectile(Arrow.class);
arrow.setCritical(true);
arrow.setVelocity(new Vector((Math.random() - 0.5) * 9, 0.1, (Math.random() - 0.5) * 9));
}
}.runTaskTimer(Manager.getPlugin(), 0, 1)).getTaskId());
}
@Override
public void cancel(Player player)
{
super.cancel(player);
player.setWalkSpeed(0.2F);
Bukkit.getScheduler().cancelTask(_tasks.get(player.getUniqueId()));
}
@Override
public double getChargeIncreasePerSecond()
{
return CHARGE_PER_SECOND;
}
@Override
public long getLength()
{
return _length;
}
}

View File

@ -0,0 +1,342 @@
package nautilus.game.arcade.game.games.quiver.ultimates;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.google.common.collect.Sets;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilInv;
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.UtilTime;
import mineplex.core.common.util.particles.effects.LineParticle;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
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
{
private static final double CHARGE_PER_SECOND = 0.4;
private static final long LAUNCHER_FIRE_DELAY = 500;
private static final long LAUNCHER_MAX_TIME = 15000;
private static final int Y_INCREASE = 10;
private double _damageTeleport;
private double _radiusTeleport;
private double _damageLauncher;
private double _radiusLauncher;
private int _rangeLauncher;
private List<SkyWarriorData> _data = new ArrayList<>();
public UltimateSkyWarrior(double damageTeleport, double radiusTeleport, double damageLauncher, double radiusLauncher, int rangeLauncher)
{
super("Bombardment", new String[] {});
_damageTeleport = damageTeleport;
_radiusTeleport = radiusTeleport;
_damageLauncher = damageLauncher;
_radiusLauncher = radiusLauncher;
_rangeLauncher = rangeLauncher;
}
@Override
public void activate(Player player)
{
super.activate(player);
Location playerLocation = player.getLocation();
// This is to stop the players getting killed by the border if they were
// teleported above it.
Location toTeleport = new Location(player.getWorld(), playerLocation.getX(), Math.min(Manager.GetGame().WorldData.MaxY - 3, playerLocation.getY() + Y_INCREASE), playerLocation.getZ());
toTeleport.setYaw(playerLocation.getYaw());
toTeleport.setPitch(playerLocation.getPitch());
Block block = toTeleport.getBlock().getRelative(BlockFace.DOWN);
block.setType(Material.BARRIER);
player.setWalkSpeed(0);
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()));
player.getInventory().clear();
ItemStack itemStack = new ItemBuilder(Material.IRON_HOE).setTitle(C.cGreenB + GetName() + C.cDGreenB + " Click To Fire!").build();
for (int i = 0; i < 9; i++)
{
player.getInventory().addItem(itemStack);
}
Game game = Manager.GetGame();
UtilFirework.playFirework(playerLocation, Type.BALL, game.GetTeam(player).GetColorBase(), false, false);
UtilFirework.playFirework(toTeleport, Type.BALL, game.GetTeam(player).GetColorBase(), false, false);
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() == UpdateType.TICK)
{
for (SkyWarriorData data : _data)
{
UtilParticle.PlayParticleToAll(ParticleType.CLOUD, data.getPlayer().getLocation().subtract(0, 0.5, 0), 0.5F, 0.25F, 0.5F, 0.01F, 6, ViewDist.MAX);
}
}
else if (event.getType() == UpdateType.FAST)
{
for (SkyWarriorData data : _data)
{
if (UtilTime.elapsed(data.getStartTimeStamp(), LAUNCHER_MAX_TIME))
{
cancel(data.getPlayer());
}
}
}
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
Player player = event.getPlayer();
SkyWarriorData data = getData(player);
if (data == null)
{
return;
}
if (player.getItemInHand().getType() != Material.IRON_HOE)
{
return;
}
if (!hasPerk(player))
{
return;
}
if (!Recharge.Instance.use(player, GetName(), LAUNCHER_FIRE_DELAY, true, false))
{
return;
}
player.getWorld().playSound(player.getLocation(), Sound.FIREWORK_BLAST, 5, 1);
LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.5, _rangeLauncher, Sets.newHashSet(Material.BARRIER), ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers());
while (!lineParticle.update())
{
}
Location location = lineParticle.getDestination();
// Damage Players
for (Player other : UtilPlayer.getNearby(location, _radiusLauncher))
{
Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, _damageLauncher, true, true, false, player.getName(), GetName());
}
UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, location, 0, 0, 0, 1F, 1, ViewDist.LONG);
data.setShotsLeft(data.getShotsLeft() - 1);
if (data.getShotsLeft() == 0)
{
cancel(player);
}
}
@EventHandler
public void onPlayerMove(PlayerMoveEvent event)
{
if (!getLastUltimate().containsKey(event.getPlayer().getUniqueId()))
{
return;
}
Location from = event.getFrom();
Location to = event.getTo();
if (from.getX() == to.getX() && from.getZ() == to.getZ())
{
return;
}
event.setTo(from);
}
@Override
public void cancel(Player player)
{
super.cancel(player);
player.getInventory().clear();
Kit.GiveItems(player);
player.setWalkSpeed(0.2F);
player.removePotionEffect(PotionEffectType.JUMP);
SkyWarriorData data = getData(player);
Game game = Manager.GetGame();
data.getBlock().setType(Material.AIR);
for (int i = 0; i < data.getPreviousArrows(); i++)
{
player.getInventory().addItem(Quiver.SUPER_ARROW);
}
boolean found = false;
for (Player other : game.GetPlayers(true))
{
if (UtilPlayer.isSpectator(other) || player.equals(other))
{
continue;
}
if (game.GetTeam(player).equals(game.GetTeam(other)))
{
player.sendMessage(F.main("Game", "You were teleported to " + F.elem(other.getName()) + "."));
player.teleport(other);
other.getWorld().strikeLightningEffect(other.getLocation());
UtilFirework.playFirework(other.getLocation(), Type.STAR, game.GetTeam(player).GetColorBase(), false, false);
for (Player toDamage : UtilPlayer.getNearby(other.getEyeLocation(), _radiusTeleport))
{
Manager.GetDamage().NewDamageEvent(toDamage, player, null, DamageCause.CUSTOM, _damageTeleport, false, true, false, player.getName(), GetName() + " Teleportation");
}
found = true;
break;
}
}
if (!found)
{
player.sendMessage(F.main("Game", "A player could not be found!"));
}
_data.remove(data);
}
@Override
public boolean isUsable(Player player)
{
for (int i = 2; i <= Y_INCREASE; i++)
{
if (player.getLocation().add(0, i, 0).getBlock().getType() != Material.AIR)
{
player.sendMessage(F.main("Game", "You do not have enough room to use this!"));;
return false;
}
}
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)
{
if (data.getPlayer().equals(player))
{
return data;
}
}
return null;
}
private final class SkyWarriorData
{
private Player _player;
private Block _block;
private int _shotsLeft;
private int _previousArrows;
private long _startTimeStamp;
public SkyWarriorData(Player player, Block block, int shots, int previousArrows, long startTimeStamp)
{
_player = player;
_block = block;
_shotsLeft = shots;
_previousArrows = previousArrows;
_startTimeStamp = startTimeStamp;
}
public void setShotsLeft(int slotsLeft)
{
_shotsLeft = slotsLeft;
}
public Player getPlayer()
{
return _player;
}
public Block getBlock()
{
return _block;
}
public int getShotsLeft()
{
return _shotsLeft;
}
public int getPreviousArrows()
{
return _previousArrows;
}
public long getStartTimeStamp()
{
return _startTimeStamp;
}
}
}

View File

@ -301,16 +301,18 @@ public abstract class Skywars extends Game
private void parseCreateConnectorChests()
{
for (int i = 0; i < 4 && !WorldData.GetDataLocs("GRAY").isEmpty(); i++)
Iterator<Location> iterator = WorldData.GetDataLocs("GRAY").iterator();
while (iterator.hasNext())
{
Location loc = UtilAlg.Random(WorldData.GetDataLocs("GRAY"));
WorldData.GetDataLocs("GRAY").remove(loc);
Location loc = iterator.next();
loc.getBlock().setTypeIdAndData(Material.CHEST.getId(), (byte) UtilMath.r(4), true);
_connectorChests.add(loc.getBlock());
_worldBlocks.add(loc.getBlock());
iterator.remove();
}
}
@ -392,15 +394,15 @@ public abstract class Skywars extends Game
private void setupBookEnchantments()
{
_commonBookEnchantments.put(Enchantment.DAMAGE_ALL, 3);
_commonBookEnchantments.put(Enchantment.DAMAGE_ALL, 1);
_commonBookEnchantments.put(Enchantment.FIRE_ASPECT, 1);
_commonBookEnchantments.put(Enchantment.ARROW_DAMAGE, 3);
_commonBookEnchantments.put(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
_commonBookEnchantments.put(Enchantment.ARROW_DAMAGE, 1);
_commonBookEnchantments.put(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
_rareBookEnchantments.put(Enchantment.DAMAGE_ALL, 4);
_rareBookEnchantments.put(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
_rareBookEnchantments.put(Enchantment.DAMAGE_ALL, 2);
_rareBookEnchantments.put(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
_rareBookEnchantments.put(Enchantment.ARROW_DAMAGE, 2);
_rareBookEnchantments.put(Enchantment.ARROW_FIRE, 1);
//_rareBookEnchantments.put(Enchantment.FIRE_ASPECT, 2);
_rareBookEnchantments.put(Enchantment.ARROW_KNOCKBACK, 1);
_rareBookEnchantments.put(Enchantment.KNOCKBACK, 2);
_rareBookEnchantments.put(Enchantment.THORNS, 1);
@ -1156,28 +1158,31 @@ public abstract class Skywars extends Game
chest.getBlockInventory().setItem(getIndex(used), _middleBlock.getLoot());
// Books
ItemStack itemStack = _middleBooks.getLoot();
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) itemStack.getItemMeta();
Enchantment enchantment = null;
for (Enchantment cur : meta.getStoredEnchants().keySet())
for (int i = 0; i < UtilMath.r(2); i++)
{
meta.removeStoredEnchant(cur);
}
ItemStack itemStack = _middleBooks.getLoot();
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) itemStack.getItemMeta();
Enchantment enchantment = null;
if (UtilMath.r(4) == 0)
{
enchantment = UtilAlg.Random(_rareBookEnchantments.keySet());
meta.addStoredEnchant(enchantment, _rareBookEnchantments.get(enchantment), true);
}
else
{
enchantment = UtilAlg.Random(_commonBookEnchantments.keySet());
meta.addStoredEnchant(enchantment, _commonBookEnchantments.get(enchantment), true);
}
for (Enchantment cur : meta.getStoredEnchants().keySet())
{
meta.removeStoredEnchant(cur);
}
itemStack.setItemMeta(meta);
chest.getBlockInventory().setItem(getIndex(used), itemStack);
if (UtilMath.r(4) == 0)
{
enchantment = UtilAlg.Random(_rareBookEnchantments.keySet());
meta.addStoredEnchant(enchantment, _rareBookEnchantments.get(enchantment), true);
}
else
{
enchantment = UtilAlg.Random(_commonBookEnchantments.keySet());
meta.addStoredEnchant(enchantment, _commonBookEnchantments.get(enchantment), true);
}
itemStack.setItemMeta(meta);
chest.getBlockInventory().setItem(getIndex(used), itemStack);
}
// Misc
chest.getBlockInventory().setItem(getIndex(used), _middleMisc.getLoot());

View File

@ -22,9 +22,9 @@ public class KitFire extends ProgressingKit
"Start with " + C.cGreen + "Wood Sword" + C.cGray + " and " + C.cGreen + "Blaze Rod",
"",
C.cYellow + "Right Click" + C.cWhite + " with Blaze Rod to use " + C.cGreen + "Fire Burst",
"Sends out a pulse of fire that deals " + C.cGreen + 3 + C.cWhite + " damage to",
"Sends out a pulse of fire that deals " + C.cGreen + 5 + C.cWhite + " damage to",
"all players within " + C.cGreen + 4 + C.cWhite + " blocks.",
"Cooldown " + C.cGreen + UtilTime.convertString(45000, 0, TimeUnit.SECONDS) + C.cWhite + "."
"Cooldown " + C.cGreen + UtilTime.convertString(40000, 0, TimeUnit.SECONDS) + C.cWhite + "."
};
private static final String FIRE_BURST = "Fire Burst";
@ -32,22 +32,22 @@ public class KitFire extends ProgressingKit
private static final Perk[][] PERKS =
{
{
new PerkFireBurst(45000, 4, 3)
new PerkFireBurst(40000, 4, 5)
},
{
new PerkFireBurst(44000, 4, 3)
new PerkFireBurst(39000, 4, 5)
},
{
new PerkFireBurst(43000, 4, 3)
new PerkFireBurst(38000, 4, 5)
},
{
new PerkFireBurst(42000, 4, 4)
new PerkFireBurst(37000, 4, 6)
},
{
new PerkFireBurst(41000, 4, 4)
new PerkFireBurst(36000, 4, 6)
},
{
new PerkFireBurst(40000, 4, 4)
new PerkFireBurst(35000, 4, 6)
},
};
@ -61,7 +61,7 @@ public class KitFire extends ProgressingKit
},
{
reduceCooldown(FIRE_BURST, 1),
increase(FIRE_BURST, "Range", 20)
increase(FIRE_BURST, "Damage", 25)
},
{
reduceCooldown(FIRE_BURST, 1)

View File

@ -31,7 +31,7 @@ public class KitMetal extends ProgressingKit
"Cooldown " + C.cGreen + UtilTime.convertString(15000, 0, TimeUnit.SECONDS) + C.cWhite + ".",
"",
"For each piece of metal armor you wear you gain",
"a level of " + C.cGreen + "Damage Resistance" + C.cWhite + ".",
"a " + C.cGreen + 7.5 + C.cWhite + "% damage resistance.",
};
private static final String MAGNET = "Magnet";

View File

@ -0,0 +1,57 @@
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 mineplex.core.common.MinecraftVersion;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
/**
* This module functions as a checkpoint for any client connecting a game
* server. Making sure they have the minimum client version for your game.
*
* @see MinecraftVersion
*/
public class VersionModule extends Module
{
private MinecraftVersion _minecraftVersion;
private String _kickMessage;
public VersionModule(MinecraftVersion minecraftVersion)
{
this(minecraftVersion, "You have an outdated client for this game!");
}
public VersionModule(MinecraftVersion minecraftVersion, String kickMessage)
{
_minecraftVersion = minecraftVersion;
_kickMessage = kickMessage;
for (Player player : UtilServer.getPlayers())
{
if (!hasVersion(player))
{
player.kickPlayer(kickMessage);
}
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerJoin(PlayerJoinEvent event)
{
if (!hasVersion(event.getPlayer()))
{
event.getPlayer().kickPlayer(_kickMessage);
}
}
private boolean hasVersion(Player player)
{
return UtilPlayer.getVersion(player) == _minecraftVersion;
}
}

View File

@ -30,6 +30,11 @@ public abstract class Perk implements Listener
public boolean hasPerk(Player player)
{
if (!Manager.GetGame().IsLive())
{
return false;
}
if (!(Kit instanceof ProgressingKit))
{
return Kit.HasKit(player);

View File

@ -24,8 +24,9 @@ public class PerkArrowRebound extends Perk
private int _max = 0;
private float _maxPower = 1f;
private float _maxDistance;
public PerkArrowRebound(int max, float maxPower)
public PerkArrowRebound(int max, float maxPower, float maxDistance)
{
super("Chain Arrows", new String[]
{
@ -35,6 +36,7 @@ public class PerkArrowRebound extends Perk
_max = max;
_maxPower = maxPower;
_maxDistance = maxDistance;
}
@EventHandler
@ -65,8 +67,8 @@ public class PerkArrowRebound extends Perk
Player hit = UtilPlayer.getClosest(arrowLoc, data.Ignore);
if (hit == null) return;
if (UtilMath.offset(hit.getLocation(), arrowLoc) > 1 &&
UtilMath.offset(hit.getEyeLocation(), arrowLoc) > 1)
if (UtilMath.offset(hit.getLocation(), arrowLoc) > _maxDistance &&
UtilMath.offset(hit.getEyeLocation(), arrowLoc) > _maxDistance)
return;
data.Ignore.add(hit);

View File

@ -0,0 +1,129 @@
package nautilus.game.arcade.kit.perks;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractEvent;
import com.google.common.collect.Sets;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.particles.effects.LineParticle;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.kit.Perk;
public class PerkDash extends Perk
{
private static final double DAMAGE_RADIUS = 2.5;
private long _cooldown;
private double _damage;
private double _distance;
public PerkDash(long cooldown, double damage, double distance)
{
super("Dash", new String[] {});
_cooldown = cooldown;
_damage = damage;
_distance = distance;
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
if (event.isCancelled())
{
return;
}
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
{
return;
}
Player player = event.getPlayer();
if (player.getItemInHand() == null)
{
return;
}
if (!UtilItem.isSword(player.getItemInHand()))
{
return;
}
if (!hasPerk(player))
{
return;
}
if (!Recharge.Instance.use(player, GetName(), _cooldown, true, true))
{
return;
}
LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.8, _distance, Sets.newHashSet(Material.RAILS), ParticleType.FIREWORKS_SPARK,
UtilServer.getPlayers());
Set<UUID> hitPlayers = new HashSet<>();
while (!lineParticle.update())
{
for (Player other : UtilPlayer.getNearby(lineParticle.getLastLocation(), DAMAGE_RADIUS))
{
if (hitPlayers.contains(other.getUniqueId()) || player.equals(other))
{
continue;
}
if (Manager.GetGame() instanceof TeamGame)
{
Game game = Manager.GetGame();
if (game.GetTeam(player).equals(game.GetTeam(other)))
{
continue;
}
}
hitPlayers.add(other.getUniqueId());
Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, _damage, true, true, false, player.getName(), GetName());
player.sendMessage(F.main("Game", "You hit " + F.elem(other.getName()) + " with " + F.skill(GetName()) + "."));
}
}
Game game = Manager.GetGame();
Location location = lineParticle.getDestination();
UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, game.GetTeam(player).GetColorBase(), false, false);
player.playSound(player.getLocation(), Sound.SHOOT_ARROW, 1, 1);
player.teleport(location.add(0, 0.5, 0));
player.playSound(player.getLocation(), Sound.SHOOT_ARROW, 1, 1);
UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, game.GetTeam(player).GetColorBase(), false, false);
player.setFallDistance(0);
player.sendMessage(F.main("Game", "You used " + F.skill(GetName()) + "."));
}
}

View File

@ -206,7 +206,7 @@ public class PerkDestructor extends Perk
for (Block block : UtilBlock.getInRadius(proj.getLocation(), 4).keySet())
{
if (block.getType() == Material.AIR || block.getType() == Material.BEDROCK || block.isLiquid())
if (block.getType() == Material.AIR || block.getType() == Material.BEDROCK || block.getType() == Material.BARRIER || block.isLiquid())
continue;
//Event

View File

@ -25,17 +25,20 @@ import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileUser;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.skywars.TeamSkywars;
import nautilus.game.arcade.kit.Perk;
public class PerkDirtCannon extends Perk implements IThrown
{
private static final int GIVE_DELAY = 20000;
private static final int MAX_DIRT = 4;
private static final long COOLDOWN = 500;
private static final ItemStack DIRT_ITEM = new ItemBuilder(Material.DIRT).setTitle(C.cGreen + "Throwable Dirt").setGlow(true).build();
private long _lastDirt;
@ -74,6 +77,11 @@ public class PerkDirtCannon extends Perk implements IThrown
return;
}
if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true))
{
return;
}
int amount = player.getInventory().getItemInHand().getAmount() - 1;
if (amount == 0)
@ -82,9 +90,9 @@ public class PerkDirtCannon extends Perk implements IThrown
}
else
{
player.getItemInHand().setAmount(amount);
player.getItemInHand().setAmount(Math.min(MAX_DIRT - 1, amount));
}
@SuppressWarnings("deprecation")
FallingBlock fallingBlock = player.getWorld().spawnFallingBlock(player.getEyeLocation().add(player.getLocation().getDirection()), Material.DIRT, (byte) 0);
fallingBlock.setDropItem(false);
@ -104,7 +112,7 @@ public class PerkDirtCannon extends Perk implements IThrown
{
for (Player player : Manager.GetGame().GetPlayers(true))
{
if (!hasPerk(player) || UtilInv.contains(player, "Throwable", Material.DIRT, (byte) 0, 4))
if (!hasPerk(player) || UtilInv.contains(player, "Throwable", Material.DIRT, (byte) 0, MAX_DIRT))
{
continue;
}
@ -143,6 +151,11 @@ public class PerkDirtCannon extends Perk implements IThrown
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event)
{
if (!hasPerk(event.getPlayer()))
{
return;
}
if (DIRT_ITEM.isSimilar(event.getItemDrop().getItemStack()))
{
event.getPlayer().sendMessage(F.main("Game", "You cannot drop this item."));
@ -178,16 +191,11 @@ public class PerkDirtCannon extends Perk implements IThrown
return;
}
if (Manager.GetGame() instanceof TeamGame && target instanceof Player && data.getThrower() instanceof Player)
if (Manager.GetGame() instanceof TeamSkywars && target instanceof Player && data.getThrower() instanceof Player)
{
Game game = Manager.GetGame();
if (!game.IsAlive(target))
{
return;
}
if (game.GetTeam((Player) target).equals(game.GetTeam((Player) data.getThrower())))
if (game.GetTeam((Player) target).equals(game.GetTeam((Player) data.getThrower())) || !game.IsAlive(target))
{
return;
}

View File

@ -0,0 +1,49 @@
package nautilus.game.arcade.kit.perks;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.ProjectileHitEvent;
import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.kit.Perk;
public class PerkFireArrows extends Perk
{
private double _distance;
private int _fireTicks;
public PerkFireArrows(double distance, int fireTicks)
{
super("Fire Arrows", new String[] {});
_distance = distance;
_fireTicks = fireTicks;
}
@EventHandler
public void onProjectileHit(ProjectileHitEvent event)
{
if (event.getEntity().getShooter() instanceof Player)
{
Player player = (Player) event.getEntity().getShooter();
Projectile projectile = event.getEntity();
if (!hasPerk(player))
{
return;
}
for (Player other : UtilPlayer.getNearby(projectile.getLocation(), _distance))
{
if (!Manager.IsAlive(other) || player.equals(other) || Manager.GetGame().GetTeam(player).equals(Manager.GetGame().GetTeam(other)))
{
continue;
}
other.setFireTicks(_fireTicks);
}
}
}
}

View File

@ -38,6 +38,7 @@ public class PerkFletcher extends Perk
private boolean _remove;
private int _slot;
private boolean _instant = true;
private String _name;
public PerkFletcher(int time, int max, boolean remove)
{
@ -55,6 +56,11 @@ public class PerkFletcher extends Perk
}
public PerkFletcher(int time, int max, boolean remove, int slot, boolean instant)
{
this(time, max, remove, slot, instant, "Fletcted Arrow");
}
public PerkFletcher(int time, int max, boolean remove, int slot, boolean instant, String name)
{
super("Fletcher", new String[]
{
@ -66,8 +72,9 @@ public class PerkFletcher extends Perk
_remove = remove;
_slot = slot;
_instant = instant;
_name = name;
}
public boolean isFletchedArrow(ItemStack stack)
{
if (!UtilGear.isMat(stack, Material.ARROW))
@ -78,7 +85,7 @@ public class PerkFletcher extends Perk
if (meta.getDisplayName() == null)
return false;
if (!meta.getDisplayName().contains("Fletched Arrow"))
if (!meta.getDisplayName().contains(_name))
return false;
return true;
@ -92,7 +99,7 @@ public class PerkFletcher extends Perk
Player player = (Player)event.getEntity();
if (!Kit.HasKit(player))
if (!hasPerk(player))
return;
for (int i=0 ; i<=8 ; i++)
@ -129,7 +136,7 @@ public class PerkFletcher extends Perk
if (Manager.isSpectator(cur))
continue;
if (!Kit.HasKit(cur))
if (!hasPerk(cur))
continue;
if (!Manager.GetGame().IsAlive(cur))
@ -145,17 +152,17 @@ public class PerkFletcher extends Perk
if (!Recharge.Instance.use(cur, GetName(), _time * 1000, false, false))
continue;
if (UtilInv.contains(cur, "Fletched Arrow", Material.ARROW, (byte)0, _max))
if (UtilInv.contains(cur, _name, Material.ARROW, (byte)0, _max))
continue;
//Add
if (_slot == -1)
{
cur.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)0, 1, F.item("Fletched Arrow")));
cur.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)0, 1, F.item(_name)));
}
else
{
cur.getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(262, (byte)0, 1, F.item("Fletched Arrow")));
cur.getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(262, (byte)0, 1, F.item(_name)));
}
cur.playSound(cur.getLocation(), Sound.ITEM_PICKUP, 2f, 1f);
@ -175,7 +182,7 @@ public class PerkFletcher extends Perk
event.setCancelled(true);
//Inform
UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot drop " + F.item("Fletched Arrow") + "."));
UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot drop " + F.item(_name) + "."));
}
@EventHandler
@ -194,7 +201,7 @@ public class PerkFletcher extends Perk
@EventHandler
public void FletchInvClick(InventoryClickEvent event)
{
UtilInv.DisallowMovementOf(event, "Fletched Arrow", Material.ARROW, (byte)0, true);
UtilInv.DisallowMovementOf(event, _name, Material.ARROW, (byte)0, true);
}
@EventHandler
@ -211,4 +218,4 @@ public class PerkFletcher extends Perk
arrowIterator.remove();
}
}
}
}

View File

@ -0,0 +1,46 @@
package nautilus.game.arcade.kit.perks;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.kit.Perk;
public class PerkLifestealArrows extends Perk
{
private double _health;
public PerkLifestealArrows(double health)
{
super("Lifesteal Arrows", new String[] {});
_health = health;
}
@EventHandler
public void onCustomDamage(CustomDamageEvent event)
{
if (event.GetCause() != DamageCause.PROJECTILE)
{
return;
}
Player player = event.GetDamagerPlayer(true);
if (!hasPerk(player))
{
return;
}
player.setHealth(Math.min(player.getMaxHealth(), player.getHealth() + _health));
UtilParticle.PlayParticleToAll(ParticleType.HEART, player.getLocation().add(0, 1, 0), 1, 1, 1, 1, 5, ViewDist.NORMAL);
UtilParticle.PlayParticleToAll(ParticleType.HEART, event.GetDamageeEntity().getLocation().add(0, 1, 0), 1, 1, 1, 1, 5, ViewDist.NORMAL);
}
}

View File

@ -6,6 +6,7 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
@ -16,30 +17,25 @@ import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilMath;
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.particles.effects.LineParticle;
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.game.Game;
import nautilus.game.arcade.game.games.skywars.TeamSkywars;
import nautilus.game.arcade.kit.Perk;
public class PerkMagnetism extends Perk
{
private static final int RESISTANCE_DURATION = 40;
private long _cooldown;
private int _range;
@ -55,31 +51,24 @@ public class PerkMagnetism extends Perk
_magnituideFactor = magnitudeFactor;
}
@EventHandler
public void onUpdate(UpdateEvent event)
@EventHandler(priority = EventPriority.HIGHEST)
public void onCustomDamage(CustomDamageEvent event)
{
if (event.getType() != UpdateType.FAST)
if (!(event.GetDamageeEntity() instanceof Player))
{
return;
}
for (Player player : UtilServer.getPlayers())
Player player = event.GetDamageePlayer();
if (!hasPerk(player))
{
if (!hasPerk(player) || UtilPlayer.isSpectator(player))
{
continue;
}
int magnituide = getAmountOfMetalArmor(player);
if (magnituide == 0)
{
continue;
}
player.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, RESISTANCE_DURATION, magnituide - 1));
return;
}
int magnitude = getAmountOfMetalArmor(player);
event.AddMod(GetName(), event.GetDamage() * (magnitude * -0.05));
}
@EventHandler
@ -139,8 +128,13 @@ public class PerkMagnetism extends Perk
}
Manager.GetDamage().NewDamageEvent(target, player, null, DamageCause.CUSTOM, 1, false, true, true, player.getName(), GetName());
UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, player.getEyeLocation(), 1, 1, 1, 0.01F, 20, ViewDist.NORMAL);
LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.5, UtilMath.offset(player, target), null, ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers());
while (!lineParticle.update())
{
}
Vector vector = UtilAlg.getTrajectory(target, player).multiply((.5 + magnitude / 4) * _magnituideFactor);
UtilAction.velocity(target, vector.setY(Math.max(.6, vector.getY())));

View File

@ -25,6 +25,7 @@ import nautilus.game.arcade.kit.Perk;
public class PerkSeismicSlamOITQ extends Perk
{
public PerkSeismicSlamOITQ()
{
super("Ground Pound", new String[]

View File

@ -33,7 +33,7 @@ public class PerkSpeed extends Perk
for (Player player : Manager.GetGame().GetPlayers(true))
{
if (!Kit.HasKit(player))
if (!hasPerk(player))
continue;
Manager.GetCondition().Factory().Speed(GetName(), player, player, 8, _level, false, false, true);

View File

@ -31,7 +31,7 @@ public class PerkStrength extends Perk
Player damager = event.GetDamagerPlayer(true);
if (damager == null) return;
if (!Kit.HasKit(damager))
if (!hasPerk(damager))
return;
event.AddMod(damager.getName(), GetName(), _power, false);

View File

@ -1012,7 +1012,17 @@ public class GameLobbyManager implements Listener
public void AddPlayerToScoreboards(Player player, GameTeam gameTeam)
{
Rank rank = Manager.GetClients().Get(player).getRealOrDisguisedRank();
Rank rank;
if (player == null)
{
rank = Rank.ALL;
}
else
{
rank = Manager.GetClients().Get(player).getRealOrDisguisedRank();
}
String teamId = getTeamId(gameTeam, player);
for (MineplexScoreboard scoreboard : Manager.getScoreboardManager().getScoreboards().values())
@ -1040,7 +1050,10 @@ public class GameLobbyManager implements Listener
}
}
}
team.addEntry(player.getName());
if (player != null)
{
team.addEntry(player.getName());
}
}
}
@ -1063,14 +1076,27 @@ public class GameLobbyManager implements Listener
public String getTeamId(GameTeam gameTeam, Player player)
{
Rank rank = Manager.GetClients().Get(player).getRealOrDisguisedRank();
String rankName = rank.Name;
boolean rankIsUltra = !rank.has(Rank.ULTRA) &&
Manager.GetDonation().Get(player).OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA");
if (rankIsUltra)
Rank rank;
if (player == null)
{
rankName = Rank.ULTRA.Name;
rank = Rank.ALL;
}
else
{
rank = Manager.GetClients().Get(player).getRealOrDisguisedRank();
}
String rankName = rank.Name;
if (player != null)
{
boolean rankIsUltra = !rank.has(Rank.ULTRA) &&
Manager.GetDonation().Get(player).OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA");
if (rankIsUltra)
{
rankName = Rank.ULTRA.Name;
}
}
String teamId;
@ -1080,11 +1106,14 @@ public class GameLobbyManager implements Listener
}
else
{
teamId = rankName;
// It needs to be color first in order for the client to sort the tab list correctly
if (gameTeam != null && gameTeam.GetColor() != null)
{
teamId += "." + gameTeam.GetColor().getChar();
teamId = gameTeam.GetColor().getChar() + "." + rankName;
}
else
{
teamId = rankName;
}
}
return teamId;

View File

@ -2,7 +2,9 @@ package nautilus.game.arcade.managers;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import mineplex.core.PlayerSelector;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.FireworkEffect.Type;
@ -329,7 +331,7 @@ public class GameManager implements Listener
{
//Stop Countdown!
if (game.GetCountdown() != -1 &&
UtilServer.getPlayers().length < Manager.GetPlayerMin() &&
getValidPlayersForGameStart().size() < Manager.GetPlayerMin() &&
!game.GetCountdownForce())
{
game.SetCountdown(-1);
@ -338,10 +340,10 @@ public class GameManager implements Listener
if (Manager.IsGameAutoStart())
{
if (UtilServer.getPlayers().length >= Manager.GetPlayerFull())
if (getValidPlayersForGameStart().size() >= Manager.GetPlayerFull())
StateCountdown(game, 20, false);
else if (UtilServer.getPlayers().length >= Manager.GetPlayerMin())
else if (getValidPlayersForGameStart().size() >= Manager.GetPlayerMin())
StateCountdown(game, 60, false);
else if (game.GetCountdown() != -1)
@ -410,6 +412,13 @@ public class GameManager implements Listener
}
}
public List<Player> getValidPlayersForGameStart()
{
return PlayerSelector.selectPlayers(
PlayerSelector.and(PlayerSelector.NOT_VANISHED, player -> !Manager.IsObserver(player))
);
}
public void StateCountdown(Game game, int timer, boolean force)
{
if (game instanceof UHC && !((UHC)game).isMapLoaded())