Make preparations for a more modular system.
parent
52814d05d5
commit
11cf488bef
|
@ -16,11 +16,12 @@ repositories {
|
|||
name = 'sonatype'
|
||||
url = 'https://oss.sonatype.org/content/groups/public/'
|
||||
}
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile group: 'junit', name: 'junit', version: '4.12'
|
||||
compile 'org.spigotmc:spigot-api:1.14.4-R0.1-SNAPSHOT'
|
||||
compile 'org.spigotmc:spigot:1.16.1-R0.1-SNAPSHOT'
|
||||
}
|
||||
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
pluginGroup=nl.kallestruik
|
||||
pluginVersion=1.1
|
||||
pluginVersion=1.2
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#Wed Aug 19 21:18:18 CEST 2020
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
package nl.kallestruik.vanillatweaks.CraftingTweaks;
|
||||
|
||||
import nl.kallestruik.vanillatweaks.config;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.RecipeChoice;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.ShapelessRecipe;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class CraftingTweaks {
|
||||
|
||||
public static void init(JavaPlugin plugin) {
|
||||
RecipeChoice woodLog = new RecipeChoice.MaterialChoice(Material.OAK_LOG, Material.BIRCH_LOG, Material.SPRUCE_LOG, Material.JUNGLE_LOG, Material.ACACIA_LOG, Material.DARK_OAK_LOG);
|
||||
RecipeChoice allWool = new RecipeChoice.MaterialChoice(Material.WHITE_WOOL, Material.BLACK_WOOL, Material.BLUE_WOOL, Material.BROWN_WOOL, Material.CYAN_WOOL, Material.GRAY_WOOL, Material.GREEN_WOOL, Material.LIGHT_BLUE_WOOL, Material.LIGHT_GRAY_WOOL, Material.LIME_WOOL, Material.MAGENTA_WOOL, Material.ORANGE_WOOL, Material.PINK_WOOL, Material.PURPLE_WOOL, Material.RED_WOOL, Material.YELLOW_WOOL);
|
||||
|
||||
// Better chest recipe
|
||||
NamespacedKey chestKey = new NamespacedKey(plugin, "chest");
|
||||
ShapedRecipe chestRecipe = new ShapedRecipe(chestKey, new ItemStack(Material.CHEST, 4));
|
||||
chestRecipe.shape("WWW", "W W", "WWW");
|
||||
chestRecipe.setIngredient('W', woodLog);
|
||||
|
||||
// Name tag recipe
|
||||
NamespacedKey nametagKey = new NamespacedKey(plugin, "nametag");
|
||||
ShapedRecipe nametagRecipe = new ShapedRecipe(nametagKey, new ItemStack(Material.NAME_TAG));
|
||||
nametagRecipe.shape(" I", " P ", "P ");
|
||||
nametagRecipe.setIngredient('I', Material.IRON_INGOT);
|
||||
nametagRecipe.setIngredient('P', Material.PAPER);
|
||||
|
||||
// Wool > String recipe
|
||||
NamespacedKey stringKey = new NamespacedKey(plugin, "string");
|
||||
ShapelessRecipe stringRecipe = new ShapelessRecipe(stringKey, new ItemStack(Material.STRING, 4));
|
||||
stringRecipe.addIngredient(allWool);
|
||||
|
||||
// Saddle
|
||||
NamespacedKey saddleKey = new NamespacedKey(plugin, "saddle");
|
||||
ShapedRecipe saddleRecipe = new ShapedRecipe(saddleKey, new ItemStack(Material.SADDLE));
|
||||
saddleRecipe.shape("LLL", "S S", "I I");
|
||||
saddleRecipe.setIngredient('L', Material.LEATHER);
|
||||
saddleRecipe.setIngredient('S', Material.STRING);
|
||||
saddleRecipe.setIngredient('I', Material.IRON_INGOT);
|
||||
|
||||
// Blue ice -> 9 packed ice
|
||||
NamespacedKey packedIceKey = new NamespacedKey(plugin, "packed_ice");
|
||||
ShapelessRecipe packedIceRecipe = new ShapelessRecipe(packedIceKey, new ItemStack(Material.PACKED_ICE, 9));
|
||||
packedIceRecipe.addIngredient(Material.BLUE_ICE);
|
||||
|
||||
// Packed ice -> 9 ice
|
||||
NamespacedKey iceKey = new NamespacedKey(plugin, "ice");
|
||||
ShapelessRecipe iceRecipe = new ShapelessRecipe(iceKey, new ItemStack(Material.ICE, 9));
|
||||
iceRecipe.addIngredient(Material.PACKED_ICE);
|
||||
|
||||
// Dragons breath
|
||||
NamespacedKey dragonBreathKey = new NamespacedKey(plugin, "dragon_breath");
|
||||
ShapedRecipe dragonBreathRecipe = new ShapedRecipe(dragonBreathKey, new ItemStack(Material.DRAGON_BREATH, 3));
|
||||
dragonBreathRecipe.shape("GCG", " G ");
|
||||
dragonBreathRecipe.setIngredient('G', Material.GLASS);
|
||||
dragonBreathRecipe.setIngredient('C', Material.POPPED_CHORUS_FRUIT);
|
||||
|
||||
// Sponge Block
|
||||
NamespacedKey spongeKey = new NamespacedKey(plugin, "sponge");
|
||||
ShapedRecipe spongeRecipe = new ShapedRecipe(spongeKey, new ItemStack(Material.SPONGE));
|
||||
spongeRecipe.shape("KKK","KDK","KKK");
|
||||
spongeRecipe.setIngredient('K', Material.KELP);
|
||||
spongeRecipe.setIngredient('D', Material.YELLOW_DYE);
|
||||
|
||||
// Dispenser Alternative Recipe
|
||||
NamespacedKey dispenserKey = new NamespacedKey(plugin, "dispenser");
|
||||
ShapedRecipe dispenserRecipe = new ShapedRecipe(dispenserKey, new ItemStack(Material.DISPENSER));
|
||||
dispenserRecipe.shape(" TS","TDS"," TS");
|
||||
dispenserRecipe.setIngredient('T', Material.STICK);
|
||||
dispenserRecipe.setIngredient('D', Material.DROPPER);
|
||||
dispenserRecipe.setIngredient('S', Material.STRING);
|
||||
|
||||
// Shulker Shell
|
||||
NamespacedKey shulkerShellKey = new NamespacedKey(plugin, "shulker_shell");
|
||||
ShapedRecipe shulkerShellRecipe = new ShapedRecipe(shulkerShellKey, new ItemStack(Material.SHULKER_SHELL));
|
||||
shulkerShellRecipe.shape("BBB","F F");
|
||||
shulkerShellRecipe.setIngredient('B', Material.PURPUR_SLAB);
|
||||
shulkerShellRecipe.setIngredient('F', Material.POPPED_CHORUS_FRUIT);
|
||||
|
||||
|
||||
|
||||
// Add recipes
|
||||
if (config.CRAFTING_TWEAKS_BETTER_CHEST) plugin.getServer().addRecipe(chestRecipe);
|
||||
if (config.CRAFTING_TWEAKS_NAME_TAG) plugin.getServer().addRecipe(nametagRecipe);
|
||||
if (config.CRAFTING_TWEAKS_WOOL_TO_STRING) plugin.getServer().addRecipe(stringRecipe);
|
||||
if (config.CRAFTING_TWEAKS_SADDLE) plugin.getServer().addRecipe(saddleRecipe);
|
||||
if (config.CRAFTING_TWEAKS_PACKED_ICE) plugin.getServer().addRecipe(packedIceRecipe);
|
||||
if (config.CRAFTING_TWEAKS_ICE) plugin.getServer().addRecipe(iceRecipe);
|
||||
if (config.CRAFTING_TWEAKS_DRAGONS_BREATH) plugin.getServer().addRecipe(dragonBreathRecipe);
|
||||
if (config.CRAFTING_TWEAKS_SPONGE) plugin.getServer().addRecipe(spongeRecipe);
|
||||
if (config.CRAFTING_TWEAKS_DISPENSER) plugin.getServer().addRecipe(dispenserRecipe);
|
||||
if (config.CRAFTING_TWEAKS_SHULKER_SHELL) plugin.getServer().addRecipe(shulkerShellRecipe);
|
||||
}
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
package nl.kallestruik.vanillatweaks.DispenserTweaks;
|
||||
|
||||
import nl.kallestruik.vanillatweaks.config;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.Dispenser;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockDispenseEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DispenserTweaksHandler implements Listener {
|
||||
|
||||
private static List<Material> saplings = new ArrayList<>();
|
||||
private static List<Material> treePlantable = new ArrayList<>();
|
||||
|
||||
public DispenserTweaksHandler() {
|
||||
saplings.add(Material.OAK_SAPLING);
|
||||
saplings.add(Material.BIRCH_SAPLING);
|
||||
saplings.add(Material.JUNGLE_SAPLING);
|
||||
saplings.add(Material.SPRUCE_SAPLING);
|
||||
saplings.add(Material.DARK_OAK_SAPLING);
|
||||
saplings.add(Material.ACACIA_SAPLING);
|
||||
|
||||
treePlantable.add(Material.DIRT);
|
||||
treePlantable.add(Material.GRASS_BLOCK);
|
||||
treePlantable.add(Material.COARSE_DIRT);
|
||||
treePlantable.add(Material.PODZOL);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDispenserDispense(BlockDispenseEvent event) {
|
||||
if (event.getBlock().getType() != Material.DISPENSER)
|
||||
return;
|
||||
|
||||
if (config.DISPENSERS_CAN_PLACE_SAPLINGS) {
|
||||
if (saplings.contains(event.getItem().getType())) {
|
||||
Dispenser dispenser = ((Dispenser) event.getBlock().getBlockData());
|
||||
BlockFace facing = dispenser.getFacing();
|
||||
Block targetBlock;
|
||||
if (facing == BlockFace.UP) {
|
||||
targetBlock = event.getBlock().getWorld().getBlockAt(event.getBlock().getLocation().add(0, 2, 0));
|
||||
} else {
|
||||
targetBlock = event.getBlock().getWorld().getBlockAt(event.getBlock().getLocation().add(facing.getModX(), facing.getModY(), facing.getModZ()));
|
||||
}
|
||||
if (targetBlock.getType() == Material.AIR
|
||||
&& treePlantable.contains(event.getBlock().getWorld().getBlockAt(targetBlock.getLocation().add(0, -1, 0)).getType())) {
|
||||
targetBlock.setType(event.getItem().getType());
|
||||
|
||||
event.setCancelled(true);
|
||||
Inventory dispenserInventory = ((org.bukkit.block.Dispenser) event.getBlock().getState()).getInventory();
|
||||
int slot = 0;
|
||||
for (ItemStack is : dispenserInventory.getContents()) {
|
||||
if (is != null && is.getType() == event.getItem().getType())
|
||||
break;
|
||||
slot++;
|
||||
}
|
||||
ItemStack newItemStack = dispenserInventory.getItem(slot);
|
||||
newItemStack.setAmount(newItemStack.getAmount() - 1);
|
||||
dispenserInventory.setItem(slot, newItemStack);
|
||||
|
||||
event.getBlock().getWorld().spawnParticle(Particle.VILLAGER_HAPPY, targetBlock.getLocation(), 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
package nl.kallestruik.vanillatweaks.ToggleTrample;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TrampleHandler implements Listener {
|
||||
|
||||
static HashSet<UUID> trampleEnabled = new HashSet<>();
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(EntityChangeBlockEvent event) {
|
||||
if (event.getBlock().getType() != Material.FARMLAND)
|
||||
return;
|
||||
|
||||
if (event.getEntity() instanceof Villager) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getEntity() instanceof IronGolem) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity() instanceof Player))
|
||||
return;
|
||||
|
||||
if (trampleEnabled.contains(event.getEntity().getUniqueId()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
public static void loadTrampleEnabled(File file) throws IOException, InvalidConfigurationException {
|
||||
file.getParentFile().mkdirs();
|
||||
file.createNewFile();
|
||||
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
config.load(file);
|
||||
|
||||
for (String item : config.getStringList("enabled"))
|
||||
trampleEnabled.add(UUID.fromString(item));
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
public static void saveTrampleEnabled(File file) throws IOException, InvalidConfigurationException {
|
||||
file.getParentFile().mkdirs();
|
||||
file.createNewFile();
|
||||
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
config.load(file);
|
||||
|
||||
List<String> list = new ArrayList<>();
|
||||
for (UUID entry : trampleEnabled)
|
||||
list.add(entry.toString());
|
||||
|
||||
config.set("enabled", list);
|
||||
|
||||
config.save(file);
|
||||
|
||||
}
|
||||
}
|
|
@ -1,71 +1,77 @@
|
|||
package nl.kallestruik.vanillatweaks;
|
||||
|
||||
import nl.kallestruik.vanillatweaks.ArmorStandSwapping.ArmorStandSwappingHandler;
|
||||
import nl.kallestruik.vanillatweaks.CraftingTweaks.CraftingTweaks;
|
||||
import nl.kallestruik.vanillatweaks.DispenserTweaks.DispenserTweaksHandler;
|
||||
import nl.kallestruik.vanillatweaks.HoeHarvesting.HoeHarvestingHandler;
|
||||
import nl.kallestruik.vanillatweaks.LilypadGrowing.LilypadGrowingHandler;
|
||||
import nl.kallestruik.vanillatweaks.NetherSpongeDrying.NetherSpongeHandler;
|
||||
import nl.kallestruik.vanillatweaks.SeedDropPlanting.SeedDropPlanting;
|
||||
import nl.kallestruik.vanillatweaks.ToggleTrample.CommandToggletrample;
|
||||
import nl.kallestruik.vanillatweaks.ToggleTrample.TrampleHandler;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import nl.kallestruik.vanillatweaks.commands.CommandPlayer;
|
||||
import nl.kallestruik.vanillatweaks.commands.CommandToggletrample;
|
||||
import nl.kallestruik.vanillatweaks.core.TweakManager;
|
||||
import nl.kallestruik.vanillatweaks.core.TweakStates;
|
||||
import nl.kallestruik.vanillatweaks.tweaks.craftingtweaks.*;
|
||||
import nl.kallestruik.vanillatweaks.tweaks.croptweaks.MobsCantTrampleCrops;
|
||||
import nl.kallestruik.vanillatweaks.tweaks.croptweaks.PlayersCantTrampleCrops;
|
||||
import nl.kallestruik.vanillatweaks.tweaks.dispensertweaks.DispensersCanPlantSaplings;
|
||||
import nl.kallestruik.vanillatweaks.tweaks.miscellaneoustweaks.ArmorStandArmorSwapping;
|
||||
import nl.kallestruik.vanillatweaks.tweaks.miscellaneoustweaks.HoesHarvestArea;
|
||||
import nl.kallestruik.vanillatweaks.tweaks.miscellaneoustweaks.LilypadBonemealing;
|
||||
import nl.kallestruik.vanillatweaks.tweaks.miscellaneoustweaks.SeedDropPlanting;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public final class VanillaTweaks extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
try {
|
||||
// Load the config from disk.
|
||||
config.load(new File(this.getDataFolder(), c.CONFIG_FILE_NAME));
|
||||
/*
|
||||
* Setup
|
||||
*/
|
||||
TweakStates.load(new File(this.getDataFolder(), c.TWEAK_STATE_FILE_NAME));
|
||||
|
||||
if (config.TOGGLE_TRAMPLE_ENABLED) {
|
||||
TrampleHandler.loadTrampleEnabled(new File(this.getDataFolder(), c.TRAMPLE_ENABLED_FILE_NAME));
|
||||
getServer().getPluginCommand("toggletrample").setExecutor(new CommandToggletrample());
|
||||
getServer().getPluginManager().registerEvents(new TrampleHandler(), this);
|
||||
}
|
||||
/*
|
||||
* Commands
|
||||
*/
|
||||
getCommand("toggletrample").setExecutor(new CommandToggletrample());
|
||||
|
||||
if (config.CRAFTING_TWEAKS_ENABLED) {
|
||||
CraftingTweaks.init(this);
|
||||
}
|
||||
/*
|
||||
* Crafting Tweaks
|
||||
*/
|
||||
TweakManager.registerTweak(new AlternativeDispenserRecipe(), this);
|
||||
TweakManager.registerTweak(new CraftableDragonsBreath(), this);
|
||||
TweakManager.registerTweak(new CraftableNametag(), this);
|
||||
TweakManager.registerTweak(new CraftableSaddle(), this);
|
||||
TweakManager.registerTweak(new CraftableShulkerShell(), this);
|
||||
TweakManager.registerTweak(new CraftableSponge(), this);
|
||||
TweakManager.registerTweak(new IceDecompression(), this);
|
||||
TweakManager.registerTweak(new LogsToChests(), this);
|
||||
TweakManager.registerTweak(new WoolToString(), this);
|
||||
|
||||
if (config.SEED_DROP_PLANTING_ENABLED) {
|
||||
SeedDropPlanting.init(this);
|
||||
}
|
||||
/*
|
||||
* Crop Tweaks
|
||||
*/
|
||||
TweakManager.registerTweak(new MobsCantTrampleCrops(), this);
|
||||
TweakManager.registerTweak(new PlayersCantTrampleCrops(), this);
|
||||
|
||||
if (config.ARMOR_STAND_SWAPPING_ENABLED) {
|
||||
getServer().getPluginManager().registerEvents(new ArmorStandSwappingHandler(), this);
|
||||
}
|
||||
/*
|
||||
* Dispenser Tweaks
|
||||
*/
|
||||
TweakManager.registerTweak(new DispensersCanPlantSaplings(), this);
|
||||
|
||||
if (config.NETHER_SPONGE_DRYING_ENABLED) {
|
||||
getServer().getPluginManager().registerEvents(new NetherSpongeHandler(), this);
|
||||
}
|
||||
|
||||
if (config.HOE_HARVESTING_ENABLED) {
|
||||
getServer().getPluginManager().registerEvents(new HoeHarvestingHandler(), this);
|
||||
}
|
||||
|
||||
if (config.LILYPAD_GROWING_ENABLED) {
|
||||
getServer().getPluginManager().registerEvents(new LilypadGrowingHandler(), this);
|
||||
}
|
||||
|
||||
getServer().getPluginManager().registerEvents(new DispenserTweaksHandler(), this);
|
||||
|
||||
} catch (IOException | InvalidConfigurationException | NullPointerException e) {
|
||||
Util.printException(e);
|
||||
}
|
||||
/*
|
||||
* Miscellaneous Tweaks
|
||||
*/
|
||||
TweakManager.registerTweak(new ArmorStandArmorSwapping(), this);
|
||||
TweakManager.registerTweak(new HoesHarvestArea(), this);
|
||||
TweakManager.registerTweak(new LilypadBonemealing(), this);
|
||||
TweakManager.registerTweak(new SeedDropPlanting(), this);
|
||||
TweakManager.registerTweak(new DispensersCanPlantSaplings(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
try {
|
||||
TrampleHandler.saveTrampleEnabled(new File(this.getDataFolder(), c.TRAMPLE_ENABLED_FILE_NAME));
|
||||
} catch (IOException | InvalidConfigurationException | NullPointerException e) {
|
||||
Util.printException(e);
|
||||
}
|
||||
TweakManager.unRegisterAllTweaks();
|
||||
|
||||
/*
|
||||
* Finishing up
|
||||
*/
|
||||
TweakStates.save(new File(this.getDataFolder(), c.TWEAK_STATE_FILE_NAME));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,6 @@ package nl.kallestruik.vanillatweaks;
|
|||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public class c {
|
||||
public static final String CONFIG_FILE_NAME = "config.yml";
|
||||
public static String TRAMPLE_ENABLED_FILE_NAME = "tramplestore.yml";
|
||||
public static final String TRAMPLE_ENABLED_FILE_NAME = "tramplestore.yml";
|
||||
public static final String TWEAK_STATE_FILE_NAME = "tweak_states.yml";
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package nl.kallestruik.vanillatweaks.ToggleTrample;
|
||||
package nl.kallestruik.vanillatweaks.commands;
|
||||
|
||||
import nl.kallestruik.vanillatweaks.tweaks.croptweaks.PlayersCantTrampleCrops;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
|
@ -17,10 +18,10 @@ public class CommandToggletrample implements CommandExecutor {
|
|||
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (TrampleHandler.trampleEnabled.remove(player.getUniqueId())) {
|
||||
if (PlayersCantTrampleCrops.trampleEnabled.remove(player.getUniqueId())) {
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&2Crop Trampling: &2&lEnabled"));
|
||||
} else {
|
||||
TrampleHandler.trampleEnabled.add(player.getUniqueId());
|
||||
PlayersCantTrampleCrops.trampleEnabled.add(player.getUniqueId());
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&2Crop Trampling: &4&lDisabled"));
|
||||
}
|
||||
return true;
|
|
@ -1,83 +0,0 @@
|
|||
package nl.kallestruik.vanillatweaks;
|
||||
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings({"WeakerAccess", "ResultOfMethodCallIgnored"})
|
||||
public class config {
|
||||
|
||||
public static boolean TOGGLE_TRAMPLE_ENABLED;
|
||||
|
||||
public static boolean CRAFTING_TWEAKS_ENABLED;
|
||||
public static boolean CRAFTING_TWEAKS_BETTER_CHEST;
|
||||
public static boolean CRAFTING_TWEAKS_NAME_TAG;
|
||||
public static boolean CRAFTING_TWEAKS_WOOL_TO_STRING;
|
||||
public static boolean CRAFTING_TWEAKS_SADDLE;
|
||||
public static boolean CRAFTING_TWEAKS_PACKED_ICE;
|
||||
public static boolean CRAFTING_TWEAKS_ICE;
|
||||
public static boolean CRAFTING_TWEAKS_DRAGONS_BREATH;
|
||||
public static boolean CRAFTING_TWEAKS_SPONGE;
|
||||
public static boolean CRAFTING_TWEAKS_DISPENSER;
|
||||
public static boolean CRAFTING_TWEAKS_SHULKER_SHELL;
|
||||
|
||||
public static boolean SEED_DROP_PLANTING_ENABLED;
|
||||
|
||||
public static boolean ARMOR_STAND_SWAPPING_ENABLED;
|
||||
|
||||
public static boolean NETHER_SPONGE_DRYING_ENABLED;
|
||||
|
||||
public static boolean HOE_HARVESTING_ENABLED;
|
||||
public static int HOE_HARVESTING_RANGE_WOOD;
|
||||
public static int HOE_HARVESTING_RANGE_STONE;
|
||||
public static int HOE_HARVESTING_RANGE_IRON;
|
||||
public static int HOE_HARVESTING_RANGE_GOLD;
|
||||
public static int HOE_HARVESTING_RANGE_DIAMOND;
|
||||
|
||||
public static boolean LILYPAD_GROWING_ENABLED;
|
||||
|
||||
public static boolean DISPENSERS_CAN_PLACE_SAPLINGS;
|
||||
|
||||
public static void load(File file) throws IOException, InvalidConfigurationException {
|
||||
if (!file.getParentFile().exists())
|
||||
file.getParentFile().mkdirs();
|
||||
if (!file.exists())
|
||||
Util.exportResource(c.CONFIG_FILE_NAME, file);
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
config.load(file);
|
||||
|
||||
TOGGLE_TRAMPLE_ENABLED = config.getBoolean("toggle-trample.enabled");
|
||||
|
||||
CRAFTING_TWEAKS_ENABLED = config.getBoolean("crafting-tweaks.enabled");
|
||||
CRAFTING_TWEAKS_BETTER_CHEST = config.getBoolean("crafting-tweaks.better-chest");
|
||||
CRAFTING_TWEAKS_NAME_TAG = config.getBoolean("crafting-tweaks.name-tag");
|
||||
CRAFTING_TWEAKS_WOOL_TO_STRING = config.getBoolean("crafting-tweaks.wool-to-string");
|
||||
CRAFTING_TWEAKS_SADDLE = config.getBoolean("crafting-tweaks.saddle");
|
||||
CRAFTING_TWEAKS_PACKED_ICE = config.getBoolean("crafting-tweaks.packed-ice");
|
||||
CRAFTING_TWEAKS_ICE = config.getBoolean("crafting-tweaks.ice");
|
||||
CRAFTING_TWEAKS_DRAGONS_BREATH = config.getBoolean("crafting-tweaks.dragons-breath");
|
||||
CRAFTING_TWEAKS_SPONGE = config.getBoolean("crafting-tweaks.sponge");
|
||||
CRAFTING_TWEAKS_DISPENSER = config.getBoolean("crafting-tweaks.dispenser");
|
||||
CRAFTING_TWEAKS_SHULKER_SHELL = config.getBoolean("crafting-tweaks.shulker-shell");
|
||||
|
||||
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");
|
||||
|
||||
HOE_HARVESTING_ENABLED = config.getBoolean("hoe-harvesting.enabled");
|
||||
HOE_HARVESTING_RANGE_WOOD = config.getInt("hoe-harvesting.ranges.wood");
|
||||
HOE_HARVESTING_RANGE_STONE = config.getInt("hoe-harvesting.ranges.stone");
|
||||
HOE_HARVESTING_RANGE_IRON = config.getInt("hoe-harvesting.ranges.iron");
|
||||
HOE_HARVESTING_RANGE_GOLD = config.getInt("hoe-harvesting.ranges.gold");
|
||||
HOE_HARVESTING_RANGE_DIAMOND = config.getInt("hoe-harvesting.ranges.diamond");
|
||||
|
||||
LILYPAD_GROWING_ENABLED = config.getBoolean("lilypad-growing.enabled");
|
||||
|
||||
DISPENSERS_CAN_PLACE_SAPLINGS = config.getBoolean("dispenser-tweaks.place-saplings");
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package nl.kallestruik.vanillatweaks.core;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public interface Tweak {
|
||||
|
||||
String getIdentifier();
|
||||
|
||||
void onRegister(JavaPlugin pluginInstance);
|
||||
|
||||
void onUnRegister();
|
||||
|
||||
void onEnable();
|
||||
|
||||
void onDisable();
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package nl.kallestruik.vanillatweaks.core;
|
||||
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class TweakManager {
|
||||
|
||||
// A HashMap containing the tweak identifier mapped to the instance of the tweak.
|
||||
private static final ConcurrentHashMap<String, Tweak> tweaks = new ConcurrentHashMap<>();
|
||||
// A HashMap containing categories and the tweak identifiers that belong to them.
|
||||
private static final HashMap<String, List<String>> tweakCategories = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Register a new tweak.
|
||||
*
|
||||
* @param tweak An instance of the tweak.
|
||||
* @param pluginInstance An instance of the plugin.
|
||||
* @return True if the tweak did not yet exist false otherwise.
|
||||
*/
|
||||
public static boolean registerTweak(Tweak tweak, JavaPlugin pluginInstance) {
|
||||
if (tweaks.containsKey(tweak.getIdentifier()))
|
||||
return false;
|
||||
|
||||
tweaks.put(tweak.getIdentifier(), tweak);
|
||||
tweak.onRegister(pluginInstance);
|
||||
if (TweakStates.get(tweak.getIdentifier()))
|
||||
tweak.onEnable();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a tweak.
|
||||
*
|
||||
* @param identifier The identifier of the tweak to unregister.
|
||||
* @return True if the tweak was successfully unregistered false otherwise.
|
||||
*/
|
||||
public static boolean unRegisterTweak(String identifier) {
|
||||
if (!tweaks.containsKey(identifier))
|
||||
return false;
|
||||
|
||||
Tweak tweak = tweaks.get(identifier);
|
||||
tweak.onDisable();
|
||||
tweak.onUnRegister();
|
||||
tweaks.remove(identifier);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister every tweak that is currently registered.
|
||||
*/
|
||||
public static void unRegisterAllTweaks() {
|
||||
for (String identifier : tweaks.keySet()) {
|
||||
unRegisterTweak(identifier);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable a tweak.
|
||||
*
|
||||
* @param identifier The identifier of the tweak.
|
||||
* @return True if the tweak exists false otherwise.
|
||||
*/
|
||||
public static boolean enableTweak(String identifier) {
|
||||
if (!tweaks.containsKey(identifier))
|
||||
return false;
|
||||
|
||||
TweakStates.set(identifier, true);
|
||||
tweaks.get(identifier).onEnable();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable a tweak.
|
||||
*
|
||||
* @param identifier The identifier of the tweak.
|
||||
* @return True if the tweak exists false otherwise.
|
||||
*/
|
||||
public static boolean disableTweak(String identifier) {
|
||||
if (!tweaks.containsKey(identifier))
|
||||
return false;
|
||||
|
||||
TweakStates.set(identifier, false);
|
||||
tweaks.get(identifier).onDisable();
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package nl.kallestruik.vanillatweaks.core;
|
||||
|
||||
import nl.kallestruik.vanillatweaks.util.Util;
|
||||
import nl.kallestruik.vanillatweaks.c;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TweakStates {
|
||||
|
||||
private static final HashMap<String, Boolean> states = new HashMap<>();
|
||||
|
||||
public static void load(File file) {
|
||||
try {
|
||||
if (!file.getParentFile().exists())
|
||||
file.getParentFile().mkdirs();
|
||||
if (!file.exists())
|
||||
Util.exportResource(c.TWEAK_STATE_FILE_NAME, file);
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
config.load(file);
|
||||
|
||||
for (String key : config.getKeys(false)) {
|
||||
states.put(key, config.getBoolean(key));
|
||||
}
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
Util.printException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void save(File file) {
|
||||
try {
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
|
||||
for (Map.Entry<String, Boolean> entry : states.entrySet()) {
|
||||
config.set(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
config.save(file);
|
||||
} catch (IOException e) {
|
||||
Util.printException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void set(String identifier, boolean state) {
|
||||
states.put(identifier, state);
|
||||
}
|
||||
|
||||
public static boolean get(String identifier) {
|
||||
if (!states.containsKey(identifier))
|
||||
states.put(identifier, false);
|
||||
|
||||
return states.get(identifier);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package nl.kallestruik.vanillatweaks.tweaks.craftingtweaks;
|
||||
|
||||
import nl.kallestruik.vanillatweaks.core.Tweak;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class AlternativeDispenserRecipe implements Tweak {
|
||||
private JavaPlugin plugin;
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "AlternativeDispenserRecipe";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(JavaPlugin pluginInstance) {
|
||||
this.plugin = pluginInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnRegister() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
NamespacedKey dispenserKey = new NamespacedKey(plugin, "dispenser");
|
||||
ShapedRecipe dispenserRecipe = new ShapedRecipe(dispenserKey, new ItemStack(Material.DISPENSER));
|
||||
dispenserRecipe.shape(" TS","TDS"," TS");
|
||||
dispenserRecipe.setIngredient('T', Material.STICK);
|
||||
dispenserRecipe.setIngredient('D', Material.DROPPER);
|
||||
dispenserRecipe.setIngredient('S', Material.STRING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package nl.kallestruik.vanillatweaks.tweaks.craftingtweaks;
|
||||
|
||||
import nl.kallestruik.vanillatweaks.core.Tweak;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class CraftableDragonsBreath implements Tweak {
|
||||
private JavaPlugin plugin;
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "CraftableDragonsBreath";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(JavaPlugin pluginInstance) {
|
||||
this.plugin = pluginInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnRegister() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
NamespacedKey dragonBreathKey = new NamespacedKey(plugin, "dragon_breath");
|
||||
ShapedRecipe dragonBreathRecipe = new ShapedRecipe(dragonBreathKey, new ItemStack(Material.DRAGON_BREATH, 3));
|
||||
dragonBreathRecipe.shape("GCG", " G ");
|
||||
dragonBreathRecipe.setIngredient('G', Material.GLASS);
|
||||
dragonBreathRecipe.setIngredient('C', Material.POPPED_CHORUS_FRUIT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package nl.kallestruik.vanillatweaks.tweaks.craftingtweaks;
|
||||
|
||||
import nl.kallestruik.vanillatweaks.core.Tweak;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class CraftableNametag implements Tweak {
|
||||
private JavaPlugin plugin;
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "CraftableNametag";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(JavaPlugin pluginInstance) {
|
||||
this.plugin = pluginInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnRegister() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
NamespacedKey nametagKey = new NamespacedKey(plugin, "nametag");
|
||||
ShapedRecipe nametagRecipe = new ShapedRecipe(nametagKey, new ItemStack(Material.NAME_TAG));
|
||||
nametagRecipe.shape(" I", " P ", "P ");
|
||||
nametagRecipe.setIngredient('I', Material.IRON_INGOT);
|
||||
nametagRecipe.setIngredient('P', Material.PAPER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package nl.kallestruik.vanillatweaks.tweaks.craftingtweaks;
|
||||
|
||||
import nl.kallestruik.vanillatweaks.core.Tweak;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class CraftableSaddle implements Tweak {
|
||||
private JavaPlugin plugin;
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "CraftableSaddle";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(JavaPlugin pluginInstance) {
|
||||
this.plugin = pluginInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnRegister() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
NamespacedKey saddleKey = new NamespacedKey(plugin, "saddle");
|
||||
ShapedRecipe saddleRecipe = new ShapedRecipe(saddleKey, new ItemStack(Material.SADDLE));
|
||||
saddleRecipe.shape("LLL", "S S", "I I");
|
||||
saddleRecipe.setIngredient('L', Material.LEATHER);
|
||||
saddleRecipe.setIngredient('S', Material.STRING);
|
||||
saddleRecipe.setIngredient('I', Material.IRON_INGOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package nl.kallestruik.vanillatweaks.tweaks.craftingtweaks;
|
||||
|
||||
import nl.kallestruik.vanillatweaks.core.Tweak;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class CraftableShulkerShell implements Tweak {
|
||||
private JavaPlugin plugin;
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "CraftableShulkerShell";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(JavaPlugin pluginInstance) {
|
||||
this.plugin = pluginInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnRegister() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
NamespacedKey shulkerShellKey = new NamespacedKey(plugin, "shulker_shell");
|
||||
ShapedRecipe shulkerShellRecipe = new ShapedRecipe(shulkerShellKey, new ItemStack(Material.SHULKER_SHELL));
|
||||
shulkerShellRecipe.shape("BBB","F F");
|
||||
shulkerShellRecipe.setIngredient('B', Material.PURPUR_SLAB);
|
||||
shulkerShellRecipe.setIngredient('F', Material.POPPED_CHORUS_FRUIT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package nl.kallestruik.vanillatweaks.tweaks.craftingtweaks;
|
||||
|
||||
import nl.kallestruik.vanillatweaks.core.Tweak;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class CraftableSponge implements Tweak {
|
||||
private JavaPlugin plugin;
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "CraftableSponge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(JavaPlugin pluginInstance) {
|
||||
this.plugin = pluginInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnRegister() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
NamespacedKey spongeKey = new NamespacedKey(plugin, "sponge");
|
||||
ShapedRecipe spongeRecipe = new ShapedRecipe(spongeKey, new ItemStack(Material.SPONGE));
|
||||
spongeRecipe.shape("KKK","KDK","KKK");
|
||||
spongeRecipe.setIngredient('K', Material.KELP);
|
||||
spongeRecipe.setIngredient('D', Material.YELLOW_DYE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package nl.kallestruik.vanillatweaks.tweaks.craftingtweaks;
|
||||
|
||||
import nl.kallestruik.vanillatweaks.core.Tweak;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapelessRecipe;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class IceDecompression implements Tweak {
|
||||
private JavaPlugin plugin;
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "IceDecompression";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(JavaPlugin pluginInstance) {
|
||||
this.plugin = pluginInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnRegister() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Blue Ice -> Packed Ice
|
||||
NamespacedKey packedIceKey = new NamespacedKey(plugin, "packed_ice");
|
||||
ShapelessRecipe packedIceRecipe = new ShapelessRecipe(packedIceKey, new ItemStack(Material.PACKED_ICE, 9));
|
||||
packedIceRecipe.addIngredient(Material.BLUE_ICE);
|
||||
|
||||
// Packed Ice -> Ice
|
||||
NamespacedKey iceKey = new NamespacedKey(plugin, "ice");
|
||||
ShapelessRecipe iceRecipe = new ShapelessRecipe(iceKey, new ItemStack(Material.ICE, 9));
|
||||
iceRecipe.addIngredient(Material.PACKED_ICE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package nl.kallestruik.vanillatweaks.tweaks.craftingtweaks;
|
||||
|
||||
import nl.kallestruik.vanillatweaks.core.Tweak;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class LogsToChests implements Tweak {
|
||||
private JavaPlugin plugin;
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "LogToChests";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(JavaPlugin pluginInstance) {
|
||||
this.plugin = pluginInstance;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnRegister() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
NamespacedKey chestKey = new NamespacedKey(plugin, "chest");
|
||||
ShapedRecipe chestRecipe = new ShapedRecipe(chestKey, new ItemStack(Material.CHEST, 4));
|
||||
chestRecipe.shape("WWW", "W W", "WWW");
|
||||
chestRecipe.setIngredient('W', MaterialGroups.ALL_LOG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package nl.kallestruik.vanillatweaks.tweaks.craftingtweaks;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.RecipeChoice;
|
||||
|
||||
public class MaterialGroups {
|
||||
public static final RecipeChoice ALL_LOG = new RecipeChoice.MaterialChoice(
|
||||
Material.OAK_LOG,
|
||||
Material.STRIPPED_OAK_LOG,
|
||||
Material.OAK_WOOD,
|
||||
Material.BIRCH_LOG,
|
||||
Material.STRIPPED_BIRCH_LOG,
|
||||
Material.BIRCH_WOOD,
|
||||
Material.SPRUCE_LOG,
|
||||
Material.STRIPPED_SPRUCE_LOG,
|
||||
Material.SPRUCE_WOOD,
|
||||
Material.JUNGLE_LOG,
|
||||
Material.STRIPPED_JUNGLE_LOG,
|
||||
Material.JUNGLE_WOOD,
|
||||
Material.ACACIA_LOG,
|
||||
Material.STRIPPED_ACACIA_LOG,
|
||||
Material.ACACIA_WOOD,
|
||||
Material.DARK_OAK_LOG,
|
||||
Material.STRIPPED_DARK_OAK_LOG,
|
||||
Material.DARK_OAK_WOOD,
|
||||
Material.CRIMSON_HYPHAE,
|
||||
Material.STRIPPED_CRIMSON_HYPHAE,
|
||||
Material.WARPED_HYPHAE,
|
||||
Material.STRIPPED_WARPED_HYPHAE);
|
||||
public static final RecipeChoice ALL_WOOL = new RecipeChoice.MaterialChoice(
|
||||
Material.WHITE_WOOL,
|
||||
Material.BLACK_WOOL,
|
||||
Material.BLUE_WOOL,
|
||||
Material.BROWN_WOOL,
|
||||
Material.CYAN_WOOL,
|
||||
Material.GRAY_WOOL,
|
||||
Material.GREEN_WOOL,
|
||||
Material.LIGHT_BLUE_WOOL,
|
||||
Material.LIGHT_GRAY_WOOL,
|
||||
Material.LIME_WOOL,
|
||||
Material.MAGENTA_WOOL,
|
||||
Material.ORANGE_WOOL,
|
||||
Material.PINK_WOOL,
|
||||
Material.PURPLE_WOOL,
|
||||
Material.RED_WOOL,
|
||||
Material.YELLOW_WOOL);
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package nl.kallestruik.vanillatweaks.tweaks.craftingtweaks;
|
||||
|
||||
import nl.kallestruik.vanillatweaks.core.Tweak;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapelessRecipe;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class WoolToString implements Tweak {
|
||||
private JavaPlugin plugin;
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "WoolToString";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(JavaPlugin pluginInstance) {
|
||||
this.plugin = pluginInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnRegister() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
NamespacedKey stringKey = new NamespacedKey(plugin, "string");
|
||||
ShapelessRecipe stringRecipe = new ShapelessRecipe(stringKey, new ItemStack(Material.STRING, 4));
|
||||
stringRecipe.addIngredient(MaterialGroups.ALL_WOOL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package nl.kallestruik.vanillatweaks.tweaks.croptweaks;
|
||||
|
||||
import nl.kallestruik.vanillatweaks.core.Tweak;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class MobsCantTrampleCrops implements Tweak, Listener {
|
||||
private JavaPlugin plugin;
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "MobsCantTrampleCrops";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(JavaPlugin pluginInstance) {
|
||||
this.plugin = pluginInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnRegister() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(EntityChangeBlockEvent event) {
|
||||
if (event.getBlock().getType() != Material.FARMLAND)
|
||||
return;
|
||||
|
||||
if (event.getEntity() instanceof Player)
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
package nl.kallestruik.vanillatweaks.tweaks.croptweaks;
|
||||
|
||||
import nl.kallestruik.vanillatweaks.util.Util;
|
||||
import nl.kallestruik.vanillatweaks.c;
|
||||
import nl.kallestruik.vanillatweaks.core.Tweak;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayersCantTrampleCrops implements Tweak, Listener {
|
||||
private JavaPlugin plugin;
|
||||
public static HashSet<UUID> trampleEnabled = new HashSet<>();
|
||||
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "PlayersCantTrampleCrops";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(JavaPlugin pluginInstance) {
|
||||
this.plugin = pluginInstance;
|
||||
try {
|
||||
loadTrampleEnabled(new File(this.plugin.getDataFolder(), c.TRAMPLE_ENABLED_FILE_NAME));
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnRegister() {
|
||||
try {
|
||||
saveTrampleEnabled(new File(this.plugin.getDataFolder(), c.TRAMPLE_ENABLED_FILE_NAME));
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
Util.printException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(EntityChangeBlockEvent event) {
|
||||
if (event.getBlock().getType() != Material.FARMLAND)
|
||||
return;
|
||||
|
||||
if (!(event.getEntity() instanceof Player))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
private void loadTrampleEnabled(File file) throws IOException, InvalidConfigurationException {
|
||||
file.getParentFile().mkdirs();
|
||||
file.createNewFile();
|
||||
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
config.load(file);
|
||||
|
||||
for (String item : config.getStringList("enabled"))
|
||||
trampleEnabled.add(UUID.fromString(item));
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
private void saveTrampleEnabled(File file) throws IOException, InvalidConfigurationException {
|
||||
file.getParentFile().mkdirs();
|
||||
file.createNewFile();
|
||||
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
config.load(file);
|
||||
|
||||
List<String> list = new ArrayList<>();
|
||||
for (UUID entry : trampleEnabled)
|
||||
list.add(entry.toString());
|
||||
|
||||
config.set("enabled", list);
|
||||
|
||||
config.save(file);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package nl.kallestruik.vanillatweaks.tweaks.dispensertweaks;
|
||||
|
||||
import nl.kallestruik.vanillatweaks.core.Tweak;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.Dispenser;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockDispenseEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DispensersCanPlantSaplings implements Tweak, Listener {
|
||||
private JavaPlugin plugin;
|
||||
private static List<Material> saplings = new ArrayList<>();
|
||||
private static List<Material> treePlantable = new ArrayList<>();
|
||||
|
||||
public DispensersCanPlantSaplings() {
|
||||
saplings.add(Material.OAK_SAPLING);
|
||||
saplings.add(Material.BIRCH_SAPLING);
|
||||
saplings.add(Material.JUNGLE_SAPLING);
|
||||
saplings.add(Material.SPRUCE_SAPLING);
|
||||
saplings.add(Material.DARK_OAK_SAPLING);
|
||||
saplings.add(Material.ACACIA_SAPLING);
|
||||
|
||||
treePlantable.add(Material.DIRT);
|
||||
treePlantable.add(Material.GRASS_BLOCK);
|
||||
treePlantable.add(Material.COARSE_DIRT);
|
||||
treePlantable.add(Material.PODZOL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "DispensersCanPlantSaplings";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(JavaPlugin pluginInstance) {
|
||||
this.plugin = pluginInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnRegister() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
HandlerList.unregisterAll(this);
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDispenserDispense(BlockDispenseEvent event) {
|
||||
if (event.getBlock().getType() != Material.DISPENSER)
|
||||
return;
|
||||
|
||||
if (saplings.contains(event.getItem().getType())) {
|
||||
Dispenser dispenser = ((Dispenser) event.getBlock().getBlockData());
|
||||
BlockFace facing = dispenser.getFacing();
|
||||
Block targetBlock;
|
||||
if (facing == BlockFace.UP) {
|
||||
targetBlock = event.getBlock().getWorld().getBlockAt(event.getBlock().getLocation().add(0, 2, 0));
|
||||
} else {
|
||||
targetBlock = event.getBlock().getWorld().getBlockAt(event.getBlock().getLocation().add(facing.getModX(), facing.getModY(), facing.getModZ()));
|
||||
}
|
||||
if (targetBlock.getType() == Material.AIR
|
||||
&& treePlantable.contains(event.getBlock().getWorld().getBlockAt(targetBlock.getLocation().add(0, -1, 0)).getType())) {
|
||||
targetBlock.setType(event.getItem().getType());
|
||||
|
||||
event.setCancelled(true);
|
||||
Inventory dispenserInventory = ((org.bukkit.block.Dispenser) event.getBlock().getState()).getInventory();
|
||||
int slot = 0;
|
||||
for (ItemStack is : dispenserInventory.getContents()) {
|
||||
if (is != null && is.getType() == event.getItem().getType())
|
||||
break;
|
||||
slot++;
|
||||
}
|
||||
ItemStack newItemStack = dispenserInventory.getItem(slot);
|
||||
newItemStack.setAmount(newItemStack.getAmount() - 1);
|
||||
dispenserInventory.setItem(slot, newItemStack);
|
||||
|
||||
event.getBlock().getWorld().spawnParticle(Particle.VILLAGER_HAPPY, targetBlock.getLocation(), 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +1,44 @@
|
|||
package nl.kallestruik.vanillatweaks.ArmorStandSwapping;
|
||||
package nl.kallestruik.vanillatweaks.tweaks.miscellaneoustweaks;
|
||||
|
||||
import nl.kallestruik.vanillatweaks.core.Tweak;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class ArmorStandSwappingHandler implements Listener {
|
||||
public class ArmorStandArmorSwapping implements Tweak, Listener {
|
||||
private JavaPlugin plugin;
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "ArmorSwapping";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(JavaPlugin pluginInstance) {
|
||||
this.plugin = pluginInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnRegister() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClickEntity(PlayerInteractAtEntityEvent event) {
|
|
@ -1,16 +1,44 @@
|
|||
package nl.kallestruik.vanillatweaks.HoeHarvesting;
|
||||
package nl.kallestruik.vanillatweaks.tweaks.miscellaneoustweaks;
|
||||
|
||||
import nl.kallestruik.vanillatweaks.config;
|
||||
import nl.kallestruik.vanillatweaks.core.Tweak;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.Ageable;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class HoeHarvestingHandler implements Listener {
|
||||
public class HoesHarvestArea implements Tweak, Listener {
|
||||
private JavaPlugin plugin;
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "HoesHarvestArea";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(JavaPlugin pluginInstance) {
|
||||
this.plugin = pluginInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnRegister() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHoeBreaksBlock(BlockBreakEvent event) {
|
||||
|
@ -21,15 +49,17 @@ public class HoeHarvestingHandler implements Listener {
|
|||
int range;
|
||||
|
||||
if (itemInHand.getType() == Material.WOODEN_HOE)
|
||||
range = config.HOE_HARVESTING_RANGE_WOOD;
|
||||
range = 1;
|
||||
else if (itemInHand.getType() == Material.STONE_HOE)
|
||||
range = config.HOE_HARVESTING_RANGE_STONE;
|
||||
range = 1;
|
||||
else if (itemInHand.getType() == Material.IRON_HOE)
|
||||
range = config.HOE_HARVESTING_RANGE_IRON;
|
||||
range = 1;
|
||||
else if (itemInHand.getType() == Material.GOLDEN_HOE)
|
||||
range = config.HOE_HARVESTING_RANGE_GOLD;
|
||||
range = 1;
|
||||
else if (itemInHand.getType() == Material.DIAMOND_HOE)
|
||||
range = config.HOE_HARVESTING_RANGE_DIAMOND;
|
||||
range = 2;
|
||||
else if (itemInHand.getType() == Material.NETHERITE_HOE)
|
||||
range = 2;
|
||||
else
|
||||
return;
|
||||
|
|
@ -1,17 +1,46 @@
|
|||
package nl.kallestruik.vanillatweaks.LilypadGrowing;
|
||||
package nl.kallestruik.vanillatweaks.tweaks.miscellaneoustweaks;
|
||||
|
||||
import nl.kallestruik.vanillatweaks.util;
|
||||
import nl.kallestruik.vanillatweaks.util.Util;
|
||||
import nl.kallestruik.vanillatweaks.core.Tweak;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class LilypadGrowingHandler implements Listener {
|
||||
public class LilypadBonemealing implements Tweak, Listener {
|
||||
private JavaPlugin plugin;
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "LilypadBonemealing";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(JavaPlugin pluginInstance) {
|
||||
this.plugin = pluginInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnRegister() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRightClickBlock(PlayerInteractEvent event) {
|
||||
|
@ -35,7 +64,7 @@ public class LilypadGrowingHandler implements Listener {
|
|||
World world = event.getClickedBlock().getWorld();
|
||||
Location origin = event.getClickedBlock().getLocation();
|
||||
for (int i = 0; i <= 5; i++) {
|
||||
Location newPos = origin.clone().add(util.getRandomLocationOffset(0, 3, false));
|
||||
Location newPos = origin.clone().add(Util.getRandomLocationOffset(0, 3, false));
|
||||
Block newBlock = world.getBlockAt(newPos);
|
||||
if (newBlock.getType() != Material.AIR)
|
||||
continue;
|
|
@ -1,16 +1,36 @@
|
|||
package nl.kallestruik.vanillatweaks.SeedDropPlanting;
|
||||
package nl.kallestruik.vanillatweaks.tweaks.miscellaneoustweaks;
|
||||
|
||||
import nl.kallestruik.vanillatweaks.core.Tweak;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
|
||||
public class SeedDropPlanting {
|
||||
public class SeedDropPlanting implements Tweak {
|
||||
private JavaPlugin plugin;
|
||||
private BukkitTask task = null;
|
||||
|
||||
public static void init(JavaPlugin plugin) {
|
||||
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "SeedDropPlanting";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(JavaPlugin pluginInstance) {
|
||||
this.plugin = pluginInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnRegister() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
task = Bukkit.getScheduler().runTaskTimer(plugin, () -> {
|
||||
for (World world : plugin.getServer().getWorlds()) {
|
||||
for (Entity entity : world.getEntities()) {
|
||||
if (entity instanceof Item) {
|
||||
|
@ -46,6 +66,14 @@ public class SeedDropPlanting {
|
|||
}, 20 * 10, 20 * 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (task == null)
|
||||
return;
|
||||
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
private static void plantSeed(Item entity, World world, Block block, Material material) {
|
||||
block.setType(material);
|
||||
world.spawnParticle(Particle.VILLAGER_HAPPY, entity.getLocation(), 10);
|
|
@ -0,0 +1,50 @@
|
|||
package nl.kallestruik.vanillatweaks.tweaks.miscellaneoustweaks;
|
||||
|
||||
import nl.kallestruik.vanillatweaks.core.Tweak;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class SpongesDryInNether implements Tweak, Listener {
|
||||
private JavaPlugin plugin;
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "SpongesDryInNether";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegister(JavaPlugin pluginInstance) {
|
||||
this.plugin = pluginInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnRegister() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package nl.kallestruik.vanillatweaks;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Random;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public class util {
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
public static void printException(Exception e) {
|
||||
System.err.println("-------------------------------------------------------------------------------------");
|
||||
System.err.println("An error seems to have occurred. A detailed stacktrace of the error is printed below.");
|
||||
System.err.println("-------------------------------------------------------------------------------------");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
public static void ExportResource(String resourceName, File 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.");
|
||||
}
|
||||
|
||||
int readBytes;
|
||||
byte[] buffer = new byte[4096];
|
||||
while ((readBytes = stream.read(buffer)) > 0) {
|
||||
resStreamOut.write(buffer, 0, readBytes);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
util.printException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector getRandomLocationOffset(int min, int max, boolean height) {
|
||||
Vector vec;
|
||||
if (height)
|
||||
vec = new Vector(min + random.nextInt(max - min), min + random.nextInt(max - min), min + random.nextInt(max - min));
|
||||
else
|
||||
vec = new Vector(min + random.nextInt(max - min), 0, min + random.nextInt(max - min));
|
||||
|
||||
vec.multiply(new Vector(random.nextBoolean() ? -1 : 1, random.nextBoolean() ? -1 : 1, random.nextBoolean() ? -1 : 1));
|
||||
return vec;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package nl.kallestruik.vanillatweaks.util;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Random;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public class Util {
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
/**
|
||||
* Print an obvious header above the stack trace so it is easier to spot.
|
||||
* @param e The {@link Exception} to print the stacktrace of.
|
||||
*/
|
||||
public static void printException(Exception e) {
|
||||
// Print the header.
|
||||
System.err.println("-------------------------------------------------------------------------------------");
|
||||
System.err.println("An error seems to have occurred. A detailed stacktrace of the error is printed below.");
|
||||
System.err.println("-------------------------------------------------------------------------------------");
|
||||
// Let the exception print its stacktrace.
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
/**
|
||||
* Export a resource from inside the jar to an outside directory.
|
||||
* @param resourceName The file name inside the jar.
|
||||
* @param output The {@link File} to write the resource to.
|
||||
*/
|
||||
public static void exportResource(String resourceName, File output) {
|
||||
// Try to create an input stream from the resource inside the jar and an output stream for the target file.
|
||||
try (InputStream inputStream = Util.class.getResourceAsStream("/" + resourceName); OutputStream resStreamOut = new FileOutputStream(output)) {
|
||||
// Make sure the input stream exists.
|
||||
if (inputStream == null) {
|
||||
throw new Exception("Cannot get resource \"" + resourceName + "\" from Jar file.");
|
||||
}
|
||||
|
||||
// Read the input stream and write it to a file.
|
||||
int readBytes;
|
||||
byte[] buffer = new byte[4096];
|
||||
while ((readBytes = inputStream.read(buffer)) > 0) {
|
||||
resStreamOut.write(buffer, 0, readBytes);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Util.printException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a random vector with integer offsets within the min and max.
|
||||
* @param min The minimum offset.
|
||||
* @param max The maximum offset.
|
||||
* @param height Whether the height should also have a random offset.
|
||||
* @return A {@link Vector} containing the offsets.
|
||||
*/
|
||||
public static Vector getRandomLocationOffset(int min, int max, boolean height) {
|
||||
Vector vec;
|
||||
// Create the vectors with all positive numbers.
|
||||
if (height) {
|
||||
vec = new Vector(
|
||||
min + random.nextInt(max - min),
|
||||
min + random.nextInt(max - min),
|
||||
min + random.nextInt(max - min));
|
||||
} else {
|
||||
vec = new Vector(
|
||||
min + random.nextInt(max - min),
|
||||
0,
|
||||
min + random.nextInt(max - min));
|
||||
}
|
||||
|
||||
// Randomly make some of the components negative instead of positive.
|
||||
vec.multiply(new Vector(
|
||||
random.nextBoolean() ? -1 : 1,
|
||||
random.nextBoolean() ? -1 : 1,
|
||||
random.nextBoolean() ? -1 : 1));
|
||||
|
||||
// Return the completed vector.
|
||||
return vec;
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
toggle-trample:
|
||||
enabled: true
|
||||
|
||||
crafting-tweaks:
|
||||
enabled: true
|
||||
better-chest: true
|
||||
name-tag: true
|
||||
wool-to-string: true
|
||||
saddle: true
|
||||
packed-ice: true
|
||||
ice: true
|
||||
dragons-breath: true
|
||||
sponge: true
|
||||
dispenser: true
|
||||
shulker-shell: true
|
||||
|
||||
seed-drop-planting:
|
||||
enabled: true
|
||||
|
||||
armor-stand-swapping:
|
||||
enabled: true
|
||||
|
||||
nether-sponge-drying:
|
||||
enabled: true
|
||||
|
||||
hoe-harvesting:
|
||||
enabled: true
|
||||
ranges:
|
||||
wood: 1
|
||||
stone: 1
|
||||
iron: 1
|
||||
gold: 1
|
||||
diamond: 2
|
||||
|
||||
lilypad-growing:
|
||||
enabled: true
|
|
@ -1,6 +1,7 @@
|
|||
name: VanillaTweaks
|
||||
version: @version@
|
||||
main: nl.kallestruik.vanillatweaks.VanillaTweaks
|
||||
api-version: 1.13
|
||||
api-version: 1.16
|
||||
commands:
|
||||
toggletrample:
|
||||
player:
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
CraftableNametag: true
|
||||
CraftableSaddle: true
|
||||
AlternativeDispenserRecipe: true
|
||||
DispensersCanPlantSaplings: true
|
||||
CraftableShulkerShell: true
|
||||
IceDecompression: true
|
||||
LogToChests: true
|
||||
CraftableSponge: true
|
||||
PlayersCantTrampleCrops: true
|
||||
WoolToString: true
|
||||
LilypadBonemealing: true
|
||||
SeedDropPlanting: true
|
||||
MobsCantTrampleCrops: true
|
||||
CraftableDragonsBreath: true
|
||||
ArmorSwapping: true
|
||||
HoesHarvestArea: true
|
Reference in New Issue