QA Testing fixes

This commit is contained in:
Sam 2017-02-09 23:47:17 +00:00
parent e76ce9dce2
commit e8b5c180ee
13 changed files with 200 additions and 66 deletions

View File

@ -1,6 +1,5 @@
package mineplex.gemhunters.chat;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;

View File

@ -14,6 +14,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
@ -77,6 +78,7 @@ public class DeathModule extends MiniPlugin
// Stop the player dieing
player.setHealth(20);
player.setFoodLevel(20);
player.setSaturation(20);
player.setExhaustion(0);
@ -114,7 +116,7 @@ public class DeathModule extends MiniPlugin
if (player == null)
{
_toRemove.remove(key);
iterator.remove();
continue;
}
@ -185,6 +187,15 @@ public class DeathModule extends MiniPlugin
event.setCancelled(true);
}
}
@EventHandler
public void inventory(InventoryClickEvent event)
{
if (_toRemove.containsKey(event.getWhoClicked().getUniqueId()))
{
event.setCancelled(true);
}
}
@EventHandler
public void playerQuit(PlayerQuitEvent event)

View File

@ -15,7 +15,6 @@ import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@ -27,22 +26,21 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.donation.DonationManager;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.gemhunters.death.events.PlayerCustomRespawnEvent;
@ReflectivelyCreateMiniPlugin
public class CashOutModule extends MiniPlugin
{
private static final DecimalFormat ARMOUR_STAND_FORMAT = new DecimalFormat("0.0");
private static final ItemStack CASH_OUT_ITEM = new ItemBuilder(Material.EMERALD).setTitle(C.cGreen + "Cash Out").addLore("", C.cGray + "Click to begin the process to cash out.", C.cGray + "Cashing out saves your current loot.").build();
public static final ItemStack CASH_OUT_ITEM = new ItemBuilder(Material.EMERALD).setTitle(C.cGreen + "Cash Out").addLore("", C.cGray + "Click to begin the process to cash out.", C.cGray + "Cashing out saves your current loot.").build();
private static final int CASH_OUT_COOLDOWN = 10000;
private static final int CASH_OUT_MAX_MOVE_DISTANCE_SQUARED = 4;
@ -89,7 +87,7 @@ public class CashOutModule extends MiniPlugin
{
if (event.getItemDrop().getItemStack().isSimilar(CASH_OUT_ITEM))
{
event.getPlayer().sendMessage(F.main("Game", "You cannnot drop the " + F.item("Cash Out Item") + "."));
event.getPlayer().sendMessage(F.main("Game", "You cannot drop the " + F.item("Cash Out Item") + "."));
event.setCancelled(true);
}
}
@ -112,18 +110,8 @@ public class CashOutModule extends MiniPlugin
}
@EventHandler
public void respawn(PlayerCustomRespawnEvent event)
{
Player player = event.getPlayer();
player.getInventory().setItem(8, CASH_OUT_ITEM);
}
// TODO this probably
// @EventHandler
public void playerQuit(PlayerQuitEvent event)
{
attemptCashOut(event.getPlayer());
}
@EventHandler
@ -143,7 +131,7 @@ public class CashOutModule extends MiniPlugin
CashOutSession session = _sessions.get(key);
double current = session.getCurrent();
ArmorStand stand = session.getArmourStand();
String standName = ARMOUR_STAND_FORMAT.format(current) + " seconds";
String standName = ARMOUR_STAND_FORMAT.format(current);
if (player == null)
{
@ -152,8 +140,8 @@ public class CashOutModule extends MiniPlugin
continue;
}
UtilTextMiddle.display("", UtilTextMiddle.progress((float) (1 - current / session.getMax())), 0, 10, 0, player);
stand.setCustomName(standName);
UtilTextMiddle.display(C.cGreen + standName, UtilTextMiddle.progress((float) (1 - current / session.getMax())), 0, 10, 0, player);
stand.setCustomName(standName + " seconds");
session.setCurrent(current - 0.05);
if (session.getCurrent() <= 0)

View File

@ -22,69 +22,76 @@ public class EconomyModule extends MiniPlugin
{
private static final float GEM_KILL_FACTOR = 0.5F;
private Map<UUID, Integer> _storedGems;
public EconomyModule()
{
super("Economy");
_storedGems = new HashMap<>();
}
@EventHandler
public void respawn(PlayerCustomRespawnEvent event)
{
_storedGems.put(event.getPlayer().getUniqueId(), 0);
addToStore(event.getPlayer(), null, 100);
}
@EventHandler
public void death(PlayerDeathEvent event)
{
Player player = event.getEntity();
Entity killer = event.getEntity().getKiller();
if (!(killer instanceof Player))
{
return;
}
Player killerPlayer = (Player) killer;
int oldGems = _storedGems.get(player.getUniqueId());
int newGems = (int) (oldGems * GEM_KILL_FACTOR);
addToStore(killerPlayer, "Killing " + F.name(player.getName()), newGems);
removeFromStore(player, oldGems);
}
@EventHandler
public void cashOut(PlayerCashOutCompleteEvent event)
{
event.incrementGems(_storedGems.get(event.getPlayer().getUniqueId()));
event.incrementGems(getGems(event.getPlayer()));
}
@EventHandler
public void quit(PlayerQuitEvent event)
{
_storedGems.remove(event.getPlayer().getUniqueId());
}
public void addToStore(Player player, String reason, int gems)
{
_storedGems.put(player.getUniqueId(), _storedGems.get(player.getUniqueId()) + gems);
UUID key = player.getUniqueId();
if (!_storedGems.containsKey(key))
{
_storedGems.put(key, 0);
}
_storedGems.put(key, _storedGems.get(key) + gems);
if (reason != null)
{
player.sendMessage(F.main(_moduleName, "+" + F.currency(GlobalCurrency.GEM, gems) + " (" + reason + ")."));
}
}
public void removeFromStore(Player player, int gems)
{
_storedGems.put(player.getUniqueId(), _storedGems.get(player.getUniqueId()) - gems);
addToStore(player, null, -gems);
}
public int getGems(Player player)
{
return _storedGems.get(player.getUniqueId());
@ -99,5 +106,5 @@ public class EconomyModule extends MiniPlugin
addToStore(event.getPlayer(), "Testing", 100);
}
}
}

View File

@ -44,6 +44,7 @@ import mineplex.gemhunters.loot.rewards.LootItemReward;
import mineplex.gemhunters.loot.rewards.LootRankReward;
import mineplex.gemhunters.safezone.SafezoneModule;
import mineplex.gemhunters.util.SlackSheetsBot;
import mineplex.gemhunters.util.UtilDebug;
import mineplex.gemhunters.world.WorldDataModule;
@ReflectivelyCreateMiniPlugin
@ -207,7 +208,7 @@ public class LootModule extends MiniPlugin
continue;
}
Bukkit.broadcastMessage("Spawned at " + UtilWorld.blockToStrClean(block) + " with key=" + key + " and index=" + index + " and max=" + spawned + "/" + max);
UtilDebug.d("Spawned at " + UtilWorld.blockToStrClean(block) + " with key=" + key + " and index=" + index + " and max=" + spawned + "/" + max);
_spawnedChest.add(new SpawnedChest(chestToPlace, properties, index));
block.setType(properties.getBlockMaterial());
}

View File

@ -11,6 +11,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.recharge.Recharge;
import mineplex.gemhunters.util.UtilDebug;
public abstract class LootItemReward
{
@ -69,7 +70,7 @@ public abstract class LootItemReward
public final void success()
{
Bukkit.broadcastMessage("Success");
UtilDebug.d("Success");
onSuccessful();
}

View File

@ -133,7 +133,7 @@ public class ScoreboardModule extends MiniPlugin
Team team = handle.registerNewTeam(otherPlayer.getName());
team.setPrefix(C.cYellow);
team.setSuffix(scoreboard.getSuffix(player, otherPlayer));
//team.setSuffix(scoreboard.getSuffix(player, otherPlayer));
team.addEntry(otherPlayer.getName());
if (player.equals(otherPlayer))
@ -146,7 +146,7 @@ public class ScoreboardModule extends MiniPlugin
Team otherTeam = otherHandle.registerNewTeam(player.getName());
otherTeam.setPrefix(C.cYellow);
otherTeam.setSuffix(other.getSuffix(other.getOwner(), player));
//otherTeam.setSuffix(other.getSuffix(other.getOwner(), player));
otherTeam.addEntry(player.getName());
}

View File

