Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
BuggyAl committed Aug 29, 2023
1 parent c8e6388 commit 38981bf
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 53 deletions.
2 changes: 1 addition & 1 deletion src/main/java/me/buggyal/chaos/Chaos.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public final class Chaos extends JavaPlugin {

public static final boolean DEV_MODE = true;
public static final boolean DEV_MODE = false;

private static Chaos instance;

Expand Down
12 changes: 9 additions & 3 deletions src/main/java/me/buggyal/chaos/ChaosManager.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package me.buggyal.chaos;

import me.buggyal.chaos.chaos.Nuke;
import me.buggyal.chaos.chaos.TrollResourcePack;
import me.buggyal.chaos.util.Chat;
import org.bukkit.GameMode;
import org.bukkit.entity.EntityType;
Expand All @@ -10,6 +9,7 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.scheduler.BukkitRunnable;
import org.reflections.Reflections;

Expand Down Expand Up @@ -39,7 +39,6 @@ public static void beginChaos() {
// throw new RuntimeException(e);
// }


Reflections reflections = new Reflections(Chaos.getInstance().getClass().getPackage().getName());
for (Class<?> clazz : reflections.getSubTypesOf(ChaosEvent.class)) {
try {
Expand All @@ -62,7 +61,7 @@ public static void beginChaos() {
ChaosEvent event = chaosEvents.get(random.nextInt(chaosEvents.size()));
Chat.sendConsoleMessage("&6[Chaos] &cRunning event: " + event.getClass().getSimpleName());
for (Player player : Chaos.getInstance().getServer().getOnlinePlayers()) {
if (player.getGameMode() == GameMode.SURVIVAL) {
if (player.getGameMode() == GameMode.SURVIVAL && !isVanished(player)) {
event.run(player);
}
}
Expand All @@ -75,6 +74,13 @@ public static void beginChaos() {

}

private static boolean isVanished(Player player) {
for (MetadataValue meta : player.getMetadata("vanished")) {
if (meta.asBoolean()) return true;
}
return false;
}

@EventHandler
public void onBegin(AsyncPlayerChatEvent chatEvent) {
if (chatEvent.getMessage().equalsIgnoreCase("subscribe to wheateneye") && !started) {
Expand Down
67 changes: 67 additions & 0 deletions src/main/java/me/buggyal/chaos/chaos/GoodItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package me.buggyal.chaos.chaos;

import me.buggyal.chaos.ChaosEvent;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

import java.util.ArrayList;
import java.util.List;

public class GoodItem implements ChaosEvent {

private static final List<ItemStack> goodItems = new ArrayList<>();
private static boolean isInit = false;

public static void init() {

ItemStack knockbackStick = new ItemStack(Material.STICK);
knockbackStick.addUnsafeEnchantment(Enchantment.KNOCKBACK, 10);
goodItems.add(knockbackStick);

goodItems.add(new ItemStack(Material.TOTEM_OF_UNDYING));

goodItems.add(new ItemStack(Material.DIAMOND_HELMET));
goodItems.add(new ItemStack(Material.DIAMOND_CHESTPLATE));
goodItems.add(new ItemStack(Material.DIAMOND_LEGGINGS));
goodItems.add(new ItemStack(Material.DIAMOND_BOOTS));
goodItems.add(new ItemStack(Material.DIAMOND_SWORD));
goodItems.add(new ItemStack(Material.DIAMOND_PICKAXE));
goodItems.add(new ItemStack(Material.DIAMOND_AXE));
goodItems.add(new ItemStack(Material.DIAMOND_SHOVEL));

goodItems.add(new ItemStack(Material.GOLDEN_APPLE, 5));

goodItems.add(new ItemStack(Material.ENDER_PEARL, 5));
goodItems.add(new ItemStack(Material.BLAZE_ROD, 3));

goodItems.add(new ItemStack(Material.BOW));
goodItems.add(new ItemStack(Material.ARROW, 64));

goodItems.add(new ItemStack(Material.OBSIDIAN, 4));

goodItems.add(new ItemStack(Material.FLINT_AND_STEEL));

goodItems.add(new ItemStack(Material.ENCHANTED_GOLDEN_APPLE));

goodItems.add(new ItemStack(Material.COOKED_BEEF, 16));

isInit = true;

}


@Override
public void run(Player player) {
if (!isInit) { init(); }
if (goodItems.isEmpty()) {
player.getInventory().addItem(new ItemStack(Material.DEAD_BUSH));
return;
}
ItemStack item = goodItems.get(random.nextInt(goodItems.size()));
goodItems.remove(item);
player.getInventory().addItem(item);
}

}
15 changes: 0 additions & 15 deletions src/main/java/me/buggyal/chaos/chaos/PumpkinHelmet.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/java/me/buggyal/chaos/chaos/RandomEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public boolean isRealMob(EntityType e) {
e != EntityType.INTERACTION && e != EntityType.ITEM_DISPLAY && e != EntityType.ITEM_FRAME &&
e != EntityType.LEASH_HITCH && e != EntityType.MARKER && e != EntityType.PAINTING &&
e != EntityType.PLAYER && e != EntityType.SPECTRAL_ARROW && e != EntityType.SPLASH_POTION &&
e != EntityType.TEXT_DISPLAY && e != EntityType.UNKNOWN;
e != EntityType.TEXT_DISPLAY && e != EntityType.PRIMED_TNT && e != EntityType.UNKNOWN;
}

}
13 changes: 11 additions & 2 deletions src/main/java/me/buggyal/chaos/chaos/RandomHealth.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,23 @@
import me.buggyal.chaos.ChaosEvent;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;

import java.util.Objects;

public class RandomHealth implements ChaosEvent {
public class RandomHealth implements ChaosEvent, Listener {

@Override
public void run(Player player) {
Objects.requireNonNull(player.getAttribute(Attribute.GENERIC_MAX_HEALTH)).setBaseValue(random.nextInt(30) + 1);
Objects.requireNonNull(player.getAttribute(Attribute.GENERIC_MAX_HEALTH)).setBaseValue(random.nextInt(25) + 5);
}

@EventHandler
public void onDeath(PlayerDeathEvent deathEvent) {
Player player = deathEvent.getEntity();
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(20);
}

}
1 change: 1 addition & 0 deletions src/main/java/me/buggyal/chaos/chaos/RandomLaunch.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public void run(Player player) {
velocity.setY(random.nextInt(5));
velocity.setZ(random.nextInt(5) - 2.5);
player.setVelocity(velocity);
player.getInventory().addItem(new ItemStack(Material.WATER_BUCKET));
}

}
30 changes: 0 additions & 30 deletions src/main/java/me/buggyal/chaos/chaos/TrollResourcePack.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ version: '${project.version}'
main: me.buggyal.chaos.Chaos
api-version: 1.20
authors: [BuggyAl]
description: A plugin to challenge
description: A plugin developed for WheatenEye's video.
website: https://github.com/BuggyAl

0 comments on commit 38981bf

Please sign in to comment.