Skip to content

Commit

Permalink
Clear arrows after game ends and disallow arrows from being picked up
Browse files Browse the repository at this point in the history
  • Loading branch information
iceBear67 committed Oct 16, 2024
1 parent a4d706c commit beadb4e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/main/java/dev/tylerm/khs/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import dev.tylerm.khs.configuration.Maps;
import dev.tylerm.khs.game.util.WinType;
import org.bukkit.*;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
Expand Down Expand Up @@ -156,6 +157,7 @@ private void stop(WinType type) {
Main.getInstance().getDatabase().getGameData().addWins(board, players, winners, board.getHiderKills(), board.getHiderDeaths(), board.getSeekerKills(), board.getSeekerDeaths(), type);
}
Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getInstance(), this::end, endGameDelay * 20);
Bukkit.getWorld(currentMap.getGameSpawn().getWorld()).getEntitiesByClass(Arrow.class).forEach(Entity::remove);
}

public void end() {
Expand Down Expand Up @@ -339,8 +341,8 @@ private void whilePlaying() {
if (gameTick % 10 == 0 && gameTick / 10 < whenToHighlight * 20) {
for (Player seeker : board.getSeekers()) {
for (Entity nearbyEntity : seeker.getNearbyEntities(2, 2, 2)) {
if(nearbyEntity instanceof Player player){
if(board.isHider(player)){
if (nearbyEntity instanceof Player player) {
if (board.isHider(player)) {
heartbeatSound.play(player.getLocation());
player.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, 20, 1));
}
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/dev/tylerm/khs/game/listener/PlayerHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerPickupArrowEvent;
import org.bukkit.inventory.ItemStack;

import static dev.tylerm.khs.configuration.Config.dropItems;
Expand Down Expand Up @@ -53,4 +54,11 @@ public void onItemSpawn(ItemSpawnEvent event){
event.setCancelled(true);
}

@EventHandler
public void onArrowPickup(PlayerPickupArrowEvent event){
if (Main.getInstance().getGame().getStatus() == Status.PLAYING) {
event.setCancelled(true);
}
}

}
11 changes: 5 additions & 6 deletions src/main/resources/items.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ items:
material: BOW
amount: 1
enchantments:
infinity: 1
power: 2
power: 3
name: '&c寻找者之弓'
unbreakable: true
'2':
material: ARROW
amount: 1
amount: 16
'helmet':
material: LEATHER_HELMET
'chestplate':
Expand Down Expand Up @@ -57,19 +56,19 @@ items:
feather_falling: 1
effects:
seeker:
'1':
'0':
type: SPEED
duration: 1000000
amplifier: 2
ambient: false
particles: false
'4':
'1':
type: WATER_BREATHING
duration: 1000000
amplifier: 10
ambient: false
particles: false
'5':
'2':
type: DOLPHINS_GRACE
duration: 1000000
amplifier: 1
Expand Down

0 comments on commit beadb4e

Please sign in to comment.