progress???
This commit is contained in:
parent
1aeb0d7504
commit
3022a8b545
4 changed files with 57 additions and 27 deletions
|
|
@ -139,7 +139,7 @@ public class ArenaList {
|
||||||
for(Location block : arena.getBlocks()) { // TODO
|
for(Location block : arena.getBlocks()) { // TODO
|
||||||
arenaBlocks.remove(block);
|
arenaBlocks.remove(block);
|
||||||
}
|
}
|
||||||
arena.removeBlockDisplays(); // TODO
|
arena.removeBlockDisplays();
|
||||||
|
|
||||||
arenas.remove(arena.getName());
|
arenas.remove(arena.getName());
|
||||||
save();
|
save();
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,6 @@ public class MinecleanerArena {
|
||||||
blockDisplays[i] = UUID.fromString(blockDisplay);
|
blockDisplays[i] = UUID.fromString(blockDisplay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blockDisplays = new UUID[widthIndex * widthIndex];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MinecleanerArena(MinecleanerPlugin plugin, String name, Location location, int widthIndex, BlockFace orientation) {
|
public MinecleanerArena(MinecleanerPlugin plugin, String name, Location location, int widthIndex, BlockFace orientation) {
|
||||||
|
|
@ -164,6 +163,11 @@ public class MinecleanerArena {
|
||||||
arenaSection.set("location", this.location);
|
arenaSection.set("location", this.location);
|
||||||
arenaSection.set("fieldwidth", this.widthIndex);
|
arenaSection.set("fieldwidth", this.widthIndex);
|
||||||
arenaSection.set("orientation", this.orientation.name());
|
arenaSection.set("orientation", this.orientation.name());
|
||||||
|
List<String> blockDisplays = new ArrayList<>();
|
||||||
|
for(UUID uuid : this.blockDisplays) {
|
||||||
|
blockDisplays.add(uuid == null ? null : uuid.toString());
|
||||||
|
}
|
||||||
|
arenaSection.set("blockdisplays", blockDisplays);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startNewGame() {
|
public void startNewGame() {
|
||||||
|
|
@ -184,15 +188,16 @@ public class MinecleanerArena {
|
||||||
this.currentPlayer = null;
|
this.currentPlayer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// block displays dont get removed
|
||||||
public void removeBlockDisplays() {
|
public void removeBlockDisplays() {
|
||||||
World world = location.getWorld();
|
World world = location.getWorld();
|
||||||
for(int fx = 0; fx < 9; fx++) {
|
for(int fx = 0; fx < 9; fx++) {
|
||||||
for(int fy = 0; fy < 9; fy++) {
|
for(int fy = 0; fy < 9; fy++) {
|
||||||
UUID blockDisplayUuid = blockDisplays[fx + fy * 9];
|
UUID blockDisplayUuid = blockDisplays[fx + fy * 9];
|
||||||
Entity blockDisplayEntity = blockDisplayUuid != null ? world.getEntity(blockDisplayUuid) : null;
|
Entity blockDisplayEntity = blockDisplayUuid != null ? world.getEntity(blockDisplayUuid) : null;
|
||||||
if(blockDisplayEntity instanceof Display blockdisplay) {
|
//if(blockDisplayEntity instanceof BlockDisplay blockDisplay) {
|
||||||
blockDisplayEntity.remove();
|
blockDisplayEntity.remove(); // Null Pointer after restart
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -239,7 +244,7 @@ public class MinecleanerArena {
|
||||||
int d1z = d0x;
|
int d1z = d0x;
|
||||||
|
|
||||||
Location loc = location.clone();
|
Location loc = location.clone();
|
||||||
for(int fx = -1; fx < 2; fx++) {
|
for(int fx = -2; fx < 1; fx++) {
|
||||||
for(int fy = -1; fy < 2; fy++) {
|
for(int fy = -1; fy < 2; fy++) {
|
||||||
loc.set(location.getX() + d1x + fx, location.getY() + fy, location.getZ() + d1z * fx);
|
loc.set(location.getX() + d1x + fx, location.getY() + fy, location.getZ() + d1z * fx);
|
||||||
blocks.add(loc.clone());
|
blocks.add(loc.clone());
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
import org.bukkit.util.RayTraceResult;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
public class MinecleanerListener implements Listener {
|
public class MinecleanerListener implements Listener {
|
||||||
|
|
@ -42,20 +44,40 @@ public class MinecleanerListener implements Listener {
|
||||||
int d1z = d0x;
|
int d1z = d0x;
|
||||||
|
|
||||||
if (e.getBlockFace() == arena.getOrientation()) {
|
if (e.getBlockFace() == arena.getOrientation()) {
|
||||||
Location loc = e.getInteractionPoint().clone().subtract(arena.getLocation()).subtract(0.5, 0.5, 0.5); // null on left-click
|
// Raytrace
|
||||||
|
// kann null sein
|
||||||
|
|
||||||
|
Player player = e.getPlayer();
|
||||||
|
RayTraceResult rayTraceResult = player.getWorld().rayTraceBlocks(player.getEyeLocation(), player.getEyeLocation().getDirection(), 64.0);
|
||||||
|
|
||||||
|
//Location loc = e.getInteractionPoint().clone().subtract(arena.getLocation()).subtract(0.5, 0.5, 0.5); // null on left-click
|
||||||
|
|
||||||
|
|
||||||
|
if(rayTraceResult != null) {
|
||||||
|
Vector hitPos = rayTraceResult.getHitPosition();
|
||||||
|
Location loc = player.getLocation().add(hitPos).clone().subtract(arena.getLocation()).subtract(0.5, 0.5, 0.5);
|
||||||
double lx = loc.getX();
|
double lx = loc.getX();
|
||||||
double ly = loc.getY();
|
double ly = loc.getY();
|
||||||
double lz = loc.getZ();
|
double lz = loc.getZ();
|
||||||
|
player.sendMessage(ChatColor.GRAY + "lx: " + lx + " ,ly: " + ly + " ,lz: " + lz);
|
||||||
double dy = ly + 1.5;
|
double dy = ly + 1.5;
|
||||||
|
player.sendMessage(ChatColor.GRAY + "dy: " + dy);
|
||||||
double dz = -d1x * lx - d1z * lz + 1.5;
|
double dz = -d1x * lx - d1z * lz + 1.5;
|
||||||
|
player.sendMessage(ChatColor.GRAY + "dz: " + dz);
|
||||||
|
|
||||||
double blockx = (dy / 3.0) * 9.0;
|
double blockx = (dy / 3.0) * 9.0;
|
||||||
double blockz = (dz / 3.0) * 9.0;
|
double blockz = (dz / 3.0) * 9.0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int blockxInt = (int) blockx;
|
int blockxInt = (int) blockx;
|
||||||
int blockzInt = (int) blockz;
|
int blockzInt = (int) blockz;
|
||||||
blockx -= blockxInt;
|
blockx -= blockxInt;
|
||||||
blockz -= blockzInt;
|
blockz -= blockzInt;
|
||||||
|
|
||||||
|
player.sendMessage(ChatColor.GRAY + "blockx: " + blockx + " ,blockz: " + blockz);
|
||||||
|
player.sendMessage(ChatColor.GRAY + "blockxInt: " + blockxInt + " ,blockzInt: " + blockzInt);
|
||||||
|
|
||||||
if (blockx >= 0.1 && blockx <= 0.9 && blockz >= 0.1 && blockz <= 0.9) {
|
if (blockx >= 0.1 && blockx <= 0.9 && blockz >= 0.1 && blockz <= 0.9) {
|
||||||
boolean hasRightClicked = false;
|
boolean hasRightClicked = false;
|
||||||
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
|
|
@ -63,10 +85,13 @@ public class MinecleanerListener implements Listener {
|
||||||
}
|
}
|
||||||
// TODO Doesnt show messages for Cells: [ROW] [>5] (6, 7, 8 are missing)
|
// TODO Doesnt show messages for Cells: [ROW] [>5] (6, 7, 8 are missing)
|
||||||
|
|
||||||
e.getPlayer().sendMessage("Arena click! " + blockxInt + " " + blockzInt + " Right Clicked: " + hasRightClicked);
|
player.sendMessage("Arena click! " + blockxInt + " " + blockzInt + " Right Clicked: " + hasRightClicked);
|
||||||
//plugin.getManager().handleFieldClick(e.getPlayer(), blockxInt, blockzInt, hasRightClicked);
|
//plugin.getManager().handleFieldClick(e.getPlayer(), blockxInt, blockzInt, hasRightClicked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
arena = plugin.getArenaList().getArenaAtBlock(block);
|
arena = plugin.getArenaList().getArenaAtBlock(block);
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ public class MinecleanerManager {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
// Deprecated
|
// Deprecated
|
||||||
this.confirmPlayingInventory = plugin.getServer().createInventory(null, InventoryType.HOPPER, "Möchtest du Minecleaner spielen?");
|
this.confirmPlayingInventory = plugin.getServer().createInventory(null, InventoryType.HOPPER, "Minecleaner starten?");
|
||||||
this.confirmPlayingInventory.setItem(1,
|
this.confirmPlayingInventory.setItem(1,
|
||||||
ItemStacks.lore(ItemStacks.rename(new ItemStack(Material.GREEN_CONCRETE), ChatColor.GREEN + "Bestätigen")));
|
ItemStacks.lore(ItemStacks.rename(new ItemStack(Material.GREEN_CONCRETE), ChatColor.GREEN + "Bestätigen")));
|
||||||
this.confirmPlayingInventory.setItem(3,
|
this.confirmPlayingInventory.setItem(3,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue