Add armor stand swapping

master
dragontamerfred 2019-10-02 19:49:30 +02:00
parent 774f7d449f
commit 6d78b656de
5 changed files with 49 additions and 10 deletions

View File

@ -26,10 +26,12 @@ Works for:
- Melon
- Pumpkin
### Armor stand swapping
Allow players to shift right-click on any armor stand to swap armor with it.
## Planned tweaks
- Dynamite
- Sign editing
- Armor stand swapping
- Nether sponge drying

View File

@ -0,0 +1,35 @@
package nl.kallestruik.vanillatweaks.ArmorStandSwapping;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.inventory.EntityEquipment;
public class ArmorStandSwappingHandler implements Listener {
@EventHandler
public void onClickEntity(PlayerInteractAtEntityEvent event) {
if (event.getPlayer().isSneaking()) {
if (event.getRightClicked() instanceof ArmorStand) {
ArmorStand armorStand = ((ArmorStand) event.getRightClicked());
EntityEquipment standEquipment = armorStand.getEquipment();
Player player = event.getPlayer();
EntityEquipment playerEquipment = player.getEquipment();
if (standEquipment != null && playerEquipment != null) {
armorStand.setHelmet(playerEquipment.getHelmet());
armorStand.setChestplate(playerEquipment.getChestplate());
armorStand.setLeggings(playerEquipment.getLeggings());
armorStand.setBoots(playerEquipment.getBoots());
player.getInventory().setArmorContents(standEquipment.getArmorContents());
}
event.setCancelled(true);
}
}
}
}

View File

@ -1,5 +1,6 @@
package nl.kallestruik.vanillatweaks;
import nl.kallestruik.vanillatweaks.ArmorStandSwapping.ArmorStandSwappingHandler;
import nl.kallestruik.vanillatweaks.CraftingTweaks.CraftingTweaks;
import nl.kallestruik.vanillatweaks.SeedDropPlanting.SeedDropPlanting;
import nl.kallestruik.vanillatweaks.ToggleTrample.CommandToggletrample;
@ -43,11 +44,9 @@ public final class VanillaTweaks extends JavaPlugin {
* Shift right-click on a sign to edit it.
*/
/**
* Armour stand swap
*
* Shift right-click on armour stand to swap armour with it.
*/
if (config.ARMOR_STAND_SWAPPING_ENABLED) {
getServer().getPluginManager().registerEvents(new ArmorStandSwappingHandler(), this);
}
/**
* Sponges in nether dry instantly

View File

@ -18,6 +18,8 @@ public class config {
public static boolean SEED_DROP_PLANTING_ENABLED;
public static boolean ARMOR_STAND_SWAPPING_ENABLED;
public static void load(File file) throws IOException, InvalidConfigurationException {
if (!file.getParentFile().exists())
file.getParentFile().mkdirs();
@ -34,10 +36,8 @@ public class config {
CRAFTING_TWEAKS_WOOL_TO_STRING = config.getBoolean("crafting-tweaks.wool-to-string");
CRAFTING_TWEAKS_SADDLE = config.getBoolean("crafting-tweaks.saddle");
SEED_DROP_PLANTING_ENABLED = config.getBoolean("seed-drop-planting.enabled");
ARMOR_STAND_SWAPPING_ENABLED = config.getBoolean("armor-stand-swapping.enabled");
}
}

View File

@ -10,3 +10,6 @@ crafting-tweaks:
seed-drop-planting:
enabled: true
armor-stand-swapping:
enabled: true