Merge branch 'project-cosmetics' into develop

This commit is contained in:
cnr 2016-06-23 18:42:47 -05:00
commit 3433e0e3bc
299 changed files with 12522 additions and 8874 deletions

View File

@ -255,12 +255,14 @@ public class MapUtil
@SuppressWarnings({ "rawtypes" })
public static boolean ClearWorldReferences(String worldName)
{
synchronized (RegionFileCache.class)
{
HashMap regionfiles = (HashMap) RegionFileCache.a;
try
{
for (Iterator<Object> iterator = regionfiles.entrySet().iterator(); iterator.hasNext();)
for (Iterator<Object> iterator = regionfiles.entrySet().iterator(); iterator.hasNext(); )
{
Map.Entry e = (Map.Entry) iterator.next();
RegionFile file = (RegionFile) e.getValue();
@ -284,6 +286,7 @@ public class MapUtil
return true;
}
}
public static BlockPosition getBlockPos(int x, int y, int z)
{

View File

@ -11,6 +11,7 @@ import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import java.lang.reflect.Field;
@ -112,7 +113,7 @@ public class UtilServer
public static Plugin getPlugin()
{
return getPluginManager().getPlugins()[0];
return JavaPlugin.getProvidingPlugin(UtilServer.class);
}
public static PluginManager getPluginManager()

View File

@ -33,6 +33,11 @@ public class UtilWorld
return chunkToStr(chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
}
public static String chunkToStr(Location location)
{
return chunkToStr(location.getWorld().getName(), location.getBlockX() >> 4, location.getBlockZ() >> 4);
}
public static String chunkToStr(String world, int x, int z)
{
return world + "," + x + "," + z;

View File

@ -1,57 +1,59 @@
package mineplex.core.common.weight;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import java.util.stream.Collectors;
public class WeightSet<T>
{
private static Random random = new Random();
private Set<Weight<T>> _weights;
private Set<Weight<T>> _weights = new HashSet<Weight<T>>();
private volatile transient Set<T> _keyset;
public WeightSet()
{
_weights = new HashSet<Weight<T>>();
}
@SafeVarargs
public WeightSet(Weight<T>... weights)
{
this();
for (Weight<T> weight : weights)
{
_weights.add(weight);
}
computeKeyset();
}
@SafeVarargs
public WeightSet(T... elements)
{
this();
for (T element : elements)
{
_weights.add(new Weight<T>(1, element)); // Constant weight of 1 means all elements are equally likely
}
computeKeyset();
}
public WeightSet(Collection<T> elements)
{
this();
for (T element : elements)
{
_weights.add(new Weight<T>(1, element)); // Constant weight of 1 means all elements are equally likely
}
computeKeyset();
}
public void add(int weight, T element)
{
_weights.add(new Weight<T>(weight, element));
computeKeyset();
}
private int getTotalWeight()
@ -87,13 +89,11 @@ public class WeightSet<T>
public Set<T> elements()
{
Set<T> elements = new HashSet<T>();
for (Weight<T> weight : _weights)
{
elements.add(weight.getValue());
return this._keyset;
}
return elements;
private void computeKeyset()
{
_keyset = Collections.unmodifiableSet(_weights.stream().map(Weight::getValue).collect(Collectors.toSet()));
}
}

View File

@ -12,6 +12,7 @@ import mineplex.core.hologram.HologramManager;
import mineplex.core.stats.StatsManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.serverdata.Region;
import mineplex.serverdata.redis.counter.Counter;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -24,6 +25,8 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
/**
* @author Shaun Bennett
*/
@ -47,8 +50,10 @@ public class FountainManager extends MiniPlugin
_brawlShopProvider = shopProvider;
World world = Bukkit.getWorlds().get(0);//-43.5, 66, -38.5
int goal = !new File("eu.dat").exists() ? 300000000 : 5000000;
_gemFountain = new Fountain(new Location(world, -32.5, 72, -23.5), new Location(world, -43.5, 67, -38.5),
C.cGreen + "Gem Fountain", "GemFountain_01", 10000000, this, clientManager, donationManager, _hologramManager, _statsManager);
C.cGreen + "Gem Fountain", "GemFountain_01", goal, this, clientManager, donationManager, _hologramManager, _statsManager);
}
@Override

View File

@ -20,7 +20,7 @@ public class GemFountainSalesPackage extends SalesPackageBase
}
@Override
public void Sold(Player player, CurrencyType currencyType)
public void sold(Player player, CurrencyType currencyType)
{
}

View File

@ -22,6 +22,7 @@ import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.commons.lang3.Validate;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -230,18 +231,35 @@ public class Chat extends MiniPlugin
return;
}
for (int i = 0; i < event.getLines().length; i++)
String[] lines = event.getLines();
runAsync(() ->
{
String line = event.getLine(i);
for (int i = 0; i < lines.length; i++)
{
String line = lines[i];
if (line != null && line.length() > 0)
{
String filteredLine = getFilteredMessage(event.getPlayer(), line);
if (filteredLine != null)
event.setLine(i, filteredLine);
{
lines[i] = filteredLine;
}
}
}
runSync(() ->
{
Sign sign = (Sign) event.getBlock().getState();
for (int i = 0; i < lines.length; i++)
{
sign.setLine(i, lines[i]);
}
sign.update();
});
});
}
@EventHandler(priority = EventPriority.LOWEST)
public void filterChat(AsyncPlayerChatEvent event)
{

View File

@ -36,6 +36,17 @@ public abstract class MultiCommandBase<PluginType extends MiniPlugin> extends Co
command.SetCommandCenter(_commandCenter);
}
}
@Override
public void SetCommandCenter(CommandCenter commandCenter)
{
super.SetCommandCenter(commandCenter);
for (ICommand iCommand : Commands.values())
{
iCommand.SetCommandCenter(commandCenter);
}
}
@Override
public void Execute(Player caller, String[] args)
{

View File

@ -0,0 +1,50 @@
package mineplex.core.progression;
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.progression.data.PlayerKit;
import mineplex.core.progression.data.PlayerKitDataManager;
import mineplex.core.progression.gui.MenuListener;
import org.bukkit.plugin.java.JavaPlugin;
/**
* The main class, process logins and loads data.
*/
public class KitProgressionManager extends MiniClientPlugin<PlayerKit>
{
private PlayerKitDataManager _dataManager;
private KitProgressionRepository _kitProgressionRepository;
private CoreClientManager _coreClientManager;
public KitProgressionManager(JavaPlugin plugin, CoreClientManager clientManager)
{
super("Kit Progression", plugin);
_dataManager = new PlayerKitDataManager();
_kitProgressionRepository = new KitProgressionRepository(this);
_coreClientManager = clientManager;
getPlugin().getServer().getPluginManager().registerEvents(new MenuListener(), getPlugin());
}
public CoreClientManager getClientManager()
{
return _coreClientManager;
}
@Override
protected PlayerKit AddPlayer(String player)
{
return null;
}
public PlayerKitDataManager getDataManager()
{
return _dataManager;
}
public KitProgressionRepository getRepository()
{
return _kitProgressionRepository;
}
}

View File

@ -0,0 +1,220 @@
package mineplex.core.progression;
import mineplex.core.database.MinecraftRepository;
import mineplex.core.progression.data.PlayerKit;
import mineplex.core.progression.util.SQLStatement;
import mineplex.serverdata.database.DBPool;
import org.bukkit.Bukkit;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.UUID;
/**
* Handles all things database related.
*/
public class KitProgressionRepository extends MinecraftRepository
{
private final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS `kitProgression` (" +
"`uuid` VARCHAR(36), " +
"`kitId` VARCHAR(64), " +
"`level` INT, " +
"`xp` INT, " +
"`upgrade_level` INT, " +
"`default` TINYINT, PRIMARY KEY(uuid, kitId))";
private final String INSERT_OR_UPDATE = "INSERT INTO `kitProgression` VALUES(?,?,?,?,?,?) ON DUPLICATE KEY UPDATE " +
"`level` = ?, `xp` = ?, `upgrade_level` = ?, `default` = ?";
private final String QUERY_KITS = "SELECT * FROM `kitProgression` WHERE `uuid` = ?;";
private KitProgressionManager _kitProgressionManager;
public KitProgressionRepository(KitProgressionManager plugin)
{
super(plugin.getPlugin(), DBPool.getAccount());
_kitProgressionManager = plugin;
}
@Override
protected void initialize()
{
}
@Override
protected void update()
{
}
/**
* Inserts data for a kit into the database
* This will update the info if the kit is already in there
*
* @param playerKit The reference to the Player Kit
* @param kit The kit's INTERNAL name
*/
public void insertOrUpdate(PlayerKit playerKit, String kit)
{
async(() -> {
int level = playerKit.getLevel(kit);
int upgradeLevel = playerKit.getUpgradeLevel(kit);
int xp = playerKit.getXp(kit);
int defaultType = playerKit.isDefault(kit) ? 1 : 0;
Connection connection = getConnection();
try
{
PreparedStatement statement = new SQLStatement(INSERT_OR_UPDATE)
.set(1, playerKit.getUuid())
.set(2, kit)
.set(3, level)
.set(4, xp)
.set(5, upgradeLevel)
.set(6, defaultType)
.set(7, level)
.set(8, xp)
.set(9, upgradeLevel)
.set(10, defaultType)
.prepare(connection);
int effect = executeUpdate(statement);
if (effect == -1)
{
//Something went wrong uh oh
this.getPlugin().getLogger().severe("Inserting new Kit Data for " + playerKit.getUuid() + " failed!");
}
} catch (SQLException e)
{
e.printStackTrace();
} finally
{
if (connection != null)
{
try
{
connection.close();
} catch (SQLException e)
{
e.printStackTrace();
}
}
}
});
}
/**
* Update whether or not the specified kit is a default kit
*
* @param playerKit The player's kit data object
* @param kit The INTERNAL name of the kit
* @param def The integer representing the boolean value (1 for true 0 for false)
*/
public void updateDefault(PlayerKit playerKit, String kit, int def)
{
async(() -> {
Connection connection = getConnection();
String update = "UPDATE `kitProgression` SET `default` = ? " + "WHERE `uuid` = ? AND`kitId` = ?";
try
{
PreparedStatement statement = new SQLStatement(update)
.set(1, def)
.set(2, playerKit.getUuid())
.set(3, kit)
.prepare(connection);
int effect = executeUpdate(statement);
if (effect == -1)
{
this.getPlugin().getLogger().severe("Updating default value for" + playerKit.getUuid().toString() + "'s kit failed!");
}
} catch (SQLException e)
{
e.printStackTrace();
} finally
{
if (connection != null)
{
try
{
connection.close();
} catch (SQLException e)
{
e.printStackTrace();
}
}
}
});
}
@SuppressWarnings("Duplicates")
public void getInfo(UUID uuid)
{
async(() -> {
PlayerKit playerKit = new PlayerKit(uuid);
try (Connection connection = getConnection())
{
PreparedStatement preparedStatement = new SQLStatement(QUERY_KITS).set(1, uuid).prepare(connection);
ResultSet resultSet = preparedStatement.executeQuery();
while (resultSet.next())
{
String kitId = resultSet.getString("kitId");
int level = resultSet.getInt("level");
int xp = resultSet.getInt("xp");
int upgradeLevel = resultSet.getInt("upgrade_level");
boolean def = resultSet.getInt("default") == 1;
playerKit.setLevel(level, kitId);
playerKit.setXp(xp, kitId);
playerKit.setUpgradeLevel(upgradeLevel, kitId);
playerKit.setDefault(def, kitId);
}
} catch (SQLException e)
{
e.printStackTrace();
}
_kitProgressionManager.getDataManager().add(playerKit);
});
}
/**
* Internal method for updating the table
*
* @param preparedStatement The statement to execute
* @return The amount of rows effected
*/
private int executeUpdate(PreparedStatement preparedStatement)
{
try
{
return preparedStatement.executeUpdate();
} catch (SQLException e)
{
e.printStackTrace();
return -1;
} finally
{
try
{
if (preparedStatement != null)
{
preparedStatement.close();
}
} catch (SQLException e)
{
e.printStackTrace();
}
}
}
private void async(Runnable runnable)
{
Bukkit.getScheduler().runTaskAsynchronously(_plugin, runnable);
}
}

View File

@ -0,0 +1,278 @@
package mineplex.core.progression;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.progression.data.KitAbilityDetail;
import mineplex.core.progression.math.Calculations;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.UUID;
/**
* The API class all kits with the new system must use
*/
public interface ProgressiveKit
{
/**
* The name of the kit for displaying
*
* @return The kit's display name
*/
String getDisplayName();
/**
* This is the name stored in the database and checked against
*
* @return The internal name of this kit
*/
String getInternalName();
/**
* Get the Icon to display in the GUI
*
* @return This kit's icon
*/
Material getIcon();
/**
* Get the description for this kit
*
* @return This kit's description
*/
String[] getDescription();
/**
* This method gives the GUI information to display about the kit's upgrades and what they do
* This information is being directly displayed in a GUI, so make sure it looks good
* For more information, see the {@link KitAbilityDetail} class
*
* @return The map of upgrades and their details
*/
List<KitAbilityDetail> getAbilityDetails();
/**
* Retrieve the current level of this kit
*
* @param player The UUID of the player whose level you wish to check
* @return The kit's current level
*/
int getLevel(UUID player);
//Should this be a double? I don't think so...
/**
* Get the current amount of XP for this kit
* NOTE: XP Resets after each level up
*
* @param player The UUID of the player whose XP you wish to check
* @return The kit's current XP
*/
int getXp(UUID player);
/**
* Get the current state of upgrades for this kit
* X/5 with 5 being the highest.
* Linearly activated upon meeting certain criteria
*
* @param player The UUID of the player whose upgrade level you wish to check
* @return The kit's current upgrade level out of 5
*/
int getUpgradeLevel(UUID player);
/**
* Is this kit set as a default kit for this player?
*
* @param player The UUID of the player whose default type for this kit you wish to check
* @return Whether or not this kit is a default
*/
boolean isDefault(UUID player);
/**
* Gets whether or not this kit has been selected by the player
*
* @param player The UUID of the player
* @return Whether or not this kit has been selected by the player
*/
boolean isSelected(UUID player);
/**
* Upgrade the player's kit to the current level
*
* @param upgradeLevel The level to upgrade too
* @param player The player who we want to upgrade for.
*/
void upgrade(int upgradeLevel, UUID player);
/**
* Toggle whether or not this kit is default for the specified player
*
* @param defaultValue Whether or not this kit should be default
* @param player The specific player for whom this kit's default staturs will be toggled
*/
void setDefault(boolean defaultValue, UUID player);
/**
* Set the player's overall level for this kit
*
* @param level The level to which you wish to set the player's kit
* @param player The UUID of the player
*/
void setLevel(int level, UUID player);
/**
* Set the player's overall xp for this kit (relative to his current level, this is not TOTAL xp)
*
* @param xp The xp to which you wish to set the player's kit
* @param player The UUID of the player
*/
void setXp(int xp, UUID player);
/**
* Set the player's overall upgradeLevel for this kit
*
* @param upgradeLevel The upgradeLevel to which you wish to set the player's kit
* @param player The UUID of the player
*/
void setUpgradeLevel(int upgradeLevel, UUID player);
/**
* This is called when a player selects a kit in the GUI
* This is where you do your logic for storing player kits in relation to the game
*
* @param player The player who selects this kit.
*/
void onSelected(UUID player);
/**
* This is called when a player clicks the default button in the gui
* It will change the state of default
*
* @param player The player who toggles this kit's default setting.
*/
void onSetDefault(UUID player);
/**
* This method is called when a player level ups
* If you have special effects or messages, here is the place to do it
*
* @param player The player who leveled up
*/
void onLevelUp(UUID player);
/**
* Gets whether or not the player can purchase the upgrade level
*
* @param upgradeLevel The level of the upgrade you wish to check.
* @param player The UUID of the player
* @return If the player can purchase the upgrade
*/
boolean canPurchaseUpgrade(UUID player, int upgradeLevel);
/* ======================================================================================================
*
*
* Below here are utility methods that I believe people will be using frequently.
* If you need to override them, feel free to do so.
*
*
* ====================================================================================================== */
/**
* Gets if a player has already leveled up
* Players are only allowed 1 level up per game.
*
* @param player The player's UUID we want to check against
* @return Whether or not the player has already leveled up in this game
*/
boolean alreadyLeveledUp(UUID player);
/**
* Increment the players current level for this kit, and reset his XP
*
* @param player The player whose level we want to increase
*/
default void levelUp(UUID player)
{
setXp(1, player);
setLevel(getLevel(player) + 1, player);
onLevelUp(player);
}
/**
* Check to see if this player is eligible for level up
*
* @param player The player who we want to check
* @return True if he is able to level up, or false if he's not
*/
default boolean isLevelUpReady(UUID player)
{
int currentLevel = getLevel(player);
int xp = getXp(player);
int nextXP = Calculations.getXpForNextLevel(currentLevel);
if (nextXP < xp)
{
//We don't want people to continue earning XP after the level up, so cancel this.
//Makes sure that they only get the exact amount required.
setXp(nextXP, player);
return true;
}
return xp >= nextXP;
}
/**
* Get the difference (the amount needed) between the players current XP and his next levels XP
*
* @param player The player who we want to check against
* @return The integer difference between his current XP and his next level's required XP
*/
default int getXpDifference(UUID player)
{
int currentLevel = getLevel(player);
int xp = getXp(player);
int nextXP = Calculations.getXpForNextLevel(currentLevel);
return nextXP - xp;
}
/**
* Retrieves whether or not the player currently owns this upgrade.
* This is the upgrade level, not the player level which the player must be to upgrade
* So it should be between 1 and 5
*
* @param player The UUID of the player you wish to check
* @param upgradeLevel The level to check and see if the player owns
* @return If the player has the current upgrade
*/
default boolean ownsUpgrade(UUID player, int upgradeLevel)
{
return getUpgradeLevel(player) >= upgradeLevel;
}
default void displaySelectedEffect(Entity kitHost, Player... displayTo)
{
for (int i = 0; i < 1; i++)
{
double lead = i * ((2d * Math.PI) / 2);
float x = (float) (Math.cos(kitHost.getTicksLived() / 5d + lead) * 1f);
float z1 = (float) (Math.sin(kitHost.getTicksLived() / 5d + lead) * 1f);
float z2 = (float) -(Math.sin(kitHost.getTicksLived() / 5d + lead) * 1f);
float y = (float) (Math.sin(kitHost.getTicksLived() / 5d + lead) + 1f);
UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, kitHost.getLocation().add(x, y, z1), 0f, 0f, 0f, 0, 1,
ViewDist.NORMAL, displayTo);
UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, kitHost.getLocation().add(x, y, z2), 0f, 0f, 0f, 0, 1,
ViewDist.NORMAL, displayTo);
}
}
}

View File

@ -0,0 +1,38 @@
package mineplex.core.progression.data;
import org.bukkit.Material;
/**
* General wrapper for Ability Details (The display properties of this kits Abilities) for a GUI
* The purpose is to limit the amount of hard coded data Kit's do and make it as flexible as possible.
*/
public class KitAbilityDetail
{
private Material _icon;
private String _displayName;
private String[] _description;
public KitAbilityDetail(Material icon, String displayName, String[] description)
{
_icon = icon;
_displayName = displayName;
_description = description;
}
public String getDisplayName()
{
return _displayName;
}
public Material getIcon()
{
return _icon;
}
public String[] getDescription()
{
return _description;
}
}

View File

@ -0,0 +1,103 @@
package mineplex.core.progression.data;
import com.google.common.collect.Maps;
import java.util.Map;
import java.util.UUID;
/**
* Player Wrapper for the Progressive kit system
*/
public class PlayerKit
{
private UUID _player;
private String _currentKit;
private Map<String, Integer> _kitLevels;
private Map<String, Integer> _kitXPs;
private Map<String, Integer> _kitUpgradeLevels;
private Map<String, Boolean> _kitDefaultTypes;
//We only want players to level up kits once per game
private boolean _hasLeveledUp;
public PlayerKit(UUID player)
{
_player = player;
_kitLevels = Maps.newHashMap();
_kitXPs = Maps.newHashMap();
_kitUpgradeLevels = Maps.newHashMap();
_kitDefaultTypes = Maps.newHashMap();
}
public String getCurrentKit()
{
return _currentKit;
}
public void setCurrentKit(String currentKit)
{
_currentKit = currentKit;
}
public int getLevel(String kit)
{
return _kitLevels.getOrDefault(kit, 1);
}
public int getXp(String kit)
{
return _kitXPs.getOrDefault(kit, 1);
}
public int getUpgradeLevel(String kit)
{
return _kitUpgradeLevels.getOrDefault(kit, 0);
}
public void setLevel(int level, String kit)
{
_kitLevels.put(kit, level);
}
public void setXp(int xp, String kit)
{
_kitXPs.put(kit, xp);
}
public void setUpgradeLevel(int upgradeLevel, String kit)
{
_kitUpgradeLevels.put(kit, upgradeLevel);
}
public boolean isDefault(String kit)
{
return _kitDefaultTypes.getOrDefault(kit, true);
}
public void setDefault(boolean value, String kit)
{
_kitDefaultTypes.put(kit, value);
}
public boolean hasLeveledUp()
{
return _hasLeveledUp;
}
public void levelUp()
{
this._hasLeveledUp = true;
}
public UUID getPlayer()
{
return _player;
}
public UUID getUuid()
{
return _player;
}
}

View File

@ -0,0 +1,40 @@
package mineplex.core.progression.data;
import com.google.common.collect.Maps;
import java.util.Map;
import java.util.UUID;
/**
* Manages all PlayerKit data in memory
*/
public class PlayerKitDataManager
{
private Map<UUID, PlayerKit> _dataMapAccountUUID;
public PlayerKitDataManager()
{
_dataMapAccountUUID = Maps.newConcurrentMap();
}
public PlayerKit get(UUID uuid)
{
return _dataMapAccountUUID.get(uuid);
}
public void add(PlayerKit playerKit)
{
_dataMapAccountUUID.put(playerKit.getUuid(), playerKit);
}
public void remove(PlayerKit kit)
{
_dataMapAccountUUID.remove(kit.getUuid());
}
public Map<UUID, PlayerKit> getAll()
{
return _dataMapAccountUUID;
}
}

View File

@ -0,0 +1,36 @@
package mineplex.core.progression.gui;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
/**
* An abstract class for managing buttons inside of menus
*/
public abstract class Button
{
private ItemStack _item;
public Button(ItemStack item)
{
this._item = item;
}
/**
* The method called when a players clicks the slot
*
* @param player The player who clicked
*/
public abstract void onClick(Player player);
public ItemStack getItemStack()
{
return _item;
}
public void setItemStack(ItemStack item)
{
this._item = item;
}
}

View File

@ -0,0 +1,191 @@
package mineplex.core.progression.gui;
import mineplex.core.progression.gui.buttons.misc.IconButton;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* A class to manage dynamic creation of GUI's
*/
public abstract class Menu
{
protected static final Button[] EMPTY = new Button[45];
protected static Map<UUID, Menu> MENUS = new HashMap<>();
private String _name;
protected Button[] _buttons;
public Menu(String name)
{
_name = name;
_buttons = EMPTY;
}
public static Menu get(UUID name)
{
return MENUS.get(name);
}
/**
* Create an icon (no click action)
*
* @param item The itemstack ti display
* @return The created button
*/
protected Button create(ItemStack item)
{
return new IconButton(item);
}
public String getName()
{
return ChatColor.translateAlternateColorCodes('&', _name);
}
/**
* Open and setup the inventory for the player to view
* Store a reference to it inside a map for retrieving later
*
* @param player The player who we wish to show the GUI to
*/
public void open(Player player)
{
setButtons(setUp());
if (MENUS.get(player.getUniqueId()) != null)
{
MENUS.remove(player.getUniqueId());
}
MENUS.put(player.getUniqueId(), this);
int size = (_buttons.length + 8) / 9 * 9;
Inventory inventory = Bukkit.createInventory(player, size, getName());
for (int i = 0; i < _buttons.length; i++)
{
if (_buttons[i] == null)
{
continue;
}
ItemStack item = _buttons[i].getItemStack();
inventory.setItem(i, item);
}
player.openInventory(inventory);
}
/**
* Set up the GUI with buttons
*
* @return The setup button array
*/
protected abstract Button[] setUp();
public Button[] getButtons()
{
return _buttons;
}
public void setButtons(Button[] buttons)
{
_buttons = buttons;
}
/**
* Retrieve the button based off the slot
*
* @param slot The slot in the inventory
* @return The button corresponding to that slot
*/
public Button getButton(int slot)
{
try
{
return _buttons[slot];
} catch (ArrayIndexOutOfBoundsException e)
{
//There isn't a button there, so no need to throw an error
//e.printStackTrace();
return null;
}
}
/**
* Replace a button, or create a new button dynamically
* Update the players GUI
*
* @param slot The slot to set the new button
* @param button The reference to the button
* @param player The player whose GUI we'll be updating
*/
public void setButton(int slot, Button button, Player player)
{
try
{
_buttons[slot] = button;
} catch (ArrayIndexOutOfBoundsException ignored)
{
ignored.printStackTrace();
}
update(player);
}
/**
* Refresh the players view, allows to change what the player sees, without opening and closing the GUI
*
* @param player The player whose view you wish to update
*/
public void update(Player player)
{
InventoryView view = player.getOpenInventory();
if (view == null)
{
return;
}
if (!view.getTitle().equalsIgnoreCase(getName()))
{
return;
}
Inventory inventory = view.getTopInventory();
for (int i = 0; i < _buttons.length; i++)
{
if (_buttons[i] == null)
{
continue;
}
ItemStack item = _buttons[i].getItemStack();
inventory.setItem(i, item);
}
}
public void setTitle(String title)
{
_name = title;
}
public void onClose(Player player)
{
MENUS.remove(player.getUniqueId());
}
public static Menu remove(UUID uniqueId)
{
return MENUS.remove(uniqueId);
}
}

View File

@ -0,0 +1,45 @@
package mineplex.core.progression.gui;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
/**
* Listener for the Menu system
*/
public class MenuListener implements Listener
{
@EventHandler
public void onClick(InventoryClickEvent event)
{
String name = event.getInventory().getName();
Player player = (Player) event.getWhoClicked();
Menu gui = Menu.get(player.getUniqueId());
if (gui == null)
{
return;
}
if (!gui.getName().equalsIgnoreCase(name))
{
return;
}
Button button = gui.getButton(event.getRawSlot());
event.setCancelled(true);
event.setResult(Event.Result.DENY);
if (button == null)
{
return;
}
button.onClick(player);
}
}

View File

@ -0,0 +1,50 @@
package mineplex.core.progression.gui.buttons;
import com.google.common.collect.Lists;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.progression.data.KitAbilityDetail;
import mineplex.core.progression.gui.buttons.misc.IconButton;
import org.bukkit.inventory.ItemStack;
import java.util.Arrays;
import java.util.List;
/**
* Representing this kits Abilities in a GUI
*/
public class KitAbilityButton extends IconButton
{
private ItemStack _item;
public KitAbilityButton(KitAbilityDetail detail)
{
super(null);
ItemBuilder builder = new ItemBuilder(detail.getIcon());
builder.setTitle(detail.getDisplayName());
List<String> lore = Lists.newArrayList(" ");
lore.addAll(Arrays.asList(detail.getDescription()));
lore.add(" ");
builder.setLore(lore.toArray(new String[lore.size()]));
_item = builder.build();
}
@Override
public ItemStack getItemStack()
{
return _item;
}
@Override
public void setItemStack(ItemStack item)
{
_item = item;
}
}

View File

@ -0,0 +1,27 @@
package mineplex.core.progression.gui.buttons;
import mineplex.core.progression.ProgressiveKit;
import mineplex.core.progression.gui.Button;
import org.bukkit.inventory.ItemStack;
/**
* Similar to KitMenu, this helps with organizing buttons related to kits
* Since they all share common features.
*/
public abstract class KitButton extends Button
{
private ProgressiveKit _kit;
public KitButton(ProgressiveKit kit, ItemStack itemStack)
{
super(itemStack);
_kit = kit;
}
protected ProgressiveKit getKit()
{
return _kit;
}
}

View File

@ -0,0 +1,75 @@
package mineplex.core.progression.gui.buttons;
import com.google.common.collect.Lists;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilInv;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.progression.ProgressiveKit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.List;
/**
* This is the display icon for the Kit inside of the main GUI
*/
public class KitIconButton extends KitButton
{
private ItemStack _itemStack;
public KitIconButton(ProgressiveKit kit, Player player)
{
super(kit, null);
ItemBuilder builder = new ItemBuilder(kit.getIcon());
builder.setTitle(C.cYellow + kit.getDisplayName());
List<String> lore = Lists.newArrayList(" ");
boolean foundPerkStart = false;
for (String s : kit.getDescription())
{
if (!foundPerkStart)
{
lore.add(ChatColor.GRAY + s);
if (s.equalsIgnoreCase(" ") || s.isEmpty() || s.equalsIgnoreCase(""))
{
foundPerkStart = true;
}
} else
{
lore.add(ChatColor.WHITE + s);
}
}
builder.setLore(lore.toArray(new String[lore.size()]));
if (kit.isSelected(player.getUniqueId()))
{
builder.addEnchantment(UtilInv.getDullEnchantment(), 1);
}
_itemStack = builder.build();
}
@Override
public ItemStack getItemStack()
{
return _itemStack;
}
@Override
public void setItemStack(ItemStack itemStack)
{
_itemStack = itemStack;
}
@Override
public void onClick(Player player)
{
getKit().onSelected(player.getUniqueId());
}
}

View File

@ -0,0 +1,47 @@
package mineplex.core.progression.gui.buttons;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.progression.ProgressiveKit;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
/**
* This manages toggling default selection of a kit
* I.E. Whether or not this kit will be always enabled without the user doing anything
*/
public class KitPermanentDefaultButton extends KitButton
{
private static final String[] DESCRIPTION = {
" ",
ChatColor.WHITE + "Selects this kit as your default kit",
ChatColor.WHITE + "until you decide to change it.",
" ",
ChatColor.WHITE + "Default kits will be auto-selected",
ChatColor.WHITE + "when you join a lobby.",
" "
};
private static final ItemStack ITEM = new ItemBuilder(Material.STAINED_GLASS_PANE)
.setData(DyeColor.LIGHT_BLUE.getWoolData())
.setTitle(ChatColor.YELLOW + "Default Kit")
.setLore(DESCRIPTION)
.build();
public KitPermanentDefaultButton(ProgressiveKit kit)
{
super(kit, ITEM);
}
@Override
public void onClick(Player player)
{
getKit().onSelected(player.getUniqueId());
getKit().onSetDefault(player.getUniqueId());
}
}

View File

@ -0,0 +1,38 @@
package mineplex.core.progression.gui.buttons;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilText;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.progression.ProgressiveKit;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
/**
* This manages selecting of the kit for the current game.
*/
public class KitSelectButton extends KitButton
{
private static final String[] LORE = {
" ",
ChatColor.WHITE + "Click to select this kit",
" "
};
public KitSelectButton(ProgressiveKit kit)
{
super(kit, new ItemBuilder(Material.STAINED_GLASS_PANE)
.setData(DyeColor.LIME.getWoolData())
.setTitle(ChatColor.YELLOW + kit.getDisplayName())
.setLore(UtilText.splitLinesToArray(LORE, LineFormat.LORE))
.build());
}
@Override
public void onClick(Player player)
{
getKit().onSelected(player.getUniqueId());
}
}

View File

@ -0,0 +1,50 @@
package mineplex.core.progression.gui.buttons;
import mineplex.core.common.util.F;
import mineplex.core.progression.ProgressiveKit;
import mineplex.core.progression.gui.Menu;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.UUID;
/**
* @author Timothy Andis (TadahTech) on 4/7/2016.
*/
public class KitUpgradeButton extends KitButton
{
private int _upgradeLevel;
private String _upggradeName;
public KitUpgradeButton(ProgressiveKit kit, ItemStack itemStack, int upgradeLevel, String upggradeName)
{
super(kit, itemStack);
_upgradeLevel = upgradeLevel;
_upggradeName = upggradeName;
}
@Override
public void onClick(Player player)
{
UUID uuid = player.getUniqueId();
if (!getKit().canPurchaseUpgrade(uuid, _upgradeLevel))
{
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 10.0F, 1.0F);
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 " + _upggradeName));
Menu.remove(uuid);
player.closeInventory();
}
}

View File

@ -0,0 +1,135 @@
package mineplex.core.progression.gui.buttons;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.progression.ProgressiveKit;
import mineplex.core.progression.gui.guis.KitInformationTrackerMenu;
import mineplex.core.progression.gui.guis.KitMenu;
import mineplex.core.progression.math.Calculations;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import static mineplex.core.common.util.UtilServer.getPlugin;
/**
* This is the button for upgrades. It'll flash when one is available
* Displays information regarding upgrades on hover
*/
public class KitUpgradeMenuButton extends KitButton
{
private static final ItemStack ITEM_STACK = new ItemBuilder(Material.ENCHANTMENT_TABLE)
.setTitle(C.cYellow + "Upgrade Level")
.setLore(" ", C.cRed + "Upgrades Coming Soon!")
.build();
private ItemStack _item;
private boolean _flash;
private BukkitTask _task;
public KitUpgradeMenuButton(ProgressiveKit kit, Player player)
{
super(kit, null);
_item = ITEM_STACK;
//The current upgrade level out of 5 for this kit
int upgradeLevel = kit.getUpgradeLevel(player.getUniqueId());
//The players level
int level = kit.getLevel(player.getUniqueId());
//What's the next UPGRADE LEVEL (1-5)
int nextUpgradeLevel = Calculations.getNextUpgradeLevel(level);
//The 1-100 Level
int nextUpgradeLevelPlayer = Calculations.getNextUpgradeLevelPlayer(level);
//The difference between the players current level, and the next upgrade level
int diff = nextUpgradeLevelPlayer - level;
//This ONLY flashes if their next upgrade level isn't their same one.
_flash = Calculations.isUpgradeLevelEligible(level) && (nextUpgradeLevel > upgradeLevel);
if (_flash)
{
flash();
}
ChatColor color = Calculations.getColor(level, nextUpgradeLevelPlayer);
}
@Override
public ItemStack getItemStack()
{
return _item;
}
@Override
public void setItemStack(ItemStack item)
{
_item = item;
}
private void flash()
{
this._task = new BukkitRunnable()
{
private ItemStack itemClone = ITEM_STACK.clone();
private ItemStack AIR = new ItemStack(Material.AIR);
private boolean resetItem = false;
@Override
public void run()
{
if (!_flash)
{
cancel();
return;
}
if (resetItem)
{
setItemStack(itemClone);
resetItem = false;
return;
}
setItemStack(AIR);
resetItem = true;
}
}.runTaskTimer(getPlugin(), 0L, 10L);
}
@Override
public void onClick(Player player)
{
this._flash = false;
if (_task != null)
{
this._task.cancel();
}
KitMenu menu = new KitInformationTrackerMenu(getKit());
menu.open(player);
}
/**
* Will be used later
*/
private ItemBuilder lore(ItemBuilder builder, int upgradeLevel, ChatColor color, int diff)
{
builder.setLore(" ",
ChatColor.WHITE + "Upgrade Level: " + ChatColor.GREEN + upgradeLevel + " out of 5",
ChatColor.WHITE + "Next Upgrade Unlocked in: " + color + diff + " level" + (diff == 1 ? "" : "s"),
"",
ChatColor.WHITE + "Click to view Upgrade and XP tracking");
return builder;
}
}

View File

@ -0,0 +1,95 @@
package mineplex.core.progression.gui.buttons;
import com.google.common.collect.Lists;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.progression.ProgressiveKit;
import mineplex.core.progression.gui.guis.KitInformationTrackerMenu;
import mineplex.core.progression.gui.guis.KitMenu;
import mineplex.core.progression.math.Calculations;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.List;
/**
* This the button which takes the player to {@link KitInformationTrackerMenu}
* Display's information regarding this kits level and experience
*/
public class KitXPButton extends KitButton
{
private ItemStack _item;
public KitXPButton(ProgressiveKit kit, Player player)
{
super(kit, null);
ItemBuilder builder = new ItemBuilder(Material.EXP_BOTTLE);
builder.setTitle(ChatColor.YELLOW + "XP and Level");
List<String> lore = Lists.newArrayList(" ");
StringBuilder levelStringBuilder = new StringBuilder();
StringBuilder xpStringBuilder = new StringBuilder();
int level = kit.getLevel(player.getUniqueId());
levelStringBuilder.append(level).append(" out of 100 ")
.append(ChatColor.GRAY).append("(")
.append(getColor(level, 100)).append(100 - level)
.append(ChatColor.GRAY).append(")");
int xp = kit.getXp(player.getUniqueId());
int nextXp = Calculations.getXpForNextLevel(kit.getLevel(player.getUniqueId()));
int diff = kit.getXpDifference(player.getUniqueId());
xpStringBuilder.append(xp).append(" out of ").append(nextXp)
.append(ChatColor.GRAY).append(" (")
.append(getColor(xp, nextXp)).append(diff)
.append(ChatColor.GRAY).append(")");
lore.add(addLoreLine("Level", levelStringBuilder.toString()));
lore.add(addLoreLine("XP", xpStringBuilder.toString()));
lore.add(" ");
lore.add(ChatColor.WHITE + "Click to view Upgrade and XP tracking");
builder.setLore(lore.toArray(new String[lore.size()]));
_item = builder.build();
}
private ChatColor getColor(int i, int n)
{
return Calculations.getColor(i, n);
}
private String addLoreLine(String key, Object value)
{
return ChatColor.WHITE + key + ": " + ChatColor.GREEN + value;
}
@Override
public ItemStack getItemStack()
{
return _item;
}
@Override
public void setItemStack(ItemStack item)
{
this._item = item;
}
@Override
public void onClick(Player player)
{
KitMenu menu = new KitInformationTrackerMenu(getKit());
menu.open(player);
}
}

View File

@ -0,0 +1,40 @@
package mineplex.core.progression.gui.buttons.misc;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.progression.gui.Button;
import mineplex.core.progression.gui.guis.KitMenu;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
/**
* This button take you back to the specified menu
*/
public class BackButton extends Button
{
private static ItemStack ITEM = new ItemBuilder(Material.BED)
.setTitle(ChatColor.GRAY + "\u21FD Go Back")
.build();
private KitMenu _toMenu;
public BackButton(KitMenu toMenu)
{
super(ITEM);
_toMenu = toMenu;
}
@Override
public void setItemStack(ItemStack itemStack)
{
//You can't remove this item
}
@Override
public void onClick(Player player)
{
_toMenu.open(player);
}
}

View File

@ -0,0 +1,23 @@
package mineplex.core.progression.gui.buttons.misc;
import mineplex.core.progression.gui.Button;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
/**
* A button designed for purely cosmetic reasons, but has no impact when clicked.
*/
public class IconButton extends Button
{
public IconButton(ItemStack item)
{
super(item);
}
@Override
public void onClick(Player player)
{
}
}

View File

@ -0,0 +1,109 @@
package mineplex.core.progression.gui.guis;
import mineplex.core.progression.ProgressiveKit;
import mineplex.core.progression.gui.Button;
import mineplex.core.progression.gui.buttons.*;
import mineplex.core.progression.gui.buttons.misc.IconButton;
import org.bukkit.entity.Player;
/**
* This is the main menu a player sees when we selects an NPC Kit
* Displays the most important information about this kit
*/
public class KitDisplayMenu extends KitMenu
{
private static final int[] UPGRADE_SLOTS = {
27, 29, 31, 33, 35
};
private static final int[] PERM_SLOTS = {
0, 1, 9, 10
};
private static final int[] SELECT_SLOTS = {
7, 8, 16, 17
};
public KitDisplayMenu(ProgressiveKit kit)
{
super(kit);
}
@Override
public Button[] setup(Player player)
{
Button[] buttons = new Button[51];
setUpSelecting(buttons);
setUpIcon(buttons, player);
setUpDetails(buttons);
setUpNextMenuButtons(buttons, player);
return buttons;
}
/**
* Set up the buttons corresponding to opening {@link KitInformationTrackerMenu}
*
* @param buttons The array of buttons we're modifying
* @param player The player whose data we'll be using
*/
private void setUpNextMenuButtons(Button[] buttons, Player player)
{
buttons[48] = new KitXPButton(getKit(), player);
buttons[50] = new KitUpgradeMenuButton(getKit(), player);
}
/**
* Set up the Kit display's icon
*
* @param buttons The array of buttons we're modifying
*/
private void setUpIcon(Button[] buttons, Player player)
{
buttons[13] = new KitIconButton(getKit(), player);
}
/**
* Set up the details (info) regarding the upgrades to this kit
* Lines commented out due to waiting to release upgrades
*
* @param buttons The array of buttons we're modifying
*/
private void setUpDetails(Button[] buttons)
{
for (int i : UPGRADE_SLOTS)
{
buttons[i] = new IconButton(COMING_SOON);
}
}
/**
* Set up the options for selecting this kit
* Either permanent or just for this game
*
* @param buttons The array of buttons we're modifying
*/
private void setUpSelecting(Button[] buttons)
{
for (int permSlot : PERM_SLOTS)
{
buttons[permSlot] = new KitPermanentDefaultButton(getKit());
}
for (int tempSlot : SELECT_SLOTS)
{
buttons[tempSlot] = new KitSelectButton(getKit());
}
}
@Override
public void onClose(Player player)
{
}
}

View File

@ -0,0 +1,298 @@
package mineplex.core.progression.gui.guis;
import com.google.common.collect.Lists;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.progression.ProgressiveKit;
import mineplex.core.progression.gui.Button;
import mineplex.core.progression.gui.buttons.misc.BackButton;
import mineplex.core.progression.gui.buttons.misc.IconButton;
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.UUID;
/**
* This is the secondary menu access by either the Enchantment table or XP Bottle
* Displays the more technical data of a kit for the player
*/
public class KitInformationTrackerMenu extends KitMenu
{
private final DyeColor[] COLORS = {
DyeColor.GRAY,
DyeColor.YELLOW,
DyeColor.ORANGE,
DyeColor.LIME,
DyeColor.BLACK
};
private final int[] XP_SLOTS = {
11, 12, 13, 14, 15
};
private final int[] LEVEL_SLOTS = {
29, 30, 31, 32, 33
};
private final int[] UPGRADE_SLOTS = {
47, 48, 49, 50, 51
};
public KitInformationTrackerMenu(ProgressiveKit kit)
{
super(kit);
}
@Override
public Button[] setup(Player player)
{
Button[] buttons = new Button[52];
buttons[0] = new BackButton(new KitDisplayMenu(getKit()));
setUpXP(buttons, player);
setUpLevel(buttons, player);
setUpUpgrade(buttons, player);
return buttons;
}
/**
* Set up the row of glass panes symbolizing the players XP advancement
*
* @param buttons The array of buttons we're modifying
* @param player The player whose data we'll be using
*/
private void setUpXP(Button[] buttons, Player player)
{
ProgressiveKit kit = getKit();
UUID uuid = player.getUniqueId();
int level = kit.getLevel(uuid);
int xp = kit.getXp(uuid);
int nextXp = Calculations.getXpForNextLevel(level);
float perc = (xp * 100.0f) / nextXp;
String[] lore = {
" ",
ChatColor.WHITE + "Current XP: " + Calculations.getColor(xp, nextXp) + xp +
ChatColor.GRAY + " (" + Calculations.getColor(xp, nextXp) + (int) perc + "%" + ChatColor.GRAY + ")",
xpLore(getKit(), player)
};
for (int i : XP_SLOTS)
{
buttons[i] = new IconButton(new ItemBuilder(Material.STAINED_GLASS_PANE)
.setData(DyeColor.BLACK.getWoolData())
.setAmount(1)
.setTitle(ChatColor.YELLOW + "Experience Progression")
.setLore(lore)
.build());
}
percentButtons(true, perc, XP_SLOTS, buttons, xp, nextXp, player);
}
/**
* Set up the row of glass panes symbolizing the players level advancement
*
* @param buttons The array of buttons we're modifying
* @param player The player whose data we'll be using
*/
private void setUpLevel(Button[] buttons, Player player)
{
ProgressiveKit kit = getKit();
UUID uuid = player.getUniqueId();
int level = kit.getLevel(uuid);
float perc = (level * 100.0f) / 100;
String[] lore = {
" ",
ChatColor.WHITE + "Current Level: " + Calculations.getColor(level, 100) + level +
ChatColor.GRAY + " (" + Calculations.getColor(level, 100) + level +
"/" + ChatColor.GREEN + 100 + ChatColor.GRAY + ")"
};
for (int i : LEVEL_SLOTS)
{
buttons[i] = new IconButton(new ItemBuilder(Material.STAINED_GLASS_PANE)
.setData(DyeColor.BLACK.getWoolData())
.setAmount(1)
.setTitle(ChatColor.YELLOW + "Level Progression")
.setLore(lore)
.build());
}
percentButtons(false, perc, LEVEL_SLOTS, buttons, level, 100, player);
}
/**
* Set up the row of Dyes / Music discs symbolizing the players upgrade advancement
*
* @param buttons The array of buttons we're modifying
* @param player The player whose data we'll be using
*/
private void setUpUpgrade(Button[] buttons, Player player)
{
for (int i : UPGRADE_SLOTS)
{
buttons[i] = new IconButton(COMING_SOON);
}
}
/* ======================================================================================================
*
*
* Below here are utility methods that speed up the process for me, and makes the code neater and easier
* to read.
*
* ====================================================================================================== */
@SuppressWarnings("Duplicates")
private int getLocked(int level)
{
switch (level)
{
case 1:
return 5;
case 2:
return 10;
case 3:
return 30;
case 4:
return 75;
case 5:
return 100;
}
if (level >= 5)
{
return 100;
}
return -1;
}
private void percentButtons(boolean xp, float perc, int[] array, Button[] buttons, int number, int total, Player player)
{
float checkAgainst = perc;
if (perc <= 20)
{
//One button
buttons[array[0]] = new IconButton(paneIcon(xp, number, total, perc, checkAgainst, player));
return;
}
if (perc <= 40)
{
buttons[array[0]] = new IconButton(paneIcon(xp, number, total, perc, checkAgainst, player));
checkAgainst -= 20;
buttons[array[1]] = new IconButton(paneIcon(xp, number, total, perc, checkAgainst, player));
return;
}
if (perc <= 60)
{
buttons[array[0]] = new IconButton(paneIcon(xp, number, total, perc, checkAgainst, player));
buttons[array[1]] = new IconButton(paneIcon(xp, number, total, perc, checkAgainst, player));
checkAgainst -= 40;
buttons[array[2]] = new IconButton(paneIcon(xp, number, total, perc, checkAgainst, player));
return;
}
if (perc <= 80)
{
buttons[array[0]] = new IconButton(paneIcon(xp, number, total, perc, checkAgainst, player));
buttons[array[1]] = new IconButton(paneIcon(xp, number, total, perc, checkAgainst, player));
buttons[array[2]] = new IconButton(paneIcon(xp, number, total, perc, checkAgainst, player));
checkAgainst -= 60;
buttons[array[3]] = new IconButton(paneIcon(xp, number, total, perc, checkAgainst, player));
return;
}
buttons[array[0]] = new IconButton(paneIcon(xp, number, total, perc, checkAgainst, player));
buttons[array[1]] = new IconButton(paneIcon(xp, number, total, perc, checkAgainst, player));
buttons[array[2]] = new IconButton(paneIcon(xp, number, total, perc, checkAgainst, player));
buttons[array[3]] = new IconButton(paneIcon(xp, number, total, perc, checkAgainst, player));
checkAgainst -= 80;
buttons[array[4]] = new IconButton(paneIcon(xp, number, total, perc, checkAgainst, player));
}
private ItemStack paneIcon(boolean xp, int number, int total, float perc, float checkAgainst, Player player)
{
String title = ChatColor.YELLOW + (xp ? "Experience Progression" : "Level Progression");
String current = ChatColor.WHITE + "Current " + (xp ? "XP" : "Level") + ": " + Calculations.getColor(number, total) + number;
String calculatedPerc = ChatColor.GRAY + " (" + Calculations.getColor(number, total) + (int) perc + "%" + ChatColor.GRAY + ")";
List<String> loreList = Lists.newArrayList(" ");
if (xp)
{
loreList.add(current + calculatedPerc);
loreList.add(xpLore(getKit(), player));
} else
{
loreList.add(current + ChatColor.GRAY + " (" + Calculations.getColor(number, total) + number +
"/" + ChatColor.GREEN + total + ChatColor.GRAY + ")");
}
return new ItemBuilder(Material.STAINED_GLASS_PANE)
.setData(perc >= 20 ? DyeColor.LIME.getWoolData() : getColor(checkAgainst))
.setTitle(title)
.setLore(loreList.toArray(new String[loreList.size()]))
.build();
}
private byte getColor(float perc)
{
if (perc <= 5)
{
return COLORS[0].getWoolData();
}
if (perc <= 10)
{
return COLORS[1].getWoolData();
}
if (perc <= 15)
{
return COLORS[2].getWoolData();
}
if (perc <= 20)
{
return COLORS[3].getWoolData();
}
return COLORS[4].getWoolData();
}
private String xpLore(ProgressiveKit kit, Player player)
{
StringBuilder xp = new StringBuilder(C.cWhite + "Progress: ");
int xpInt = kit.getXp(player.getUniqueId());
int xpNext = Calculations.getXpForNextLevel(kit.getLevel(player.getUniqueId()));
int diff = kit.getXpDifference(player.getUniqueId());
xp.append(Calculations.getColor(xpInt, xpNext)).append(xpInt)
.append(ChatColor.GRAY).append("/")
.append(ChatColor.GREEN).append(xpNext)
.append(ChatColor.GRAY).append(" (")
.append(Calculations.getColor(xpInt, xpNext)).append(diff)
.append(" needed")
.append(ChatColor.GRAY).append(")");
return xp.toString();
}
}

View File

@ -0,0 +1,101 @@
package mineplex.core.progression.gui.guis;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.progression.ProgressiveKit;
import mineplex.core.progression.gui.Button;
import mineplex.core.progression.gui.Menu;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
/**
* An implementation of {@link Menu} corresponding to kits
*/
public abstract class KitMenu extends Menu
{
/**
* Coming soon icon for upgrades
*/
protected static final ItemStack COMING_SOON = new ItemBuilder(Material.INK_SACK)
.setAmount(1)
.setData(DyeColor.GRAY.getDyeData())
.setTitle(ChatColor.RED + "Coming Soon")
.setLore(" ", ChatColor.GRAY + "Upgrades coming soon!")
.build();
private ProgressiveKit _kit;
public KitMenu(ProgressiveKit kit)
{
super(kit.getDisplayName());
_kit = kit;
}
/**
* Set up a menu based on the specific player
*
* @param player The player who we want to tailor the GUI to
* @return The setup arrangement of buttons
*/
public abstract Button[] setup(Player player);
/**
* Open a GUI tailored to the player
*
* @param player The player who we wish to show the GUI to
*/
@Override
public void open(Player player)
{
this.setButtons(setup(player));
if (MENUS.get(player.getUniqueId()) != null)
{
MENUS.remove(player.getUniqueId());
}
MENUS.put(player.getUniqueId(), this);
int size = (this._buttons.length + 8) / 9 * 9;
Inventory inventory = Bukkit.createInventory(player, size, getName());
for (int i = 0; i < _buttons.length; i++)
{
if (_buttons[i] == null)
{
continue;
}
ItemStack item = _buttons[i].getItemStack();
inventory.setItem(i, item);
}
player.openInventory(inventory);
}
/**
* Get the kit specific to this GUI
*
* @return This GUI's kit
*/
public ProgressiveKit getKit()
{
return _kit;
}
/**
* We don't want to use this, as we may require per player GUI's
* @return The arrangement of buttons
*/
@Override
public Button[] setUp()
{
return new Button[45];
}
}

View File

@ -0,0 +1,208 @@
package mineplex.core.progression.math;
import com.google.common.collect.Maps;
import net.md_5.bungee.api.ChatColor;
import java.util.Map;
/**
* This class handles all the math and static fields needed for Kit Progressions
* You can find some util methods in here as well that relate to numbers
*/
public class Calculations
{
private static final int[] LEVELS = new int[100];
private static final int[] UPGRADE_LEVELS = {5, 10, 30, 75, 100};
private static final Map<Integer, Integer> GEMS_FOR_UPGRADE = Maps.newHashMap();
static
{
generateDefaultExperienceLevels();
for (int level : UPGRADE_LEVELS)
{
GEMS_FOR_UPGRADE.put(level, level * 1000);
}
}
/**
* Generate the default XP values for leveling up.
*/
private static void generateDefaultExperienceLevels()
{
int expReq = 0;
for (int i = 0; i < 10; i++)
{
expReq += 50;
LEVELS[i] = expReq;
}
for (int i = 10; i < 20; i++)
{
expReq += 100;
LEVELS[i] = expReq;
}
for (int i = 20; i < 40; i++)
{
expReq += 200;
LEVELS[i] = expReq;
}
for (int i = 40; i < 60; i++)
{
expReq += 300;
LEVELS[i] = expReq;
}
for (int i = 60; i < 80; i++)
{
expReq += 400;
LEVELS[i] = expReq;
}
for (int i = 80; i < LEVELS.length; i++)
{
expReq += 500;
LEVELS[i] = expReq;
}
}
/**
* Determines if the players current level is a level at which an upgrade is unlocked
*
* @param currentLevel The players level
* @return Whether or not the players level is within the {@code GEMS_FOR_UPGRADE} map
*/
public static boolean isUpgradeLevelEligible(int currentLevel)
{
return GEMS_FOR_UPGRADE.containsKey(currentLevel);
}
/**
* Determines if the players current level, and his gems, are what he needs to level up this upgrade
*
* @param currentLevel The players level
* @param gems The players current gems
* @return Whether or not the player can upgrade
*/
public static boolean canUpgrade(int currentLevel, int gems)
{
return GEMS_FOR_UPGRADE.containsKey(currentLevel) && GEMS_FOR_UPGRADE.get(currentLevel) <= gems;
}
/**
* Get the XP required for the next level
*
* @param currLevel The players current level
* @return The XP for the next level
*/
public static int getXpForNextLevel(int currLevel)
{
if (currLevel >= 100)
{
return LEVELS[LEVELS.length - 1];
}
//lets get this calculation right....
return LEVELS[currLevel - 1];
}
/**
* Get the difference between the players current level, and the next level he needs for upgrades
*
* @param currentLevel The players level
* @return The integer difference
*/
public static int getUpgradeLevelDifference(int currentLevel)
{
for (int i = 0; i < UPGRADE_LEVELS.length; i++) {
if (UPGRADE_LEVELS[i] > currentLevel) {
return UPGRADE_LEVELS[i] - currentLevel;
}
}
return 0;
}
/**
* Utility method for percentage based chat colors
*
* @param i The initial number
* @param n The total number
* @return The chat color corresponding to the percentage
*/
public static ChatColor getColor(int i, int n)
{
ChatColor color = ChatColor.GREEN;
float perc = (i * 100.0f) / n;
if (perc <= 25)
{
return ChatColor.GRAY;
}
if (perc <= 50)
{
return ChatColor.YELLOW;
}
if (perc <= 75)
{
return ChatColor.GOLD;
}
return color;
}
/**
* Get the next integer upgrade level based of the players current leve;
*
* @param currentLevel The players current level
* @return The next upgrade level
*/
public static int getNextUpgradeLevel(int currentLevel)
{
for (int i = 0; i < UPGRADE_LEVELS.length; i++) {
if (UPGRADE_LEVELS[i] <= currentLevel) {
return UPGRADE_LEVELS[i];
}
}
return 5;
}
/**
* Get the next level the player needs to reach to unlock an upgrade
*
* @param currentLevel The players current level
* @return The next level the player needs to reach to unlock an upgrade
*/
public static int getNextUpgradeLevelPlayer(int currentLevel)
{
for (int i = 0; i < UPGRADE_LEVELS.length; i++) {
if (UPGRADE_LEVELS[i] >= currentLevel) {
return UPGRADE_LEVELS[i];
}
}
return 100;
}
@SuppressWarnings("Duplicates")
public static int getLevelRequiredFor(int upgradeLevel)
{
switch (upgradeLevel)
{
case 1:
return 5;
case 2:
return 10;
case 3:
return 30;
case 4:
return 75;
case 5:
return 100;
}
return -1;
}
}

View File

@ -0,0 +1,75 @@
package mineplex.core.progression.util;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* Create and manager a prepared statement for inserting into SQL
*/
public class SQLStatement
{
/**
* The initial string literal statement
*/
private String _base;
/**
* The _map for inserting objects into a prepared statement
*/
private Map<Integer, Object> _map;
/**
* Create a new instance of an SQLStatement
*
* @param base The literal string MySQL query ('?' are allowed)
*/
public SQLStatement(String base)
{
this._base = base;
this._map = new HashMap<>();
}
/**
* Set an object to a value for inserting upon completion
*
* @param i The position of the object
* @param object The object to insert into the statement for the given position
* @return The local instance with an updated map
*/
public SQLStatement set(int i, Object object)
{
this._map.put(i, object);
return this;
}
/**
* Prepare a fully built statement for running
*
* @param connection The connection used to establish the statement
* @return The fully built PreparedStatement
* @throws SQLException
*/
public PreparedStatement prepare(Connection connection) throws SQLException
{
PreparedStatement statement = connection.prepareStatement(_base);
for (Map.Entry<Integer, Object> entry : _map.entrySet())
{
int slot = entry.getKey();
Object object = entry.getValue();
if (object instanceof UUID)
{
statement.setObject(slot, object.toString());
continue;
}
statement.setObject(slot, object);
}
return statement;
}
}

View File

@ -85,15 +85,6 @@ public class ClanEnergyManager extends MiniPlugin implements Runnable
return _clansManager;
}
@EventHandler
public void command(PlayerCommandPreprocessEvent event)
{
if (event.getMessage().startsWith("/energyshop"))
{
openShop(event.getPlayer());
}
}
public int convertEnergyToGold(int energy)
{
return (energy / 8) + (energy % 8 == 0 ? 0 : 1);

View File

@ -304,10 +304,11 @@ public class ClansGame extends MiniPlugin
return;
}
// Banners/String
// Banners/String/Heads
if (player.getGameMode() != GameMode.CREATIVE && player.getItemInHand() != null)
{
if (player.getItemInHand().getType() == Material.BANNER || player.getItemInHand().getType() == Material.STRING)
if (player.getItemInHand().getType() == Material.BANNER || player.getItemInHand().getType() == Material.STRING
|| player.getItemInHand().getType() == Material.SKULL_ITEM)
{
Location destLocation = event.getClickedBlock().getRelative(event.getBlockFace()).getLocation();
ClanTerritory territory = _clans.getClanUtility().getClaim(destLocation);

View File

@ -71,6 +71,7 @@ import mineplex.game.clans.core.repository.tokens.ClanToken;
import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.fields.Field;
import mineplex.game.clans.gameplay.Gameplay;
import mineplex.game.clans.gameplay.HiddenChestManager;
import mineplex.game.clans.gameplay.safelog.SafeLog;
import mineplex.game.clans.gameplay.safelog.npc.NPCManager;
import mineplex.game.clans.items.GearManager;
@ -241,6 +242,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
_condition = new SkillConditionManager(plugin);
_damageManager = new DamageManager(plugin, _combatManager, _npcManager, _disguiseManager, _condition);
_damageManager.addCommand(new KillCommand(_damageManager));
_condition.setDamageManager(_damageManager);
_worldEvent = new WorldEventManager(plugin, this, _damageManager, _lootManager, blockRestore, _clanRegions, null);
@ -290,6 +292,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
new Weapon(plugin, energy);
new Gameplay(plugin, this, blockRestore, _damageManager);
new HiddenChestManager(this, packetHandler);
_projectileManager = new ProjectileManager(plugin);
Fire fire = new Fire(plugin, _condition, _damageManager);
@ -619,7 +622,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
continue;
}
other.sendMessage(F.sys("Quit ", event.getPlayer().getName()));
other.sendMessage(F.sys("Quit", event.getPlayer().getName()));
}
}

View File

@ -1,30 +1,26 @@
package mineplex.game.clans.clans.map;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.PrintWriter;
import java.io.*;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.*;
import java.util.Map.Entry;
import mineplex.core.common.util.*;
import mineplex.game.clans.tutorial.TutorialManager;
import mineplex.game.clans.tutorial.map.TutorialMapManager;
import net.minecraft.server.v1_8_R3.*;
import org.apache.commons.io.FileUtils;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftChunk;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.util.LongHash;
import org.bukkit.craftbukkit.v1_8_R3.util.LongObjectHashMap;
import org.bukkit.entity.ItemFrame;
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.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
@ -35,6 +31,8 @@ import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.map.MapRenderer;
@ -46,13 +44,6 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.Multisets;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.portal.ServerTransferEvent;
@ -62,27 +53,77 @@ import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClansUtility;
import mineplex.game.clans.clans.map.events.PlayerGetMapEvent;
import mineplex.game.clans.clans.worldevent.WorldEventManager;
import net.minecraft.server.v1_8_R3.Block;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.Blocks;
import net.minecraft.server.v1_8_R3.IBlockData;
import net.minecraft.server.v1_8_R3.MaterialMapColor;
import net.minecraft.server.v1_8_R3.PersistentCollection;
/*
* This class manages what the Clans map will show.
* It will scan all relevant chunks (eg players nearby) every <x> ticks
*/
public class ItemMapManager extends MiniPlugin
{
private int _blocksScan = 16 * 3;
// Every BLOCK_SCAN_INTERVAL we add as a new region to scan
private static final int BLOCK_SCAN_INTERVAL = 16 * 3;
// 1536 is the width of the entire world from one borderland to the other
private static final int HALF_WORLD_SIZE = 1536 / 2;
// This slot is where the Clans Map will go by default
private static final int CLANS_MAP_SLOT = 8;
private static final String[] ZOOM_INFO;
static
{
ZOOM_INFO = new String[4];
for (int zoomLevel = 0; zoomLevel <= 3; zoomLevel++)
{
StringBuilder progressBar = new StringBuilder(C.cBlue);
boolean colorChange = false;
for (int i = 2; i >= 0; i--)
{
if (!colorChange && i < zoomLevel)
{
progressBar.append(C.cGray);
colorChange = true;
}
char c;
switch (i)
{
case 0:
c = '█';
break;
case 1:
c = '▆';
break;
default:
c = '▄';
break;
}
for (int a = 0; a < 4; a++)
{
progressBar.append(c);
}
if (i > 0)
{
progressBar.append(" ");
}
}
ZOOM_INFO[zoomLevel] = progressBar.toString();
}
}
private ClansUtility _clansUtility;
private Comparator<Entry<Integer, Integer>> _comparator;
private int _halfMapSize = 1536 / 2;
private int[][] _heightMap = new int[(_halfMapSize * 2) + 16][];
private boolean _loadWorld = true;
private int[][] _heightMap = new int[(HALF_WORLD_SIZE * 2) + 16][];
private HashMap<Integer, Byte[][]> _map = new HashMap<Integer, Byte[][]>();
private short _mapId = -1;
private HashMap<String, MapInfo> _mapInfo = new HashMap<String, MapInfo>();
private HashMap<Integer, Integer> _scale = new HashMap<Integer, Integer>();
private ArrayList<Entry<Integer, Integer>> _scanList = new ArrayList<Entry<Integer, Integer>>();
// Use LinkedList because operations are either add(Entry) which is O(1) and remove(0) which is O(1) on LinkedList but O(n) on ArrayList
private LinkedList<Entry<Integer, Integer>> _scanList = new LinkedList<Entry<Integer, Integer>>();
private World _world;
private WorldServer _nmsWorld;
private ChunkProviderServer _chunkProviderServer;
private ChunkRegionLoader _chunkRegionLoader;
private WorldEventManager _eventManager;
private TutorialManager _tutorial;
@ -94,14 +135,10 @@ public class ItemMapManager extends MiniPlugin
_eventManager = eventManager;
_tutorial = tutorial;
_comparator = new Comparator<Entry<Integer, Integer>>()
{
@Override
public int compare(Entry<Integer, Integer> o1, Entry<Integer, Integer> o2)
_comparator = (o1, o2) ->
{
// Render the places outside the map first to speed up visual errors fixing
int outsideMap = Boolean.compare(o1.getValue() < -_halfMapSize, o2.getValue() < -_halfMapSize);
int outsideMap = Boolean.compare(o1.getValue() < -HALF_WORLD_SIZE, o2.getValue() < -HALF_WORLD_SIZE);
if (outsideMap != 0)
{
@ -127,17 +164,8 @@ public class ItemMapManager extends MiniPlugin
return Double.compare(dist1, dist2);
}
};
for (int x = -_halfMapSize; x < _halfMapSize; x += _blocksScan)
{
for (int z = -_halfMapSize - 16; z < _halfMapSize; z += (z < -_halfMapSize ? 16 : _blocksScan))
{
_scanList.add(new HashMap.SimpleEntry(x, z));
}
}
_scale.put(0, 1);
// _scale.put(1, 2);
_scale.put(1, 4);
@ -147,7 +175,7 @@ public class ItemMapManager extends MiniPlugin
for (Entry<Integer, Integer> entry : _scale.entrySet())
{
int size = (_halfMapSize * 2) / entry.getValue();
int size = (HALF_WORLD_SIZE * 2) / entry.getValue();
Byte[][] bytes = new Byte[size][];
for (int i = 0; i < size; i++)
@ -165,6 +193,23 @@ public class ItemMapManager extends MiniPlugin
_world = Bukkit.getWorld("world");
try
{
Field chunkLoader = ChunkProviderServer.class.getDeclaredField("chunkLoader");
chunkLoader.setAccessible(true);
_nmsWorld = ((CraftWorld) _world).getHandle();
_chunkProviderServer = _nmsWorld.chunkProviderServer;
_chunkRegionLoader = (ChunkRegionLoader) chunkLoader.get(_chunkProviderServer);
if (_chunkRegionLoader == null)
{
throw new RuntimeException("Did not expect null chunkLoader");
}
}
catch (ReflectiveOperationException e)
{
throw new RuntimeException("Could not reflectively access ChunkRegionLoader", e);
}
try
{
File file = new File("world/clans_map_id");
@ -238,6 +283,58 @@ public class ItemMapManager extends MiniPlugin
}
rebuildScan();
initialScan();
}
private void initialScan()
{
System.out.println("Beginning initial scan. There are " + _scanList.size() + " regions to scan");
// How many regions before logging an update (Currently set to every 20%)
int logPer = _scanList.size() / 5;
while (!_scanList.isEmpty())
{
Entry<Integer, Integer> entry = _scanList.remove(0);
if (_scanList.size() % logPer == 0)
{
System.out.println("Running initial render... " + _scanList.size() + " sections to go");
}
int startingX = entry.getKey();
int startingZ = entry.getValue();
boolean outsideMap = startingZ < -HALF_WORLD_SIZE;
scanWorldMap(startingX, startingZ, !outsideMap, true);
if (outsideMap)
{
continue;
}
for (int scale = 1; scale < _scale.size(); scale++)
{
if (scale == 3)
continue;
drawWorldScale(scale, startingX, startingZ);
colorWorldHeight(scale, startingX, startingZ);
}
colorWorldHeight(0, startingX, startingZ);
}
for (int x = -HALF_WORLD_SIZE; x < HALF_WORLD_SIZE; x += BLOCK_SCAN_INTERVAL)
{
for (int z = -HALF_WORLD_SIZE; z < HALF_WORLD_SIZE; z += BLOCK_SCAN_INTERVAL)
{
drawWorldScale(3, x, z);
colorWorldHeight(3, x, z);
}
}
System.out.println("Finished first map scan and render");
}
private void setupRenderer(MapView view)
@ -256,10 +353,7 @@ public class ItemMapManager extends MiniPlugin
if (!(event.getRightClicked() instanceof ItemFrame))
return;
ItemStack item = event.getPlayer().getItemInHand();
if (item == null || item.getType() != Material.MAP || item.getDurability() < _mapId
|| item.getDurability() > _mapId + 100)
if (!isItemClansMap(event.getPlayer().getItemInHand()))
return;
event.setCancelled(true);
@ -270,7 +364,7 @@ public class ItemMapManager extends MiniPlugin
*/
public int calcMapCenter(int zoom, int cord)
{
int mapSize = _halfMapSize / zoom; // This is how large the map is in pixels
int mapSize = HALF_WORLD_SIZE / zoom; // This is how large the map is in pixels
int mapCord = cord / zoom; // This is pixels from true center of map, not held map
@ -309,7 +403,7 @@ public class ItemMapManager extends MiniPlugin
Byte[][] map = _map.get(scale);
int zoom = getZoom(scale);
for (int x = startingX; x < startingX + _blocksScan; x += zoom)
for (int x = startingX; x < startingX + BLOCK_SCAN_INTERVAL; x += zoom)
{
double d0 = 0;
@ -319,10 +413,10 @@ public class ItemMapManager extends MiniPlugin
{
for (int addZ = 0; addZ < zoom; addZ++)
{
int hX = x + addX + _halfMapSize;
int hZ = (startingZ - zoom) + addZ + _halfMapSize;
int hX = x + addX + HALF_WORLD_SIZE;
int hZ = (startingZ - zoom) + addZ + HALF_WORLD_SIZE;
if (hX >= _halfMapSize * 2 || hZ >= _halfMapSize * 2)
if (hX >= HALF_WORLD_SIZE * 2 || hZ >= HALF_WORLD_SIZE * 2)
{
continue;
}
@ -331,7 +425,7 @@ public class ItemMapManager extends MiniPlugin
}
}
for (int z = startingZ; z < startingZ + _blocksScan; z += zoom)
for (int z = startingZ; z < startingZ + BLOCK_SCAN_INTERVAL; z += zoom)
{
// Water depth colors not included
double d1 = 0;
@ -340,10 +434,10 @@ public class ItemMapManager extends MiniPlugin
{
for (int addZ = 0; addZ < zoom; addZ++)
{
int hX = x + addX + _halfMapSize;
int hZ = z + addZ + _halfMapSize;
int hX = x + addX + HALF_WORLD_SIZE;
int hZ = z + addZ + HALF_WORLD_SIZE;
if (hX >= _halfMapSize * 2 || hZ >= _halfMapSize * 2)
if (hX >= HALF_WORLD_SIZE * 2 || hZ >= HALF_WORLD_SIZE * 2)
{
continue;
}
@ -370,7 +464,7 @@ public class ItemMapManager extends MiniPlugin
b0 = 0;
}
int origColor = map[(x + _halfMapSize) / zoom][(z + _halfMapSize) / zoom] - 1;
int origColor = map[(x + HALF_WORLD_SIZE) / zoom][(z + HALF_WORLD_SIZE) / zoom] - 1;
/*if (color < 4)
{
@ -388,7 +482,15 @@ public class ItemMapManager extends MiniPlugin
}*/
byte color = (byte) (origColor + b0);
map[(x + _halfMapSize) / zoom][(z + _halfMapSize) / zoom] = color;
if((color <= -113 || color >= 0) && color <= 127)
{
map[(x + HALF_WORLD_SIZE) / zoom][(z + HALF_WORLD_SIZE) / zoom] = color;
}
else
{
// System.out.println(String.format("Tried to set color to %s in colorWorldHeight scale: %s, sx: %s, sz: %s, x: %s, z: %s, zoom: %s",
// color, scale, startingX, startingZ, x, z, zoom));
}
}
}
}
@ -399,9 +501,9 @@ public class ItemMapManager extends MiniPlugin
Byte[][] second = _map.get(scale);
int zoom = getZoom(scale);
for (int x = startingX; x < startingX + _blocksScan; x += zoom)
for (int x = startingX; x < startingX + BLOCK_SCAN_INTERVAL; x += zoom)
{
for (int z = startingZ; z < startingZ + _blocksScan; z += zoom)
for (int z = startingZ; z < startingZ + BLOCK_SCAN_INTERVAL; z += zoom)
{
HashMultiset<Byte> hashmultiset = HashMultiset.create();
@ -409,8 +511,8 @@ public class ItemMapManager extends MiniPlugin
{
for (int addZ = 0; addZ < zoom; addZ++)
{
int pX = x + addX + _halfMapSize;
int pZ = z + addZ + _halfMapSize;
int pX = x + addX + HALF_WORLD_SIZE;
int pZ = z + addZ + HALF_WORLD_SIZE;
if (pX >= first.length || pZ >= first.length)
{
@ -432,7 +534,7 @@ public class ItemMapManager extends MiniPlugin
{
color = (byte) 0;
}
second[(x + _halfMapSize) / zoom][(z + _halfMapSize) / zoom] = color;
second[(x + HALF_WORLD_SIZE) / zoom][(z + HALF_WORLD_SIZE) / zoom] = color;
}
}
}
@ -440,27 +542,18 @@ public class ItemMapManager extends MiniPlugin
@EventHandler
public void dropItem(ItemSpawnEvent event)
{
ItemStack item = event.getEntity().getItemStack();
if (item != null && item.getType() == Material.MAP && item.getDurability() >= _mapId
&& item.getDurability() <= _mapId + 100)
{
if (isItemClansMap(event.getEntity().getItemStack()))
event.getEntity().remove();
}
}
public void removeMap(Player player)
{
for (int slot = 0; slot < player.getInventory().getSize(); slot++)
{
ItemStack item = player.getInventory().getItem(slot);
if (item != null && item.getType() == Material.MAP && item.getDurability() >= _mapId && item.getDurability() <= _mapId + 100)
{
if (isItemClansMap(player.getInventory().getItem(slot)))
player.getInventory().setItem(slot, null);
}
}
}
public ClansUtility getClansUtility()
{
@ -477,7 +570,7 @@ public class ItemMapManager extends MiniPlugin
private double getDistance(Entry<Integer, Integer> entry, double x1, double z1)
{
return getDistance(x1, z1, entry.getKey() + (_blocksScan / 2), entry.getValue() + (_blocksScan / 2));
return getDistance(x1, z1, entry.getKey() + (BLOCK_SCAN_INTERVAL / 2), entry.getValue() + (BLOCK_SCAN_INTERVAL / 2));
}
public Byte[][] getMap(int scale)
@ -492,7 +585,7 @@ public class ItemMapManager extends MiniPlugin
public int getMapSize()
{
return _halfMapSize;
return HALF_WORLD_SIZE;
}
public int getZoom(int scale)
@ -500,35 +593,7 @@ public class ItemMapManager extends MiniPlugin
return _scale.get(scale);
}
@EventHandler
public void preventMapMoveInventories(InventoryClickEvent event)
{
Inventory inv = event.getClickedInventory();
if (inv == null)
return;
// Yeah, the loop looks a little weird..
for (ItemStack item : new ItemStack[]
{
event.getCurrentItem(), event.getCursor()
})
{
if (item == null || item.getType() != Material.MAP || item.getDurability() < _mapId
|| item.getDurability() > _mapId + 100)
continue;
if (inv.getHolder() instanceof Player ? !event.isShiftClick() : Objects.equal(event.getCurrentItem(), item))
continue;
event.setCancelled(true);
UtilPlayer.message(event.getWhoClicked(),
F.main("Inventory", "You cannot move " + F.item("Clans Map") + " between inventories."));
return;
}
}
//fixme So what appears to happen is that after you die, if your map is is the same then the map is frozen
@EventHandler
public void onDeath(PlayerDeathEvent event)
{
@ -542,14 +607,10 @@ public class ItemMapManager extends MiniPlugin
{
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItem(event.getNewSlot());
if (item == null || item.getType() != Material.MAP || item.getDurability() < _mapId
|| item.getDurability() > _mapId + 100)
if (!isItemClansMap(player.getInventory().getItem(event.getNewSlot())))
return;
showZoom(player, getMap(player));
}
@EventHandler
@ -558,10 +619,7 @@ public class ItemMapManager extends MiniPlugin
if (event.getAction() == Action.PHYSICAL)
return;
ItemStack item = event.getItem();
if (item == null || item.getType() != Material.MAP || item.getDurability() < _mapId
|| item.getDurability() > _mapId + 100)
if (!isItemClansMap(event.getItem()))
return;
event.setCancelled(true);
@ -666,36 +724,11 @@ public class ItemMapManager extends MiniPlugin
private void rebuildScan()
{
for (int x = -_halfMapSize; x < _halfMapSize; x += _blocksScan)
for (int x = -HALF_WORLD_SIZE; x < HALF_WORLD_SIZE; x += BLOCK_SCAN_INTERVAL)
{
for (int z = -_halfMapSize - 16; z < _halfMapSize; z += (z < -_halfMapSize ? 16 : _blocksScan))
for (int z = -HALF_WORLD_SIZE - 16; z < HALF_WORLD_SIZE; z += (z < -HALF_WORLD_SIZE ? 16 : BLOCK_SCAN_INTERVAL))
{
_scanList.add(new HashMap.SimpleEntry(x, z));
}
}
if (!_loadWorld)
{
Iterator<Entry<Integer, Integer>> itel = _scanList.iterator();
while (itel.hasNext())
{
Entry<Integer, Integer> entry = itel.next();
boolean removeEntry = true;
for (Player player : UtilServer.getPlayers())
{
if (Math.sqrt(getDistance(entry, player.getLocation().getX(), player.getLocation().getZ())) < 200)
{
removeEntry = false;
break;
}
}
if (removeEntry)
{
itel.remove();
}
_scanList.add(new HashMap.SimpleEntry<>(x, z));
}
}
@ -744,101 +777,117 @@ public class ItemMapManager extends MiniPlugin
if (event.getType() != UpdateType.FAST)
return;
if (_scanList.isEmpty())
if (_scanList.isEmpty() && UtilServer.getPlayers().length > 0)
{
if (_loadWorld)
{
for (int x = -_halfMapSize; x < _halfMapSize; x += _blocksScan)
{
for (int z = -_halfMapSize; z < _halfMapSize; z += _blocksScan)
{
drawWorldScale(3, x, z);
colorWorldHeight(3, x, z);
}
}
System.out.print("Finished first map scan and render");
}
_loadWorld = false;
if (UtilServer.getPlayers().length == 0)
return;
rebuildScan();
}
else if (_scanList.size() % 20 == 0)
if (_scanList.size() % 20 == 0)
{
Collections.sort(_scanList, _comparator);
}
if (_scanList.isEmpty())
{
return;
}
Entry<Integer, Integer> entry = _scanList.remove(0);
int startingX = entry.getKey();
int startingZ = entry.getValue();
boolean outsideMap = startingZ < -_halfMapSize;
boolean outsideMap = startingZ < -HALF_WORLD_SIZE;
scanWorldMap(startingX, startingZ, !outsideMap);
scanWorldMap(startingX, startingZ, !outsideMap, false);
if (outsideMap)
{
return;
}
for (int scale = 1; scale < _scale.size(); scale++)
{
if (scale == 3 && _loadWorld)
continue;
if (!outsideMap)
{
drawWorldScale(scale, startingX, startingZ);
}
colorWorldHeight(scale, startingX, startingZ);
}
colorWorldHeight(0, startingX, startingZ);
}
public void scanWorldMap(int startingX, int startingZ, boolean setColors)
// Let's not create hundreds of thousands of BlockPositions
// Single thread = should be thread safe
private BlockPosition.MutableBlockPosition _blockPosition = new BlockPosition.MutableBlockPosition();
// Maps the cached chunks which were loaded from disk to save IO operations
private LongObjectHashMap<Chunk> _chunkCache = new LongObjectHashMap<>();
/*
* Remove the cached chunks when the real chunks are loaded in
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void LoadChunk(ChunkLoadEvent event)
{
_chunkCache.remove(LongHash.toLong(event.getChunk().getX(), event.getChunk().getZ()));
}
/*
* Given a particular coordinate, this method will scan up to BLOCK_SCAN_INTERVAL and record the color of ever 16th block
* If a chunk has not been loaded, the following steps will be taken:
* * Attempt to load the chunk from disk.
* * If the chunk could not be loaded, generate it froms scratch
* Otherwise, the loaded chunk will be used
*/
public void scanWorldMap(int startingX, int startingZ, boolean setColors, boolean isFirstScan)
{
Byte[][] map = _map.get(0);
for (int beginX = startingX; beginX < startingX + _blocksScan; beginX += 16)
for (int beginX = startingX; beginX < startingX + BLOCK_SCAN_INTERVAL; beginX += 16)
{
for (int beginZ = startingZ - (startingZ > -_halfMapSize ? 16 : 0); beginZ < startingZ
+ (setColors ? _blocksScan : 16); beginZ += 16)
for (int beginZ = startingZ - (startingZ > -HALF_WORLD_SIZE ? 16 : 0); beginZ < startingZ
+ (setColors ? BLOCK_SCAN_INTERVAL : 16); beginZ += 16)
{
Chunk chunk = _world.getChunkAt(beginX / 16, beginZ / 16);
boolean loaded = false;
if (!chunk.isLoaded())
int chunkX = beginX / 16;
int chunkZ = beginZ / 16;
net.minecraft.server.v1_8_R3.Chunk nmsChunk = _chunkProviderServer.getChunkIfLoaded(chunkX, chunkZ);
if (nmsChunk == null)
{
if (_loadWorld)
long key = LongHash.toLong(chunkX, chunkZ);
nmsChunk = _chunkCache.get(key);
if (nmsChunk == null)
{
loaded = chunk.load();
}
else
if (!isFirstScan)
{
continue;
}
try
{
Object[] data = _chunkRegionLoader.loadChunk(_nmsWorld, chunkX, chunkZ);
if (data == null)
{
// Something is wrong with the chunk
System.out.println("Chunk is not generated or missing level/block data. Regenerating (" + chunkX + "," + chunkZ + ")");
nmsChunk = ((CraftChunk) _world.getChunkAt(chunkX, chunkZ)).getHandle();
}
else
{
nmsChunk = (net.minecraft.server.v1_8_R3.Chunk) data[0];
}
}
catch (IOException e)
{
throw new RuntimeException("Chunk is corrupt or not readable!", e);
}
_chunkCache.put(key, nmsChunk);
}
}
net.minecraft.server.v1_8_R3.Chunk nmsChunk = ((CraftChunk) chunk).getHandle();
if (!nmsChunk.isEmpty())
{
for (int x = beginX; x < beginX + 16; x++)
{
for (int z = beginZ; z < beginZ + 16; z++)
{
int color = 0;
if (!nmsChunk.isEmpty())
{
int k3 = x & 0xF;
int l3 = z & 0xF;
@ -850,7 +899,8 @@ public class ItemMapManager extends MiniPlugin
do
{
l4--;
iblockdata= nmsChunk.getBlockData(new BlockPosition(k3, l4, l3));
_blockPosition.c(k3, l4, l3);
iblockdata = nmsChunk.getBlockData(_blockPosition);
}
while (iblockdata.getBlock().g(iblockdata) == MaterialMapColor.b && (l4 > 0));
@ -860,33 +910,30 @@ public class ItemMapManager extends MiniPlugin
Block block1;
do
{
block1 = nmsChunk.getType(new BlockPosition(k3, j5--, l3));
_blockPosition.c(k3, j5--, l3);
block1 = nmsChunk.getType(_blockPosition);
}
while ((j5 > 0) && (block1.getMaterial().isLiquid()));
}
}
_heightMap[x + _halfMapSize + 16][z + _halfMapSize + 16] = l4;
_heightMap[x + HALF_WORLD_SIZE + 16][z + HALF_WORLD_SIZE + 16] = l4;
if (setColors)
{
//color = block.f(i5).M;
IBlockData data = nmsChunk.getBlockData(new BlockPosition(k3, l4, l3));
_blockPosition.c(k3, l4, l3);
IBlockData data = nmsChunk.getBlockData(_blockPosition);
color = data.getBlock().g(data).M;
color = (byte) ((color * 4) + 1);
}
}
if (setColors && beginZ >= startingZ)
{
map[x + _halfMapSize][z + _halfMapSize] = (byte) color;
map[x + HALF_WORLD_SIZE][z + HALF_WORLD_SIZE] = (byte) color;
}
}
if (loaded)
{
chunk.unload();
}
}
}
@ -901,7 +948,7 @@ public class ItemMapManager extends MiniPlugin
for (ItemStack item : UtilInv.getItems(player))
{
if (item.getType() == Material.MAP && (item.getDurability() >= _mapId && item.getDurability() <= _mapId + 100))
if (isItemClansMap(item))
{
return;
}
@ -909,62 +956,38 @@ public class ItemMapManager extends MiniPlugin
ItemStack item = new ItemBuilder(Material.MAP, 1, (short) getMap(player).getMap()).setTitle("Clans Map").build();
int slot = player.getInventory().firstEmpty();
int slot = CLANS_MAP_SLOT;
ItemStack mapSlot = player.getInventory().getItem(slot);
if (mapSlot != null && mapSlot.getType() != Material.AIR)
{
slot = player.getInventory().firstEmpty();
}
if (slot >= 0)
{
ItemStack mapSlot = player.getInventory().getItem(8);
if (mapSlot == null || mapSlot.getType() == Material.AIR)
{
slot = 8;
}
player.getInventory().setItem(slot, item);
}
}
/*
* Displays the action bar to a player given their zoom level. Implementation may change
*/
private void showZoom(Player player, MapInfo info)
{
String progressBar = C.cBlue + "";
UtilTextBottom.display(ZOOM_INFO[info.getScale()], player);
}
boolean colorChange = false;
for (int i = 2; i >= 0; i--)
/*
* Check whether an {@link ItemStack} is also a Clans Map
*
* @param itemStack The {@link ItemStack} to check
* @returns Whether the {@link ItemStack} is also a Clans Map
*/
private boolean isItemClansMap(ItemStack itemStack)
{
if (!colorChange && i < info.getScale())
{
progressBar += C.cGray;
colorChange = true;
return UtilItem.matchesMaterial(itemStack, Material.MAP)
&& itemStack.getDurability() >= _mapId
&& itemStack.getDurability() <= _mapId + 100;
}
char c;
switch (i)
{
case 0:
c = '█';
break;
case 1:
c = '▆';
break;
default:
c = '▄';
break;
}
for (int a = 0; a < 4; a++)
{
progressBar += c;
}
if (i > 0)
{
progressBar += " ";
}
}
UtilTextBottom.display(progressBar, player);
}
}

View File

@ -183,6 +183,14 @@ public class ItemMapRenderer extends MapRenderer
}
if (clanColor != null)
{
if(! ((color <= -113 || color >= 0) && color <= 127))
{
color = (byte) 0;
System.out.println(String.format("Tried to draw invalid color %s, player: %s, mapX: %s, mapZ: %s",
color, player.getName(), mapX, mapZ));
}
else
{
int chunkBX = blockX & 0xF;
int chunkBZ = blockZ & 0xF;
@ -256,6 +264,7 @@ public class ItemMapRenderer extends MapRenderer
}
}
}
}
else
{
color = (byte) 0;

View File

@ -4,6 +4,9 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/*
* This event is called when a Player is about to receive a Clans Map
*/
public class PlayerGetMapEvent extends Event
{
private static final HandlerList handlers = new HandlerList();

View File

@ -197,18 +197,7 @@ public class ClansRegions extends MiniPlugin
{
int x = chunkX + xOffset;
int z = chunkZ + zOffset;
Chunk chunk;
try
{ //Corrupted chunk will hold up whole server
chunk = location.getWorld().getChunkAt(x, z);
}
catch(Exception e)
{
System.out.println("UNABLE TO LOAD CHUNK AT " + x + " , " + z);
e.printStackTrace();
continue;
}
String chunkStr = UtilWorld.chunkToStr(chunk);
String chunkStr = location.getWorld().getName() + "," + x + "," + z;
if (addNegative)
{

View File

@ -332,35 +332,6 @@ public class Gameplay extends MiniPlugin
}
}
@EventHandler
public void onInteract(PlayerInteractEvent event)
{
if (!_clansManager.getIncognitoManager().Get(event.getPlayer()).Status)
{
return;
}
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
{
return;
}
if (event.getClickedBlock() == null)
{
return;
}
Material type = event.getClickedBlock().getType();
if (type != Material.CHEST && type != Material.TRAPPED_CHEST)
{
return;
}
Chest chest = (Chest) event.getClickedBlock().getState();
event.getPlayer().openInventory(chest.getInventory());
event.setCancelled(true);
}
/**
* Disable all Piston related events in Clans
*

View File

@ -0,0 +1,55 @@
package mineplex.game.clans.gameplay;
import mineplex.core.common.util.UtilServer;
import mineplex.core.packethandler.PacketHandler;
import mineplex.game.clans.clans.ClansManager;
import org.bukkit.Material;
import org.bukkit.block.Chest;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory;
import org.bukkit.craftbukkit.v1_8_R3.inventory.InventoryWrapper;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
public class HiddenChestManager implements Listener
{
private final ClansManager _clansManager;
public HiddenChestManager(ClansManager clansManager, PacketHandler packetHandler)
{
this._clansManager = clansManager;
UtilServer.RegisterEvents(this);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInteract(PlayerInteractEvent event)
{
if (!_clansManager.getIncognitoManager().Get(event.getPlayer()).Status)
{
return;
}
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
{
return;
}
if (event.getClickedBlock() == null)
{
return;
}
Material type = event.getClickedBlock().getType();
if (type != Material.CHEST && type != Material.TRAPPED_CHEST)
{
return;
}
Chest chest = (Chest) event.getClickedBlock().getState();
event.getPlayer().openInventory(new CraftInventory(new InventoryWrapper(chest.getInventory())));
event.setCancelled(true);
//fixme opened chest has name "container.chest" and that looks bad
}
}

View File

@ -31,30 +31,17 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
*/
public class CustomItem implements Listener
{
// Chat color used for item display name
private static final ChatColor TITLE_COLOR = ChatColor.GOLD;
// Chat color used for attribute descriptions
private static final ChatColor ATTRIBUTE_COLOR = ChatColor.WHITE;
private static final ChatColor TITLE_COLOR = ChatColor.GOLD; // Chat color
// used for
// item
// display
// name
private static final ChatColor ATTRIBUTE_COLOR = ChatColor.WHITE; // Chat
// color
// used
// for
// attribute
// descriptions
protected transient String _displayName;
protected transient String[] _description;
protected transient Material _material;
private AttributeContainer _attributes;
public AttributeContainer getAttributes()
{
return _attributes;
}
protected String _displayName;
protected String[] _description;
protected Material _material;
protected String _uuid;
protected boolean _dullEnchantment;
@ -113,10 +100,6 @@ public class CustomItem implements Listener
lore.add(attributeLine);
}
// Add encoded JSON form of this item, not seen by user.
String serialization = GearManager.getItemSerialization(this);
lore.add(serialization);
return lore;
}
@ -200,6 +183,8 @@ public class CustomItem implements Listener
meta.setLore(lore);
item.setItemMeta(meta);
GearManager.writeNBT(this, item);
}
public static String prettifyName(Material material)
@ -220,4 +205,9 @@ public class CustomItem implements Listener
{
return _material;
}
public AttributeContainer getAttributes()
{
return _attributes;
}
}

