This commit is contained in:
Trixkz 2021-11-23 10:14:40 -05:00
parent d2e3c65882
commit c109219759
8 changed files with 270 additions and 1 deletions

View File

@ -46,6 +46,10 @@ public class ArenaCommand implements CommandExecutor {
player.sendMessage(CC.translate("&7⚫ &9/arena setTeamGenerator <arena> &7- &eSet the team's generator"));
player.sendMessage(CC.translate("&7⚫ &9/arena setDiamondGenerator <arena> &7- &eSet the diamond generator"));
player.sendMessage(CC.translate("&7⚫ &9/arena setEmeraldGenerator <arena> &7- &eSet the emerald generator"));
player.sendMessage(CC.translate("&7⚫ &9/arena setTeamAShop <arena> &7- &eSet team A shop"));
player.sendMessage(CC.translate("&7⚫ &9/arena setTeamBShop <arena> &7- &eSet team B shop"));
player.sendMessage(CC.translate("&7⚫ &9/arena setTeamAUpgrades <arena> &7- &eSet team A upgrades"));
player.sendMessage(CC.translate("&7⚫ &9/arena setTeamBUpgrades <arena> &7- &eSet team B upgrades"));
player.sendMessage(CC.translate("&7⚫ &9/arena list &7- &eLook at all of the arenas"));
player.sendMessage(CC.translate("&7⚫ &9/arena save &7- &eSave all of the arenas"));
player.sendMessage(CC.translate("&7⚫ &9/arena manage &7- &eOpen the arena manage menu"));
@ -125,6 +129,22 @@ public class ArenaCommand implements CommandExecutor {
case "setemeraldgenerator":
new SetEmeraldGeneratorCommand().executeAs(sender, cmd, label, args);
break;
case "setteamashop":
new SetTeamAShopCommand().executeAs(sender, cmd, label, args);
break;
case "setteambshop":
new SetTeamBShopCommand().executeAs(sender, cmd, label, args);
break;
case "setteamaupgrades":
new SetTeamAUpgradesCommand().executeAs(sender, cmd, label, args);
break;
case "setteambupgrades":
new SetTeamBUpgradesCommand().executeAs(sender, cmd, label, args);
break;
case "list":
player.sendMessage(CC.translate("&9&lArenas List &7(&eTotal: " + this.main.getArenaManager().getArenas().size() + "&7)"));

View File

@ -0,0 +1,48 @@
package rip.tilly.bedwars.commands.arena;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import rip.tilly.bedwars.BedWars;
import rip.tilly.bedwars.commands.BaseCommand;
import rip.tilly.bedwars.game.arena.Arena;
import rip.tilly.bedwars.utils.CC;
import rip.tilly.bedwars.utils.CustomLocation;
import java.util.ArrayList;
import java.util.List;
public class SetTeamAShopCommand extends BaseCommand {
private BedWars main = BedWars.getInstance();
@Override
public void executeAs(CommandSender sender, Command cmd, String label, String[] args) {
Player player = (Player) sender;
if (args.length == 0) {
player.sendMessage(CC.translate("&cError: no arena found! /arena <args> <arena>"));
return;
}
Arena arena = this.main.getArenaManager().getArena(args[1]);
if (arena != null) {
Location location = player.getLocation();
arena.setTeamAshop(CustomLocation.fromBukkitLocation(location));
player.sendMessage(CC.translate("&aSuccessfully set the Team A shop position for the arena called &a&l" + args[1]));
} else {
player.sendMessage(CC.translate("&cThis arena does not exist"));
}
}
@Override
public List<String> getTabCompletions(CommandSender sender, Command cmd, String label, String[] args) {
List<String> tabCompletions = new ArrayList<String>();
return tabCompletions;
}
}

View File

@ -0,0 +1,48 @@
package rip.tilly.bedwars.commands.arena;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import rip.tilly.bedwars.BedWars;
import rip.tilly.bedwars.commands.BaseCommand;
import rip.tilly.bedwars.game.arena.Arena;
import rip.tilly.bedwars.utils.CC;
import rip.tilly.bedwars.utils.CustomLocation;
import java.util.ArrayList;
import java.util.List;
public class SetTeamAUpgradesCommand extends BaseCommand {
private BedWars main = BedWars.getInstance();
@Override
public void executeAs(CommandSender sender, Command cmd, String label, String[] args) {
Player player = (Player) sender;
if (args.length == 0) {
player.sendMessage(CC.translate("&cError: no arena found! /arena <args> <arena>"));
return;
}
Arena arena = this.main.getArenaManager().getArena(args[1]);
if (arena != null) {
Location location = player.getLocation();
arena.setTeamAupgrades(CustomLocation.fromBukkitLocation(location));
player.sendMessage(CC.translate("&aSuccessfully set the Team A upgrades position for the arena called &a&l" + args[1]));
} else {
player.sendMessage(CC.translate("&cThis arena does not exist"));
}
}
@Override
public List<String> getTabCompletions(CommandSender sender, Command cmd, String label, String[] args) {
List<String> tabCompletions = new ArrayList<String>();
return tabCompletions;
}
}

View File

@ -0,0 +1,48 @@
package rip.tilly.bedwars.commands.arena;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import rip.tilly.bedwars.BedWars;
import rip.tilly.bedwars.commands.BaseCommand;
import rip.tilly.bedwars.game.arena.Arena;
import rip.tilly.bedwars.utils.CC;
import rip.tilly.bedwars.utils.CustomLocation;
import java.util.ArrayList;
import java.util.List;
public class SetTeamBShopCommand extends BaseCommand {
private BedWars main = BedWars.getInstance();
@Override
public void executeAs(CommandSender sender, Command cmd, String label, String[] args) {
Player player = (Player) sender;
if (args.length == 0) {
player.sendMessage(CC.translate("&cError: no arena found! /arena <args> <arena>"));
return;
}
Arena arena = this.main.getArenaManager().getArena(args[1]);
if (arena != null) {
Location location = player.getLocation();
arena.setTeamBshop(CustomLocation.fromBukkitLocation(location));
player.sendMessage(CC.translate("&aSuccessfully set the Team B shop position for the arena called &a&l" + args[1]));
} else {
player.sendMessage(CC.translate("&cThis arena does not exist"));
}
}
@Override
public List<String> getTabCompletions(CommandSender sender, Command cmd, String label, String[] args) {
List<String> tabCompletions = new ArrayList<String>();
return tabCompletions;
}
}

View File

@ -0,0 +1,48 @@
package rip.tilly.bedwars.commands.arena;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import rip.tilly.bedwars.BedWars;
import rip.tilly.bedwars.commands.BaseCommand;
import rip.tilly.bedwars.game.arena.Arena;
import rip.tilly.bedwars.utils.CC;
import rip.tilly.bedwars.utils.CustomLocation;
import java.util.ArrayList;
import java.util.List;
public class SetTeamBUpgradesCommand extends BaseCommand {
private BedWars main = BedWars.getInstance();
@Override
public void executeAs(CommandSender sender, Command cmd, String label, String[] args) {
Player player = (Player) sender;
if (args.length == 0) {
player.sendMessage(CC.translate("&cError: no arena found! /arena <args> <arena>"));
return;
}
Arena arena = this.main.getArenaManager().getArena(args[1]);
if (arena != null) {
Location location = player.getLocation();
arena.setTeamBupgrades(CustomLocation.fromBukkitLocation(location));
player.sendMessage(CC.translate("&aSuccessfully set the Team B upgrades position for the arena called &a&l" + args[1]));
} else {
player.sendMessage(CC.translate("&cThis arena does not exist"));
}
}
@Override
public List<String> getTabCompletions(CommandSender sender, Command cmd, String label, String[] args) {
List<String> tabCompletions = new ArrayList<String>();
return tabCompletions;
}
}

View File

@ -10,6 +10,7 @@ import org.bukkit.Sound;
import org.bukkit.block.Block;
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;
@ -279,4 +280,22 @@ public class Game {
public double secondsToMinutes(int seconds) {
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);
Villager teamBShopVillager = this.arena.getTeamBshop().toBukkitLocation().getWorld().spawn(this.arena.getTeamBshop().toBukkitLocation(), Villager.class);
teamBShopVillager.setCustomName(CC.translate("&aItem Shop"));
teamBShopVillager.setCustomNameVisible(true);
Villager teamAUpgradesVillager = this.arena.getTeamAupgrades().toBukkitLocation().getWorld().spawn(this.arena.getTeamAupgrades().toBukkitLocation(), Villager.class);
teamAUpgradesVillager.setCustomName(CC.translate("&aUpgrades Shop"));
teamAUpgradesVillager.setCustomNameVisible(true);
Villager teamBUpgradesVillager = this.arena.getTeamBupgrades().toBukkitLocation().getWorld().spawn(this.arena.getTeamBupgrades().toBukkitLocation(), Villager.class);
teamBUpgradesVillager.setCustomName(CC.translate("&aUpgrades Shop"));
teamBUpgradesVillager.setCustomNameVisible(true);
}
}

View File

@ -2,10 +2,12 @@ package rip.tilly.bedwars.listeners;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.TrapDoor;
@ -16,6 +18,7 @@ import rip.tilly.bedwars.menus.settings.SettingsMenu;
import rip.tilly.bedwars.menus.shop.blocks.BlocksMenu;
import rip.tilly.bedwars.playerdata.PlayerData;
import rip.tilly.bedwars.playerdata.PlayerState;
import rip.tilly.bedwars.utils.CC;
public class InteractListener implements Listener {
@ -128,4 +131,38 @@ public class InteractListener implements Listener {
break;
}
}
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
Player player = event.getPlayer();
if (event.getRightClicked() instanceof ArmorStand) {
event.setCancelled(true);
}
String name = event.getRightClicked().getCustomName();
if (name == null) {
return;
}
switch (name) {
case "&aItem Shop":
event.setCancelled(true);
// open item shop gui
player.sendMessage(CC.translate("&aItem shop menu opened"));
break;
case "&aUpgrades Shop":
event.setCancelled(true);
// open upgrades shop gui
player.sendMessage(CC.translate("&aUpgrades shop menu opened"));
break;
}
}
}

View File

@ -37,8 +37,8 @@ public class GameStartListener implements Listener {
return;
}
CopiedArena currentArena = game.getCopiedArena();
for (CustomLocation location : currentArena.getTeamGenerators()) {
Generator teamGen1 = new Generator(location.toBukkitLocation(), GeneratorType.IRON, true, game);
teamGen1.setActivated(true);
@ -65,6 +65,7 @@ public class GameStartListener implements Listener {
game.getActivatedGenerators().add(emeGen);
}
game.spawnVillagers();
Set<Player> gamePlayers = new HashSet<>();
game.getTeams().forEach(team -> team.playingPlayers().forEach(player -> {