Merge pull request #16 in MIN/mineplex from clans_custom_gear to clans/test-server
* commit '1541dc329ea6f3deb382381fc35af5092121fa95': Reimplement clan energy-draining over time. Add combat-logging NPC for players that prematurely log off. Fix bug regarding /logout command for safe-logging. Reduce Shop territory side by 1 chunk radius. Add organic farming shop for purchasing/selling farm produce. Add travel hub for transporting between different spawn and shop locations. Add missing BowAttributes implementations for custom bows, and re-add in probability for dropping bows on custom gear drops. Fix bug related to custom-bow items not properly formatting item descriptions and display name. Update Redis default host IP. Fix bug where ranged attacks triggered melee-based custom gear attributes. Add clan management command for managing/deleting clans during testing phase of alpha/beta Clans. Add ability to convert Gems into Gold daily to Bank Shop, including redis-based system for tracking most recent transfers. Fix bug with item attributes that reference potions not properly displaying potion value effects (uses roman numerals). Prepare for custom textured Legendary items by modifying over to record-based materials. Add base for organic produce / farming shop.
This commit is contained in:
commit
9816d6d1dd
@ -135,7 +135,6 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
|
||||
|
||||
public void playerClicked(InventoryClickEvent event)
|
||||
{
|
||||
System.out.println("Clicked " + event.getRawSlot() + " --- vs " + event.getSlot() + " --- " + event.getInventory().getSize() + " --- " + inventory.getSize() + event.getInventory().getName());
|
||||
if (_buttonMap.containsKey(event.getRawSlot()))
|
||||
{
|
||||
_buttonMap.get(event.getRawSlot()).onClick(_player, event.getClick());
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mineplex.game.clans;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.MinecraftServer;
|
||||
@ -110,4 +111,18 @@ public class Clans extends JavaPlugin
|
||||
|
||||
MinecraftServer.getServer().getPropertyManager().setProperty("debug", true);
|
||||
}
|
||||
|
||||
public static String prettifyName(Material material)
|
||||
{
|
||||
String name = "";
|
||||
String[] words = material.toString().split("_");
|
||||
|
||||
for (String word : words)
|
||||
{
|
||||
word = word.toLowerCase();
|
||||
name += word.substring(0, 1).toUpperCase() + word.substring(1) + " ";
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class ClanEnergyManager extends MiniPlugin implements Runnable
|
||||
|
||||
for (final ClanInfo clanInfo : _clansManager.getClanMap().values())
|
||||
{
|
||||
if (clanInfo.isAdmin() || true) // TODO: Remove || true and implement ability to purchase Energy
|
||||
if (clanInfo.isAdmin())
|
||||
continue;
|
||||
|
||||
int energyPerMinute = clanInfo.getEnergyCostPerMinute();
|
||||
|
@ -34,6 +34,7 @@ import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.teleport.Teleport;
|
||||
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||
import mineplex.game.clans.clans.commands.ClanManagementCommand;
|
||||
import mineplex.game.clans.clans.commands.ClansAllyChatCommand;
|
||||
import mineplex.game.clans.clans.commands.ClansChatCommand;
|
||||
import mineplex.game.clans.clans.commands.ClansCommand;
|
||||
@ -48,7 +49,8 @@ import mineplex.game.clans.economy.GoldManager;
|
||||
import mineplex.game.clans.clans.worldevent.WorldEventManager;
|
||||
import mineplex.game.clans.fields.Field;
|
||||
import mineplex.game.clans.gameplay.Gameplay;
|
||||
import mineplex.game.clans.shop.ShopManager;
|
||||
import mineplex.game.clans.gameplay.safelog.LoggingManager;
|
||||
import mineplex.game.clans.gameplay.safelog.npc.NPCManager;
|
||||
import mineplex.game.clans.spawn.Spawn;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
||||
import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken;
|
||||
@ -138,7 +140,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
|
||||
// Required managers to be initialized
|
||||
new Spawn(plugin);
|
||||
new ShopManager(this, _clientManager, donationManager);
|
||||
new NPCManager(this);
|
||||
new LoggingManager(plugin);
|
||||
new GoldManager(this, _clientManager, donationManager);
|
||||
|
||||
|
||||
@ -193,6 +196,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
addCommand(new ClansChatCommand(this));
|
||||
addCommand(new ClansAllyChatCommand(this));
|
||||
addCommand(new ServerTimeCommand(this));
|
||||
addCommand(new ClanManagementCommand(this));
|
||||
}
|
||||
|
||||
public int getInviteExpire()
|
||||
|
@ -0,0 +1,77 @@
|
||||
package mineplex.game.clans.clans.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilInput;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClanRole;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||
import mineplex.game.clans.clans.ClientClan;
|
||||
import mineplex.game.clans.items.CustomItem;
|
||||
import mineplex.game.clans.items.GearManager;
|
||||
import mineplex.game.clans.items.attributes.weapon.FlamingAttribute;
|
||||
import mineplex.game.clans.items.attributes.weapon.FrostedAttribute;
|
||||
import mineplex.game.clans.items.attributes.weapon.SharpAttribute;
|
||||
import mineplex.game.clans.items.legendaries.LegendaryItem;
|
||||
import mineplex.game.clans.items.legendaries.WindBlade;
|
||||
|
||||
public class ClanManagementCommand extends CommandBase<ClansManager>
|
||||
{
|
||||
|
||||
private ClansManager _clansManager;
|
||||
|
||||
public ClanManagementCommand(ClansManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "clanmanagement", "cm");
|
||||
_clansManager = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null || args.length == 0)
|
||||
{
|
||||
notify(caller, "Incorrect number of arguments!");
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("delete") && args.length > 1)
|
||||
{
|
||||
String clanName = args[1];
|
||||
ClanInfo clan = Plugin.getClanUtility().searchClan(caller, args[1], false);
|
||||
|
||||
if (clan != null)
|
||||
{
|
||||
_clansManager.getClanDataAccess().delete(clan);
|
||||
notify(caller, String.format("Deleted the clan %s!", clanName));
|
||||
}
|
||||
else
|
||||
{
|
||||
notify(caller, String.format("Unable to locate clan %s!", clanName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void notify(Player player, String message)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Clans", message));
|
||||
}
|
||||
}
|
@ -112,7 +112,6 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
if (args.length > 1) infoClan(caller, args[1]);
|
||||
else infoClan(caller, null);
|
||||
}
|
||||
|
||||
else
|
||||
infoClan(caller, args[0]);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public class ClansRegions
|
||||
{
|
||||
public final static String DEFAULT_WORLD_NAME = "world";
|
||||
public final static int SPAWN_RADIUS = 2; // Radius of spawn claim area (measured in chunks)
|
||||
public final static int SHOP_RADIUS = 2; // Radius of shop claim area (measured in chunks)
|
||||
public final static int SHOP_RADIUS = 1; // Radius of shop claim area (measured in chunks)
|
||||
public final static int FIELDS_RADIUS = 7; // Radius of fields claim area (measured in chunks)
|
||||
public final static int BORDERLANDS_RADIUS = 75; // Radius of borderlands claim area (measured in chunks)
|
||||
|
||||
|
@ -0,0 +1,51 @@
|
||||
package mineplex.game.clans.economy;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.serverdata.data.Data;
|
||||
|
||||
public class GemTransfer implements Data
|
||||
{
|
||||
private static DateFormat dateFormatter = new SimpleDateFormat("dd/MM/yyyy");
|
||||
|
||||
private String _playerName;
|
||||
private Date _date;
|
||||
|
||||
public GemTransfer(String playerName)
|
||||
{
|
||||
_playerName = playerName;
|
||||
_date = new Date();
|
||||
}
|
||||
|
||||
public boolean transferWasToday()
|
||||
{
|
||||
return currentDate().before(_date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDataId()
|
||||
{
|
||||
return _playerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current date, with hours/minutes/seconds defaulted to 00:00, 12:00am of the
|
||||
* current day.
|
||||
*/
|
||||
public static Date currentDate()
|
||||
{
|
||||
Date current = new Date();
|
||||
|
||||
try
|
||||
{
|
||||
return dateFormatter.parse(dateFormatter.format(current));
|
||||
}
|
||||
catch (Exception exception) { }
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ package mineplex.game.clans.economy;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -31,17 +32,24 @@ import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.donation.Donor;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.shop.bank.BankShop;
|
||||
import mineplex.game.clans.shop.farming.FarmingShop;
|
||||
import mineplex.game.clans.spawn.travel.TravelButton;
|
||||
import mineplex.game.clans.spawn.travel.TravelShop;
|
||||
import mineplex.minecraft.game.core.condition.ConditionFactory;
|
||||
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||
|
||||
public class GoldManager extends MiniPlugin
|
||||
{
|
||||
public static final double DEATH_TAX = 0.04d; // Percentage of gold lost on death
|
||||
public static final int GEM_CONVERSION_RATE = 50; // The number of gold coins when converted from a single gem
|
||||
public static final double DEATH_TAX = 0.04d; // Percentage of gold lost on death
|
||||
public static final String META_STRING = "clans.goldAmount";
|
||||
|
||||
private static GoldManager _instance;
|
||||
public static GoldManager getInstance() { return _instance; }
|
||||
|
||||
private DonationManager _donationManager;
|
||||
private HashSet<Item> _itemSet;
|
||||
private TransferTracker _transferTracker;
|
||||
private Set<Item> _itemSet;
|
||||
private BankShop _bankShop;
|
||||
|
||||
public GoldManager(ClansManager plugin, CoreClientManager clientManager, DonationManager donationManager)
|
||||
@ -50,8 +58,11 @@ public class GoldManager extends MiniPlugin
|
||||
|
||||
_instance = this;
|
||||
_donationManager = donationManager;
|
||||
_transferTracker = new TransferTracker();
|
||||
_itemSet = new HashSet<Item>();
|
||||
_bankShop = new BankShop(plugin, clientManager, donationManager);
|
||||
new FarmingShop(plugin, clientManager, donationManager);
|
||||
new TravelShop(plugin, clientManager, donationManager);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -82,7 +93,6 @@ public class GoldManager extends MiniPlugin
|
||||
if (event.getMessage().startsWith("/gold"))
|
||||
{
|
||||
notify(event.getPlayer(), "Your Balance is " + C.cYellow + getGold(event.getPlayer()) + "g");
|
||||
addGold(event.getPlayer(), 100000);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -131,9 +141,37 @@ public class GoldManager extends MiniPlugin
|
||||
return getDonor(player).getGold();
|
||||
}
|
||||
|
||||
public int getGems(Player player)
|
||||
{
|
||||
return getDonor(player).GetGems();
|
||||
}
|
||||
|
||||
public void transferGemsToCoins(Player player, int gemAmount)
|
||||
{
|
||||
int gemCount = getGems(player);
|
||||
int goldCount = gemAmount * GEM_CONVERSION_RATE;
|
||||
|
||||
if (gemCount >= gemAmount)
|
||||
{
|
||||
deductGems(player, gemAmount);
|
||||
addGold(player, goldCount);
|
||||
notify(player, String.format("You have transferred %d gems into %d gold coins!", gemCount, goldCount));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player - the player to be checked for whether they can transfer gems into coins
|
||||
* @return true, if the player has not converted gems into coins within the
|
||||
* last day, false otherwise.
|
||||
*/
|
||||
public boolean canTransferGems(Player player)
|
||||
{
|
||||
return !_transferTracker.hasTransferredToday(player);
|
||||
}
|
||||
|
||||
public void addGold(Player player, int amount)
|
||||
{
|
||||
getDonor(player).addGold(amount);
|
||||
_donationManager.RewardGoldLater("GoldManager", player, amount);
|
||||
}
|
||||
|
||||
public void deductGold(Player player, int amount)
|
||||
@ -178,12 +216,22 @@ public class GoldManager extends MiniPlugin
|
||||
notify(player, String.format("You have purchased a gold token worth %dg!", tokenValue));
|
||||
}
|
||||
|
||||
public void addGems(Player player, int amount)
|
||||
{
|
||||
_donationManager.RewardGemsLater("GoldManager", player, amount);
|
||||
}
|
||||
|
||||
public void deductGems(Player player, int amount)
|
||||
{
|
||||
addGems(player, -amount);
|
||||
}
|
||||
|
||||
private Donor getDonor(Player player)
|
||||
{
|
||||
return _donationManager.Get(player.getName());
|
||||
}
|
||||
|
||||
private void notify(Player player, String message)
|
||||
public static void notify(Player player, String message)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Gold", message));
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
package mineplex.game.clans.economy;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.data.DataRepository;
|
||||
import mineplex.serverdata.redis.RedisDataRepository;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
|
||||
/**
|
||||
* Tracks when a player last converted gems into coins.
|
||||
* @author MrTwiggy
|
||||
*
|
||||
*/
|
||||
public class TransferTracker
|
||||
{
|
||||
public static final int TRANSFER_TIMEOUT = 24 * 60 * 60; // Time before transfer entry expires from DB (in seconds)
|
||||
private DataRepository<GemTransfer> _repository;
|
||||
|
||||
public TransferTracker()
|
||||
{
|
||||
_repository = new RedisDataRepository<GemTransfer>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(),
|
||||
Region.currentRegion(), GemTransfer.class, "GemTransfers");
|
||||
}
|
||||
|
||||
public void insertTransfer(Player player)
|
||||
{
|
||||
GemTransfer transfer = new GemTransfer(player.getName());
|
||||
_repository.addElement(transfer, TRANSFER_TIMEOUT);
|
||||
}
|
||||
|
||||
public boolean hasTransferredToday(Player player)
|
||||
{
|
||||
GemTransfer transfer = _repository.getElement(player.getName());
|
||||
return transfer != null && transfer.transferWasToday();
|
||||
}
|
||||
}
|
@ -25,6 +25,7 @@ import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.gameplay.safelog.npc.NPCManager;
|
||||
import mineplex.game.clans.items.commands.GearCommand;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
@ -62,7 +63,8 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class LoggingManager extends MiniPlugin
|
||||
{
|
||||
public static final double SAFE_LOG_RANGE = 32d;
|
||||
public static final String SAFE_LOG_MESSAGE = "You have safely logged out!";
|
||||
public static final double SAFE_LOG_RANGE = 1.5d;
|
||||
public static final int LOGOUT_DURATION = 10000; // Duration of safe-log (in milliseconds)
|
||||
public static final long REJOIN_TIME = 60000;
|
||||
|
||||
@ -95,7 +97,7 @@ public class LoggingManager extends MiniPlugin
|
||||
|
||||
public void onPlayerQuit(Player player)
|
||||
{
|
||||
LogoutData logoutData = _logouts.remove(player);
|
||||
LogoutData logoutData = _logouts.remove(player.getName());
|
||||
|
||||
boolean isSafeLog = logoutData != null && logoutData.hasSafeLogout() && !player.isDead();
|
||||
|
||||
@ -113,8 +115,11 @@ public class LoggingManager extends MiniPlugin
|
||||
|
||||
public void onPlayerJoin(Player player)
|
||||
{
|
||||
// TODO: Check to see if the player has a combat-log bot in place
|
||||
// and if so, remove/un-use it as they have logged back in.
|
||||
// Despawn the player's logout NPC if they have one existing on login
|
||||
if (NPCManager.getInstance().hasLogoutNpc(player))
|
||||
{
|
||||
NPCManager.getInstance().despawnLogoutNpc(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -126,6 +131,8 @@ public class LoggingManager extends MiniPlugin
|
||||
@EventHandler
|
||||
public void onPlayerKicked(PlayerKickEvent event)
|
||||
{
|
||||
if (isSafeLogKick(event)) return;
|
||||
|
||||
onPlayerQuit(event.getPlayer());
|
||||
}
|
||||
|
||||
@ -157,6 +164,7 @@ public class LoggingManager extends MiniPlugin
|
||||
{
|
||||
LogoutData data = new LogoutData(player, duration);
|
||||
_logouts.put(player.getName(), data);
|
||||
notify(player, "Successfully initiated safe-log!");
|
||||
|
||||
return data;
|
||||
}
|
||||
@ -171,6 +179,16 @@ public class LoggingManager extends MiniPlugin
|
||||
return getLogoutData(player) != null;
|
||||
}
|
||||
|
||||
private boolean isSafeLogKick(PlayerKickEvent event)
|
||||
{
|
||||
return event.getReason().equals(SAFE_LOG_MESSAGE);
|
||||
}
|
||||
|
||||
private void onCombatLog(Player player)
|
||||
{
|
||||
NPCManager.getInstance().spawnLogoutNpc(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tick the internal logic of this manager and update it's state.
|
||||
* Intended to be ticked/updated every in-game tick.
|
||||
@ -191,7 +209,7 @@ public class LoggingManager extends MiniPlugin
|
||||
}
|
||||
else if (data.hasSafeLogout())
|
||||
{
|
||||
// TODO: Log out player safely.
|
||||
safeLogPlayer(data.getPlayer());
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -204,12 +222,18 @@ public class LoggingManager extends MiniPlugin
|
||||
private void cancelSafeLog(Player player)
|
||||
{
|
||||
_logouts.remove(player.getName());
|
||||
// TODO: Notify player that safe-log was cancelled
|
||||
notify(player, "Your safe logout has been cancelled!");
|
||||
}
|
||||
|
||||
public void onCombatLog(Player player)
|
||||
private void notify(Player player, String message)
|
||||
{
|
||||
UtilInv.drop(player, true); // Drop player's inventory belongigs to ground
|
||||
UtilPlayer.message(player, F.main("SafeLog", message));
|
||||
}
|
||||
|
||||
private void safeLogPlayer(Player player)
|
||||
{
|
||||
player.kickPlayer(SAFE_LOG_MESSAGE);
|
||||
_logouts.remove(player.getName());
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
|
@ -56,7 +56,6 @@ public class QuitCommand extends CommandBase<LoggingManager>
|
||||
else
|
||||
{
|
||||
_loggingManager.insertLogoutData(caller);
|
||||
UtilPlayer.message(caller, F.main("SafeLog", "Successfully initiated safe-log!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
package mineplex.game.clans.shop;
|
||||
package mineplex.game.clans.gameplay.safelog.npc;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.EntityInsentient;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@ -11,48 +12,47 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
|
||||
public class ShopNPC
|
||||
public class CombatLogNPC
|
||||
{
|
||||
|
||||
public final static EntityType NPC_TYPE = EntityType.VILLAGER;
|
||||
|
||||
private ShopBase<ClansManager> _shop;
|
||||
private String _name;
|
||||
private Location _spawn;
|
||||
private String _playerName;
|
||||
|
||||
private LivingEntity _npc;
|
||||
public int getEntityId() { return _npc.getEntityId(); }
|
||||
|
||||
public ShopNPC(Location location, String name, ShopBase<ClansManager> shop)
|
||||
public CombatLogNPC(Player player)
|
||||
{
|
||||
_name = name;
|
||||
_shop = shop;
|
||||
_spawn = location;
|
||||
spawn();
|
||||
_playerName = player.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player interacts with the {@link Entity} associated
|
||||
* with this ShopNPC.
|
||||
* @param player - the player that interacted with the shop NPC
|
||||
* Called when the {@code _npc} associated with this CombatLogNPC is killed
|
||||
* and thus drops all the owner's items.
|
||||
*/
|
||||
public void onInteracted(Player player)
|
||||
public void onDeath()
|
||||
{
|
||||
_shop.attemptShopOpen(player);
|
||||
Player player = getPlayer();
|
||||
UtilInv.drop(player, true);
|
||||
player.setHealth(0.0d);
|
||||
}
|
||||
|
||||
public void spawn()
|
||||
{
|
||||
System.out.println("Spawning");
|
||||
if (_npc != null) despawn();
|
||||
|
||||
_npc = spawnNpc(_spawn, _name);
|
||||
_npc = spawnNpc(getPlayer());
|
||||
}
|
||||
|
||||
public void despawn()
|
||||
{
|
||||
System.out.println("Despawning");
|
||||
if (_npc != null)
|
||||
{
|
||||
_npc.remove();
|
||||
@ -60,17 +60,28 @@ public class ShopNPC
|
||||
}
|
||||
}
|
||||
|
||||
private static LivingEntity spawnNpc(Location location, String name)
|
||||
public Player getPlayer()
|
||||
{
|
||||
return Bukkit.getPlayerExact(_playerName);
|
||||
}
|
||||
|
||||
public boolean matchesPlayer(Player player)
|
||||
{
|
||||
return _playerName.equalsIgnoreCase(player.getName());
|
||||
}
|
||||
|
||||
private LivingEntity spawnNpc(Player player)
|
||||
{
|
||||
Location location = player.getLocation();
|
||||
World world = location.getWorld();
|
||||
LivingEntity entity = (LivingEntity) world.spawnEntity(location, NPC_TYPE);
|
||||
|
||||
// Initialize proper values of entity NPC on spawn
|
||||
entity.setCustomNameVisible(true);
|
||||
entity.setCustomName(ChatColor.RESET + name);
|
||||
entity.setCustomName(ChatColor.RESET + player.getName());
|
||||
entity.setCanPickupItems(false);
|
||||
entity.setRemoveWhenFarAway(false);
|
||||
((EntityInsentient) ((CraftLivingEntity) entity).getHandle()).persistent = true;
|
||||
//((EntityInsentient) ((CraftLivingEntity) entity).getHandle()).persistent = true;
|
||||
|
||||
return entity;
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
package mineplex.game.clans.gameplay.safelog.npc;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.items.generation.WeightSet;
|
||||
import mineplex.game.clans.shop.energy.EnergyShop;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class NPCManager extends MiniPlugin
|
||||
{
|
||||
private static NPCManager _instance;
|
||||
public static NPCManager getInstance() { return _instance; }
|
||||
|
||||
private ClansManager _clansManager;
|
||||
private Set<CombatLogNPC> _logoutNpcs;
|
||||
|
||||
public NPCManager(ClansManager plugin)
|
||||
{
|
||||
super("NPC Manager", plugin.getPlugin());
|
||||
|
||||
_instance = this;
|
||||
_logoutNpcs = new HashSet<CombatLogNPC>();
|
||||
_clansManager = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable()
|
||||
{
|
||||
log("Killing logout npcs");
|
||||
|
||||
// Despawn/kill all combat log NPCs on server shutdown
|
||||
for (CombatLogNPC npc : _logoutNpcs)
|
||||
{
|
||||
npc.despawn();
|
||||
}
|
||||
_logoutNpcs.clear();
|
||||
}
|
||||
|
||||
public void spawnLogoutNpc(Player player)
|
||||
{
|
||||
if (!hasLogoutNpc(player))
|
||||
{
|
||||
CombatLogNPC npc = new CombatLogNPC(player);
|
||||
npc.spawn();
|
||||
_logoutNpcs.add(npc);
|
||||
log(String.format("Spawned combat log NPC for %s!", player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
public void despawnLogoutNpc(Player player)
|
||||
{
|
||||
CombatLogNPC npc = getLogoutNpc(player);
|
||||
|
||||
if (npc != null)
|
||||
{
|
||||
npc.despawn();
|
||||
_logoutNpcs.remove(npc);
|
||||
log(String.format("Despawned combat log NPC for %s!", player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasLogoutNpc(Player player)
|
||||
{
|
||||
return getLogoutNpc(player) != null;
|
||||
}
|
||||
|
||||
public CombatLogNPC getLogoutNpc(Player player)
|
||||
{
|
||||
for (CombatLogNPC logoutNpc : _logoutNpcs)
|
||||
{
|
||||
if (logoutNpc.matchesPlayer(player))
|
||||
{
|
||||
return logoutNpc;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onEntityDamaged(EntityDeathEvent event)
|
||||
{
|
||||
CombatLogNPC logoutNpc = getLogoutNpc(event.getEntity());
|
||||
|
||||
if (logoutNpc != null)
|
||||
{
|
||||
logoutNpc.onDeath();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isLogoutNpc(Entity entity)
|
||||
{
|
||||
return getLogoutNpc(entity) != null;
|
||||
}
|
||||
|
||||
private CombatLogNPC getLogoutNpc(Entity entity)
|
||||
{
|
||||
return getLogoutNpc(entity.getEntityId());
|
||||
}
|
||||
|
||||
private CombatLogNPC getLogoutNpc(int entityId)
|
||||
{
|
||||
for (CombatLogNPC npc : _logoutNpcs)
|
||||
{
|
||||
if (npc.getEntityId() == entityId)
|
||||
{
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.game.clans.items.attributes.AttributeContainer;
|
||||
import mineplex.game.clans.items.attributes.ItemAttribute;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
@ -26,7 +27,7 @@ public class CustomItem
|
||||
|
||||
private ItemAttribute _superPrefix;
|
||||
public void setSuperPrefix(ItemAttribute attribute) { _superPrefix = attribute; }
|
||||
|
||||
|
||||
private ItemAttribute _prefix;
|
||||
public void setPrefix(ItemAttribute attribute) { _prefix = attribute; }
|
||||
|
||||
@ -210,6 +211,11 @@ public class CustomItem
|
||||
}
|
||||
}
|
||||
|
||||
public AttributeContainer cloneAttributes()
|
||||
{
|
||||
return new AttributeContainer(_superPrefix, _prefix, _suffix);
|
||||
}
|
||||
|
||||
public static String prettifyName(Material material)
|
||||
{
|
||||
String name = "";
|
||||
|
@ -17,9 +17,11 @@ import mineplex.core.packethandler.PacketInfo;
|
||||
import mineplex.core.portal.TransferHandler;
|
||||
import mineplex.core.portal.Commands.SendCommand;
|
||||
import mineplex.core.portal.Commands.ServerCommand;
|
||||
import mineplex.game.clans.items.attributes.AttributeContainer;
|
||||
import mineplex.game.clans.items.attributes.ItemAttribute;
|
||||
import mineplex.game.clans.items.attributes.weapon.*;
|
||||
import mineplex.game.clans.items.attributes.armor.*;
|
||||
import mineplex.game.clans.items.attributes.bow.*;
|
||||
import mineplex.game.clans.items.commands.GearCommand;
|
||||
import mineplex.game.clans.items.economy.GoldToken;
|
||||
import mineplex.game.clans.items.generation.Weight;
|
||||
@ -90,8 +92,8 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
_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>(10, ItemType.LEGENDARY),
|
||||
new Weight<ItemType>(45, ItemType.ARMOUR),
|
||||
new Weight<ItemType>(22, ItemType.WEAPON),
|
||||
new Weight<ItemType>(0, ItemType.BOW));
|
||||
new Weight<ItemType>(23, ItemType.WEAPON),
|
||||
new Weight<ItemType>(22, ItemType.BOW));
|
||||
|
||||
// Weapon-based attributes
|
||||
_weaponAttributes = new WeightSet<Class<? extends ItemAttribute>>(FrostedAttribute.class, SharpAttribute.class,
|
||||
@ -102,7 +104,8 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
ProtectionAttribute.class, PaddedAttribute.class, LavaAttribute.class);
|
||||
|
||||
// Bow-based attributes
|
||||
//_bowAttributes = new WeightSet<Class<? extends ItemAttribute>>(); // TODO: Add in bow-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.STONE_SWORD,
|
||||
@ -121,7 +124,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
// TODO: Add rest of legendaries, find better way?
|
||||
|
||||
// Register listeners
|
||||
UtilServer.getServer().getPluginManager().registerEvents(new ItemListener(), getPlugin());
|
||||
UtilServer.getServer().getPluginManager().registerEvents(new ItemListener(getPlugin()), getPlugin());
|
||||
UtilServer.getServer().getPluginManager().registerEvents(new SmeltingListener(), getPlugin());
|
||||
|
||||
// Initialize attribute types factory for JSON handling of polymorphism.
|
||||
@ -136,6 +139,10 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
{
|
||||
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
|
||||
@ -247,6 +254,9 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
case WEAPON:
|
||||
attributes.add(instantiate(_weaponAttributes.generateRandom()));
|
||||
break;
|
||||
case BOW:
|
||||
attributes.add(instantiate(_bowAttributes.generateRandom()));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -328,11 +338,21 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
return _gson.toJson(customItem, CustomItem.class);
|
||||
}
|
||||
|
||||
public static String serialize(AttributeContainer attributes)
|
||||
{
|
||||
return _gson.toJson(attributes, AttributeContainer.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 singleton instance of {@link GearManager}.
|
||||
*/
|
||||
|
@ -1,16 +1,25 @@
|
||||
package mineplex.game.clans.items;
|
||||
|
||||
import mineplex.game.clans.items.attributes.AttributeContainer;
|
||||
import mineplex.game.clans.items.attributes.ItemAttribute;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
* Listens for item-related trigger events and accordingly triggers appropriate
|
||||
@ -21,6 +30,15 @@ import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
public class ItemListener implements Listener
|
||||
{
|
||||
|
||||
public static final String PROJECTILE_META_TAG = "[CustomGearProj]";
|
||||
|
||||
private JavaPlugin _plugin;
|
||||
|
||||
public ItemListener(JavaPlugin plugin)
|
||||
{
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle players shuffling CustomItems around by properly updating
|
||||
* and managing their movement.
|
||||
@ -54,8 +72,9 @@ public class ItemListener implements Listener
|
||||
@EventHandler
|
||||
public void onPlayerAttack(CustomDamageEvent event)
|
||||
{
|
||||
Player damager = event.GetDamagerPlayer(true);
|
||||
Player damager = event.GetDamagerPlayer(false); // For non-ranged attacks
|
||||
Player damagee = event.GetDamageePlayer();
|
||||
Projectile projectile = event.GetProjectile();
|
||||
|
||||
// Trigger custom gear effects for attacker
|
||||
if (damager != null)
|
||||
@ -70,6 +89,51 @@ public class ItemListener implements Listener
|
||||
PlayerGear defenderGear = getGear(damagee);
|
||||
defenderGear.onAttacked(event);
|
||||
}
|
||||
|
||||
// Trigger bow-related attribute effects properly
|
||||
if (projectile != null)
|
||||
{
|
||||
if (projectile.hasMetadata(PROJECTILE_META_TAG))
|
||||
{
|
||||
for (MetadataValue data : projectile.getMetadata(PROJECTILE_META_TAG))
|
||||
{
|
||||
String serialization = data.asString();
|
||||
AttributeContainer container = GearManager.deserialize(serialization, AttributeContainer.class);
|
||||
|
||||
for (ItemAttribute attribute : container.getAttributes())
|
||||
{
|
||||
attribute.onAttack(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Properly marks projectiles shot from a custom-gear bow so that it will properly trigger events.
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler
|
||||
public void onEntityShootBow(EntityShootBowEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player)
|
||||
{
|
||||
Player player = (Player) event.getEntity();
|
||||
PlayerGear gear = getGear(player);
|
||||
|
||||
CustomItem weapon = gear.getWeapon();
|
||||
|
||||
if (weapon != null)
|
||||
{
|
||||
// Copy weapon attributes onto projectile for later processing
|
||||
AttributeContainer attributes = weapon.cloneAttributes();
|
||||
String serialization = GearManager.serialize(attributes);
|
||||
|
||||
Entity projectile = event.getProjectile();
|
||||
projectile.setMetadata(PROJECTILE_META_TAG, new FixedMetadataValue(_plugin, serialization));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,5 @@
|
||||
package mineplex.game.clans.items.attributes.weapon;
|
||||
package mineplex.game.clans.items.attributes;
|
||||
|
||||
import mineplex.game.clans.items.attributes.ItemAttribute;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
@ -0,0 +1,21 @@
|
||||
package mineplex.game.clans.items.attributes;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class AttributeContainer
|
||||
{
|
||||
|
||||
private Set<ItemAttribute> _attributes;
|
||||
public Set<ItemAttribute> getAttributes() { return _attributes; }
|
||||
|
||||
public AttributeContainer(ItemAttribute... attributes)
|
||||
{
|
||||
_attributes = new HashSet<ItemAttribute>();
|
||||
|
||||
for (ItemAttribute attribute : attributes)
|
||||
{
|
||||
_attributes.add(attribute);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package mineplex.game.clans.items.attributes.weapon;
|
||||
package mineplex.game.clans.items.attributes;
|
||||
|
||||
import mineplex.game.clans.items.attributes.ItemAttribute;
|
||||
import mineplex.game.clans.items.generation.ValueDistribution;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
@ -50,4 +50,72 @@ public abstract class ItemAttribute
|
||||
{
|
||||
return new ValueDistribution(minValue, maxValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param amplifier - the amplifier for a potion effect intensity
|
||||
* @return the roman-numeral properly representing the amplifier
|
||||
*/
|
||||
public static String amplifierToRoman(int amplifier)
|
||||
{
|
||||
return integerToRomanNumeral(amplifier + 1); // Add one because amplifiers are zero-based
|
||||
}
|
||||
|
||||
// Ugly int-to-roman numeral conversion found online. Don't judge!
|
||||
public static String integerToRomanNumeral(int input) {
|
||||
if (input < 1 || input > 3999)
|
||||
return "???";
|
||||
String s = "";
|
||||
while (input >= 1000) {
|
||||
s += "M";
|
||||
input -= 1000; }
|
||||
while (input >= 900) {
|
||||
s += "CM";
|
||||
input -= 900;
|
||||
}
|
||||
while (input >= 500) {
|
||||
s += "D";
|
||||
input -= 500;
|
||||
}
|
||||
while (input >= 400) {
|
||||
s += "CD";
|
||||
input -= 400;
|
||||
}
|
||||
while (input >= 100) {
|
||||
s += "C";
|
||||
input -= 100;
|
||||
}
|
||||
while (input >= 90) {
|
||||
s += "XC";
|
||||
input -= 90;
|
||||
}
|
||||
while (input >= 50) {
|
||||
s += "L";
|
||||
input -= 50;
|
||||
}
|
||||
while (input >= 40) {
|
||||
s += "XL";
|
||||
input -= 40;
|
||||
}
|
||||
while (input >= 10) {
|
||||
s += "X";
|
||||
input -= 10;
|
||||
}
|
||||
while (input >= 9) {
|
||||
s += "IX";
|
||||
input -= 9;
|
||||
}
|
||||
while (input >= 5) {
|
||||
s += "V";
|
||||
input -= 5;
|
||||
}
|
||||
while (input >= 4) {
|
||||
s += "IV";
|
||||
input -= 4;
|
||||
}
|
||||
while (input >= 1) {
|
||||
s += "I";
|
||||
input -= 1;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,6 @@ public class ReinforcedAttribute extends FlatReductionAttribute
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return String.format("Reduce incoming enemy attacks by %.2f half-hearts.", getFlatReduction());
|
||||
return String.format("Reduce incoming attacks by enemies by %.2f half-hearts.", getFlatReduction());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
package mineplex.game.clans.items.attributes.bow;
|
||||
|
||||
import mineplex.game.clans.items.attributes.ItemAttribute;
|
||||
import mineplex.game.clans.items.generation.ValueDistribution;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class DestructionAttribute extends ItemAttribute
|
||||
{
|
||||
private static ValueDistribution attackGen = generateDistribution(2, 4);
|
||||
private static ValueDistribution fireGen = generateDistribution(60, 120);
|
||||
|
||||
|
||||
public DestructionAttribute()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttack(CustomDamageEvent event)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package mineplex.game.clans.items.attributes.bow;
|
||||
|
||||
import mineplex.game.clans.items.attributes.ItemAttribute;
|
||||
import mineplex.game.clans.items.generation.ValueDistribution;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class HeavyArrowsAttribute extends ItemAttribute
|
||||
{
|
||||
private static ValueDistribution knockbackGen = generateDistribution(25, 75);
|
||||
|
||||
private double _knockbackPercent;
|
||||
|
||||
public HeavyArrowsAttribute()
|
||||
{
|
||||
_knockbackPercent = knockbackGen.generateValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
return "Heavy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return String.format("Increase knockback by %.2f%", _knockbackPercent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttack(CustomDamageEvent event)
|
||||
{
|
||||
event.AddKnockback("HeavyAttribute", _knockbackPercent);
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package mineplex.game.clans.items.attributes.bow;
|
||||
|
||||
import mineplex.game.clans.items.attributes.ItemAttribute;
|
||||
import mineplex.game.clans.items.generation.ValueDistribution;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class HuntingAttribute extends ItemAttribute
|
||||
{
|
||||
private static ValueDistribution amountGen = generateDistribution(0, 2); // Value generator for slow amount range
|
||||
private static ValueDistribution durationGen = generateDistribution(1, 4); // Value generator for slow duration range
|
||||
|
||||
private int _slowAmount; // The slowness level/amplifier
|
||||
private double _slowDuration; // The duration (in ticks) of slow effect
|
||||
|
||||
public HuntingAttribute()
|
||||
{
|
||||
_slowAmount = amountGen.generateIntValue();
|
||||
_slowDuration = durationGen.generateValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
return "Hunting";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return String.format("Damaged enemies receive slowness %s for %.2f seconds.", amplifierToRoman(_slowAmount), _slowDuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttacked(CustomDamageEvent event)
|
||||
{
|
||||
Player damager = event.GetDamagerPlayer(true);
|
||||
|
||||
if (damager != null)
|
||||
{
|
||||
damager.addPotionEffect(generateSlowEffect()); // Slow attacking player
|
||||
}
|
||||
}
|
||||
|
||||
private PotionEffect generateSlowEffect()
|
||||
{
|
||||
return new PotionEffect(PotionEffectType.SLOW, (int) (_slowDuration * 20), _slowAmount);
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package mineplex.game.clans.items.attributes.bow;
|
||||
|
||||
import mineplex.game.clans.items.attributes.ItemAttribute;
|
||||
import mineplex.game.clans.items.generation.ValueDistribution;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class InverseAttribute extends ItemAttribute
|
||||
{
|
||||
private static ValueDistribution knockbackGen = generateDistribution(-0.5d, 1.0d);
|
||||
|
||||
private double _knockbackModifier;
|
||||
|
||||
public InverseAttribute()
|
||||
{
|
||||
_knockbackModifier = knockbackGen.generateValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
return "Inverse";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return String.format("Reverse knockback and modify amount to %.2f percent!", (1.0d + _knockbackModifier) * 100d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttack(CustomDamageEvent event)
|
||||
{
|
||||
event.AddKnockback("InverseAttribute", _knockbackModifier);
|
||||
event.invertKnockback();
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package mineplex.game.clans.items.attributes.bow;
|
||||
|
||||
import mineplex.game.clans.items.attributes.ItemAttribute;
|
||||
import mineplex.game.clans.items.generation.ValueDistribution;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
public class LeechingAttribute extends ItemAttribute
|
||||
{
|
||||
private static ValueDistribution healGen = generateDistribution(5, 15);
|
||||
|
||||
private int _healPercent;
|
||||
|
||||
public LeechingAttribute()
|
||||
{
|
||||
_healPercent = healGen.generateIntValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
return "Leeching";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return String.format("Heal yourself for %d percentage of damage dealt to enemy players.", _healPercent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttack(CustomDamageEvent event)
|
||||
{
|
||||
Player damager = event.GetDamagerPlayer(true);
|
||||
|
||||
double damage = event.GetDamage();
|
||||
double healAmount = damage * (_healPercent / 100d);
|
||||
heal(damager, healAmount);
|
||||
}
|
||||
|
||||
private void heal(Player player, double healAmount)
|
||||
{
|
||||
player.setHealth(player.getHealth() + healAmount);
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package mineplex.game.clans.items.attributes.bow;
|
||||
|
||||
import mineplex.game.clans.items.attributes.ItemAttribute;
|
||||
import mineplex.game.clans.items.generation.ValueDistribution;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class ReboundingAttribute extends ItemAttribute
|
||||
{
|
||||
private static ValueDistribution attackGen = generateDistribution(2, 4);
|
||||
private static ValueDistribution fireGen = generateDistribution(60, 120);
|
||||
|
||||
|
||||
public ReboundingAttribute()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttack(CustomDamageEvent event)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package mineplex.game.clans.items.attributes.bow;
|
||||
|
||||
import mineplex.game.clans.items.attributes.DamageAttribute;
|
||||
import mineplex.game.clans.items.attributes.ItemAttribute;
|
||||
import mineplex.game.clans.items.generation.ValueDistribution;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class RecursiveAttribute extends DamageAttribute
|
||||
{
|
||||
private static ValueDistribution attackGen = generateDistribution(2, 6);
|
||||
|
||||
public RecursiveAttribute()
|
||||
{
|
||||
super(attackGen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
return "Recursive";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return String.format("Increase damage by %.2f half-hearts!", getBonusDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean grantBonusDamage(Entity defender)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package mineplex.game.clans.items.attributes.bow;
|
||||
|
||||
import mineplex.game.clans.items.attributes.AttackAttribute;
|
||||
import mineplex.game.clans.items.generation.ValueDistribution;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class ScorchingAttribute extends AttackAttribute
|
||||
{
|
||||
private static ValueDistribution fireGen = generateDistribution(2, 6);
|
||||
|
||||
private double _fireDuration;
|
||||
|
||||
public ScorchingAttribute()
|
||||
{
|
||||
super(1); // Activates every hit
|
||||
_fireDuration = fireGen.generateValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
return "Scorching";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return String.format("Struck enemies catch fire for %.2f seconds.", _fireDuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void triggerAttack(Entity attacker, Entity defender)
|
||||
{
|
||||
defender.setFireTicks((int) (_fireDuration * 20));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package mineplex.game.clans.items.attributes.bow;
|
||||
|
||||
import mineplex.game.clans.items.attributes.DamageAttribute;
|
||||
import mineplex.game.clans.items.attributes.ItemAttribute;
|
||||
import mineplex.game.clans.items.generation.ValueDistribution;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Monster;
|
||||
|
||||
public class SlayingAttribute extends DamageAttribute
|
||||
{
|
||||
private static ValueDistribution attackGen = generateDistribution(2, 12);
|
||||
|
||||
public SlayingAttribute()
|
||||
{
|
||||
super(attackGen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
return "Slaying";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return String.format("Increase damage by %.2f half-hearts against mobs & bosses!", getBonusDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean grantBonusDamage(Entity defender)
|
||||
{
|
||||
return defender instanceof Monster; // TODO: Check to see if defender is also a WorldEvent boss?
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package mineplex.game.clans.items.attributes.bow;
|
||||
|
||||
import mineplex.game.clans.items.attributes.ItemAttribute;
|
||||
import mineplex.game.clans.items.generation.ValueDistribution;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class SpectralAttribute extends ItemAttribute
|
||||
{
|
||||
private static ValueDistribution attackGen = generateDistribution(2, 4);
|
||||
private static ValueDistribution fireGen = generateDistribution(60, 120);
|
||||
|
||||
|
||||
public SpectralAttribute()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttack(CustomDamageEvent event)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package mineplex.game.clans.items.attributes.weapon;
|
||||
|
||||
import mineplex.game.clans.items.attributes.DamageAttribute;
|
||||
import mineplex.game.clans.items.generation.ValueDistribution;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.game.clans.items.attributes.weapon;
|
||||
|
||||
import mineplex.game.clans.items.attributes.AttackAttribute;
|
||||
import mineplex.game.clans.items.generation.ValueDistribution;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
@ -41,13 +41,13 @@ public class FrostedAttribute extends ItemAttribute
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return String.format("Apply slowness %d for %d ticks to enemies.", _slowAmount, _slowDuration);
|
||||
return String.format("Apply slowness %s for %d ticks to enemies.", amplifierToRoman(_slowAmount), _slowDuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttacked(CustomDamageEvent event)
|
||||
{
|
||||
Player damager = event.GetDamagerPlayer(true);
|
||||
Player damager = event.GetDamagerPlayer(false);
|
||||
|
||||
if (damager != null)
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.game.clans.items.attributes.weapon;
|
||||
|
||||
import mineplex.game.clans.items.attributes.AttackAttribute;
|
||||
import mineplex.game.clans.items.generation.ValueDistribution;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -34,7 +35,7 @@ public class HasteAttribute extends AttackAttribute
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return String.format("Gain speed %d for %d ticks every %d attacks.", _speedAmount, _speedDuration, getAttackLimit());
|
||||
return String.format("Gain speed %s for %d ticks every %d attacks.", amplifierToRoman(_speedAmount), _speedDuration, getAttackLimit());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.game.clans.items.attributes.weapon;
|
||||
|
||||
import mineplex.game.clans.items.attributes.AttackAttribute;
|
||||
import mineplex.game.clans.items.generation.ValueDistribution;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.game.clans.items.attributes.weapon;
|
||||
|
||||
import mineplex.game.clans.items.attributes.DamageAttribute;
|
||||
import mineplex.game.clans.items.generation.ValueDistribution;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
@ -33,7 +33,7 @@ public class VampiricAttribute extends ItemAttribute
|
||||
@Override
|
||||
public void onAttack(CustomDamageEvent event)
|
||||
{
|
||||
Player damager = event.GetDamagerPlayer(true);
|
||||
Player damager = event.GetDamagerPlayer(false);
|
||||
|
||||
double damage = event.GetDamage();
|
||||
double healAmount = damage * (_healPercent / 100d);
|
||||
|
@ -49,7 +49,7 @@ public class GearCommand extends CommandBase<GearManager>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Gear", "Opening custom gear GUI!"));
|
||||
UtilPlayer.message(caller, F.main("Gear", "Spawning a random piece of custom gear!"));
|
||||
|
||||
if (args == null || args.length == 0)
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ public class AlligatorsTooth extends LegendaryItem
|
||||
|
||||
public AlligatorsTooth()
|
||||
{
|
||||
super("Alligators Tooth", "Grants bonus damage in water and special ability to swim fast!", Material.RAW_FISH);
|
||||
super("Alligators Tooth", "Grants bonus damage in water and special ability to swim fast!", Material.RECORD_3);
|
||||
|
||||
_damageBonus = damageGen.generateValue();
|
||||
_swimSpeed = boostGen.generateValue();
|
||||
|
@ -16,7 +16,7 @@ public class GiantsBroadsword extends LegendaryItem
|
||||
|
||||
public GiantsBroadsword()
|
||||
{
|
||||
super("Giants Broadsword", "Deal huge damage and block to gain defensive abilities!", Material.PAPER);
|
||||
super("Giants Broadsword", "Deal huge damage and block to gain defensive abilities!", Material.RECORD_4);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,7 +23,7 @@ public class HyperBlade extends LegendaryItem
|
||||
|
||||
public HyperBlade()
|
||||
{
|
||||
super("Hyper Blade", "Increased attack speed!", Material.STICK);
|
||||
super("Hyper Blade", "Increased attack speed!", Material.RECORD_5);
|
||||
_speedAmount = amountGen.generateIntValue();
|
||||
_speedDuration = durationGen.generateIntValue();
|
||||
_lastAttack = 0;
|
||||
|
@ -18,7 +18,7 @@ public class MagneticBlade extends LegendaryItem
|
||||
|
||||
public MagneticBlade()
|
||||
{
|
||||
super("Magnetic Blade", "Pull enemies closer with special abilities!", Material.STICK);
|
||||
super("Magnetic Blade", "Pull enemies closer with special abilities!", Material.RECORD_6);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,7 +19,7 @@ public class WindBlade extends LegendaryItem
|
||||
|
||||
public WindBlade()
|
||||
{
|
||||
super("Wind Blade", "Activate flying ability to take flight for 80 ticks before landing!", Material.STICK); // TODO: Configurable?
|
||||
super("Wind Blade", "Activate flying ability to take flight for 80 ticks before landing!", Material.RECORD_8); // TODO: Configurable?
|
||||
|
||||
_flightTime = 0;
|
||||
}
|
||||
|
@ -34,6 +34,27 @@ public class PvpItem extends ShopItem
|
||||
_bulkCount = bulkCount;
|
||||
}
|
||||
|
||||
public PvpItem(Material type, byte data, int displayAmount, String name, int buyPrice, int sellPrice, int bulkCount)
|
||||
{
|
||||
super(type, data, name, new String[]
|
||||
{
|
||||
C.cWhite + " ",
|
||||
LEFT_CLICK_BUY,
|
||||
C.cWhite + "Costs " + C.cGreen + "$" + buyPrice,
|
||||
C.cWhite + " ",
|
||||
C.cYellow + "Shift Left-Click" + C.cWhite + " to Buy " + C.cGreen + bulkCount,
|
||||
C.cWhite + "Costs " + C.cGreen + "$" + (buyPrice * bulkCount),
|
||||
C.cWhite + " ",
|
||||
RIGHT_CLICK_SELL,
|
||||
C.cWhite + "Earns " + C.cGreen + "$" + sellPrice,
|
||||
C.cWhite + " ",
|
||||
C.cYellow + "Shift Right-Click" + C.cWhite + " to Sell " + C.cGreen + "All",
|
||||
}, 0, false, false);
|
||||
|
||||
_price = buyPrice;
|
||||
_bulkCount = bulkCount;
|
||||
}
|
||||
|
||||
public PvpItem(Material type, byte data, int displayAmount, String name, int price)
|
||||
{
|
||||
super(type, data, name, new String[]
|
||||
|
@ -1,104 +0,0 @@
|
||||
package mineplex.game.clans.shop;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.items.generation.WeightSet;
|
||||
import mineplex.game.clans.shop.energy.EnergyShop;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class ShopManager extends MiniPlugin
|
||||
{
|
||||
|
||||
private ClansManager _clansManager;
|
||||
private CoreClientManager _clientManager;
|
||||
private DonationManager _donationManager;
|
||||
private Set<ShopNPC> _shopNpcs;
|
||||
|
||||
public ShopManager(ClansManager plugin, CoreClientManager clientManager, DonationManager donationManager)
|
||||
{
|
||||
super("Clans Shop Manager", plugin.getPlugin());
|
||||
|
||||
_shopNpcs = new HashSet<ShopNPC>();
|
||||
_clansManager = plugin;
|
||||
_clientManager = clientManager;
|
||||
_donationManager = donationManager;
|
||||
|
||||
initialize();
|
||||
}
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
// Spawn appropriate shop NPCs
|
||||
World world = Bukkit.getWorld("world");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable()
|
||||
{
|
||||
System.out.println("Killing shop npcs");
|
||||
// Despawn/kill all shop NPCs on server shutdown
|
||||
for (ShopNPC npc : _shopNpcs)
|
||||
{
|
||||
npc.despawn();
|
||||
}
|
||||
}
|
||||
|
||||
public void addShopNPC(Location location, String shopName, ShopBase<ClansManager> shop)
|
||||
{
|
||||
ShopNPC npc = new ShopNPC(location, shopName, shop);
|
||||
_shopNpcs.add(npc);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerClickEntity(PlayerInteractEntityEvent event)
|
||||
{
|
||||
Entity clicked = event.getRightClicked();
|
||||
ShopNPC shop = getShopNpc(clicked.getEntityId());
|
||||
|
||||
if (shop != null) // Player interacted with a Shop NPC
|
||||
{
|
||||
shop.onInteracted(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onEntityDamaged(EntityDamageEvent event)
|
||||
{
|
||||
if (isShopNpc(event.getEntity()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isShopNpc(Entity entity)
|
||||
{
|
||||
return getShopNpc(entity.getEntityId()) != null;
|
||||
}
|
||||
|
||||
private ShopNPC getShopNpc(int entityId)
|
||||
{
|
||||
for (ShopNPC npc : _shopNpcs)
|
||||
{
|
||||
if (npc.getEntityId() == entityId)
|
||||
{
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@ import mineplex.game.clans.shop.building.BuildingPage;
|
||||
|
||||
public class BankPage extends ShopPageBase<ClansManager, BankShop>
|
||||
{
|
||||
public static final int GEM_CONVERSION = 1000; // The number of gems that can be converted into gold
|
||||
public static final int TOKEN_VALUE = 50000; // Value of a GoldToken (in gold) that can be stored/cashed in here
|
||||
private ClanInfo _clanInfo;
|
||||
|
||||
@ -45,6 +46,15 @@ public class BankPage extends ShopPageBase<ClansManager, BankShop>
|
||||
{
|
||||
buildTokenUnpurchasable();
|
||||
}
|
||||
|
||||
if (GoldManager.getInstance().canTransferGems(getPlayer()))
|
||||
{
|
||||
buildTransferGems();
|
||||
}
|
||||
else
|
||||
{
|
||||
buildTransferGemsCooldown();
|
||||
}
|
||||
}
|
||||
|
||||
private void buildCashIn()
|
||||
@ -58,6 +68,31 @@ public class BankPage extends ShopPageBase<ClansManager, BankShop>
|
||||
ShopItem shopItem = new ShopItem(Material.FURNACE, title, new String[] {" ", playerGoldString, description}, 0, true, true);
|
||||
addButton(5, shopItem, button);
|
||||
}
|
||||
|
||||
private void buildTransferGems()
|
||||
{
|
||||
int playerGold = getPlayerGold();
|
||||
int playerGems = getPlayerGems();
|
||||
int conversionCount = GEM_CONVERSION * GoldManager.GEM_CONVERSION_RATE;
|
||||
|
||||
GemTransferButton button = new GemTransferButton(this, GEM_CONVERSION);
|
||||
String title = ChatColor.GOLD + C.Bold + "Convert Gems To Gold!";
|
||||
String playerGoldString = ChatColor.RESET + F.value("Your Gold", playerGold + "g");
|
||||
String playerGemString = ChatColor.RESET + F.value("Your Gems", playerGems + " gems");
|
||||
String purchaseString = ChatColor.RESET + F.value("Conversion Rate", GEM_CONVERSION + " gems for " + conversionCount + " gold");
|
||||
String goldString = ChatColor.RESET + C.cWhite + "Convert gems into gold coins once per day!";
|
||||
ShopItem shopItem = new ShopItem(Material.EMERALD, title, new String[] {" ", playerGoldString, playerGemString, purchaseString, goldString}, 0, true, true);
|
||||
addButton(4, shopItem, button);
|
||||
}
|
||||
|
||||
private void buildTransferGemsCooldown()
|
||||
{
|
||||
StoreGoldButton button = new StoreGoldButton(this);
|
||||
String title = ChatColor.RED + C.Bold + "Conversion Cooldown!";
|
||||
String purchaseString = ChatColor.RESET + C.cWhite + "You have already converted gems into coins today";
|
||||
ShopItem shopItem = new ShopItem(Material.REDSTONE_BLOCK, title, new String[] {" ", purchaseString, " "}, 0, true, true);
|
||||
addButton(4, shopItem, button);
|
||||
}
|
||||
|
||||
private void buildTokenPurchasable()
|
||||
{
|
||||
@ -95,6 +130,11 @@ public class BankPage extends ShopPageBase<ClansManager, BankShop>
|
||||
{
|
||||
return getPlayerGold() >= TOKEN_VALUE;
|
||||
}
|
||||
|
||||
private int getPlayerGems()
|
||||
{
|
||||
return GoldManager.getInstance().getGems(getPlayer());
|
||||
}
|
||||
|
||||
private int getPlayerGold()
|
||||
{
|
||||
|
@ -0,0 +1,41 @@
|
||||
package mineplex.game.clans.shop.bank;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.economy.GoldManager;
|
||||
import mineplex.game.clans.items.CustomItem;
|
||||
import mineplex.game.clans.items.GearManager;
|
||||
import mineplex.game.clans.items.economy.GoldToken;
|
||||
|
||||
public class GemTransferButton implements IButton
|
||||
{
|
||||
private BankPage _page;
|
||||
private int _gemAmount;
|
||||
|
||||
public GemTransferButton(BankPage page, int gemAmount)
|
||||
{
|
||||
_page = page;
|
||||
_gemAmount = gemAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
if (clickType != ClickType.LEFT) return;
|
||||
|
||||
if (GoldManager.getInstance().canTransferGems(player))
|
||||
{
|
||||
GoldManager.getInstance().transferGemsToCoins(player, _gemAmount);
|
||||
_page.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package mineplex.game.clans.shop.farming;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.game.clans.Clans;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.shop.PvpItem;
|
||||
import mineplex.game.clans.shop.PvpShopButton;
|
||||
|
||||
public class FarmingPage extends ShopPageBase<ClansManager, FarmingShop>
|
||||
{
|
||||
public FarmingPage(ClansManager plugin, FarmingShop shop, CoreClientManager clientManager, DonationManager donationManager, org.bukkit.entity.Player player)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, "Organic Produce", player, 9);
|
||||
|
||||
buildPage();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
addShopItem(1, Material.POTATO, 10, 5);
|
||||
addShopItem(2, Material.MELON, 10, 5);
|
||||
addShopItem(3, Material.BREAD, 30, 20);
|
||||
addShopItem(4, Material.COOKED_BEEF, 50, 35);
|
||||
addShopItem(5, Material.COOKED_CHICKEN, 50, 35);
|
||||
addShopItem(6, Material.FEATHER, 50, 25);
|
||||
addShopItem(7, Material.CARROT, 6, 3);
|
||||
}
|
||||
|
||||
public void addShopItem(int slot, Material material, int buyPrice, int sellPrice)
|
||||
{
|
||||
PvpItem item = new PvpItem(material, (byte)0, 1, Clans.prettifyName(material), buyPrice, sellPrice, 64);
|
||||
addButton(slot, item, new ShopItemButton<FarmingPage>(this, item, buyPrice, sellPrice));
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package mineplex.game.clans.shop.farming;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
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.shop.ShopBase;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
|
||||
public class FarmingShop extends ShopBase<ClansManager>
|
||||
{
|
||||
public FarmingShop(ClansManager plugin, CoreClientManager clientManager, mineplex.core.donation.DonationManager donationManager)
|
||||
{
|
||||
super(plugin, clientManager, donationManager, "Organic Produce");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ShopPageBase<ClansManager, ? extends ShopBase<ClansManager>> buildPagesFor(Player player)
|
||||
{
|
||||
return new FarmingPage(getPlugin(), this, getClientManager(), getDonationManager(), player);
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package mineplex.game.clans.shop.farming;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftInventory;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.InventoryUtil;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.economy.GoldManager;
|
||||
import mineplex.game.clans.items.CustomItem;
|
||||
import mineplex.game.clans.items.GearManager;
|
||||
import mineplex.game.clans.items.economy.GoldToken;
|
||||
import mineplex.game.clans.shop.PvpItem;
|
||||
|
||||
public class ShopItemButton<T extends ShopPageBase> implements IButton
|
||||
{
|
||||
private int _buyPrice;
|
||||
private int _sellPrice;
|
||||
private T _page;
|
||||
private PvpItem _item;
|
||||
|
||||
public ShopItemButton(T page, PvpItem item, int buyPrice, int sellPrice)
|
||||
{
|
||||
_page = page;
|
||||
_item = item;
|
||||
_sellPrice = sellPrice;
|
||||
_buyPrice = buyPrice;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
boolean shiftClick = (clickType == ClickType.SHIFT_LEFT || clickType == ClickType.SHIFT_RIGHT);
|
||||
|
||||
if (clickType == ClickType.SHIFT_RIGHT || clickType == ClickType.RIGHT)
|
||||
{
|
||||
int amount = 1; // # of items removed/sold from inventory
|
||||
ItemStack dumbItem = new ItemStack(_item.getType(), amount);
|
||||
|
||||
if (!hasItem(player, dumbItem))
|
||||
{
|
||||
_page.playDenySound(player);
|
||||
notify(player, "You do not have any of the appropriate item in your inventory!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (shiftClick)
|
||||
{
|
||||
amount = InventoryUtil.getCountOfObjectsRemoved((CraftInventory)player.getInventory(), 36, dumbItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
InventoryUtil.removeItem((CraftInventory)player.getInventory(), 36, dumbItem);
|
||||
}
|
||||
|
||||
int reward = amount * _sellPrice;
|
||||
GoldManager.getInstance().addGold(player, reward);
|
||||
GoldManager.notify(player, String.format("You sold %d items for %dg!", amount, reward));
|
||||
_page.playAcceptSound(player);
|
||||
}
|
||||
else if (clickType == ClickType.SHIFT_LEFT || clickType == ClickType.LEFT)
|
||||
{
|
||||
int amount = shiftClick ? 64 : 1;
|
||||
int cost = amount * _buyPrice;
|
||||
int goldCount = GoldManager.getInstance().getGold(player);
|
||||
|
||||
if (goldCount >= cost)
|
||||
{
|
||||
GoldManager.getInstance().deductGold(player, cost);
|
||||
giftItem(player, amount);
|
||||
GoldManager.notify(player, String.format("You have purchased %d items for %dg!", amount, cost));
|
||||
_page.playAcceptSound(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
GoldManager.notify(player, "You cannot afford that item!");
|
||||
_page.playDenySound(player);
|
||||
}
|
||||
}
|
||||
|
||||
_page.refresh();
|
||||
}
|
||||
|
||||
private boolean hasItem(Player player, ItemStack item)
|
||||
{
|
||||
return InventoryUtil.first((CraftInventory)player.getInventory(), 36, item, true) != -1;
|
||||
}
|
||||
|
||||
private void notify(Player player, String message)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Shop", message));
|
||||
}
|
||||
|
||||
private void giftItem(Player player, int amount)
|
||||
{
|
||||
ItemStack item = new ItemStack(_item.getType(), amount);
|
||||
player.getInventory().addItem(item);
|
||||
}
|
||||
}
|
@ -10,6 +10,8 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -36,13 +38,25 @@ public class Spawn extends MiniPlugin
|
||||
super("Clan Spawn Zones", plugin);
|
||||
|
||||
_instance = this;
|
||||
_spawns = new WeightSet<Location>(new Location(getSpawnWorld(), -200, 85, 0), new Location(getSpawnWorld(), 200, 71, 0));
|
||||
_spawns = new WeightSet<Location>(getWestSpawn(), getEastSpawn());
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel most fire-spread mechanics to prevent mass destruction and uncontrollable fires.
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler
|
||||
public void onBlockIgnite(BlockIgniteEvent event)
|
||||
{
|
||||
if (event.getCause() != IgniteCause.FLINT_AND_STEEL)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRespawn(PlayerRespawnEvent event)
|
||||
{
|
||||
System.out.println("On respawn");
|
||||
event.setRespawnLocation(getSpawnLocation());
|
||||
}
|
||||
|
||||
@ -75,11 +89,6 @@ public class Spawn extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public World getSpawnWorld()
|
||||
{
|
||||
return Bukkit.getWorld("world");
|
||||
}
|
||||
|
||||
public Location getSpawnLocation()
|
||||
{
|
||||
Location spawn = _spawns.generateRandom().clone();
|
||||
@ -114,6 +123,31 @@ public class Spawn extends MiniPlugin
|
||||
return isInSpawn(player.getLocation());
|
||||
}
|
||||
|
||||
public static World getSpawnWorld()
|
||||
{
|
||||
return Bukkit.getWorld("world");
|
||||
}
|
||||
|
||||
public static Location getEastSpawn()
|
||||
{
|
||||
return new Location(getSpawnWorld(), 200, 68, 0);
|
||||
}
|
||||
|
||||
public static Location getWestSpawn()
|
||||
{
|
||||
return new Location(getSpawnWorld(), -200, 68, 0);
|
||||
}
|
||||
|
||||
public static Location getNorthShop()
|
||||
{
|
||||
return new Location(getSpawnWorld(), 8, 103, -200);
|
||||
}
|
||||
|
||||
public static Location getSouthShop()
|
||||
{
|
||||
return new Location(getSpawnWorld(), 8, 111, 200);
|
||||
}
|
||||
|
||||
private boolean isCombatTagged(Player player)
|
||||
{
|
||||
return false; // TODO: Check for implemented combat tagging?
|
||||
|
@ -0,0 +1,74 @@
|
||||
package mineplex.game.clans.spawn.travel;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftInventory;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.InventoryUtil;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.economy.GoldManager;
|
||||
import mineplex.game.clans.items.CustomItem;
|
||||
import mineplex.game.clans.items.GearManager;
|
||||
import mineplex.game.clans.items.economy.GoldToken;
|
||||
import mineplex.game.clans.shop.PvpItem;
|
||||
|
||||
public class TravelButton implements IButton
|
||||
{
|
||||
|
||||
private static final String LEFT_CLICK_TRAVEL = C.cYellow + "Left-Click" + C.cWhite + " to Warp" + C.cGreen + "!";
|
||||
|
||||
private TravelPage _page;
|
||||
private Location _location;
|
||||
private Material _iconMaterial;
|
||||
private String _name;
|
||||
|
||||
public TravelButton(TravelPage page, Location location, Material material, String name)
|
||||
{
|
||||
_page = page;
|
||||
_location = location;
|
||||
_iconMaterial = material;
|
||||
_name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
if (clickType != ClickType.LEFT) return;
|
||||
|
||||
transportPlayer(player);
|
||||
}
|
||||
|
||||
public ItemStack generateButtonItem()
|
||||
{
|
||||
ShopItem item = new ShopItem(_iconMaterial, (byte)0, _name, new String[]
|
||||
{
|
||||
C.cWhite + " ",
|
||||
LEFT_CLICK_TRAVEL,
|
||||
C.cWhite + "Costs " + C.cGreen + "$0",
|
||||
C.cWhite + "Travel to " + C.cGreen + _name + C.cWhite + "!",
|
||||
C.cWhite + " ",
|
||||
}, 0, false, false);
|
||||
return item;
|
||||
}
|
||||
|
||||
private void transportPlayer(Player player)
|
||||
{
|
||||
player.teleport(_location);
|
||||
_page.playAcceptSound(player);
|
||||
// TODO: Notify player? Effects here?
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package mineplex.game.clans.spawn.travel;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.game.clans.Clans;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.shop.PvpItem;
|
||||
import mineplex.game.clans.shop.PvpShopButton;
|
||||
import mineplex.game.clans.spawn.Spawn;
|
||||
|
||||
public class TravelPage extends ShopPageBase<ClansManager, TravelShop>
|
||||
{
|
||||
public TravelPage(ClansManager plugin, TravelShop shop, CoreClientManager clientManager, DonationManager donationManager, org.bukkit.entity.Player player)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, "Organic Produce", player, 27);
|
||||
|
||||
buildPage();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
addTravelLocation(Spawn.getEastSpawn(), Material.IRON_SWORD, "East Spawn", 14);
|
||||
addTravelLocation(Spawn.getWestSpawn(), Material.IRON_SWORD, "West Spawn", 12);
|
||||
addTravelLocation(Spawn.getNorthShop(), Material.EMERALD, "North Shop", 4);
|
||||
addTravelLocation(Spawn.getSouthShop(), Material.EMERALD, "South Shop", 22);
|
||||
}
|
||||
|
||||
public void addTravelLocation(Location location, Material material, String name, int slot)
|
||||
{
|
||||
TravelButton button = new TravelButton(this, location, material, name);
|
||||
addButton(slot, button.generateButtonItem(), button);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package mineplex.game.clans.spawn.travel;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
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.shop.ShopBase;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
|
||||
public class TravelShop extends ShopBase<ClansManager>
|
||||
{
|
||||
public TravelShop(ClansManager plugin, CoreClientManager clientManager, mineplex.core.donation.DonationManager donationManager)
|
||||
{
|
||||
super(plugin, clientManager, donationManager, "Travel Hub");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ShopPageBase<ClansManager, ? extends ShopBase<ClansManager>> buildPagesFor(Player player)
|
||||
{
|
||||
return new TravelPage(getPlugin(), this, getClientManager(), getDonationManager(), player);
|
||||
}
|
||||
}
|
@ -287,6 +287,30 @@ public class CustomDamageEvent extends Event implements Cancellable
|
||||
{
|
||||
return _knockbackMod;
|
||||
}
|
||||
|
||||
public double getKnockbackValue()
|
||||
{
|
||||
double value = 0.0d;
|
||||
|
||||
for (double knockback : _knockbackMod.values())
|
||||
{
|
||||
value += knockback;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invert knockback modifier values to their negative counterparts.
|
||||
*/
|
||||
public void invertKnockback()
|
||||
{
|
||||
for (String key : _knockbackMod.keySet())
|
||||
{
|
||||
double value = _knockbackMod.get(key);
|
||||
_knockbackMod.put(key, -value);
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<String> GetCancellers()
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ public class ServerManager
|
||||
{
|
||||
|
||||
// Connection host to server database
|
||||
private static final String DATABASE_HOST = "10.33.53.16";
|
||||
private static final String DATABASE_HOST = "10.3.203.80";
|
||||
|
||||
// Ports associated with slave redis instances
|
||||
private static final int[] SLAVE_PORTS = {6377, 6378, 6380, 6381, 6382};
|
||||
|
Loading…
Reference in New Issue
Block a user