Skip to content

Commit 3b1a919

Browse files
committed
Fixed some bugs, added readme.
1 parent 9230b63 commit 3b1a919

File tree

8 files changed

+31
-27
lines changed

8 files changed

+31
-27
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SimpleGenBuckets
2+
3+
A powerful minecraft plugin for generating walls easily.
4+
5+
For a full description and basic documentation, visit [the spigot page]().

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,13 @@
8686
<groupId>com.sk89q.worldguard</groupId>
8787
<artifactId>worldguard-legacy</artifactId>
8888
<version>6.2</version>
89+
<scope>provided</scope>
8990
</dependency>
9091
<dependency>
9192
<groupId>net.coreprotect</groupId>
9293
<artifactId>coreprotect</artifactId>
9394
<version>2.12.0</version>
95+
<scope>provided</scope>
9496
</dependency>
9597
<dependency>
9698
<groupId>net.milkbowl.vault</groupId>

src/main/java/codes/biscuit/simplegenbuckets/commands/GenBucketAdminCommand.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import org.bukkit.command.TabCompleter;
1010
import org.bukkit.entity.Player;
1111
import org.bukkit.inventory.ItemStack;
12-
import org.bukkit.inventory.meta.ItemMeta;
1312

1413
import java.util.ArrayList;
1514
import java.util.Arrays;
@@ -27,7 +26,7 @@ public GenBucketAdminCommand(SimpleGenBuckets main) {
2726
public final TabCompleter TAB_COMPLETER = (sender, cmd, alias, args) -> {
2827
if (args.length == 1) {
2928
List<String> arguments = new ArrayList<>(Arrays.asList("give", "reload", "bypass"));
30-
for (String arg : Arrays.asList("give", "reload")) {
29+
for (String arg : Arrays.asList("give", "reload", "bypass")) {
3130
if (!arg.startsWith(args[0].toLowerCase())) {
3231
arguments.remove(arg);
3332
}
@@ -92,11 +91,12 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
9291
p.getWorld().dropItemNaturally(p.getLocation(), (ItemStack) excessItem);
9392
}
9493
}
95-
if (!main.getConfigValues().getGiveMessage(p, giveAmount).equals("")) {
96-
sender.sendMessage(main.getConfigValues().getGiveMessage(p, giveAmount));
94+
double price = main.getConfigValues().getBucketShopPrice(bucket) * giveAmount;
95+
if (!main.getConfigValues().getGiveMessage(p, giveAmount, bucket).equals("")) {
96+
sender.sendMessage(main.getConfigValues().getGiveMessage(p, giveAmount, bucket));
9797
}
98-
if (!main.getConfigValues().getReceiveMessage(giveAmount).equals("")) {
99-
p.sendMessage(main.getConfigValues().getReceiveMessage(giveAmount));
98+
if (!main.getConfigValues().getReceiveMessage(giveAmount, price, bucket).equals("")) {
99+
p.sendMessage(main.getConfigValues().getReceiveMessage(giveAmount, price, bucket));
100100
}
101101
} else {
102102
sender.sendMessage(ChatColor.RED + "This bucket does not exist!");

src/main/java/codes/biscuit/simplegenbuckets/events/PlayerEvents.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.bukkit.event.player.PlayerInteractEvent;
1717
import org.bukkit.event.player.PlayerJoinEvent;
1818
import org.bukkit.inventory.ItemStack;
19-
import org.bukkit.inventory.meta.ItemMeta;
2019

2120
import java.util.HashMap;
2221

@@ -35,7 +34,7 @@ public void onBlockPlace(BlockPlaceEvent e) {
3534
String bucket = main.getUtils().matchBucket(e.getItemInHand());
3635
Player p = e.getPlayer();
3736
if (main.getHookUtils().canBePlacedHere(p, e.getBlock().getLocation(), false) && main.getHookUtils().takeBucketPlaceCost(p, bucket)) {
38-
if (main.getConfigValues().getBucketType(bucket).equals("HORIZONTAL") && (e.getBlockAgainst().getFace(e.getBlock()).equals(BlockFace.UP) || e.getBlockAgainst().getFace(e.getBlock()).equals(BlockFace.DOWN))) {
37+
if (main.getConfigValues().getBucketDirection(bucket).equals("HORIZONTAL") && (e.getBlockAgainst().getFace(e.getBlock()).equals(BlockFace.UP) || e.getBlockAgainst().getFace(e.getBlock()).equals(BlockFace.DOWN))) {
3938
if (!main.getConfigValues().getWrongDirectionMessage().equals("")) {
4039
p.sendMessage(main.getConfigValues().getWrongDirectionMessage());
4140
}
@@ -66,7 +65,7 @@ public void onBucketPlace(PlayerInteractEvent e) {
6665
String bucket = main.getUtils().matchBucket(e.getItem());
6766
Player p = e.getPlayer();
6867
if (main.getHookUtils().canBePlacedHere(p, e.getClickedBlock().getRelative(e.getBlockFace()).getLocation(), false) && main.getHookUtils().takeBucketPlaceCost(p, bucket)) {
69-
if ((main.getConfigValues().getBucketType(bucket).equals("HORIZONTAL") || main.getConfigValues().getBucketType(bucket).equals("HORIZONTAL_CHUNK")) &&
68+
if ((main.getConfigValues().getBucketDirection(bucket).equals("HORIZONTAL") || main.getConfigValues().getBucketDirection(bucket).equals("HORIZONTAL_CHUNK")) &&
7069
(e.getBlockFace().equals(BlockFace.UP) || e.getBlockFace().equals(BlockFace.DOWN))) {
7170
if (!main.getConfigValues().getWrongDirectionMessage().equals("")) {
7271
p.sendMessage(main.getConfigValues().getWrongDirectionMessage());
@@ -92,7 +91,7 @@ public void onBucketPlace(PlayerInteractEvent e) {
9291

9392
private void startGenBucket(String bucket, Player p, Block block, BlockFace direction) {
9493
boolean chunkLimited = false;
95-
switch (main.getConfigValues().getBucketType(bucket)) {
94+
switch (main.getConfigValues().getBucketDirection(bucket)) {
9695
case "UPWARDS":
9796
direction = BlockFace.UP;
9897
break;

src/main/java/codes/biscuit/simplegenbuckets/timers/GenningTimer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public GenningTimer(Player p, Material genMaterial, Block startingBlock, BlockFa
2929
this.chunkLimited = chunkLimited;
3030
}
3131

32+
@SuppressWarnings("deprecation")
3233
@Override
3334
public void run() {
3435
if (blockCounter < limit && !(currentBlock.getY() > main.getConfigValues().getMaxY()) &&

src/main/java/codes/biscuit/simplegenbuckets/utils/ConfigValues.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import codes.biscuit.simplegenbuckets.SimpleGenBuckets;
44
import net.md_5.bungee.api.ChatColor;
5-
import org.bukkit.Bukkit;
65
import org.bukkit.Material;
76
import org.bukkit.entity.Player;
87
import org.bukkit.inventory.ItemStack;
@@ -93,8 +92,8 @@ public List<Material> getIgnoredBlockList() {
9392
return materialList;
9493
}
9594

96-
public String getBucketType(String bucket) {
97-
return main.getConfig().getString("items."+bucket+".block.type");
95+
public String getBucketDirection(String bucket) {
96+
return main.getConfig().getString("items."+bucket+".block.direction");
9897
}
9998

10099
public boolean bucketExists(String bucket) {
@@ -130,14 +129,14 @@ public boolean shopShouldDropItem() {
130129
return main.getConfig().getBoolean("shop-drop-item-if-full");
131130
}
132131

133-
public String getGiveMessage(Player p, int amount) {
132+
public String getGiveMessage(Player p, int amount, String bucket) {
134133
return ChatColor.translateAlternateColorCodes('&', main.getConfig().getString("messages.give"))
135-
.replace("{player}", p.getName()).replace("{amount}", String.valueOf(amount));
134+
.replace("{player}", p.getName()).replace("{amount}", String.valueOf(amount)).replace("{bucket}", bucket);
136135
}
137136

138-
public String getReceiveMessage(int amount) {
137+
public String getReceiveMessage(int amount, double price, String bucket) {
139138
return ChatColor.translateAlternateColorCodes('&', main.getConfig().getString("messages.receive"))
140-
.replace("{amount}", String.valueOf(amount));
139+
.replace("{amount}", String.valueOf(amount)).replace("{price}", String.valueOf(price)).replace("{amount}", String.valueOf(amount)).replace("{bucket}", bucket);
141140
}
142141

143142
public String getNoPermissionCommandMessage() {

src/main/java/codes/biscuit/simplegenbuckets/utils/Utils.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
import org.bukkit.Material;
88
import org.bukkit.enchantments.Enchantment;
99
import org.bukkit.entity.Player;
10-
import org.bukkit.inventory.ItemFlag;
11-
import org.bukkit.inventory.ItemStack;
12-
import org.bukkit.inventory.Recipe;
13-
import org.bukkit.inventory.ShapedRecipe;
10+
import org.bukkit.inventory.*;
1411
import org.bukkit.inventory.meta.ItemMeta;
1512
import org.bukkit.scheduler.BukkitRunnable;
1613

@@ -85,7 +82,7 @@ public void registerRecipes() {
8582
continue;
8683
}
8784
if (data != 1) {
88-
newRecipe.setIngredient(ingredient.getKey(), mat, data);
85+
newRecipe.setIngredient(ingredient.getKey(), new ItemStack(mat, 1, data).getData());
8986
} else {
9087
newRecipe.setIngredient(ingredient.getKey(), mat);
9188
}

src/main/resources/config.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ give-drop-item-if-full: true
3030
# Whether to drop items if a players inventory is full when buying from the shop. (false means it will show an error message instead)
3131
shop-drop-item-if-full: false
3232

33-
# Define your genbuckets here
33+
# Define your genbuckets here. This part may get a bit confusing with all the indents, its best to copy one of the examples
34+
# and then just edit it to your liking. Feel free to double check your formatting @ http://yaml-online-parser.appspot.com/.
3435
items:
3536
omnidirectional_cobble: # The name of the bucket, can be anything. No spaces!
3637
item:
@@ -49,7 +50,7 @@ items:
4950
# 'UPWARDS' - Will gen up from the block it's placed on
5051
# 'OMNIDIRECTIONAL' - Can gen upwards, downwards, or horizontally. The direction depends on what the bucket was placed against.
5152
# 'OMNIDIRECTIONAL_CHUNK' - Can gen upwards, downwards, or horizontally by chunk. The direction depends on what the bucket was placed against.
52-
type: 'OMNIDIRECTIONAL'
53+
direction: 'OMNIDIRECTIONAL'
5354
gui:
5455
name: '&7Omnidirectional Cobble Bucket (BUY)' # The item name shown in the shop gui.
5556
material: 'COBBLESTONE' # The material name shown in the shop gui.
@@ -74,7 +75,7 @@ items:
7475
glow: true
7576
block:
7677
material: 'OBSIDIAN'
77-
type: 'HORIZONTAL'
78+
direction: 'HORIZONTAL'
7879
gui:
7980
name: '&7Horizontal Cobble Bucket (BUY)'
8081
material: 'OBSIDIAN'
@@ -158,8 +159,8 @@ factions:
158159

159160
# Customize messages sent to the player. Set to '' for no message.
160161
messages:
161-
give: '&aYou gave {player} {amount} genbuckets(s).' # Message to the person who executed /gba give.
162-
receive: '&aYou have received {amount} genbuckets(s).' # Message to the person who received a gen bucket from /gba give.
162+
give: '&aYou gave {player} {amount} {bucket} genbuckets(s).' # Message to the person who executed /gba give.
163+
receive: '&aYou have received {amount} {bucket} genbuckets(s).' # Message to the person who received a gen bucket from /gba give. OTHER PLACEHOLDERS: {price} - The price it would have been if it was bought.
163164
no-permission-command: '&cNo permission!' # Message when someone does not have the permission to use a command.
164165
no-permission-place: '&cYou cannot place genbuckets!' # Message when someone does not have the permission to place gen buckets.
165166
no-faction: '&cYou must have a faction to use a genbucket!' # Message when someone tries to place a gen bucket without a faction when requires-faction: true.

0 commit comments

Comments
 (0)