Problems with my RPG plugin - new problem 3. 5. 2015

Discussion in 'Plugin Development' started by bohafr, Apr 29, 2015.

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

    bohafr

    Hello, I am now working on RPG plugin, i think i will have several problems with it, which I can´t solve.

    I will add all problems to one thread (I hope I can do it).
    I am using Bukkit 1.7.9 R0.2, also Craftbukkit 1.7.9 R0.2, server running Spigot 1.7.9 (I dont know more specificly version)

    My problems:
    How to set player max food level? Can I do it? With some packets or anything? - maybe solved, thanks to Konato_K
    How to able player can sprint without hunger bar? solved, thanks to Konato_K
    Set text over levels?

    How get if headshot? (EntityDamageByEntityEvent)
    this doesn´t work:
    Code:
            
    boolean headshot = false;
            double arrowLoc = ((Arrow)e.getDamager()).getLocation().getY();
            double entityLoc = ((LivingEntity)e.getEntity()).getEyeLocation().getY();
         
            if ((entityLoc-arrowLoc) <= 0.015){
                System.out.println("headshot?");
            }
    
    Can I hit someone in code? Is there any packet for hit, that I can send to player?

    Thanks!
     
    Last edited: May 3, 2015
  2. Offline

    LetsTalkTnTHere

    @bohafr so if I'm right; you wan't it so that if I would set the maximum foodlevel to 10(half food bar), the player can't have more than that, not by eating nor respawning?
     
  3. Offline

    bohafr

    Yes, but i dont want to have less max food level, but more food level for example i want to player can have 25 Food levels
     
  4. Offline

    Konato_K

    @bohafr You can't change food.

    And you can't make them sprint with 6 or less hunger (this is client side as far I know unless someone can prove me wrong).
     
  5. Offline

    Creeperzombi3

    This is if you want them to sprint without losing Hunger.
    The first part is a command if you want it.
    The second part is sprinting without losing hunger.

    Code:
        public boolean onCommand(CommandSender sender, Command command,
                String commandLabel, String[] args) {
            Player player = (Player) sender;
            if (commandLabel.equalsIgnoreCase("feed")) {
                player.setFoodLevel(20);
            }
            return false;
        }
       
        @EventHandler
        public void onPlayerMove(PlayerMoveEvent event) {
            Player player = event.getPlayer();
            if(player.hasPermission("PluginName.feed")) {
                player.setFoodLevel(20);
            }
        }
    
     
  6. Offline

    bohafr

    @Konato_K I thought it, but i hoped I can do it.. Thanks

    @Creeperzombi3 In my RPG plugin will be mana, mana will be instead hunger.. I don´t want to player have 20 food level (20 mana for all time)..

    New question: Can I set text over level? When player changing item in hand, you can see tooltiphere, can I set it to custom text? When yes, how? Thanks

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
  7. Offline

    Konato_K

    @bohafr The only way to do that is by changing the name of item they have on their hands.

    In 1.8 there is something called "Action Bar" which can be used for the same purpose, there should be something about that in the Alternatives section.
     
    vhbob likes this.
  8. Offline

    HungerCraftNL

    Lol ur crazy, using the PlayerMoveEvent to stay 'fed' it's a overkill, use the FoodLevelChangeEvent.

    Code:
        public void onpick(FoodLevelChangeEvent e){
            if(!(e.getEntity() instanceof Player))
                return;
            Player player = (Player) e.getEntity();
            if(player.hasPermission("PluginName.feed"))
                e.setCancelled(true);
        }
    
     
    Konato_K likes this.
  9. Offline

    Creeperzombi3

  10. Offline

    bohafr

    How get if headshot? (EntityDamageByEntityEvent)
    this doesn´t work:
    Code:
            boolean headshot = false;
            double arrowLoc = ((Arrow)e.getDamager()).getLocation().getY();
            double entityLoc = ((LivingEntity)e.getEntity()).getEyeLocation().getY();
          
            if ((entityLoc-arrowLoc) <= 0.015){
                System.out.println("headshot?");
            }
     
Thread Status:
Not open for further replies.

Share This Page