@ -8,7 +8,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Villager;
import org.bukkit.event.EventHandler;
@ -27,6 +26,7 @@ import mineplex.gemhunters.loot.deserialisers.LootItemDeserialiser;
import mineplex.gemhunters.safezone.SafezoneModule;
import mineplex.gemhunters.shop.deserialisers.VillagerPropertiesDeserialiser;
import mineplex.gemhunters.util.SlackSheetsBot;
import mineplex.gemhunters.util.UtilDebug;
import mineplex.gemhunters.world.WorldDataModule;
@ReflectivelyCreateMiniPlugin
@ -207,17 +207,37 @@ public class ShopModule extends MiniPlugin
continue;
}
int index = UtilMath.r(locations.size());
int index = getFreeIndex(locations.size(), usedIndexes);
if (index == -1)
{
return;
}
Location randomLocation = locations.get(index);
usedIndexes.add(index);
Bukkit.broadcastMessage("Trader at " + UtilWorld.locToStrClean(randomLocation) + " with key=" + key + " and index=" + index + " and max=" + spawned + "/" + max);
UtilDebug.d("Trader at " + UtilWorld.locToStrClean(randomLocation) + " with key=" + key + " and index=" + index + " and max=" + spawned + "/" + max);
_npcs.add(new TraderNPC(_plugin, randomLocation, Villager.class, NAMES[UtilMath.r(NAMES.length)], _safezone.isInSafeZone(randomLocation), properties, getRandomItemSet(_trades.get(key))));
}
}
public Set<TradeableItem> getRandomItemSet(Set<TradeableItem> items)
private int getFreeIndex(int endIndex, Set<Integer> used)
{
int index = -1;
while (index == -1 || used.contains(index))
{
index = UtilMath.r(endIndex);
}
used.add(index);
return index;
}
private Set<TradeableItem> getRandomItemSet(Set<TradeableItem> items)
{
int size = UtilMath.rRange(MINIMUM_ITEMS, MAXIMUM_ITEMS);
Set<TradeableItem> items2 = new HashSet<>(size);

View File

@ -16,7 +16,9 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.Managers;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilItem;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.gemhunters.economy.EconomyModule;
import mineplex.gemhunters.util.SimpleNPC;
@ -45,7 +47,7 @@ public class TraderNPC extends SimpleNPC
for (TradeableItem item : _selling)
{
ItemStack itemStack = new ItemBuilder(item.getLootItem().getItemStack()).addLore("", "Cost: " + F.currency(GlobalCurrency.GEM, item.getCost())).build();
ItemStack itemStack = new ItemBuilder(item.getLootItem().getItemStack()).addLore("Cost: " + F.currency(GlobalCurrency.GEM, item.getCost())).build();
_inv.setItem(index++, itemStack);
}
@ -77,6 +79,8 @@ public class TraderNPC extends SimpleNPC
return;
}
event.setCancelled(true);
ItemStack itemStack = event.getCurrentItem();
if (itemStack == null)
@ -93,16 +97,18 @@ public class TraderNPC extends SimpleNPC
return;
}
event.setCancelled(true);
if (cost > gems)
{
player.sendMessage(F.main(_entity.getCustomName(), "I'm sorry you don't have enough gems to purchase this."));
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0.6F);
return;
}
_economy.removeFromStore(player, cost);
String itemName = ItemStackFactory.Instance.GetName(itemStack, true);
player.sendMessage(F.main(_entity.getCustomName(), "Purchased " + F.elem(itemName) + "!"));
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1, 1.2F);
player.getInventory().addItem(itemStack);
player.closeInventory();

View File

@ -5,7 +5,6 @@ import org.bukkit.Material;
import org.bukkit.WorldBorder;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
import org.bukkit.event.EventHandler;
@ -23,6 +22,7 @@ import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.portal.Intent;
import mineplex.core.portal.Portal;
import mineplex.gemhunters.economy.CashOutModule;
import mineplex.gemhunters.safezone.SafezoneModule;
import mineplex.gemhunters.util.ColouredTextAnimation;
import mineplex.gemhunters.util.SimpleNPC;
@ -32,8 +32,9 @@ import mineplex.gemhunters.world.WorldDataModule;
public class SpawnModule extends MiniPlugin
{
private static final int WORLD_BORDER_RADIUS = 900;
private static final int WORLD_BORDER_RADIUS = 750;
private static final int MAX_SPAWNING_Y = 73;
private final SafezoneModule _safezone;
private final WorldDataModule _worldData;
@ -83,20 +84,22 @@ public class SpawnModule extends MiniPlugin
{
@Override
public void run(Player data)
public void run(Player player)
{
Location location = getRandomLocation();
if (location == null)
{
data.sendMessage(F.main(_moduleName, "A suitable teleport location could not be found. Please try again in a few seconds."));
player.sendMessage(F.main(_moduleName, "A suitable teleport location could not be found. Please try again in a few seconds."));
return;
}
data.teleport(location);
data.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 4 * 20, 9));
data.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 4 * 20, 9));
player.teleport(location);
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 4 * 20, 9));
player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 4 * 20, 9));
player.getInventory().setItem(8, CashOutModule.CASH_OUT_ITEM);
ColouredTextAnimation animation = new ColouredTextAnimation("GEM HUNTERS", C.cGoldB + "M ", C.cGoldB + " M", new String[] { C.cDGreenB, C.cGreenB, C.cWhiteB });
runSyncTimer(new BukkitRunnable()
@ -105,7 +108,7 @@ public class SpawnModule extends MiniPlugin
@Override
public void run()
{
if (animation.displayAsTitle(data))
if (animation.displayAsTitle(player))
{
cancel();
}
@ -130,11 +133,11 @@ public class SpawnModule extends MiniPlugin
});
}
{
Location location = _worldData.getCustomLocation("CARL").get(0);
Location location = _worldData.getCustomLocation("TUTORIAL").get(0);
location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _spawn)));
new SimpleNPC(_plugin, location, Creeper.class, C.cGreenB + "Carl", new Callback<Player>()
new SimpleNPC(_plugin, location, Villager.class, C.cGoldB + "Tutorial", new Callback<Player>()
{
@Override
@ -155,7 +158,7 @@ public class SpawnModule extends MiniPlugin
Block up = block.getRelative(BlockFace.UP);
Block down = block.getRelative(BlockFace.DOWN);
if (block.getType() != Material.AIR || down.getType() == Material.AIR || UtilBlock.liquid(down) || UtilBlock.liquid(up) || UtilBlock.liquid(block) || _safezone.isInSafeZone(block.getLocation()))
if (block.getType() != Material.AIR || down.getType() == Material.AIR || UtilBlock.liquid(down) || UtilBlock.liquid(up) || UtilBlock.liquid(block) || _safezone.isInSafeZone(block.getLocation()) || block.getLocation().getBlockY() > MAX_SPAWNING_Y)
{
return false;
}

View File

@ -0,0 +1,27 @@
package mineplex.gemhunters.util;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
public class UtilDebug
{
public static final void d(String message)
{
for (Player player : Bukkit.getOnlinePlayers())
{
if (player.getItemInHand() == null || player.getItemInHand().getType() != Material.SPONGE)
{
continue;
}
if (player.getName().equals("Moppletop"))
{
player.sendMessage(message);
return;
}
}
}
}

View File

@ -69,7 +69,7 @@ public class WorldDataModule extends MiniPlugin
TimingManager.stop("WorldData loading world.");
World.setDifficulty(Difficulty.HARD);
World.setDifficulty(Difficulty.EASY);
World.setGameRuleValue("showDeathMessages", "false");
TimingManager.start("WorldData loading WorldConfig.");

View File

@ -1,23 +1,50 @@
package mineplex.gemhunters.world;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.hanging.HangingEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.inventory.BrewerInventory;
import org.bukkit.plugin.java.JavaPlugin;
import org.spigotmc.SpigotConfig;
public class WorldListeners implements Listener
{
private static final int VIEW_DISTANCE = 10;
public WorldListeners(JavaPlugin plugin)
{
plugin.getServer().getPluginManager().registerEvents(this, plugin);
plugin.getServer().getScheduler().runTaskLater(plugin, () -> {
for (World world : plugin.getServer().getWorlds())
{
SpigotConfig.config.set("world-settings.world.view-distance", VIEW_DISTANCE);
((CraftWorld) world).getHandle().spigotConfig.viewDistance = VIEW_DISTANCE;
Bukkit.broadcastMessage(((CraftWorld) world).getHandle().spigotConfig.viewDistance + " chunks");
}
}, 20);
}
@EventHandler(priority = EventPriority.LOWEST)
@ -32,7 +59,7 @@ public class WorldListeners implements Listener
@EventHandler(priority = EventPriority.LOWEST)
public void blockPlace(BlockPlaceEvent event)
{
if (shouldBlock(event.getPlayer()))
if (event.getBlockPlaced().getType() != Material.CAKE_BLOCK && shouldBlock(event.getPlayer()))
{
event.setCancelled(true);
}
@ -56,10 +83,54 @@ public class WorldListeners implements Listener
}
}
@EventHandler
public void armorStandDamage(EntityDamageEvent event)
{
if (event.getEntity() instanceof ArmorStand)
{
event.setCancelled(true);
}
}
@EventHandler
public void paintings(HangingBreakEvent event)
{
event.setCancelled(true);
}
@EventHandler
public void inventoryOpen(InventoryOpenEvent event)
{
if (event.getInventory() instanceof BrewerInventory)
{
event.setCancelled(true);
}
}
@EventHandler
public void chunkUnload(ChunkUnloadEvent event)
{
// Sam don't you dare look here, I understand the implications of this but entities, can I just save by UUID? or does not doing this have bigger complications?.
// Sam don't you dare look here, I understand the implications of this
// but entities, can I just save by UUID? or does not doing this have
// bigger complications?.
event.setCancelled(true);
}
@EventHandler
public void fireSpread(BlockIgniteEvent event)
{
event.setCancelled(true);
}
@EventHandler
public void fireSpread(BlockBurnEvent event)
{
event.setCancelled(true);
}
@EventHandler
public void blockDecay(BlockFadeEvent event)
{
event.setCancelled(true);
}