-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A couple fixes, plus range replace mode
- Loading branch information
Showing
6 changed files
with
117 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/main/java/com/archivesmc/painter/listeners/PlayerInteractListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.archivesmc.painter.listeners; | ||
|
||
import com.archivesmc.painter.Painter; | ||
import org.bukkit.Material; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.block.BlockState; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.block.Action; | ||
import org.bukkit.event.player.PlayerInteractEvent; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class PlayerInteractListener implements Listener { | ||
Painter plugin; | ||
|
||
public PlayerInteractListener(Painter plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@EventHandler(priority = EventPriority.HIGHEST) | ||
public void onPlayerInteractEvent(PlayerInteractEvent event) { | ||
if(! event.isCancelled()) { | ||
Player player = event.getPlayer(); | ||
|
||
if (this.plugin.range_painters.contains(player.getUniqueId()) | ||
&& event.getAction() == Action.LEFT_CLICK_AIR) { | ||
if (! this.plugin.permissions.has(player, "painter.replace.range")) { | ||
this.plugin.range_painters.remove(player.getUniqueId()); | ||
|
||
Map<String, String> args = new HashMap<>(); | ||
args.put("permission", "painter.replace.range"); | ||
args.put("name", player.getName()); | ||
|
||
this.plugin.sendMessage(player, "range_replace_perm_lost", args); | ||
return; | ||
} | ||
|
||
ItemStack items = player.getItemInHand(); | ||
Material heldMat = items.getType(); | ||
|
||
if (heldMat.isBlock()) { | ||
Block block = player.getTargetBlock(null, 100); | ||
BlockState oldBlockState = block.getState(); | ||
|
||
block.setType(heldMat); | ||
block.setData(items.getData().getData()); | ||
|
||
event.setCancelled(true); | ||
|
||
// Log it if it's being logged | ||
this.plugin.blockPainted(player, oldBlockState, block.getState(), block); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,27 @@ | ||
name: Painter | ||
version: 0.0.1pre4 | ||
version: 0.0.1pre5 | ||
description: Allows the painting of wool and clay, and the replacing of blocks | ||
|
||
author: Gareth Coles | ||
|
||
main: com.archivesmc.painter.Painter | ||
database: false | ||
depend: [Vault] | ||
softdepend: [LogBlock, CoreProtect, Prism, Hawkeye] | ||
softdepend: [LogBlock, CoreProtect, Prism, HawkEye] | ||
|
||
commands: | ||
painter: | ||
aliases: [paint, ptr, pt, p] | ||
description: "Enter or leave block replacement mode, or change the colours on your wool/clay paint tool" | ||
usage: "/<command> [left-click colour] [right-click colour]\n/<command> \u00BB Toggle block replacement mode\n/<command> red white \u00BB Set colours on the paint tool\n/<command> - black \u00BB Set only the right-click colour on the paint tool" | ||
description: "Toggle replacement ("toggle" or no arguments) and range replacement modes" | ||
usage: "/<command> [toggle|range]" | ||
|
||
permissions: | ||
painter.*: | ||
children: | ||
painter.tool: true | ||
painter.replace: true | ||
painter.command: true | ||
painter.replace.range: true | ||
description: All the Painter permissions | ||
painter.tool: | ||
description: Use the wool/clay paint tool | ||
painter.replace: | ||
description: Replace blocks by breaking them | ||
description: Replace blocks by breaking them | ||
painter.replace.range: | ||
description: Replace blocks at range by left-clicking |