View File

@ -1,24 +1,29 @@
package mineplex.game.clans.items;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import com.google.gson.JsonSyntaxException;
import mineplex.core.account.CoreClient;
import mineplex.core.common.Rank;
import mineplex.game.clans.clans.ClansManager;
import net.minecraft.server.v1_8_R3.NBTBase;
import net.minecraft.server.v1_8_R3.NBTTagByte;
import net.minecraft.server.v1_8_R3.NBTTagString;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
@ -29,8 +34,6 @@ import com.google.gson.GsonBuilder;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.weight.Weight;
import mineplex.core.common.weight.WeightSet;
@ -62,14 +65,12 @@ import mineplex.game.clans.items.attributes.weapon.SharpAttribute;
import mineplex.game.clans.items.commands.GearCommand;
import mineplex.game.clans.items.economy.GoldToken;
import mineplex.game.clans.items.legendaries.AlligatorsTooth;
import mineplex.game.clans.items.legendaries.EnergyCrossbow;
import mineplex.game.clans.items.legendaries.GiantsBroadsword;
import mineplex.game.clans.items.legendaries.HyperAxe;
import mineplex.game.clans.items.legendaries.LegendaryItem;
import mineplex.game.clans.items.legendaries.MagneticMaul;
import mineplex.game.clans.items.legendaries.MeridianScepter;
import mineplex.game.clans.items.legendaries.WindBlade;
import mineplex.game.clans.items.rares.Crossbow;
import mineplex.game.clans.items.rares.RareItem;
import mineplex.game.clans.items.rares.RunedPickaxe;
import mineplex.game.clans.items.smelting.SmeltingListener;
@ -81,50 +82,150 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot;
import net.minecraft.server.v1_8_R3.PacketPlayOutWindowItems;
/**
* Manages creation and retrieval of associated {@link PlayerGear}s with online
* players, as well as offering methods for parsing and handling
* {@link CustomItem}s.
*
* @author MrTwiggy
*
* Handles converting legendary itemstacks to their respective CustomItem objects
*/
public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
{
private static final Field UNHANDLED_TAGS_FIELD;
static
{
try
{
UNHANDLED_TAGS_FIELD = Class.forName("org.bukkit.craftbukkit.v1_8_R3.inventory.CraftMetaItem").getDeclaredField("unhandledTags");
UNHANDLED_TAGS_FIELD.setAccessible(true);
}
catch (Throwable t)
{
throw new RuntimeException("Error getting unhandledTags field", t);
}
}
private static final String ITEM_SERIALIZATION_TAG = "-JSON-";
private static Gson _gson;
private static GearManager _instance; // Singleton instance
private static final Gson GSON;
private Map<String, PlayerGear> _playerGears; // Mapping of player names
// (key) to cached gear set
// (value).
private WeightSet<Integer> _attributeWeights; // Weightings for randomly
// selecting number of
// attributes (1, 2, 3)
private WeightSet<ItemType> _typeWeights; // Weightings for randomly
// selecting item type
// (legendary/weapon/armor/bow)
private Set<String> _creativePlayers; // Set of names for all players
// currently in Creative gamemode
// Weightings for randomly selecting number of attributes (1, 2, 3)
private static final WeightSet<Integer> ATTRIBUTE_WEIGHTS = new WeightSet<>(
new Weight<>(3, 3),
new Weight<>(20, 2),
new Weight<>(77, 1)
);
// Legendary generation
public WeightSet<Class<? extends LegendaryItem>> LegendaryWeights;
// Weightings for randomly selecting item type (legendary/weapon/armor/bow)
private static final WeightSet<ItemType> TYPE_WEIGHTS = new WeightSet<>(
new Weight<>(6, ItemType.LEGENDARY),
new Weight<>(9, ItemType.RARE),
new Weight<>(46 - 9, ItemType.ARMOR),
new Weight<>(25, ItemType.WEAPON),
new Weight<>(23, ItemType.BOW)
);
// Rare generation
public WeightSet<Class<? extends RareItem>> RareWeights;
private static final WeightSet<Class<? extends LegendaryItem>> LEGENDARY_WEIGHTS = new WeightSet<>(
MeridianScepter.class,
AlligatorsTooth.class,
WindBlade.class,
GiantsBroadsword.class,
HyperAxe.class,
MagneticMaul.class
);
// Weapon generation
public WeightSet<Material> WeaponTypes;
private static final WeightSet<Class<? extends RareItem>> RARE_WEIGHTS = new WeightSet<>(
RunedPickaxe.class
);
// Armor generation
public WeightSet<Material> ArmorTypes;
private static final WeightSet<Material> WEAPON_TYPES = new WeightSet<>(
Material.DIAMOND_SWORD,
Material.GOLD_SWORD,
Material.IRON_SWORD,
Material.DIAMOND_AXE,
Material.GOLD_AXE,
Material.IRON_AXE
);
// Attribute generation
public WeightSet<Class<? extends ItemAttribute>> WeaponAttributes;
public WeightSet<Class<? extends ItemAttribute>> ArmorAttributes;
public WeightSet<Class<? extends ItemAttribute>> BowAttributes;
private static final WeightSet<Material> ARMOR_TYPES = new WeightSet<>(
Material.DIAMOND_HELMET,
Material.DIAMOND_CHESTPLATE,
Material.DIAMOND_LEGGINGS,
Material.DIAMOND_BOOTS,
Material.IRON_HELMET,
Material.IRON_CHESTPLATE,
Material.IRON_LEGGINGS,
Material.IRON_BOOTS,
Material.GOLD_HELMET,
Material.GOLD_CHESTPLATE,
Material.GOLD_LEGGINGS,
Material.GOLD_BOOTS
);
private static final WeightSet<Class<? extends ItemAttribute>> WEAPON_ATTRIBUTES = new WeightSet<>(
FrostedAttribute.class,
SharpAttribute.class,
JaggedAttribute.class,
HasteAttribute.class,
FlamingAttribute.class,
ConqueringAttribute.class
);
private static final WeightSet<Class<? extends ItemAttribute>> ARMOR_ATTRIBUTES = new WeightSet<>(
SlantedAttribute.class,
ReinforcedAttribute.class,
ConqueringArmorAttribute.class,
PaddedAttribute.class,
LavaAttribute.class
);
private static final WeightSet<Class<? extends ItemAttribute>> BOW_ATTRIBUTES = new WeightSet<>(
HeavyArrowsAttribute.class,
HuntingAttribute.class,
InverseAttribute.class,
LeechingAttribute.class,
RecursiveAttribute.class,
ScorchingAttribute.class,
SlayingAttribute.class
);
// Attribute Masks
private EnumSet<Material> _maskAttributes;
private static final EnumSet<Material> MASK_ATTRIBUTES = EnumSet.of(
Material.GOLD_RECORD,
Material.GREEN_RECORD,
Material.RECORD_3,
Material.RECORD_4,
Material.RECORD_5,
Material.RECORD_6,
Material.RECORD_7,
Material.RECORD_8,
Material.RECORD_9,
Material.RECORD_10,
Material.RECORD_11,
Material.RECORD_12
);
static
{
// Initialize attribute types factory for JSON handling of polymorphism.
RuntimeTypeAdapterFactory<ItemAttribute> attributeFactory = RuntimeTypeAdapterFactory.of(ItemAttribute.class);
ARMOR_ATTRIBUTES.elements().forEach(attributeFactory::registerSubtype);
WEAPON_ATTRIBUTES.elements().forEach(attributeFactory::registerSubtype);
BOW_ATTRIBUTES.elements().forEach(attributeFactory::registerSubtype);
// Initialize legendary item type factory for JSON handling of polymorphism.
RuntimeTypeAdapterFactory<CustomItem> customItemType = RuntimeTypeAdapterFactory.of(CustomItem.class);
customItemType.registerSubtype(CustomItem.class);
customItemType.registerSubtype(LegendaryItem.class);
customItemType.registerSubtype(RareItem.class);
customItemType.registerSubtype(GoldToken.class);
LEGENDARY_WEIGHTS.elements().forEach(customItemType::registerSubtype);
RARE_WEIGHTS.elements().forEach(customItemType::registerSubtype);
// Build GSON instance off factories for future serialization of items.
GSON = new GsonBuilder().registerTypeAdapterFactory(attributeFactory).registerTypeAdapterFactory(customItemType).create();
}
private static Map<UUID, CustomItem> _customItemCache = new HashMap<>();
private static GearManager _instance; // Singleton instance
// Mapping of player names (key) to cached gear set (value).
private Map<Player, PlayerGear> _playerGears = new HashMap<>();
private GearShop _shop;
@ -132,90 +233,22 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
{
super("CustomGear", plugin);
if (_instance != null)
{
throw new RuntimeException("GearManager is already initialized");
}
_instance = this;
_shop = new GearShop(this, clientManager, donationManager);
_creativePlayers = new HashSet<String>();
_playerGears = new HashMap<String, PlayerGear>();
// TODO: Introduce configurable non-hardcoded values for generation
// weights?
_attributeWeights = new WeightSet<Integer>(new Weight<Integer>(3, 3), new Weight<Integer>(20, 2), new Weight<Integer>(77, 1));
_typeWeights = new WeightSet<ItemType>(new Weight<ItemType>(6, ItemType.LEGENDARY),
new Weight<ItemType>(9, ItemType.RARE),
new Weight<ItemType>(46 - 9, ItemType.ARMOR),
new Weight<ItemType>(25, ItemType.WEAPON),
new Weight<ItemType>(23, ItemType.BOW));
// Weapon-based attributes
WeaponAttributes = new WeightSet<Class<? extends ItemAttribute>>(FrostedAttribute.class, SharpAttribute.class, JaggedAttribute.class, HasteAttribute.class, FlamingAttribute.class, ConqueringAttribute.class);
// Armor-based attributes
ArmorAttributes = new WeightSet<Class<? extends ItemAttribute>>(SlantedAttribute.class, ReinforcedAttribute.class, ConqueringArmorAttribute.class, PaddedAttribute.class, LavaAttribute.class);
// Bow-based attributes
BowAttributes = new WeightSet<Class<? extends ItemAttribute>>(HeavyArrowsAttribute.class, HuntingAttribute.class, InverseAttribute.class, LeechingAttribute.class, RecursiveAttribute.class, ScorchingAttribute.class, SlayingAttribute.class);
// Weapon material types
WeaponTypes = new WeightSet<Material>(Material.DIAMOND_SWORD, Material.GOLD_SWORD, Material.IRON_SWORD, Material.DIAMOND_AXE, Material.GOLD_AXE, Material.IRON_AXE);
// Armor material types
ArmorTypes = new WeightSet<Material>(Material.DIAMOND_HELMET, Material.DIAMOND_CHESTPLATE, Material.DIAMOND_LEGGINGS, Material.DIAMOND_BOOTS, Material.IRON_HELMET, Material.IRON_CHESTPLATE, Material.IRON_LEGGINGS, Material.IRON_BOOTS, Material.GOLD_HELMET, Material.GOLD_CHESTPLATE, Material.GOLD_LEGGINGS, Material.GOLD_BOOTS);
// TODO: Initialize list of attributes and types
// Initialize various LegendaryItem types
LegendaryWeights = new WeightSet<Class<? extends LegendaryItem>>(MeridianScepter.class, AlligatorsTooth.class, WindBlade.class, GiantsBroadsword.class, HyperAxe.class, MagneticMaul.class);
RareWeights = new WeightSet<Class<? extends RareItem>>(RunedPickaxe.class);
// TODO: Add rest of legendaries, find better way?
// Register listeners
UtilServer.getServer().getPluginManager().registerEvents(new ItemListener(getPlugin()), getPlugin());
UtilServer.getServer().getPluginManager().registerEvents(new SmeltingListener(), getPlugin());
// Initialize attribute types factory for JSON handling of polymorphism.
RuntimeTypeAdapterFactory<ItemAttribute> attributeFactory = RuntimeTypeAdapterFactory.of(ItemAttribute.class);
for (Class<? extends ItemAttribute> attributeType : ArmorAttributes.elements())
{
attributeFactory.registerSubtype(attributeType);
}
for (Class<? extends ItemAttribute> attributeType : WeaponAttributes.elements())
{
attributeFactory.registerSubtype(attributeType);
}
for (Class<? extends ItemAttribute> attributeType : BowAttributes.elements())
{
attributeFactory.registerSubtype(attributeType);
}
// Initialize legendary item type factory for JSON handling of
// polymorphism.
RuntimeTypeAdapterFactory<CustomItem> customItemType = RuntimeTypeAdapterFactory.of(CustomItem.class);
customItemType.registerSubtype(CustomItem.class);
customItemType.registerSubtype(LegendaryItem.class);
customItemType.registerSubtype(RareItem.class);
customItemType.registerSubtype(GoldToken.class);
for (Class<? extends CustomItem> itemType : LegendaryWeights.elements())
{
customItemType.registerSubtype(itemType);
}
for (Class<? extends RareItem> itemType : RareWeights.elements())
{
customItemType.registerSubtype(itemType);
}
// Build GSON instance off factories for future serialization of items.
_gson = new GsonBuilder().registerTypeAdapterFactory(attributeFactory).registerTypeAdapterFactory(customItemType).create();
packetHandler.addPacketHandler(this, PacketPlayOutSetSlot.class, PacketPlayOutWindowItems.class);
plugin.getServer().getScheduler().runTaskTimer(plugin, this, 1l, 1l);
_maskAttributes = EnumSet.of(Material.GOLD_RECORD, Material.GREEN_RECORD, Material.RECORD_3, Material.RECORD_4, Material.RECORD_5, Material.RECORD_6,
Material.RECORD_7, Material.RECORD_8, Material.RECORD_9, Material.RECORD_10, Material.RECORD_11, Material.RECORD_12);
plugin.getServer().getScheduler().runTaskTimer(plugin, this, 1L, 1L);
}
@Override
@ -224,21 +257,8 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
addCommand(new GearCommand(this));
}
public void addCreativePlayer(Player player)
{
_creativePlayers.add(player.getName());
player.updateInventory();
}
public void removeCreativePlayer(Player player)
{
_creativePlayers.remove(player.getName());
player.updateInventory();
}
/**
* Tick & update internal logic for {@link GearManager}. Called once per
* tick.
* Tick & update internal logic for {@link GearManager}. Called once per tick.
*/
@Override
public void run()
@ -247,13 +267,13 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
while (iterator.hasNext())
{
PlayerGear gear = iterator.next();
if (gear.isOnline())
if (gear.cleanup())
{
gear.update();
iterator.remove();
}
else
{
iterator.remove();
gear.update();
}
}
}
@ -265,38 +285,31 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
*/
public PlayerGear getPlayerGear(Player player)
{
String playerName = player.getName();
if (!_playerGears.containsKey(playerName))
{
PlayerGear gear = new PlayerGear(playerName);
_playerGears.put(playerName, gear);
}
return _playerGears.get(playerName);
return _playerGears.computeIfAbsent(player, PlayerGear::new);
}
public CustomItem generateItem()
{
int attributeCount = _attributeWeights.generateRandom();
ItemType itemType = _typeWeights.generateRandom();
int attributeCount = ATTRIBUTE_WEIGHTS.generateRandom();
ItemType itemType = TYPE_WEIGHTS.generateRandom();
RareItemFactory factory = RareItemFactory.begin(itemType);
if (itemType == ItemType.RARE)
{
factory.setRare(RareWeights.generateRandom());
factory.setRare(RARE_WEIGHTS.generateRandom());
}
else if (itemType == ItemType.LEGENDARY)
{
factory.setLegendary(LegendaryWeights.generateRandom());
factory.setLegendary(LEGENDARY_WEIGHTS.generateRandom());
}
else if (itemType == ItemType.ARMOR)
{
factory.setType(ArmorTypes.generateRandom());
factory.setType(ARMOR_TYPES.generateRandom());
}
else if (itemType == ItemType.WEAPON)
{
factory.setType(WeaponTypes.generateRandom());
factory.setType(WEAPON_TYPES.generateRandom());
}
else if (itemType == ItemType.BOW)
{
@ -347,13 +360,13 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
switch (type)
{
case ARMOR:
sampleAttribute = instantiate(ArmorAttributes.generateRandom());
sampleAttribute = instantiate(ARMOR_ATTRIBUTES.generateRandom());
break;
case WEAPON:
sampleAttribute = instantiate(WeaponAttributes.generateRandom());
sampleAttribute = instantiate(WEAPON_ATTRIBUTES.generateRandom());
break;
case BOW:
sampleAttribute = instantiate(BowAttributes.generateRandom());
sampleAttribute = instantiate(BOW_ATTRIBUTES.generateRandom());
break;
default:
break;
@ -361,8 +374,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
if (sampleAttribute != null && remaining.contains(sampleAttribute.getType()))
{
attribute = sampleAttribute; // Select valid attribute to
// add
attribute = sampleAttribute; // Select valid attribute to add
}
attempts++;
@ -380,42 +392,119 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
public static CustomItem parseItem(ItemStack item)
{
String serialization = getItemSerialization(item);
if (serialization != null)
if (item == null)
{
CustomItem customItem = null;
return null;
}
Map<String, NBTBase> data = getUnhandledTags(item);
if (data == null)
{
return null;
}
if (data.containsKey("gearmanager.uuid"))
{
String strUUID = ((NBTTagString) data.get("gearmanager.uuid")).a_();
try
{
customItem = deserialize(serialization);
}
catch (Exception exception)
UUID uuid = UUID.fromString(strUUID);
CustomItem customItem = _customItemCache.get(uuid);
if (customItem == null)
{
exception.printStackTrace();
System.out.println("==========");
System.out.println("GearManager parse problem :");
System.out.println(serialization);
System.out.println("==========");
String json = ((NBTTagString) data.get("gearmanager.json")).a_();
customItem = deserialize(json);
_customItemCache.put(uuid, customItem);
}
return customItem;
}
// Not an UUID?
catch (IllegalArgumentException exception)
{
if (!data.containsKey("gearmanager.warnuuid"))
{
// Add to the lore that this item is corrupted
List<String> lore = item.getItemMeta().getLore();
lore.add("");
lore.add(C.cRedB + "Corrupted item (Error 1)");
data.put("gearmanager.warnuuid", new NBTTagByte((byte) 1));
exception.printStackTrace();
saveUnhandledTags(item, data);
}
return null;
}
// Failed to parse
catch (JsonSyntaxException exception)
{
if (!data.containsKey("gearmanager.warnsyntax"))
{
// Add to the lore that this item is corrupted
List<String> lore = item.getItemMeta().getLore();
lore.add("");
lore.add(C.cRedB + "Corrupted item (Error 2)");
data.put("gearmanager.warnsyntax", new NBTTagByte((byte) 1));
System.out.println(((NBTTagString) data.get("gearmanager.json")).a_());
exception.printStackTrace();
saveUnhandledTags(item, data);
}
return null;
}
// Other
catch (Exception exception)
{
if (!data.containsKey("gearmanager.warnother"))
{
// Add to the lore that this item is corrupted
List<String> lore = item.getItemMeta().getLore();
lore.add("");
lore.add(C.cRedB + "Corrupted item (Error 3)");
data.put("gearmanager.warnother", new NBTTagByte((byte) 1));
exception.printStackTrace();
saveUnhandledTags(item, data);
}
return null;
}
}
else // This is stored in the old format
{
String serialization = getItemSerialization(item);
if (serialization == null)
{
return null;
}
try
{
CustomItem customItem = deserialize(serialization);
return null; // No serialization found in item's lore, not a custom
// item!
data.put("gearmanager.uuid", new NBTTagString(customItem._uuid));
data.put("gearmanager.json", new NBTTagString(serialization));
saveUnhandledTags(item, data);
_customItemCache.put(UUID.fromString(customItem._uuid), customItem);
return customItem;
}
catch (Exception e)
{
System.out.println(serialization);
e.printStackTrace();
}
return null;
}
}
public static void writeNBT(CustomItem customItem, ItemStack item)
{
Map<String, NBTBase> data = getUnhandledTags(item);
data.put("gearmanager.uuid", new NBTTagString(customItem._uuid));
data.put("gearmanager.json", new NBTTagString(serialize(customItem)));
saveUnhandledTags(item, data);
}
public static boolean isCustomItem(ItemStack item)
{
return getItemSerialization(item) != null;
}
public static String getItemSerialization(CustomItem customItem)
Map<String, NBTBase> data = getUnhandledTags(item);
if (data.containsKey("gearmanager.uuid") && data.containsKey("gearmanager.json"))
{
String serialization = serialize(customItem);
return ITEM_SERIALIZATION_TAG + serialization;
return true;
}
return getItemSerialization(item) != null;
}
/**
@ -436,46 +525,36 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
}
}
@Deprecated
private static String getItemSerialization(ItemStack item)
{
if (item == null || item.getItemMeta() == null || item.getItemMeta().getLore() == null) return null;
// fixme Each call to getItemMeta creates a new ItemMeta, a clone of an ArrayList, and a clone of a Hashmap
// Each call to getLore re-clones that ArrayList again
// Reflection may be too slow, but perhaps MethodHandles would be good?
ItemMeta meta = item.getItemMeta();
for (String lore : meta.getLore())
{
if (lore.startsWith(ITEM_SERIALIZATION_TAG)) // Found serialization
// lore-line
if (lore.startsWith(ITEM_SERIALIZATION_TAG))
{
int tagLength = ITEM_SERIALIZATION_TAG.length();
String serialization = lore.substring(tagLength);
return serialization;
return lore.substring(tagLength);
}
}
return null; // Unable to find any serialized lore lines, hence not a
// CustomItem.
return null; // Unable to find any serialized lore lines, hence not a CustomItem.
}
public static String serialize(CustomItem customItem)
{
return _gson.toJson(customItem, CustomItem.class);
}
public static String serialize(AttributeContainer attributes)
{
return _gson.toJson(attributes, AttributeContainer.class);
return GSON.toJson(customItem, CustomItem.class);
}
public static CustomItem deserialize(String serialization)
{
return _gson.fromJson(serialization, CustomItem.class);
}
public static <T> T deserialize(String serialization, Class<T> type)
{
return _gson.fromJson(serialization, type);
return GSON.fromJson(serialization, CustomItem.class);
}
/**
@ -486,11 +565,6 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
return _instance;
}
public static void notify(Player player, String message)
{
UtilPlayer.message(player, F.main("Gear", message));
}
/**
* @param player - the player to see if they should have their out-going
* packets masked on CustomGear items.
@ -499,13 +573,14 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
*/
private boolean maskGearPacket(Player player)
{
return player.getGameMode() != GameMode.CREATIVE && !_creativePlayers.contains(player.getName());
return player.getGameMode() != GameMode.CREATIVE;
}
public void handle(PacketInfo packetInfo)
{
// Don't mask custom gear lore for creative players, as this will break
// them.
// Don't mask custom gear lore for creative players, as this will break them.
// To be precise, the lore is added more than once because the creative client spawns in new items with the existing lore
// fixme
if (!maskGearPacket(packetInfo.getPlayer())) return;
Packet<?> packet = packetInfo.getPacket();
@ -513,8 +588,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
if (packet instanceof PacketPlayOutSetSlot)
{
PacketPlayOutSetSlot slotPacket = (PacketPlayOutSetSlot) packet;
slotPacket.c = maskItem(slotPacket.c, packetInfo.getPlayer()); // Mask all out-going item
// packets
slotPacket.c = maskItem(slotPacket.c, packetInfo.getPlayer()); // Mask all out-going item packets
}
else if (packet instanceof PacketPlayOutWindowItems)
{
@ -522,11 +596,9 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
for (int i = 0; i < itemsPacket.b.length; i++)
{
itemsPacket.b[i] = maskItem(itemsPacket.b[i], packetInfo.getPlayer()); // Mask all
// out-going
// item packets
itemsPacket.b[i] = maskItem(itemsPacket.b[i], packetInfo.getPlayer()); // Mask all out-going item packets
ItemStack item = CraftItemStack.asCraftMirror(itemsPacket.b[i]);
if (item != null && _maskAttributes.contains(item.getType()))
if (item != null && MASK_ATTRIBUTES.contains(item.getType()))
itemsPacket.b[i] = removeAttributes(itemsPacket.b[i]);
}
}
@ -563,34 +635,135 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
return item;
}
List<String> lore = new ArrayList<String>();
List<String> newLore = cleanseLore(originalMeta.getLore());
CustomItem ci = parseItem(originalItem);
for (String line : originalMeta.getLore())
if (ci != null && LEGENDARY_WEIGHTS.elements().contains(ci.getClass()))
{
if (!line.startsWith(ITEM_SERIALIZATION_TAG))
String originalOwner = null;
if (ci.OriginalOwner == null)
{
lore.add(line);
originalOwner = "You";
}
else
{
if (player.getUniqueId().toString().equals(ci.OriginalOwner))
{
originalOwner = "You";
}
else
{
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(UUID.fromString(ci.OriginalOwner));
originalOwner = offlinePlayer.getName();
}
}
if (ci != null && LegendaryWeights.elements().contains(ci.getClass()))
newLore.add(" ");
newLore.add(C.cWhite + "Original Owner: " + C.cYellow + originalOwner);
}
if (ci != null)
{
lore.add(" ");
lore.add(C.cWhite + "Original Owner: " + C.cYellow + (ci.OriginalOwner == null ? "You" : Bukkit.getOfflinePlayer(UUID.fromString(ci.OriginalOwner)).getName()));
newLore.add(" ");
newLore.add(C.cWhite + "UUID: " + C.cYellow + ci._uuid);
}
net.minecraft.server.v1_8_R3.ItemStack newItem = CraftItemStack.asNMSCopy(originalItem);
CraftItemStack newCopy = CraftItemStack.asCraftMirror(newItem);
ItemMeta newMeta = newCopy.getItemMeta();
newMeta.setLore(lore);
newMeta.setLore(newLore);
newCopy.setItemMeta(newMeta);
return newItem;
}
private List<String> cleanseLore(List<String> input)
{
List<String> cleansed = new ArrayList<>();
for (String s : input)
{
if (!s.startsWith(ITEM_SERIALIZATION_TAG))
{
cleansed.add(s);
}
}
return cleansed;
}
public void openShop(Player player)
{
_shop.attemptShopOpen(player);
}
// WARNING
// This will not be persistent if the ItemStack is a block and placed then picked up
private static Map<String, NBTBase> getUnhandledTags(ItemStack itemStack)
{
ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta == null)
{
return null;
}
try
{
return (Map<String, NBTBase>) UNHANDLED_TAGS_FIELD.get(itemMeta);
}
catch (IllegalAccessException e)
{
System.out.println("Could not get unhandledTags");
e.printStackTrace();
}
return null;
}
private static void saveUnhandledTags(ItemStack itemStack, Map<String, NBTBase> map)
{
ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta == null)
{
return;
}
try
{
UNHANDLED_TAGS_FIELD.set(itemMeta, map);
}
catch (IllegalAccessException e)
{
System.out.println("Could not get unhandledTags");
e.printStackTrace();
}
itemStack.setItemMeta(itemMeta);
}
public static void save(ItemStack itemStack, boolean remove)
{
CustomItem item = parseItem(itemStack);
if (item != null)
{
Map<String, NBTBase> data = getUnhandledTags(itemStack);
data.put("gearmanager.json", new NBTTagString(serialize(item)));
saveUnhandledTags(itemStack, data);
if (remove)
{
_customItemCache.remove(item);
}
}
}
public static void cleanup()
{
Iterator<CustomItem> it = _customItemCache.values().iterator();
while (it.hasNext())
{
CustomItem item = it.next();
if (item.OriginalOwner != null)
{
UUID uuid = UUID.fromString(item.OriginalOwner);
Player player = Bukkit.getPlayer(uuid);
if (player == null || !player.isOnline())
{
UtilServer.Unregister(item);
it.remove();
}
}
}
}
}

