commit e865515e6671424d287a40dd841d3021073cda1d
parent 06e6bbe78513f4b31c4f6c9f02b9c95741e049df
Author: chunksize <reisingerluca@gmail.com>
Date: Sat, 18 Feb 2023 16:26:33 +0100
Added /up command and fixed bug
Diffstat:
6 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1,4 +1,5 @@
/bin/
+/.vscode/
/lib/
*.jar
.classpath
diff --git a/build.gradle b/build.gradle
@@ -22,5 +22,5 @@ sourceCompatibility = 1.11
targetCompatibility = 1.11
dependencies {
- implementation 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT'
+ implementation 'org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT'
}
diff --git a/res/plugin.yml b/res/plugin.yml
@@ -21,4 +21,6 @@ commands:
usage: /slime
r:
usage: /r
+ up:
+ usage: /up
info:
diff --git a/src/poppy/Main.java b/src/poppy/Main.java
@@ -5,6 +5,7 @@ import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
+import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -120,6 +121,8 @@ public class Main extends JavaPlugin
return ifSlimeChunk(player, args);
case "r":
return reload(player, args);
+ case "up":
+ return blockBelow(player, args);
default:
return false;
}
@@ -335,4 +338,25 @@ public class Main extends JavaPlugin
player.chat("/reload confirm");
return true;
}
+
+ private boolean blockBelow(final Player player, final String[] args)
+ {
+ Location playerLocation = player.getLocation().clone();
+ Block blockBelow = playerLocation.add(0, -1, 0).getBlock();
+
+ if(!Utils.isAir(blockBelow.getType()))
+ {
+ return false;
+ }
+
+ if(!player.isOp())
+ {
+ player.sendMessage(Constants.Messages.NOT_ENOUGH_PERMISSION);
+ return true;
+ }
+
+ blockBelow.setType(Material.GLASS);
+
+ return true;
+ }
}
diff --git a/src/poppy/modules/AutoBreakerModule.java b/src/poppy/modules/AutoBreakerModule.java
@@ -43,7 +43,7 @@ public class AutoBreakerModule implements Listener
{
final Dispenser dispenser = (Dispenser) blockState;
- if(dispenser.getCustomName().toLowerCase().equals("breaker"))
+ if(dispenser.getCustomName() != null && dispenser.getCustomName().toLowerCase().equals("breaker"))
{
event.setCancelled(true);
diff --git a/src/poppy/modules/AutoPlacerModule.java b/src/poppy/modules/AutoPlacerModule.java
@@ -39,7 +39,7 @@ public class AutoPlacerModule implements Listener
{
Dispenser dispenser = (Dispenser) blockState;
- if(dispenser.getCustomName().toLowerCase().equals("placer"))
+ if(dispenser.getCustomName() != null && dispenser.getCustomName().toLowerCase().equals("placer"))
{
event.setCancelled(true);