some Testing with Blockdisplays
This commit is contained in:
47
src/main/java/commands/ChessCommand.java
Normal file
47
src/main/java/commands/ChessCommand.java
Normal file
@ -0,0 +1,47 @@
|
||||
package commands;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.BlockDisplay;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ChessCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if(sender instanceof Player p) {
|
||||
Location playerLocation = p.getLocation();
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
int finalI = i+1;
|
||||
for (int j = 0; j < 8; j++) {
|
||||
int finalJ = j+1;
|
||||
p.getWorld().spawn(
|
||||
new Location(p.getWorld(),
|
||||
playerLocation.x()+i,
|
||||
playerLocation.y(),
|
||||
playerLocation.z()+j),
|
||||
BlockDisplay.class, blockDisplay -> {
|
||||
if(finalI % 2 == 0 && finalJ % 2 == 0) {
|
||||
blockDisplay.setBlock(Material.BLACK_CONCRETE.createBlockData());
|
||||
} else if(finalI % 2 != 0 && finalJ % 2 != 0) {
|
||||
blockDisplay.setBlock(Material.BLACK_CONCRETE.createBlockData());
|
||||
} else {
|
||||
blockDisplay.setBlock(Material.WHITE_CONCRETE.createBlockData());
|
||||
}
|
||||
blockDisplay.setDisplayHeight(0.5f);
|
||||
blockDisplay.setDisplayWidth(0.5f);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
return(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,7 +1,11 @@
|
||||
package eu.mhsl.minecraft.pixelblocks;
|
||||
|
||||
import commands.ChessCommand;
|
||||
import listeners.PlayerJumpListener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public final class PixelBlocks extends JavaPlugin {
|
||||
public static PixelBlocks plugin;
|
||||
|
||||
@ -9,6 +13,8 @@ public final class PixelBlocks extends JavaPlugin {
|
||||
public void onEnable() {
|
||||
PixelBlocks.plugin = this;
|
||||
this.getLogger().info("Hello World");
|
||||
getServer().getPluginManager().registerEvents(new PlayerJumpListener(), this);
|
||||
Objects.requireNonNull(getCommand("chess")).setExecutor(new ChessCommand());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
12
src/main/java/listeners/PlayerJoinListener.java
Normal file
12
src/main/java/listeners/PlayerJoinListener.java
Normal file
@ -0,0 +1,12 @@
|
||||
package listeners;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class PlayerJoinListener implements Listener {
|
||||
@EventHandler
|
||||
static void onPlayerJoin(PlayerJoinEvent event) {
|
||||
|
||||
}
|
||||
}
|
17
src/main/java/listeners/PlayerJumpListener.java
Normal file
17
src/main/java/listeners/PlayerJumpListener.java
Normal file
@ -0,0 +1,17 @@
|
||||
package listeners;
|
||||
|
||||
import com.destroystokyo.paper.event.player.PlayerJumpEvent;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.BlockDisplay;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class PlayerJumpListener implements Listener {
|
||||
@EventHandler
|
||||
static void onPlayerJump(PlayerJumpEvent event) {
|
||||
event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), BlockDisplay.class, blockDisplay -> {
|
||||
blockDisplay.setBlock(Material.OAK_LOG.createBlockData());
|
||||
});
|
||||
|
||||
}
|
||||
}
|
@ -2,3 +2,5 @@ name: PixelBlocks
|
||||
version: '${version}'
|
||||
main: eu.mhsl.minecraft.pixelblocks.PixelBlocks
|
||||
api-version: '1.21'
|
||||
commands:
|
||||
chess:
|
||||
|
Reference in New Issue
Block a user