How to set pvp enabled and disabled

Discussion in 'Plugin Development' started by JordyPwner, Nov 18, 2014.

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

    JordyPwner

    Like the titles says :p i need this for in a scheduler (purge)
     
  2. Offline

    chasertw123

    Make a public Boolean in the main class and after a certain amount of time change that to either true for pvp or false for not. Also to prevent pvp use the entitydamagebyentityevent listener and if the two entities are players and the Boolean is false then cancel the event.
     
    es359 likes this.
  3. Offline

    JordyPwner

    NVm how can i use this in a bukkit runnable?

    Bukkit.getConsoleSender().dispatchCommand("Region flag __global__ -w plotworld pvp allow");

    it gives me this error: The method dispatchCommand(String) is undefined for the type ConsoleCommandSender
     
  4. Offline

    chasertw123

    JordyPwner
    Why not just listen for the damage.
     
  5. Offline

    JordyPwner

    Its already fixed but is there a tick to minute converter?
     
  6. Offline

    Hawktasard

    20 ticks = 1s
    20*60 ticks = 60s
    60s = 1m
     
  7. Offline

    JordyPwner

    K thanks last question i need to do if the runnable is at 1500 ticks how can i do it do something? (so i can check if its at a certain tick or something to do a command
     
  8. Offline

    thewalkingplay

    You can make a boolean "pvp" and set it, after make this, make a EntityDamageByEntity class(or just a event) like this:

    Code:java
    1. @EventHandler
    2. public void onEntityDamageByEntity(EntityDamageByEntityEvent e){
    3. if (e.getEntity() instanceof Player && e.getDamager() instanceof Player){
    4. if (pvp = false)
    5. e.setCancelled(true);
    6. }
    7. }


    Sorry for my english, i'm brazilian
     
  9. Offline

    JordyPwner

    I already fixed it. i only need to get the current tick in a runnable so i can do a command at a certain tick or second
     
  10. Offline

    Hawktasard

    (as far as I know) There's no current tick, It just executes whatever code you put in the run method after that set amount of time.
     
  11. Offline

    JordyPwner

    well i mean to check what second it is and then execute a cmd this is possible cause i saw it earlier
     
  12. Offline

    Hawktasard

    So, you're looking to execute that code every second for 60 seconds? If so you can just do something like this:
    Code:java
    1. int second = 1;
    2.  
    3. public void run() {
    4. System.out.println(second + "s...");
    5. second++;
    6. }


    Just remember to check if the seconds are more than 60, then cancel the event and set the pvp on.
    Also, sorry if this is not at all what you want, I didn't quite understand what you want.

    Edit: Also, change whatever I gave you before back to 20L if this is what you want.
     
  13. Offline

    JordyPwner

    i have a runnable that has 1800 ticks or 18k i just want to execute a command on 15k ticks or 1.5k ticks
     
  14. Offline

    Hawktasard

    I don't understand what you're trying to achieve, try to explain in a better way than that?
    Also, 1800 is not 18k, but 1.8k
     
  15. Offline

    JordyPwner

    K.
    I have a runnable of 20seconds i want if it is on 7 seconds to do something then on 16 then on 20 ect.
     
  16. Offline

    Hawktasard

    Do what I posted before:
    You can just check if seconds = 7.
     
  17. Offline

    JordyPwner

    Guess you dont understand me..

    WHAT I WANT. I have a bukkit runnable that starts when you do /cmd thennit will run the runnable. When the runnable id on 7 seconds i want it to do something. Then when it ison 14 seconds i want it to do something
     
  18. Offline

    Hawktasard

    What I posted would do exactly what you want (with minor modifications, ofcourse).
     
  19. Offline

    ColonelHedgehog

    JordyPwner: Don't get so angry. I know it's frustrating to hit a wall but Hawk is only trying to help.

    And actually for countdowns I think it's only possible to use arrays. So outside of the runnable:

    Code:
    final int[] seconds = new int[]{0};
    Then use seconds[0]++ to add to it.
     
  20. Offline

    Hawktasard

    ColonelHedgehog
    You can use whatever you want, You just need to declare the variable inside of the BukkitRunnable.

    Code:java
    1. new BukkitRunnable() {
    2. int someInt = 1234;
    3.  
    4. @Override
    5. public void run() {
    6. someInt++;
    7. }
    8. };
     
  21. Offline

    JordyPwner

    Now i do understand! Sorry :p So i can create multiple of this: int int = 1200; and int in1 = 1300; ect ect?
     
  22. Offline

    mythbusterma

  23. Offline

    JordyPwner

    Idk im learning with bukkit runnables atm
     
  24. Offline

    mythbusterma

    JordyPwner

    All it is (at least, in the way you're using it) is an anonymous inner class, it has all the same properties and features of a normal class (except a name).
     
    Hawktasard likes this.
Thread Status:
Not open for further replies.

Share This Page