Skip to content

Commit

Permalink
Lots of in place bug fixes during official playtesting and debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
Dove-Bren committed Aug 1, 2016
1 parent fb91b18 commit 5b3933e
Show file tree
Hide file tree
Showing 26 changed files with 248 additions and 30 deletions.
Expand Up @@ -138,6 +138,7 @@
import com.skyisland.questmanager.ui.menu.action.PartyInviteAction;
import com.skyisland.questmanager.ui.menu.action.ShowSkillMenuAction;
import com.skyisland.questmanager.ui.menu.action.ShowSkillRecipesAction;
import com.skyisland.questmanager.ui.menu.action.ShowSpellsMenuAction;
import com.skyisland.questmanager.ui.menu.inventory.ServiceInventory;
import com.skyisland.questmanager.ui.menu.inventory.ShopInventory;
import com.skyisland.questmanager.ui.menu.message.BioptionMessage;
Expand Down Expand Up @@ -375,7 +376,10 @@ public void onDisable() {
//unregister our scheduler
Bukkit.getScheduler().cancelTasks(this);

playerManager.getParties().forEach(Party::disband);
//playerManager.getParties().forEach(Party::disband);
while (!playerManager.getParties().isEmpty()) {
playerManager.getParties().iterator().next().disband();
}

//save user database
playerManager.save(new File(getDataFolder(), playerConfigFileName));
Expand Down Expand Up @@ -828,6 +832,10 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
return true;
}

if (args[0].equals("spells")) {
new ShowSpellsMenuAction(qp).onAction();
}

if (args[0].equals("recipe")) {
String skillName = args[1];

Expand Down
Expand Up @@ -130,14 +130,14 @@ public void apply(Entity e, MagicUser cause) {
targ.damage(curDamage, cause.getEntity());
// targ.damage(0.0, cause.getEntity());
// targ.setHealth(Math.max(0.0, Math.min(targ.getMaxHealth(), targ.getHealth() - curDamage)));
targ.setMetadata(DAMAGE_META_KEY, new FixedMetadataValue
(QuestManagerPlugin.questManagerPlugin, true));

//make sure they didn't invincible their way out damage
if (invi && Math.abs(snapshot - targ.getHealth()) < .0001) {
//targ.setHealth(targ.getHealth() - curDamage);
targ.setHealth(Math.max(0.0, Math.min(targ.getMaxHealth(), targ.getHealth() - curDamage)));
}
targ.setMetadata(DAMAGE_META_KEY, new FixedMetadataValue
(QuestManagerPlugin.questManagerPlugin, false));

if (cause instanceof QuestPlayer) {
QuestPlayer qp = (QuestPlayer) cause;
Expand Down
Expand Up @@ -100,7 +100,7 @@ public void apply(Entity e, MagicUser cause) {
(QuestManagerPlugin.questManagerPlugin, true));
targ.damage(0.0, cause.getEntity());
targ.setMetadata(DamageEffect.DAMAGE_META_KEY, new FixedMetadataValue
(QuestManagerPlugin.questManagerPlugin, true));
(QuestManagerPlugin.questManagerPlugin, false));
}
}

Expand Down
Expand Up @@ -119,10 +119,13 @@ public void apply(Entity e, MagicUser cause) {
msg = ChatColor.DARK_GRAY + "You gained the effect ";
} else {
String name = cause.getEntity().getCustomName();
if (cause.getEntity() instanceof Player) {
name = ((Player) cause.getEntity()).getName();
}
if (name == null) {
name = cause.getEntity().getType().toString();
}
msg = ChatColor.GRAY + cause.getEntity().getCustomName() + ChatColor.DARK_GRAY
msg = ChatColor.GRAY + name + ChatColor.DARK_GRAY
+ " gave you the effect ";
}

Expand All @@ -144,7 +147,7 @@ public void apply(Entity e, MagicUser cause) {
(QuestManagerPlugin.questManagerPlugin, true));
targ.damage(0.0, cause.getEntity());
targ.setMetadata(DamageEffect.DAMAGE_META_KEY, new FixedMetadataValue
(QuestManagerPlugin.questManagerPlugin, true));
(QuestManagerPlugin.questManagerPlugin, false));
}

}
Expand Down
Expand Up @@ -49,7 +49,9 @@ public enum Key {
SKILL_LIST("skill.inLog", new ItemStack(Material.WRITTEN_BOOK),
Lists.newArrayList("Display skill levels in", "the questlog. If off, you", "can still use the command", "/player skills", "to see your skill levels"), true),
SKILL_RECIPES_ALL("skill.recipes.all", new ItemStack(Material.SHEARS),
Lists.newArrayList("Shows all recipes for", "a skill even if it is", "way more difficult than", "what you could achieve"));
Lists.newArrayList("Shows all recipes for", "a skill even if it is", "way more difficult than", "what you could achieve")),
SHOW_PLAYER_MENU("player.menu", new ItemStack(Material.SKULL_ITEM),
Lists.newArrayList("Right click players to see", "a player menu"));

