aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/detrav/commands/DetravLevelUpCommand.java
blob: 432aac54fe3bf6d8d012ffa1343249d5841844e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package com.detrav.commands;

import com.google.common.collect.HashMultimap;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.ai.attributes.BaseAttributeMap;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * Created by Detrav on 26.03.2017.
 */
public class DetravLevelUpCommand implements ICommand {

    private List aliases;

    public  DetravLevelUpCommand()
    {
        this.aliases = new ArrayList<String>();
        this.aliases.add("DetravLevelUp");
        this.aliases.add("dlup");
    }

    @Override
    public String getCommandName() {
        return "DetravLevelUp";
    }

    @Override
    public String getCommandUsage(ICommandSender p_71518_1_) {
        return "DetravLevelUp";
    }

    @Override
    public List getCommandAliases() {
        return aliases;
    }

    static int level = 0;

    static UUID id = UUID.randomUUID();

    @Override
    public void processCommand(ICommandSender player, String[] p_71515_2_) {
        if(player instanceof EntityPlayerMP)
        {

            level++;
            AttributeModifier mod = new AttributeModifier(id,"detravlevelup",level,0);
            ((EntityPlayerMP) player).getEntityAttribute(
                    SharedMonsterAttributes.maxHealth
            ).removeModifier(mod);
            ((EntityPlayerMP) player).getEntityAttribute(
                    SharedMonsterAttributes.maxHealth
            ).applyModifier(mod);



            /*BaseAttributeMap attrMap = ((EntityPlayerMP) player).getAttributeMap();
            HashMultimap map = HashMultimap.create();
            map.put()
            attrMap.applyAttributeModifiers(map);*/
        }
    }

    private void sendHelpMessage(ICommandSender sender)
    {
        sender.addChatMessage(new ChatComponentText(getCommandUsage(sender)));
    }

    @Override
    public boolean canCommandSenderUseCommand(ICommandSender p_71519_1_) {
        return true;
    }

    @Override
    public List addTabCompletionOptions(ICommandSender p_71516_1_, String[] p_71516_2_) {
        return null;
    }

    @Override
    public boolean isUsernameIndex(String[] p_82358_1_, int p_82358_2_) {
        return false;
    }

    @Override
    public int compareTo(Object o) {
        return 0;
    }
}