Death message enable/disable

Discussion in 'Plugin Development' started by xXDevastationXx, Feb 14, 2015.

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

    xXDevastationXx

    Helloooo :) i wanted to know how it could be possible to make a command enable/disable death messages to only that player.

    EXAMPLE

    Me: /dm enable
    I see: lalaguy98 killed xXDevastationXx with a stone sword!

    Other guy: /dm disable
    They see: nothing

    Dont give me the entire code, i just want hints to learn :)
     
  2. You could use a hasmap that stores the player's name or id and whether they have it enabled or not.
    Use the command to toggle it, and check the hashmap in the event.
     
  3. Offline

    pie_flavor

    @Laekh @xXDevastationXx A better idea would be to use a HashSet<UUID> which is faster and there's no point in using a hashmap if the value is just a boolean.
     
    GrandmaJam likes this.
  4. I stand corrected.
    I'll blame it on it being 5 am :rolleyes:
     
  5. Offline

    mythbusterma

    @pie_flavor

    Explain how a HashSet is faster than a HashMap, when a HashSet is simply a HashMap with empty buckets.

    In reality it makes no difference.
     
    GrandmaJam likes this.
  6. Offline

    xXDevastationXx

    Im not the best with hashmaps/hashsets, can I see an example? (Sorry im not good with reading learning, i like to see it)
     
  7. Offline

    Skionz

    @xXDevastationXx
    Code:
    public static void main(String[] args) {
        Map<String, Integer> map = new HashMap<String, Integer>();
        map.put("Stuff", 3);
        System.out.println(map.get("Stuff"));
    }
     
Thread Status:
Not open for further replies.

Share This Page