Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
iceBear67 committed Dec 30, 2024
1 parent cdc60e0 commit 73e6858
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 40 deletions.
21 changes: 1 addition & 20 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,4 @@ jobs:
# gradle-version: '8.9'
#
# - name: Build with Gradle 8.9
# run: gradle build

dependency-submission:

runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
# See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md
- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
# run: gradle build
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = 'dev.tylerm'
version = '1.8.1a'
version = '1.8.3a'
description = 'Hide and Seek Plugin'
java.sourceCompatibility = JavaVersion.VERSION_21

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/tylerm/khs/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ private List<HiderSkill> loadSkills() {
var display = ItemStacks.of(
Material.WIND_CHARGE,
"&b弹弓",
"&f风弹 x4",
"&f风弹 x2",
"&a砸中别人会很痛。"
);
list.add(new HiderSkill(display, List.of(windCharge)));
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/dev/tylerm/khs/configuration/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class Config {
regenHealth;

public static int
maxPlayers,
minPlayers,
gameLength,
extendPerKill,
Expand Down Expand Up @@ -161,6 +162,7 @@ public static void loadConfig() {
//Lobby
startingSeekerCount = Math.max(1, config.getInt("startingSeekerCount"));
waitTillNoneLeft = config.getBoolean("waitTillNoneLeft");
maxPlayers = config.getInt("maxPlayers");
minPlayers = Math.max(1 + startingSeekerCount + (waitTillNoneLeft ? 0 : 1), config.getInt("minPlayers"));
countdown = Math.max(10, config.getInt("lobby.countdown"));
changeCountdown = Math.max(minPlayers, config.getInt("lobby.changeCountdown"));
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/dev/tylerm/khs/event/DamagedByWindChargeEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package dev.tylerm.khs.event;

import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;

public class DamagedByWindChargeEvent extends Event {
private static final HandlerList HANDLERS = new HandlerList();
private final Player player;

public DamagedByWindChargeEvent(Player player) {
this.player = player;
}

public Player getPlayer() {
return player;
}

public static HandlerList getHandlerList() {
return HANDLERS;
}

@Override
public @NotNull HandlerList getHandlers() {
return HANDLERS;
}
}
19 changes: 19 additions & 0 deletions src/main/java/dev/tylerm/khs/event/GameStartedEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package dev.tylerm.khs.event;

import dev.tylerm.khs.game.util.WinType;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;

public class GameStartedEvent extends Event {
private static final HandlerList HANDLERS = new HandlerList();

public static HandlerList getHandlerList() {
return HANDLERS;
}

@Override
public @NotNull HandlerList getHandlers() {
return HANDLERS;
}
}
28 changes: 28 additions & 0 deletions src/main/java/dev/tylerm/khs/event/HitByBeeBirdEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package dev.tylerm.khs.event;

import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;

public class HitByBeeBirdEvent extends Event {
private static final HandlerList HANDLERS = new HandlerList();
private final Player player;

public HitByBeeBirdEvent(Player player) {
this.player = player;
}

public Player getPlayer() {
return player;
}

public static HandlerList getHandlerList() {
return HANDLERS;
}

@Override
public @NotNull HandlerList getHandlers() {
return HANDLERS;
}
}
2 changes: 2 additions & 0 deletions src/main/java/dev/tylerm/khs/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import dev.tylerm.khs.event.GameEndEvent;
import dev.tylerm.khs.event.GameStartedEvent;
import dev.tylerm.khs.game.events.Glow;
import dev.tylerm.khs.game.events.Taunt;
import dev.tylerm.khs.game.listener.RespawnHandler;
Expand Down Expand Up @@ -288,6 +289,7 @@ private void whileStarting() {
currentMap.getGameSpawn().teleport(player);
}
});
Bukkit.getPluginManager().callEvent(new GameStartedEvent());
} else if (startingTimer == 1) {
message = message("START_COUNTDOWN_LAST").addAmount(startingTimer).toString();
} else {
Expand Down
27 changes: 18 additions & 9 deletions src/main/java/dev/tylerm/khs/game/listener/DamageHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.cryptomorin.xseries.XSound;
import dev.tylerm.khs.Main;
import dev.tylerm.khs.event.DamagedByWindChargeEvent;
import dev.tylerm.khs.event.HitByBeeBirdEvent;
import dev.tylerm.khs.event.PlayerKillEvent;
import dev.tylerm.khs.game.Board;
import dev.tylerm.khs.game.Game;
Expand Down Expand Up @@ -35,24 +37,30 @@ public void onProjectileHit(ProjectileHitEvent event) {
var hitEntity = event.getHitEntity();
var hitBlock = event.getHitBlock();

if(hitBlock != null && directEntity.hasMetadata(CustomItems.OWL_BOW_METADATA_KEY)){
new SpecialArrowTaunt(hitBlock.getLocation().add(0,1,0), 32).runTaskTimer(Main.getInstance(), 0L, 5L);
if (hitBlock != null && directEntity.hasMetadata(CustomItems.OWL_BOW_METADATA_KEY)) {
new SpecialArrowTaunt(hitBlock.getLocation().add(0, 1, 0), 32).runTaskTimer(Main.getInstance(), 0L, 5L);
directEntity.remove();
return;
}

if(hitEntity instanceof Player player){
if(Main.getInstance().getBoard().isHider(player)){
if (hitEntity instanceof Player player) {
if (Main.getInstance().getBoard().isHider(player)) { //todo test
Bukkit.getScheduler().runTaskLater(Main.getInstance(), () -> {
player.setArrowsInBody(0);
}, 10L);
}
if (directEntity instanceof WindCharge) {
if (player != directEntity.getShooter() && player.getHealth() > 6.5) {
player.setHealth(player.getHealth() - 6.5);
//todo: test 风弹伤害
return;
}
directEntity.getNearbyEntities(0.7, 0.7, 0.7).forEach(entity -> {
if (!(entity instanceof Player) || Main.getInstance().getBoard().isSpectator((Player) entity)) {
return;
}
var p = (Player) entity;
if (p != directEntity.getShooter() && p.getHealth() > 6.5) {
p.setHealth(p.getHealth() - 6.5);
Bukkit.getPluginManager().callEvent(new DamagedByWindChargeEvent(p));
//todo: test 风弹伤害
}
});
}
}
}
Expand Down Expand Up @@ -87,6 +95,7 @@ else if (((EntityDamageByEntityEvent) event).getDamager() instanceof Projectile)
new SpecialArrowTaunt(player.getLocation(), 32)
.runTaskTimer(Main.getInstance(), 0L, 5L);
event.setDamage(0);
Bukkit.getPluginManager().callEvent(new HitByBeeBirdEvent(player));
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ private void onPlayerInteractGame(ItemStack temp, PlayerInteractEvent event) {
switch (CustomItems.getId(temp)) {
case CustomItems.BLOCK_CHANGER -> {
var game = Main.getInstance().getGame();
var selectableBlocks = game.getCurrentMap().getBlockHunt();
// find a block
var hiders = Main.getInstance().getBoard().getHiders();
if (hiders.size() == 1) {
Expand All @@ -106,7 +105,7 @@ private void onPlayerInteractGame(ItemStack temp, PlayerInteractEvent event) {
text = TextComponent.fromLegacy(ChatColor.LIGHT_PURPLE + "你现在变成了 ");
text.addExtra(new TranslatableComponent(targetDisguise.getMaterial().getBlockTranslationKey()));
text.addExtra("!");
player.spigot().sendMessage(text); //todo test 换装
player.spigot().sendMessage(text);

player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 2 * 20, 1));
selected.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 2 * 20, 1));
Expand Down Expand Up @@ -145,7 +144,6 @@ private void onPlayerInteractGame(ItemStack temp, PlayerInteractEvent event) {
));
player.sendMessage(ChatColor.RED+"你被加速了,快跑!");
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public void onPlayerJoin(PlayerJoinEvent event) {
return;
}
Main.getInstance().getGame().join(event.getPlayer());
if(Main.getInstance().getBoard().getPlayers().size() >= lobbyMax){
Main.getInstance().getGame().start();
}
} else if (teleportToExit) {
if (
event.getPlayer().getWorld().getName().equals(Main.getInstance().getGame().getCurrentMap().getLobbyName()) ||
Expand Down
18 changes: 12 additions & 6 deletions src/main/java/dev/tylerm/khs/task/AnnounceBlockTypeTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,27 @@
import net.md_5.bungee.api.chat.TranslatableComponent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;

import java.util.concurrent.ThreadLocalRandom;

public class AnnounceBlockTypeTask extends BukkitRunnable {
private static BaseComponent EMPTY = TextComponent.fromLegacy("");

@Override
public void run() {
if(Main.getInstance().getGame().getStatus() != Status.PLAYING) return;
if (Main.getInstance().getGame().getStatus() != Status.PLAYING) return;
BaseComponent v;
if(Main.getInstance().getBoard().getHiders().isEmpty()){
if (Main.getInstance().getBoard().getHiders().isEmpty()) {
v = EMPTY;
}else{
var first = Main.getInstance().getDisguiser().getDisguise(Main.getInstance().getBoard().getHiders().getFirst());
v = new TranslatableComponent(first.getMaterial().getBlockTranslationKey());
} else {
var hiders = Main.getInstance().getBoard().getHiders();
Player randomHider = hiders.get(ThreadLocalRandom.current().nextInt(hiders.size()));
var disguise = Main.getInstance().getDisguiser().getDisguise(randomHider);
v = new TranslatableComponent(disguise.getMaterial().getBlockTranslationKey());
}
var text = TextComponent.fromLegacy(ChatColor.GREEN+" TIP: "+ChatColor.WHITE+"场上有一个");
var text = TextComponent.fromLegacy(ChatColor.GREEN + " TIP: " + ChatColor.WHITE + "场上有一个 ");
text.addExtra(v);
text.addExtra(" 方块!");
Bukkit.spigot().broadcast(text);
Expand Down

0 comments on commit 73e6858

Please sign in to comment.