Added /GPBlockInfo
Useful for admins to set up their config files with correct IDs and data values.
This commit is contained in:
parent
fc1c26dcb6
commit
5a3319022a
|
|
@ -140,6 +140,10 @@ commands:
|
||||||
givepet:
|
givepet:
|
||||||
description: Allows a player to give away a pet he or she tamed.
|
description: Allows a player to give away a pet he or she tamed.
|
||||||
usage: /GivePet <player>
|
usage: /GivePet <player>
|
||||||
|
gpblockinfo:
|
||||||
|
description: Allows an administrator to get technical information about blocks in the world and items in hand.
|
||||||
|
usage: /GPBlockInfo
|
||||||
|
permission: griefprevention.gpblockinfo
|
||||||
permissions:
|
permissions:
|
||||||
griefprevention.createclaims:
|
griefprevention.createclaims:
|
||||||
description: Grants permission to create claims.
|
description: Grants permission to create claims.
|
||||||
|
|
@ -205,3 +209,6 @@ permissions:
|
||||||
griefprevention.visualizenearbyclaims:
|
griefprevention.visualizenearbyclaims:
|
||||||
description: Allows a player to see all nearby claims at once.
|
description: Allows a player to see all nearby claims at once.
|
||||||
default: op
|
default: op
|
||||||
|
griefprevention.gpblockinfo:
|
||||||
|
description: Grants access to /GPBlockInfo.
|
||||||
|
default: op
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
GriefPrevention Server Plugin for Minecraft
|
||||||
|
Copyright (C) 2012 Ryan Hamshire
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.ryanhamshire.GriefPrevention;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
//players can be "trapped" in a portal frame if they don't have permission to break
|
||||||
|
//solid blocks blocking them from exiting the frame
|
||||||
|
//if that happens, we detect the problem and send them back through the portal.
|
||||||
|
class CheckForPortalTrapTask implements Runnable
|
||||||
|
{
|
||||||
|
//player who recently teleported via nether portal
|
||||||
|
private Player player;
|
||||||
|
|
||||||
|
//where to send the player back to if he hasn't left the portal frame
|
||||||
|
private Location returnLocation;
|
||||||
|
|
||||||
|
public CheckForPortalTrapTask(Player player, Location location)
|
||||||
|
{
|
||||||
|
this.player = player;
|
||||||
|
this.returnLocation = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
//if player has logged out, do nothing
|
||||||
|
if(!this.player.isOnline()) return;
|
||||||
|
|
||||||
|
//otherwise if still standing in a portal frame, teleport him back through
|
||||||
|
if(this.player.getLocation().getBlock().getType() == Material.PORTAL)
|
||||||
|
{
|
||||||
|
this.player.teleport(this.returnLocation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -39,6 +39,7 @@ import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.command.*;
|
import org.bukkit.command.*;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
@ -49,6 +50,7 @@ import org.bukkit.inventory.PlayerInventory;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.util.BlockIterator;
|
||||||
|
|
||||||
public class GriefPrevention extends JavaPlugin
|
public class GriefPrevention extends JavaPlugin
|
||||||
{
|
{
|
||||||
|
|
@ -61,6 +63,9 @@ public class GriefPrevention extends JavaPlugin
|
||||||
//this handles data storage, like player and region data
|
//this handles data storage, like player and region data
|
||||||
public DataStore dataStore;
|
public DataStore dataStore;
|
||||||
|
|
||||||
|
//this tracks item stacks expected to drop which will need protection
|
||||||
|
ArrayList<PendingItemProtection> pendingItemWatchList = new ArrayList<PendingItemProtection>();
|
||||||
|
|
||||||
//configuration variables, loaded/saved from a config.yml
|
//configuration variables, loaded/saved from a config.yml
|
||||||
|
|
||||||
//claim mode for each world
|
//claim mode for each world
|
||||||
|
|
@ -1952,6 +1957,18 @@ public class GriefPrevention extends JavaPlugin
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//gpblockinfo
|
||||||
|
else if(cmd.getName().equalsIgnoreCase("gpblockinfo") && player != null)
|
||||||
|
{
|
||||||
|
ItemStack inHand = player.getItemInHand();
|
||||||
|
player.sendMessage("In Hand: " + String.format("%s(%d:%d)", inHand.getType().name(), inHand.getTypeId(), inHand.getData().getData()));
|
||||||
|
|
||||||
|
Block inWorld = GriefPrevention.getTargetNonAirBlock(player, 300);
|
||||||
|
player.sendMessage("In World: " + String.format("%s(%d:%d)", inWorld.getType().name(), inWorld.getTypeId(), inWorld.getData()));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2590,6 +2607,16 @@ public class GriefPrevention extends JavaPlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//this tracks item stacks expected to drop which will need protection
|
private static Block getTargetNonAirBlock(Player player, int maxDistance) throws IllegalStateException
|
||||||
ArrayList<PendingItemProtection> pendingItemWatchList = new ArrayList<PendingItemProtection>();
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -781,6 +781,13 @@ class PlayerEventHandler implements Listener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//FEATURE: when players get trapped in a nether portal, send them back through to the other side
|
||||||
|
if(event.getCause() == TeleportCause.NETHER_PORTAL)
|
||||||
|
{
|
||||||
|
CheckForPortalTrapTask task = new CheckForPortalTrapTask(player, event.getFrom());
|
||||||
|
GriefPrevention.instance.getServer().getScheduler().scheduleSyncDelayedTask(GriefPrevention.instance, task, 100L);
|
||||||
|
}
|
||||||
|
|
||||||
//FEATURE: prevent teleport abuse to win sieges
|
//FEATURE: prevent teleport abuse to win sieges
|
||||||
|
|
||||||
//these rules only apply to siege worlds only
|
//these rules only apply to siege worlds only
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user