Cleanup method names and descriptions

This commit is contained in:
PikaMug 2019-09-12 17:00:54 -04:00
parent 0db230452d
commit cfb7be4272
3 changed files with 60 additions and 53 deletions

View File

@ -221,7 +221,7 @@ public abstract class CustomObjective implements Listener {
quester.finishObjective(quest, "customObj", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, goal), null, null, null, null, null, null, null, obj);
// Multiplayer
quester.dispatchMultiplayerEventShareObjective(quest, quester.getCurrentStage(quest), (Quester q) -> {
quester.dispatchMultiplayerObjectives(quest, quester.getCurrentStage(quest), (Quester q) -> {
q.getQuestData(quest).customObjectiveCounts.put(obj.getName(), quester.getQuestData(quest).customObjectiveCounts.get(obj.getName()));
q.finishObjective(quest, "customObj", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, goal), null, null, null, null, null, null, null, obj);
return null;

View File

@ -934,8 +934,9 @@ public class Quester {
* Check if player's current stage has the specified objective<p>
*
* Accepted strings are: breakBlock, damageBlock, placeBlock, useBlock,
* cutBlock, catchFish, enchantItem, killMob, deliverItem, killPlayer,
* talkToNPC, killNPC, tameMob, shearSheep, password, reachLocation
* cutBlock, craftItem, smeltItem, enchantItem, brewItem, catchFish,
* killMob, deliverItem, killPlayer, talkToNPC, killNPC, tameMob,
* shearSheep, password, reachLocation
*
* @deprecated Use containsObjective() instead
* @param quest The quest to check objectives of
@ -950,8 +951,9 @@ public class Quester {
* Check if player's current stage has the specified objective<p>
*
* Accepted strings are: breakBlock, damageBlock, placeBlock, useBlock,
* cutBlock, catchFish, enchantItem, killMob, deliverItem, killPlayer,
* talkToNPC, killNPC, tameMob, shearSheep, password, reachLocation
* cutBlock, craftItem, smeltItem, enchantItem, brewItem, catchFish,
* killMob, deliverItem, killPlayer, talkToNPC, killNPC, tameMob,
* shearSheep, password, reachLocation
*
* @param quest The quest to check objectives of
* @param s The type of objective to check for
@ -1080,7 +1082,7 @@ public class Quester {
// Multiplayer
final ItemStack finalBroken = broken;
final ItemStack finalToBreak = toBreak;
dispatchMultiplayerEventShareObjective(quest, getCurrentStage(quest), (Quester q) -> {
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
q.getQuestData(quest).blocksBroken.set(getQuestData(quest).blocksBroken.indexOf(finalBroken), newBroken);
q.finishObjective(quest, "breakBlock", m, finalToBreak, null, null, null, null, null, null, null, null);
return null;
@ -1145,7 +1147,7 @@ public class Quester {
// Multiplayer
final ItemStack finalDamaged = damaged;
final ItemStack finalToDamage = toDamage;
dispatchMultiplayerEventShareObjective(quest, getCurrentStage(quest), (Quester q) -> {
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
q.getQuestData(quest).blocksDamaged.set(getQuestData(quest).blocksDamaged.indexOf(finalDamaged), newDamaged);
q.finishObjective(quest, "damageBlock", m, finalToDamage, null, null, null, null, null, null, null, null);
return null;
@ -1210,7 +1212,7 @@ public class Quester {
// Multiplayer
final ItemStack finalPlaced = placed;
final ItemStack finalToPlace = toPlace;
dispatchMultiplayerEventShareObjective(quest, getCurrentStage(quest), (Quester q) -> {
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
q.getQuestData(quest).blocksPlaced.set(getQuestData(quest).blocksPlaced.indexOf(finalPlaced), newplaced);
q.finishObjective(quest, "damageBlock", m, finalToPlace, null, null, null, null, null, null, null, null);
return null;
@ -1275,7 +1277,7 @@ public class Quester {
// Multiplayer
final ItemStack finalUsed = used;
final ItemStack finalToUse = toUse;
dispatchMultiplayerEventShareObjective(quest, getCurrentStage(quest), (Quester q) -> {
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
q.getQuestData(quest).blocksUsed.set(getQuestData(quest).blocksUsed.indexOf(finalUsed), newUsed);
q.finishObjective(quest, "useBlock", m, finalToUse, null, null, null, null, null, null, null, null);
return null;
@ -1340,7 +1342,7 @@ public class Quester {
// Multiplayer
final ItemStack finalCut = cut;
final ItemStack finalToCut = toCut;
dispatchMultiplayerEventShareObjective(quest, getCurrentStage(quest), (Quester q) -> {
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
q.getQuestData(quest).blocksCut.set(getQuestData(quest).blocksCut.indexOf(finalCut), newCut);
q.finishObjective(quest, "cutBlock", m, finalToCut, null, null, null, null, null, null, null, null);
return null;
@ -1383,7 +1385,7 @@ public class Quester {
// Multiplayer
final ItemStack finalFound = found;
dispatchMultiplayerEventShareObjective(quest, getCurrentStage(quest), (Quester q) -> {
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
q.getQuestData(quest).itemsCrafted.put(finalFound, req);
q.finishObjective(quest, "craftItem", new ItemStack(m, 1), finalFound, null, null, null, null, null, null, null, null);
return null;
@ -1428,7 +1430,7 @@ public class Quester {
// Multiplayer
final ItemStack finalFound = found;
dispatchMultiplayerEventShareObjective(quest, getCurrentStage(quest), (Quester q) -> {
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
q.getQuestData(quest).itemsSmelted.put(finalFound, req);
q.finishObjective(quest, "smeltItem", new ItemStack(m, 1), finalFound, null, null, null, null, null, null, null, null);
return null;
@ -1461,7 +1463,7 @@ public class Quester {
finishObjective(quest, "enchantItem", new ItemStack(m, 1), finalToEnchant, e, null, null, null, null, null, null, null);
// Multiplayer
dispatchMultiplayerEventShareObjective(quest, getCurrentStage(quest), (Quester q) -> {
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
q.getQuestData(quest).itemsEnchanted.put(entry.getKey(), num);
q.finishObjective(quest, "enchantItem", new ItemStack(m, 1), finalToEnchant, null, null, null, null, null, null, null, null);
return null;
@ -1509,7 +1511,7 @@ public class Quester {
// Multiplayer
final ItemStack finalFound = found;
dispatchMultiplayerEventShareObjective(quest, getCurrentStage(quest), (Quester q) -> {
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
q.getQuestData(quest).itemsBrewed.put(finalFound, req);
q.finishObjective(quest, "brewItem", new ItemStack(m, 1), finalFound, null, null, null, null, null, null, null, null);
return null;
@ -1535,7 +1537,7 @@ public class Quester {
finishObjective(quest, "catchFish", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, fishToCatch), null, null, null, null, null, null, null, null);
// Multiplayer
dispatchMultiplayerEventShareObjective(quest, getCurrentStage(quest), (Quester q) -> {
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
q.getQuestData(quest).setFishCaught(fishToCatch);
q.finishObjective(quest, "catchFish", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, fishToCatch), null, null, null, null, null, null, null, null);
return null;
@ -1589,7 +1591,7 @@ public class Quester {
new ItemStack(Material.AIR, numberOfSpecificMobNeedsToBeKilledInCurrentStage), null, e, null, null, null, null, null, null);
// Multiplayer
dispatchMultiplayerEventShareObjective(quest, currentStage, (Quester q) -> {
dispatchMultiplayerObjectives(quest, currentStage, (Quester q) -> {
q.getQuestData(quest).mobNumKilled.set(indexOfMobKilled, newNumberOfSpecificMobKilled);
q.finishObjective(quest, "killMob", new ItemStack(Material.AIR, 1),
new ItemStack(Material.AIR, numberOfSpecificMobNeedsToBeKilledInCurrentStage), null, e, null, null, null, null, null, null);
@ -1613,7 +1615,7 @@ public class Quester {
finishObjective(quest, "killPlayer", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, playersToKill), null, null, null, null, null, null, null, null);
// Multiplayer
dispatchMultiplayerEventShareObjective(quest, getCurrentStage(quest), (Quester q) -> {
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
q.getQuestData(quest).setPlayersKilled(getQuestData(quest).getPlayersKilled());
q.finishObjective(quest, "killPlayer", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, playersToKill), null, null, null, null, null, null, null, null);
return null;
@ -1671,7 +1673,7 @@ public class Quester {
finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
// Multiplayer
dispatchMultiplayerEventShareObjective(quest, getCurrentStage(quest), (Quester q) -> {
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
q.getQuestData(quest).itemsDelivered.put(found, req);
q.finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
return null;
@ -1732,7 +1734,7 @@ public class Quester {
// Multiplayer
final ItemStack finalFound = found;
dispatchMultiplayerEventShareObjective(quest, getCurrentStage(quest), (Quester q) -> {
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
q.getQuestData(quest).itemsDelivered.put(finalFound, req);
q.finishObjective(quest, "deliverItem", new ItemStack(m, 1), finalFound, null, null, null, null, null, null, null, null);
return null;
@ -1764,7 +1766,7 @@ public class Quester {
finishObjective(quest, "talkToNPC", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, 1), null, null, null, n, null, null, null, null);
// Multiplayer
dispatchMultiplayerEventShareObjective(quest, getCurrentStage(quest), (Quester q) -> {
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
q.getQuestData(quest).citizensInteracted.put(n.getId(), true);
q.finishObjective(quest, "talkToNPC", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, 1), null, null, null, n, null, null, null, null);
return null;
@ -1789,7 +1791,7 @@ public class Quester {
finishObjective(quest, "killNPC", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, npcsToKill), null, null, null, n, null, null, null, null);
// Multiplayer
dispatchMultiplayerEventShareObjective(quest, getCurrentStage(quest), (Quester q) -> {
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
q.getQuestData(quest).citizenNumKilled.set(index, getQuestData(quest).citizenNumKilled.get(index));
q.finishObjective(quest, "killNPC", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, npcsToKill), null, null, null, n, null, null, null, null);
return null;
@ -1834,7 +1836,7 @@ public class Quester {
// Multiplayer
final int finalIndex = index;
dispatchMultiplayerEventShareObjective(quest, getCurrentStage(quest), (Quester q) -> {
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
if (finalIndex >= getQuestData(quest).hasReached.size()) {
q.getQuestData(quest).hasReached.add(true);
} else {
@ -1874,7 +1876,7 @@ public class Quester {
finishObjective(quest, "tameMob", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, mobsToTame), null, entity, null, null, null, null, null, null);
// Multiplayer
dispatchMultiplayerEventShareObjective(quest, getCurrentStage(quest), (Quester q) -> {
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
q.getQuestData(quest).mobsTamed.put(entity, getQuestData(quest).mobsTamed.get(entity));
q.finishObjective(quest, "tameMob", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, mobsToTame), null, entity, null, null, null, null, null, null);
return null;
@ -1897,7 +1899,7 @@ public class Quester {
finishObjective(quest, "shearSheep", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, sheepToShear), null, null, null, null, null, color, null, null);
// Multiplayer
dispatchMultiplayerEventShareObjective(quest, getCurrentStage(quest), (Quester q) -> {
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
q.getQuestData(quest).sheepSheared.put(color, getQuestData(quest).sheepSheared.get(color));
q.finishObjective(quest, "shearSheep", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, sheepToShear), null, null, null, null, null, color, null, null);
return null;
@ -1926,7 +1928,7 @@ public class Quester {
finishObjective(quest, "password", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, 1), null, null, null, null, null, null, display, null);
// Multiplayer
dispatchMultiplayerEventShareObjective(quest, getCurrentStage(quest), (Quester q) -> {
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
q.getQuestData(quest).passwordsSaid.put(display, true);
q.finishObjective(quest, "password", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, 1), null, null, null, null, null, null, display, null);
return null;
@ -3266,16 +3268,21 @@ public class Quester {
}
/**
* Dispatch any event to the right quest if multiplayer enabled
* Dispatch player event to fellow questers<p>
*
* Accepted strings are: breakBlock, damageBlock, placeBlock, useBlock,
* cutBlock, craftItem, smeltItem, enchantItem, brewItem, catchFish,
* killMob, deliverItem, killPlayer, talkToNPC, killNPC, tameMob,
* shearSheep, password, reachLocation
*
* @param eventName the event name
* @param fun the function to execute, the event call
* @param objectiveType The type of objective to progress
* @param fun The function to execute, the event call
*/
public void dispatchMultiplayerEvent(String eventName, BiFunction<Quester, Quest, Void> fun) {
public void dispatchMultiplayerEverything(String objectiveType, BiFunction<Quester, Quest, Void> fun) {
Map<Quester, MultiplayerType> mq = getMultiplayerQuesters();
for (Entry<Quester, MultiplayerType> q : mq.entrySet()) {
for (Quest quest : q.getKey().getCurrentQuests().keySet()) {
if (q.getKey().containsObjective(quest, eventName)
if (q.getKey().containsObjective(quest, objectiveType)
&& quest.getOptions().getShareProgressLevel() == 1
&& ((quest.getOptions().getUsePartiesPlugin() && q.getValue().parties)
|| (quest.getOptions().getUseDungeonsXLPlugin() && q.getValue().dungeonxl))) {
@ -3286,13 +3293,13 @@ public class Quester {
}
/**
* Dispatch a finish objective multiplayer event
* Dispatch finish objective to fellow questers
*
* @param quest the current quest
* @param currentStage the current stage of the quest
* @param fun the function to execute, the event call
* @param quest The current quest
* @param currentStage The current stage of the quest
* @param fun The function to execute, the event call
*/
public void dispatchMultiplayerEventShareObjective(Quest quest, Stage currentStage, Function<Quester, Void> fun) {
public void dispatchMultiplayerObjectives(Quest quest, Stage currentStage, Function<Quester, Void> fun) {
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
for (Quester q : mq) {

View File

@ -213,7 +213,7 @@ public class PlayerListener implements Listener {
}
// Multiplayer
quester.dispatchMultiplayerEvent("useBlock", (Quester q, Quest quest) -> {
quester.dispatchMultiplayerEverything("useBlock", (Quester q, Quest quest) -> {
q.useBlock(quest, blockItemStack);
return null;
});
@ -369,7 +369,7 @@ public class PlayerListener implements Listener {
}
// Multiplayer
quester.dispatchMultiplayerEvent("password", (Quester q, Quest quest) -> {
quester.dispatchMultiplayerEverything("password", (Quester q, Quest quest) -> {
q.sayPassword(quest, evt);
return null;
});
@ -427,7 +427,7 @@ public class PlayerListener implements Listener {
}
// Multiplayer
quester.dispatchMultiplayerEvent("placeBlock", (Quester q, Quest quest) -> {
quester.dispatchMultiplayerEverything("placeBlock", (Quester q, Quest quest) -> {
q.placeBlock(quest, blockItemStack);
return null;
});
@ -450,7 +450,7 @@ public class PlayerListener implements Listener {
}
// Multiplayer
quester.dispatchMultiplayerEvent("placeBlock", (Quester q, Quest quest) -> {
quester.dispatchMultiplayerEverything("placeBlock", (Quester q, Quest quest) -> {
q.placeBlock(quest, blockItemStack);
return null;
});
@ -489,13 +489,13 @@ public class PlayerListener implements Listener {
}
// Multiplayer
quester.dispatchMultiplayerEvent("breakBlock", (Quester q, Quest quest) -> {
quester.dispatchMultiplayerEverything("breakBlock", (Quester q, Quest quest) -> {
if (evt.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH) == false) {
q.breakBlock(quest, blockItemStack);
}
return null;
});
quester.dispatchMultiplayerEvent("placeBlock", (Quester q, Quest quest) -> {
quester.dispatchMultiplayerEverything("placeBlock", (Quester q, Quest quest) -> {
for (ItemStack is : q.getQuestData(quest).blocksPlaced) {
if (evt.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) {
int index = q.getQuestData(quest).blocksPlaced.indexOf(is);
@ -505,7 +505,7 @@ public class PlayerListener implements Listener {
}
return null;
});
quester.dispatchMultiplayerEvent("cutBlock", (Quester q, Quest quest) -> {
quester.dispatchMultiplayerEverything("cutBlock", (Quester q, Quest quest) -> {
if (evt.getPlayer().getItemInHand().getType().equals(Material.SHEARS)) {
q.cutBlock(quest, blockItemStack);
}
@ -527,7 +527,7 @@ public class PlayerListener implements Listener {
}
// Multiplayer
quester.dispatchMultiplayerEvent("shearSheep", (Quester q, Quest quest) -> {
quester.dispatchMultiplayerEverything("shearSheep", (Quester q, Quest quest) -> {
q.shearSheep(quest, sheep.getColor());
return null;
});
@ -548,7 +548,7 @@ public class PlayerListener implements Listener {
}
// Multiplayer
quester.dispatchMultiplayerEvent("tameMob", (Quester q, Quest quest) -> {
quester.dispatchMultiplayerEverything("tameMob", (Quester q, Quest quest) -> {
q.tameMob(quest, evt.getEntityType());
return null;
});
@ -571,7 +571,7 @@ public class PlayerListener implements Listener {
}
// Multiplayer
quester.dispatchMultiplayerEvent("craftItem", (Quester q, Quest quest) -> {
quester.dispatchMultiplayerEverything("craftItem", (Quester q, Quest quest) -> {
q.craftItem(quest, craftedItem);
return null;
});
@ -615,7 +615,7 @@ public class PlayerListener implements Listener {
}
// Multiplayer
quester.dispatchMultiplayerEvent("smeltItem", (Quester q, Quest quest) -> {
quester.dispatchMultiplayerEverything("smeltItem", (Quester q, Quest quest) -> {
q.smeltItem(quest, evt.getCurrentItem());
return null;
});
@ -630,7 +630,7 @@ public class PlayerListener implements Listener {
}
// Multiplayer
quester.dispatchMultiplayerEvent("brewItem", (Quester q, Quest quest) -> {
quester.dispatchMultiplayerEverything("brewItem", (Quester q, Quest quest) -> {
q.brewItem(quest, evt.getCurrentItem());
return null;
});
@ -652,7 +652,7 @@ public class PlayerListener implements Listener {
}
// Multiplayer
quester.dispatchMultiplayerEvent("enchantItem", (Quester q, Quest quest) -> {
quester.dispatchMultiplayerEverything("enchantItem", (Quester q, Quest quest) -> {
for (Enchantment e : evt.getEnchantsToAdd().keySet()) {
q.enchantItem(quest, e, evt.getItem().getType());
}
@ -716,7 +716,7 @@ public class PlayerListener implements Listener {
}
// Multiplayer
quester.dispatchMultiplayerEvent("killNPC", (Quester q, Quest quest) -> {
quester.dispatchMultiplayerEverything("killNPC", (Quester q, Quest quest) -> {
q.killNPC(quest, CitizensAPI.getNPCRegistry().getNPC(target));
return null;
});
@ -731,7 +731,7 @@ public class PlayerListener implements Listener {
}
// Multiplayer
quester.dispatchMultiplayerEvent("killMob", (Quester q, Quest quest) -> {
quester.dispatchMultiplayerEverything("killMob", (Quester q, Quest quest) -> {
q.killMob(quest, target.getLocation(), target.getType());
return null;
});
@ -826,7 +826,7 @@ public class PlayerListener implements Listener {
}
// Multiplayer
quester.dispatchMultiplayerEvent("killPlayer", (Quester q, Quest quest) -> {
quester.dispatchMultiplayerEverything("killPlayer", (Quester q, Quest quest) -> {
q.killPlayer(quest, (Player)target);
return null;
});
@ -845,7 +845,7 @@ public class PlayerListener implements Listener {
}
// Multiplayer
quester.dispatchMultiplayerEvent("catchFish", (Quester q, Quest quest) -> {
quester.dispatchMultiplayerEverything("catchFish", (Quester q, Quest quest) -> {
q.catchFish(quest);
return null;
});
@ -977,7 +977,7 @@ public class PlayerListener implements Listener {
}
// Multiplayer
quester.dispatchMultiplayerEvent("reachLocation", (Quester q, Quest quest) -> {
quester.dispatchMultiplayerEverything("reachLocation", (Quester q, Quest quest) -> {
q.reachLocation(quest, evt.getTo());
return null;
});