Skip to content

Commit

Permalink
API update
Browse files Browse the repository at this point in the history
  • Loading branch information
bea4dev committed Feb 19, 2022
1 parent d41a806 commit c6e6d39
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,64 @@ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
if (args == null) return false;
if (args.length == 0) return false;

if(args[0].equals("structure")){
if(args.length < 3){
return false;
}

//parallel structure set-data [structure-name] [data-name] [player]
if(args[1].equals("set-data")) {
if(args.length < 5){
return false;
}

ParallelStructure parallelStructure = ParallelStructure.getParallelStructure(args[2]);
if (parallelStructure == null) {
sender.sendMessage(ChatColor.RED + "指定された名前の構造体は存在しません。");
return true;
}

ImplStructureData implStructureData = (ImplStructureData) ImplStructureData.getStructureData(args[3]);
if (implStructureData == null) {
sender.sendMessage(ChatColor.RED + "指定された名前の構造データは存在しません。");
return true;
}

Player player = Bukkit.getPlayer(args[4]);
if(player == null){
sender.sendMessage(ChatColor.RED + "指定されたプレイヤーが見つかりませんでした。");
return true;
}

parallelStructure.setStructureData(player, implStructureData);
sender.sendMessage(ChatColor.GREEN + "適用しました。");
return true;
}

//parallel structure remove-data [structure-name] [player]
if(args[1].equals("remove-data")) {
if (args.length < 4) {
return false;
}

ParallelStructure parallelStructure = ParallelStructure.getParallelStructure(args[2]);
if (parallelStructure == null) {
sender.sendMessage(ChatColor.RED + "指定された名前の構造体は存在しません。");
return true;
}

Player player = Bukkit.getPlayer(args[3]);
if(player == null){
sender.sendMessage(ChatColor.RED + "指定されたプレイヤーが見つかりませんでした。");
return true;
}

parallelStructure.clearStructureData(player, true);
sender.sendMessage(ChatColor.GREEN + "適用しました。");
return true;
}
}

if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "このコマンドはコンソールから実行できません。");
return true;
Expand Down Expand Up @@ -180,58 +238,6 @@ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
sender.sendMessage(ChatColor.GREEN + "保存しました。");
return true;
}

//parallel structure set-data [structure-name] [data-name] [player]
if(args[1].equals("set-data")) {
if(args.length < 5){
return false;
}

ParallelStructure parallelStructure = ParallelStructure.getParallelStructure(args[2]);
if (parallelStructure == null) {
sender.sendMessage(ChatColor.RED + "指定された名前の構造体は存在しません。");
return true;
}

ImplStructureData implStructureData = (ImplStructureData) ImplStructureData.getStructureData(args[3]);
if (implStructureData == null) {
sender.sendMessage(ChatColor.RED + "指定された名前の構造データは存在しません。");
return true;
}

Player player = Bukkit.getPlayer(args[4]);
if(player == null){
sender.sendMessage(ChatColor.RED + "指定されたプレイヤーが見つかりませんでした。");
return true;
}

parallelStructure.setStructureData(player, implStructureData);
sender.sendMessage(ChatColor.GREEN + "適用しました。");
return true;
}

//parallel structure remove-data [structure-name] [player]
if(args[1].equals("remove-data")) {
if (args.length < 4) {
return false;
}

ParallelStructure parallelStructure = ParallelStructure.getParallelStructure(args[2]);
if (parallelStructure == null) {
sender.sendMessage(ChatColor.RED + "指定された名前の構造体は存在しません。");
return true;
}

Player player = Bukkit.getPlayer(args[3]);
if(player == null){
sender.sendMessage(ChatColor.RED + "指定されたプレイヤーが見つかりませんでした。");
return true;
}

parallelStructure.clearStructureData(player, true);
sender.sendMessage(ChatColor.GREEN + "適用しました。");
return true;
}
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ public void setStructureData(ParallelPlayer parallelPlayer, ImplStructureData im
blocks.add(block);
updateBlocks.add(new BlockPosition3i(block.getX(), block.getY(), block.getZ()));
}

parallelPlayer.getBukkitPlayer().sendMessage("HI!" + blocks.size());

dataMap.put(universe.getName(), blocks);

Expand Down Expand Up @@ -163,12 +165,17 @@ public void clearStructureData(ParallelPlayer parallelPlayer, boolean chunkUpdat

Set<Block> blocks = dataMap.get(universe.getName());
if(blocks == null) return;
parallelPlayer.getBukkitPlayer().sendMessage("HI!" + blocks.size());

ParallelWorld parallelWorld = universe.getWorld(Objects.requireNonNull(baseLocation.getWorld()).getName());

for(Block block : blocks){
parallelWorld.removeBlockData(block.getX(), block.getY(), block.getZ());
}
Set<BlockPosition3i> blockPosition3iSet = new HashSet<>();
blocks.forEach(block -> blockPosition3iSet.add(new BlockPosition3i(block.getX(), block.getY(), block.getZ())));

parallelWorld.sendMultiBlockUpdate(blockPosition3iSet);
}


Expand Down

0 comments on commit c6e6d39

Please sign in to comment.