1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-30 21:07:48 +01:00

Re-add StackMob support

Temporary it is solved by using flat-jar until the repository is inaccessible.

- Fixed the ordering of shop items
This commit is contained in:
montlikadani 2021-04-02 15:14:03 +02:00
parent 22f985aa88
commit 7e5ab9bb9c
18 changed files with 119 additions and 78 deletions

BIN
libs/StackMob-5.5.3.jar Normal file

Binary file not shown.

View File

@ -156,6 +156,10 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</exclusion>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- PlaceholderAPI -->
@ -187,8 +191,9 @@
<dependency>
<groupId>com.github.Nathat23</groupId>
<artifactId>StackMob-5</artifactId>
<version>master-SNAPSHOT</version>
<scope>provided</scope>
<version>5.5.3</version>
<scope>system</scope>
<systemPath>${basedir}/libs/StackMob-5.5.3.jar</systemPath>
</dependency>
<!-- MyPet -->
<dependency>

View File

@ -111,6 +111,25 @@ public class ItemBoostManager {
if (one.equalsIgnoreCase("exampleBoost"))
continue;
List<Job> jobs = new ArrayList<>();
for (String oneJ : cfg.get(one + ".jobs", Arrays.asList(""))) {
if (oneJ.equalsIgnoreCase("all")) {
jobs.addAll(Jobs.getJobs());
} else {
Job job = Jobs.getJob(oneJ);
if (job != null) {
jobs.add(job);
} else {
Jobs.getPluginLogger().warning("Cant determine job by " + oneJ + " name for " + one + " boosted item!");
}
}
}
if (jobs.isEmpty()) {
Jobs.getPluginLogger().warning("Jobs list is empty for " + one + " boosted item!");
continue;
}
List<String> lore = new ArrayList<>();
if (cfg.getC().isList(one + ".lore")) {
for (String eachLine : cfg.get(one + ".lore", Arrays.asList(""))) {
@ -143,25 +162,6 @@ public class ItemBoostManager {
b.add(oneC, cfg.get(one + "." + typeName + "Boost", 1D) - 1);
}
List<Job> jobs = new ArrayList<>();
for (String oneJ : cfg.get(one + ".jobs", Arrays.asList(""))) {
if (oneJ.equalsIgnoreCase("all")) {
jobs.addAll(Jobs.getJobs());
} else {
Job job = Jobs.getJob(oneJ);
if (job != null) {
jobs.add(job);
} else {
Jobs.getPluginLogger().warning("Cant determine job by " + oneJ + " name for " + one + " boosted item!");
}
}
}
if (jobs.isEmpty()) {
Jobs.getPluginLogger().warning("Jobs list is empty for " + one + " boosted item!");
continue;
}
CMIMaterial mat = cfg.getC().isString(one + ".id") ? CMIMaterial.get(cfg.get(one + ".id", "Stone")) : null;
String name = cfg.getC().isString(one + ".name") ? cfg.get(one + ".name", "") : null;
@ -181,7 +181,7 @@ public class ItemBoostManager {
// Lets add into legacy map
if (one.contains("_")) {
item.setLegacyKey(one.split("_")[1].toLowerCase());
item.setLegacyKey(one.split("_", 2)[1].toLowerCase());
LEGACY.put(item.getLegacyKey(), item);
}

View File

@ -374,17 +374,17 @@ public class Placeholder {
}
private static JobProgression getProgFromValue(JobsPlayer user, String value) {
JobProgression j = null;
try {
int id = Integer.parseInt(value);
if (id > 0)
j = user.getJobProgression().get(id - 1);
} catch (Exception e) {
return user.getJobProgression().get(id - 1);
} catch (IndexOutOfBoundsException | NumberFormatException e) {
Job job = Jobs.getJob(value);
if (job != null)
j = user.getJobProgression(job);
return user.getJobProgression(job);
}
return j;
return null;
}
private static Job getJobFromValue(String value) {

View File

@ -337,6 +337,7 @@ public class PlayerManager {
for (JobProgression oneJ : jPlayer.getJobProgression())
dao.insertJob(jPlayer, oneJ);
dao.saveLog(jPlayer);
dao.savePoints(jPlayer);
dao.recordPlayersLimits(jPlayer);
@ -850,13 +851,16 @@ public class PlayerManager {
if (cmd.contains(":")) {
String[] split = cmd.split(":", 2);
String command = split[1];
command = command.replace("[playerName]", player.getName());
command = command.replace("[job]", job.getName());
String command = "";
if (split.length > 1) {
command = split[1];
command = command.replace("[playerName]", player.getName());
command = command.replace("[job]", job.getName());
}
if (split[0].equalsIgnoreCase("player:")) {
player.performCommand(command);
} else if (split[0].equalsIgnoreCase("console:")) {
} else {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
}
} else {
@ -1108,7 +1112,7 @@ public class PlayerManager {
boost.add(BoostOf.PetPay, new BoostMultiplier().add(petPay));
}
if (victim != null && victim.hasMetadata(getMobSpawnerMetadata())) {
if (victim != null && victim.hasMetadata(mobSpawnerMetadata)) {
Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner", false, false);
if (amount != 0D)
boost.add(BoostOf.NearSpawner, new BoostMultiplier().add(amount));

View File

@ -138,9 +138,12 @@ public class jobsSign {
}
public String getIdentifier() {
if (getType() != SignTopType.toplist)
return getType().toString();
return jobName != null ? jobName + ":" + getType().toString() : getType().toString();
SignTopType type = getType();
if (type != SignTopType.toplist)
return type.toString();
return jobName != null ? jobName + ":" + type.toString() : type.toString();
}
public static String getIdentifier(Job job, SignTopType type) {

View File

@ -25,27 +25,28 @@ public class area implements Cmd {
Player player = (Player) sender;
RestrictedAreaManager ra = Jobs.getRestrictedAreaManager();
if (args.length == 3) {
if (args[0].equalsIgnoreCase("add")) {
if (!Jobs.hasPermission(player, "jobs.area.add", true))
return true;
String name = args[1];
double bonus = 0D;
try {
bonus = Double.parseDouble(args[2]);
} catch (NumberFormatException e) {
return false;
}
boolean wg = false;
String name = args[1];
if (name.startsWith("wg:")) {
wg = true;
name = name.substring("wg:".length(), name.length());
}
RestrictedAreaManager ra = Jobs.getRestrictedAreaManager();
if (ra.isExist(name)) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.exist"));
return true;
@ -78,6 +79,7 @@ public class area implements Cmd {
if (!Jobs.hasPermission(player, "jobs.area.remove", true))
return true;
RestrictedAreaManager ra = Jobs.getRestrictedAreaManager();
String name = args[1];
if (!ra.isExist(name)) {

View File

@ -421,7 +421,7 @@ public class editjobs implements Cmd {
String materialName = jInfo.getName().toLowerCase().replace('_', ' ');
materialName = Character.toUpperCase(materialName.charAt(0)) + materialName.substring(1);
materialName = Jobs.getNameTranslatorManager().Translate(materialName, jInfo);
materialName = Jobs.getNameTranslatorManager().translate(materialName, jInfo);
materialName = CMIChatColor.translate(materialName);
rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.material", "%materialname%", jInfo.getName()))

View File

@ -133,7 +133,7 @@ public class editquests implements Cmd {
String objName = target.toLowerCase().replace('_', ' ');
objName = Character.toUpperCase(objName.charAt(0)) + objName.substring(1);
if (o != null)
objName = Jobs.getNameTranslatorManager().Translate(objName, o.getAction(), o.getTargetId(),
objName = Jobs.getNameTranslatorManager().translate(objName, o.getAction(), o.getTargetId(),
o.getTargetMeta(), target);
objName = org.bukkit.ChatColor.translateAlternateColorCodes('&', objName);

View File

@ -105,7 +105,7 @@ public class quests implements Cmd {
for (java.util.Map<String, QuestObjective> oneAction : q.getQuest().getObjectives().values()) {
for (Entry<String, QuestObjective> oneObjective : oneAction.entrySet()) {
hoverList.add(Jobs.getLanguage().getMessage("command.info.output." + oneObjective.getValue().getAction().toString().toLowerCase() + ".info") + " " +
Jobs.getNameTranslatorManager().Translate(oneObjective.getKey(), oneObjective.getValue().getAction(), oneObjective.getValue().getTargetId(), oneObjective.getValue()
Jobs.getNameTranslatorManager().translate(oneObjective.getKey(), oneObjective.getValue().getAction(), oneObjective.getValue().getTargetId(), oneObjective.getValue()
.getTargetMeta(), oneObjective.getValue().getTargetName())
+ " " + q.getAmountDone(oneObjective.getValue()) + "/"
+ oneObjective.getValue().getAmount());

View File

@ -25,11 +25,11 @@ public class NameTranslatorManager {
private final List<NameList> ListOfEntities = new ArrayList<>(), ListOfColors = new ArrayList<>();
private final Map<String, NameList> ListOfEnchants = new HashMap<>(), ListOfMMEntities = new HashMap<>();
public String Translate(String materialName, JobInfo info) {
return Translate(materialName, info.getActionType(), info.getId(), info.getMeta(), info.getName());
public String translate(String materialName, JobInfo info) {
return translate(materialName, info.getActionType(), info.getId(), info.getMeta(), info.getName());
}
public String Translate(String materialName, ActionType action, Integer id, String meta, String name) {
public String translate(String materialName, ActionType action, Integer id, String meta, String name) {
// Translating name to user friendly
if (Jobs.getGCManager().UseCustomNames)
switch (action) {

View File

@ -321,7 +321,7 @@ public class ShopManager {
int i = 0;
int y = 1;
for (String category : new java.util.HashSet<>(categories)) {
for (String category : new ArrayList<>(categories)) {
ConfigurationSection nameSection = confCategory.getConfigurationSection(category);
if (nameSection == null) {
continue;
@ -372,12 +372,12 @@ public class ShopManager {
sItem.setRequiredTotalLevels(nameSection.getInt("RequiredTotalLevels"));
if (nameSection.isList("RequiredJobLevels")) {
HashMap<String, Integer> requiredJobs = new HashMap<>();
Map<String, Integer> requiredJobs = new HashMap<>();
for (String one : nameSection.getStringList("RequiredJobLevels")) {
if (!one.contains("-"))
continue;
String[] split = one.split("-");
String[] split = one.split("-", 2);
String job = split[0];
int lvl = 1;
if (split.length > 1) {
@ -430,7 +430,7 @@ public class ShopManager {
if (!eachLine.contains("="))
continue;
String[] split = eachLine.split("=");
String[] split = eachLine.split("=", 2);
Enchantment ench = CMIEnchantment.getEnchantment(split[0]);
Integer level = 1;
if (split.length > 1) {

View File

@ -543,10 +543,6 @@ public class Job {
this.quests.addAll(quests == null ? new ArrayList<>() : quests);
}
// public Quest getNextQuest() {
// return getNextQuest(null, null);
// }
public Quest getNextQuest(List<String> excludeQuests, Integer level) {
List<Quest> ls = new ArrayList<>(quests);
Collections.shuffle(ls);

View File

@ -35,30 +35,34 @@ public class JobConditions {
this.node = node;
for (String one : requires) {
if (one.toLowerCase().contains("j:")) {
String jobName = one.toLowerCase().replace("j:", "").split("-")[0];
String cond = one.toLowerCase();
if (cond.contains("j:")) {
String[] split = cond.replace("j:", "").split("-", 2);
int jobLevel = 0;
try {
jobLevel = Integer.valueOf(one.toLowerCase().replace("j:", "").split("-")[1]);
jobLevel = Integer.valueOf(split[1]);
} catch (NumberFormatException e) {
continue;
}
requiresJobs.put(jobName, jobLevel);
requiresJobs.put(split[0], jobLevel);
}
if (one.toLowerCase().contains("p:")) {
if (cond.contains("p:")) {
requiresPerm.add(one.replace("p:", ""));
}
}
for (String one : perform) {
if (!one.toLowerCase().contains("p:"))
one = one.toLowerCase();
if (!one.contains("p:"))
continue;
String clean = one.toLowerCase().substring("p:".length());
String clean = one.substring("p:".length());
if (clean.contains("-")) {
String[] split = clean.split("-");
String[] split = clean.split("-", 2);
performPerm.put(split[0], split[1].equalsIgnoreCase("true"));
} else {
performPerm.put(clean, true);

View File

@ -77,9 +77,9 @@ public class JobInfo {
}
public String getRealisticName() {
String materialName = getName().toLowerCase().replace('_', ' ');
String materialName = name.toLowerCase().replace('_', ' ');
materialName = Character.toUpperCase(materialName.charAt(0)) + materialName.substring(1);
materialName = Jobs.getNameTranslatorManager().Translate(actionType == ActionType.MMKILL ? getName() : materialName, this);
materialName = Jobs.getNameTranslatorManager().translate(actionType == ActionType.MMKILL ? name : materialName, this);
materialName = CMIChatColor.translate(materialName);
return materialName;
}

View File

@ -165,7 +165,8 @@ public class BlockOwnerShip {
}
public int getTotal(UUID uuid) {
return blockOwnerShips.getOrDefault(uuid, new ArrayList<>()).size();
List<blockLoc> list = blockOwnerShips.get(uuid);
return list == null ? 0 : list.size();
}
public void load() {
@ -192,12 +193,13 @@ public class BlockOwnerShip {
for (String one : section.getKeys(false)) {
String value = section.getString(one);
List<String> ls = new ArrayList<>();
if (value.contains(";"))
ls.addAll(Arrays.asList(value.split(";")));
else
ls.add(value);
UUID uuid = null;
UUID uuid;
try {
uuid = UUID.fromString(one);
} catch (IllegalArgumentException e) {
@ -255,6 +257,7 @@ public class BlockOwnerShip {
for (Map.Entry<UUID, List<blockLoc>> one : blockOwnerShips.entrySet()) {
String full = "";
for (blockLoc oneL : one.getValue()) {
if (!full.isEmpty())
full += ";";

View File

@ -1,6 +1,6 @@
package com.gamingmesh.jobs.hooks.stackMob;
import java.util.HashSet;
import java.util.Collection;
import org.bukkit.entity.LivingEntity;
import org.bukkit.plugin.java.JavaPlugin;
@ -16,7 +16,7 @@ public class StackMobHandler extends HookPlugin {
return getPlugin().getEntityManager().isStackedEntity(entity);
}
public HashSet<StackEntity> getStackEntities() {
public Collection<StackEntity> getStackEntities() {
return getPlugin().getEntityManager().getStackEntities();
}

View File

@ -303,10 +303,18 @@ public class JobsPaymentListener implements Listener {
if (jDamager == null || sheep.getColor() == null)
return;
if (Jobs.getGCManager().payForStackedEntities && JobsHook.WildStacker.isEnabled() && HookManager.getWildStackerHandler().isStackedEntity(sheep)) {
for (com.bgsoftware.wildstacker.api.objects.StackedEntity stacked : HookManager.getWildStackerHandler().getStackedEntities()) {
if (stacked.getType() == sheep.getType()) {
Jobs.action(jDamager, new CustomKillInfo(((Sheep) stacked.getLivingEntity()).getColor().name(), ActionType.SHEAR));
if (Jobs.getGCManager().payForStackedEntities) {
if (JobsHook.WildStacker.isEnabled() && HookManager.getWildStackerHandler().isStackedEntity(sheep)) {
for (com.bgsoftware.wildstacker.api.objects.StackedEntity stacked : HookManager.getWildStackerHandler().getStackedEntities()) {
if (stacked.getType() == sheep.getType()) {
Jobs.action(jDamager, new CustomKillInfo(((Sheep) stacked.getLivingEntity()).getColor().name(), ActionType.SHEAR));
}
}
} else if (JobsHook.StackMob.isEnabled() && HookManager.getStackMobHandler().isStacked(sheep)) {
for (uk.antiperson.stackmob.entity.StackEntity stacked : HookManager.getStackMobHandler().getStackEntities()) {
if (stacked.getEntity().getType() == sheep.getType()) {
Jobs.action(jDamager, new CustomKillInfo(((Sheep) stacked.getEntity()).getColor().name(), ActionType.SHEAR));
}
}
}
}
@ -537,10 +545,18 @@ public class JobsPaymentListener implements Listener {
if (jDamager == null)
return;
if (Jobs.getGCManager().payForStackedEntities && JobsHook.WildStacker.isEnabled() && HookManager.getWildStackerHandler().isStackedEntity(animal)) {
for (com.bgsoftware.wildstacker.api.objects.StackedEntity stacked : HookManager.getWildStackerHandler().getStackedEntities()) {
if (stacked.getType() == animal.getType()) {
Jobs.action(jDamager, new EntityActionInfo(stacked.getLivingEntity(), ActionType.TAME));
if (Jobs.getGCManager().payForStackedEntities) {
if (JobsHook.WildStacker.isEnabled() && HookManager.getWildStackerHandler().isStackedEntity(animal)) {
for (com.bgsoftware.wildstacker.api.objects.StackedEntity stacked : HookManager.getWildStackerHandler().getStackedEntities()) {
if (stacked.getType() == animal.getType()) {
Jobs.action(jDamager, new EntityActionInfo(stacked.getLivingEntity(), ActionType.TAME));
}
}
} else if (JobsHook.StackMob.isEnabled() && HookManager.getStackMobHandler().isStacked(animal)) {
for (uk.antiperson.stackmob.entity.StackEntity stacked : HookManager.getStackMobHandler().getStackEntities()) {
if (stacked.getEntity().getType() == animal.getType()) {
Jobs.action(jDamager, new EntityActionInfo(stacked.getEntity(), ActionType.TAME));
}
}
}
}
@ -1230,10 +1246,18 @@ public class JobsPaymentListener implements Listener {
return;
}
if (Jobs.getGCManager().payForStackedEntities && JobsHook.WildStacker.isEnabled() && HookManager.getWildStackerHandler().isStackedEntity(lVictim)) {
for (com.bgsoftware.wildstacker.api.objects.StackedEntity stacked : HookManager.getWildStackerHandler().getStackedEntities()) {
if (stacked.getType() == lVictim.getType()) {
Jobs.action(jDamager, new EntityActionInfo(stacked.getLivingEntity(), ActionType.KILL), e.getDamager(), stacked.getLivingEntity());
if (Jobs.getGCManager().payForStackedEntities) {
if (JobsHook.WildStacker.isEnabled() && HookManager.getWildStackerHandler().isStackedEntity(lVictim)) {
for (com.bgsoftware.wildstacker.api.objects.StackedEntity stacked : HookManager.getWildStackerHandler().getStackedEntities()) {
if (stacked.getType() == lVictim.getType()) {
Jobs.action(jDamager, new EntityActionInfo(stacked.getLivingEntity(), ActionType.KILL), e.getDamager(), stacked.getLivingEntity());
}
}
} else if (JobsHook.StackMob.isEnabled() && HookManager.getStackMobHandler().isStacked(lVictim)) {
for (uk.antiperson.stackmob.entity.StackEntity stacked : HookManager.getStackMobHandler().getStackEntities()) {
if (stacked.getEntity().getType() == lVictim.getType()) {
Jobs.action(jDamager, new EntityActionInfo(stacked.getEntity(), ActionType.KILL), e.getDamager(), stacked.getEntity());
}
}
}
}