This commit is contained in:
Luca
2021-11-23 19:06:20 +01:00
parent 9209b3e5cc
commit c63f42afd9
7 changed files with 93 additions and 26 deletions

View File

@ -3,17 +3,18 @@ package rip.tilly.bedwars.game;
import io.netty.util.internal.ConcurrentSet;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.Bukkit;
import net.minecraft.server.v1_8_R3.WorldServer;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
import org.bukkit.inventory.ItemStack;
import org.github.paperspigot.Title;
import rip.tilly.bedwars.BedWars;
import rip.tilly.bedwars.customvillager.CustomVillager;
import rip.tilly.bedwars.game.arena.Arena;
import rip.tilly.bedwars.game.arena.CopiedArena;
import rip.tilly.bedwars.generators.Generator;
@ -22,8 +23,8 @@ import rip.tilly.bedwars.generators.GeneratorType;
import rip.tilly.bedwars.utils.CC;
import rip.tilly.bedwars.utils.CustomLocation;
import rip.tilly.bedwars.utils.TimeUtils;
import java.util.*;
import java.util.List;
import java.util.stream.Stream;
@Getter
@ -38,6 +39,8 @@ public class Game {
private final Set<Integer> runnables = new HashSet<>();
private final Set<ItemStack> droppedItems = new ConcurrentSet<>();
private final Set<CustomVillager> villagers = new ConcurrentSet<>();
private final List<GameTeam> teams;
private final Arena arena;
private final GameType gameType;
@ -223,33 +226,33 @@ public class Game {
return false;
}
public void tick(int amount) {
public void tick(int amount, Game game) {
if (this.secondsToMinutes(amount) == 5D) {
Bukkit.broadcastMessage(CC.translate("&bDiamond &egenerators have been upgraded to &bTier II"));
game.broadcast("&bDiamond &egenerators have been upgraded to &bTier II&e.");
this.diamondGeneratorTier = GeneratorTier.TWO;
}
if (this.secondsToMinutes(amount) == 8D) {
Bukkit.broadcastMessage(CC.translate("&aEmerald &egenerators have been upgraded to &bTier II"));
game.broadcast("&aEmerald &egenerators have been upgraded to &bTier II&e.");
this.emeraldGeneratorTier = GeneratorTier.TWO;
}
if (this.secondsToMinutes(amount) == 10D) {
Bukkit.broadcastMessage(CC.translate("&bDiamond &egenerators have been upgraded to &bTier II"));
game.broadcast("&bDiamond &egenerators have been upgraded to &bTier III&e.");
this.diamondGeneratorTier = GeneratorTier.THREE;
}
if (this.secondsToMinutes(amount) == 12D) {
Bukkit.broadcastMessage(CC.translate("&aEmerald &egenerators have been upgraded to &bTier II"));
game.broadcast("&aEmerald &egenerators have been upgraded to &bTier III&e.");
this.emeraldGeneratorTier = GeneratorTier.THREE;
}
if (this.secondsToMinutes(amount) == 15D) {
Bukkit.broadcastMessage(CC.translate("&bDiamond &egenerators have been upgraded to &bTier II"));
game.broadcast("&bDiamond &egenerators have been upgraded to &bTier IV&e.");
this.diamondGeneratorTier = GeneratorTier.FOUR;
}
@ -281,21 +284,28 @@ public class Game {
return seconds / 60D;
}
public void spawnVillagers() {
Villager teamAShopVillager = this.arena.getTeamAshop().toBukkitLocation().getWorld().spawn(this.arena.getTeamAshop().toBukkitLocation(), Villager.class);
teamAShopVillager.setCustomName(CC.translate("&aItem Shop"));
teamAShopVillager.setCustomNameVisible(true);
public void spawnVillagers(CopiedArena copiedArena) {
Location teamAshopLoc = copiedArena.getTeamAshop().toBukkitLocation();
WorldServer worldServer = ((CraftWorld) teamAshopLoc.getWorld()).getHandle();
Villager teamBShopVillager = this.arena.getTeamBshop().toBukkitLocation().getWorld().spawn(this.arena.getTeamBshop().toBukkitLocation(), Villager.class);
teamBShopVillager.setCustomName(CC.translate("&aItem Shop"));
teamBShopVillager.setCustomNameVisible(true);
CustomVillager teamAshop = new CustomVillager(worldServer, "&aItem Shop");
teamAshop.setLocation(teamAshopLoc.getBlockX(), teamAshopLoc.getBlockY(), teamAshopLoc.getBlockZ(), teamAshopLoc.getYaw(), teamAshopLoc.getPitch());
Villager teamAUpgradesVillager = this.arena.getTeamAupgrades().toBukkitLocation().getWorld().spawn(this.arena.getTeamAupgrades().toBukkitLocation(), Villager.class);
teamAUpgradesVillager.setCustomName(CC.translate("&aUpgrades Shop"));
teamAUpgradesVillager.setCustomNameVisible(true);
Location teamBshopLoc = copiedArena.getTeamBshop().toBukkitLocation();
CustomVillager teamBshop = new CustomVillager(worldServer, "&aItem Shop");
teamBshop.setLocation(teamBshopLoc.getBlockX(), teamBshopLoc.getBlockY(), teamBshopLoc.getBlockZ(), teamBshopLoc.getYaw(), teamBshopLoc.getPitch());
Villager teamBUpgradesVillager = this.arena.getTeamBupgrades().toBukkitLocation().getWorld().spawn(this.arena.getTeamBupgrades().toBukkitLocation(), Villager.class);
teamBUpgradesVillager.setCustomName(CC.translate("&aUpgrades Shop"));
teamBUpgradesVillager.setCustomNameVisible(true);
Location teamAupgradeLoc = copiedArena.getTeamAupgrades().toBukkitLocation();
CustomVillager teamAupgrade = new CustomVillager(worldServer, "&aUpgrades Shop");
teamAupgrade.setLocation(teamAupgradeLoc.getBlockX(), teamAupgradeLoc.getBlockY(), teamAupgradeLoc.getBlockZ(), teamAupgradeLoc.getYaw(), teamAupgradeLoc.getPitch());
Location teamBupgradeLoc = copiedArena.getTeamAupgrades().toBukkitLocation();
CustomVillager teamBupgrade = new CustomVillager(worldServer, "&aUpgrades Shop");
teamBupgrade.setLocation(teamBupgradeLoc.getBlockX(), teamBupgradeLoc.getBlockY(), teamBupgradeLoc.getBlockZ(), teamBupgradeLoc.getYaw(), teamBupgradeLoc.getPitch());
this.villagers.add(teamAshop);
this.villagers.add(teamBshop);
this.villagers.add(teamAupgrade);
this.villagers.add(teamBupgrade);
}
}