Hey everyone, I have a really urgent request -- Limiting the fortune enchantment. I'm not entirely sure how the game calculates how many extra drops per block depending on level, but I'd like to cut that in about half. A config where I can change some options is preferred. When I'd like it by: Tomorrow :O Sorry for the unspecific request but I really do need this urgently. Thanks!
why not limit the amount of bookshelves around the enchantment table? it would limit all enchantments but should work till you code/find a permanent solution?
People already have the picks. -_- For example, someone just got 88 lapis from a vein of 6. This is why the request is urgent. -_- :3 With that being said... WarmakerT Woobiesharp237 calebbfmv Omnitv MrBluebear3 -_Husky_- Sushi EDIT by Moderator: merged posts, please use the edit button instead of double posting.
I can think of a way to do it... You would have to do something like onBlockBreak you could either... Check the picks enchantment level and change it Get the drops and if there is more than 'x' and the pick is enchanted with fortune then remove half of them
Hmm... I may have to try that tomorrow. But it's 1:45AM here, so I'd better go to... *me falls asleep*
on block break event check if the itemin hand has enchantment fortune and set the amount of drops to whatever you want ? :3
Sure, I'll help! =) //EDIT - You doing this? If you are, just Code: if(!e.isCancelled()) { //continue here } Worldguard will simply cancel the event, so you don't need to hook into it (So will any protection plugin)
Code:java import java.util.Map; import org.bukkit.enchantments.Enchantment;import org.bukkit.entity.Entity;import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.block.BlockBreakEvent;import org.bukkit.event.enchantment.EnchantItemEvent;import org.bukkit.event.entity.EntityDamageByEntityEvent;import org.bukkit.plugin.java.JavaPlugin; public class Default extends JavaPlugin implements Listener{Enchantment[] es = {Enchantment.LOOT_BONUS_BLOCKS,Enchantment.LOOT_BONUS_BLOCKS};public void onEnable(){this.getServer().getPluginManager().registerEvents(this, this);}@EventHandlerpublic void onBlockBreak(BlockBreakEvent e){Player p =e.getPlayer();Map<Enchantment, Integer> ec=p.getItemInHand().getEnchantments();for(Enchantment ecs:es){if(ec.containsKey(ecs)){p.getItemInHand().removeEnchantment(ecs);}}}@EventHandlerpublic void onEntityDamage(EntityDamageByEntityEvent e){Entity eb =e.getDamager();if(eb instanceof Player){Player p = (Player) eb;Map<Enchantment, Integer> ec=p.getItemInHand().getEnchantments();for(Enchantment ecs:es){if(ec.containsKey(ecs)){p.getItemInHand().removeEnchantment(ecs);}}}} //OR @EventHandlerpublic void onEnchant(EnchantItemEvent e){Map<Enchantment, Integer> ec=e.getEnchantsToAdd();if(ec.containsKey(Enchantment.LOOT_BONUS_MOBS)){//Limit level of enchantmentint lvl = ec.get(Enchantment.LOOT_BONUS_MOBS);if(lvl>5)lvl=5;/** OR*/}else if(ec.containsKey(Enchantment.LOOT_BONUS_BLOCKS)){//Remove enchantmentec.remove(Enchantment.LOOT_BONUS_BLOCKS); }}} Sorry np98765 I'll make you edit it to what you want it to do exactly.
No I'm not doing this xP so many ppl offered to help. One more would only be a bother. I was actually doing another request "Change gamemode to survival on a wg region". Aparently the implemented one wasn't workign so well lol My problem was checking if the player was inside the region but After a loong time searching XD I managed to understand how it works :3 Thank you anyways :3
I tried that contains and only vectors and locations show up :3 So I'm guessing you're derping xD I used a check on players location. If he can build tehre do this if not do that
Whats up with all this being nosy in other people's requests? Isnt this like the 5th from you this week? Woobie
3rd one this week* My server has gotten a bit busier than normal, and I've discovered some problems with excessive item gains -- Cocoa beans and everything with Fortune picks. I've also gotten so much busier, so I can't work on much of anything. The StaffChat addition one is still needed. :| Oh, and I'll probably be posting another one today. It regards chat.
StaffChat? I shall do that, AND this one for you, sometime this week. LIKE I SAID, today is my day off (date day) so me and my girl are going to hang out and go have lunch, then go to the mall. So, whenever I get the time this week, I shall make these plugins for you.
I just coded this: There are 2 variables you can change, "uses" and "plus". Every time you mine a block it will cumulatively add the "plus" variable. If you mine a block and this comulative number is greater than or equal to the "uses" variable then the fortune enchantment will not take effect on the block break and the 'cumulative number' is reset. Code: package me.sharp237.fortunecontrol; import java.util.HashMap; import java.util.logging.Logger; import org.bukkit.Bukkit; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; public class FortuneControl extends JavaPlugin implements Listener { public static HashMap<String, Double> Loot = new HashMap<String, Double>(); public static HashMap<String, Double> Loot2 = new HashMap<String, Double>(); public final Logger logger = Logger.getLogger("Minecraft"); //Plus public double plus = 1; //Uses public double uses = 2; public void onDisable() { PluginDescriptionFile pdfFile = getDescription(); this.logger.info(pdfFile.getName() + " Has Been Disabled"); } public void onEnable() { PluginDescriptionFile pdfFile = getDescription(); this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " Has Been Enabled"); getServer().getPluginManager().registerEvents(this, this); } @EventHandler public void onBlockBreak(BlockBreakEvent event){ final Player player = event.getPlayer(); int check; check = 0; if(player.getItemInHand().containsEnchantment(Enchantment.LOOT_BONUS_BLOCKS) && check == 0){ if(!Loot.containsKey(player.getName())){ Loot.put(player.getName(), plus); check = 1; } if(Loot.containsKey(player.getName()) && check == 0){ double num = Loot.get(player.getName()); double added = num + plus; if(added != uses){ Loot2.put(player.getName(), added); Loot.remove(player.getName()); Loot.put(player.getName(), Loot2.get(player.getName())); Loot2.remove(player.getName()); } if(added >= uses){ int level = player.getItemInHand().getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS); if(level == 1){ player.getItemInHand().removeEnchantment(Enchantment.LOOT_BONUS_BLOCKS); Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { @Override public void run() { player.getItemInHand().addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 1); } }); } if(level == 2){ player.getItemInHand().removeEnchantment(Enchantment.LOOT_BONUS_BLOCKS); Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { @Override public void run() { player.getItemInHand().addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 2); } }); } if(level == 3){ player.getItemInHand().removeEnchantment(Enchantment.LOOT_BONUS_BLOCKS); Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { @Override public void run() { player.getItemInHand().addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3); } }); } Loot.remove(player.getName()); } check = 1; } } } } Edit: Do I need to make a dev page for this?
Please do. I remember at least one other request for this. (If not, I can quickly whip one up when I get home if you'd like.)
WHY DID YOU STEAL MY THUNDER?!?!?!?! Eh, staff chat is mine, I claim it! Just tell me what it needs to do.
Ok, so I tested the plugin pretty thoroughly. It works amazingly, sharp237 -- Very creative way of doing it. I've created a Dev page for it, which can be found here. If you'd like to see the results of the latest quick test, I made a quick table on the page. Sharp: I changed the name/used my domain, edited the onEnable/onDisable, and made the code good for my eyes. You can decompile it or I'll send/post the source if you'd like. ^_^ Is the GPL(v3) license is fine?
Wow, thanks Yea I tried to do your request and then I realised that 'getDrop()' doesn't work for Fortune So it became a sort of personal challenge to find a way of doing this, lol. I don't really mind how you change the code, make it whatever you want. Oh, and I also don't care what the license is, its not like I made the next version of Microsoft Word .