Removed unnecessary classes.

This commit is contained in:
Blackvein 2013-10-25 10:17:39 -07:00
parent 3b654100f1
commit 96d4885468
9 changed files with 144 additions and 94 deletions

View File

@ -54,9 +54,9 @@ public class ItemData {
}
public class Data {
private String name_;
private int id_;
private byte data_;
private final String name_;
private final int id_;
private final byte data_;
public Data(String name, int id, byte mdata) {
this.name_ = name;

View File

@ -1,12 +0,0 @@
package me.blackvein.quests;
import net.minecraft.server.v1_6_R3.Packet;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class PacketUtils {
public static void sendPacket(Player player, Packet packet) {
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}

View File

@ -37,6 +37,8 @@ public class Quest {
List<String> permissionReqs = new LinkedList<String>();
List<String> mcMMOSkillReqs = new LinkedList<String>();
List<Integer> mcMMOAmountReqs = new LinkedList<Integer>();
String heroesPrimaryClassReq = null;
String heroesSecondaryClassReq = null;
public String failRequirements = null;
//
//Rewards
@ -186,6 +188,20 @@ public class Quest {
}
if(heroesPrimaryClassReq != null){
if(plugin.testPrimaryHeroesClass(heroesPrimaryClassReq, player.getName()) == false)
return false;
}
if(heroesSecondaryClassReq != null){
if(plugin.testSecondaryHeroesClass(heroesSecondaryClassReq, player.getName()) == false)
return false;
}
if (quester.questPoints < questPointsReq) {
return false;
}
@ -462,6 +478,26 @@ public class Quest {
return false;
}
if (other.heroesPrimaryClassReq != null && heroesPrimaryClassReq != null) {
if (other.heroesPrimaryClassReq.equals(heroesPrimaryClassReq) == false) {
return false;
}
} else if (other.heroesPrimaryClassReq != null && heroesPrimaryClassReq == null) {
return false;
} else if (other.heroesPrimaryClassReq == null && heroesPrimaryClassReq != null) {
return false;
}
if (other.heroesSecondaryClassReq != null && heroesSecondaryClassReq != null) {
if (other.heroesSecondaryClassReq.equals(heroesSecondaryClassReq) == false) {
return false;
}
} else if (other.heroesSecondaryClassReq != null && heroesSecondaryClassReq == null) {
return false;
} else if (other.heroesSecondaryClassReq == null && heroesSecondaryClassReq != null) {
return false;
}
if (other.permissions.equals(permissions) == false) {
return false;
}
@ -496,4 +532,5 @@ public class Quest {
return true;
}
}

View File

@ -82,14 +82,13 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
@Override
public String getPromptText(ConversationContext context) {
String text =
GOLD + "- Quest Editor -\n"
String text
= GOLD + "- Quest Editor -\n"
+ BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("questEditorCreate") + "\n"
+ BLUE + "" + BOLD + "2" + RESET + YELLOW + " - " + Lang.get("questEditorEdit") + "\n"
+ BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("questEditorDelete") + "\n"
+ GOLD + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("exit");
return text;
}
@ -153,8 +152,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
@Override
public String getPromptText(ConversationContext context) {
String text =
GOLD + "- Quest: " + AQUA + context.getSessionData(CK.Q_NAME) + GOLD + " -\n";
String text
= GOLD + "- Quest: " + AQUA + context.getSessionData(CK.Q_NAME) + GOLD + " -\n";
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("questEditorName") + "\n";
@ -164,14 +163,12 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - " + Lang.get("questEditorAskMessage") + " (\"" + context.getSessionData(CK.Q_ASK_MESSAGE) + "\")\n";
}
if (context.getSessionData(CK.Q_FINISH_MESSAGE) == null) {
text += BLUE + "" + BOLD + "3" + RESET + RED + " - " + Lang.get("questEditorFinishMessage") + " " + DARKRED + "(Required, none set)\n";
} else {
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("questEditorFinishMessage") + " (\"" + context.getSessionData(CK.Q_FINISH_MESSAGE) + "\")\n";
}
if (context.getSessionData(CK.Q_REDO_DELAY) == null) {
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("questEditorRedoDelay") + " (None set)\n";
} else {
@ -212,7 +209,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
if (context.getSessionData(CK.Q_INITIAL_EVENT) == null) {
if (quests.citizens != null) {
@ -239,7 +235,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
text += BLUE + "" + BOLD + "7" + RESET + DARKAQUA + " - " + Lang.get("questEditorReqs") + "\n";
}
if (quests.citizens != null) {
text += BLUE + "" + BOLD + "9" + RESET + PINK + " - " + Lang.get("questEditorStages") + "\n";
} else {
@ -252,7 +247,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
text += BLUE + "" + BOLD + "9" + RESET + GREEN + " - " + Lang.get("questEditorRews") + "\n";
}
if (quests.citizens != null) {
text += BLUE + "" + BOLD + "11" + RESET + GOLD + " - " + Lang.get("save") + "\n";
} else {
@ -265,7 +259,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
text += BLUE + "" + BOLD + "11" + RESET + RED + " - " + Lang.get("exit") + "\n";
}
return text;
}
@ -538,7 +531,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
selectedBlockStarts.remove(player);
}
return new CreateMenuPrompt();
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
@ -892,8 +884,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
LinkedList<String> mcMMOSkillRews = null;
LinkedList<Integer> mcMMOSkillAmounts = null;
if (cc.getSessionData(CK.Q_REDO_DELAY) != null) {
redo = (Long) cc.getSessionData(CK.Q_REDO_DELAY);
}
@ -906,8 +896,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
blockStart = Quests.getLocationInfo((Location) cc.getSessionData(CK.Q_START_BLOCK));
}
if (cc.getSessionData(CK.REQ_MONEY) != null) {
moneyReq = (Integer) cc.getSessionData(CK.REQ_MONEY);
}
@ -932,7 +920,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (cc.getSessionData(CK.REQ_QUEST_BLOCK) != null) {
questBlocks = (LinkedList<String>) cc.getSessionData(CK.REQ_QUEST_BLOCK);
}
if (cc.getSessionData(CK.REQ_MCMMO_SKILLS) != null) {
mcMMOSkillReqs = (LinkedList<String>) cc.getSessionData(CK.REQ_MCMMO_SKILLS);
mcMMOAmountReqs = (LinkedList<Integer>) cc.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS);
@ -989,8 +977,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
mcMMOSkillAmounts = (LinkedList<Integer>) cc.getSessionData(CK.REW_MCMMO_AMOUNTS);
}
cs.set("name", name);
cs.set("npc-giver-id", npcStart);
cs.set("block-start", blockStart);
@ -999,8 +985,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
cs.set("finish-message", finish);
cs.set(CK.S_FINISH_EVENT, initialEvent);
if (moneyReq != null || questPointsReq != null || itemReqs != null && itemReqs.isEmpty() == false || permReqs != null && permReqs.isEmpty() == false || (questReqs != null && questReqs.isEmpty() == false) || (questBlocks != null && questBlocks.isEmpty() == false) ||(mcMMOSkillReqs != null && mcMMOSkillReqs.isEmpty() == false)) {
if (moneyReq != null || questPointsReq != null || itemReqs != null && itemReqs.isEmpty() == false || permReqs != null && permReqs.isEmpty() == false || (questReqs != null && questReqs.isEmpty() == false) || (questBlocks != null && questBlocks.isEmpty() == false) || (mcMMOSkillReqs != null && mcMMOSkillReqs.isEmpty() == false)) {
ConfigurationSection reqs = cs.createSection("requirements");
List<String> items = new LinkedList<String>();
@ -1027,7 +1012,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
cs.set("requirements", null);
}
ConfigurationSection stages = cs.createSection("stages");
ConfigurationSection ordered = stages.createSection("ordered");
@ -1357,7 +1341,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
if (moneyRew != null || questPointsRew != null || itemRews != null && itemRews.isEmpty() == false || permRews != null && permRews.isEmpty() == false || expRew != null || commandRews != null && commandRews.isEmpty() == false || mcMMOSkillRews != null || RPGItemRews != null) {
ConfigurationSection rews = cs.createSection("rewards");
@ -1418,8 +1401,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (q.blockQuests.isEmpty() == false) {
cc.setSessionData(CK.REQ_QUEST_BLOCK, q.blockQuests);
}
if(q.mcMMOSkillReqs.isEmpty() == false){
if (q.mcMMOSkillReqs.isEmpty() == false) {
cc.setSessionData(CK.REQ_MCMMO_SKILLS, q.mcMMOSkillReqs);
cc.setSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS, q.mcMMOAmountReqs);
}
@ -1428,11 +1411,19 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
cc.setSessionData(CK.REQ_PERMISSION, q.permissionReqs);
}
if(q.mcMMOSkillReqs.isEmpty() == false) {
if (q.heroesPrimaryClassReq != null) {
cc.setSessionData(CK.REQ_HEROES_PRIMARY_CLASS, q.heroesPrimaryClassReq);
}
if (q.heroesSecondaryClassReq != null) {
cc.setSessionData(CK.REQ_HEROES_SECONDARY_CLASS, q.heroesSecondaryClassReq);
}
if (q.mcMMOSkillReqs.isEmpty() == false) {
cc.setSessionData(CK.REQ_MCMMO_SKILLS, q.mcMMOSkillReqs);
cc.setSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS, q.mcMMOAmountReqs);
}
if (q.failRequirements != null) {
cc.setSessionData(CK.Q_FAIL_MESSAGE, q.failRequirements);
}
@ -1464,7 +1455,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
cc.setSessionData(CK.REW_MCMMO_AMOUNTS, q.mcmmoAmounts);
}
if(q.rpgItemRewardIDs.isEmpty() == false) {
if (q.rpgItemRewardIDs.isEmpty() == false) {
cc.setSessionData(CK.REW_RPG_ITEM_IDS, q.rpgItemRewardIDs);
cc.setSessionData(CK.REW_RPG_ITEM_AMOUNTS, q.rpgItemRewardAmounts);
}
@ -1492,7 +1483,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
if (stage.blocksToDamage != null) {
LinkedList<Integer> ids = new LinkedList<Integer>();
@ -1510,7 +1500,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
if (stage.blocksToPlace != null) {
LinkedList<Integer> ids = new LinkedList<Integer>();
@ -1545,7 +1534,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
if (stage.blocksToCut != null) {
LinkedList<Integer> ids = new LinkedList<Integer>();
@ -1563,17 +1551,14 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
if (stage.fishToCatch != null) {
cc.setSessionData(pref + CK.S_FISH, stage.fishToCatch);
}
if (stage.playersToKill != null) {
cc.setSessionData(pref + CK.S_PLAYER_KILL, stage.playersToKill);
}
if (stage.itemsToEnchant.isEmpty() == false) {
LinkedList<String> enchants = new LinkedList<String>();
@ -1598,7 +1583,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
if (stage.itemsToDeliver.isEmpty() == false) {
LinkedList<ItemStack> items = new LinkedList<ItemStack>();
@ -1618,7 +1602,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
if (stage.citizensToInteract.isEmpty() == false) {
LinkedList<Integer> npcs = new LinkedList<Integer>();
@ -1630,7 +1613,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
if (stage.citizensToKill.isEmpty() == false) {
LinkedList<Integer> npcs = new LinkedList<Integer>();
@ -1643,7 +1625,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
if (stage.bossesToKill.isEmpty() == false) {
cc.setSessionData(pref + CK.S_BOSS_IDS, stage.bossesToKill);
@ -1651,7 +1632,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
if (stage.mobsToKill.isEmpty() == false) {
LinkedList<String> mobs = new LinkedList<String>();
@ -1677,7 +1657,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
if (stage.locationsToReach.isEmpty() == false) {
LinkedList<String> locs = new LinkedList<String>();
@ -1691,7 +1670,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
if (stage.mobsToTame.isEmpty() == false) {
LinkedList<String> mobs = new LinkedList<String>();
@ -1709,7 +1687,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
if (stage.sheepToShear.isEmpty() == false) {
LinkedList<String> colors = new LinkedList<String>();
@ -1725,7 +1702,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
if (stage.startEvent != null) {
cc.setSessionData(pref + CK.S_START_EVENT, stage.startEvent.getName());
}
@ -1755,7 +1731,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
if (stage.delay != -1) {
cc.setSessionData(pref + CK.S_DELAY, stage.delay);
if (stage.delayMessage != null) {
@ -1847,8 +1822,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
@Override
public String getPromptText(ConversationContext context) {
String text =
RED + Lang.get("questEditorDeleted") + " \"" + GOLD + (String) context.getSessionData(CK.ED_QUEST_DELETE) + RED + "\"?\n";
String text
= RED + Lang.get("questEditorDeleted") + " \"" + GOLD + (String) context.getSessionData(CK.ED_QUEST_DELETE) + RED + "\"?\n";
text += YELLOW + Lang.get("yes") + "/" + Lang.get(Lang.get("no"));
return text;
@ -1897,7 +1872,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
try {
data.save(questsFile);
} catch (IOException e) {
@ -1909,6 +1883,5 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
context.getForWhom().sendRawMessage(WHITE + "" + BOLD + "Quest deleted! Quests and Events have been reloaded.");
}
}

View File

@ -5,6 +5,8 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import com.herocraftonline.heroes.Heroes;
import com.herocraftonline.heroes.characters.Hero;
import com.herocraftonline.heroes.characters.classes.HeroClass;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
@ -26,8 +28,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import me.ThaH3lper.com.EpicBoss;
import me.ThaH3lper.com.Mobs.EpicMobs;
import static me.blackvein.quests.ColorUtil.GREEN;
import static me.blackvein.quests.ColorUtil.RED;
import me.blackvein.quests.prompts.QuestAcceptPrompt;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
@ -563,6 +563,26 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
}
if(quest.heroesPrimaryClassReq != null){
if(this.testPrimaryHeroesClass(quest.heroesPrimaryClassReq, player.getName())){
cs.sendMessage(BOLD + "" + DARKRED + quest.heroesPrimaryClassReq + RESET + "" + RED + " class");
}else{
cs.sendMessage(BOLD + "" + GREEN + quest.heroesPrimaryClassReq + RESET + "" + DARKGREEN + " class");
}
}
if(quest.heroesSecondaryClassReq != null){
if(this.testSecondaryHeroesClass(quest.heroesSecondaryClassReq, player.getName())){
cs.sendMessage(BOLD + "" + DARKRED + quest.heroesSecondaryClassReq + RESET + "" + RED + " class");
}else{
cs.sendMessage(BOLD + "" + GREEN + quest.heroesSecondaryClassReq + RESET + "" + DARKGREEN + " class");
}
}
if (quest.mcMMOSkillReqs.isEmpty() == false) {
for (String skill : quest.mcMMOSkillReqs) {
@ -2041,6 +2061,38 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
}
if (config.contains("quests." + s + ".requirements.heroes-primary-class")) {
String className = config.getString("quests." + s + ".requirements.heroes-primary-class");
HeroClass hc = heroes.getClassManager().getClass(className);
if(hc != null && hc.isPrimary()){
quest.heroesPrimaryClassReq = hc.getName();
}else if(hc != null){
printSevere("[Quests] heroes-primary-class: Requirement for Quest " + quest.name + " is not a primary Heroes class!");
continue;
}else{
printSevere("[Quests] heroes-primary-class: Requirement for Quest " + quest.name + " is not a valid Heroes class!");
continue;
}
}
if (config.contains("quests." + s + ".requirements.heroes-secondary-class")) {
String className = config.getString("quests." + s + ".requirements.heroes-secondary-class");
HeroClass hc = heroes.getClassManager().getClass(className);
if(hc != null && hc.isSecondary()){
quest.heroesSecondaryClassReq = hc.getName();
}else if(hc != null){
printSevere("[Quests] heroes-secondary-class: Requirement for Quest " + quest.name + " is not a secondary Heroes class!");
continue;
}else{
printSevere("[Quests] heroes-secondary-class: Requirement for Quest " + quest.name + " is not a valid Heroes class!");
continue;
}
}
}
quest.plugin = this;
@ -4574,4 +4626,28 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
}
public Hero getHero(String player){
Player p = getServer().getPlayer(player);
if(p == null)
return null;
return heroes.getCharacterManager().getHero(p);
}
public boolean testPrimaryHeroesClass(String primaryClass, String player){
Hero hero = getHero(player);
return hero.getHeroClass().getName().equalsIgnoreCase(primaryClass);
}
public boolean testSecondaryHeroesClass(String secondaryClass, String player){
Hero hero = getHero(player);
return hero.getHeroClass().getName().equalsIgnoreCase(secondaryClass);
}
}

View File

@ -1,19 +0,0 @@
package me.blackvein.quests;
import java.lang.reflect.Field;
public class ReflectionUtilities {
public static void setValue(Object instance, String fieldName, Object value) throws Exception {
Field field = instance.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
field.set(instance, value);
}
public static Object getValue(Object instance, String fieldName) throws Exception {
Field field = instance.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
return field.get(instance);
}
}

View File

@ -0,0 +1 @@
Add Heroes class requirements to the RequirementsPrompt, saveQuest() and loadQuest() stages etc. etc.

View File

@ -1,8 +0,0 @@
- Do NOT translate the texts on the left-hand side, only the ones on the right.
Example: Translate "Event Editor", NOT "eventEditorTitle"
- Keep all capitalization in phrases (if the first word is capitalized, keep it that way)
- Keep all punctuation (if there is a period at the end of a phrase, keep it there. If there isn't, don't add one etc.)
- Keep all brackets, parentheses and quotation marks.
- The ___ 's just mean that there is a number or something before the phrase, it is just so you can understand the context.
Example: "___ is not a number!" just means that when the actual message is printed out, something will be put in place of the ___,
so keep that in mind when you are translating.

View File

@ -22,8 +22,10 @@ public class CK {
public static final String REQ_ITEMS = "itemReqs";
public static final String REQ_ITEMS_REMOVE = "removeItemReqs";
public static final String REQ_PERMISSION = "permissionReqs";
public static final String REQ_MCMMO_SKILLS = "mcMMOSkillReqs";
public static final String REQ_MCMMO_SKILL_AMOUNTS = "mcMMOSkillAmountReqs";
public static final String REQ_MCMMO_SKILLS = "mcMMOSkillReqs";
public static final String REQ_MCMMO_SKILL_AMOUNTS = "mcMMOSkillAmountReqs";
public static final String REQ_HEROES_PRIMARY_CLASS = "heroesPrimaryClassReq";
public static final String REQ_HEROES_SECONDARY_CLASS = "heroesSecondaryClassReq";
public static final String REQ_QUEST = "questReqs";
public static final String REQ_QUEST_BLOCK= "questBlocks";