View File

@ -1,5 +1,10 @@
package mineplex.game.clans.items;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilOfflinePlayer;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import net.minecraft.server.v1_8_R3.PlayerInventory;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Entity;
@ -14,6 +19,8 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.java.JavaPlugin;
@ -25,73 +32,48 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
/**
* Listens for item-related trigger events and accordingly triggers appropriate
* {@link PlayerGear} events for {@link CustomItem} abilities and attributes.
* @author MrTwiggy
*
* @author MrTwiggy
*/
public class ItemListener implements Listener
public class ItemListener implements Listener, Runnable
{
public static final String PROJECTILE_META_TAG = "[CustomGearProj]";
private static final String PROJECTILE_META_TAG = "[CustomGearProj]";
private JavaPlugin _plugin;
public ItemListener(JavaPlugin plugin)
{
_plugin = plugin;
_plugin.getServer().getScheduler().runTaskTimer(_plugin, this, 20 * 60 * 5, 0);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onGamemodeChange(PlayerGameModeChangeEvent event)
{
if (event.getNewGameMode() == GameMode.CREATIVE) // Entering creative mode
{
GearManager.getInstance().addCreativePlayer(event.getPlayer());
}
else if (event.getPlayer().getGameMode() == GameMode.CREATIVE) // Exiting creative mode
{
GearManager.getInstance().removeCreativePlayer(event.getPlayer());
// Update/refresh the players inventory in 5 ticks once they're in survival mode again
final Player player = event.getPlayer();
Bukkit.getScheduler().runTaskLater(_plugin, new Runnable()
{
@Override
public void run()
{
player.updateInventory();
}
}, 5l);
}
}
/**
* Handle players shuffling CustomItems around by properly updating
* and managing their movement.
* @param event
*/
@EventHandler
public void onInventoryClick(InventoryClickEvent event)
for (Player player : UtilServer.getPlayersCollection())
{
// TODO: Update any custom-items that are selected/moved to save proper stats if they
// TODO: are active. (IE: PlayerGear possesses it as armor slot or weapon)
save(player, false);
}
GearManager.cleanup();
}
/**
* Handle updated CustomItem stats and lore upon player
* switching items.
* @param event
*/
@EventHandler
public void onItemHeldChanged(PlayerItemHeldEvent event)
@EventHandler(priority = EventPriority.LOWEST)
public void on(PlayerQuitEvent event)
{
Player player = event.getPlayer();
PlayerGear gear = getGear(player);
save(event.getPlayer(), true);
}
gear.onItemHeldChanged(event);
private void save(Player player, boolean remove)
{
for (ItemStack item : UtilInv.getItems(player))
{
GearManager.save(item, remove);
}
}
/**
* Handle the trigger of custom gear related effects and abilities.
*
* @param event
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
@ -124,8 +106,7 @@ public class ItemListener implements Listener
{
for (MetadataValue data : projectile.getMetadata(PROJECTILE_META_TAG))
{
String serialization = data.asString();
AttributeContainer container = GearManager.deserialize(serialization, AttributeContainer.class);
AttributeContainer container = (AttributeContainer) data.value();
for (ItemAttribute attribute : container.getAttributes())
{
@ -138,6 +119,7 @@ public class ItemListener implements Listener
/**
* Properly marks projectiles shot from a custom-gear bow so that it will properly trigger events.
*
* @param event
*/
@EventHandler
@ -154,10 +136,9 @@ public class ItemListener implements Listener
{
// Copy weapon attributes onto projectile for later processing
AttributeContainer attributes = weapon.getAttributes();
String serialization = GearManager.serialize(attributes);
Entity projectile = event.getProjectile();
projectile.setMetadata(PROJECTILE_META_TAG, new FixedMetadataValue(_plugin, serialization));
projectile.setMetadata(PROJECTILE_META_TAG, new FixedMetadataValue(_plugin, attributes));
}
}
@ -165,6 +146,7 @@ public class ItemListener implements Listener
/**
* Handle weapon ability activation of custom gear.
*
* @param event
*/
@EventHandler

View File

@ -2,6 +2,7 @@ package mineplex.game.clans.items;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Consumer;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -27,23 +28,13 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
*/
public class PlayerGear
{
private String _playerName; // Name of player who owns the gear
private boolean _cleanedUp = false;
// Cached custom item information for player's gear
private CustomItem _weapon;
private CustomItem _helmet;
private CustomItem _chestplate;
private CustomItem _leggings;
private CustomItem _boots;
private Player _owner;
/**
* Class constructor
*
* @param playerName
*/
public PlayerGear(String playerName)
public PlayerGear(Player owner)
{
_playerName = playerName;
this._owner = owner;
}
/**
@ -52,7 +43,7 @@ public class PlayerGear
*/
public void update()
{
if (isOnline())
if (_owner.isOnline())
{
CustomItem item = getWeapon();
@ -65,38 +56,22 @@ public class PlayerGear
if (legendary.OriginalOwner == null)
{
legendary.OriginalOwner = getPlayer().getUniqueId().toString();
getPlayer().setItemInHand(legendary.toItemStack());
}
}
}
}
public boolean isOnline()
{
Player player = getPlayer();
return player != null && player.isOnline();
}
/**
* @return the {@link Player} that owns this gear set.
*/
public Player getPlayer()
{
return Bukkit.getPlayer(_playerName);
}
/**
* @return the {@link PlayerInventory} associated with the owner of this
* {@link PlayerGear}.
*/
public PlayerInventory getInventory()
{
return getPlayer().getInventory();
return this._owner;
}
public String getPlayerName()
{
return _playerName;
return getPlayer().getName();
}
/**
@ -107,12 +82,10 @@ public class PlayerGear
*/
public void onInteract(PlayerInteractEvent event)
{
for (CustomItem item : getGear())
{
item.onInteract(event);
}
forEachGear(item -> item.onInteract(event));
}
/**
* Trigger on-attack events for the set of equipped {@link CustomItem}s in
* gear set.
@ -121,10 +94,7 @@ public class PlayerGear
*/
public void onAttack(CustomDamageEvent event)
{
for (CustomItem item : getGear())
{
item.onAttack(event);
}
forEachGear(item -> item.onAttack(event));
}
/**
@ -135,118 +105,68 @@ public class PlayerGear
*/
public void onAttacked(CustomDamageEvent event)
{
for (CustomItem item : getGear())
{
item.onAttacked(event);
}
forEachGear(item -> item.onAttacked(event));
}
/**
* Update appropriate gear status and item lores.
*
* @param event - the triggering item held change event.
*/
public void onItemHeldChanged(PlayerItemHeldEvent event)
private void forEachGear(Consumer<CustomItem> itemConsumer)
{
ItemStack item = getPlayer().getItemInHand();
CustomItem weapon = getWeapon();
if (weapon != null)
{
weapon.update(item); // Update held-item's stats.
itemConsumer.accept(weapon);
}
CustomItem helmet = getHelmet();
if (helmet != null)
{
itemConsumer.accept(helmet);
}
CustomItem chestplate = getChestplate();
if (chestplate != null)
{
itemConsumer.accept(chestplate);
}
CustomItem leggings = getLeggings();
if (leggings != null)
{
itemConsumer.accept(leggings);
}
CustomItem boots = getBoots();
if (boots != null)
{
itemConsumer.accept(boots);
}
}
public CustomItem getWeapon()
{
ItemStack weaponItem = getPlayer().getInventory().getItemInHand();
if (!itemsMatch(_weapon, weaponItem))
{
_weapon = parseItem(weaponItem);
}
return _weapon;
return GearManager.parseItem(getPlayer().getInventory().getItemInHand());
}
public CustomItem getHelmet()
{
ItemStack helmetItem = getPlayer().getInventory().getHelmet();
if (!itemsMatch(_helmet, helmetItem))
{
_helmet = parseItem(helmetItem);
}
return _helmet;
return GearManager.parseItem(getPlayer().getInventory().getHelmet());
}
public CustomItem getChestplate()
{
ItemStack chestplateItem = getPlayer().getInventory().getChestplate();
if (!itemsMatch(_chestplate, chestplateItem))
{
_chestplate = parseItem(chestplateItem);
}
return _chestplate;
return GearManager.parseItem(getPlayer().getInventory().getChestplate());
}
public CustomItem getLeggings()
{
ItemStack leggingsItem = getPlayer().getInventory().getLeggings();
if (!itemsMatch(_leggings, leggingsItem))
{
_leggings = parseItem(leggingsItem);
}
return _leggings;
return GearManager.parseItem(getPlayer().getInventory().getLeggings());
}
public CustomItem getBoots()
{
ItemStack bootsItem = getPlayer().getInventory().getBoots();
if (!itemsMatch(_boots, bootsItem))
{
_boots = parseItem(bootsItem);
return GearManager.parseItem(getPlayer().getInventory().getBoots());
}
return _boots;
}
/**
* @return set of currently equipped {@link CustomItem}s in the gear set.
/*
* Perform cleanup if necessary. If cleanup was performed, return true. Otherwise return false
*/
public Set<CustomItem> getGear()
public boolean cleanup()
{
Set<CustomItem> items = new HashSet<CustomItem>();
if (getWeapon() != null) items.add(getWeapon());
if (getHelmet() != null) items.add(getHelmet());
if (getChestplate() != null) items.add(getChestplate());
if (getLeggings() != null) items.add(getLeggings());
if (getBoots() != null) items.add(getBoots());
return items;
}
private boolean itemsMatch(CustomItem customItem, ItemStack item)
{
if (customItem == null || item == null) return false;
if (GearManager.isCustomItem(item))
{
CustomItem customItem2 = GearManager.parseItem(item);
return customItem2.matches(customItem);
}
return false;
}
private CustomItem parseItem(ItemStack item)
{
return GearManager.parseItem(item);
return !getPlayer().isOnline();
}
}

View File

@ -1,13 +1,9 @@
package mineplex.game.clans.items.legendaries;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import mineplex.core.common.util.UtilAction;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
@ -18,12 +14,11 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
public class AlligatorsTooth extends LegendaryItem
{
private static ValueDistribution boostGen = generateDistribution(0.8d, 1.4d);
private static ValueDistribution BOOST_GEN = generateDistribution(0.8d, 1.4d);
private static double LAND_DAMAGE_BONUS = 7;
private static double WATER_DAMAGE_BONUS = 11;
private double _landDamageBonus = 7;
private double _waterDamageBonus = 11;
private double _swimSpeed;
private int _soundUpdateCounter;
public AlligatorsTooth()
@ -38,7 +33,7 @@ public class AlligatorsTooth extends LegendaryItem
C.cYellow + "Right-Click" + C.cWhite + " to use" + C.cGreen + " Swim",
}, Material.RECORD_4);
_swimSpeed = boostGen.generateValue();
_swimSpeed = BOOST_GEN.generateValue();
}
@Override
@ -46,8 +41,7 @@ public class AlligatorsTooth extends LegendaryItem
{
if (isInWater(wielder))
{
// Player gain water breathing while under water with legendary
// equipped
// Player gain water breathing while under water with legendary equipped
grantPotionEffect(wielder, PotionEffectType.WATER_BREATHING, 0, 50);
if (isHoldingRightClick())
@ -56,7 +50,6 @@ public class AlligatorsTooth extends LegendaryItem
if (++_soundUpdateCounter % 3 == 0)
{
wielder.playSound(wielder.getLocation(), Sound.SPLASH2, .5f, 1.25f);
wielder.getLocation().getWorld().playEffect(wielder.getLocation(), Effect.STEP_SOUND, Material.LAPIS_BLOCK.getId());
}
}
@ -68,12 +61,12 @@ public class AlligatorsTooth extends LegendaryItem
{
if (isInWater(wielder))
{
event.AddMod("Alligators Tooth", _waterDamageBonus);
event.AddKnockback("Alligators Tooth", 0.5d);
event.AddMod("Alligators Tooth Water Bonus", WATER_DAMAGE_BONUS);
event.AddKnockback("Alligators Tooth Water Bonus", 0.5d);
}
else
{
event.AddMod("Alligators Tooth", _landDamageBonus);
event.AddMod("Alligators Tooth Land Bonus", LAND_DAMAGE_BONUS);
}
}
@ -87,6 +80,7 @@ public class AlligatorsTooth extends LegendaryItem
private boolean isInWater(Player player)
{
return player.getLocation().getBlock().getType() == Material.WATER || player.getLocation().getBlock().getType() == Material.STATIONARY_WATER;
Material type = player.getLocation().getBlock().getType();
return type == Material.WATER || type == Material.STATIONARY_WATER;
}
}

