commit 5e77bd165e27aefa0c2775a31313a120d6217c75
parent 4925aa5b14e6ba3f5fc689dc69fc7bf2a3256d1b
Author: chunksize <reisingerluca@gmail.com>
Date: Sun, 23 Jul 2023 15:09:22 +0200
Added enderchest command and added changes and fixes
Diffstat:
5 files changed, 111 insertions(+), 2 deletions(-)
diff --git a/res/plugin.yml b/res/plugin.yml
@@ -40,3 +40,10 @@ commands:
info:
usage: /info
description: Opens a book with the latest features.
+ e:
+ usage: /e
+ description: Opens the enderchest.
+ enderchest:
+ usage: /enderchest
+ description: Opens the enderchest.
+
diff --git a/src/poppy/Main.java b/src/poppy/Main.java
@@ -5,11 +5,14 @@ import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
+import org.bukkit.NamespacedKey;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
+import org.bukkit.inventory.FurnaceRecipe;
import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.RecipeChoice;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.plugin.Plugin;
@@ -92,6 +95,10 @@ public class Main extends JavaPlugin
blockDetectorModule = new BlockDetectorModule();
pluginManager.registerEvents(blockDetectorModule, this);
+
+ NamespacedKey key = new NamespacedKey(this, "leather");
+ FurnaceRecipe recipe = new FurnaceRecipe(key, new ItemStack(Material.LEATHER), Material.ROTTEN_FLESH, 1, 200);
+ Bukkit.addRecipe(recipe);
}
@Override
@@ -133,6 +140,10 @@ public class Main extends JavaPlugin
return doReload(player, args);
case "up":
return placeBlockBelow(player, args);
+ case "e":
+ return openEnderChest(player, args);
+ case "enderchest":
+ return openEnderChest(player, args);
default:
return false;
}
@@ -374,4 +385,33 @@ public class Main extends JavaPlugin
return true;
}
+
+ private boolean openEnderChest(final Player player, final String[] args)
+ {
+ if(args.length != 0)
+ {
+ if(!player.isOp())
+ {
+ player.sendMessage(Constants.Messages.NOT_ENOUGH_PERMISSION);
+ return true;
+ }
+
+ final Player target = Bukkit.getPlayer(args[0]);
+
+ if(target == null)
+ {
+ player.sendMessage(ChatColor.RED + "Player not found!");
+ return true;
+ }
+
+ player.openInventory(target.getEnderChest());
+
+ }
+ else
+ {
+ player.openInventory(player.getEnderChest());
+ }
+
+ return true;
+ }
}
diff --git a/src/poppy/modules/AutoPlacerModule.java b/src/poppy/modules/AutoPlacerModule.java
@@ -53,6 +53,11 @@ public class AutoPlacerModule implements Listener
faceBlock.setType(item.getType());
removeSnapshotItem(dispenser, item.getType(), 1);
}
+
+ if(Tag.ITEMS_HOES.isTagged(item.getType()) && faceBlock.getType() == Material.COARSE_DIRT)
+ {
+ faceBlock.setType(Material.DIRT);
+ }
}
if(isShulkerboxContent(item))
diff --git a/src/poppy/modules/BlockDetectorModule.java b/src/poppy/modules/BlockDetectorModule.java
@@ -3,10 +3,12 @@ package poppy.modules;
import java.util.HashSet;
import org.bukkit.Location;
+import org.bukkit.Tag;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.type.Observer;
+import org.bukkit.block.data.type.TripwireHook;
import org.bukkit.entity.ItemFrame;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@@ -60,4 +62,41 @@ public class BlockDetectorModule implements Listener
}
return itemstacks.toArray(new ItemStack[itemstacks.size()]);
}
+
+ @EventHandler
+ public void onBlockRedstoneHook(BlockRedstoneEvent event)
+ {
+ final Block block = event.getBlock();
+
+ if(block.getType() != Material.TRIPWIRE_HOOK) return;
+ if (!(block.getBlockData() instanceof TripwireHook)) return;
+
+ final TripwireHook tripwireHook = (TripwireHook) block.getBlockData();
+
+ if(tripwireHook.getFacing().toString() == "NORTH" || tripwireHook.getFacing().toString() == "EAST")
+ {
+ if(tripwireHook.isPowered())
+ {
+ if(tripwireHook.getFacing().toString() == "NORTH")
+ {
+ Block aBlock = block.getLocation().clone().add(0, 0, 1).getBlock();
+
+ if(!Tag.TRAPDOORS.isTagged(aBlock.getType())) return;
+
+ block.breakNaturally();
+ block.setType(Material.TRIPWIRE_HOOK);
+ }
+
+ if(tripwireHook.getFacing().toString() == "EAST")
+ {
+ Block aBlock = block.getLocation().clone().add(-1, 0, 0).getBlock();
+
+ if(!Tag.TRAPDOORS.isTagged(aBlock.getType())) return;
+
+ block.breakNaturally();
+ block.setType(Material.TRIPWIRE_HOOK);
+ }
+ }
+ }
+ }
}
diff --git a/src/poppy/modules/CommonModule.java b/src/poppy/modules/CommonModule.java
@@ -65,15 +65,34 @@ public class CommonModule implements Listener
final Material material = block.getType();
final Set<Material> signs = Tag.ALL_SIGNS.getValues();
+ final String playerMainItemTypeString = player.getInventory().getItemInMainHand().getType().toString();
for(Material sign : signs)
{
if(material == sign && !player.isSneaking())
{
- event.setCancelled(true);
+ if(!playerMainItemTypeString.endsWith("DYE") && !playerMainItemTypeString.endsWith("SAC"))
+ {
+ event.setCancelled(true);
+ }
}
}
+ // Location blockpos = block.getLocation().clone();
+
+ // double radius = 2;
+
+ // for (int i = 0; i < 20; i++) {
+
+ // double posX = (radius * Math.sin(i));
+ // double posZ = (radius * Math.cos(i));
+
+ // player.spawnParticle(Particle.FIREWORKS_SPARK, blockpos.getX() + posX + 0.5, blockpos.getY() + 2, blockpos.getZ() + posZ + 0.5 ,2, 0, 0, 0, 0);
+
+ // }
+
+ //player.spawnParticle(Particle.FIREWORKS_SPARK, blockpos.getX() + 0.5 , blockpos.getY() + 2, blockpos.getZ() + 0.5 ,2, 0, 0, 0, 0);
+
if(player.isSneaking())
{
return;
@@ -83,7 +102,6 @@ public class CommonModule implements Listener
if(blockdata instanceof Ageable)
{
-
final Ageable ageable = (Ageable) blockdata;
if(Utils.isFarmable(material) && ageable.getAge() == ageable.getMaximumAge())