Add saddleable horses, carpetable llamas.
This commit is contained in:
parent
8015db68f6
commit
2b7c295d2c
@ -39,6 +39,8 @@ public class DisguiseConfig {
|
|||||||
private static boolean colorizeSheep;
|
private static boolean colorizeSheep;
|
||||||
private static boolean colorizeWolf;
|
private static boolean colorizeWolf;
|
||||||
private static boolean colorizeCat;
|
private static boolean colorizeCat;
|
||||||
|
private static boolean saddleableHorse;
|
||||||
|
private static boolean carpetableLlama;
|
||||||
private static HashMap<DisguisePerm, String> customDisguises = new HashMap<>();
|
private static HashMap<DisguisePerm, String> customDisguises = new HashMap<>();
|
||||||
private static boolean disableInvisibility;
|
private static boolean disableInvisibility;
|
||||||
private static int disguiseCloneExpire;
|
private static int disguiseCloneExpire;
|
||||||
@ -317,6 +319,8 @@ public class DisguiseConfig {
|
|||||||
setSheepDyeable(config.getBoolean("DyeableSheep"));
|
setSheepDyeable(config.getBoolean("DyeableSheep"));
|
||||||
setWolfDyeable(config.getBoolean("DyeableWolf"));
|
setWolfDyeable(config.getBoolean("DyeableWolf"));
|
||||||
setCatDyeable(config.getBoolean("DyeableCat"));
|
setCatDyeable(config.getBoolean("DyeableCat"));
|
||||||
|
setHorseSaddleable(config.getBoolean("SaddleableHorse"));
|
||||||
|
setLlamaCarpetable(config.getBoolean("CarpetableLlama"));
|
||||||
setUndisguiseOnWorldChange(config.getBoolean("UndisguiseOnWorldChange"));
|
setUndisguiseOnWorldChange(config.getBoolean("UndisguiseOnWorldChange"));
|
||||||
setUpdateNotificationPermission(config.getString("Permission"));
|
setUpdateNotificationPermission(config.getString("Permission"));
|
||||||
setStopShulkerDisguisesFromMoving(config.getBoolean("StopShulkerDisguisesFromMoving", true));
|
setStopShulkerDisguisesFromMoving(config.getBoolean("StopShulkerDisguisesFromMoving", true));
|
||||||
@ -780,6 +784,22 @@ public class DisguiseConfig {
|
|||||||
return colorizeCat;
|
return colorizeCat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setHorseSaddleable(boolean saddle) {
|
||||||
|
saddleableHorse = saddle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isHorseSaddleable() {
|
||||||
|
return saddleableHorse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setLlamaCarpetable(boolean carpet) {
|
||||||
|
carpetableLlama = carpet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isLlamaCarpetable() {
|
||||||
|
return carpetableLlama;
|
||||||
|
}
|
||||||
|
|
||||||
private DisguiseConfig() {
|
private DisguiseConfig() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,24 @@ public enum AnimalColor {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static AnimalColor getColorByWool(Material carpet) {
|
||||||
|
if (carpet == null || (!carpet.name().endsWith("_WOOL") && !carpet.name().endsWith("_CARPET"))) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String name = carpet.name().replace("_CARPET", "").replace("_WOOL", "");
|
||||||
|
|
||||||
|
for (AnimalColor color : AnimalColor.values()) {
|
||||||
|
if (!color.name().equals(name)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static AnimalColor getColorByMaterial(Material material) {
|
public static AnimalColor getColorByMaterial(Material material) {
|
||||||
for (AnimalColor color : values()) {
|
for (AnimalColor color : values()) {
|
||||||
if (color.getDyeMaterial() != material) {
|
if (color.getDyeMaterial() != material) {
|
||||||
|
@ -14,16 +14,15 @@ import me.libraryaddict.disguise.disguisetypes.AnimalColor;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.CatWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.*;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.OcelotWatcher;
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.SheepWatcher;
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.WolfWatcher;
|
|
||||||
import me.libraryaddict.disguise.events.DisguiseInteractEvent;
|
import me.libraryaddict.disguise.events.DisguiseInteractEvent;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.material.Wool;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
public class PacketListenerClientInteract extends PacketAdapter {
|
public class PacketListenerClientInteract extends PacketAdapter {
|
||||||
@ -86,11 +85,84 @@ public class PacketListenerClientInteract extends PacketAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (disguise.getType() != DisguiseType.SHEEP && disguise.getType() != DisguiseType.WOLF &&
|
switch (disguise.getType()) {
|
||||||
disguise.getType() != DisguiseType.CAT) {
|
case CAT:
|
||||||
return;
|
case WOLF:
|
||||||
|
case SHEEP:
|
||||||
|
doDyeable(observer, disguise);
|
||||||
|
break;
|
||||||
|
case MULE:
|
||||||
|
case DONKEY:
|
||||||
|
case HORSE:
|
||||||
|
case ZOMBIE_HORSE:
|
||||||
|
case SKELETON_HORSE:
|
||||||
|
if (DisguiseConfig.isHorseSaddleable()) {
|
||||||
|
doSaddleable(observer, disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case LLAMA:
|
||||||
|
case TRADER_LLAMA:
|
||||||
|
if (DisguiseConfig.isLlamaCarpetable()) {
|
||||||
|
doCarpetable(observer, disguise);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doSaddleable(Player observer, Disguise disguise) {
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// If this is something the player can dye the disguise with
|
||||||
|
for (ItemStack item : new ItemStack[]{observer.getInventory().getItemInMainHand(),
|
||||||
|
observer.getInventory().getItemInOffHand()}) {
|
||||||
|
|
||||||
|
if (item == null || item.getType() != Material.SADDLE) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractHorseWatcher watcher = (TraderLlamaWatcher) disguise.getWatcher();
|
||||||
|
|
||||||
|
watcher.setSaddled(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTask(LibsDisguises.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doCarpetable(Player observer, Disguise disguise) {
|
||||||
|
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// If this is something the player can dye the disguise with
|
||||||
|
for (ItemStack item : new ItemStack[]{observer.getInventory().getItemInMainHand(),
|
||||||
|
observer.getInventory().getItemInOffHand()}) {
|
||||||
|
if (item == null || !item.getType().name().endsWith("_CARPET")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
AnimalColor color = AnimalColor.getColorByWool(item.getType());
|
||||||
|
|
||||||
|
if (color == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
LlamaWatcher llamaWatcher = (LlamaWatcher) disguise.getWatcher();
|
||||||
|
|
||||||
|
llamaWatcher.setSaddled(true);
|
||||||
|
llamaWatcher.setCarpet(color);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTask(LibsDisguises.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doDyeable(Player observer, Disguise disguise) {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -120,6 +120,11 @@ AddEntityAnimations: true
|
|||||||
DyeableSheep: false
|
DyeableSheep: false
|
||||||
DyeableWolf: false
|
DyeableWolf: false
|
||||||
DyeableCat: false
|
DyeableCat: false
|
||||||
|
# Can a player interact with a llama with carpet to set or change their carpet color?
|
||||||
|
CarpetableLlama: false
|
||||||
|
# Can a player interact with a non-saddled horse of any type, to give it a saddle?
|
||||||
|
# This does not change what you can ride or control!
|
||||||
|
SaddleableHorse: false
|
||||||
|
|
||||||
# This is only called into action when the disguise is constructed using the commands.
|
# This is only called into action when the disguise is constructed using the commands.
|
||||||
# And when the disguise supports that. This will not be used at all for plugins constructing the disguises for instance.
|
# And when the disguise supports that. This will not be used at all for plugins constructing the disguises for instance.
|
||||||
|
Loading…
Reference in New Issue
Block a user