|
1 | 1 | package com.massivecraft.factions.listeners;
|
2 | 2 |
|
| 3 | +import com.cryptomorin.xseries.XMaterial; |
3 | 4 | import com.massivecraft.factions.*;
|
4 | 5 | import com.massivecraft.factions.cmd.CmdFly;
|
5 | 6 | import com.massivecraft.factions.cmd.CmdSeeChunk;
|
|
14 | 15 | import com.massivecraft.factions.struct.Role;
|
15 | 16 | import com.massivecraft.factions.util.FactionGUI;
|
16 | 17 | import com.massivecraft.factions.util.VisualizeUtil;
|
17 |
| -import com.massivecraft.factions.util.XMaterial; |
18 | 18 | import com.massivecraft.factions.zcore.fperms.Access;
|
19 | 19 | import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
20 | 20 | import com.massivecraft.factions.zcore.persist.MemoryFPlayer;
|
@@ -272,124 +272,36 @@ private static PermissableAction GetPermissionFromUsableBlock(Block block) {
|
272 | 272 | }
|
273 | 273 |
|
274 | 274 | private static PermissableAction GetPermissionFromUsableBlock(Material material) {
|
275 |
| - // Check for doors that might have diff material name in old version. |
276 |
| - if (material.name().contains("DOOR") || material.name().contains("FENCE_GATE")) |
277 |
| - return PermissableAction.DOOR; |
278 |
| - if (material.name().toUpperCase().contains("BUTTON") || material.name().toUpperCase().contains("PRESSURE") |
279 |
| - || material.name().contains("DIODE") || material.name().contains("COMPARATOR")) |
280 |
| - return PermissableAction.BUTTON; |
281 |
| - if (SavageFactions.plugin.mc113 || SavageFactions.plugin.mc114) { |
282 |
| - switch (material) { |
283 |
| - case LEVER: |
284 |
| - return PermissableAction.LEVER; |
285 |
| - case ACACIA_BUTTON: |
286 |
| - case BIRCH_BUTTON: |
287 |
| - case DARK_OAK_BUTTON: |
288 |
| - case JUNGLE_BUTTON: |
289 |
| - case OAK_BUTTON: |
290 |
| - case SPRUCE_BUTTON: |
291 |
| - case STONE_BUTTON: |
292 |
| - case COMPARATOR: |
293 |
| - case REPEATER: |
294 |
| - return PermissableAction.BUTTON; |
295 |
| - |
296 |
| - case ACACIA_DOOR: |
297 |
| - case BIRCH_DOOR: |
298 |
| - case IRON_DOOR: |
299 |
| - case JUNGLE_DOOR: |
300 |
| - case OAK_DOOR: |
301 |
| - case SPRUCE_DOOR: |
302 |
| - case DARK_OAK_DOOR: |
303 |
| - |
304 |
| - case ACACIA_TRAPDOOR: |
305 |
| - case BIRCH_TRAPDOOR: |
306 |
| - case DARK_OAK_TRAPDOOR: |
307 |
| - case IRON_TRAPDOOR: |
308 |
| - case JUNGLE_TRAPDOOR: |
309 |
| - case OAK_TRAPDOOR: |
310 |
| - case SPRUCE_TRAPDOOR: |
311 |
| - |
312 |
| - case ACACIA_FENCE_GATE: |
313 |
| - case BIRCH_FENCE_GATE: |
314 |
| - case DARK_OAK_FENCE_GATE: |
315 |
| - case JUNGLE_FENCE_GATE: |
316 |
| - case OAK_FENCE_GATE: |
317 |
| - case SPRUCE_FENCE_GATE: |
318 |
| - return PermissableAction.DOOR; |
319 |
| - |
320 |
| - case CHEST: |
321 |
| - case TRAPPED_CHEST: |
322 |
| - case CHEST_MINECART: |
323 |
| - |
324 |
| - case BARREL: |
325 |
| - |
326 |
| - case SHULKER_BOX: |
327 |
| - case BLACK_SHULKER_BOX: |
328 |
| - case BLUE_SHULKER_BOX: |
329 |
| - case BROWN_SHULKER_BOX: |
330 |
| - case CYAN_SHULKER_BOX: |
331 |
| - case GRAY_SHULKER_BOX: |
332 |
| - case GREEN_SHULKER_BOX: |
333 |
| - case LIGHT_BLUE_SHULKER_BOX: |
334 |
| - case LIGHT_GRAY_SHULKER_BOX: |
335 |
| - case LIME_SHULKER_BOX: |
336 |
| - case MAGENTA_SHULKER_BOX: |
337 |
| - case ORANGE_SHULKER_BOX: |
338 |
| - case PINK_SHULKER_BOX: |
339 |
| - case PURPLE_SHULKER_BOX: |
340 |
| - case RED_SHULKER_BOX: |
341 |
| - case WHITE_SHULKER_BOX: |
342 |
| - case YELLOW_SHULKER_BOX: |
343 |
| - |
344 |
| - case FURNACE: |
345 |
| - case DROPPER: |
| 275 | + if (material.name().contains("_BUTTON") |
| 276 | + || material.name().contains("COMPARATOR") |
| 277 | + || material.name().contains("PRESSURE") |
| 278 | + || material.name().contains("REPEATER") |
| 279 | + || material.name().contains("DIODE")) return PermissableAction.BUTTON; |
| 280 | + if (material.name().contains("_DOOR") |
| 281 | + || material.name().contains("_TRAPDOOR") |
| 282 | + || material.name().contains("_FENCE_GATE") |
| 283 | + || material.name().startsWith("FENCE_GATE")) return PermissableAction.DOOR; |
| 284 | + if (material.name().contains("SHULKER_BOX") |
| 285 | + || material.name().endsWith("ANVIL") |
| 286 | + || material.name().startsWith("CHEST_MINECART") |
| 287 | + || material.name().endsWith("CHEST") |
| 288 | + || material.name().endsWith("JUKEBOX") |
| 289 | + || material.name().endsWith("CAULDRON") |
| 290 | + || material.name().endsWith("FURNACE") |
| 291 | + || material.name().endsWith("HOPPER") |
| 292 | + || material.name().endsWith("BEACON") |
| 293 | + || material.name().startsWith("TRAPPED_CHEST") |
| 294 | + || material.name().equalsIgnoreCase("ENCHANTING_TABLE") |
| 295 | + || material.name().equalsIgnoreCase("ENCHANTMENT_TABLE") |
| 296 | + || material.name().endsWith("BREWING_STAND") |
| 297 | + || material.name().equalsIgnoreCase("BARREL")) return PermissableAction.CONTAINER; |
| 298 | + if (material.name().endsWith("LEVER")) return PermissableAction.LEVER; |
| 299 | + switch (material) { |
346 | 300 | case DISPENSER:
|
347 |
| - case ENCHANTING_TABLE: |
348 |
| - case BREWING_STAND: |
349 |
| - case CAULDRON: |
350 |
| - case HOPPER: |
351 |
| - case BEACON: |
352 |
| - case JUKEBOX: |
353 |
| - case ANVIL: |
354 |
| - case CHIPPED_ANVIL: |
355 |
| - case DAMAGED_ANVIL: |
356 |
| - return PermissableAction.CONTAINER; |
357 |
| - default: |
358 |
| - return null; |
359 |
| - } |
360 |
| - } else { |
361 |
| - switch (material) { |
362 |
| - case LEVER: |
363 |
| - return PermissableAction.LEVER; |
364 |
| - case DARK_OAK_DOOR: |
365 |
| - case ACACIA_DOOR: |
366 |
| - case BIRCH_DOOR: |
367 |
| - case IRON_DOOR: |
368 |
| - case JUNGLE_DOOR: |
369 |
| - case SPRUCE_DOOR: |
370 |
| - case ACACIA_FENCE_GATE: |
371 |
| - case BIRCH_FENCE_GATE: |
372 |
| - case OAK_FENCE_GATE: |
373 |
| - case DARK_OAK_FENCE_GATE: |
374 |
| - case JUNGLE_FENCE_GATE: |
375 |
| - case SPRUCE_FENCE_GATE: |
376 |
| - return PermissableAction.DOOR; |
377 |
| - case CHEST: |
378 |
| - case ENDER_CHEST: |
379 |
| - case TRAPPED_CHEST: |
380 |
| - case DISPENSER: |
381 |
| - case ENCHANTING_TABLE: |
382 | 301 | case DROPPER:
|
383 |
| - case FURNACE: |
384 |
| - case HOPPER: |
385 |
| - case ANVIL: |
386 |
| - case CHIPPED_ANVIL: |
387 |
| - case DAMAGED_ANVIL: |
388 |
| - case BREWING_STAND: |
389 | 302 | return PermissableAction.CONTAINER;
|
390 | 303 | default:
|
391 | 304 | return null;
|
392 |
| - } |
393 | 305 | }
|
394 | 306 | }
|
395 | 307 |
|
@@ -745,7 +657,11 @@ public void onPlayerInteract(PlayerInteractEvent event) {
|
745 | 657 | Material type;
|
746 | 658 | if (event.getItem() != null) {
|
747 | 659 | // Convert 1.8 Material Names -> 1.14
|
748 |
| - type = XMaterial.matchXMaterial(event.getItem().getType().toString()).parseMaterial(); |
| 660 | + try { |
| 661 | + type = XMaterial.matchXMaterial(event.getItem().getType().toString()).get().parseMaterial(); |
| 662 | + } catch (NullPointerException npe) { |
| 663 | + type = null; |
| 664 | + } |
749 | 665 | } else {
|
750 | 666 | type = null;
|
751 | 667 | }
|
|
0 commit comments