Add nether sponge drying.
Fix bug with armor stand swapping. Fix bug with seed drop planting.master
parent
6d78b656de
commit
4a1793b2e1
|
@ -29,9 +29,11 @@ Works for:
|
|||
### Armor stand swapping
|
||||
Allow players to shift right-click on any armor stand to swap armor with it.
|
||||
|
||||
### Nether sponge drying
|
||||
Instantly dry wet sponges when they are placed in the nether.
|
||||
|
||||
## Planned tweaks
|
||||
- Dynamite
|
||||
- Sign editing
|
||||
- Nether sponge drying
|
||||
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ArmorStandSwappingHandler implements Listener {
|
||||
|
||||
|
@ -19,12 +20,20 @@ public class ArmorStandSwappingHandler implements Listener {
|
|||
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());
|
||||
ItemStack playerHelmet = playerEquipment.getHelmet();
|
||||
ItemStack playerChestpalte = playerEquipment.getChestplate();
|
||||
ItemStack playerLeggings = playerEquipment.getLeggings();
|
||||
ItemStack playerBoots = playerEquipment.getBoots();
|
||||
|
||||
player.getInventory().setArmorContents(standEquipment.getArmorContents());
|
||||
player.getInventory().setHelmet(standEquipment.getHelmet());
|
||||
player.getInventory().setChestplate(standEquipment.getChestplate());
|
||||
player.getInventory().setLeggings(standEquipment.getLeggings());
|
||||
player.getInventory().setBoots(standEquipment.getBoots());
|
||||
|
||||
armorStand.setHelmet(playerHelmet);
|
||||
armorStand.setChestplate(playerChestpalte);
|
||||
armorStand.setLeggings(playerLeggings);
|
||||
armorStand.setBoots(playerBoots);
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package nl.kallestruik.vanillatweaks.NetherSpongeDrying;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
public class NetherSpongeHandler implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onSpongePlaced(BlockPlaceEvent event) {
|
||||
Block block = event.getBlockPlaced();
|
||||
if (block.getType() == Material.WET_SPONGE &&
|
||||
block.getWorld().getEnvironment() == World.Environment.NETHER) {
|
||||
block.setType(Material.SPONGE);
|
||||
block.getWorld().spawnParticle(Particle.CAMPFIRE_COSY_SMOKE, block.getLocation(), 3);
|
||||
block.getWorld().playEffect(block.getLocation(), Effect.EXTINGUISH, 1, 10);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,38 +10,44 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||
public class SeedDropPlanting {
|
||||
|
||||
public static void init(JavaPlugin plugin) {
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, () -> {
|
||||
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
|
||||
for (World world : plugin.getServer().getWorlds()) {
|
||||
for (Entity entity : world.getEntities()) {
|
||||
if (entity instanceof Item) {
|
||||
Item item = ((Item) entity);
|
||||
Block b = world.getBlockAt(item.getLocation());
|
||||
Block below = world.getBlockAt(item.getLocation().add(0, -1, 0));
|
||||
if (b.getType() == Material.AIR && below.getType() == Material.FARMLAND) {
|
||||
Block above = world.getBlockAt(item.getLocation().add(0, 1, 0));
|
||||
if (b.getType() == Material.FARMLAND && above.getType() == Material.AIR) {
|
||||
switch (item.getItemStack().getType()) {
|
||||
case WHEAT_SEEDS:
|
||||
b.setType(Material.WHEAT);
|
||||
above.setType(Material.WHEAT);
|
||||
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
|
||||
entity.remove();
|
||||
break;
|
||||
case BEETROOT_SEEDS:
|
||||
b.setType(Material.BEETROOT);
|
||||
above.setType(Material.BEETROOTS);
|
||||
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
|
||||
entity.remove();
|
||||
break;
|
||||
case MELON_SEEDS:
|
||||
b.setType(Material.MELON_STEM);
|
||||
above.setType(Material.MELON_STEM);
|
||||
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
|
||||
entity.remove();
|
||||
break;
|
||||
case PUMPKIN_SEEDS:
|
||||
b.setType(Material.PUMPKIN_STEM);
|
||||
above.setType(Material.PUMPKIN_STEM);
|
||||
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
|
||||
entity.remove();
|
||||
break;
|
||||
case POTATO:
|
||||
b.setType(Material.POTATOES);
|
||||
above.setType(Material.POTATOES);
|
||||
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
|
||||
entity.remove();
|
||||
break;
|
||||
case CARROT:
|
||||
b.setType(Material.CARROTS);
|
||||
above.setType(Material.CARROTS);
|
||||
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
|
||||
entity.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package nl.kallestruik.vanillatweaks;
|
|||
|
||||
import nl.kallestruik.vanillatweaks.ArmorStandSwapping.ArmorStandSwappingHandler;
|
||||
import nl.kallestruik.vanillatweaks.CraftingTweaks.CraftingTweaks;
|
||||
import nl.kallestruik.vanillatweaks.NetherSpongeDrying.NetherSpongeHandler;
|
||||
import nl.kallestruik.vanillatweaks.SeedDropPlanting.SeedDropPlanting;
|
||||
import nl.kallestruik.vanillatweaks.ToggleTrample.CommandToggletrample;
|
||||
import nl.kallestruik.vanillatweaks.ToggleTrample.TrampleHandler;
|
||||
|
@ -38,22 +39,13 @@ public final class VanillaTweaks extends JavaPlugin {
|
|||
SeedDropPlanting.init(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sign editing
|
||||
*
|
||||
* Shift right-click on a sign to edit it.
|
||||
*/
|
||||
|
||||
if (config.ARMOR_STAND_SWAPPING_ENABLED) {
|
||||
getServer().getPluginManager().registerEvents(new ArmorStandSwappingHandler(), this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sponges in nether dry instantly
|
||||
*
|
||||
* Kind of what is says.
|
||||
*/
|
||||
|
||||
if (config.NETHER_SPONGE_DRYING_ENABLED) {
|
||||
getServer().getPluginManager().registerEvents(new NetherSpongeHandler(), this);
|
||||
}
|
||||
|
||||
} catch (IOException | InvalidConfigurationException | NullPointerException e) {
|
||||
util.printException(e);
|
||||
|
|
|
@ -20,6 +20,8 @@ public class config {
|
|||
|
||||
public static boolean ARMOR_STAND_SWAPPING_ENABLED;
|
||||
|
||||
public static boolean NETHER_SPONGE_DRYING_ENABLED;
|
||||
|
||||
public static void load(File file) throws IOException, InvalidConfigurationException {
|
||||
if (!file.getParentFile().exists())
|
||||
file.getParentFile().mkdirs();
|
||||
|
@ -39,5 +41,7 @@ public class config {
|
|||
SEED_DROP_PLANTING_ENABLED = config.getBoolean("seed-drop-planting.enabled");
|
||||
|
||||
ARMOR_STAND_SWAPPING_ENABLED = config.getBoolean("armor-stand-swapping.enabled");
|
||||
|
||||
NETHER_SPONGE_DRYING_ENABLED = config.getBoolean("nether-sponge-drying.enabled");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ public class util {
|
|||
}
|
||||
|
||||
public static void ExportResource(String resourceName, File output) {
|
||||
try (InputStream stream = VanillaTweaks.class.getResourceAsStream(resourceName); OutputStream resStreamOut = new FileOutputStream(output)) {
|
||||
try (InputStream stream = VanillaTweaks.class.getResourceAsStream("/" + resourceName); OutputStream resStreamOut = new FileOutputStream(output)) {
|
||||
if (stream == null) {
|
||||
throw new Exception("Cannot get resource \"" + resourceName + "\" from Jar file.");
|
||||
}
|
||||
|
|
|
@ -12,4 +12,7 @@ seed-drop-planting:
|
|||
enabled: true
|
||||
|
||||
armor-stand-swapping:
|
||||
enabled: true
|
||||
|
||||
nether-sponge-drying:
|
||||
enabled: true
|
|
@ -3,4 +3,4 @@ version: @version@
|
|||
main: nl.kallestruik.vanillatweaks.VanillaTweaks
|
||||
api-version: 1.13
|
||||
commands:
|
||||
toggeltrample:
|
||||
toggletrample:
|
||||
|
|
Reference in New Issue