Skip to content

Commit ebe80e8

Browse files
committed
Fixed multi-colored particle; Fixed gifts bug; Updated config
1 parent fb70fbc commit ebe80e8

3 files changed

Lines changed: 34 additions & 11 deletions

File tree

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
package ru.meloncode.xmas;
22

3+
import org.bukkit.Color;
34
import org.bukkit.Location;
45
import org.bukkit.Particle;
6+
import org.bukkit.Particle.DustOptions;
57
import org.bukkit.entity.Player;
68

9+
import java.util.Random;
10+
711
public class ParticleContainer {
812

13+
final static DustOptions[] COLORS = new DustOptions[]{
14+
new DustOptions(Color.LIME, 1f),
15+
new DustOptions(Color.RED, 1f),
16+
new DustOptions(Color.AQUA, 1f),
17+
new DustOptions(Color.YELLOW, 1f),
18+
new DustOptions(Color.BLUE, 1f),
19+
new DustOptions(Color.FUCHSIA, 1f)
20+
};
21+
final static Random random = new Random("Happy 2019!".hashCode());
22+
923
private final Particle type;
1024
private final float offsetX;
1125
private final float offsetY;
@@ -28,7 +42,11 @@ public void playEffect(Location location) {
2842
for (Player player : location.getWorld().getPlayers())
2943
if (player.getLocation().distance(location) < 16) {
3044
try {
31-
player.spawnParticle(type, location, count, offsetX, offsetY, offsetZ, speed);
45+
if (type == Particle.REDSTONE) {
46+
player.spawnParticle(type, location, count, offsetX, offsetY, offsetZ, speed, COLORS[random.nextInt(6)]);
47+
} else {
48+
player.spawnParticle(type, location, count, offsetX, offsetY, offsetZ, speed);
49+
}
3250
} catch (Exception e) {
3351
e.printStackTrace();
3452
}

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

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

3+
import net.minecraft.server.v1_13_R2.BlockPosition;
4+
import net.minecraft.server.v1_13_R2.TileEntitySkull;
35
import org.bukkit.Location;
46
import org.bukkit.Material;
5-
import org.bukkit.SkullType;
6-
import org.bukkit.World;
77
import org.bukkit.block.Block;
88
import org.bukkit.block.Skull;
9+
import org.bukkit.craftbukkit.v1_13_R2.CraftWorld;
910
import org.bukkit.entity.Player;
1011
import org.bukkit.inventory.ItemStack;
1112
import ru.meloncode.xmas.utils.TextUtils;
1213

13-
import java.util.*;
14+
import java.util.ArrayList;
15+
import java.util.Collection;
16+
import java.util.List;
17+
import java.util.UUID;
1418
import java.util.concurrent.ConcurrentHashMap;
1519

1620
class XMas {
@@ -38,15 +42,16 @@ public static void removeTree(MagicTree tree) {
3842
TreeSerializer.removeTree(tree);
3943
trees.remove(tree.getTreeUID());
4044
}
41-
4245
public static void processPresent(Block block, Player player) {
43-
if (block.getType() == Material.SKULL) {
46+
if (block.getType() == Material.PLAYER_HEAD) {
4447
Skull skull = (Skull) block.getState();
45-
if (skull.getSkullType() == SkullType.PLAYER) {
46-
if (Main.getHeads().contains(skull.getOwner())) {
48+
TileEntitySkull skullTile = (TileEntitySkull) ((CraftWorld)skull.getWorld()).getHandle().getTileEntity(new BlockPosition(skull.getX(), skull.getY(), skull.getZ()));
49+
if(skullTile != null && skullTile.getGameProfile() != null) {
50+
if (Main.getHeads().contains(skullTile.getGameProfile().getName())) {
4751
Location loc = block.getLocation();
4852
if ((Main.RANDOM.nextFloat()) < Main.LUCK_CHANCE || !Main.LUCK_CHANCE_ENABLED) {
49-
loc.getWorld().dropItemNaturally(loc, new ItemStack(Main.gifts.get(Main.RANDOM.nextInt(Main.gifts.size()))));
53+
loc.getWorld().dropItemNaturally(loc,
54+
new ItemStack(Main.gifts.get(Main.RANDOM.nextInt(Main.gifts.size()))));
5055
Effects.TREE_SWAG.playEffect(loc);
5156
TextUtils.sendMessage(player, LocaleManager.GIFT_LUCK);
5257
} else {

src/main/resources/config.yml

Lines changed: 2 additions & 2 deletions
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-2018 03-33-33
14+
date: 10-01-2019 03-33-33
1515
# if true - plugin will summon chest with spent resources under tree
1616
resource-back: true
1717

@@ -64,7 +64,7 @@ xmas:
6464
DIAMOND: 3
6565
GOLD_INGOT: 5
6666
BLAZE_POWDER: 10
67-
SNOW_BALL: 30
67+
SNOWBALL: 30
6868
tree:
6969
gift-cooldown: 180
7070
lvlup:

0 commit comments

Comments
 (0)