Add armor stand swapping
parent
774f7d449f
commit
6d78b656de
|
@ -26,10 +26,12 @@ Works for:
|
||||||
- Melon
|
- Melon
|
||||||
- Pumpkin
|
- Pumpkin
|
||||||
|
|
||||||
|
### Armor stand swapping
|
||||||
|
Allow players to shift right-click on any armor stand to swap armor with it.
|
||||||
|
|
||||||
## Planned tweaks
|
## Planned tweaks
|
||||||
- Dynamite
|
- Dynamite
|
||||||
- Sign editing
|
- Sign editing
|
||||||
- Armor stand swapping
|
|
||||||
- Nether sponge drying
|
- Nether sponge drying
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package nl.kallestruik.vanillatweaks;
|
package nl.kallestruik.vanillatweaks;
|
||||||
|
|
||||||
|
import nl.kallestruik.vanillatweaks.ArmorStandSwapping.ArmorStandSwappingHandler;
|
||||||
import nl.kallestruik.vanillatweaks.CraftingTweaks.CraftingTweaks;
|
import nl.kallestruik.vanillatweaks.CraftingTweaks.CraftingTweaks;
|
||||||
import nl.kallestruik.vanillatweaks.SeedDropPlanting.SeedDropPlanting;
|
import nl.kallestruik.vanillatweaks.SeedDropPlanting.SeedDropPlanting;
|
||||||
import nl.kallestruik.vanillatweaks.ToggleTrample.CommandToggletrample;
|
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.
|
* Shift right-click on a sign to edit it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
if (config.ARMOR_STAND_SWAPPING_ENABLED) {
|
||||||
* Armour stand swap
|
getServer().getPluginManager().registerEvents(new ArmorStandSwappingHandler(), this);
|
||||||
*
|
}
|
||||||
* Shift right-click on armour stand to swap armour with it.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sponges in nether dry instantly
|
* Sponges in nether dry instantly
|
||||||
|
|
|
@ -18,6 +18,8 @@ public class config {
|
||||||
|
|
||||||
public static boolean SEED_DROP_PLANTING_ENABLED;
|
public static boolean SEED_DROP_PLANTING_ENABLED;
|
||||||
|
|
||||||
|
public static boolean ARMOR_STAND_SWAPPING_ENABLED;
|
||||||
|
|
||||||
public static void load(File file) throws IOException, InvalidConfigurationException {
|
public static void load(File file) throws IOException, InvalidConfigurationException {
|
||||||
if (!file.getParentFile().exists())
|
if (!file.getParentFile().exists())
|
||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
|
@ -34,10 +36,8 @@ public class config {
|
||||||
CRAFTING_TWEAKS_WOOL_TO_STRING = config.getBoolean("crafting-tweaks.wool-to-string");
|
CRAFTING_TWEAKS_WOOL_TO_STRING = config.getBoolean("crafting-tweaks.wool-to-string");
|
||||||
CRAFTING_TWEAKS_SADDLE = config.getBoolean("crafting-tweaks.saddle");
|
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");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,4 +9,7 @@ crafting-tweaks:
|
||||||
saddle: true
|
saddle: true
|
||||||
|
|
||||||
seed-drop-planting:
|
seed-drop-planting:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
armor-stand-swapping:
|
||||||
enabled: true
|
enabled: true
|
Reference in New Issue