View File

@ -1,5 +1,6 @@
package mineplex.game.clans.items.legendaries;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@ -35,18 +36,17 @@ import mineplex.core.recharge.Recharge;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
/*
@deprecated Code probably doesn't work and needs a rewrite
*/
@Deprecated
public class EnergyCrossbow extends LegendaryItem
{
private long _lastFire = System.currentTimeMillis();
private long _interactWait;
private static List<Vector> _preCalculatedSphere;
{
ClansManager.getInstance().runAsync(() ->
_preCalculatedSphere = UtilTrig.GetSpherePoints(new Vector(0, 0, 0), 1.8d, 1.8d, true, .4d)
private static final List<Vector> PRE_CALCULATED_SPHERE = Collections.unmodifiableList(
UtilTrig.GetSpherePoints(new Vector(0, 0, 0), 1.8d, 1.8d, true, .4d)
);
}
private long _interactWait;
public EnergyCrossbow()
{
@ -60,7 +60,7 @@ public class EnergyCrossbow extends LegendaryItem
@Override
public void update(Player wielder)
{
if ((System.currentTimeMillis() - _lastBlock) < 98 && (System.currentTimeMillis() - _interactWait) >= 98)
if (timeSinceLastBlock() < 98 && (System.currentTimeMillis() - _interactWait) >= 98)
{
if (Recharge.Instance.use(wielder, "Crossbow", 6500, true, true))
{
@ -82,6 +82,7 @@ public class EnergyCrossbow extends LegendaryItem
private RGBData[] colors = { UtilColor.RgbLightRed, UtilColor.RgbLightRed.Lighten(), UtilColor.RgbLightRed.Darken() };
{
// Pretty sure this won't work
_player = player;
Arrow arrow = _player.shootArrow();
@ -125,7 +126,7 @@ public class EnergyCrossbow extends LegendaryItem
{
HandlerList.unregisterAll(this);
for (Vector vector : _preCalculatedSphere)
for (Vector vector : PRE_CALCULATED_SPHERE)
{
UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, _arrow.getLocation().add(vector), UtilColor.RgbLightRed.ToVector(), 1.0f, 0, ViewDist.MAX);
}
@ -182,7 +183,5 @@ public class EnergyCrossbow extends LegendaryItem
}
});
_lastFire = System.currentTimeMillis();
}
}

View File

@ -14,8 +14,8 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
public class GiantsBroadsword extends LegendaryItem
{
public static final int SLOW_AMPLIFIER = 43;
public static final int REGEN_AMPLIFIER = 1;
private static final int SLOW_AMPLIFIER = 43;
private static final int REGEN_AMPLIFIER = 1;
public GiantsBroadsword()
{
@ -33,7 +33,8 @@ public class GiantsBroadsword extends LegendaryItem
@Override
public void update(Player wielder)
{
if (isHoldingRightClick()) {
if (isHoldingRightClick())
{
buffPlayer(wielder);
UtilParticle.PlayParticle(ParticleType.HEART, wielder.getEyeLocation().add(0, 0.25, 0), -.5f + (float) Math.random(), -.5f + (float) Math.random(), -.5f + (float) Math.random(), .2f, 1, ViewDist.NORMAL);
@ -57,7 +58,6 @@ public class GiantsBroadsword extends LegendaryItem
event.AddKnockback("Giants Sword", 0.5d);
}
private void buffPlayer(Player player)
{
grantPotionEffect(player, PotionEffectType.SLOW, 40, SLOW_AMPLIFIER);

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.items.legendaries;
package mineplex.game.clans.items.legendaries;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -12,9 +12,9 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
public class HyperAxe extends LegendaryItem
{
public static final long ATTACK_RATE_DURATION = 1000 / 10;
private static ValueDistribution amountGen = generateDistribution(0, 3); // [1, 4] speed amount
private static ValueDistribution durationGen = generateDistribution(80, 320); // [4, 16] seconds speed duration
private static final long ATTACK_RATE_DURATION = 1000 / 10;
private static ValueDistribution AMOUNT_GEN = generateDistribution(0, 3); // [1, 4] speed amount
private static ValueDistribution DURATION_GEN = generateDistribution(80, 320); // [4, 16] seconds speed duration
private int _speedAmount;
private int _speedDuration;
@ -34,15 +34,15 @@ public class HyperAxe extends LegendaryItem
C.cWhite + "Deals " + C.cYellow + "3 Damage" + C.cWhite + " with attack",
C.cYellow + "Right-Click" + C.cWhite + " to use " + C.cGreen + "Dash",
}, Material.RECORD_3);
_speedAmount = amountGen.generateIntValue();
_speedDuration = durationGen.generateIntValue();
_speedAmount = AMOUNT_GEN.generateIntValue();
_speedDuration = DURATION_GEN.generateIntValue();
_lastAttack = 0;
}
@Override
public void update(Player wielder)
{
if (isHoldingRightClick() && canBuff(wielder))
if (isHoldingRightClick())
{
buffPlayer(wielder);
}
@ -64,22 +64,18 @@ public class HyperAxe extends LegendaryItem
}
}
public long timeSinceLastAttack()
private long timeSinceLastAttack()
{
return System.currentTimeMillis() - _lastAttack;
}
private void buffPlayer(Player wielder)
{
if (Recharge.Instance.usable(wielder, "Hyper Rush", true))
{
Recharge.Instance.use(wielder, "Hyper Rush", 16000, true, false);
// Give player speed buff
wielder.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, _speedDuration, _speedAmount));
log("Buffing");
}
private boolean canBuff(Player wielder)
{
return Recharge.Instance.usable(wielder, "Hyper Rush", true);
}
}

View File

@ -13,16 +13,15 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
public class LegendaryItem extends CustomItem
{
public final long BLOCK_COOLDOWN = 200l; // Right clicking activates right click for 200ms
private final long BLOCK_COOLDOWN = 200L; // Right clicking activates right click for 200ms
protected long _lastBlock; // Timestamp of last block from wielder
public long timeSinceLastBlock() { return System.currentTimeMillis() - _lastBlock; }
public LegendaryItem(String name, String[] description, Material material)
{
super(name, description, material);
_lastBlock = 0l;
_lastBlock = 0L;
}
public void update(Player wielder)
@ -67,6 +66,11 @@ public class LegendaryItem extends CustomItem
return timeSinceLastBlock() <= BLOCK_COOLDOWN;
}
public long timeSinceLastBlock()
{
return System.currentTimeMillis() - _lastBlock;
}
protected void log(String message)
{
System.out.println("[Custom Item - " + _displayName + "] " + message);
@ -92,7 +96,6 @@ public class LegendaryItem extends CustomItem
*/
public static void grantPotionEffect(Player player, PotionEffectType type, int tickDuration, int amplifier)
{
player.removePotionEffect(type);
player.addPotionEffect(new PotionEffect(type, amplifier, tickDuration));
player.addPotionEffect(new PotionEffect(type, amplifier, tickDuration), true);
}
}

View File

@ -1,6 +1,7 @@
package mineplex.game.clans.items.legendaries;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
@ -8,9 +9,11 @@ import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilWorld;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.core.repository.ClanTerritory;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import org.bukkit.Location;
@ -21,31 +24,29 @@ import org.bukkit.util.Vector;
public class MagneticMaul extends LegendaryItem
{
public static final double PULL_RANGE = 10d;
private static final double PULL_RANGE = 10d;
private double _power;
private double _heat;
public MagneticMaul()
{
super("Magnetic Maul", new String[] {
C.cWhite + "This brutal weapon allows you to pull your enemies towards you with magnetic force!"
+ " ",
super("Magnetic Maul", UtilText.splitLinesToArray(new String[] {
C.cWhite + "This brutal weapon allows you to pull your enemies towards you with magnetic force!",
" ",
C.cYellow + "Right-Click" + C.cWhite + " to use Maul."
}, Material.RECORD_5);
}, LineFormat.LORE), Material.RECORD_5);
}
@Override
public void update(Player wielder)
{
Location loc = wielder.getLocation();
if (ClansManager.getInstance().getClaimMap().containsKey(UtilWorld.chunkToStr(loc.getChunk())))
{
if (ClansManager.getInstance().getClaimMap().get(UtilWorld.chunkToStr(loc.getChunk())).isSafe(wielder.getLocation()))
ClanTerritory territory = ClansManager.getInstance().getClaimMap().get(UtilWorld.chunkToStr(loc));
if (territory != null && territory.isSafe(loc))
{
return;
}
}
if (isHoldingRightClick() && canPull())
{
@ -94,9 +95,9 @@ public class MagneticMaul extends LegendaryItem
if (otherTargetDistance < targetDistance && otherDistance <= PULL_RANGE)
{
// If entity is in safe zone, don't allow pulling of that entity.
if (ClansManager.getInstance().getClaimMap().containsKey(UtilWorld.chunkToStr(entity.getLocation().getChunk())))
if (ClansManager.getInstance().getClaimMap().containsKey(UtilWorld.chunkToStr(entity.getLocation())))
{
if (ClansManager.getInstance().getClaimMap().get(UtilWorld.chunkToStr(entity.getLocation().getChunk())).isSafe(entity.getLocation()))
if (ClansManager.getInstance().getClaimMap().get(UtilWorld.chunkToStr(entity.getLocation())).isSafe(entity.getLocation()))
{
continue;
}
@ -107,7 +108,7 @@ public class MagneticMaul extends LegendaryItem
}
// Do Particles
for (int i=0 ; i<6 ; i++)
for (int i = 0; i < 6; i++)
{
Vector random = new Vector(Math.random() * 4 - 2, Math.random() * 4 - 2, Math.random() * 4 - 2);

View File

@ -35,9 +35,9 @@ import org.bukkit.util.Vector;
public class MeridianScepter extends LegendaryItem
{
private long _interactWait;
private static final RGBData[] COLORS = { UtilColor.RgbPurple, UtilColor.RgbPurple.Lighten(), UtilColor.RgbPurple.Darken() };
private RGBData[] colors = { UtilColor.RgbPurple, UtilColor.RgbPurple.Lighten(), UtilColor.RgbPurple.Darken() };
private long _interactWait;
private transient HashMap<AttackAnimation, Integer> _animations = new HashMap<AttackAnimation, Integer>();
@ -53,7 +53,7 @@ public class MeridianScepter extends LegendaryItem
@Override
public void update(Player wielder)
{
if ((System.currentTimeMillis() - _lastBlock) < 98 && (System.currentTimeMillis() - _interactWait) >= 98)
if (timeSinceLastBlock() < 98 && (System.currentTimeMillis() - _interactWait) >= 98)
{
if (ClansManager.getInstance().hasTimer(wielder))
{
@ -248,7 +248,7 @@ public class MeridianScepter extends LegendaryItem
{
for (Location loc : UtilShapes.getLinesDistancedPoints(start, end, 0.06))
{
UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, loc, UtilCollections.random(colors).ToVector(), 1f, 0, ViewDist.LONG);
UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, loc, UtilCollections.random(COLORS).ToVector(), 1f, 0, ViewDist.LONG);
}
}

View File

@ -44,7 +44,7 @@ public class WindBlade extends LegendaryItem
}
}
public static final double FLIGHT_VELOCITY = 0.75d;
private static final double FLIGHT_VELOCITY = 0.75d;
private double _power;
private double _burnoutThreshold;

View File

@ -74,6 +74,11 @@ public abstract class Tutorial implements Listener, ObjectiveListener
public void start(Player player)
{
if (!canStart(player))
{
return;
}
System.out.println(String.format("Tutorial> [%s] started tutorial [%s]", player.getName(), getName()));
TutorialSession session = new TutorialSession();
@ -223,6 +228,8 @@ public abstract class Tutorial implements Listener, ObjectiveListener
*/
protected abstract void onQuit(Player player);
protected abstract boolean canStart(Player player);
public void unregisterAll()
{
HandlerList.unregisterAll(this);

View File

@ -2,6 +2,7 @@ package mineplex.game.clans.tutorial;
import java.io.File;
import java.io.IOException;
import java.util.LinkedList;
import java.util.Stack;
import org.bukkit.Bukkit;
@ -25,7 +26,7 @@ public class TutorialWorldManager extends MiniPlugin
private final World _tutorialWorld;
private final Schematic _schematic;
private Stack<TutorialRegion> _regionStack;
private LinkedList<TutorialRegion> _regionStack;
private TutorialRegion _centerRegion;
public TutorialWorldManager(JavaPlugin plugin, String worldName, String schematicName) throws IOException
@ -56,7 +57,7 @@ public class TutorialWorldManager extends MiniPlugin
private void populateRegionStack()
{
_regionStack = new Stack<>();
_regionStack = new LinkedList<>();
// Populate the stack with 100 available tutorial regions
for (int x = 0; x < 10; x++)

View File

@ -171,6 +171,18 @@ public class ClansMainTutorial extends Tutorial
*/
}
@Override
protected boolean canStart(Player player)
{
ClanInfo clan = ClansManager.getInstance().getClan(player);
if (clan != null)
{
UtilPlayer.message(player, F.main("Clans", "You are part of a clan - please leave or disband the clan before doing the tutorial"));
return false;
}
return true;
}
@Override
protected void onStart(Player player)
{
@ -205,12 +217,6 @@ public class ClansMainTutorial extends Tutorial
addHologram(player,
getPoint(region, ClansMainTutorial.Point.SPAWN).add(0, 1.5, -23),
"Jump Off!");
ClanInfo clan = ClansManager.getInstance().getClan(player);
if (clan != null)
{
ClansManager.getInstance().getClanDataAccess().delete(clan, null);
}
}
@Override
@ -464,9 +470,17 @@ public class ClansMainTutorial extends Tutorial
// });
if (!_taskManager.hasCompletedTask(event.getPlayer(), getTaskIdentifier()))
{
ClanInfo clan = ClansManager.getInstance().getClan(event.getPlayer());
if (clan == null)
{
start(event.getPlayer());
}
else
{
UtilPlayer.message(event.getPlayer(), F.main("Clans", "It seems you already have a clan here, so we can skip the tutorial"));
}
}
else if (!event.getPlayer().hasPlayedBefore() || !event.getPlayer().getLocation().getWorld().equals(Spawn.getSpawnWorld()))
{
Spawn.getInstance().teleport(event.getPlayer(), Spawn.getInstance().getSpawnLocation(), 2);

View File

@ -1,6 +1,7 @@
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
import mineplex.core.common.util.F;
import mineplex.game.clans.clans.event.ClanCreatedEvent;
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;

View File

@ -47,6 +47,7 @@ public class DisbandClanGoal extends ObjectiveGoal<FinalObjective>
{
return;
}
event.setCancelled(true);
UtilPlayer.message(event.getDisbander(), F.main("Clans", "You have disbanded your Tutorial Clan."));

View File

@ -88,6 +88,10 @@ public class Recall extends Skill
return;
Factory.runSync(() -> {
if (player.isDead())
{
return;
}
//Heal
double newHealth = Math.min(health.getLast(), player.getHealth() + 3 + level);
player.setHealth(newHealth);

View File

@ -258,7 +258,7 @@ public abstract class EventCreature<T extends LivingEntity> implements Listener
@EventHandler
public void onChunkUnload(ChunkUnloadEvent event)
{
if (_entity.getLocation().getChunk().equals(event.getChunk()))
if (_entity != null && _entity.getLocation().getChunk().equals(event.getChunk()))
event.setCancelled(true);
}

View File

@ -1,9 +1,5 @@
package nautilus.game.arcade;
import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
@ -12,13 +8,7 @@ import mineplex.core.blood.Blood;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.chat.Chat;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.*;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.creature.Creature;
import mineplex.core.customdata.CustomDataManager;
@ -45,6 +35,7 @@ import mineplex.core.pet.PetManager;
import mineplex.core.poll.PollManager;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.progression.KitProgressionManager;
import mineplex.core.projectile.ProjectileManager;
import mineplex.core.punish.Punish;
import mineplex.core.resourcepack.ResourcePackManager;
@ -73,46 +64,22 @@ import mineplex.minecraft.game.core.fire.Fire;
import nautilus.game.arcade.addons.SoupAddon;
import nautilus.game.arcade.addons.TeamArmorAddon;
import nautilus.game.arcade.addons.compass.CompassAddon;
import nautilus.game.arcade.command.DisguiseCommand;
import nautilus.game.arcade.command.GameCmdModeCommand;
import nautilus.game.arcade.command.GameCommand;
import nautilus.game.arcade.command.KitUnlockCommand;
import nautilus.game.arcade.command.RequiredRankCommand;
import nautilus.game.arcade.command.WriteCommand;
import nautilus.game.arcade.command.*;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.GameServerConfig;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.games.event.EventModule;
import nautilus.game.arcade.game.games.uhc.UHC;
import nautilus.game.arcade.managers.GameAchievementManager;
import nautilus.game.arcade.managers.GameCreationManager;
import nautilus.game.arcade.managers.GameFlagManager;
import nautilus.game.arcade.managers.GameGemManager;
import nautilus.game.arcade.managers.GameHostManager;
import nautilus.game.arcade.managers.GameLobbyManager;
import nautilus.game.arcade.managers.GameLootManager;
import nautilus.game.arcade.managers.GameManager;
import nautilus.game.arcade.managers.GamePlayerManager;
import nautilus.game.arcade.managers.GameSpectatorManager;
import nautilus.game.arcade.managers.GameStatManager;
import nautilus.game.arcade.managers.GameTestingManager;
import nautilus.game.arcade.managers.GameTournamentManager;
import nautilus.game.arcade.managers.GameWorldManager;
import nautilus.game.arcade.managers.IdleManager;
import nautilus.game.arcade.managers.MiscManager;
import nautilus.game.arcade.managers.*;
import nautilus.game.arcade.managers.chat.GameChatManager;
import nautilus.game.arcade.player.ArcadePlayer;
import nautilus.game.arcade.shop.ArcadeShop;
import net.minecraft.server.v1_8_R3.EntityLiving;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.*;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity;
@ -136,6 +103,10 @@ import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.util.Vector;
import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
public class ArcadeManager extends MiniPlugin implements IRelation
{
// Modules
@ -192,6 +163,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
private Punish _punishmentManager;
private BrandingManager _brandingManager;
private BonusManager _bonusManager;
private KitProgressionManager _kitProgressionManager;
private ProgressingKitManager _progressionKitManager;
private IncognitoManager _incognitoManager;
@ -344,6 +317,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_punishmentManager = punish;
_kitProgressionManager = new KitProgressionManager(getPlugin(), clientManager);
_progressionKitManager = new ProgressingKitManager(this);
if (GetHost() != null && !GetHost().isEmpty())
{
Bukkit.getScheduler().runTaskLater(plugin, () -> Portal.transferPlayer(GetHost(), _serverStatusManager.getCurrentServerName()), 80L);
@ -1703,4 +1679,14 @@ public class ArcadeManager extends MiniPlugin implements IRelation
return true;
}
public ProgressingKitManager getProgressionKitManager()
{
return _progressionKitManager;
}
public KitProgressionManager getKitProgressionManager()
{
return _kitProgressionManager;
}
}

View File

@ -218,7 +218,7 @@ public enum GameType
Pair<MinecraftVersion, String>[] _resourcePacks;
Class<? extends Game> _gameClass;
GameMode[] _gameModes;
private GameMode[] _gameModes;
private boolean _gameMaps;
private int _gameId; // Unique identifying id for this gamemode (used for statistics)
@ -322,14 +322,13 @@ public enum GameType
return _display.getGameCategory();
}
public String GetKitGameName()
public String GetKitGameName(Game game)
{
return _display.getKitGameName();
if (hasGamemodes())
{
return getModeGameType(game.getClass())._display.getKitGameName();
}
public boolean isUsingGameModes()
{
return _gameMaps;
return _display.getKitGameName();
}
public GameType getModeGameType(Class<? extends Game> game)
@ -343,4 +342,14 @@ public enum GameType
}
return null;
}
public boolean isUsingGameModesMaps()
{
return _gameMaps;
}
public boolean hasGamemodes()
{
return _gameModes.length != 0;
}
}

View File

@ -1,20 +1,41 @@
package nautilus.game.arcade.game;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import com.google.common.collect.Lists;
import com.mojang.authlib.GameProfile;
import mineplex.core.common.util.*;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.elo.EloPlayer;
import mineplex.core.elo.EloTeam;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.classcombat.event.ClassCombatCreatureAllowSpawnEvent;
import mineplex.minecraft.game.core.combat.DeathMessageType;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.ArcadeFormat;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.events.PlayerStateChangeEvent;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.managers.GameLobbyManager;
import nautilus.game.arcade.managers.chat.ChatStatData;
import nautilus.game.arcade.scoreboard.GameScoreboard;
import nautilus.game.arcade.stats.*;
import nautilus.game.arcade.wineffect.WinEffectManager;
import nautilus.game.arcade.world.WorldData;
import net.minecraft.server.v1_8_R3.EntityItem;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import net.minecraft.server.v1_8_R3.WorldServer;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
@ -45,57 +66,8 @@ import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Team;
import org.bukkit.util.Vector;
import com.mojang.authlib.GameProfile;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTabTitle;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.elo.EloPlayer;
import mineplex.core.elo.EloTeam;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.classcombat.event.ClassCombatCreatureAllowSpawnEvent;
import mineplex.minecraft.game.core.combat.DeathMessageType;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.ArcadeFormat;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.events.PlayerStateChangeEvent;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.managers.GameLobbyManager;
import nautilus.game.arcade.managers.chat.ChatStatData;
import nautilus.game.arcade.scoreboard.GameScoreboard;
import nautilus.game.arcade.stats.AssistsStatTracker;
import nautilus.game.arcade.stats.DamageDealtStatTracker;
import nautilus.game.arcade.stats.DamageTakenStatTracker;
import nautilus.game.arcade.stats.DeathsStatTracker;
import nautilus.game.arcade.stats.ExperienceStatTracker;
import nautilus.game.arcade.stats.GamesPlayedStatTracker;
import nautilus.game.arcade.stats.KillsStatTracker;
import nautilus.game.arcade.stats.LoseStatTracker;
import nautilus.game.arcade.stats.StatTracker;
import nautilus.game.arcade.stats.WinStatTracker;
import nautilus.game.arcade.wineffect.WinEffectManager;
import nautilus.game.arcade.world.WorldData;
import net.minecraft.server.v1_8_R3.EntityItem;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import net.minecraft.server.v1_8_R3.WorldServer;
import java.util.*;
import java.util.Map.Entry;
public abstract class Game implements Listener
{
@ -490,7 +462,7 @@ public abstract class Game implements Listener
}
}
if (GetType().isUsingGameModes())
if (GetType().isUsingGameModesMaps())
{
GameType mode = GetType().getModeGameType(getClass());
@ -687,6 +659,10 @@ public abstract class Game implements Listener
{
for (Kit kit : _kits)
{
if(kit == null)
{
continue;
}
UtilServer.getServer().getPluginManager().registerEvents(kit, Manager.getPlugin());
for (Perk perk : kit.GetPerks())
@ -701,6 +677,11 @@ public abstract class Game implements Listener
{
for (Kit kit : _kits)
{
if(kit == null)
{
continue;
}
HandlerList.unregisterAll(kit);
for (Perk perk : kit.GetPerks())
@ -728,9 +709,6 @@ public abstract class Game implements Listener
team.AddPlayer(player, in);
// Ensure Valid Kit
ValidateKit(player, team);
// Game Scoreboard
Scoreboard.SetPlayerTeam(player, team.GetName().toUpperCase());
@ -739,6 +717,9 @@ public abstract class Game implements Listener
// Save Tournament Team
Manager.GetGameTournamentManager().setTournamentTeam(player, team);
// Ensure Valid Kit
ValidateKit(player, team);
}
public GameTeam ChooseTeam(Player player)
@ -819,13 +800,48 @@ public abstract class Game implements Listener
public void ValidateKit(Player player, GameTeam team)
{
// Kit
if (GetKit(player) != null)
{
//Make sure their current kit can be used, if not, tell them.
Kit kit = GetKit(player);
if (team.KitAllowed(kit))
{
return;
}
player.sendMessage(F.main("Kit", "Your current kit is not applicable with your team. Please select a different kit"));
Optional<Kit> newKit = Lists.newArrayList(GetKits())
.stream().filter(team::KitAllowed).findFirst();
if (newKit.isPresent())
{
SetKit(player, newKit.get(), false);
return;
}
return;
}
//This IN THEORY shouldn't ever be used, but oh well.
if (GetKit(player) == null || !team.KitAllowed(GetKit(player)))
{
for (Kit kit : _kits)
{
if (kit.GetAvailability() == KitAvailability.Hide || kit.GetAvailability() == KitAvailability.Null)
{
continue;
}
//Set the default kit (if they have one selected)
if (kit instanceof ProgressingKit)
{
ProgressingKit progressingKit = (ProgressingKit) kit;
if (team.KitAllowed(progressingKit))
{
if (progressingKit.isDefault(player.getUniqueId()))
{
SetKit(player, progressingKit, true);
break;
}
}
}
if (team.KitAllowed(kit))
{
@ -868,8 +884,14 @@ public abstract class Game implements Listener
}
if (InProgress())
{
kit.ApplyKit(player);
}
else
{
player.closeInventory();
}
}
public Kit GetKit(Player player)
{

View File

@ -48,7 +48,7 @@ public class AbsorptionFix implements Listener
{
player.removePotionEffect(PotionEffectType.ABSORPTION);
player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()));
player.setHealth(player.getMaxHealth());
player.setHealth(player.getHealth() + 4);
}
}
}

View File

@ -1,5 +1,17 @@
package nautilus.game.arcade.game.games.baconbrawl.kits;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguisePig;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkBaconBlast;
import nautilus.game.arcade.kit.perks.PerkSpeed;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
@ -10,37 +22,25 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguisePig;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkBaconBlast;
import nautilus.game.arcade.kit.perks.PerkSpeed;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
public class KitMamaPig extends Kit
public class KitMamaPig extends ProgressingKit
{
private static final String[] DESCRIPTION = {
"Mama & Baby Piggles fight together",
"",
click(false, C.cWhite + "Axe to use " + C.cGreen + "Bacon Blast"),
};
private static final ItemStack IN_HAND = new ItemStack(Material.PORK);
private static final Perk[] PERKS = {
new PerkBaconBlast(),
new PerkSpeed(1)
};
public KitMamaPig(ArcadeManager manager)
{
super(manager, "Mama Piggles", KitAvailability.Gem,
new String[]
{
"Mama & Baby Piggles fight together!"
},
new Perk[]
{
new PerkBaconBlast(),
new PerkSpeed(1),
},
EntityType.PIG,
new ItemStack(Material.PORK));
super(manager, "Mama Piggles", "mamapiggles", KitAvailability.Gem, DESCRIPTION, PERKS, EntityType.PIG, IN_HAND);
}
@Override
@ -64,30 +64,29 @@ public class KitMamaPig extends Kit
player.setPassenger(pig);
Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable()
{
@Override
public void run()
{
UtilPlayer.sendPacket(player, new PacketPlayOutEntityDestroy(new int[] { pig.getEntityId() }));
}
}, 2);
Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), () -> UtilPlayer.sendPacket(player, new PacketPlayOutEntityDestroy(new int[]{pig.getEntityId()})), 2);
}
@EventHandler(priority=EventPriority.LOWEST)
@EventHandler(priority = EventPriority.LOWEST)
public void damageTransfer(CustomDamageEvent event)
{
if (event.IsCancelled())
{
return;
}
if (!(event.GetDamageeEntity() instanceof Pig))
{
return;
}
Pig pig = (Pig)event.GetDamageeEntity();
Pig pig = (Pig) event.GetDamageeEntity();
if (pig.getVehicle() == null || !(pig.getVehicle() instanceof LivingEntity))
{
return;
}
event.setDamagee((LivingEntity)pig.getVehicle());
event.setDamagee((LivingEntity) pig.getVehicle());
}
}

View File

@ -1,37 +1,36 @@
package nautilus.game.arcade.game.games.baconbrawl.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.disguise.disguises.DisguisePig;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkBodySlam;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class KitPig extends Kit
public class KitPig extends ProgressingKit
{
private static final String[] DESCRIPTION = {
"Such a fat pig. Oink",
"",
click(false, "Axe to " + C.cGreen + "Body Slam"),
};
private static final Perk[] PERKS = {
new PerkBodySlam(6, 2),
};
private static final ItemStack IN_HAND = new ItemStack(Material.PORK);
public KitPig(ArcadeManager manager)
{
super(manager, "El Muchacho Pigo", KitAvailability.Free,
new String[]
{
"Such a fat pig. Oink."
},
new Perk[]
{
new PerkBodySlam(6, 2),
//new PerkJump(1), MAC
},
EntityType.PIG,
new ItemStack(Material.PORK));
super(manager, "El Muchacho Pigo", "elmuchachopigo", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.PIG, IN_HAND);
}
@Override

View File

@ -1,44 +1,41 @@
package nautilus.game.arcade.game.games.baconbrawl.kits;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.disguise.disguises.DisguiseSheep;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkBackstabKnockback;
import nautilus.game.arcade.kit.perks.PerkPigCloak;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.*;
import org.bukkit.inventory.ItemStack;
public class KitSheepPig extends Kit
public class KitSheepPig extends ProgressingKit
{
public KitSheepPig(ArcadeManager manager)
{
super(manager, "Pig", KitAvailability.Gem, 5000,
new String[]
{
"\"...Oink?\""
},
private static final String[] DESCRIPTION = {
"\"...Oink?\"",
"",
click(false, "Axe to " + C.cGreen + "Cloak"),
"Deal " + C.cGreen + "+250%" + C.cWhite + " Knockback from behind opponents."
};
new Perk[]
{
private static final Perk[] PERKS = {
new PerkPigCloak(),
new PerkBackstabKnockback()
},
EntityType.SHEEP,
new ItemStack(Material.WOOL));
};
private static final ItemStack IN_HAND = new ItemStack(Material.WOOL, 1, DyeColor.PINK.getWoolData());
public KitSheepPig(ArcadeManager manager)
{
super(manager, "Pig", "wolfpig", KitAvailability.Gem, 5000, DESCRIPTION, PERKS, EntityType.SHEEP, IN_HAND);
}
@Override
@ -59,7 +56,9 @@ public class KitSheepPig extends Kit
{
EntityType type = _entityType;
if (type == EntityType.PLAYER)
{
type = EntityType.ZOMBIE;
}
LivingEntity entity = (LivingEntity) Manager.GetCreature().SpawnEntity(loc, type);
@ -70,7 +69,7 @@ public class KitSheepPig extends Kit
if (type == EntityType.SHEEP)
{
Sheep sheep = (Sheep)entity;
Sheep sheep = (Sheep) entity;
sheep.setColor(DyeColor.PINK);
}

View File

@ -1,50 +1,56 @@
package nautilus.game.arcade.game.games.barbarians.kits;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkFletcher;
import nautilus.game.arcade.kit.perks.PerkRopedArrow;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkFletcher;
import nautilus.game.arcade.kit.perks.PerkRopedArrow;
public class KitArcher extends Kit
public class KitArcher extends ProgressingKit
{
private static final String[] DESCRIPTION = {
"Uses some kind of less barbaric ranged weapon"
};
private static final Perk[] PERKS = {
new PerkRopedArrow("Roped Arrow", 1, 6000),
new PerkFletcher(2, 2, true)
};
private static final ItemStack[] PLAYER_ITEMS = {
ItemStackFactory.Instance.CreateStack(Material.IRON_AXE),
ItemStackFactory.Instance.CreateStack(Material.BOW),
ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP),
ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)
};
private static final ItemStack[] ARMOR = {
ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET),
ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE),
ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS),
ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS)
};
private static final ItemStack IN_HAND = new ItemStack(Material.BOW);
public KitArcher(ArcadeManager manager)
{
super(manager, "Barbarian Archer", KitAvailability.Gem,
new String[]
{
"Uses some kind of less barbaric ranged weapon..."
},
new Perk[]
{
new PerkRopedArrow("Roped Arrow", 1, 6000),
new PerkFletcher(2, 2, true),
},
EntityType.PLAYER,
new ItemStack(Material.BOW));
super(manager, "Barbarian Archer", "barbarianarcher", KitAvailability.Gem, DESCRIPTION, PERKS, EntityType.PLAYER, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET));
player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE));
player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS));
player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS));
player.getInventory().addItem(PLAYER_ITEMS);
player.getInventory().setArmorContents(ARMOR);
}
@Override

