EarthquakeItem

Discussion in 'Plugin Requests' started by kentlivar, Jan 4, 2017.

Thread Status:
Not open for further replies.
  1. Offline

    kentlivar

    Plugin category: Fun

    Minecraft version: 1.11.2

    Suggested name: EarthquakeItem

    What I want: Its like a Portable Earthquake enchantment. its on an axe on slimefun but it breaks so fast, and i would really enjoy just running around with this just having fun. It dosent destroy any of the blocks around
    Picture:
    [​IMG]
    Ideas for commands: /earth enchant (enchants item in hand), /earth reload
    .
    Ideas for permissions: earth.enchant, earth.reload.

    When I'd like it by: as soon as possible.
     
    Last edited: Jan 4, 2017
  2. Offline

    kentlivar

  3. Offline

    ipodtouch0218

    Just put unbreaking on the tool.

    Or make it Unbreakable with an NBT tag.
     
  4. Offline

    kentlivar

    @ipodtouch0218 tried to make it unbreakable it just last a little longer then break.
     
  5. Offline

    ipodtouch0218

    @kentlivar
    That's Unbreaking, not unbreakable.

    Use the NBT tag "Unbreakable." Use google if necessary.
     
  6. Offline

    kentlivar

    is it the one with /unbk if it is thats the one i was trying it does show that the axe lastes life but then boom it just disipar after a little while just last a little longer then usually. and i didnt try /enchant unbreaking (unsafeenchantment number) no i tried an unbreakble plugin with the command as /unbk.
     
  7. Offline

    kentlivar

  8. Offline

    EagleX21

    So, you want a shortcut? You want to type /unbk and then have the item enchanted with Unbreaking X?

    EDIT: You could just do something like this:
    Code:
    if(label.equalsIgnoreCase("unbk")) {
        ItemStack daxe = new ItemStack(Material.DIAMOND_AXE, 1);
        daxe.addEnchantment(Enchantment.DURABILITY, 10);
    }
    
    EDIT: Or if you want to make it unbreakable, you could do it with the NBT tags (as stated above) in a dispatchCommand.
     
    Last edited: Jan 9, 2017
  9. Offline

    kentlivar

    @EagleX21
    no i want this :
    Plugin category: Fun

    Minecraft version: 1.11.2

    Suggested name: EarthquakeItem

    What I want: Its like a Portable Earthquake enchantment. its on an axe on slimefun but it breaks so fast, and i would really enjoy just running around with this just having fun. It dosent destroy any of the blocks around
    Picture:
    [​IMG]
    Ideas for commands: /earth enchant (enchants item in hand), /earth reload
    .
    Ideas for permissions: earth.enchant, earth.reload.

    When I'd like it by: as soon as possible.
    btw please go back up next time you read a post and use your time before replying thanks
     
  10. Offline

    EagleX21

    You want a plugin that already exists?

    EDIT: Oh, never mind. So: you want an axe that makes block get higher and never breaks?
    Do you want it to change blocks on-click or when they're in a specific radius?
     
  11. Offline

    kentlivar

    @EagleX21 on click, and not just an axe you can do /earth enchant (and you enchants the thing you hold in your hand with earthquake basicly)
     
  12. Offline

    EagleX21

    Well, I've made something. I can configure it to use every item but it seems like it's impossible to raise a blocks height to me. We might need to get a more experienced developer to help with that...
    Code:
    package com.gmail.blackeaglex21.earthquakeitem;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Main extends JavaPlugin implements Listener {
      
        @EventHandler
        public void onRightClick(PlayerInteractEvent e) {
            if(e.getPlayer().getItemInHand().equals(Material.DIAMOND_AXE)) {
                if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
                    Block block = e.getClickedBlock();
                    // Looks like it's impossible to raise a block's height to me
                }
            }
        }
      
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
          
            if(label.equalsIgnoreCase("unbk")) {
                if(sender.hasPermission("earth.enchant")) {
                    Bukkit.dispatchCommand(sender, "give " + sender.getName() + " diamondaxe 1 Unbreakable:1");
                } else {
                    sender.sendMessage(ChatColor.RED + "You don't have the permission earth.enchant");
                }
            }
          
          
            return true;
        }
    }
    EDIT: Just saw this is in Plugin Requests. So you probavly have no coding experience... If you don't get the code, please post the parts you don't get and I'll explain them.
     
  13. Offline

    timtower Administrator Administrator Moderator

  14. Offline

    EagleX21

    @timtower Does that make any difference in terms of what I can do? Or is that just because it's a convention or something like that?

    EDIT: Would be something like this then, right? Can't get it to work though...
    Code:
        public void onEnable() {
            getServer().getPluginManager().registerEvents(onRightClick, plugin);
        }
     
    Last edited: Jan 9, 2017
  15. Offline

    timtower Administrator Administrator Moderator

  16. Offline

    EagleX21

    @timtower Yeah, but still, the is no way to change the Y of a block, like this:
    block.setY();
     
  17. Offline

    timtower Administrator Administrator Moderator

    @EagleX21 You can set the type, data, and other stuff to the block above though.
     
  18. Offline

    kentlivar

    i am not a coder i havent taken the time to learn eclipse (basic java coding) and then bukkit events and shit am sorry
     
  19. Offline

    kentlivar

    bump still wants this, but no rush tho
     
  20. Offline

    EagleX21

    @kentlivar Well, I'm trying something new: I am going to place a block of the same type on the old block and then delete the old one. I'll see if I can get it to work...

    EDIT: Yay, there is a containsEnchantment(); I think I can finish this for you. I'll probably have it finished in the weekend, is that ok with you? (I might be able to finish it sooner, but that depends on another project)

    EDIT: Well, I'm pretty far into developing. I have a quick question though: The plugin currently checks if the item has a specific enchantment. Is this enough checking for you, or do you also want me to check for a custom permission, like earth.canuseearthquake?

    Sorry for double posting, but I think it's clearer like this...
    Anybody reading this threat (EDIT: Thread of course, lol) , please help me with this:
    Code:
    package com.gmail.blackeaglex21.earthquakeitem;
    
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    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.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Main extends JavaPlugin implements Listener {
    
        @EventHandler
        public void onRightClick(PlayerInteractEvent e) {
            if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
                ItemStack item = e.getPlayer().getItemInHand();
                if(item.containsEnchantment(Enchantment.DURABILITY) && e.getPlayer().hasPermission("earth.xxx")) {
                    Block block = e.getClickedBlock();
                    Material blockMaterial = block.getType();
                    Location blockLocation = block.getLocation();
                    double blockY = blockLocation.getY();
                    double blockZ = blockLocation.getZ();
                    double blockX = blockLocation.getX();
                    int blockYPlusOne = (int) blockY + 1;
                    int blockZPlusOne = (int) blockZ + 1;
                    int blockXPlusOne = (int) blockX + 1;
    
    
                    e.getPlayer().getWorld().getBlockAt(blockXPlusOne, blockYPlusOne, blockZPlusOne).setType(blockMaterial);
                    e.getPlayer().getWorld().getBlockAt(blockLocation).breakNaturally();
                  
                }
                }
            }
    
            public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    
                Player player = (Player) sender;
    
                if(cmd.getName().equalsIgnoreCase("unbk")) {
                    if(player.hasPermission("earth.enchant")) {
                        player.getItemInHand().addUnsafeEnchantment(Enchantment.DURABILITY, 100);
                    } else {
                        player.sendMessage(ChatColor.RED + "You don't have the permission earth.enchant");
                    }
                }
    
    
                return true;
            }
        }
    
    Why doesn't this work? Something with datatypes? Something in the setType? It doesn't return errors or something like that... It just doesn't work when right-clicking...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jan 11, 2017
  21. Offline

    Sploon

    @EagleX12 - don't forget to register events.
     
  22. Offline

    EagleX21

    @Sploon I should do that inside a onEnable method right? Can you tell me if this will work then?
    Code:
    Bukkit.getPluginManager().registerEvents(this, this);
    EDIT: Never mind! I tested it and it works! Thanks, man. I'm going to convert this to 1.11.2 and then see if my DevBukkit account finally works so I can upload it...

    EDIT: It has been uploaded, @kentlivar, just waiting for approval from DevBukkit and then you can download it. Let me know if there is anything you want me to change! By the way: Permissions are: earth.xxx and earth.unbk
    Commands are: /unbk

    EDIT: It's approved! This is the download link: https://dev.bukkit.org/projects/earthquakeitem
    Again, let me know if there's anything you want me to change, and I'll look into it!

    EDIT: @kentlivar I read your e-mail. Is it just the delting of the blocks that you don't want? Because I can fix that in like 5 seconds. Also, I'll change the plugin.yml then.
     
    Last edited: Jan 13, 2017
Thread Status:
Not open for further replies.

Share This Page