Skip to content

Commit 9b25932

Browse files
committed
Custom action support for Prism - see README
1 parent 1ba4b71 commit 9b25932

File tree

3 files changed

+35
-17
lines changed

3 files changed

+35
-17
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ Block replacement tools, plus support for LogBlock, Prism and CoreProtect.
55

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

8+
Prism support
9+
=============
10+
11+
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.
12+
You may have to add `Painter` to your allowed plugins for this. To do so, do the following..
13+
14+
* Open your `Prism/config.yml` file.
15+
* Find the section named `allowed-plugins` - it's under `api`, under `tracking`, under `prism`.
16+
* Add `Painter` to the list.
17+
* You're ready to go!
18+
819
Compiling
920
=========
1021

src/main/java/com/archivesmc/painter/loggers/PrismLogger.java

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
import com.archivesmc.painter.Painter;
44

5+
import me.botsko.prism.Prism;
6+
import me.botsko.prism.actionlibs.ActionFactory;
7+
import me.botsko.prism.actionlibs.ActionType;
58
import me.botsko.prism.actionlibs.RecordingQueue;
6-
import me.botsko.prism.actions.BlockChangeAction;
79

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

2125
@Override
2226
public void blockPainted(Player player, BlockState oldBlockState, BlockState newBlockState, Block block) {
23-
BlockChangeAction breakAction = new BlockChangeAction();
24-
BlockChangeAction placeAction = new BlockChangeAction();
27+
Handler paintAction = ActionFactory.createBlockChange("painter-block-paint",
28+
oldBlockState.getLocation(), oldBlockState.getTypeId(), oldBlockState.getRawData(),
29+
newBlockState.getTypeId(), newBlockState.getRawData(), player.getName()
30+
);
2531

26-
breakAction.setActionType("block-break");
27-
breakAction.setLoc(block.getLocation());
28-
breakAction.setBlock(oldBlockState);
29-
breakAction.setPlayerName(player);
30-
31-
placeAction.setActionType("block-place");
32-
placeAction.setLoc(block.getLocation());
33-
placeAction.setBlock(newBlockState);
34-
placeAction.setPlayerName(player);
35-
36-
RecordingQueue.addToQueue(breakAction);
37-
RecordingQueue.addToQueue(placeAction);
32+
RecordingQueue.addToQueue(paintAction);
3833
}
3934

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

49-
return pPlugin != null && pPlugin.isEnabled();
44+
if (pPlugin != null && pPlugin.isEnabled()) {
45+
try {
46+
Prism.getActionRegistry().registerCustomAction(this.plugin,
47+
new ActionType("painter-block-paint", true, true, true, "BlockChangeAction", "painted")
48+
);
49+
} catch (InvalidActionException e) {
50+
e.printStackTrace();
51+
return false;
52+
}
53+
return true;
54+
}
55+
56+
return false;
5057
}
5158
}

src/main/resources/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Painter
2-
version: 0.0.1pre2
2+
version: 0.0.1pre3
33
description: Allows the painting of wool and clay, and the replacing of blocks
44

55
author: Gareth Coles

0 commit comments

Comments
 (0)