Skip to content

Commit 151b249

Browse files
committed
Removed NMS dependency
1 parent 3e9938c commit 151b249

5 files changed

Lines changed: 19 additions & 29 deletions

File tree

-30.5 MB
Binary file not shown.

pom.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,6 @@
7575
<artifactId>bungeecord-api</artifactId>
7676
<version>1.14-SNAPSHOT</version>
7777
</dependency>
78-
<!-- Spigot Binary-->
79-
<dependency>
80-
<groupId>org.spigotmc</groupId>
81-
<artifactId>spigot-binary</artifactId>
82-
<scope>system</scope>
83-
<systemPath>${basedir}/lib/Spigot-1.14.4-e5b1b5d-20190802-0923.jar</systemPath>
84-
</dependency>
8578
<!-- Apache Commons 3-->
8679
<dependency>
8780
<groupId>org.apache.commons</groupId>

src/main/java/ru/meloncode/xmas/Events.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void onPlayerOpenPresent(PlayerInteractEvent event) {
3434
if (event.getHand() == EquipmentSlot.OFF_HAND) return; //Event firing for both hands
3535
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
3636
Block block = event.getClickedBlock();
37-
if (block.getType() == Material.PLAYER_HEAD) {
37+
if (block != null && block.getType() == Material.PLAYER_HEAD) {
3838
XMas.processPresent(block, event.getPlayer());
3939
}
4040
}
@@ -244,10 +244,6 @@ public void onPlayerBreakBlock(BlockBreakEvent event) {
244244
} else {
245245
TextUtils.sendMessage(player, LocaleManager.DESTROY_FAIL_OWNER);
246246
}
247-
248-
break;
249-
case PLAYER_HEAD:
250-
XMas.processPresent(block, player);
251247
break;
252248
default:
253249
break;

src/main/java/ru/meloncode/xmas/XMas.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package ru.meloncode.xmas;
22

3-
import net.minecraft.server.v1_14_R1.BlockPosition;
4-
import net.minecraft.server.v1_14_R1.TileEntitySkull;
53
import org.bukkit.Location;
64
import org.bukkit.Material;
5+
import org.bukkit.World;
76
import org.bukkit.block.Block;
87
import org.bukkit.block.Skull;
9-
import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
108
import org.bukkit.entity.Player;
119
import org.bukkit.inventory.ItemStack;
1210
import ru.meloncode.xmas.utils.TextUtils;
@@ -17,6 +15,8 @@
1715
import java.util.UUID;
1816
import java.util.concurrent.ConcurrentHashMap;
1917

18+
import static ru.meloncode.xmas.Main.RANDOM;
19+
2020
class XMas {
2121

2222
private static final ConcurrentHashMap<UUID, MagicTree> trees = new ConcurrentHashMap<>();
@@ -42,26 +42,27 @@ public static void removeTree(MagicTree tree) {
4242
TreeSerializer.removeTree(tree);
4343
trees.remove(tree.getTreeUID());
4444
}
45+
4546
public static void processPresent(Block block, Player player) {
4647
if (block.getType() == Material.PLAYER_HEAD) {
4748
Skull skull = (Skull) block.getState();
48-
TileEntitySkull skullTile = (TileEntitySkull) ((CraftWorld)skull.getWorld()).getHandle().getTileEntity(new BlockPosition(skull.getX(), skull.getY(), skull.getZ()));
49-
if(skullTile != null && skullTile.gameProfile != null) {
50-
if (Main.getHeads().contains(skullTile.gameProfile.getName())) {
49+
50+
if (Main.getHeads().contains(skull.getOwner())) {
5151
Location loc = block.getLocation();
52-
if ((Main.RANDOM.nextFloat()) < Main.LUCK_CHANCE || !Main.LUCK_CHANCE_ENABLED) {
53-
loc.getWorld().dropItemNaturally(loc,
54-
new ItemStack(Main.gifts.get(Main.RANDOM.nextInt(Main.gifts.size()))));
55-
Effects.TREE_SWAG.playEffect(loc);
56-
TextUtils.sendMessage(player, LocaleManager.GIFT_LUCK);
57-
} else {
58-
Effects.SMOKE.playEffect(loc);
59-
loc.getWorld().dropItemNaturally(loc, new ItemStack(Material.COAL));
60-
TextUtils.sendMessage(player, LocaleManager.GIFT_FAIL);
52+
World world = loc.getWorld();
53+
if (world != null) {
54+
if (RANDOM.nextFloat() < Main.LUCK_CHANCE || !Main.LUCK_CHANCE_ENABLED) {
55+
world.dropItemNaturally(loc, new ItemStack(Main.gifts.get(RANDOM.nextInt(Main.gifts.size()))));
56+
Effects.TREE_SWAG.playEffect(loc);
57+
TextUtils.sendMessage(player, LocaleManager.GIFT_LUCK);
58+
} else {
59+
Effects.SMOKE.playEffect(loc);
60+
world.dropItemNaturally(loc, new ItemStack(Material.COAL));
61+
TextUtils.sendMessage(player, LocaleManager.GIFT_FAIL);
62+
}
6163
}
6264
block.setType(Material.AIR);
6365
}
64-
}
6566
}
6667
}
6768

src/main/resources/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ core:
1111
holiday-ends:
1212
enabled: true
1313
#DD.MM.YYYY HH-MM-SS
14-
date: 10-01-2019 03-33-33
14+
date: 10-01-2020 03-33-33
1515
# if true - plugin will summon chest with spent resources under tree
1616
resource-back: true
1717

0 commit comments

Comments
 (0)