Skip to content

Commit b0f3bab

Browse files
author
david
committed
added default brush item setting
1 parent 12a67a4 commit b0f3bab

File tree

5 files changed

+27
-10
lines changed

5 files changed

+27
-10
lines changed

src/main/java/net/onelitefeather/bettergopaint/BetterGoPaint.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.bstats.bukkit.Metrics;
3131
import org.bstats.charts.SimplePie;
3232
import org.bukkit.Bukkit;
33+
import org.bukkit.Material;
3334
import org.bukkit.command.CommandSender;
3435
import org.bukkit.event.Listener;
3536
import org.bukkit.plugin.PluginManager;
@@ -48,6 +49,8 @@
4849

4950
public class BetterGoPaint extends JavaPlugin implements Listener {
5051

52+
public static final @NotNull String PAPER_DOCS = "https://jd.papermc.io/paper/1.20.6/org/bukkit/Material.html#enum-constant-summary";
53+
5154
private final @NotNull PlayerBrushManager brushManager = new PlayerBrushManager();
5255
private final @NotNull Metrics metrics = new Metrics(this, 18734);
5356

@@ -68,12 +71,19 @@ public void onEnable() {
6871
if (hasOriginalGoPaint()) {
6972
getComponentLogger().error("BetterGoPaint is a replacement for goPaint. Please use one instead of both");
7073
getComponentLogger().error("This plugin is now disabling to prevent future errors");
71-
this.getServer().getPluginManager().disablePlugin(this);
74+
getServer().getPluginManager().disablePlugin(this);
7275
return;
7376
}
7477

7578
reloadConfig();
7679

80+
Material brush = Settings.settings().GENERIC.DEFAULT_BRUSH;
81+
if (!brush.isItem()) {
82+
getComponentLogger().error("{} is not a valid default brush, it has to be an item", brush.name());
83+
getComponentLogger().error("For more information visit {}", PAPER_DOCS);
84+
getServer().getPluginManager().disablePlugin(this);
85+
}
86+
7787
//noinspection UnnecessaryUnicodeEscape
7888
getComponentLogger().info(MiniMessage.miniMessage().deserialize(
7989
"<white>Made with <red>\u2665</red> <white>in <gradient:black:red:gold>Germany</gradient>"

src/main/java/net/onelitefeather/bettergopaint/listeners/InteractListener.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import net.onelitefeather.bettergopaint.objects.other.Settings;
2929
import org.bukkit.FluidCollisionMode;
3030
import org.bukkit.Location;
31-
import org.bukkit.Material;
3231
import org.bukkit.block.Block;
3332
import org.bukkit.entity.Player;
3433
import org.bukkit.event.EventHandler;
@@ -62,7 +61,7 @@ public void onClick(PlayerInteractEvent event) {
6261
return;
6362
}
6463

65-
if (event.getAction().isLeftClick() && item.getType().equals(Material.FEATHER)) {
64+
if (event.getAction().isLeftClick() && item.getType().equals(Settings.settings().GENERIC.DEFAULT_BRUSH)) {
6665
PlayerBrush brush = plugin.getBrushManager().getBrush(player);
6766
player.openInventory(brush.getInventory());
6867
event.setCancelled(true);
@@ -86,8 +85,8 @@ public void onClick(PlayerInteractEvent event) {
8685
return;
8786
}
8887

89-
if ((!player.hasPermission("bettergopaint.world.bypass")) && (Settings.settings().GENERIC.DISABLED_WORLDS
90-
.contains(location.getWorld().getName()))) {
88+
if (!player.hasPermission("bettergopaint.world.bypass") && Settings.settings().GENERIC.DISABLED_WORLDS
89+
.contains(location.getWorld().getName())) {
9190
return;
9291
}
9392

@@ -101,7 +100,7 @@ public void onClick(PlayerInteractEvent event) {
101100

102101
//noinspection removal
103102
brushSettings = brush.map(current -> ExportedPlayerBrush.parse(current, itemMeta)).orElse(null);
104-
} else if (item.getType().equals(Material.FEATHER)) {
103+
} else if (item.getType().equals(Settings.settings().GENERIC.DEFAULT_BRUSH)) {
105104
brushSettings = plugin.getBrushManager().getBrush(player);
106105
} else {
107106
return;

src/main/java/net/onelitefeather/bettergopaint/listeners/InventoryListener.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import net.onelitefeather.bettergopaint.objects.brush.SplatterBrush;
3232
import net.onelitefeather.bettergopaint.objects.brush.SprayBrush;
3333
import net.onelitefeather.bettergopaint.objects.brush.UnderlayBrush;
34+
import net.onelitefeather.bettergopaint.objects.other.Settings;
3435
import net.onelitefeather.bettergopaint.utils.GUI;
3536
import org.bukkit.Material;
3637
import org.bukkit.entity.Player;
@@ -68,7 +69,7 @@ public void menuClick(InventoryClickEvent event) {
6869
if (event.getRawSlot() == 10 || event.getRawSlot() == 1 || event.getRawSlot() == 19) {
6970
if (event.getClick().equals(ClickType.LEFT)) {
7071
if (!event.getCursor().getType().isBlock()) {
71-
if (!event.getCursor().getType().equals(Material.FEATHER)) {
72+
if (!event.getCursor().getType().equals(Settings.settings().GENERIC.DEFAULT_BRUSH)) {
7273
playerBrush.export(event.getCursor());
7374
}
7475
}

src/main/java/net/onelitefeather/bettergopaint/objects/other/Settings.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ public void reload(BetterGoPaint plugin, File file) {
6161
@Comment("This is related to generic settings")
6262
public static class GENERIC {
6363

64+
@Comment({
65+
"Default brush item",
66+
"Possible values: " + BetterGoPaint.PAPER_DOCS,
67+
"Only items are allowed"
68+
})
69+
public Material DEFAULT_BRUSH = Material.FEATHER;
6470
@Comment("Max size of the brush")
6571
public int MAX_SIZE = 100;
6672
@Comment("Default size for each player of the brush")
@@ -86,7 +92,7 @@ public static class GENERIC {
8692

8793
@Comment({
8894
"Default mask to apply",
89-
"Possible values: https://jd.papermc.io/paper/1.20.6/org/bukkit/Material.html#enum-constant-summary"
95+
"Possible values: " + BetterGoPaint.PAPER_DOCS
9096
})
9197
public Material DEFAULT_MASK = Material.SPONGE;
9298

src/main/java/net/onelitefeather/bettergopaint/utils/GUI.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import net.onelitefeather.bettergopaint.objects.brush.SplatterBrush;
3333
import net.onelitefeather.bettergopaint.objects.brush.SprayBrush;
3434
import net.onelitefeather.bettergopaint.objects.brush.UnderlayBrush;
35+
import net.onelitefeather.bettergopaint.objects.other.Settings;
3536
import org.bukkit.Bukkit;
3637
import org.bukkit.Material;
3738
import org.bukkit.inventory.Inventory;
@@ -76,13 +77,13 @@ public static void update(@NotNull Inventory inventory, @NotNull PlayerBrush pla
7677
// goPaint toggle
7778
if (playerBrush.enabled()) {
7879
inventory.setItem(1, Items.create(Material.LIME_STAINED_GLASS_PANE, 1, "§7", ""));
79-
inventory.setItem(10, Items.create(Material.FEATHER, 1, "§6goPaint Brush",
80+
inventory.setItem(10, Items.create(Settings.settings().GENERIC.DEFAULT_BRUSH, 1, "§6goPaint Brush",
8081
"§a§lEnabled\n\n§7Left click with item to export\n§7Right click to toggle"
8182
));
8283
inventory.setItem(19, Items.create(Material.LIME_STAINED_GLASS_PANE, 1, "§7", ""));
8384
} else {
8485
inventory.setItem(1, Items.create(Material.RED_STAINED_GLASS_PANE, 1, "§7", ""));
85-
inventory.setItem(10, Items.create(Material.FEATHER, 1, "§6goPaint Brush",
86+
inventory.setItem(10, Items.create(Settings.settings().GENERIC.DEFAULT_BRUSH, 1, "§6goPaint Brush",
8687
"§c§lDisabled\n\n§7Left click with item to export\n§7Right click to toggle"
8788
));
8889
inventory.setItem(19, Items.create(Material.RED_STAINED_GLASS_PANE, 1, "§7", ""));

0 commit comments

Comments
 (0)