Skip to content

Commit 77ebb67

Browse files
authored
Changement sur le Cube (stop command, une bulle = un cube) (#1227)
* one particuleTask for each Cube * add stop command * finalize * orthograf
1 parent e7de576 commit 77ebb67

4 files changed

Lines changed: 74 additions & 27 deletions

File tree

src/main/java/fr/openmc/core/features/cube/Cube.java

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
// - iambibi_
2626
public class Cube extends MultiBlock {
2727
public BukkitTask corruptedBubbleTask;
28+
public BukkitTask particuleBubbleTask;
29+
2830
public ReproductionTask reproductionTask;
2931
public BossBar cubeBossBar;
3032
public boolean showBossBar;
@@ -199,15 +201,17 @@ public void startMagneticShock() {
199201
}
200202
}
201203

202-
public final int RADIUS_BUBBLE = this.radius * 3;
204+
public final int RADIUS_BUBBLE = this.radius * 4;
203205

204206
public void startCorruptedBubble() {
205207
Location center = this.getCenter();
206208

207-
int totalTicks = 20 * 3600;
209+
int totalTicks = 20 * 1300;
208210

209211
startBubbleParticles();
210212

213+
if (corruptedBubbleTask != null) corruptedBubbleTask.cancel();
214+
211215
int intervalCorruption = 20 * 15;
212216
corruptedBubbleTask = new BukkitRunnable() {
213217
int elapsed = 0;
@@ -231,7 +235,7 @@ public void run() {
231235

232236
if (isPartOf(new Location(origin.getWorld(), x, y, z))) continue;
233237

234-
Location loc = center.clone().add(x, y, z);
238+
Location loc = center.add(x, y, z);
235239
Block block = loc.getBlock();
236240
Material type = block.getType();
237241

@@ -264,31 +268,36 @@ public void startBubbleParticles() {
264268
Location center = this.getCenter();
265269
double radius = RADIUS_BUBBLE;
266270

267-
Bukkit.getScheduler().runTaskTimer(OMCPlugin.getInstance(), () -> {
268-
for (int i = 0; i < 50; i++) {
269-
double theta = Math.random() * 2 * Math.PI;
270-
double phi = Math.random() * Math.PI;
271-
double x = radius * Math.sin(phi) * Math.cos(theta);
272-
double y = radius * Math.cos(phi);
273-
double z = radius * Math.sin(phi) * Math.sin(theta);
271+
if (particuleBubbleTask != null) particuleBubbleTask.cancel();
274272

275-
Location particleLoc = center.clone().add(x, y, z);
276-
world.spawnParticle(Particle.OMINOUS_SPAWNING, particleLoc, 1, 0.1, 0.1, 0.1, 0);
277-
}
278-
279-
for (double theta = 0; theta < Math.PI; theta += Math.PI / 16) {
280-
for (double phi = 0; phi < 2 * Math.PI; phi += Math.PI / 16) {
281-
double x = radius * Math.sin(theta) * Math.cos(phi);
282-
double y = radius * Math.cos(theta);
283-
double z = radius * Math.sin(theta) * Math.sin(phi);
273+
particuleBubbleTask = new BukkitRunnable() {
274+
@Override
275+
public void run() {
276+
for (int i = 0; i < 50; i++) {
277+
double theta = Math.random() * 2 * Math.PI;
278+
double phi = Math.random() * Math.PI;
279+
double x = radius * Math.sin(phi) * Math.cos(theta);
280+
double y = radius * Math.cos(phi);
281+
double z = radius * Math.sin(phi) * Math.sin(theta);
284282

285283
Location particleLoc = center.clone().add(x, y, z);
284+
world.spawnParticle(Particle.OMINOUS_SPAWNING, particleLoc, 1, 0.1, 0.1, 0.1, 0);
285+
}
286286

287-
Vector dir = center.clone().subtract(particleLoc).toVector().normalize();
288-
world.spawnParticle(Particle.SNEEZE, particleLoc, 1, dir.getX(), dir.getY(), dir.getZ(), 0.1);
287+
for (double theta = 0; theta < Math.PI; theta += Math.PI / 16) {
288+
for (double phi = 0; phi < 2 * Math.PI; phi += Math.PI / 16) {
289+
double x = radius * Math.sin(theta) * Math.cos(phi);
290+
double y = radius * Math.cos(theta);
291+
double z = radius * Math.sin(theta) * Math.sin(phi);
292+
293+
Location particleLoc = center.clone().add(x, y, z);
294+
295+
Vector dir = center.clone().subtract(particleLoc).toVector().normalize();
296+
world.spawnParticle(Particle.SNEEZE, particleLoc, 1, dir.getX(), dir.getY(), dir.getZ(), 0.1);
297+
}
289298
}
290299
}
291-
}, 0L, 20L);
300+
}.runTaskTimer(OMCPlugin.getInstance(), 0L, 20L);
292301
}
293302

294303
public void startReproduction() {
@@ -345,14 +354,13 @@ public void startEventsCycle() {
345354
public void run() {
346355
double roll = ThreadLocalRandom.current().nextDouble();
347356

348-
if (roll < 0.5) {
357+
if (roll < 0.7) {
349358
startMagneticShock();
350359
} else {
351-
if (corruptedBubbleTask == null)
352-
startCorruptedBubble();
360+
startCorruptedBubble();
353361
}
354362
}
355-
}.runTaskTimer(OMCPlugin.getInstance(), 20L * 60 * 5, 20L * 60 * 20);
363+
}.runTaskTimer(OMCPlugin.getInstance(), 20L * 60 * 5, 20L * 60 * 10);
356364
}
357365

358366
public void startSoundCycle() {

src/main/java/fr/openmc/core/features/cube/CubeCommands.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,41 @@ public void startCorruptedBubble(
4747
MessagesManager.sendMessage(player, Component.text("Bulle corrompue lancé"), Prefix.STAFF, MessageType.SUCCESS, false);
4848
}
4949

50+
@Subcommand("stopShock")
51+
@CommandPermission("omc.admins.commands.cube.shock")
52+
public void stopShock(
53+
Player player,
54+
@Named("cubeLoc") @SuggestWith(CubeLocationAutoComplete.class) String cubeLoc
55+
) {
56+
Cube cube = getInputCubes(player, cubeLoc);
57+
58+
if (cube == null) return;
59+
60+
MessagesManager.sendMessage(player, Component.text("Choc éléctro-magnétique arreté"), Prefix.STAFF, MessageType.SUCCESS, false);
61+
}
62+
63+
@Subcommand("stopBubble")
64+
@CommandPermission("omc.admins.commands.cube.bubble")
65+
public void stopCorruptedBubble(
66+
Player player,
67+
@Named("cubeLoc") @SuggestWith(CubeLocationAutoComplete.class) String cubeLoc
68+
) {
69+
Cube cube = getInputCubes(player, cubeLoc);
70+
71+
if (cube == null) return;
72+
73+
if (cube.particuleBubbleTask != null) {
74+
cube.particuleBubbleTask.cancel();
75+
cube.particuleBubbleTask = null;
76+
}
77+
78+
if (cube.corruptedBubbleTask != null) {
79+
cube.corruptedBubbleTask.cancel();
80+
cube.corruptedBubbleTask = null;
81+
}
82+
MessagesManager.sendMessage(player, Component.text("Bulle corrompue arreté"), Prefix.STAFF, MessageType.SUCCESS, false);
83+
}
84+
5085
@Subcommand("reproduce")
5186
@CommandPermission("omc.admins.commands.cube.reproduce")
5287
public void reproduceCube(

src/main/java/fr/openmc/core/features/cube/ReproductionTask.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ public void run() {
4040
world.playSound(babyOrigin, Sound.ENTITY_ENDER_DRAGON_GROWL, 0.3f, 0.2f);
4141
world.spawnParticle(Particle.EXPLOSION_EMITTER, babyCube.getCenter(), 3, 1, 1, 1, 0);
4242

43+
for (int i = 0; i <= 10; i++) {
44+
world.strikeLightningEffect(babyCube.getCenter());
45+
}
46+
4347
MultiBlockManager.register(babyCube);
4448
cancel();
4549
parent.reproductionTask = null;

src/main/java/fr/openmc/core/features/friend/FriendCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public void listCommand(
164164
.color(isOnline ? NamedTextColor.GREEN : NamedTextColor.YELLOW)
165165
.decoration(TextDecoration.BOLD, isOnline))
166166
.hoverEvent(HoverEvent.showText(
167-
Component.text(7Vile : §e" + (city != null ? city.getName() : "Aucune") +
167+
Component.text(7Ville : §e" + (city != null ? city.getName() : "Aucune") +
168168
"\n§7Argent : §e" + formattedMoney +
169169
"\n§7Statut : " + (isOnline ? "§aEn ligne" : "§cHors ligne")
170170
)))

0 commit comments

Comments
 (0)