Skip to content

Commit

Permalink
Custom action support for Prism - see README
Browse files Browse the repository at this point in the history
  • Loading branch information
gdude2002 committed Jul 15, 2014
1 parent 1ba4b71 commit 9b25932
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ Block replacement tools, plus support for LogBlock, Prism and CoreProtect.

See the BukkitDev page (when I make one) for full documentation.

Prism support
=============

If you want to use this with prism, bear in mind that Painter supports Prism custom actions - namely, it adds the `painter-block-paint` action.
You may have to add `Painter` to your allowed plugins for this. To do so, do the following..

* Open your `Prism/config.yml` file.
* Find the section named `allowed-plugins` - it's under `api`, under `tracking`, under `prism`.
* Add `Painter` to the list.
* You're ready to go!

Compiling
=========

Expand Down
39 changes: 23 additions & 16 deletions src/main/java/com/archivesmc/painter/loggers/PrismLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

import com.archivesmc.painter.Painter;

import me.botsko.prism.Prism;
import me.botsko.prism.actionlibs.ActionFactory;
import me.botsko.prism.actionlibs.ActionType;
import me.botsko.prism.actionlibs.RecordingQueue;
import me.botsko.prism.actions.BlockChangeAction;

import me.botsko.prism.actions.Handler;
import me.botsko.prism.exceptions.InvalidActionException;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
Expand All @@ -20,21 +24,12 @@ public PrismLogger(Painter plugin) {

@Override
public void blockPainted(Player player, BlockState oldBlockState, BlockState newBlockState, Block block) {
BlockChangeAction breakAction = new BlockChangeAction();
BlockChangeAction placeAction = new BlockChangeAction();
Handler paintAction = ActionFactory.createBlockChange("painter-block-paint",
oldBlockState.getLocation(), oldBlockState.getTypeId(), oldBlockState.getRawData(),
newBlockState.getTypeId(), newBlockState.getRawData(), player.getName()
);

breakAction.setActionType("block-break");
breakAction.setLoc(block.getLocation());
breakAction.setBlock(oldBlockState);
breakAction.setPlayerName(player);

placeAction.setActionType("block-place");
placeAction.setLoc(block.getLocation());
placeAction.setBlock(newBlockState);
placeAction.setPlayerName(player);

RecordingQueue.addToQueue(breakAction);
RecordingQueue.addToQueue(placeAction);
RecordingQueue.addToQueue(paintAction);
}

@Override
Expand All @@ -46,6 +41,18 @@ public String getPluginName() {
public boolean setup() {
Plugin pPlugin = this.plugin.getServer().getPluginManager().getPlugin("Prism");

return pPlugin != null && pPlugin.isEnabled();
if (pPlugin != null && pPlugin.isEnabled()) {
try {
Prism.getActionRegistry().registerCustomAction(this.plugin,
new ActionType("painter-block-paint", true, true, true, "BlockChangeAction", "painted")
);
} catch (InvalidActionException e) {
e.printStackTrace();
return false;
}
return true;
}

return false;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Painter
version: 0.0.1pre2
version: 0.0.1pre3
description: Allows the painting of wool and clay, and the replacing of blocks

author: Gareth Coles
Expand Down

0 comments on commit 9b25932

Please sign in to comment.