1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-15 20:51:44 +01:00

Support of mushroom cow shearing

This commit is contained in:
Zrips 2024-06-25 16:49:48 +03:00
parent dc82211192
commit 9fd58eb990
5 changed files with 64 additions and 35 deletions

View File

@ -1028,10 +1028,8 @@ public final class Jobs extends JavaPlugin {
List<JobProgression> progression = jPlayer.getJobProgression();
int numjobs = progression.size();
CMIDebug.it();
if (!Jobs.getGCManager().useBlockProtectionBlockTracker && !Jobs.getExploitManager().isProtectionValidAddIfNotExists(jPlayer, info, block, true))
return;
CMIDebug.d(CMIDebug.getIT(), "ms");
// no job
if (numjobs == 0) {
@ -1336,7 +1334,6 @@ public final class Jobs extends JavaPlugin {
}
}
private static int getPlayerExperience(Player player) {
return (expToLevel(player.getLevel()) + Math.round(deltaLevelToExp(player.getLevel()) * player.getExp()));
}

View File

@ -833,6 +833,12 @@ public class ConfigManager {
meta = "ALL";
// case for ":all" identifier
type = (actionType == ActionType.SHEAR && myKey.startsWith("color")) ? "color" : CMIMaterial.getGeneralMaterialName(type);
CMIEntityType entity = CMIEntityType.get(type);
if (entity != null) {
type = entity.toString();
}
}
if (actionType == ActionType.TNTBREAK)

View File

@ -125,25 +125,9 @@ public class NameTranslatorManager {
case KILL:
case MILK:
case TAME:
for (NameList one : listOfEntities) {
String ids = one.getId() + ":" + one.getMeta();
if (!one.getMeta().isEmpty() && !one.getId().equals("0") && ids.equalsIgnoreCase(id + ":" + meta)) {
return one.getName();
}
ids = one.getId();
if (!one.getId().equals("0") && ids.equalsIgnoreCase(Integer.toString(id))) {
return one.getName();
}
ids = one.getMinecraftName();
if (ids.equalsIgnoreCase(name)) {
return one.getName();
}
}
String entityName = getEntityName(id, meta, name);
if (entityName != null)
return entityName;
break;
case ENCHANT:
String mName = materialName;
@ -186,6 +170,10 @@ public class NameTranslatorManager {
}
}
entityName = getEntityName(id, meta, name);
if (entityName != null)
return entityName;
return name == null ? "nocolor" : Arrays.stream(name.split("\\s|:|-"))
.map(word -> word.substring(0, 1).toUpperCase() + word.substring(1).toLowerCase())
.collect(Collectors.joining(" ")); // returns capitalized word (from this -> To This)
@ -203,6 +191,29 @@ public class NameTranslatorManager {
return materialName;
}
private String getEntityName(int id, String meta, String name) {
for (NameList one : listOfEntities) {
String ids = one.getId() + ":" + one.getMeta();
if (!one.getMeta().isEmpty() && !one.getId().equals("0") && ids.equalsIgnoreCase(id + ":" + meta)) {
return one.getName();
}
ids = one.getId();
if (!one.getId().equals("0") && ids.equalsIgnoreCase(Integer.toString(id))) {
return one.getName();
}
ids = one.getMinecraftName();
if (ids.equalsIgnoreCase(name)) {
return one.getName();
}
}
return null;
}
public void readFile() {
YmlMaker itemFile = new YmlMaker(Jobs.getFolder(), "TranslatableWords" + File.separator + "Words_"
+ Jobs.getGCManager().localeString + ".yml");

View File

@ -26,7 +26,6 @@ public class PyroFishingProManager implements Listener {
}
public static String getFish() {
CMIDebug.d("Get fish", time + 60 < System.currentTimeMillis(), lastFish);
if (time + 60 < System.currentTimeMillis())
return null;
return lastFish;

View File

@ -44,6 +44,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.MushroomCow;
import org.bukkit.entity.Tameable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -313,16 +314,20 @@ public final class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityShear(PlayerShearEntityEvent event) {
Player player = event.getPlayer();
if (!(event.getEntity() instanceof Sheep) || !Jobs.getGCManager().canPerformActionInWorld(player.getWorld()))
if (!(event.getEntity() instanceof Sheep) && !(event.getEntity() instanceof MushroomCow) || !Jobs.getGCManager().canPerformActionInWorld(player.getWorld()))
return;
Sheep sheep = (Sheep) event.getEntity();
Entity entity = event.getEntity();
if (!(entity instanceof LivingEntity))
return;
// mob spawner, no payment or experience
if (!Jobs.getGCManager().payNearSpawner() && sheep.hasMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata())) {
sheep.removeMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), plugin);
if (!Jobs.getGCManager().payNearSpawner() && entity.hasMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata())) {
entity.removeMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), plugin);
return;
}
@ -342,25 +347,36 @@ public final class JobsPaymentListener implements Listener {
// pay
JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(player);
if (jDamager == null || sheep.getColor() == null)
if (jDamager == null)
return;
String typeString = null;
if (event.getEntity() instanceof Sheep) {
Sheep sheep = (Sheep) event.getEntity();
if (sheep.getColor() == null)
return;
typeString = sheep.getColor().name();
} else if (event.getEntity() instanceof MushroomCow) {
typeString = CMIEntityType.get(entity).toString();
}
if (Jobs.getGCManager().payForStackedEntities) {
if (JobsHook.WildStacker.isEnabled() && !StackSplit.SHEEP_SHEAR.isEnabled()) {
for (int i = 0; i < HookManager.getWildStackerHandler().getEntityAmount(sheep) - 1; i++) {
Jobs.action(jDamager, new CustomKillInfo(sheep.getColor().name(), ActionType.SHEAR));
for (int i = 0; i < HookManager.getWildStackerHandler().getEntityAmount((LivingEntity) entity) - 1; i++) {
Jobs.action(jDamager, new CustomKillInfo(typeString, ActionType.SHEAR));
}
} else if (JobsHook.StackMob.isEnabled() && HookManager.getStackMobHandler().isStacked(sheep)) {
StackEntity stack = HookManager.getStackMobHandler().getStackEntity(sheep);
} else if (JobsHook.StackMob.isEnabled() && HookManager.getStackMobHandler().isStacked((LivingEntity) entity)) {
StackEntity stack = HookManager.getStackMobHandler().getStackEntity((LivingEntity) entity);
if (stack != null) {
Jobs.action(jDamager, new CustomKillInfo(sheep.getColor().name(), ActionType.SHEAR));
Jobs.action(jDamager, new CustomKillInfo(typeString, ActionType.SHEAR));
return;
}
}
}
Jobs.action(jDamager, new CustomKillInfo(sheep.getColor().name(), ActionType.SHEAR));
Jobs.action(jDamager, new CustomKillInfo(typeString, ActionType.SHEAR));
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)