Fix Illusion bug causing the Illusion clone to not properly function and spawn inside Clan territories. Fix bug where Carrots and Potatoes purchased from the Produce shop could not be eaten. Fix bug with SQL query when adding new enemies and not initialized 'initiator' field with a proper value. Modify starting score values for clan wars to 0 instead of 20. Update CustomItem descriptions with bullet points instead of hyphens for more readable stats. Reword error messages associated with trusting non-allied clans to be more intuitive to players.

This commit is contained in:
Ty Sayers 2015-09-29 17:36:42 -04:00
parent 033425a20b
commit bc7615a5c3
18 changed files with 88 additions and 33 deletions

View File

@ -83,7 +83,7 @@ public class Creature extends MiniPlugin
return;
}
CreatureSpawnCustomEvent customEvent = new CreatureSpawnCustomEvent(event.getLocation());
CreatureSpawnCustomEvent customEvent = new CreatureSpawnCustomEvent(event.getLocation(), event.getSpawnReason());
_plugin.getServer().getPluginManager().callEvent(customEvent);

View File

@ -4,6 +4,7 @@ import org.bukkit.Location;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
public class CreatureSpawnCustomEvent extends Event implements Cancellable
{
@ -11,10 +12,12 @@ public class CreatureSpawnCustomEvent extends Event implements Cancellable
private boolean _cancelled = false;
private Location _location;
private SpawnReason _reason;
public CreatureSpawnCustomEvent(Location location)
public CreatureSpawnCustomEvent(Location location, SpawnReason reason)
{
_location = location;
_reason = reason;
}
public HandlerList getHandlers()
@ -43,4 +46,9 @@ public class CreatureSpawnCustomEvent extends Event implements Cancellable
{
return _location;
}
public SpawnReason getReason()
{
return _reason;
}
}

View File

@ -62,7 +62,7 @@ public class ClanRepository extends RepositoryBase
private static String ADD_CLAN = "INSERT INTO clans (serverId, name, description, home, admin, dateCreated, energy, lastOnline) VALUES (?, ?, ?, ?, ?, now(), ?, now());";
private static String ADD_CLAN_MEMBER = "INSERT INTO accountClan (accountId, clanId, clanRole) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.name = ?;";
private static String ADD_CLAN_ALLIANCE = "INSERT INTO clanAlliances (clanId, otherClanId, trusted) VALUES (?, ?, ?);";
private static String ADD_CLAN_ENEMY = "INSERT INTO clanEnemies (clanId, otherClanId, timeFormed) VALUES (?, ?, now());";
private static String ADD_CLAN_ENEMY = "INSERT INTO clanEnemies (clanId, otherClanId, initiator, timeFormed) VALUES (?, ?, 1, now());";
private static String ADD_CLAN_TERRITORY = "INSERT INTO clanTerritory (clanId, chunk, safe) VALUES (?, ?, ?);";
private static String UPDATE_CLAN = "UPDATE clans SET name = ?, description = ?, home = ?, admin = ?, energy = ?, kills = ?, murder = ?, deaths = ?, warWins = ?, warLosses = ?, lastOnline = ? WHERE id = ?;";

View File

@ -515,7 +515,7 @@ public class ClansAdmin
if (!callerClan.isAlly(otherClan.getName()))
{
UtilPlayer.message(caller, F.main("Clans Admin", "You cannot give trust to enemies."));
UtilPlayer.message(caller, F.main("Clans Admin", "You must be allied to trust a clan!"));
return;
}

View File

@ -344,12 +344,14 @@ public class ClansDataAccessLayer
ClanEnemyToken clanEnemyToken = new ClanEnemyToken();
clanEnemyToken.Initiator = true;
clanEnemyToken.TimeFormed = currDate;
clanEnemyToken.Score = 0;
clanEnemyToken.EnemyName = otherClan.getName();
clan.updateEnemy(clanEnemyToken);
clan.updateEnemy(clanEnemyToken);
ClanEnemyToken otherClanEnemyToken = new ClanEnemyToken();
otherClanEnemyToken.Initiator = false;
otherClanEnemyToken.TimeFormed = currDate;
otherClanEnemyToken.Score = 0;
otherClanEnemyToken.EnemyName = clan.getName();
otherClan.updateEnemy(otherClanEnemyToken);

View File

@ -19,7 +19,6 @@ import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
@ -59,13 +58,6 @@ public class ClansGame extends MiniPlugin
super("Clans Game", plugin);
Clans = clans;
}
@EventHandler
public void preventHorseSpawn(CreatureSpawnEvent event)
{
if (event.getEntityType() == EntityType.HORSE)
event.setCancelled(true);
}
@EventHandler
@ -468,7 +460,9 @@ public class ClansGame extends MiniPlugin
//Block Placement
if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
{
if (player.getItemInHand().getType() != Material.AIR)
{
if (player.getGameMode() != GameMode.CREATIVE && Clans.getClanBlocks().denyUsePlace(player.getItemInHand().getTypeId()))
{
//Disallow
@ -485,6 +479,8 @@ public class ClansGame extends MiniPlugin
return;
}
}
}
}
@EventHandler(priority = EventPriority.LOWEST)

View File

@ -15,6 +15,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemBreakEvent;
@ -412,9 +413,11 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
{
ClanInfo clan = _clanUtility.getOwner(event.GetLocation());
if (clan != null)
if (!clan.isAdmin() && !clan.getName().equals("Spawn"))
event.setCancelled(true);
if (clan != null && !clan.isAdmin()
&& !clan.getName().equals("Spawn") && event.getReason() != SpawnReason.CUSTOM)
{
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST)

View File

@ -38,7 +38,8 @@ public class EnemyData
public void addScore(int add)
{
_score = Math.max(0, Math.min(_score + add, 40));
int newScore = _score + add;
_score = Math.max(-40, Math.min(40, newScore)); // Cap range of score to [-40, 40]
}
public void addKill()

View File

@ -15,7 +15,7 @@ public class ClansAllyChatCommand extends CommandBase<ClansManager>
{
super(plugin, Rank.ALL, "ac");
}
@Override
public void Execute(Player caller, String[] args)
{

View File

@ -779,7 +779,7 @@ public class ClansCommand extends CommandBase<ClansManager>
if (!cA.isAlly(cB.getName()))
{
UtilPlayer.message(caller, F.main("Clans", "You cannot give trust to enemies."));
UtilPlayer.message(caller, F.main("Clans", "You must be allied to trust a clan!"));
return;
}

View File

@ -57,7 +57,7 @@ public class WarManager extends MiniPlugin
private WarState calculateWarState()
{
// Get a calendar snapshot of the current time using server timezone
Calendar calendar = Calendar.getInstance(_clansManager.getServerTimeZone());
Calendar calendar = getCurrentDate();
WarState warState = WarState.WAR;
@ -68,6 +68,12 @@ public class WarManager extends MiniPlugin
return warState;
}
private Calendar getCurrentDate()
{
Calendar date = Calendar.getInstance(_clansManager.getServerTimeZone());
return date;
}
public void attemptEnemy(Player player, ClanInfo initiatingClan, ClanInfo otherClan)
{
@ -178,7 +184,7 @@ public class WarManager extends MiniPlugin
*/
public Date getNextEnemyTime()
{
Calendar c = Calendar.getInstance(_clansManager.getServerTimeZone());
Calendar c = getCurrentDate();
int currDayOfWeek = c.get(Calendar.DAY_OF_WEEK);
c.set(Calendar.DAY_OF_WEEK, CREATE_ENEMY_DATE);
@ -198,7 +204,7 @@ public class WarManager extends MiniPlugin
*/
public Date getNextInvadeTime()
{
Calendar c = Calendar.getInstance(_clansManager.getServerTimeZone());
Calendar c = getCurrentDate();
int currDayOfWeek = c.get(Calendar.DAY_OF_WEEK);
c.set(Calendar.DAY_OF_WEEK, INVADE_ENEMY_DATE);
@ -214,7 +220,7 @@ public class WarManager extends MiniPlugin
public Date getNextWarStart()
{
Calendar c = Calendar.getInstance(_clansManager.getServerTimeZone());
Calendar c = getCurrentDate();
int currDayOfWeek = c.get(Calendar.DAY_OF_WEEK);
c.set(Calendar.DAY_OF_WEEK, INVADE_ENEMY_DATE);

View File

@ -78,7 +78,7 @@ public class CustomItem
// Display attribute descriptions and stats in lore
for (ItemAttribute attribute : _attributes.getAttributes())
{
String attributeLine = ATTRIBUTE_COLOR + "-" + attribute.getDescription();
String attributeLine = ATTRIBUTE_COLOR + "" + attribute.getDescription();
lore.add(attributeLine);
}

View File

@ -11,6 +11,8 @@ import java.util.Set;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
@ -401,11 +403,16 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
/**
* @return singleton instance of {@link GearManager}.
*/
public static GearManager getInstane()
public static GearManager getInstance()
{
return _instance;
}
public static void notify(Player player, String message)
{
UtilPlayer.message(player, F.main("Gear", message));
}
/**
* @param player - the player to see if they should have their out-going packets
* masked on CustomGear items.
@ -431,6 +438,7 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
net.minecraft.server.v1_7_R4.ItemStack original = slotPacket.c;
CraftItemStack originalItem = CraftItemStack.asCraftMirror(original);
ItemMeta originalMeta = originalItem.getItemMeta();
if (originalMeta == null || originalMeta.getLore() == null) return; // No need to modify item packets with no lore
List<String> lore = new ArrayList<String>();

View File

@ -3,6 +3,7 @@ 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 net.minecraft.server.v1_7_R4.Material;
import org.bukkit.GameMode;
import org.bukkit.entity.Entity;
@ -20,6 +21,7 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.java.JavaPlugin;
@ -47,11 +49,11 @@ public class ItemListener implements Listener
{
if (event.getNewGameMode() == GameMode.CREATIVE) // Entering creative mode
{
GearManager.getInstane().addCreativePlayer(event.getPlayer());
GearManager.getInstance().addCreativePlayer(event.getPlayer());
}
else if (event.getPlayer().getGameMode() == GameMode.CREATIVE) // Exiting creative mode
{
GearManager.getInstane().removeCreativePlayer(event.getPlayer());
GearManager.getInstance().removeCreativePlayer(event.getPlayer());
}
}
@ -161,17 +163,45 @@ public class ItemListener implements Listener
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
// Prevent players from equipping armour items in hand (prevents lore-breaking bug)
ItemStack itemInHand = event.getItem();
if (isArmour(itemInHand))
{
Action action = event.getAction();
boolean rightClick = action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK;
if (rightClick)
{
event.setCancelled(true);
GearManager.notify(event.getPlayer(), "You must manually equip armour!");
return;
}
}
// Activate weapon interact abilities
PlayerGear playerGear = getGear(event.getPlayer());
playerGear.onInteract(event);
}
/**
* @param type - the {@link org.bukkit.Material} type to be checked for armour type
* @return true, if {@code type} is an equipable armour-based material, false otherwise.
*/
private boolean isArmour(ItemStack item)
{
if (item == null) return false;
String name = item.getType().toString();
return name.endsWith("HELMET") || name.endsWith("CHESTPLATE")
|| name.endsWith("LEGGINGS") || name.endsWith("BOOTS");
}
/**
* @param player - the player whose gear is to be fetched
* @return the {@link PlayerGear} associated with {@code player}.
*/
private PlayerGear getGear(Player player)
{
return GearManager.getInstane().getPlayerGear(player);
return GearManager.getInstance().getPlayerGear(player);
}
}

View File

@ -58,8 +58,8 @@ public class GearCommand extends CommandBase<GearManager>
}
else
{
Vector direction = caller.getLocation().getDirection().normalize();
_gearManager.spawnItem(caller.getEyeLocation().add(direction));
//caller.setFoodLevel(10);
//return;
}
}

View File

@ -80,7 +80,7 @@ public class ShopItemButton<T extends ShopPageBase<?, ?>> implements IButton
if (success)
{
giftItem(player, amount);
GoldManager.notify(player, String.format("You have purchased %d items for %dg!", amount, cost));
GoldManager.notify(player, String.format("You have purchased %d item(s) for %dg!", amount, cost));
_page.playAcceptSound(player);
}
else

View File

@ -24,14 +24,14 @@ public class FarmingPage extends ClansShopPage<FarmingShop>
@Override
protected void buildPage()
{
addShopItem(1, Material.POTATO, 15, 3);
addShopItem(1, Material.POTATO_ITEM, 15, 3);
addShopItem(2, Material.MELON, 5, 1);
addShopItem(3, Material.BREAD, 30, 6);
addShopItem(4, Material.COOKED_BEEF, 50, 10);
addShopItem(5, Material.GRILLED_PORK, 50, 10);
addShopItem(6, Material.COOKED_CHICKEN, 35, 7);
addShopItem(7, Material.FEATHER, 50, 10);
addShopItem(8, Material.CARROT, 10, 2);
addShopItem(8, Material.CARROT_ITEM, 10, 2);
addShopItem(10, Material.MUSHROOM_SOUP, 200, 40);
addShopItem(11, Material.SUGAR_CANE, 15, 3);
addShopItem(12, Material.PUMPKIN, 30, 6);

View File

@ -14,6 +14,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
import mineplex.core.updater.event.UpdateEvent;