added build automization

This commit is contained in:
2023-10-03 18:35:35 +02:00
parent e8252d1a60
commit f0c2ce71c7
11 changed files with 405 additions and 400 deletions

View File

@ -0,0 +1,22 @@
package de.steev.bm.changes.env;
import org.bukkit.World;
public class weather {
static long lastThunder = 0;
long delay = 24000;
private static boolean isThunder(World world) {
return world.getThunderDuration() > 0;
}
public static void changeWeather(World world) {
if(isThunder(world)) {
if(lastThunder + 24000 > world.getFullTime()) {
world.setClearWeatherDuration(1000);
}else {
lastThunder = world.getFullTime();
}
}
}
}

View File

@ -0,0 +1,30 @@
package de.steev.bm.changes.interaction;
import de.steev.bm.main;
import org.bukkit.Material;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.inventory.ItemStack;
import java.util.concurrent.ThreadLocalRandom;
public class Death {
/**
* handles animal loot drops only works as array
* @param amount the drop amount
* @param drops the dropping items
* @param plugin plugin reference
*/
public static void onAnimalDeath(int[] amount, Material[] drops, main plugin, EntityDeathEvent event){
// Random Drop amount generation DO NOT TOUCH!!!!
int i1_amnt = ThreadLocalRandom.current().nextInt(1, amount[0] + 1);
int i2_amnt = ThreadLocalRandom.current().nextInt(1, amount[1] + 1);
// Clears Vanilla drops
event.getDrops().clear();
// Drops specified amount of the specified items
for(int i = 0; i < i1_amnt; i++) { event.getEntity().getLocation().getWorld().dropItem(event.getEntity().getLocation(), new ItemStack(drops[0])); }
for(int i = 0; i < i2_amnt; i++) { event.getEntity().getLocation().getWorld().dropItem(event.getEntity().getLocation(), new ItemStack(drops[1])); }
}
}

View File

@ -0,0 +1,50 @@
package de.steev.bm.changes.interaction;
import de.steev.bm.main;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
public class Item_Recipy_Override {
main plugin;
NamespacedKey item;
static ShapedRecipe rec_item;
/**
* Overrides vanilla recipes
* @param plugin Plugin Reference
* @param Item Item name
* @param result the dropping item
* @param amount the droprate
*/
public Item_Recipy_Override(main plugin, String Item, Material result, int amount){
this.plugin = plugin;
item = new NamespacedKey(plugin, Item);
ItemStack itemStack = new ItemStack(result);
itemStack.setAmount(amount);
rec_item = new ShapedRecipe(item, itemStack);
}
/**
* registers recipe to bukkit recipe handler
* @param ing Ingredience reference
* @param mat material ing will reference
* @param rec the recipe shape
*/
public static void register_recipy(char[] ing, Material[] mat, String[] rec){
//Recipe shapes
rec_item.shape(rec[0], rec[1], rec[2]);
for(int i = 0; i < ing.length; i++) {
// Material Definitions
rec_item.setIngredient(ing[i], mat[i]);
}
// Add recipes to Server
Bukkit.addRecipe(rec_item);
}
}

View File

@ -0,0 +1,47 @@
package de.steev.bm.changes.interaction;
import de.steev.bm.main;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.Ageable;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
public class replanting {
private main plugin;
/**
* event constructor
* @param plugin plugin instance
*/
public replanting(main plugin) {
plugin.getLogger().info("replanting handler Registered");
this.plugin = plugin;
}
/**
* simplified function for handling replanting works only with arrays
* @param item the material of each drop
* @param amount the drop amount of each item
*/
public static void planting(Material[] item, int[] amount, Block target){
Ageable crop = (Ageable) target.getBlockData();
Location loc = target.getLocation().clone().add(0.5, 0.5, 0.5);
// TODO: validate if code may throw errors
if(crop.getAge() == crop.getMaximumAge()){
for(int i = 0; i < amount[0]; i++) {
target.getLocation().getWorld().dropItem(loc, new ItemStack(item[0]));
}
for(int i = 0; i < amount[1]; i++) {
target.getLocation().getWorld().dropItem(loc, new ItemStack(item[1]));
}
crop.setAge(0);
target.setBlockData(crop);
}
}
}