Skip to content

Commit a2a53d6

Browse files
committed
Updated to 1.14.2
1 parent 1dc4023 commit a2a53d6

File tree

5 files changed

+36
-70
lines changed

5 files changed

+36
-70
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<dependency>
6666
<groupId>org.spigotmc</groupId>
6767
<artifactId>spigot-api</artifactId>
68-
<version>1.12.2-R0.1-SNAPSHOT</version>
68+
<version>1.14.2-R0.1-SNAPSHOT</version>
6969
<scope>provided</scope>
7070
</dependency>
7171
<!-- Third-party plugins -->

src/main/java/com/narrowtux/dropchest/DropChest.java

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ public static String chestInformation(Inventory inv, String identifier) {
6767
HashMap<Material, Integer> map = new HashMap<Material, Integer>();
6868
for (int i = 0; i < inv.getSize(); i++) {
6969
ItemStack stack = inv.getItem(i);
70-
if (stack != null && stack.getTypeId() != 0) {
70+
// TODO: Fix
71+
// if (stack != null && stack.getTypeId() != 0) {
72+
if (stack != null) {
7173
Material mat = stack.getType();
7274
Integer count = stack.getAmount();
7375
if (map.containsKey(mat)) {
@@ -157,7 +159,6 @@ private void load() {
157159
}
158160
File yamlFile = new File(dir, "dropchests.yml");
159161
if (yamlFile.exists()) {
160-
//TODO: Do yaml loading
161162
Yaml yaml = new Yaml();
162163
try {
163164
FileReader reader = new FileReader(yamlFile);
@@ -173,7 +174,6 @@ private void load() {
173174
}
174175
}
175176
} catch (FileNotFoundException e) {
176-
// TODO Auto-generated catch block
177177
e.printStackTrace();
178178
}
179179
return;
@@ -515,28 +515,11 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
515515
if (chest != null) {
516516
if (ownsChest(chest, sender)) {
517517
try {
518-
item = Material.valueOf(itemstring.toUpperCase());
518+
item = Material.getMaterial(itemstring);
519519
} catch (IllegalArgumentException e) {
520520
item = null;
521521
}
522-
boolean materialNotFound = false;
523-
if (item == null) {
524-
Integer itemid = null;
525-
try {
526-
itemid = Integer.valueOf(itemstring);
527-
} catch (NumberFormatException e) {
528-
itemid = null;
529-
}
530-
if (itemid != null) {
531-
item = Material.getMaterial(itemid);
532-
if (item == null) {
533-
materialNotFound = true;
534-
}
535-
} else {
536-
materialNotFound = true;
537-
}
538-
}
539-
if (!materialNotFound) {
522+
if (item != null) {
540523
List<Material> filter = chest.getFilter(type);
541524
if (filter.contains(item)) {
542525
filter.remove(item);
@@ -691,26 +674,11 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
691674
if (cmd.getName().equals("dcitem")) {
692675
if (args.length == 1) {
693676
int id = 0;
694-
Material m = null;
695-
try {
696-
id = Integer.valueOf(args[0]);
697-
} catch (Exception e) {
698-
m = Material.matchMaterial(args[0].toUpperCase());
699-
}
700-
if (id != 0) {
701-
m = Material.getMaterial(id);
702-
if (m != null) {
703-
sender.sendMessage(ChatColor.YELLOW.toString() + id + ChatColor.WHITE + " is " + ChatColor.YELLOW.toString() + m.toString());
704-
} else {
705-
sender.sendMessage(ChatColor.RED + "That item does not exist.");
706-
}
677+
Material m = Material.getMaterial(args[0]);
678+
if (m != null) {
679+
sender.sendMessage(ChatColor.YELLOW.toString() + id + ChatColor.WHITE + " is " + ChatColor.YELLOW.toString() + m.toString());
707680
} else {
708-
if (m != null) {
709-
id = m.getId();
710-
sender.sendMessage(ChatColor.YELLOW + m.toString() + ChatColor.WHITE + " is " + ChatColor.YELLOW + id);
711-
} else {
712-
sender.sendMessage(ChatColor.RED + "That item does not exist.");
713-
}
681+
sender.sendMessage(ChatColor.RED + "That item does not exist.");
714682
}
715683
return true;
716684
}

src/main/java/com/narrowtux/dropchest/DropChestInventory.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public List<HumanEntity> getViewers() {
109109
return null;
110110
}
111111

112-
@Override
112+
// @Override
113113
public String getTitle() {
114114
return null;
115115
}
@@ -169,7 +169,7 @@ public boolean contains(ItemStack arg0) {
169169
return false;
170170
}
171171

172-
@Override
172+
// @Override
173173
public boolean contains(int materialId, int amount) {
174174
return false;
175175
}
@@ -205,26 +205,23 @@ public boolean containsAtLeast(ItemStack item, int amount) {
205205
return false;
206206
}
207207

208-
@Override
208+
// @Override
209209
public HashMap<Integer, ? extends ItemStack> all(int materialId) {
210210
return null;
211211
}
212212

213213
// @Override
214214
public int first(int arg0) {
215-
// TODO Auto-generated method stub
216215
return 0;
217216
}
218217

219218
@Override
220219
public int first(Material arg0) {
221-
// TODO Auto-generated method stub
222220
return 0;
223221
}
224222

225223
@Override
226224
public int first(ItemStack arg0) {
227-
// TODO Auto-generated method stub
228225
return 0;
229226
}
230227

@@ -233,14 +230,13 @@ public int firstEmpty() {
233230
return first(0);
234231
}
235232

236-
@Override
233+
// @Override
237234
public void remove(int materialId) {
238235

239236
}
240237

241238
@Override
242239
public ItemStack[] getContents() {
243-
//TODO
244240
return null;
245241
}
246242

@@ -261,7 +257,7 @@ public void setStorageContents(ItemStack[] items) throws IllegalArgumentExceptio
261257

262258
}
263259

264-
@Override
260+
// @Override
265261
public boolean contains(int materialId) {
266262
return false;
267263
}
@@ -295,7 +291,7 @@ public void setMaxStackSize(int size) {
295291

296292
}
297293

298-
@Override
294+
// @Override
299295
public String getName() {
300296
return null;
301297
}

src/main/java/com/narrowtux/dropchest/DropChestItem.java

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.bukkit.block.Block;
2424
import org.bukkit.block.BlockFace;
2525
import org.bukkit.block.Chest;
26+
import org.bukkit.block.data.BlockData;
2627
import org.bukkit.entity.Player;
2728
import org.bukkit.entity.minecart.StorageMinecart;
2829
import org.bukkit.inventory.Inventory;
@@ -74,10 +75,10 @@ public DropChestItem(Map<String, Object> loadMap, DropChest plugin) {
7475
}
7576

7677
static public boolean acceptsBlockType(Material m) {
77-
return m.getId() == Material.CHEST.getId()
78-
|| m.getId() == Material.DISPENSER.getId()
79-
|| m.getId() == Material.FURNACE.getId()
80-
|| m.getId() == Material.BURNING_FURNACE.getId();
78+
return m == Material.CHEST ||
79+
m == Material.TRAPPED_CHEST ||
80+
m == Material.FURNACE ||
81+
m == Material.DISPENSER;
8182
}
8283

8384
private void initFilter() {
@@ -156,7 +157,7 @@ public double getPercentFull() {
156157
ItemStack istack = inv.getItem(j);
157158
if (istack != null) {
158159
totalItems += istack.getAmount();
159-
if (istack.getTypeId() == 0) {
160+
if (istack.getType() == Material.AIR) {
160161
maxStackSize += 64;
161162
} else {
162163
maxStackSize += istack.getMaxStackSize();
@@ -200,7 +201,7 @@ public HashMap<Integer, ItemStack> addItem(ItemStack item, FilterType filterType
200201
return ret;
201202
} else {
202203
for (Material m : filter.get(filterType)) {
203-
if (m.getId() == item.getTypeId()) {
204+
if (m == item.getType()) {
204205
pm.callEvent(fillEvent);
205206
return getInventory().addItem(item);
206207
}
@@ -227,14 +228,15 @@ public void setMinecartAction(DropChestMinecartAction minecartAction) {
227228

228229
public void setRedstone(boolean value) {
229230
Block below = getBlock().getRelative(BlockFace.DOWN);
230-
if (below.getTypeId() == Material.LEVER.getId()) {
231-
byte data = below.getData();
232-
if (value) {
233-
data = 0x8 | 0x5;
234-
} else {
235-
data = 0x5;
236-
}
237-
below.setData(data);
231+
if (below.getType() == Material.LEVER) {
232+
BlockData data = below.getBlockData();
233+
// TODO: FIX
234+
// if (value) {
235+
// data = 0x8 | 0x5;
236+
// } else {
237+
// data = 0x5;
238+
// }
239+
below.setBlockData(data);
238240
}
239241
}
240242

@@ -448,7 +450,7 @@ public void minecartAction(StorageMinecart storage) {
448450
for (int i = 0; i < items.length; i++) {
449451
ItemStack is = items[i];
450452
if (is.getType().equals(Material.COAL)
451-
|| is.getType().equals(Material.WOOD)
453+
|| is.getType().equals(Material.LEGACY_WOOD)
452454
|| is.getType().equals(Material.LAVA_BUCKET)) {
453455
//this is fuel
454456
ItemStack fs = furn[1];
@@ -477,7 +479,7 @@ public void minecartAction(StorageMinecart storage) {
477479
}
478480
}
479481
if (is.getType().toString().contains("ORE") ||
480-
is.getType().equals(Material.LOG) ||
482+
is.getType().equals(Material.LEGACY_LOG) ||
481483
is.getType().equals(Material.CACTUS) ||
482484
is.getType().equals(Material.SAND) ||
483485
is.getType().equals(Material.COBBLESTONE)) {
@@ -703,7 +705,7 @@ private void load(Map<String, Object> loadMap) {
703705
List<Material> filter = getFilter(type);
704706
ArrayList<String> items = (ArrayList<String>) filters.get(typename);
705707
for (String item : items) {
706-
filter.add(Material.getMaterial(Integer.valueOf(item)));
708+
filter.add(Material.getMaterial(item));
707709
}
708710
}
709711
}

src/main/java/com/narrowtux/dropchest/DropChestWorldListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class DropChestWorldListener implements Listener {
2828
public void onChunkUnload(ChunkUnloadEvent event) {
2929
for (DropChestItem item : plugin.getChests()) {
3030
if (item.getBlock().getChunk().equals(event.getChunk())) {
31-
event.setCancelled(true);
31+
event.getChunk().load();
3232
return;
3333
}
3434
}

0 commit comments

Comments
 (0)