-
-
Notifications
You must be signed in to change notification settings - Fork 359
/
Copy pathTownBlockData.java
117 lines (94 loc) · 2.87 KB
/
TownBlockData.java
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package com.palmergames.bukkit.towny.object;
import com.palmergames.bukkit.towny.TownyAsciiMap;
import com.palmergames.bukkit.towny.TownySettings;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Material;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
public class TownBlockData {
private String mapKey = "+";
private NamedTextColor colour = null;
private double cost = 0.0;
private double tax = 0.0;
private final Set<Material> itemUseIds = new HashSet<>(); // List of item names that will trigger an item use test.
private final Set<Material> switchIds = new HashSet<>(); // List of item names that will trigger a switch test.
private final Set<Material> allowedBlocks = new HashSet<>(); // List of item names that will always be allowed.
public String getMapKey() {
return mapKey;
}
public void setMapKey(String mapKey) {
this.mapKey = TownyAsciiMap.parseSymbol(mapKey);
}
public boolean hasColour() {
return colour != null;
}
@Nullable
public NamedTextColor getColour() {
return colour;
}
public void setColour(NamedTextColor colour) {
this.colour = colour;
}
public double getCost() {
return cost;
}
/**
* Sets how much it costs for a player to set to plot to this type.
* @param cost The cost
*/
public void setCost(double cost) {
this.cost = cost;
}
public Set<Material> getItemUseIds() {
if (itemUseIds.isEmpty())
return TownySettings.getItemUseMaterials();
else
return itemUseIds;
}
public Set<Material> getSwitchIds() {
if (switchIds.isEmpty())
return TownySettings.getSwitchMaterials();
else
return switchIds;
}
public Set<Material> getAllowedBlocks() {
return allowedBlocks;
}
public void setItemUseIds(Collection<Material> itemUseIds) {
this.itemUseIds.clear();
this.itemUseIds.addAll(itemUseIds);
}
public void setSwitchIds(Collection<Material> switchIds) {
this.switchIds.clear();
this.switchIds.addAll(switchIds);
}
public void setAllowedBlocks(Collection<Material> allowedBlocks) {
this.allowedBlocks.clear();
this.allowedBlocks.addAll(allowedBlocks);
}
// These bridge methods were added during 0.99.2.*
@SuppressWarnings({"unused", "unchecked"})
private void setItemUseIds$$bridge$$public(EnumSet<?> itemUseIds) {
setItemUseIds((Collection<Material>) itemUseIds);
}
@SuppressWarnings({"unused", "unchecked"})
private void setSwitchIds$$bridge$$public(EnumSet<?> switchIds) {
setSwitchIds((Collection<Material>) switchIds);
}
@SuppressWarnings({"unused", "unchecked"})
private void setAllowedBlocks$$bridge$$public(EnumSet<?> allowedBlocks) {
setAllowedBlocks((Collection<Material>) allowedBlocks);
}
public void setTax(double tax) {
this.tax = tax;
}
public double getTax(Town town) {
if (tax == 0)
return town.getPlotTax();
else
return tax;
}
}