View File

@ -1,52 +1,57 @@
package nautilus.game.arcade.game.games.barbarians.kits;
import mineplex.core.common.util.F;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkBomber;
import nautilus.game.arcade.kit.perks.PerkLeap;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.F;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.*;
public class KitBomber extends Kit
public class KitBomber extends ProgressingKit
{
public KitBomber(ArcadeManager manager)
{
super(manager, "Bomber", KitAvailability.Gem, 5000,
new String[]
{
private static final String[] DESCRIPTION = {
"Crazy bomb throwing barbarian. BOOM!"
},
};
new Perk[]
{
private static final Perk[] PERKS = {
new PerkBomber(8, 2, -1),
new PerkLeap("Leap", 1, 1, 8000)
},
EntityType.ZOMBIE,
new ItemStack(Material.TNT));
};
private static final ItemStack[] PLAYER_ITEMS = {
ItemStackFactory.Instance.CreateStack(Material.IRON_AXE),
ItemStackFactory.Instance.CreateStack(Material.TNT, (byte) 0, 1, F.item("Throwing TNT")),
ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP),
ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)
};
private static final ItemStack[] ARMOR = {
ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET),
ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE),
ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS),
ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS)
};
private static final ItemStack IN_HAND = new ItemStack(Material.TNT);
public KitBomber(ArcadeManager manager)
{
super(manager, "Bomber", "barbarianbomber", KitAvailability.Gem, 5000, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.TNT, (byte)0, 1, F.item("Throwing TNT")));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET));
player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE));
player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS));
player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS));
player.getInventory().addItem(PLAYER_ITEMS);
player.getInventory().setArmorContents(ARMOR);
}
@Override

View File

@ -1,48 +1,54 @@
package nautilus.game.arcade.game.games.barbarians.kits;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkBodySlam;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkBodySlam;
public class KitBrute extends Kit
public class KitBrute extends ProgressingKit
{
private static final String[] DESCRIPTION = {
"A true barbarian, loves to kill people!"
};
private static final Perk[] PERKS = {
new PerkBodySlam(8, 2)
};
private static final ItemStack[] PLAYER_ITEMS = {
ItemStackFactory.Instance.CreateStack(Material.IRON_AXE),
ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP),
ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP),
ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)
};
private static final ItemStack[] ARMOR = {
ItemStackFactory.Instance.CreateStack(Material.IRON_HELMET),
ItemStackFactory.Instance.CreateStack(Material.IRON_CHESTPLATE),
ItemStackFactory.Instance.CreateStack(Material.IRON_LEGGINGS),
ItemStackFactory.Instance.CreateStack(Material.IRON_BOOTS)
};
private static final ItemStack IN_HAND = new ItemStack(Material.IRON_AXE);
public KitBrute(ArcadeManager manager)
{
super(manager, "Barbarian Brute", KitAvailability.Free,
new String[]
{
"A true barbarian, loves to kill people!"
},
new Perk[]
{
new PerkBodySlam(8, 2)
},
EntityType.PLAYER,
new ItemStack(Material.IRON_AXE));
super(manager, "Barbarian Brute", "barbarianbrute", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.PLAYER, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(Material.IRON_HELMET));
player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(Material.IRON_CHESTPLATE));
player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.IRON_LEGGINGS));
player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.IRON_BOOTS));
player.getInventory().addItem(PLAYER_ITEMS);
player.getInventory().setArmorContents(ARMOR);
}
@Override

View File

