Add nether sponge drying.

Fix bug with armor stand swapping.
Fix bug with seed drop planting.
master
dragontamerfred 2019-10-03 17:41:20 +02:00
parent 6d78b656de
commit 4a1793b2e1
9 changed files with 66 additions and 29 deletions

View File

@ -29,9 +29,11 @@ Works for:
### Armor stand swapping ### Armor stand swapping
Allow players to shift right-click on any armor stand to swap armor with it. 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 ## Planned tweaks
- Dynamite - Dynamite
- Sign editing - Sign editing
- Nether sponge drying

View File

@ -6,6 +6,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack;
public class ArmorStandSwappingHandler implements Listener { public class ArmorStandSwappingHandler implements Listener {
@ -19,12 +20,20 @@ public class ArmorStandSwappingHandler implements Listener {
EntityEquipment playerEquipment = player.getEquipment(); EntityEquipment playerEquipment = player.getEquipment();
if (standEquipment != null && playerEquipment != null) { if (standEquipment != null && playerEquipment != null) {
armorStand.setHelmet(playerEquipment.getHelmet()); ItemStack playerHelmet = playerEquipment.getHelmet();
armorStand.setChestplate(playerEquipment.getChestplate()); ItemStack playerChestpalte = playerEquipment.getChestplate();
armorStand.setLeggings(playerEquipment.getLeggings()); ItemStack playerLeggings = playerEquipment.getLeggings();
armorStand.setBoots(playerEquipment.getBoots()); 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); event.setCancelled(true);

View File

@ -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);
}
}
}

View File

@ -10,38 +10,44 @@ import org.bukkit.plugin.java.JavaPlugin;
public class SeedDropPlanting { public class SeedDropPlanting {
public static void init(JavaPlugin plugin) { public static void init(JavaPlugin plugin) {
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, () -> { Bukkit.getScheduler().runTaskTimer(plugin, () -> {
for (World world : plugin.getServer().getWorlds()) { for (World world : plugin.getServer().getWorlds()) {
for (Entity entity : world.getEntities()) { for (Entity entity : world.getEntities()) {
if (entity instanceof Item) { if (entity instanceof Item) {
Item item = ((Item) entity); Item item = ((Item) entity);
Block b = world.getBlockAt(item.getLocation()); Block b = world.getBlockAt(item.getLocation());
Block below = world.getBlockAt(item.getLocation().add(0, -1, 0)); Block above = world.getBlockAt(item.getLocation().add(0, 1, 0));
if (b.getType() == Material.AIR && below.getType() == Material.FARMLAND) { if (b.getType() == Material.FARMLAND && above.getType() == Material.AIR) {
switch (item.getItemStack().getType()) { switch (item.getItemStack().getType()) {
case WHEAT_SEEDS: case WHEAT_SEEDS:
b.setType(Material.WHEAT); above.setType(Material.WHEAT);
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10); world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
entity.remove();
break; break;
case BEETROOT_SEEDS: case BEETROOT_SEEDS:
b.setType(Material.BEETROOT); above.setType(Material.BEETROOTS);
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10); world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
entity.remove();
break; break;
case MELON_SEEDS: case MELON_SEEDS:
b.setType(Material.MELON_STEM); above.setType(Material.MELON_STEM);
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10); world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
entity.remove();
break; break;
case PUMPKIN_SEEDS: case PUMPKIN_SEEDS:
b.setType(Material.PUMPKIN_STEM); above.setType(Material.PUMPKIN_STEM);
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10); world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
entity.remove();
break; break;
case POTATO: case POTATO:
b.setType(Material.POTATOES); above.setType(Material.POTATOES);
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10); world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
entity.remove();
break; break;
case CARROT: case CARROT:
b.setType(Material.CARROTS); above.setType(Material.CARROTS);
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10); world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
entity.remove();
break; break;
} }
} }

View File

@ -2,6 +2,7 @@ package nl.kallestruik.vanillatweaks;
import nl.kallestruik.vanillatweaks.ArmorStandSwapping.ArmorStandSwappingHandler; import nl.kallestruik.vanillatweaks.ArmorStandSwapping.ArmorStandSwappingHandler;
import nl.kallestruik.vanillatweaks.CraftingTweaks.CraftingTweaks; import nl.kallestruik.vanillatweaks.CraftingTweaks.CraftingTweaks;
import nl.kallestruik.vanillatweaks.NetherSpongeDrying.NetherSpongeHandler;
import nl.kallestruik.vanillatweaks.SeedDropPlanting.SeedDropPlanting; import nl.kallestruik.vanillatweaks.SeedDropPlanting.SeedDropPlanting;
import nl.kallestruik.vanillatweaks.ToggleTrample.CommandToggletrample; import nl.kallestruik.vanillatweaks.ToggleTrample.CommandToggletrample;
import nl.kallestruik.vanillatweaks.ToggleTrample.TrampleHandler; import nl.kallestruik.vanillatweaks.ToggleTrample.TrampleHandler;
@ -38,22 +39,13 @@ public final class VanillaTweaks extends JavaPlugin {
SeedDropPlanting.init(this); SeedDropPlanting.init(this);
} }
/**
* Sign editing
*
* Shift right-click on a sign to edit it.
*/
if (config.ARMOR_STAND_SWAPPING_ENABLED) { if (config.ARMOR_STAND_SWAPPING_ENABLED) {
getServer().getPluginManager().registerEvents(new ArmorStandSwappingHandler(), this); getServer().getPluginManager().registerEvents(new ArmorStandSwappingHandler(), this);
} }
/** if (config.NETHER_SPONGE_DRYING_ENABLED) {
* Sponges in nether dry instantly getServer().getPluginManager().registerEvents(new NetherSpongeHandler(), this);
* }
* Kind of what is says.
*/
} catch (IOException | InvalidConfigurationException | NullPointerException e) { } catch (IOException | InvalidConfigurationException | NullPointerException e) {
util.printException(e); util.printException(e);

View File

@ -20,6 +20,8 @@ public class config {
public static boolean ARMOR_STAND_SWAPPING_ENABLED; public static boolean ARMOR_STAND_SWAPPING_ENABLED;
public static boolean NETHER_SPONGE_DRYING_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();
@ -39,5 +41,7 @@ public class config {
SEED_DROP_PLANTING_ENABLED = config.getBoolean("seed-drop-planting.enabled"); SEED_DROP_PLANTING_ENABLED = config.getBoolean("seed-drop-planting.enabled");
ARMOR_STAND_SWAPPING_ENABLED = config.getBoolean("armor-stand-swapping.enabled"); ARMOR_STAND_SWAPPING_ENABLED = config.getBoolean("armor-stand-swapping.enabled");
NETHER_SPONGE_DRYING_ENABLED = config.getBoolean("nether-sponge-drying.enabled");
} }
} }

View File

@ -15,7 +15,7 @@ public class util {
} }
public static void ExportResource(String resourceName, File output) { 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) { if (stream == null) {
throw new Exception("Cannot get resource \"" + resourceName + "\" from Jar file."); throw new Exception("Cannot get resource \"" + resourceName + "\" from Jar file.");
} }

View File

@ -12,4 +12,7 @@ seed-drop-planting:
enabled: true enabled: true
armor-stand-swapping: armor-stand-swapping:
enabled: true
nether-sponge-drying:
enabled: true enabled: true

View File

@ -3,4 +3,4 @@ version: @version@
main: nl.kallestruik.vanillatweaks.VanillaTweaks main: nl.kallestruik.vanillatweaks.VanillaTweaks
api-version: 1.13 api-version: 1.13
commands: commands:
toggeltrample: toggletrample: