Skip to content

Commit 93dc28d

Browse files
authored
Merge pull request MelonCode#1 from MelonCode/master
got stuff from official repo
2 parents 7f3c400 + 131b02a commit 93dc28d

7 files changed

Lines changed: 79 additions & 17 deletions

File tree

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# X-Mas
2+
3+
![Image](http://puu.sh/dKlK1/85c3dad454.jpg)
4+
5+
With this plugin you can plant your Christmas tree and upgrade it. Look for some gifts under it!
6+
7+
[SpigotMC plugin page](https://www.spigotmc.org/resources/x-mas-upgradeable-christmas-tree-event.2672/)
8+
9+
## Authors
10+
11+
* **MelonCode** - *Original dev* - [MelonCode](https://github.com/MelonCode)
12+
* **Ghost_chu** - *NMS fixes* - [Ghost_chu](https://github.com/Ghost-chu)
13+
* **LoneDev6** - *Optimization patches* - [LoneDev6](https://github.com/LoneDev6)
14+
* **montlikadani** - *Translation (hu)* - [montlikadani](https://github.com/montlikadani)
15+
16+
See also the list of [contributors](https://github.com/MelonCode/X-Mas/graphs/contributors) who participated in this project.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>me.meloncode</groupId>
88
<artifactId>xmas</artifactId>
9-
<version>2.3</version>
9+
<version>2.4</version>
1010

1111
<repositories>
1212
<repository>

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,18 @@ public void onSaplingGrow(StructureGrowEvent event) {
261261
}
262262
}
263263

264+
@EventHandler
265+
public void disableDecay(LeavesDecayEvent e)
266+
{
267+
if(e.isCancelled())
268+
return;
269+
270+
if(e.getBlock().getType() != Material.SPRUCE_LEAVES)
271+
return;
272+
273+
if (MagicTree.isBlockBelongs(e.getBlock().getLocation().getBlock()))
274+
e.setCancelled(true);
275+
}
276+
277+
264278
}

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,23 +106,28 @@ public void update() {
106106
}
107107
presentCounter--;
108108
}
109+
}
110+
}
109111

110-
if (blocks != null && blocks.size() > 0) {
111-
for (Block block : blocks) {
112-
if (block.getType() == Material.SPRUCE_LEAVES) {
113-
if (level.getSwagEffect() != null) {
114-
level.getSwagEffect().playEffect(block.getLocation());
115-
}
116-
}
117-
if (block.getType() == Material.SPRUCE_LOG) {
118-
if (level.getBodyEffect() != null) {
119-
level.getBodyEffect().playEffect(block.getLocation());
120-
}
112+
public void playParticles()
113+
{
114+
if (blocks != null && blocks.size() > 0) {
115+
for (Block block : blocks) {
116+
if(!block.getWorld().isChunkLoaded(block.getX() / 16, block.getZ() / 16))
117+
continue;
118+
if (block.getType() == Material.SPRUCE_LEAVES) {
119+
if (level.getSwagEffect() != null) {
120+
level.getSwagEffect().playEffect(block.getLocation());
121121
}
122-
if (level.getAmbientEffect() != null) {
123-
level.getAmbientEffect().playEffect(location.clone().add(0, level.getTreeHeight(), 0));
122+
}
123+
if (block.getType() == Material.SPRUCE_LOG) {
124+
if (level.getBodyEffect() != null) {
125+
level.getBodyEffect().playEffect(block.getLocation());
124126
}
125127
}
128+
if (level.getAmbientEffect() != null) {
129+
level.getAmbientEffect().playEffect(location.clone().add(0, level.getTreeHeight(), 0));
130+
}
126131
}
127132
}
128133
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class Main extends JavaPlugin implements Listener {
3434
static long endTime;
3535
static boolean inProgress;
3636
private static int UPDATE_SPEED;
37+
private static int PARTICLES_DELAY;
3738
private static List<String> heads;
3839
private static Plugin plugin;
3940
private FileConfiguration config;
@@ -67,6 +68,10 @@ public void onEnable() {
6768
config.set("core.update-speed", 7);
6869
UPDATE_SPEED = 7;
6970
}
71+
PARTICLES_DELAY = config.getInt("core.particles-delay");
72+
if (PARTICLES_DELAY <= 0)
73+
config.set("particles-delay", 35);
74+
7075
autoEnd = config.getBoolean("core.holiday-ends.enabled");
7176
resourceBack = config.getBoolean("core.holiday-ends.resource-back");
7277
MAX_TREE_COUNT = config.getInt("core.tree-limit");
@@ -119,6 +124,7 @@ public void onEnable() {
119124
LUCK_CHANCE = (float) config.getInt("xmas.luck.chance") / 100;
120125
new Events().registerListener();
121126
new MagicTask(this).runTaskTimer(this, 5, UPDATE_SPEED);
127+
new PlayParticlesTask(this).runTaskTimerAsynchronously(this, 5, PARTICLES_DELAY);
122128
XMas.XMAS_CRYSTAL = new ItemMaker(Material.EMERALD, LocaleManager.CRYSTAL_NAME, LocaleManager.CRYSTAL_LORE).make();
123129

124130
ShapedRecipe grinderRecipe;
@@ -136,7 +142,7 @@ public void onEnable() {
136142
try {
137143
if (!registered)
138144
getServer().addRecipe(grinderRecipe);
139-
} catch (Exception e) {
145+
} catch (Exception ignored) {
140146
}
141147
XMasCommand.register(this);
142148
TextUtils.sendConsoleMessage(LocaleManager.PLUGIN_ENABLED);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package ru.meloncode.xmas;
2+
3+
import org.bukkit.scheduler.BukkitRunnable;
4+
5+
class PlayParticlesTask extends BukkitRunnable {
6+
7+
private final Main xmas;
8+
9+
PlayParticlesTask(Main main) {
10+
this.xmas = main;
11+
}
12+
13+
@Override
14+
public void run() {
15+
if (Main.inProgress)
16+
for (MagicTree tree : XMas.getAllTrees()) {
17+
tree.playParticles();
18+
}
19+
}
20+
}

src/main/resources/config.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ core:
1919
#I don't Recommend to touch it.
2020
#20 = 1 update / sec
2121
#Can't be 0
22-
update-speed: 7
22+
update-speed: 7
23+
particles-delay: 35
2324
xmas:
2425
luck:
2526
enabled: false
@@ -74,4 +75,4 @@ xmas:
7475
GLOWSTONE_DUST: 16
7576
magic_tree:
7677
gift-cooldown: 120
77-
lvlup:
78+
lvlup:

0 commit comments

Comments
 (0)