-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCategory.java
More file actions
81 lines (68 loc) · 1.26 KB
/
Copy pathCategory.java
File metadata and controls
81 lines (68 loc) · 1.26 KB
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
package net.virtuallyabstract.minecraft;
import java.util.*;
public class Category implements Comparable<Category>
{
private String name, desc;
private ArrayList<Category> subCats;
private ArrayList<Command> commands;
public Category(String name, String description)
{
this.name = name;
this.desc = description;
this.subCats = new ArrayList<Category>();
this.commands = new ArrayList<Command>();
}
public void addCategory(Category c)
{
subCats.add(c);
Collections.sort(subCats);
}
public void addCommand(Command c)
{
commands.add(c);
Collections.sort(commands);
}
public void update(CommandBuilder cb, String value)
{
for(Category c : subCats)
{
if(c.equals(value))
{
cb.setActiveCategory(c);
return;
}
}
for(Command c : commands)
{
if(c.equals(value))
{
cb.setActiveCommand(c);
return;
}
}
}
public boolean equals(String name)
{
return this.name.equals(name);
}
@Override public int compareTo(Category c2)
{
return name.compareTo(c2.getName());
}
public String toString()
{
return name + " - " + desc;
}
public String getName()
{
return name;
}
public ArrayList<Command> listCommands()
{
return commands;
}
public ArrayList<Category> listCategories()
{
return subCats;
}
}