Skip to content

Commit

Permalink
added default brush item setting
Browse files Browse the repository at this point in the history
  • Loading branch information
david committed Jun 12, 2024
1 parent 12a67a4 commit b0f3bab
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Listener;
import org.bukkit.plugin.PluginManager;
Expand All @@ -48,6 +49,8 @@

public class BetterGoPaint extends JavaPlugin implements Listener {

public static final @NotNull String PAPER_DOCS = "https://jd.papermc.io/paper/1.20.6/org/bukkit/Material.html#enum-constant-summary";

private final @NotNull PlayerBrushManager brushManager = new PlayerBrushManager();
private final @NotNull Metrics metrics = new Metrics(this, 18734);

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

reloadConfig();

Material brush = Settings.settings().GENERIC.DEFAULT_BRUSH;
if (!brush.isItem()) {
getComponentLogger().error("{} is not a valid default brush, it has to be an item", brush.name());
getComponentLogger().error("For more information visit {}", PAPER_DOCS);
getServer().getPluginManager().disablePlugin(this);
}

//noinspection UnnecessaryUnicodeEscape
getComponentLogger().info(MiniMessage.miniMessage().deserialize(
"<white>Made with <red>\u2665</red> <white>in <gradient:black:red:gold>Germany</gradient>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import net.onelitefeather.bettergopaint.objects.other.Settings;
import org.bukkit.FluidCollisionMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand Down Expand Up @@ -62,7 +61,7 @@ public void onClick(PlayerInteractEvent event) {
return;
}

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

if ((!player.hasPermission("bettergopaint.world.bypass")) && (Settings.settings().GENERIC.DISABLED_WORLDS
.contains(location.getWorld().getName()))) {
if (!player.hasPermission("bettergopaint.world.bypass") && Settings.settings().GENERIC.DISABLED_WORLDS
.contains(location.getWorld().getName())) {
return;
}

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

//noinspection removal
brushSettings = brush.map(current -> ExportedPlayerBrush.parse(current, itemMeta)).orElse(null);
} else if (item.getType().equals(Material.FEATHER)) {
} else if (item.getType().equals(Settings.settings().GENERIC.DEFAULT_BRUSH)) {
brushSettings = plugin.getBrushManager().getBrush(player);
} else {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import net.onelitefeather.bettergopaint.objects.brush.SplatterBrush;
import net.onelitefeather.bettergopaint.objects.brush.SprayBrush;
import net.onelitefeather.bettergopaint.objects.brush.UnderlayBrush;
import net.onelitefeather.bettergopaint.objects.other.Settings;
import net.onelitefeather.bettergopaint.utils.GUI;
import org.bukkit.Material;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -68,7 +69,7 @@ public void menuClick(InventoryClickEvent event) {
if (event.getRawSlot() == 10 || event.getRawSlot() == 1 || event.getRawSlot() == 19) {
if (event.getClick().equals(ClickType.LEFT)) {
if (!event.getCursor().getType().isBlock()) {
if (!event.getCursor().getType().equals(Material.FEATHER)) {
if (!event.getCursor().getType().equals(Settings.settings().GENERIC.DEFAULT_BRUSH)) {
playerBrush.export(event.getCursor());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ public void reload(BetterGoPaint plugin, File file) {
@Comment("This is related to generic settings")
public static class GENERIC {

@Comment({
"Default brush item",
"Possible values: " + BetterGoPaint.PAPER_DOCS,
"Only items are allowed"
})
public Material DEFAULT_BRUSH = Material.FEATHER;
@Comment("Max size of the brush")
public int MAX_SIZE = 100;
@Comment("Default size for each player of the brush")
Expand All @@ -86,7 +92,7 @@ public static class GENERIC {

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

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/onelitefeather/bettergopaint/utils/GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import net.onelitefeather.bettergopaint.objects.brush.SplatterBrush;
import net.onelitefeather.bettergopaint.objects.brush.SprayBrush;
import net.onelitefeather.bettergopaint.objects.brush.UnderlayBrush;
import net.onelitefeather.bettergopaint.objects.other.Settings;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.inventory.Inventory;
Expand Down Expand Up @@ -76,13 +77,13 @@ public static void update(@NotNull Inventory inventory, @NotNull PlayerBrush pla
// goPaint toggle
if (playerBrush.enabled()) {
inventory.setItem(1, Items.create(Material.LIME_STAINED_GLASS_PANE, 1, "§7", ""));
inventory.setItem(10, Items.create(Material.FEATHER, 1, "§6goPaint Brush",
inventory.setItem(10, Items.create(Settings.settings().GENERIC.DEFAULT_BRUSH, 1, "§6goPaint Brush",
"§a§lEnabled\n\n§7Left click with item to export\n§7Right click to toggle"
));
inventory.setItem(19, Items.create(Material.LIME_STAINED_GLASS_PANE, 1, "§7", ""));
} else {
inventory.setItem(1, Items.create(Material.RED_STAINED_GLASS_PANE, 1, "§7", ""));
inventory.setItem(10, Items.create(Material.FEATHER, 1, "§6goPaint Brush",
inventory.setItem(10, Items.create(Settings.settings().GENERIC.DEFAULT_BRUSH, 1, "§6goPaint Brush",
"§c§lDisabled\n\n§7Left click with item to export\n§7Right click to toggle"
));
inventory.setItem(19, Items.create(Material.RED_STAINED_GLASS_PANE, 1, "§7", ""));
Expand Down

0 comments on commit b0f3bab

Please sign in to comment.