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.

This commit is contained in:
Ty Sayers 2015-06-22 16:20:20 -04:00
parent 4dd1cf43de
commit 2ffe2badf2
45 changed files with 1169 additions and 167 deletions

View File

@ -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;
@ -109,4 +110,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;
}
}

View File

@ -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();

View File

@ -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;
@ -47,7 +48,8 @@ import mineplex.game.clans.clans.war.WarManager;
import mineplex.game.clans.economy.GoldManager;
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;
@ -136,7 +138,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);
@ -189,6 +192,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()

View File

@ -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));
}
}

View File

@ -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]);
}

View File

@ -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)

View File

@ -31,6 +31,9 @@ import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.fields.repository.FieldRepository;
import mineplex.game.clans.items.generation.WeightSet;
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;
@ -54,6 +57,8 @@ public class GoldManager extends MiniPlugin
_donationManager = donationManager;
_transferTracker = new TransferTracker();
_bankShop = new BankShop(plugin, clientManager, donationManager);
new FarmingShop(plugin, clientManager, donationManager);
new TravelShop(plugin, clientManager, donationManager);
}
@EventHandler
@ -84,7 +89,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);
}
}
@ -162,7 +166,7 @@ public class GoldManager extends MiniPlugin
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));
}

View File

@ -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)

View File

@ -56,7 +56,6 @@ public class QuitCommand extends CommandBase<LoggingManager>
else
{
_loggingManager.insertLogoutData(caller);
UtilPlayer.message(caller, F.main("SafeLog", "Successfully initiated safe-log!"));
}
}
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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 = "";

View File

@ -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}.
*/

View File

@ -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));
}
}
}
/**

View File

@ -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;

View File

@ -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);
}
}
}

View File

@ -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;

View File

@ -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)
{
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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();
}
}

View File

@ -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);
}
}

View File

@ -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)
{
}
}

View File

@ -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;
}
}

View File

@ -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));
}
}

View File

@ -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?
}
}

View File

@ -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)
{
}
}

View File

@ -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;

View File

@ -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;

View File

@ -47,7 +47,7 @@ public class FrostedAttribute extends ItemAttribute
@Override
public void onAttacked(CustomDamageEvent event)
{
Player damager = event.GetDamagerPlayer(true);
Player damager = event.GetDamagerPlayer(false);
if (damager != null)
{

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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)
{

View File

@ -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[]

View File

@ -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;
}
}

View File

@ -5,6 +5,7 @@ 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;
@ -13,7 +14,7 @@ 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);
super(plugin, shop, clientManager, donationManager, "Organic Produce", player, 9);
buildPage();
}
@ -21,14 +22,18 @@ public class FarmingPage extends ShopPageBase<ClansManager, FarmingShop>
@Override
protected void buildPage()
{
addPvpItem(1, new PvpItem(Material.STONE, (byte)0, 1, "Stone", 25, 64));
addPvpItem(2, new PvpItem(Material.WOOD, (byte)0, 1, "Wood", 15, 64));
addPvpItem(3, new PvpItem(Material.BRICK, (byte)0, 1, "Bricks", 30, 64));
addPvpItem(4, new PvpItem(Material.SANDSTONE, (byte)0, 1, "Sandstone", 30, 64));
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 addPvpItem(int slot, PvpItem item)
public void addShopItem(int slot, Material material, int buyPrice, int sellPrice)
{
addButton(slot, item, new PvpShopButton<FarmingPage>(this, item));
PvpItem item = new PvpItem(material, (byte)0, 1, Clans.prettifyName(material), buyPrice, sellPrice, 64);
addButton(slot, item, new ShopItemButton<FarmingPage>(this, item, buyPrice, sellPrice));
}
}

View File

@ -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);
}
}

View File

@ -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?

View File

@ -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?
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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()
{

View File

@ -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};