This commit is contained in:
Luca 2021-11-24 18:52:53 +01:00
parent f210b41f2e
commit 9301730272
6 changed files with 210 additions and 1 deletions

View File

@ -0,0 +1,8 @@
package rip.tilly.bedwars.customitems.popuptower;
public class CheckRotation {
public CheckRotation(Double d) {
}
}

View File

@ -1,8 +1,27 @@
package rip.tilly.bedwars.customitems.popuptower;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import rip.tilly.bedwars.BedWars;
import rip.tilly.bedwars.playerdata.PlayerTeam;
public class PlaceTower {
public PlaceTower(Block block, String xyz, )
public PlaceTower(Block block, String xyz, PlayerTeam playerTeam, Player player, boolean ladder, int ladderData) {
int x = Integer.parseInt(xyz.split(", ")[0]);
int y = Integer.parseInt(xyz.split(", ")[1]);
int z = Integer.parseInt(xyz.split(", ")[2]);
Block relative = block.getRelative(x, y, z);
if (relative.getType() == Material.AIR) {
if (!ladder) {
relative.setType(Material.WOOL);
relative.setData((byte) playerTeam.getColorData());
} else {
relative.setType(Material.LADDER);
relative.setData((byte) ladderData);
}
BedWars.getInstance().getGameManager().getGame(player.getUniqueId()).addPlacedBlock(relative);
}
}
}

View File

@ -0,0 +1,4 @@
package rip.tilly.bedwars.customitems.popuptower.types;
public class TowerEast {
}

View File

@ -0,0 +1,4 @@
package rip.tilly.bedwars.customitems.popuptower.types;
public class TowerNorth {
}

View File

@ -0,0 +1,4 @@
package rip.tilly.bedwars.customitems.popuptower.types;
public class TowerSouth {
}

View File