private String key;

Expand Down
Expand Up @@ -113,4 +113,8 @@ public FoodItem clone() {
ret.setQuality(this.getQuality());
return ret;
}

public int setFoodLevel(double calculateFoodLevel) {
return foodLevel;
}
}
Expand Up @@ -85,6 +85,7 @@ public void perform(QuestPlayer participant, int actionLevel, boolean fail) {
//every level difference between skill and player decreases xp. Each level differene is
//1/[cutoff] reduction. That way, we get a nice approach towards 0 at the cutoff
float xp = (float) (base * (1-(Math.abs((double) levelDifference) / (double) config.getSkillCutoff())));
xp = Math.max(0, xp);

//lulz now just add it to player xp
participant.setSkillExperience(this, participant.getSkillExperience(this) + xp);
Expand Down
Expand Up @@ -700,7 +700,8 @@ else if (line.toLowerCase().contains("food level:"))
double qualityDifference = food.getQuality() - 1.0;
qualityDifference = qualityDifference * hungerRate;
int newLevel = Math.min(20, e.getPlayer().getFoodLevel()
+ (int) Math.round(food.getFoodLevel() * (1 + qualityDifference)));
// + (int) Math.round(food.getFoodLevel() * (1 + qualityDifference)));
+ (int) Math.round(food.getFoodLevel()));

FoodLevelChangeEvent event = new FoodLevelChangeEvent(e.getPlayer(), newLevel);
Bukkit.getPluginManager().callEvent(event);
Expand All @@ -726,5 +727,11 @@ public List<SkillRecipe> getRecipes() {
return list;
}


public double calculateFoodLevel(int initialFoodLevel, double quality) {
double additional = Math.max(0, quality - 1);
additional *= hungerRate;

return initialFoodLevel + additional;

}
}
Expand Up @@ -41,6 +41,7 @@
import com.skyisland.questmanager.player.QuestPlayer;
import com.skyisland.questmanager.player.skill.CraftingSkill;
import com.skyisland.questmanager.player.skill.Skill;
import com.skyisland.questmanager.player.skill.defaults.MagerySkill;
import com.skyisland.questmanager.quest.Quest;

