Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix /gpblockinfo causing legacy load #1043

Merged
merged 2 commits into from Oct 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 6 additions & 19 deletions src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java
Expand Up @@ -30,6 +30,7 @@
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot;
import org.bukkit.FluidCollisionMode;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
Expand All @@ -38,7 +39,6 @@
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
Expand All @@ -52,7 +52,6 @@
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.BlockIterator;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -2703,11 +2702,12 @@ else if (cmd.getName().equalsIgnoreCase("givepet") && player != null)
//gpblockinfo
else if (cmd.getName().equalsIgnoreCase("gpblockinfo") && player != null)
{
ItemStack inHand = player.getItemInHand();
player.sendMessage("In Hand: " + String.format("%s(dValue:%s)", inHand.getType().name(), inHand.getData().getData()));
ItemStack inHand = player.getInventory().getItemInMainHand();
player.sendMessage("In Hand: " + inHand.getType().name());

Block inWorld = GriefPrevention.getTargetNonAirBlock(player, 300);
player.sendMessage("In World: " + String.format("%s(dValue:%s)", inWorld.getType().name(), inWorld.getData()));
Block inWorld = player.getTargetBlockExact(300, FluidCollisionMode.ALWAYS);
if (inWorld == null) inWorld = player.getEyeLocation().getBlock();
player.sendMessage("In World: " + inWorld.getType().name());

return true;
}
Expand Down Expand Up @@ -3618,19 +3618,6 @@ public int getSeaLevel(World world)
}
}

private static Block getTargetNonAirBlock(Player player, int maxDistance) throws IllegalStateException
{
BlockIterator iterator = new BlockIterator(player.getLocation(), player.getEyeHeight(), maxDistance);
Block result = player.getLocation().getBlock().getRelative(BlockFace.UP);
while (iterator.hasNext())
{
result = iterator.next();
if (result.getType() != Material.AIR) return result;
}

return result;
}

public boolean containsBlockedIP(String message)
{
message = message.replace("\r\n", "");
Expand Down