@ -0,0 +1,170 @@
package rip.tilly.bedwars.customitems.popuptower.types;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitTask;
import rip.tilly.bedwars.BedWars;
import rip.tilly.bedwars.customitems.popuptower.PlaceTower;
import rip.tilly.bedwars.playerdata.PlayerTeam;
import java.util.ArrayList;
import java.util.List;
public class TowerWest {
private BukkitTask bukkitTask;
public TowerWest(Location location, Block block, PlayerTeam playerTeam, Player player) {
ItemStack hand = player.getItemInHand();
if (hand.getAmount() == 1) {
hand.setType(Material.AIR);
player.setItemInHand(hand);
} else {
hand.setAmount(hand.getAmount() - 1);
}
List<String> locList = new ArrayList<>();
locList.add("-2, 0, 1");
locList.add("-1, 0, 2");
locList.add("0, 0, 2");
locList.add("1, 0, 1");
locList.add("1, 0, 0");
locList.add("1, 0, -1");
locList.add("0, 0, -2");
locList.add("-1, 0, -2");
locList.add("-2, 0, -1");
locList.add("0, 0, 0, ladder4");
locList.add("-2, 1, 1");
locList.add("-1, 1, 2");
locList.add("0, 1, 2");
locList.add("1, 1, 1");
locList.add("1, 1, 0");
locList.add("1, 1, -1");
locList.add("0, 1, -2");
locList.add("-1, 1, -2");
locList.add("-2, 1, -1");
locList.add("0, 1, 0, ladder4");
locList.add("-2, 2, 1");
locList.add("-1, 2, 2");
locList.add("0, 2, 2");
locList.add("1, 2, 1");
locList.add("1, 2, 0");
locList.add("1, 2, -1");
locList.add("0, 2, -2");
locList.add("-1, 2, -2");
locList.add("-2, 2, -1");
locList.add("0, 2, 0, ladder4");
locList.add("-2, 3, 0");
locList.add("-2, 3, 1");
locList.add("-1, 3, 2");
locList.add("0, 3, 2");
locList.add("1, 3, 1");
locList.add("1, 3, 0");
locList.add("1, 3, -1");
locList.add("0, 3, -2");
locList.add("-1, 3, -2");
locList.add("-2, 3, -1");
locList.add("0, 3, 0, ladder4");
locList.add("-2, 4, 0");
locList.add("-2, 4, 1");
locList.add("-1, 4, 2");
locList.add("0, 4, 2");
locList.add("1, 4, 1");
locList.add("1, 4, 0");
locList.add("1, 4, -1");
locList.add("0, 4, -2");
locList.add("-1, 4, -2");
locList.add("-2, 4, -1");
locList.add("0, 4, 0, ladder4");
locList.add("1, 5, 2");
locList.add("0, 5, 2");
locList.add("-1, 5, 2");
locList.add("-2, 5, 2");
locList.add("1, 5, 1");
locList.add("0, 5, 1");
locList.add("-1, 5, 1");
locList.add("-2, 5, 1");
locList.add("1, 5, 0");
locList.add("-1, 5, 0");
locList.add("-2, 5, 0");
locList.add("1, 5, -1");
locList.add("0, 5, -1");
locList.add("-1, 5, -1");
locList.add("-2, 5, -1");
locList.add("0, 5, 0, ladder4");
locList.add("1, 5, -2");
locList.add("0, 5, -2");
locList.add("-1, 5, -2");
locList.add("-2, 5, -2");
locList.add("-2, 5, 3");
locList.add("-2, 6, 3");
locList.add("-2, 7, 3");
locList.add("-1, 6, 3");
locList.add("0, 6, 3");
locList.add("1, 5, 3");
locList.add("1, 6, 3");
locList.add("1, 7, 3");
locList.add("2, 5, 2");
locList.add("2, 6, 2");
locList.add("2, 7, 2");
locList.add("2, 6, 1");
locList.add("2, 5, 0");
locList.add("2, 6, 0");
locList.add("2, 7, 0");
locList.add("2, 6, -1");
locList.add("2, 5, -2");
locList.add("2, 6, -2");
locList.add("2, 7, -2");
locList.add("-2, 5, -3");
locList.add("-2, 6, -3");
locList.add("-2, 7, -3");
locList.add("-1, 6, -3");
locList.add("0, 6, -3");
locList.add("1, 5, -3");
locList.add("1, 6, -3");
locList.add("1, 7, -3");
locList.add("-3, 5, 2");
locList.add("-3, 6, 2");
locList.add("-3, 7, 2");
locList.add("-3, 6, 1");
locList.add("-3, 5, 0");
locList.add("-3, 6, 0");
locList.add("-3, 7, 0");
locList.add("-3, 6, -1");
locList.add("-3, 5, -2");
locList.add("-3, 6, -2");
locList.add("-3, 7, -2");
int[] i = { 0 };
this.bukkitTask = Bukkit.getScheduler().runTaskTimer(BedWars.getInstance(), () -> {
location.getWorld().playSound(location, Sound.CHICKEN_EGG_POP, 1f, 0.5f);
if (locList.size() + 1 == i[0] + 1) {
this.bukkitTask.cancel();
return;
}
String string = locList.get(i[0]);
if (string.contains("ladder")) {
int ladderData = Integer.parseInt(string.split("ladder")[1]);
new PlaceTower(block, string, playerTeam, player, true, ladderData);
} else {
new PlaceTower(block, string, playerTeam, player, false, 0);
}
if (locList.size() + 1 == i[0] + 2) {
this.bukkitTask.cancel();
return;
}
String string2 = locList.get(i[0] + 1);
if (string2.contains("ladder")) {
int ladderData = Integer.parseInt(string2.split("ladder")[1]);
new PlaceTower(block, string2, playerTeam, player, true, ladderData);
} else {
new PlaceTower(block, string2, playerTeam, player, false, 0);
}
i[0] = i[0] + 2;
}, 0, 1);
}
}