Skip to content

Commit

Permalink
Fix the block changer skill
Browse files Browse the repository at this point in the history
  • Loading branch information
iceBear67 committed Oct 22, 2024
1 parent bd472de commit 906521a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
14 changes: 4 additions & 10 deletions src/main/java/dev/tylerm/khs/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,16 +310,10 @@ private void whileStarting() {

private void whilePlaying() {
for (Player hider : board.getHiders()) {
int distance = 100, temp = 100;
double distance = 100;
for (Player seeker : board.getSeekers()) {
try {
temp = (int) hider.getLocation().distance(seeker.getLocation());
} catch (Exception e) {
//Players in different worlds, NOT OK!!!
}
if (distance > temp) {
distance = temp;
}
if (hider.getLocation().getWorld() != seeker.getLocation().getWorld()) continue;
distance = Math.min(distance, hider.getLocation().distanceSquared(seeker.getLocation()));
}
if (seekerPing) switch (gameTick % 10) {
case 0:
Expand All @@ -339,7 +333,7 @@ private void whilePlaying() {
break;
}
}
if (gameTick % 10 == 0 && gameTimer < whenToHighlight ) {
if (gameTick % 10 == 0 && gameTimer < whenToHighlight) {
for (Player seeker : board.getSeekers()) {
for (Entity nearbyEntity : seeker.getNearbyEntities(8, 2, 8)) {
if (nearbyEntity instanceof Player player) {
Expand Down
24 changes: 15 additions & 9 deletions src/main/java/dev/tylerm/khs/game/listener/InteractHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import dev.tylerm.khs.Main;
import dev.tylerm.khs.game.Board;
import dev.tylerm.khs.game.util.Status;
import dev.tylerm.khs.gui.BlockPickerGUI;
import dev.tylerm.khs.item.CustomItems;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
Expand All @@ -25,7 +24,9 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;

import static dev.tylerm.khs.configuration.Config.*;
import static dev.tylerm.khs.configuration.Localization.message;
Expand Down Expand Up @@ -79,11 +80,16 @@ private void onPlayerInteractGame(ItemStack temp, PlayerInteractEvent event) {
switch (CustomItems.getId(temp)) {
case CustomItems.BLOCK_CHANGER -> {
player.getInventory().remove(temp);
new BlockPickerGUI(
event.getPlayer(),
Main.getInstance().getGame().getCurrentMap(),
() -> {
});
var game = Main.getInstance().getGame();
var selectableBlocks = game.getCurrentMap().getBlockHunt();
var rand = selectableBlocks.get(ThreadLocalRandom.current().nextInt(selectableBlocks.size()));
Main.getInstance().getDisguiser().disguise(player ,rand, game.getCurrentMap());
}
case CustomItems.BLINDNESS_WAND -> {
player.getInventory().remove(temp);
for (Player seeker : Main.getInstance().getBoard().getSeekers()) {
seeker.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 6 * 20, 2));
}
}
case CustomItems.SEEKER_VISUALIZER -> {
var glow = Main.getInstance().getGame().getGlow();
Expand All @@ -101,14 +107,14 @@ private void onPlayerInteractGame(ItemStack temp, PlayerInteractEvent event) {
if (p != null)
glow.setGlow(user, p, false);
}
}, 3 * 20);
}, 5 * 20);
}
case CustomItems.SPEED_POTION -> {
temp.setAmount(temp.getAmount() - 1);
player.addPotionEffect(new PotionEffect(
PotionEffectType.SPEED,
20 * 5,
3
20 * 6,
4
));
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/dev/tylerm/khs/item/CustomItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class CustomItems {
public static final int SPEED_POTION = 10;
public static final int BLOCK_CHANGER = 11;
public static final int SEEKER_VISUALIZER = 12;
public static final int BLINDNESS_WAND = 13;

public static int getId(ItemStack stack){
if(stack.getItemMeta() == null || !stack.getItemMeta().hasCustomModelData()) return -1;
Expand Down

0 comments on commit 906521a

Please sign in to comment.