Implemented mechanics
This commit is contained in:
parent
5510a73c20
commit
220c7c7ff7
@ -14,7 +14,7 @@ public class Death {
|
|||||||
* @param drops the dropping items
|
* @param drops the dropping items
|
||||||
* @param plugin plugin reference
|
* @param plugin plugin reference
|
||||||
*/
|
*/
|
||||||
public void onAnimalDeath(int[] amount, Material[] drops, main plugin, EntityDeathEvent event){
|
public static void onAnimalDeath(int[] amount, Material[] drops, main plugin, EntityDeathEvent event){
|
||||||
|
|
||||||
// Random Drop amount generation DO NOT TOUCH!!!!
|
// Random Drop amount generation DO NOT TOUCH!!!!
|
||||||
int i1_amnt = ThreadLocalRandom.current().nextInt(1, amount[0] + 1);
|
int i1_amnt = ThreadLocalRandom.current().nextInt(1, amount[0] + 1);
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package de.steev.bm.events;
|
package de.steev.bm.events;
|
||||||
|
|
||||||
|
import de.steev.bm.changes.interaction.replanting;
|
||||||
import de.steev.bm.main;
|
import de.steev.bm.main;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -16,12 +18,6 @@ public class InteractEvent implements Listener {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Carrot: Carrot 3
|
|
||||||
* Potato: potato 2
|
|
||||||
* Wheat: 2 Wheat, 2 Wheat Seeds
|
|
||||||
* Beetroots: 1 Beetroot, 3 Beetroot seeds
|
|
||||||
*/
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent event){
|
public void onPlayerInteract(PlayerInteractEvent event){
|
||||||
if(event.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
|
if(event.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
|
||||||
@ -30,17 +26,30 @@ public class InteractEvent implements Listener {
|
|||||||
Block target = event.getClickedBlock();
|
Block target = event.getClickedBlock();
|
||||||
/** the location of the clicked block */
|
/** the location of the clicked block */
|
||||||
Location loc = target.getLocation().clone().add(0.5, 0.5, 0.5);
|
Location loc = target.getLocation().clone().add(0.5, 0.5, 0.5);
|
||||||
|
Material[] drops;
|
||||||
|
int[] amounts;
|
||||||
// Detects which type to replant
|
// Detects which type to replant
|
||||||
// TODO: do the replant implementation
|
|
||||||
switch(target.getType().toString()){
|
switch(target.getType().toString()){
|
||||||
case "CARROT":
|
case "CARROTS":
|
||||||
|
/** Droping items */
|
||||||
|
drops = new Material[] { Material.CARROT };
|
||||||
|
amounts = new int[] {3};
|
||||||
|
replanting.planting(drops, amounts, target);
|
||||||
break;
|
break;
|
||||||
case "POTATO":
|
case "POTATOES":
|
||||||
|
drops = new Material[] { Material.POTATO };
|
||||||
|
amounts = new int[] {2};
|
||||||
|
replanting.planting(drops, amounts, target);
|
||||||
break;
|
break;
|
||||||
case "WHEAT":
|
case "WHEAT":
|
||||||
|
drops = new Material[] { Material.WHEAT, Material.WHEAT_SEEDS };
|
||||||
|
amounts = new int[] {1,2};
|
||||||
|
replanting.planting(drops, amounts, target);
|
||||||
break;
|
break;
|
||||||
case "BEETROOT":
|
case "BEETROOTS":
|
||||||
|
drops = new Material[] { Material.BEETROOT, Material.BEETROOT_SEEDS };
|
||||||
|
amounts = new int[] {1,2};
|
||||||
|
replanting.planting(drops, amounts, target);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package de.steev.bm.events;
|
package de.steev.bm.events;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -10,9 +9,9 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import de.steev.bm.main;
|
import de.steev.bm.main;
|
||||||
|
import de.steev.bm.changes.interaction.Death;
|
||||||
|
|
||||||
public class KillEvent implements Listener{
|
public class KillEvent implements Listener{
|
||||||
private main plugin;
|
private main plugin;
|
||||||
@ -28,6 +27,9 @@ public class KillEvent implements Listener{
|
|||||||
*/
|
*/
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityDeath(EntityDeathEvent event) {
|
public void onEntityDeath(EntityDeathEvent event) {
|
||||||
|
int[] amounts;
|
||||||
|
Material[] drops;
|
||||||
|
|
||||||
if(event.getEntity() instanceof Player){
|
if(event.getEntity() instanceof Player){
|
||||||
Location death = ((Player) event.getEntity()).getPlayer().getLocation();
|
Location death = ((Player) event.getEntity()).getPlayer().getLocation();
|
||||||
UUID uuid = ((Player) event.getEntity()).getPlayer().getUniqueId();
|
UUID uuid = ((Player) event.getEntity()).getPlayer().getUniqueId();
|
||||||
@ -36,8 +38,9 @@ public class KillEvent implements Listener{
|
|||||||
|
|
||||||
|
|
||||||
if(event.getEntity().toString() == "CraftPig"){
|
if(event.getEntity().toString() == "CraftPig"){
|
||||||
// leather: 2, porkchop: 2
|
amounts = new int[]{ 2,2 };
|
||||||
// TODO: do the implementation
|
drops = new Material[]{Material.LEATHER, Material.PORKCHOP};
|
||||||
|
Death.onAnimalDeath(amounts, drops, plugin, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ public class main extends JavaPlugin implements Listener {
|
|||||||
playerDataConfig.save(playerdata);
|
playerDataConfig.save(playerdata);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
this.getLogger().warning("Unable to save " + playerdatafilename); // shouldn't really happen, but save
|
this.getLogger().warning("Unable to save " + playerdatafilename); // shouldn't really happen, but save
|
||||||
// throws the exception
|
// throws the exception
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user