@ -1,75 +1,10 @@
package nautilus.game.arcade.game.games.bridge;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.GameMode;
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.block.Chest;
import org.bukkit.craftbukkit.v1_8_R3.block.CraftBlock;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Cow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Item;
import org.bukkit.entity.Pig;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerBucketFillEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.Vector;
import com.google.common.collect.Lists;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.*;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.explosion.ExplosionEvent;
import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -82,21 +17,34 @@ import nautilus.game.arcade.events.PlayerDeathOutEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.bridge.kits.KitApple;
import nautilus.game.arcade.game.games.bridge.kits.KitArcher;
import nautilus.game.arcade.game.games.bridge.kits.KitBeserker;
import nautilus.game.arcade.game.games.bridge.kits.KitBomber;
import nautilus.game.arcade.game.games.bridge.kits.KitDestructor;
import nautilus.game.arcade.game.games.bridge.kits.KitMammoth;
import nautilus.game.arcade.game.games.bridge.kits.KitMiner;
import nautilus.game.arcade.game.games.bridge.kits.*;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.ore.OreHider;
import nautilus.game.arcade.ore.OreObsfucation;
import nautilus.game.arcade.stats.BridgesSniperStatTracker;
import nautilus.game.arcade.stats.DeathBomberStatTracker;
import nautilus.game.arcade.stats.FoodForTheMassesStatTracker;
import nautilus.game.arcade.stats.KillFastStatTracker;
import nautilus.game.arcade.stats.TntMinerStatTracker;
import nautilus.game.arcade.stats.*;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Chest;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.event.player.*;
import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.Vector;
import java.util.*;
public class Bridge extends TeamGame implements OreObsfucation
{
@ -186,7 +134,8 @@ public class Bridge extends TeamGame implements OreObsfucation
new Kit[]
{
new KitApple(manager),
new KitBeserker(manager),
new KitBerserker(manager),
new KitBrawler(manager),
new KitMammoth(manager),
new KitArcher(manager),
new KitMiner(manager),
@ -201,6 +150,28 @@ public class Bridge extends TeamGame implements OreObsfucation
"The last team alive wins!"
});
List<Kit> kits = Lists.newArrayList(GetKits());
List<Kit> finalKits = Lists.newArrayList(kits);
boolean foundBrawler = false;
for(int i = 0; i < kits.size(); i++)
{
Kit kit = kits.get(i);
if(kit.GetName().equalsIgnoreCase("Brawler"))
{
if(!foundBrawler)
{
foundBrawler = true;
}
else
{
finalKits.remove(i);
}
}
}
setKits(finalKits.toArray(new Kit[finalKits.size()]));
_ore = new OreHider();
// Flags
@ -258,28 +229,6 @@ public class Bridge extends TeamGame implements OreObsfucation
_tournament = Manager.IsTournamentServer();
}
@EventHandler
public void blockTntDupe(InventoryClickEvent event)
{
Player player = (Player) event.getWhoClicked();
ItemStack itemStack = event.getCurrentItem();
InventoryView view = player.getOpenInventory();
if(view.getTopInventory() == null || itemStack == null || itemStack.getType() != Material.TNT)
{
return;
}
if(event.getClickedInventory() == null)
{
return;
}
if(event.getClickedInventory().getType() == InventoryType.PLAYER)
{
return;
}
event.setCancelled(true);
}
@EventHandler
public void PlayerOut(final PlayerDeathOutEvent event)
{

View File

@ -1,34 +1,34 @@
package nautilus.game.arcade.game.games.bridge.kits;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkApple;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.*;
public class KitApple extends Kit
public class KitApple extends ProgressingKit
{
private static final String[] DESCRIPTION = {
"Possess the rare skill of finding apples frequently!",
"",
receiveItem("apple", 1, 10, 0),
click(true, "the apple to throw it")
};
private static final Perk[] PERKS = {
new PerkApple()
};
private static final ItemStack IN_HAND = new ItemStack(Material.APPLE);
public KitApple(ArcadeManager manager)
{
super(manager, "Apple", KitAvailability.Free,
new String[]
{
"Possess the rare skill of finding apples frequently!"
},
new Perk[]
{
new PerkApple(manager)
},
EntityType.ZOMBIE,
new ItemStack(Material.APPLE));
super(manager, "Apple", "bridgeapple", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND);
}
@Override

View File

@ -1,37 +1,45 @@
package nautilus.game.arcade.game.games.bridge.kits;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.bridge.Bridge;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkBarrage;
import nautilus.game.arcade.kit.perks.PerkFletcher;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class KitArcher extends Kit
public class KitArcher extends ProgressingKit
{
public KitArcher(ArcadeManager manager)
{
super(manager, "Archer", KitAvailability.Gem,
new String[]
{
"Highly trained with a bow, probably an elf or something..."
},
private static final String[] DESCRIPTION = {
"Highly trained with a bow, probably an elf or something...",
" ",
"Begin the game with a Bow",
receiveArrowString(1, 20, 3),
"Charge Bow to use " + C.cGreen + "Barrage"
};
new Perk[]
{
private static final Perk[] PERKS = {
new PerkFletcher(20, 3, true),
new PerkBarrage(5, 250, true, false),
},
EntityType.ZOMBIE,
new ItemStack(Material.BOW));
};
private static final ItemStack[] PLAYER_ITEMS = {
ItemStackFactory.Instance.CreateStack(Material.BOW)
};
private static final ItemStack IN_HAND = new ItemStack(Material.BOW);
public KitArcher(ArcadeManager manager)
{
super(manager, "Archer", "bridgearcher", KitAvailability.Gem, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND);
}

View File

@ -0,0 +1,49 @@
package nautilus.game.arcade.game.games.bridge.kits;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkAxeman;
import nautilus.game.arcade.kit.perks.PerkLeap;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class KitBerserker extends ProgressingKit
{
private static final String[] DESCRIPTION = {
"Agile warrior trained in the ways of axe combat.",
" ",
"Begin with a Stone Axe",
"Deal " + C.cGreen + "+1" + C.cWhite + " damage using axes",
click(false, " with your axe to use " + C.cGreen + "Berserker Leap")
};
private static final Perk[] PERKS = {
new PerkLeap("Beserker Leap", 1.2, 1.2, 8000),
new PerkAxeman(),
};
private static final ItemStack[] PLAYER_ITEMS = {
ItemStackFactory.Instance.CreateStack(Material.STONE_AXE)
};
private static final ItemStack IN_HAND = new ItemStack(Material.STONE_AXE);
public KitBerserker(ArcadeManager manager)
{
super(manager, "Berserker", "bridgeberserker", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(PLAYER_ITEMS);
}
}

View File

@ -1,49 +0,0 @@
package nautilus.game.arcade.game.games.bridge.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.bridge.Bridge;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.*;
public class KitBeserker extends Kit
{
public KitBeserker(ArcadeManager manager)
{
super(manager, "Beserker", KitAvailability.Free,
new String[]
{
"Agile warrior trained in the ways of axe combat."
},
new Perk[]
{
new PerkLeap("Beserker Leap", 1.2, 1.2, 8000),
new PerkAxeman(),
},
EntityType.ZOMBIE,
new ItemStack(Material.STONE_AXE));
}
@Override
public void GiveItems(Player player)
{
if(!(Manager.GetGame() instanceof Bridge))
{
return;
}
Bridge bridge = (Bridge) Manager.GetGame();
if(!bridge.hasUsedRevive(player))
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_AXE));
}
}

View File

@ -1,34 +1,35 @@
package nautilus.game.arcade.game.games.bridge.kits;
import mineplex.core.common.util.C;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkBomber;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.*;
public class KitBomber extends Kit
public class KitBomber extends ProgressingKit
{
private static final String[] DESCRIPTION = {
"Crazy bomb throwing guy.",
" ",
receiveItem("TNT", 1, 30, 2),
C.cYellow + "Click" + C.cWhite + " to throw TNT"
};
private static final Perk[] PERKS = {
new PerkBomber(30, 2, -1)
};
private static final ItemStack IN_HAND = new ItemStack(Material.TNT);
public KitBomber(ArcadeManager manager)
{
super(manager, "Bomber", KitAvailability.Gem, 5000,
new String[]
{
"Crazy bomb throwing guy."
},
new Perk[]
{
new PerkBomber(30, 2, -1)
},
EntityType.ZOMBIE,
new ItemStack(Material.TNT));
super(manager, "Bomber", "bridgebomber", KitAvailability.Gem, 5000, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND);
}
@Override

View File

@ -0,0 +1,50 @@
package nautilus.game.arcade.game.games.bridge.kits;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkIronSkin;
import nautilus.game.arcade.kit.perks.PerkMammoth;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class KitBrawler extends ProgressingKit
{
private static final String[] DESCRIPTION = {
"Giant and muscular, easily smacks others around.",
" ",
"Begin with an Iron Sword",
"Take " + C.cGreen + "75%" + C.cWhite + " knockback",
"Deal " + C.cGreen + "125%" + C.cWhite + " knockback",
"Take " + C.cGreen + "-1" + C.cWhite + " damage from all attacks"
};
private static final Perk[] PERKS = {
new PerkMammoth(),
new PerkIronSkin(1)
};
private static final ItemStack[] PLAYER_ITEMS = {
ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD)
};
private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD);
public KitBrawler(ArcadeManager manager)
{
super(manager, "Brawler", "bridgebrawler", KitAvailability.Gem, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(PLAYER_ITEMS);
}
}

View File

@ -1,44 +1,50 @@
package nautilus.game.arcade.game.games.bridge.kits;
import mineplex.core.achievement.Achievement;
import mineplex.core.common.util.C;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkDestructor;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.achievement.Achievement;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.*;
public class KitDestructor extends Kit
public class KitDestructor extends ProgressingKit
{
public KitDestructor(ArcadeManager manager)
{
super(manager, "Destructor", KitAvailability.Achievement, 99999,
new String[]
{
"Has the ability to make the world crumble!"
},
private static final String[] DESCRIPTION = {
"Has the ability to make the world crumble!",
" ",
receiveItem("Seismic Charge", 1, 40, 2),
C.cYellow + "Right-Click" + C.cWhite + " with Seismic Charge to " + C.cGreen + "Throw Seismic Charge",
new Perk[]
{
"",
C.cRed + "Seismic Charges begin after bridges drop"
};
private static final Perk[] PERKS = {
new PerkDestructor(40, 2, 400, false)
},
EntityType.ZOMBIE,
new ItemStack(Material.ENDER_PEARL));
};
this.setAchievementRequirements(new Achievement[]
{
private static final Achievement[] ACHIEVEMENTS = {
Achievement.BRIDGES_DEATH_BOMBER,
Achievement.BRIDGES_FOOD,
Achievement.BRIDGES_FORTUNE_BOMBER,
Achievement.BRIDGES_RAMPAGE,
Achievement.BRIDGES_SNIPER,
Achievement.BRIDGES_WINS
});
};
private static final ItemStack IN_HAND = new ItemStack(Material.ENDER_PEARL);
public KitDestructor(ArcadeManager manager)
{
super(manager, "Destructor", "bridgedesctructor", KitAvailability.Achievement, 99999, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND);
this.setAchievementRequirements(ACHIEVEMENTS);
}
@Override

View File

@ -1,36 +1,45 @@
package nautilus.game.arcade.game.games.bridge.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.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.bridge.Bridge;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.*;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.kit.perks.PerkDigger;
import nautilus.game.arcade.kit.perks.PerkOreFinder;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class KitMiner extends Kit
public class KitMiner extends ProgressingKit
{
public KitMiner(ArcadeManager manager)
{
super(manager, "Miner", KitAvailability.Gem, 5000,
new String[]
{
"Master of ore prospecting and digging quickly."
},
private static final String[] DESCRIPTION = {
"Master of ore prospecting and digging quickly.",
" ",
"Begin with a Stone Pickaxe",
"Receive " + C.cGreen + "Haste 2",
click(false, "your pickaxe to " + C.cGreen + "find ores"),
};
new Perk[]
{
private static final Perk[] PERKS = {
new PerkOreFinder(),
new PerkDigger(),
},
EntityType.ZOMBIE,
new ItemStack(Material.STONE_PICKAXE));
};
private static final ItemStack[] PLAYER_ITEMS = {
ItemStackFactory.Instance.CreateStack(Material.STONE_PICKAXE)
};
private static final ItemStack IN_HAND = new ItemStack(Material.STONE_PICKAXE);
public KitMiner(ArcadeManager manager)
{
super(manager, "Miner", "bridgeminer", KitAvailability.Gem, 5000, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND);
}

View File

@ -13,6 +13,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
@ -21,6 +22,7 @@ import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionType;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.ArcadeManager;
@ -49,6 +51,8 @@ public class OverpoweredBridge extends Bridge
WorldBoundaryKill = true;
Manager.GetDamage().SetEnabled(false);
new AbsorptionFix(this);
}
@ -128,6 +132,10 @@ public class OverpoweredBridge extends Bridge
public void supplyChest(PlayerPrepareTeleportEvent event)
{
Location chestLoc = event.GetPlayer().getLocation().clone().add(0, 0, 1);
while (chestLoc.getBlock().getType() == Material.CHEST)
chestLoc.add(2, 0, 0);
_starterChests.put(event.GetPlayer(), chestLoc);
Block block = chestLoc.getBlock();
@ -136,8 +144,9 @@ public class OverpoweredBridge extends Bridge
Chest chest = (Chest) block.getState();
event.GetPlayer().getLocation().getBlock().setType(Material.WALL_SIGN);
Sign sign = (Sign) event.GetPlayer().getLocation().getBlock().getState();
Block signBlock = chestLoc.clone().add(0, 0, -1).getBlock();
signBlock.setType(Material.WALL_SIGN);
Sign sign = (Sign) signBlock.getState();
sign.setLine(0, "§b=============");
sign.setLine(1, "§4§l" + event.GetPlayer().getName() + ChatColor.RESET + "§4's");
sign.setLine(2, "§4Supply Chest");
@ -182,19 +191,19 @@ public class OverpoweredBridge extends Bridge
if (event.getClickedBlock().getType() != Material.CHEST)
return;
for (Player player : _starterChests.keySet())
{
if (player == event.getPlayer())
continue;
if (_starterChests.get(player).getBlock().getLocation()
.equals(event.getClickedBlock().getLocation()))
{
if (disallow(event.getPlayer(), event.getClickedBlock()))
event.setCancelled(true);
break;
}
}
}
@EventHandler
public void placeChest(BlockPlaceEvent event)
{
if (event.getBlockPlaced().getType() != Material.CHEST)
return;
if (disallow(event.getPlayer(), event.getBlock()))
event.setCancelled(true);
}
@EventHandler
@ -220,6 +229,32 @@ public class OverpoweredBridge extends Bridge
}
}
private boolean disallow(Player clicker, Block block)
{
for (Player player : _starterChests.keySet())
{
System.out.println("test4");
if (player == clicker)
continue;
System.out.println("test2");
Location chest = _starterChests.get(player);
if (chest.getBlock().getLocation().equals(block.getLocation()))
{
System.out.println("test1");
return true;
}
for (Block surround : UtilBlock.getSurrounding(block, false))
{
if(chest.getBlock().getLocation().equals(surround.getLocation()))
return true;
}
}
return false;
}
@Override
public void ParseOre(ArrayList<Location> teamOre)
{

View File

@ -9,14 +9,6 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.games.bridge.Bridge;
import nautilus.game.arcade.game.games.bridge.kits.KitApple;
import nautilus.game.arcade.game.games.bridge.kits.KitArcher;
import nautilus.game.arcade.game.games.bridge.kits.KitBeserker;
import nautilus.game.arcade.game.games.bridge.kits.KitBomber;
import nautilus.game.arcade.game.games.bridge.kits.KitDestructor;
import nautilus.game.arcade.game.games.bridge.kits.KitMammoth;
import nautilus.game.arcade.game.games.bridge.kits.KitMiner;
import nautilus.game.arcade.kit.Kit;
/**
* SpeedBridges gamemode for Bridges

View File

@ -1,31 +1,28 @@
package nautilus.game.arcade.game.games.build.kits;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
public class KitBuilder extends Kit
public class KitBuilder extends ProgressingKit
{
private static final String[] DESCRIPTION = {
"Can I build it!? Yes I can!"
};
private static final Perk[] PERKS = {};
private static final ItemStack IN_HAND = new ItemStack(Material.WOOD);
public KitBuilder(ArcadeManager manager)
{
super(manager, "Builder", KitAvailability.Free,
new String[]
{
"Can I build it!? Yes I can!"
},
new Perk[]
{
},
EntityType.SKELETON,
new ItemStack(Material.WOOD));
super(manager, "Builder", "buildbuilder", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.SKELETON, IN_HAND);
}

View File

@ -1,22 +1,18 @@
package nautilus.game.arcade.game.games.castlesiege.kits;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
public abstract class KitHuman extends Kit
public abstract class KitHuman extends ProgressingKit
{
public KitHuman(ArcadeManager manager, String name, KitAvailability kitAvailability, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand)
{
super(manager, name, kitAvailability, kitDesc, kitPerks, entityType, itemInHand);
super(manager, name, name.toLowerCase().replace(" ", ""), kitAvailability, kitDesc, kitPerks, entityType, itemInHand);
}
public KitHuman(ArcadeManager manager, String name, KitAvailability kitAvailability, int cost, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand)
{
super(manager, name, kitAvailability, cost, kitDesc, kitPerks, entityType, itemInHand);
}
}

View File

@ -1,81 +0,0 @@
package nautilus.game.arcade.game.games.castlesiege.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkFletcher;
import nautilus.game.arcade.kit.perks.PerkLeap;
import nautilus.game.arcade.kit.perks.PerkPowershot;
import nautilus.game.arcade.kit.perks.PerkRegeneration;
public class KitHumanAssassin extends KitHuman
{
public KitHumanAssassin(ArcadeManager manager)
{
super(manager, "Castle Assassin", KitAvailability.Gem, 5000,
new String[]
{
"Able to kill with a single shot!"
},
new Perk[]
{
new PerkFletcher(2, 4, false),
new PerkLeap("Leap", 1.2, 1, 8000),
new PerkPowershot(5, 400),
new PerkRegeneration(0),
},
EntityType.ZOMBIE,
new ItemStack(Material.BOW));
}
@EventHandler
public void FireItemResist(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
if (Manager.GetGame() == null)
return;
for (Player player : Manager.GetGame().GetPlayers(true))
{
if (!HasKit(player))
continue;
Manager.GetCondition().Factory().FireItemImmunity(GetName(), player, player, 1.9, false);
}
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_AXE));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW));
player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(Material.LEATHER_HELMET));
player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(Material.LEATHER_CHESTPLATE));
player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.LEATHER_LEGGINGS));
player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.LEATHER_BOOTS));
}
@Override
public void SpawnCustom(LivingEntity ent)
{
ent.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET));
ent.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
ent.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS));
}
}

View File

@ -1,82 +0,0 @@
package nautilus.game.arcade.game.games.castlesiege.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkCleave;
import nautilus.game.arcade.kit.perks.PerkKnockbackGive;
import nautilus.game.arcade.kit.perks.PerkSeismicSlamCS;
public class KitHumanBrawler extends KitHuman
{
public KitHumanBrawler(ArcadeManager manager)
{
super(manager, "Castle Brawler", KitAvailability.Gem, 5000,
new String[]
{
"Extremely tanky, can smash the undead around."
},
new Perk[]
{
new PerkSeismicSlamCS(),
new PerkCleave(0.75, true),
},
EntityType.ZOMBIE, new ItemStack(Material.IRON_AXE));
}
@EventHandler
public void FireItemResist(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
if (Manager.GetGame() == null)
return;
for (Player player : Manager.GetGame().GetPlayers(true))
{
if (!HasKit(player))
continue;
Manager.GetCondition().Factory().FireItemImmunity(GetName(), player, player, 1.9, false);
}
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.ARROW, 16));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_HELMET));
player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_CHESTPLATE));
player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_LEGGINGS));
player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BOOTS));
}
@Override
public void SpawnCustom(LivingEntity ent)
{
ent.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET));
ent.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
ent.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS));
ent.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS));
}
}

View File

@ -1,5 +1,15 @@
package nautilus.game.arcade.game.games.castlesiege.kits;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkConstructor;
import nautilus.game.arcade.kit.perks.PerkMammoth;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
@ -7,35 +17,45 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.F;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.*;
public class KitHumanKnight extends KitHuman
{
public KitHumanKnight(ArcadeManager manager)
{
super(manager, "Castle Knight", KitAvailability.Gem,
new String[]
{
"Robust knight, also able to construct defenses."
},
private static final String[] DESCRIPTION = {
"Robust knight, also able to construct defenses.",
" ",
receiveItem("oak fence", 1, 40, 2),
"Take " + C.cGreen + "75%" + C.cWhite + " knockback",
"Deal " + C.cGreen + "125%" + C.cWhite + " knockback",
};
new Perk[]
{
private static final Perk[] PERKS = {
new PerkMammoth(),
new PerkConstructor("Constructor", 40, 2, Material.FENCE, "Castle Barricade", true)
},
};
EntityType.ZOMBIE, new ItemStack(Material.IRON_SWORD));
private static final ItemStack[] PLAYER_ITEMS = {
ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD),
ItemStackFactory.Instance.CreateStack(Material.BOW),
ItemStackFactory.Instance.CreateStack(Material.ARROW, 64),
ItemStackFactory.Instance.CreateStack(Material.FENCE, (byte) 0, 2, F.item("Castle Barricade")),
ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP),
ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP),
ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP),
ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)
};
private static final ItemStack[] ARMOR = {
ItemStackFactory.Instance.CreateStack(Material.IRON_HELMET),
ItemStackFactory.Instance.CreateStack(Material.IRON_CHESTPLATE),
ItemStackFactory.Instance.CreateStack(Material.IRON_LEGGINGS),
ItemStackFactory.Instance.CreateStack(Material.IRON_BOOTS)
};
public static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD);
public KitHumanKnight(ArcadeManager manager)
{
super(manager, "Castle Knight", KitAvailability.Gem, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND);
}
@EventHandler
@ -59,21 +79,8 @@ public class KitHumanKnight extends KitHuman
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.ARROW, 64));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.FENCE, (byte)0, 2, F.item("Castle Barricade")));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(Material.IRON_HELMET));
player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(Material.IRON_CHESTPLATE));
player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.IRON_LEGGINGS));
player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.IRON_BOOTS));
player.getInventory().addItem(PLAYER_ITEMS);
player.getInventory().setArmorContents(ARMOR);
}
@Override

View File

@ -1,5 +1,14 @@
package nautilus.game.arcade.game.games.castlesiege.kits;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkBarrage;
import nautilus.game.arcade.kit.perks.PerkFletcher;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
@ -7,48 +16,62 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkBarrage;
import nautilus.game.arcade.kit.perks.PerkFletcher;
public class KitHumanMarksman extends KitHuman
{
public KitHumanMarksman(ArcadeManager manager)
{
super(manager, "Castle Marksman", KitAvailability.Free,
new String[]
{
"Skilled human marksman, can fletch arrows."
},
new Perk[]
{
private static final String[] DESCRIPTION = {
"Skilled human marksman, can fletch arrows.",
" ",
receiveArrowString(1, 2, 4),
"Charge your Bow to use " + C.cGreen + "Barrage"
};
private static final Perk[] PERKS = {
new PerkBarrage(5, 250, true, false),
new PerkFletcher(2, 4, false),
},
EntityType.ZOMBIE,
new ItemStack(Material.BOW));
};
private static final ItemStack[] PLAYER_ITEMS = {
ItemStackFactory.Instance.CreateStack(Material.STONE_SWORD),
ItemStackFactory.Instance.CreateStack(Material.BOW),
ItemStackFactory.Instance.CreateStack(Material.ARROW, 32),
ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP),
ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)
};
private static final ItemStack[] ARMOR = {
ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET),
ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE),
ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS),
ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS)
};
public static final ItemStack IN_HAND = new ItemStack(Material.BOW);
public KitHumanMarksman(ArcadeManager manager)
{
super(manager, "Castle Marksman", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND);
}
@EventHandler
public void FireItemResist(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
{
return;
}
if (Manager.GetGame() == null)
{
return;
}
for (Player player : Manager.GetGame().GetPlayers(true))
{
if (!HasKit(player))
{
continue;
}
Manager.GetCondition().Factory().FireItemImmunity(GetName(), player, player, 1.9, false);
}
@ -57,16 +80,8 @@ public class KitHumanMarksman extends KitHuman
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_SWORD));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.ARROW, 32));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET));
player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE));
player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS));
player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS));
player.getInventory().addItem(PLAYER_ITEMS);
player.getInventory().setArmorContents(ARMOR);
}
@Override

View File

@ -1,58 +1,62 @@
package nautilus.game.arcade.game.games.castlesiege.kits;
import mineplex.core.disguise.disguises.DisguiseWolf;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkKnockbackGive;
import nautilus.game.arcade.kit.perks.PerkStrength;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import mineplex.core.disguise.disguises.DisguisePig;
import mineplex.core.disguise.disguises.DisguisePigZombie;
import mineplex.core.disguise.disguises.DisguiseWolf;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkKnockbackGive;
import nautilus.game.arcade.kit.perks.PerkStrength;
public class KitHumanPeasant extends KitHuman
{
public KitHumanPeasant(ArcadeManager manager)
{
super(manager, "Castle Wolf", KitAvailability.Hide,
new String[]
{
private static final String[] DESCRIPTION = {
"OINK! OINK!"
},
};
new Perk[]
{
private static final Perk[] PERKS = {
new PerkStrength(1),
new PerkKnockbackGive(2)
},
};
EntityType.ZOMBIE, new ItemStack(Material.IRON_HOE));
private static final ItemStack[] PLAYER_ITEMS = {
ItemStackFactory.Instance.CreateStack(Material.BONE, (byte) 0, 0, "Wolf Bite")
};
public static final ItemStack IN_HAND = new ItemStack(Material.IRON_HOE);
public KitHumanPeasant(ArcadeManager manager)
{
super(manager, "Castle Wolf", KitAvailability.Hide, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND);
}
@EventHandler
public void FireItemResist(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
{
return;
}
if (Manager.GetGame() == null)
{
return;
}
for (Player player : Manager.GetGame().GetPlayers(true))
{
if (!HasKit(player))
{
continue;
}
Manager.GetCondition().Factory().FireItemImmunity(GetName(), player, player, 1.9, false);
}
@ -61,7 +65,7 @@ public class KitHumanPeasant extends KitHuman
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BONE, (byte)0, 0, "Wolf Bite"));
player.getInventory().addItem(PLAYER_ITEMS);
player.setHealth(4);

View File

@ -1,22 +1,21 @@
package nautilus.game.arcade.game.games.castlesiege.kits;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
public abstract class KitUndead extends Kit
public abstract class KitUndead extends ProgressingKit
{
public KitUndead(ArcadeManager manager, String name, KitAvailability kitAvailability, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand)
{
super(manager, name, kitAvailability, kitDesc, kitPerks, entityType, itemInHand);
super(manager, name, name.toLowerCase().replace(" ", ""), kitAvailability, kitDesc, kitPerks, entityType, itemInHand);
}
public KitUndead(ArcadeManager manager, String name, KitAvailability kitAvailability, int cost, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand)
{
super(manager, name, kitAvailability, cost, kitDesc, kitPerks, entityType, itemInHand);
super(manager, name, name.toLowerCase().replace(" ", ""), kitAvailability, cost, kitDesc, kitPerks, entityType, itemInHand);
}
}

View File

@ -1,5 +1,13 @@
package nautilus.game.arcade.game.games.castlesiege.kits;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilInv;
import mineplex.core.disguise.disguises.DisguiseSkeleton;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkIronSkin;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.EntityType;
@ -8,40 +16,36 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.UtilInv;
import mineplex.core.disguise.disguises.DisguiseSkeleton;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkIronSkin;
public class KitUndeadArcher extends KitUndead
{
private static final String[] DESCRIPTION = {
"Makes use of arrows scavenged from human archers.",
" ",
"Take " + C.cGreen + "-1" + C.cWhite + " damage from attacks"
};
private static final Perk[] PERKS = {
new PerkIronSkin(1)
};
private static final ItemStack[] PLAYER_ITEMS = {
ItemStackFactory.Instance.CreateStack(Material.STONE_AXE),
ItemStackFactory.Instance.CreateStack(Material.BOW)
};
public static final ItemStack IN_HAND = new ItemStack(Material.BOW);
public KitUndeadArcher(ArcadeManager manager)
{
super(manager, "Undead Archer", KitAvailability.Gem,
new String[]
{
"Makes use of arrows scavenged from human archers."
},
new Perk[]
{
new PerkIronSkin(1)
},
EntityType.SKELETON,
new ItemStack(Material.BOW));
super(manager, "Undead Archer", KitAvailability.Gem, DESCRIPTION, PERKS, EntityType.SKELETON, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_AXE));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW));
player.getInventory().addItem(PLAYER_ITEMS);
DisguiseSkeleton disguise = new DisguiseSkeleton(player);
disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName());

View File

@ -1,5 +1,13 @@
package nautilus.game.arcade.game.games.castlesiege.kits;
import mineplex.core.common.util.C;
import mineplex.core.disguise.disguises.DisguisePigZombie;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkLeap;
import nautilus.game.arcade.kit.perks.PerkSpeed;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@ -7,38 +15,35 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.disguise.disguises.DisguisePigZombie;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.*;
public class KitUndeadGhoul extends KitUndead
{
public KitUndeadGhoul(ArcadeManager manager)
{
super(manager, "Undead Ghoul", KitAvailability.Free,
new String[]
{
"Weak, but able to jump around with ease."
},
private static final String[] DESCRIPTION = {
"Weak, but able to jump around with ease.",
" ",
click(false, "your axe to use " + C.cGreen + "Ghoul Leap"),
};
new Perk[]
{
private static final Perk[] PERKS = {
new PerkLeap("Ghoul Leap", 1.2, 0.8, 8000),
new PerkSpeed(0)
},
EntityType.PIG_ZOMBIE,
new ItemStack(Material.STONE_AXE));
};
private static final ItemStack[] PLAYER_ITEMS = {
ItemStackFactory.Instance.CreateStack(Material.STONE_AXE),
};
public static final ItemStack IN_HAND = new ItemStack(Material.STONE_AXE);
public KitUndeadGhoul(ArcadeManager manager)
{
super(manager, "Undead Ghoul", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.PIG_ZOMBIE, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_AXE));
player.getInventory().addItem(PLAYER_ITEMS);
DisguisePigZombie disguise = new DisguisePigZombie(player);
disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName());
@ -50,9 +55,13 @@ public class KitUndeadGhoul extends KitUndead
public void PickupArrow(PlayerPickupItemEvent event)
{
if (!HasKit(event.getPlayer()))
{
return;
}
if (event.getItem().getItemStack().getType() == Material.ARROW)
{
event.setCancelled(true);
}
}
}

View File

@ -1,5 +1,12 @@
package nautilus.game.arcade.game.games.castlesiege.kits;
import mineplex.core.common.util.C;
import mineplex.core.disguise.disguises.DisguiseZombie;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkRegeneration;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@ -7,38 +14,35 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.disguise.disguises.DisguiseZombie;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.*;
public class KitUndeadZombie extends KitUndead
{
private static final String[] DESCRIPTION = {
"Regenerates rapidly",
" ",
"Receive " + C.cGreen + "Regeneration III"
};
private static final Perk[] PERKS = {
new PerkRegeneration(2)
};
private static final ItemStack[] PLAYER_ITEMS = {
ItemStackFactory.Instance.CreateStack(Material.STONE_AXE),
};
public static final ItemStack IN_HAND = new ItemStack(Material.STONE_AXE);
public KitUndeadZombie(ArcadeManager manager)
{
super(manager, "Undead Zombie", KitAvailability.Gem, 5000,
new String[]
{
"Regenerates rapidly"
},
new Perk[]
{
new PerkRegeneration(2)
},
EntityType.ZOMBIE,
new ItemStack(Material.STONE_AXE));
super(manager, "Undead Zombie", KitAvailability.Gem, 5000, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_AXE));
player.getInventory().addItem(PLAYER_ITEMS);
DisguiseZombie disguise = new DisguiseZombie(player);

View File

@ -1,42 +1,39 @@
package nautilus.game.arcade.game.games.champions.kits;
import java.util.HashMap;
import mineplex.minecraft.game.classcombat.Class.ClientClass;
import mineplex.minecraft.game.classcombat.Class.IPvpClass;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.ChampionsKit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.minecraft.game.classcombat.Class.ClientClass;
import mineplex.minecraft.game.classcombat.Class.IPvpClass;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import java.util.HashMap;
public class KitAssassin extends Kit
public class KitAssassin extends ChampionsKit
{
private HashMap<Player, ClientClass> _class = new HashMap<Player, ClientClass>();
public KitAssassin(ArcadeManager manager)
{
super(manager, "Assassin", KitAvailability.Free,
new String[]
{
private static final String[] DESCRIPTION = {
"Extremely agile warrior, trained in",
"the mystic arts of assassination.",
"",
"Attack Damage increased by 1",
"Fall Damage reduced by 1",
"Permanent Speed 2",
},
new Perk[]
{
};
},
EntityType.ZOMBIE,
new ItemStack(Material.IRON_SWORD));
private static final Perk[] PERKS = {};
private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD);
public KitAssassin(ArcadeManager manager)
{
super(manager, "Assassin", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND);
}
@ -61,7 +58,9 @@ public class KitAssassin extends Kit
clientClass.EquipCustomBuild(clientClass.GetCustomBuilds(pvpClass).get(0));
if (!Manager.GetGame().InProgress())
{
clientClass.SetActiveCustomBuild(pvpClass, pvpClass.getDefaultBuild());
}
Manager.openClassShop(player);
}

View File

@ -1,42 +1,38 @@
package nautilus.game.arcade.game.games.champions.kits;
import java.util.HashMap;
import mineplex.minecraft.game.classcombat.Class.ClientClass;
import mineplex.minecraft.game.classcombat.Class.IPvpClass;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.ChampionsKit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.minecraft.game.classcombat.Class.ClientClass;
import mineplex.minecraft.game.classcombat.Class.IPvpClass;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import java.util.HashMap;
public class KitBrute extends Kit
public class KitBrute extends ChampionsKit
{
private HashMap<Player, ClientClass> _class = new HashMap<Player, ClientClass>();
public KitBrute(ArcadeManager manager)
{
super(manager, "Brute", KitAvailability.Free,
new String[]
{
private static final String[] DESCRIPTION = {
"A giant of a man, able to smash and",
"destroy anything in his path.",
"",
"Takes additional damage to counter",
"the strength of Diamond Armor."
},
new Perk[]
};
private static final Perk[] PERKS = {};
private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD);
public KitBrute(ArcadeManager manager)
{
},
EntityType.ZOMBIE,
new ItemStack(Material.IRON_SWORD));
super(manager, "Brute", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND);
}
@Override

View File

@ -1,38 +1,35 @@
package nautilus.game.arcade.game.games.champions.kits;
import java.util.HashMap;
import mineplex.minecraft.game.classcombat.Class.ClientClass;
import mineplex.minecraft.game.classcombat.Class.IPvpClass;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.ChampionsKit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.minecraft.game.classcombat.Class.ClientClass;
import mineplex.minecraft.game.classcombat.Class.IPvpClass;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import java.util.HashMap;
public class KitKnight extends Kit
public class KitKnight extends ChampionsKit
{
private HashMap<Player, ClientClass> _class = new HashMap<Player, ClientClass>();
public KitKnight(ArcadeManager manager)
{
super(manager, "Knight", KitAvailability.Free,
new String[]
{
private static final String[] DESCRIPTION = {
"Knight of the realm, extremely good at",
"defending and surviving.",
},
new Perk[]
{
};
},
EntityType.ZOMBIE,
new ItemStack(Material.IRON_SWORD));
private static final Perk[] PERKS = {};
private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD);
public KitKnight(ArcadeManager manager)
{
super(manager, "Knight", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND);
}
@ -64,8 +61,10 @@ public class KitKnight extends Kit
clientClass.EquipCustomBuild(clientClass.GetCustomBuilds(pvpClass).get(0));
if (!Manager.GetGame().InProgress())
{
clientClass.SetActiveCustomBuild(pvpClass, pvpClass.getDefaultBuild());
}
}
@Override
public void GiveItems(Player player)

View File

@ -1,39 +1,35 @@
package nautilus.game.arcade.game.games.champions.kits;
import java.util.HashMap;
import mineplex.minecraft.game.classcombat.Class.ClientClass;
import mineplex.minecraft.game.classcombat.Class.IPvpClass;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.ChampionsKit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.minecraft.game.classcombat.Class.ClientClass;
import mineplex.minecraft.game.classcombat.Class.IPvpClass;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import java.util.HashMap;
public class KitMage extends Kit
public class KitMage extends ChampionsKit
{
private HashMap<Player, ClientClass> _class = new HashMap<Player, ClientClass>();
public KitMage(ArcadeManager manager)
{
super(manager, "Mage", KitAvailability.Free,
new String[]
{
private static final String[] DESCRIPTION = {
"Trained in the ways of magic, the mage",
"can unleash hell upon his opponents.",
},
new Perk[]
};
private static final Perk[] PERKS = {};
private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD);
public KitMage(ArcadeManager manager)
{
},
EntityType.ZOMBIE,
new ItemStack(Material.IRON_SWORD));
super(manager, "Mage", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND);
}
@Override

View File

@ -1,39 +1,35 @@
package nautilus.game.arcade.game.games.champions.kits;
import java.util.HashMap;
import mineplex.minecraft.game.classcombat.Class.ClientClass;
import mineplex.minecraft.game.classcombat.Class.IPvpClass;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.ChampionsKit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.minecraft.game.classcombat.Class.ClientClass;
import mineplex.minecraft.game.classcombat.Class.IPvpClass;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import java.util.HashMap;
public class KitRanger extends Kit
public class KitRanger extends ChampionsKit
{
private HashMap<Player, ClientClass> _class = new HashMap<Player, ClientClass>();
public KitRanger(ArcadeManager manager)
{
super(manager, "Ranger", KitAvailability.Free,
new String[]
{
private static final String[] DESCRIPTION = {
"Uses mastery of archery and kinship with",
"nature to defeat opponents."
},
new Perk[]
};
private static final Perk[] PERKS = {};
private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD);
public KitRanger(ArcadeManager manager)
{
},
EntityType.ZOMBIE,
new ItemStack(Material.IRON_SWORD));
super(manager, "Ranger", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND);
}
@Override
@ -57,7 +53,9 @@ public class KitRanger extends Kit
clientClass.EquipCustomBuild(clientClass.GetCustomBuilds(pvpClass).get(0));
if (!Manager.GetGame().InProgress())
{
clientClass.SetActiveCustomBuild(pvpClass, pvpClass.getDefaultBuild());
}
Manager.openClassShop(player);
}

View File

@ -1,22 +1,17 @@
package nautilus.game.arcade.game.games.deathtag.kits;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
public abstract class AbstractKitChaser extends Kit
public abstract class AbstractKitChaser extends ProgressingKit
{
public AbstractKitChaser(ArcadeManager manager, String name, KitAvailability kitAvailability, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand)
{
super(manager, name, kitAvailability, kitDesc, kitPerks, entityType, itemInHand);
super(manager, name, name.toLowerCase().replace(" ", ""), kitAvailability, kitDesc, kitPerks, entityType, itemInHand);
}
public AbstractKitChaser(ArcadeManager manager, String name, KitAvailability kitAvailability, int cost, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand)
{
super(manager, name, kitAvailability, cost, kitDesc, kitPerks, entityType, itemInHand);
}
}

View File

@ -1,22 +1,21 @@
package nautilus.game.arcade.game.games.deathtag.kits;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
public abstract class AbstractKitRunner extends Kit
public abstract class AbstractKitRunner extends ProgressingKit
{
public AbstractKitRunner(ArcadeManager manager, String name, KitAvailability kitAvailability, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand)
{
super(manager, name, kitAvailability, kitDesc, kitPerks, entityType, itemInHand);
super(manager, name, name.toLowerCase().replace(" ", ""), kitAvailability, kitDesc, kitPerks, entityType, itemInHand);
}
public AbstractKitRunner(ArcadeManager manager, String name, KitAvailability kitAvailability, int cost, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand)
{
super(manager, name, kitAvailability, cost, kitDesc, kitPerks, entityType, itemInHand);
super(manager, name, name.toLowerCase().replace(" ", ""), kitAvailability, cost, kitDesc, kitPerks, entityType, itemInHand);
}
}

View File

@ -1,46 +1,52 @@
package nautilus.game.arcade.game.games.deathtag.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.disguise.disguises.DisguiseSkeleton;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.SmashKit;
import nautilus.game.arcade.kit.perks.PerkDamageSet;
import nautilus.game.arcade.kit.perks.PerkIronSkin;
import nautilus.game.arcade.kit.perks.PerkKnockbackMultiplier;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.inventory.ItemStack;
public class KitAlphaChaser extends AbstractKitChaser
{
public KitAlphaChaser(ArcadeManager manager)
{
super(manager, "Alpha Chaser", KitAvailability.Free,
new String[]
{
},
private static final String[] DESCRIPTION = {
"Tag! You're it...",
" ",
"Deal " + C.cGreen + 6 + C.cWhite + " damage per attack",
"Take " + C.cGreen + "50%" + C.cWhite + " knockback",
"Take " + C.cGreen + "-4" + C.cWhite + " damage from all attacks"
};
new Perk[]
{
private static final Perk[] PERKS = {
new PerkDamageSet(6),
new PerkKnockbackMultiplier(0.5),
new PerkIronSkin(4)
},
EntityType.SKELETON,
new ItemStack(Material.IRON_AXE));
};
private static final ItemStack IN_HAND = new ItemStack(Material.IRON_AXE);
private static final ItemStack[] PLAYER_ITEMS = {
ItemStackFactory.Instance.CreateStack(Material.IRON_AXE)
};
public KitAlphaChaser(ArcadeManager manager)
{
super(manager, "Alpha Chaser", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.SKELETON, IN_HAND);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE));
player.getInventory().addItem(PLAYER_ITEMS);
//Disguise
DisguiseSkeleton disguise = new DisguiseSkeleton(player);

Some files were not shown because too many files have changed in this diff Show More