/**
Expand Down Expand Up @@ -261,6 +262,9 @@ public static void updateQuestlog(QuestPlayer qp, boolean silent) {
if (s instanceof CraftingSkill) {
title.tooltip(desc + "\n\n" + ChatColor.BLUE + "Click here for recipes")
.command("/player recipe " + s.getName());
} else if (s instanceof MagerySkill) {
title.tooltip(desc + "\n\n" + ChatColor.BLUE + "Click here to see your spells")
.command("/player spells");
} else {
title.tooltip(desc);
}
Expand Down
Expand Up @@ -87,15 +87,19 @@ public void onInventoryInteract(InventoryClickEvent e) {
return;
}

if (!e.getWhoClicked().getUniqueId().equals(player.getPlayer().getUniqueId())) {
return;
}

//our inventory event!
int pos = e.getRawSlot();

e.setCancelled(true);
if (gui.getItem(pos) == null || gui.getItem(pos).getAction(player) == null) {
if (gui.getItem(pos, e.getAction()) == null || gui.getItem(pos, e.getAction()).getAction(player) == null) {
return;
}

gui.getItem(pos).getAction(player).onAction();
gui.getItem(pos, e.getAction()).getAction(player).onAction();
}

@EventHandler
Expand Down
Expand Up @@ -50,7 +50,9 @@ public enum Repairable {
CHESTPLATE,
LEGGINGS,
HELMET,
BOOTS;
BOOTS,
SHIELD,
ROD;

public static boolean isRepairable(Material mat) {

Expand Down
Expand Up @@ -64,7 +64,8 @@ public void onAction() {

Player p = player.getPlayer().getPlayer();

if (player.getFame() < fameCheck) {
//if (player.getFame() < fameCheck) {
if (player.getAlphaFame() < fameCheck) {
p.sendMessage(DENIAL_FAME);
return;
}
Expand Down
Expand Up @@ -63,7 +63,8 @@ public void onAction() {

Player p = player.getPlayer().getPlayer();

if (player.getFame() < fameCheck) {
//if (player.getFame() < fameCheck) {
if (player.getAlphaFame() < fameCheck) {
p.sendMessage(DENIAL_FAME);
return;
}
Expand Down
@@ -0,0 +1,154 @@
/*
* QuestManager: An RPG plugin for the Bukkit API.
* Copyright (C) 2015-2016 Github Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.skyisland.questmanager.ui.menu.action;

import java.util.LinkedList;
import java.util.List;

import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import com.skyisland.questmanager.QuestManagerPlugin;
import com.skyisland.questmanager.magic.spell.SimpleTargetSpell;
import com.skyisland.questmanager.magic.spell.Spell;
import com.skyisland.questmanager.player.QuestPlayer;
import com.skyisland.questmanager.ui.menu.InventoryMenu;
import com.skyisland.questmanager.ui.menu.inventory.BasicInventory;
import com.skyisland.questmanager.ui.menu.inventory.BasicInventoryItem;

public class ShowSpellsMenuAction implements MenuAction {

private QuestPlayer player;

public ShowSpellsMenuAction(QuestPlayer player) {
this.player = player;
}

@Override
public void onAction() {
BasicInventory inv = new BasicInventory();
// List<String> descList;
// for (Skill.Type type : Skill.Type.values()) {
//
// boolean spoil = player.getOptions().getOption(PlayerOptions.Key.SKILL_REVEAL);
// for (Skill s : QuestManagerPlugin.questManagerPlugin.getSkillManager().getSkills(type)) {
// //get a formatted description. (Code from QuestPlayer's magic menu)
//
// if (!spoil && player.getSkillLevel(s) <= 0 && player.getSkillExperience(s) <= 0) {
// continue;
// }
//
// descList = formatDescription(s.getDescription(player));
//
// descList.add(0, ChatColor.DARK_GREEN + "" + player.getSkillLevel(s) + "."
// + ((int) (player.getSkillExperience(s)*100)) + "");
//
// descList.add(0, s.getName());
//
// MenuAction responseAction = null;
//
//
// if (s instanceof CraftingSkill) {
// descList.add(" ");
// descList.add(ChatColor.BLUE + "Click here for recipes");
// responseAction = new ShowSkillRecipesAction(player, (CraftingSkill) s);
// }
//
// inv.addInventoryItem(new BasicInventoryItem(
// s.getIcon(), descList, responseAction
// ));
//
//
// }
// }

if (player.getSpells() == null || player.getSpells().isEmpty()) {
player.getPlayer().getPlayer().sendMessage(
ChatColor.RED + "You do not know any spells");
return;
}

for (String t : player.getSpells()) {
List<String> descList = new LinkedList<>();
Spell sp = QuestManagerPlugin.questManagerPlugin.getSpellManager().getSpell(t);
if (sp != null) {

descList.add(ChatColor.RED + sp.getName());
descList.add(ChatColor.GOLD + "Difficulty: " + sp.getDifficulty());
descList.add(ChatColor.BLUE + "Mana Cost: " + sp.getCost());
if (sp instanceof SimpleTargetSpell) {
SimpleTargetSpell spell = (SimpleTargetSpell) sp;
descList.add(ChatColor.DARK_GREEN + "Range: " + spell.getMaxDistance());
descList.add(ChatColor.DARK_PURPLE + "Speed: " + spell.getSpeed());
}

String desc;
desc = sp.getDescription();

String mid;
int pos;
while (desc.length() > 30) {

desc = desc.trim();

//find first space before 30
mid = desc.substring(0, 30);
pos = mid.lastIndexOf(" ");
if (pos == -1) {
descList.add(mid);
desc = desc.substring(30);
continue;
}
//else we found a space
descList.add(mid.substring(0, pos));
desc = desc.substring(pos);
}

descList.add(desc.trim());
} else {
descList.add("No Description");
}

// String desc = "";
// for (int i = 0; i < descList.size() - 1; i++) {
// desc += descList.get(i) + "\n";
// }
// desc += descList.get(descList.size() - 1);
// opts.add(new ChatMenuOption(
// new PlainMessage(t),
// new ChangeSpellHolderAction(this, holder, t),
// new FancyMessage("").then(desc)));
ItemStack icon = new ItemStack(Material.EMPTY_MAP);
ItemMeta meta = icon.getItemMeta();
meta.setDisplayName(sp.getName());
icon.setItemMeta(meta);
inv.addInventoryItem(new BasicInventoryItem(
icon, descList, null
));
}


InventoryMenu menu = new InventoryMenu(player, inv);
QuestManagerPlugin.questManagerPlugin.getInventoryGuiHandler().showMenu(
player.getPlayer().getPlayer(), menu);
}

}
Expand Up @@ -28,6 +28,7 @@
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
Expand Down Expand Up @@ -209,7 +210,7 @@ public static BasicInventory valueOf(Map<String, Object> configMap) {
}

@Override
public InventoryItem getItem(int pos) {
public InventoryItem getItem(int pos, InventoryAction action) {
return items.get(pos);
}
}
Expand Up @@ -25,6 +25,7 @@
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
Expand Down Expand Up @@ -127,7 +128,7 @@ public Map<String, Object> serialize() {
}

@Override
public InventoryItem getItem(int pos) {
public InventoryItem getItem(int pos, InventoryAction action) {
//real logic is here
/*
* Check slot. If in player's inventory, try to take. If in top inventory, try and put back.
Expand Down

0 comments on commit 5b3933e

Please sign in to comment.