-
Notifications
You must be signed in to change notification settings - Fork 0
Make sure you added a recent version of LogBlock (v0.14 +) as external library/jar or whatever this is called in your IDE. You don’t have to add LogBlock.jar to the classpath. Javadocs are currently not available for the LogBlock API.
You need the following imports:
import de.diddiz.LogBlock.Consumer;
import de.diddiz.LogBlock.LogBlock;Then, you have to declare a local variable for the consumer:
public class MyPlugin extends JavaPlugin
{
private Consumer lbconsumer = null;
[...]Next is to get an instance of the consumer:
@Override
public void onEnable() {
final PluginManager pm = getServer().getPluginManager();
final Plugin plugin = pm.getPlugin("LogBlock");
if (plugin != null)
lbconsumer = ((LogBlock)plugin).getConsumer();
[...]Now you can queue blocks from everywhere in your code (for example):
lbconsumer.queueBlockBreak(event.getPlayer().getName(), event.getClickedBlock().getState());To get a list of all queue methods have a look at the javadoc:
[[http://diddiz.insane-architects.net/LogBlock/doc/de/diddiz/LogBlock/Consumer.html#method_summary]]
LogBlock logblock = (LogBlock)getServer().getPluginManager().getPlugin("LogBlock");
QueryParams params = new QueryParams(logblock);
params.setPlayer("DiddiZ");
params.bct = BlockChangeType.CREATED;
params.limit = -1;
params.minutes = 1440;
params.world = getServer().getWorlds().get(0);
params.needDate = true;
params.needType = true;
params.needData = true;
params.needPlayer = true;
try {
for (BlockChange bc : logblock.getBlockChanges(params))
System.out.println(bc.toString());
}-
BlockChangeType
-
int limit
-
int minutes
-
int radius
-
Location loc
-
Order order
-
List<String> players
-
boolean excludePlayersMode
-
boolean coords
-
Selection sel
-
List<Integer> types
-
World world
You have to specify the columns you need (otherwise they’ll get filled with 0 or null:
-
needId - The id column of the main table
-
needDate - The date
-
needType - type and replaced columns
-
needData - data column
-
needPlayer - joined playerName column from
lb-players -
needCoords - x,y and z columns
-
needSignText - All rows from -sign table
-
needChestAccess - All rows from -chest table
Most act like the imgame parameters. For further understanding, have a look at the source: [[https://github.com/DiddiZ/LogBlock/blob/master/src/de/diddiz/LogBlock/QueryParams.java]]
LogBlock logblock = getServer().getPluginManager().getPlugin("LogBlock");
QueryParams params = new QueryParams(logblock);
params.setPlayer("DiddiZ");
params.world = getServer().getWorlds().get(0);
params.silent = true;
try {
logblock.getCommandsHandler().new CommandRollback(logblock, params, true);
}Not implemented yet, but a later implementation will work with queuing blocks
public class KingMidas extends JavaPlugin
{
@Override
public void onEnable() {
final PluginManager pm = getServer().getPluginManager();
Plugin plugin = pm.getPlugin("LogBlock");
if (plugin == null) {
pm.disablePlugin(this);
return;
}
pm.registerEvent(Type.PLAYER_INTERACT, new KMPlayerListener((LogBlock)plugin, Priority.Normal, this);
}
}
class KMPlayerListener extends PlayerListener
{
private final Consumer consumer;
KMPlayerListener(LogBlock logblock) {
consumer = logblock.getConsumer();
}
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
consumer.queueBlockReplace(event.getPlayer().getName(), event.getClickedBlock().getState(), 41, (byte)0)
event.getClickedBlock().setTypeId(41)
}
}
}