#help-development
1 messages · Page 411 of 1
is that visual studio
probably vscode
Vsc
He might not have correct repository / not java extension pack
I'd switch to a java IDE. Heck even eclipse would be better
nah, I'm good, just not used to mac
I'm at home for a week
I've been coding plugin with vscode on my windows pc
you're missing the spigot repo
bruh
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>```
this is the repository.
like so?
thank, do I even need my repo there? or should I just remove it?
Mvn reload?
nah you just click a button :)
you should not need it there, no
Since you're not depending on it (you wouldn't be, anyway.)
I missread something somewhere then lol
The forum guide is a little outdated so
Thank you, and I did not eat your butter.
a 7 year old joke
has anyone run into issues where fireworks that get stuck in weird places will stay alive functionally forever?
no ig
so i got a friend that is making a little prison server for him and his friends he asked me to code a custom enchant for 3x3 mining well i have got everything setup but when i add the enchant to the pickaxe and mine it does 3x3x2 and i want it to do 3x3x1 and i cant seem to figure out what i have done wrong in my code so i figured i would come n ask here to see if i could get some help
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
ItemStack item = player.getInventory().getItemInMainHand();
player.sendMessage(item.getEnchantments().toString());
if (item.getEnchantments().containsKey(Enchantment.getByKey(Kiki_pick.explodeEnchant.getKey()))) {
List<Location> locations = new ArrayList<>();
int locRad = 3;
int r = locRad - 1;
int start = r / 2;
Location sL = block.getLocation();
sL.setX(sL.getX() - start);
sL.setY(sL.getY() - start);
sL.setZ(sL.getZ() - start);
for (int x = 0; x < locRad; x++) {
for (int y = 0; y < locRad; y++) {
for (int z = 0; z < locRad; z++) {
locations.add(new Location(sL.getWorld(), sL.getX() + x, sL.getY() + y, sL.getZ() + z));
}
}
}
for (Location loc : locations) {
loc.getBlock().breakNaturally(item);
}
}
}
does it do 3x3x3 or 3x3x2?
you are looping over x, y, and z. usually you would only want to loop over 2 dimensions instead of 3
its mining 3x3x2
does the orientation work correctly? e.g. it always goes 2 in depth, no matter in which direction you are mining?
depending on the direction, you should not change the x or z value
when looking at positive or negative x, you should only loop over y and z, and when looking in z direction, you should only loop over x and y
yeah no matter which way i mine it does 3x3x2
so with what you are saying is i need to make a loop for each direction like UP, DOWN, LEFT, RIGHT something like that
no
you only need to loop half the directions if its even
because you can just simply mirror
however you should loop over y first
since it is the smallest
well i guess im confused at this
Just mirror four times smh.
locations.add(new Location(sL.getWorld(), sL.getX() + x, sL.getY() + y, sL.getZ() + z));
locations.add(new Location(sl.getWorld, sL.getX() + (x*-1), sL.getY() + (y*-1), sL.getZ() + (z*-1));
so the first one is your original, which would go in one way
the second, will go the other way at the same time
this is the easiest way
there are other ways depending how familiar with math you are, to mirror
so with that shown and said, you now don't need need to loop for all directions, just half of them 😉
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
Why isnt my anvil working?
https://paste.md-5.net/corobosolu.cs
so the list you access in the command is not the same list as the one you access in the listener
use the same instance of your class for both, the command and listener. or, better: do not mix listeners and commands in one class
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
its not giving me a result item*
did you register the listener? do all the if statements even get executed? add a debug statement to each if statement to see if they actually eveluate to true
why that?
just use the same List<String> in both classes
this was a reply to the "why isnt my anvil working" message
as I already said, your List<String> doesn't work because you created two instances of your class
yep, that should fix it
its giving me all 3 "here1" but doesn't give me a result
https://paste.md-5.net/udomudigig.cs
You should import manualy
try to already change the result item in the PrepareAnvilEvent instead
I need to correct myself, it doesn't display a result item but when i click the EmptySlot it gives the lore to the sword in the 1st slot
yeah because you add the lore to "inputItem"
why don't you just use the PrepareAnvilEvent to change the result? And why do you add any lore to the input item in the first place?
usually you never change the input items, but only the result item
take a look at the guides, I personally learnt from Kody Simpson on YouTube
basic kotlin knowledge is expected
ofc
he is coding in java, but you can apply his API usage to kotlin
np
watch his course even if i work in paper?
do you actually need anything from paper api? if no, there's no reason to use it
performance i think
thats it
you can code a plugin against the spigot-api and still run it on paper
I do advice to use a gui library
because working with raw gui spigot API is masochism
public int getPing(Player p) {
int ping = p.getPing();
return ping;
}
always returns 0 for some reason (not on localhost)
first of all, why is this a separate function if you can just call Player#getPing?
it was some old method which i had to redo because of updates, used to do something like this
Object entityPlayer = player.getClass().getMethod("getHandle").invoke(player);
int ping = (int) entityPlayer.getClass().getField("ping").get(entityPlayer);
wait... maybe i know why
ah still doesent work if i rename method
it takes a while to update
ahh you are right thank you
@eternal oxide you posted this code for the issue I had but that'll always return true. Shouldnt it be checking if the slot from the event is 36?
@EventHandler
public void onSwap(PlayerSwapHandItemsEvent event){
if (slotToLock == 36 || slotToLock == 45)
event.setCancelled(true);
}```
Seems like an odd piece of code, but perhaps Im too stupid to understand it
no
on swap is only for swapping hands so you only prevent it IF you are protecting slot 1
one sec I'll pull up the current code
Uhh I think it's broken
Swapping with hotkeys doesnt work and dropping also doesnt work, so thats good
?paste
mine works, apart from drop as thats just sample code
mine is using slot 0-8
as it doesn;t use raw
all you have to do is check it's the correct item
Does that mean it can break when using other inventories such as opening chests?
Nevermind it works, although the onSwap prevents me from swapping anything
@EventHandler
public void onSwap(PlayerSwapHandItemsEvent event) {
if (slotToLock == 0)
event.setCancelled(true);
}
and that's not really wanted
PlayerInteractEvent fires EquipmentSlot.HAND twice when RIGHT_CLICK_BLOCK
all you need to do is check if the item in the main hand is your item
True, Ill do that instead
else ```java
@EventHandler
public void onSwap(PlayerSwapHandItemsEvent event) {
if (event.getPlayer().getInventory().getHeldItemSlot() == slotToLock)
event.setCancelled(true);
}```
but noit neded for you as you can just check for your specific item
?interactevent
The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.
For example, only executing code if the main hand was used:
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
return; // do not progress past this point |
}
// provide functionality
}
@wraith cipher ^
Right now Im using java @EventHandler public void onSwap(PlayerSwapHandItemsEvent event) { if (event.getMainHandItem().getType() != Material.NETHER_STAR || !event.getMainHandItem().hasItemMeta()) return; if(event.getMainHandItem().getItemMeta().getCustomModelData() != 1) return; event.setCancelled(true); }
But it still allows me to switch to my offhand, but it doesnt allow me to switch it back to my main hand
check offhand too
like java if (yourCustomItem.equals(event.getMainHandItem() || yourCustomItem.equals(event.getOffHandItem()) event.setCancelled(true);
I'm assuming your custom item is unstackable adn they will only every have one
if not
if (yourCustomItem.isSimilar(event.getMainHandItem() || yourCustomItem.isSimilar(event.getOffHandItem()) event.setCancelled(true);```
then use isSimilar as that ignores quantity
Should yourCustomItem just be the Itemstack with a custom itemmeta?
its also easier than checking the type and model data separately
it shoudl be the item you give to the player
k
in yoru code you should create it once (probably static) and keep it available
so MyCustomItems.NETHER_STAR
Yeah thats what Im trying but something like this isnt possible afaik
ItemStack netherStar = new ItemStack((Material.NETHER_STAR).getItemMeta().setCustomModelData(1));
create a private method
then your field would be static ItemStack NETHERSTAR = getStar();
ItemStack getStar(){
ItemStack item = new ItemStack(Material.NETHER_STAR);
item.getItemMeta().setCustomModelData(1);
return item;
}```
yep. make the method private so it can only be called inside your items class
If i make a constructor from the Listener Class to another class, i can manage the event from the other class?
naming conventions also say thi sis a constant so shoudl be all upper case
same as an enum
Just wanna know bcause i have to listen to like 7 inventories
Yes, just add a method in the other class to accept the event
Okay
Thanks
To cancel properly the inventory click event in a custom inv should be like this:
- all the listener stuff and that *
if (e.getView().getTitle().equalsIgnoreCase("inv title)){e.setCancelled(true)}
Or
(e.getView().getTitle.equals("Inv title)){ e.setCancelled(true)}
just confused because any of that works
don;t compare inventories by title, use their instance
Now it doesnt do anything anymore, apart from saying "Right clicked" when i right click it
https://paste.md-5.net/uropojikaq.cs
But it also doesn't say rightclicked if I check if the item == netherStar in onPlayerInterct
not != use .isSimilar in swap
what is that sentence
err in drop
Can u give me a example?
in drop java if netherStar.isSimilar(event.getItemDrop().getItemStack()) event.setCancelled(true);
I cant drop normal netherstars but I can drop netherstars with custommodeldata
So I think item.getItemMeta().setCustomModelData(1); isnt working
your logic is reversed
or that
you no longer need those checks
all you do is java if (netherStar.isSimilar(item)
no checking meta nor the model data
But how is that going to fix my issue
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
Inventory clickedInventory = event.getClickedInventory();
if (clickedInventory != null && clickedInventory.equals(inventory)) {
e.setCancelled(true)
}
}
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
if (netherStar.isSimilar(item)) {
Bukkit.broadcastMessage("Clicked");```
Smth like that?
If you create a Listener for every GUI or you check for every GUI inventory by name or with equals/== then you
are doing something wrong. This scales poorly and you are just repeating your code for every new inventory.
Ill try to follow your guide
Right now Im using this https://paste.md-5.net/rofoduqolu.cs and it almost works. Only issues I have no clue how to fix are:
- When using /give player nether_star{CustomModelData:1} it gives me 2 netherstars. If I remove the custommodeldata part it gives me just 1 netherstar
- When I have a normal netherstar in my offhand, and a custommodeldata=1 netherstar in my main, I can swap them using F.
Im checking if it has custommodeldata so idk what's happening
@lost matrix can you answer me a doubt?
Sure
I showed you the swap method.
if (yourCustomItem.isSimilar(event.getMainHandItem() || yourCustomItem.isSimilar(event.getOffHandItem()) event.setCancelled(true);```
Here ur only indexing stuff into the Map for the inventories right?
And the handler is the same from the InvetoryHandler interface for every onClick, onOpen and stuff?
Yes, but it didn't work. The entire thing revolving around defining netherStar = getStar broke the entire piece of code. I didn't feel like fixing everything over so I stuck with the code that did work and only had 1 little issue
Now I fixed that issue and it has 1 even tinier issue
that code I just posted will work for swapping
if either hand is one of your custom stars it will cancel
Yes but that doesnt fix the other 3 functions that broke
You can look at the examples further down. The key is the Bukkit Inventory and the value is a Handler
which is used for this Bukkit Inventory. So every Inventory you open has its own InventoryHandler instance.
ok your interact is still using bad/old code
you don;t have to check meta nor model data anymore
Why not
thats what your item is for
K thanks
Always use the PDC to check for custom items
the item is fine
Why not check for custommodeldata
Because this can be subject to change. You visual representation should be completely disjunct from
your items identification. What if you wanted to change the model later on.
Why would I want it to store more
Let's go back to ooga booga time and store a single number for every time we need data
Then I just change it and use the same custommodeldata?
PDC is basically an NBT wrapper type thing
You can store custom objects, binary data
And it's not limited to just items
?pdc
I get it, PDC is cool, but you're missing my point
Why would I need to store more info
I just need 1 number
to identify what item it is
Use the PDC. The primary take here is: You visual representation should be completely disjunct from
your objects identification. Apply this to everything and you will have much cleaner and future proof code.
future expandability pretty much
What if in the future, you want to have multiple tiers to your nether star?
You visual representation should be completely disjunct from
your objects identification.
why
I uh... don't
Well whatever I'm not going anywhere by suggesting good practices to someone that's in denial
Why am I in denial
Im just wondering why I should use PDC if I only want to store 1 thing
For why:
What if you wanted to have 2 items which use the same model
but do different things. For example one is a mildly upgraded
version of the other. Then you need to check for the model data
and something else. Extrapolate this idea and you will have a horrible
mess.
You may onl;y want one thing today. Tomorrow you may expand
aren't you vaccinated?
Vaccinations actually give you a higher chance of sideeffects compared to non-vaccinated nowadays
But let's leave that out of the chat
That violates the open closed principle. Your code should always be open to
to extension but closed for modification. This automatically makes your code
more modular without having to put extra time into it.
before we start a war

You dont lose time when writing scalable code if you just always follow the SOLID principles.
None of the principles should be followed religiously to the fullest
Well yeah. Take them a bit softer
k I think pdc might work for this seeing as I do want to store "spells"/powers in the netherstar (I think?)
Basically what I want to do is:
Every player has their own netherstar that, when they right click, opens up a new hotbar containing "spells". I think it might be useful to store those spells inside the pdc instead of inside a different function that stores them for each player. But that also means that if the player loses that one netherstar for some reason, all of the spells inside are gone right? If I store the spells inside a different object that is assigned to a player, it won't ever disappear (unless someone deletes the config)
They’re guide lines to make your code as future proof as possible towards changes
You can avoid that by storing a UUID inside each nether star
regardless, you shouldn't really store data in configs
SQLite or literally any other database works better
We were talking about how great PDCS are and now you go to UUIDs
whatever those are
Yourt item didn;t work because you never put teh meta back on it java private ItemStack getStar(){ ItemStack item = new ItemStack(Material.NETHER_STAR); item.getItemMeta().setCustomModelData(1); return item; }
And finding out which ones need to be is usually part of the project planning phase.
But nobody here uses a Waterfall or Agile approach when they write their plugins.
They just write it and add a bunch of stuff over the years.
Scrum :D (/s)
so your item never had custom model data
?
oh
I thought the .setcustommodeldata would do that
Yes. Still dont know what our Scrum master did the rest of the day after standup is done. 🥲
🥲🥲
So it should be
private ItemStack getStar(){
ItemStack item = new ItemStack(Material.NETHER_STAR);
item.setItemMeta(item.getItemMeta().setCustomModelData(1));
return item;
}```
Almost
store the itemmeta in a variable
modify it
set the meta back to the item by using the variable
I've been coding for a while and even I had to rewrite an npc system 3x this week
Yes but thats like 3 lines. Why not make it 1 line
dw the interface:actual class ratio is like 3:1 now
Is it packet based? If so then i need a hint on how to make them fking look at a location.
I mean scalability is more of a point when we talk about capacity, that is concurrency often. Else it’s just maintainability, quite the difference
uhh It's a fancy wrapper for citizens
but if you want to learn about making them look at a location
you just send packets with the npc's entity id
Eh. I wrote this so that i can get away from the citizens mess of a plugin.
Citizens does so by calling NMS.lookAt(npc.getEntity(), yaw, pitch)
Good question
It delegates to PacketPlayOutHeadRotation
idk
or ClientboundWhatever
Design choice from api designers justin
are gambling plugins allowed on spigot
yeah ik but free ones? couldnt find anything about it
actually there's a PlayerNPC thing that uses packets
Not tested but https://paste.md-5.net/nikivefifu.java
@lost matrix if you're using an EntityPlayer internally
fixed
Thx but i dont have an NMS implementation for my NPCs. Its Plib based
I was just writing that too lol. I gave it a test but moving in inventory and swapping in inventory still work. Dropping and swapping hands is fixed
yes that on click code is only to lock a specific hotbar slot
hello guys, i'm trying to create a custom block, and i would like to use something like /mycmd give user 4 but i dont know how to pass my args in the command usage.
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
{
if (!(sender instanceof Player)) {
sender.sendMessage("Only players can use this command.");
return true;
}
Player player = (Player) sender;
ItemStack item = new ItemStack(Material.GOLD_BLOCK, 1);
Inventory inv = player.getInventory();
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("&6Gold Machine");
item.setItemMeta(meta);
inv.addItem(item);
return true;
}
Still doesnt work though. If I click the 1st hotbar slot it just lets me move
it will only protect a specific slot, doesn;t matter what item it is
it works as I tested it
Assuming the slot is the first slot in hotbar
yes
Both
Im using 1.17.1, not sure if that changes anything
new discord update killed imags :/
your issue is you are testing currentItem
Ah I see
Hm ive only tried sending either so far. Let me try sending both.
so hovering over a slot and pressing 1 does not return slot 1 contents for getCurrentItem. it returns the item ion the slot you are hovering
you need to player.getInventory().getItem(event.getHotbarButton())
if event.getHotbarButton() != -1
👍
Thats just the gif resetting
I changed it to this so that players can still drop items in their first slot if it's not a netherstar, which works, but now swapping doesn't work correctly
@EventHandler
public void onClick(InventoryClickEvent event) {
if ((event.getSlot() == slotToLock && event.getSlotType() == InventoryType.SlotType.QUICKBAR)
|| (event.getHotbarButton() != -1 && event.getHotbarButton() + slotToLock == slotToLock)) {
if (!netherStar.isSimilar(event.getCurrentItem())) return;
event.setCancelled(true);
}
}```
Hmm true
you are not using any of the code I just told you
The
player.getInventory().getItem(event.getHotbarButton())
if event.getHotbarButton() != -1
part?
@EventHandler
public void onClick(InventoryClickEvent event) {
if (event.getHotbarButton() != -1 && netherStar.isSimilar(event.getPlayer().getInventory().getItem(event.getHotbarButton()))) {
event.setCancelled(true);
}```
probably
This works perfectly:
@EventHandler
public void onClick(InventoryClickEvent event) {
if (event.getHotbarButton() != -1 && netherStar.isSimilar(event.getWhoClicked().getInventory().getItem(event.getHotbarButton()))) {
event.setCancelled(true);
}
if (!netherStar.isSimilar(event.getCurrentItem())) return;
event.setCancelled(true);
}```
Only problem now is when I use /give me nether_star{customModelData:1} it gives me 2 instead of 1
nothign to do with any of that listener code
No that's what I thought
but what else would it be
Perhaps there's an event being triggered
causing it to duplicate..., somehow?
why is this not working as it should?
command file
public class Machine implements CommandExecutor
{
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
{
if (!(sender instanceof Player)) {
sender.sendMessage("Only players can use this command.");
return true;
}
Player player = (Player) sender;
if(args.length == 0) {
player.sendMessage(ChatColor.RED + "Correct usage: /machine <amount>");
return false;
}
if (args.length >= 1) {
ItemStack item = new ItemStack(Material.GOLD_BLOCK, Integer.parseInt(args[0]));
Inventory inv = player.getInventory();
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(ChatColor.GOLD + "Gold Machine");
item.setItemMeta(meta);
inv.addItem(item);
}
return true;
}
}
plugin.yml
commands:
machine:
description: Machine command.
usage: /machine
aliases: mcn
permission: machines
permission-message: You do not have permission to execute this command.
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
it doesn't reply with the correct usage, neither give me the custom item
what does it reply with
/machine
you didnt register the command executor
only if you register the command
public void onEnable() {
getCommand("machine").setExecutor(new Machine());
I need help. I want to check for the item in slot 10 and 12 and if they match with what i want then after clicking slot 14 you get a result in slot 16. After clicking slot 14 nothing happens! please help
https://paste.md-5.net/igadosobas.java
what's CSTMItems?
it worked now, but it still send /machine
you mean when no amount is entered?
that's because you "return false"
return false = "show usage"
my class with custom ItemStacks
ah ok, I thought it was your main class
if i dont return, it wont send /machine?
you gotta "return true"
oh ok
do your if statements get executed? add a debug System.out.println inside every if, then see where it stops
should i use ChatColor.COLOR + "Gold Machine" when setting the display name or use some different method?
yes
ok
if you wanna make it configurable, yu can use ChatColor.translateAlternateColorCodes
String name = "&cGod Machine";
String transatedName = ChatColor.translateAternateColorCodes('&', name);
that turns "&c" into red
np
returns all besides 5 & 6
omfg. I shouldnt program when im tiered...
This took me too long
what is 5 & 6?
can i check if my custom item was placed?
it does print "here4", but neither "here5" nor "here6"?
because that actually can't be
like, only gold_blocks with that specific name
check the name of the item in BlockPaceEvent
however rather use PDC tags
you should never rely on names to identify your custom things
i can create custom tags?
yes
PDC can store basically any data
you could e.g. store a boolean "isMyCustomGoldBlock", or a string like "myCustomItemId" if you have more than one custom item, etc
Spawned at another location to test it out. But he doesnt have a cool skin so i spawned Tom2 XDD
and where's Tom0
🥲
Oh dang there is propr. info in that vid...
Nobody ask about those multiple lines in the action bar pls
I tried doing this to fix it, but now whenever I interact with any item that has more than 1 just gets set to 1.
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
int count = 0;
for (ItemStack i : player.getInventory().getContents()) {
if (i != null && netherStar.isSimilar(i)){
count += item.getAmount();
if (count >= 2) {
item.setAmount(1);
break;
}
}
}
if (event.getAction().name().contains("RIGHT") && netherStar.isSimilar(item)) {
Bukkit.broadcastMessage("Rightclicked netherstar");
}
}```
I'm checkiing if it's the right netherstar though? Why is this happening
I did read the other chat
Ah yeah you know how its done 😄
:>
What were those multiple lines?
I saw them and I thought they looked pretty cool

Do not try and fudge a fix for too many items. find the actual cause
Couldnt find it though :/
then keep looking
you are either using the give command incorrectly or you have some code doubling it up
This is literally the only code Im using
And an onenable that instantiates it
but that's it
?paste unreadable for long pastes in Discord
nothing in that code is causing multiple items
Exactly
then it's not that class. look elsewhere
so whats in main
do you get duplicates if you remove your plugin?
Im testing that now
how do i see if the pdc tag is correct?
nope
you can check the PDC tags of your item in your main hand by doing
/data get entity <yourUsername> SelectedItem
then check for the part that says "PublicBukkitValues"
Perhaps it had to do with me reloading the server a billion times
using /reload sometimes breaks stuff
Still duplicates it
...
/give JustinS_2006 minecraft:nether_star{CustomModelData:1} 1
it worked, but how would i check for this pdc tag when using the BlockPlaceEvent?
It always gives 1+ the amount specified in the command
So it doesn't duplicate it @eternal oxide
It just adds 1
you can get the item in use from the BlockPlaceEvent, then check if that item has your PDC tag
I've never use teh MC give command so can't comment
ItemStack item = event.getItemInHand();
if(!item.hasItemMeta()) return;
PersistentDataContainer pdc = item.getItemMeta().getPersistentDataContainer();
if(pdc.has(myKey, PersistentDataType.YOUR_DATA_TYPE)) {
// It's your item
}
Here's chatgpt's fix
To fix this, you can simply remove the 1 from the CustomModelData tag in the command, like this: /give me nether_star{CustomModelData:} amount. This will ensure that the game interprets amount as the number of Nether Stars to give, rather than the maximum stack size.
chatgpt drunk again
Ill just not use /give
Usual senior dev error be like
Hey, Anyone know what repo I should be using in my pom.xml file when trying to include mcMMO?
they don't mention it anywhere. I'd just compile it from source, then mvn install it
then you have it in your local repo and don't have to declare any external repo
I just checked their pom, they publish snapshots to https://nexus.neetgames.com/repository/maven-snapshots/ and releases to https://nexus.neetgames.com/repository/maven-releases/
so could I use those as repos or should I still create the local repo for it?
you can use those repos
Code: https://sourceb.in/wPjBqh6rP2
Cannot invoke "org.bukkit.configuration.ConfigurationSection.getKeys(boolean)" because the return value of "org.bukkit.configuration.file.FileConfiguration.getConfigurationSection(String)" is null
This code is for a sieve and when i pick like
Sieve:
Gravel:
...
SAND:
...
Depending on what's below Gravel or Sand it is not a ConfigurationSection.
Sieve:
Gravel:
- example: exampleValue
example2: exampleValue2
is not a configurationSection but a List of Objects
not a List
Then what is below Gravel or SAND?
Gravel:
time: 10
items:
- "TEST"
It keeps the original lore, but doesnt add the "War Hero I". What do i do?
https://paste.md-5.net/asirufavax.cs
How can I make my plugin handle reloads? As in, I want to keep some data over from before the reload and after
What are some good practices
PDC, database or config
huh?
That does look like a configurationSection. You can try
Object x = plugin.getConfig().get("Sieve." + itemsName);
System.out.println(x.getClass());
to find out what it is interpreted as
== instead of equals?
it works tho
that isnt the problem
the lore is not being added
If he only has one instance of this inventory then == is fine
Do spigot/paper plugin work in Velocity/Pufferfish ?
dont think CraftInventory overrides .equals() so it does the same thing anyways
Did you learn about:
- Maps
- Interfaces
- Singletons
So far? If yes then i have a decent GUI approach for you
how can i make a custom command in a plugin?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
thanks!
is there something in kotlin?
Its the same. Just with kotlin syntax...
i am still a beginner, so i am note rlly good in converting
The error as before
IntelliJIDEA will convert it for you, if needed
I feel like you should learn Java first to really grasp the benefits and caveats of Kotlin
You can't get an error from a function you are not calling. How did you adapt the code?
learned java, but still new in kotlin
and not that much even in java tho
https://sourceb.in/wPjBqh6rP2 the function is before the loop
i know, but i am trying to do this stuff by my own without intellij's help
Where is the code snippet I just sent in order to find the type of the section?
Inside the first for
So for itemsName
Object x = plugin.getConfig().get("Sieve." + itemsName);
System.out.println(x.getClass());
I can't find this anywhere.
Put it before line 10 and check what's the result
Thats the old one
???
What i send you is the first one, in the sourcebin
There's nothing wrong with having the IDE help you. Try to understand what changed and in the future you can do it without its help
I added it but it gives the error from the Set<String> called items
You will still receive the error obviously. What's relevant is what is printed
I just don’t get nothing the loop is based on Items so if items give me an error the loop just doesn’t work
But isn't the error thrown at this line?
ConfigurationSection itemConfig = plugin.getConfig().getConfigurationSection("Sieve." + itemsName);
Now im seeing yes, but that part still doesn’t start
Whats this about? You can store and load ItemStacks from configs by simply using
FileConfiguration configuration = ...;
ItemStack itemStack = configuration.getItemStack("path.to.itemstack");
.
He's trying to get a ConfigurationSection but it states that it isn't a configurationSection
my code : https://paste.md-5.net/canikicira.java
my error: https://paste.md-5.net/fepelamaqi.sql
and i am giving the player the specific hashmap entry when they join for the first time, yet I am getting this error
thats right, but if i start without its help, its gonna be easier, like 5 mins ago i didnt know how to make that code in kotlin, now i know
Looks like you are trying to get a key which is not in your config
is it right like this:
package eu.lostgamers.AdvancedPlugin
import org.bukkit.Bukkit
import org.bukkit.Material
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.event.block.BlockBreakEvent
import org.bukkit.event.player.PlayerJoinEvent
import org.bukkit.inventory.ItemStack
import org.bukkit.plugin.java.JavaPlugin
class Main() : JavaPlugin() , Listener, CommandExecutor {
init {
print("This got called before everything else!")
}
override fun onEnable() {
Bukkit.getLogger().info { "Advanced plugin started!" }
Bukkit.getPluginManager().registerEvents(this,this);
this.saveDefaultConfig();
}
override fun onDisable() {
Bukkit.getLogger().info { "Advanced plugin stopped!" }
}
@EventHandler
fun onPlayerJoin(e: PlayerJoinEvent) {
e.player.sendMessage("Welcome to our network, ${e.player.name}")
}
fun onCommand(sender: CommandSender, cmd: Command, label: String, args: Array<out String>) {
if (sender is Player) {
sender.health = sender.maxHealth
sender.sendMessage("You have been healed")
}
}
@EventHandler
fun onBreakBlock(e: BlockBreakEvent) {
val block = e.block
val blockMaterial = block.type
logger.info("${e.player.name} broke a $blockMaterial at ${block.x}, ${block.y} ${block.z}")
}
}
Show where you're adding it
Usually you want to create a new class for every command.
Its correct Sieve exist, the error is on the first Set<String> items = …, my idea is probably deep giving the problem?
ok 1 min
class Heal() : JavaPlugin() , CommandExecutor {
override fun onCommand(sender: CommandSender, cmd: Command, label: String, args: Array<out String>) {
if (sender is Player) {
sender.health = sender.maxHealth
sender.sendMessage("You have been healed")
}
}
Didnt even see that you are iterating by key. Then obviously you will iterate
all keys down to your primitives. And those are not sections ofc.
the ide tells me that i have to change the return type to boolean, why tho?
You are not allowed to extend JavaPlugin
what does that mean
Sorry, but what you mean?
Returns true if command was successful and false otherwise
You meant this?
public defaultskill(Rpg plugin) {
Bukkit.getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (player.hasPlayedBefore()) {
player.sendMessage(ChatColor.GREEN + "Welcome Back!");
}
else {
strength.StrengthMap.put(player.getUniqueId(), 0);
speed.SpeedMap.put(player.getUniqueId(), 100);
crafting.CraftMap.put(player.getUniqueId(), 0);
husbandry.Husbandrymap.put(player.getUniqueId(), 0);
max.stmax.put(player.getUniqueId(), 5);
}
}
}```
oh ok
This means that you can not extend the JavaPlugin class
so i just put CommandExcuter?
You're never putting anything in progressxp.stprog which is what you're accessing in the EntityDeathEvent
So it's returning null, and then when you call intValue() on a null object... well there's your NPE.
ahh, completely overlooked that. Thanks!
How can I replace the players inventory with a different inventory upon command, then change it back to the old inventory too
Hi, does anyone know what type of problem is this? java.lang.NoClassDefFoundError: net/minecraft/world/entity/monster/Zombie
im using remapped mojang jar, maybe i should attach remapped jar somewhere?
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
someone doing bot attack on my server hoow i canfix
You have to remap it back to obfuscated when you compile
We need more Details. Also: Do you want a programmatic approach or what do you mean by "fix"?
but all class paths will be diff
Wdym? The server is using the obfuscated JAR
So by not remapping you're making them all different.
Which is why it can't find that Class.
How can I build my project (using jitpack) while having nms as dependency?
maven or gradle
you could run buildtools using the maven-exec-plugin but that sounds like a dirty solution
why don't you just use a proper repo instead?
maven
yeah most likely youd have to run buildtools
run it on the jitpack server?
probably as some kind of maven task
it'd be way easier to just build it locally and then publish it to some repo
you dont have to do anything special
https://github.com/patheloper/pathetic/tree/production/pathetic-nms
https://jitpack.io/com/github/patheloper/pathetic/2.1.0/build.log
you could also check out this https://www.spigotmc.org/threads/unsolved-working-with-jitci-nms-dependency.555532/
Do I need nms for creating heads from these textures? eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzNhOTZlOTU0YmQyNTRhOTFhNDE1NTIwNDQ2Y2Y3OGE4OGNlM2VmNTM5ODY3M2JjZTRiODQ3NzUzMzRjZGQzOCJ9fX0=
no
no
._.
by providing more information
does Spigot provide a way to manage I/O files other than config.yml? Or should I just do it in plain java
JavaPlugin#saveResource
hey
So i got an issue that you guys might be able to help me with
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onLastDamageEntity(EntityDamageEvent e) {
if (!(livingEntity instanceof ArmorStand) && livingEntity.getHealth() - e.getFinalDamage() > 0)
return;
}
And what may that question be?
sorry someone texted me
had to respond to that first
anyways
the issue i have is that its not always triggering im not 100% if its the event, i rather think that somethings wrong with the if statement
or is it possible that the event doesnt get triggered?
any ideas whats wrong with it?
what ru tryna achieve
its not me trying to achieve
im working with an api and i found a dupe on it
im trying to replicate it but its not consistent
am i doing smthn wrong with my code, when the guardian spawns its just a beam of bubbles, no laser
this.location = location;
this.guardian = (Guardian) location.getWorld().spawnEntity(location, EntityType.GUARDIAN);
this.squid = (Squid) location.getWorld().spawnEntity(location.clone().add(0, 0.01, 0), EntityType.SQUID);
scheduler = Bukkit.getScheduler().scheduleSyncRepeatingTask(SAdd.getInstance(), new Runnable() {
@Override
public void run() {
guardian.setTarget(squid);
}
},0,2);
guardian.setInvisible(true);
guardian.setGravity(false);
guardian.setSilent(true);
guardian.setInvulnerable(true);
squid.setInvisible(true);
squid.setGravity(false);
squid.setSilent(true);
squid.setInvulnerable(true);```
where is that livingentity from lol
the issue is that after this event, the entity equipment gets cached so it can multiply the drops on death, this should prevent the duplication of donkey inventories but it sometimes still passes
ur doing checks on the same livingentity regardless of the entity that was damaged
whats the issue with that?
h
ah
wdym whats the issue wiht that xd
LivingEntity livingEntity = (LivingEntity) e.getEntity();
not sure what that piece of code is going to do tho. since u just return, unless thats not all the code
i think he means to set it to cancelled
i think he jsut mixed up return and setcancelled
@jagged briar
?
that would stop him from damaging any entity that's not an armorstand and has sufficient health
not sure thats the end goal here
nope
let me send you a pastebin
one sec
okay so maybe he does not want to do anything to things thatr are armorstands or things that wont die
this code is very stripped out
cacheEntityEquipment(livingEntity);
also are armor stands considered living entities?
ye
take my opinion with a grain of salt because im also bad at programming but
shouldnt it be ||
na
you get whats supposed to happen right?
hes caching equipment if the entity is not an armorstand and the entity will die after that event
checked with the health
sometimes the entity quipment doesnt get cached thus causing the plugin to multiply the donkey loot
and what is the problem
it multiplies the stuff in the chest of the donkey as well
therefore youre able to dupe
is this ur updated code?
its not my code as i said
im using an api
and i want to fix the dupe myself since the actual dev is lazy
and thats the version that has the dupe in it
ah
LivingEntity livingEntity = (LivingEntity) e.getEntity();
yep
did u strip that out?
what exactly do you wanna do?
ye since i tried to cut it down for discord
should i create another one?
make message and ban logs, but not anymore i'm just going to use yaml so its just using YamlConfiguration.loadConfiguration
yea why not
aight
and regarding the problem. you should add some debug messages, so you can see whats being ran when the donkey dies
then you will know if the event is being called etc.
why are you using HIGH instead of MONITOR? Plugins could still change the final damage on HIGH and HIGHEST, you wouldnt be able to catch those
you should definitely use monitor for this
i was thinking of that as well
hmm
it isnt my plugin as i said
that could be the solution
is there a way to make my plugin load after everything else? so I can override any other plugins with the same command names
I also wonder what's the "cache" for anyway, why not just get the equipment directly in the death event?
There is load field in plugin yml
You can set it to pre world ig
what would be the purpose of that?
i have it on startup
bump
so my commands arent overriden by others?
do you want to manually create a laser beam?
wdym by manually create
yeah im doing it myself
oh
what about in legacy versions
getServer().getScheduler().scheduleSyncDelayedTask(this, () -> {
getCommand("<name>").setExecutor(new CommandNameThing());
});
would that work
no, that only works for your own plugin's commands
you can loop over the command map to get all commands
final CommandExecutor myExecutor = new MyExecutor();
final SimpleCommandMap commandMap = ((CraftServer) Bukkit.getServer()).getCommandMap();
for(final Command command : commandMap.getCommands()) {
if(command instanceof PluginCommand pluginCommand) {
pluginCommand.setExecutor(myExecutor);
}
}
I'm wondering what the impact of saving a json file not during server start or stop would be. It shouldn't be a super large file definitely wouldn't even hit a mb
what's the cleanest way of making such a scripting system
should i put a delay to ensure all other plugins loaded ?
I'd create a BiConsumer<Context, String[]> for each "command", then have them in a map.
E.g. Map<String, BiConsumer<Context, String[]>>. Then for the first, you get the "npcselect" consumer and throw the args {"npc-one"} at it. The context class could hold information like "which npc is selected" etc bla bla
yes

I still wonder what's the purpose of overriding other plugin's commands
thinking npcselect.* -> args do whatever
and then have to do some fancy ass validation
it'd be fun
idk peace of mind
Epic design pattern I haven’t heard any1 mention in a long time
or maybe a BiFunction that would return SUCCESS or FAILURE or sth or whatever
idk it's the first thing that came to my mind
Hey I'm trying to make a Vigenere Cipher encryption but when I put in as the user input "in a land far far away" with the key being "test" it's not encrypting correctly. I'm getting dZs\tX[i_e`\me`\me[r\e when I should be getting bXsZtVYg]e^Zke^ZkeYpZc java @Override public String encrypt(String input) { StringBuilder sb = new StringBuilder(); int keyIndex = 0; for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); int shift = key.charAt(keyIndex) - START_CHAR; char encrypted = (char) ((c + shift - START_CHAR) % RANGE + START_CHAR); sb.append(encrypted); keyIndex = (keyIndex + 1) % key.length(); } return sb.toString(); }
what's RANGE and what's START_CHAR?
start_char is the first valid character for the range of string characters which would be a space character and the range is the number of valid string values which is the difference between the two previous values plus one
The two previous characters would be start_char and end_char
Why are you using unmapped 💀
forgot how to mapped it @@
?nms
read it
oh right
Monads 💪🏻
How i can get craftbukkit sources? Buildtools gave me only builded jar
?stash
I have an item in a players hotbar which should activate a different inventory when rightclicked. So for example:
The player has its normal inventory with all its items (let's call this x) and he has the rightclickable item. If he right clicks it, it should replace x with a new inventory and hotbar (but the rightclickable item should still be there in the first slot). This new inventory contains different custom items which the player can move around in the inventory and select. When the player right clicks again, x goes back with all the items in their previous locations.
How would I do this?
I think I got it
just a couple interfaces
Thanks, but i cant find version for 1.19.2
and a couple registries
Source for 1.19.2 and.3 is most likely identical
I mean no major changes
Oh yeah
how do i return a damage dealt to an entity that is not player?
LivingEntity#damage
So, what branch do i need to use for 1.19.2?
im still lost on why its not converting correctly
What's the best way to make that player can place items only in 1 slot? I can check if the slot index is 13 and then cancell or not event, but how to make that for only one inventory?
Any way to mark these slots or inventorys?
or something
Hey I just switched from Eclipse to IntelliJ. However, now all § characters have become such a character �. How can I fix this without replacing each character individually?
select that weird symbol, then do Ctrl+Shift+R, then enter § as replacement and then run it
and next time, don't hardcode § but use the ChatColor class
I need some help here. Would any one know how I could compare an armor stand head to a head texture link?
Thank you very much
just get the link from the PlayerProfile and if it's the same link, sth like this should do
public static boolean isSame(SkullMeta skull, String skinUrl) {
try {
return skull.getOwnerProfile().getTextures().getSkin().toURI().toString().equals(skinUrl);
} catch (URISyntaxException e) {
e.printStackTrace();
return false;
}
}
How do I use an interface to allow for multiple storage options (config, SQL, mongo, ...)
?config
?help
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous names and nicknames of a member.
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
you have a class per storage option which all implement your interface
then at startup you instance whichever class you need
Okay thanks
Thanks
please paste it with java highlighting
Why PlayerInteractEvent is called twice when you right click a block?
?interactevent
The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.
For example, only executing code if the main hand was used:
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
return; // do not progress past this point |
}
// provide functionality
}
just store the inventory somewhere
you can try adding a custom holder tho
so you don't need a collection for storing invs
well even if you don't read the java docs its still kinda obvious. You have 2 hands :P
Too old! (Click the link to get the exact time)
I'm surprised people haven't caught on after 7 and a half years
well they paid 12$ to a 13 year old 7.5 years ago for a custom plugin that only works in 1.8 so they "can't update"
trueeeeee
who did
you
it was just an example
I didnt play mc 7.5 years ago xd
it's the typical "1.8 user argumentation"
ok
One question guys, is there any way for setting all blocks over y = n to a specified block for all the pregenerated chunks in a world?
let me check those
its quite a heavy work load so spread it out
are those events?
ChunkLoadEvent
nono I mean
I pregenerate until 10k
with chunky
when it is finished, is there a way to set all blocks over y = n to be deepslate?
idk if that makes any sense
yes, load each chunk and loop over
write own worldgen for chunky/minecraft 
the thing is
I've been investigating but haven't found any info on it
the generator: in bukkit
how could I make it so it is only a single biome
class Cringe extends ChunkGenerator()
one sec
is there any docs
for that
this was the most info I could get
oh
minestom 🙏
stomachine
idk
there's little to no info
f
hmm
wait, if I use my world save and upload it to the server it will still work right?
wait you want your world to have 1 biome
how do i reduce damage do to the player from a certain Entity?
or what
yeah
just use my post above
EntityDamageByEntityEvent
but it's only for new worlds
^^
you just check the entitytype of entity which hit the player
and reduce the damage based on the type
i think its working
https://paste.md-5.net/iyuvorucof.cs
bruh
i guess you need final damage tho
not just a damage
and what is mc version you are coding for
1.19.3
i dont understand
never done it before
declaration: package: org.bukkit.event.entity, class: EntityDamageByEntityEvent
btw you can compare enums using ==
no need for equals()
and instead of checking the chestplate's name, rather use a PDC tag
too complex
it's not complex at all
private final NamespacedKey MY_CHESTPLATE_KEY = new NamespacedKey(myPlugin, "isMyChestPlate");
// aply tag:
myItemMeta.getPersistentDataContainer().set(MY_CHESTPLATE_KEY, PersistentDataType.BYTE, (byte) 1);
// check if it has the key:
if(myItemMeta.gerPersistentDataContainer().has(MY_CHESTPLATE_KEY, PersistentDataType.BYTE)) {
if i make a constructor (1st image) for my class and i wanna use it in another method (2nd image) it would work?
variables are awesome to use
that is not constructor
wtf is that
constructor must have same name as class
bruh
bcause isnt working
constructor is a method which runs when class instance is created
what does the 2nd picture have to do with the first
not a method
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
this is a constructor:
public class MyClass {
public MyClass() { }
}
this is NOT a constructor, but just a method you called "constructor":
public class MyClass {
public void constructor() { }
}
?conventions
its the same
its literally not
i dont get how i modify the damage and apply it to the pla yer
but im just importing 2 var
event.setDamage?
that matters?
didnt the damage from the mob already apply?
if you don't cancel the event, yes
damage is only applied if the event is not cancelled
it's applied after the code you write in the eventhandler
so will this work?
https://paste.md-5.net/ganevereye.cs
it should right?
i do the NamespacedKey and apply in the class where i have my ItemStacks and the check for tag in any event?
how can load users from database, i mean avoid SELECT * due to numbers of users, or it dont make difference?
You set the tag when you create the item, and you check it where ever you wanna know whether its your custom item
select x means number of columns, not rows. Also you should select things you need. If you don't need smth, dont select it
wdym create item. Like this?https://paste.md-5.net/unovodarur.cs
thanks man
i mean, doing it without 'LIMIT X' , did it encumbers the code?
Okay im getting closer but this still isn't doing the trick for vigenere cipher java @Override public String encrypt(String input) { StringBuilder result = new StringBuilder(); for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (c >= START_CHAR && c <= END_CHAR) { // only encrypt printable characters int keyIndex = i % keyLength; // handle key that is not the same length as input int keyShift = key.charAt(keyIndex) - START_CHAR; c = (char) (START_CHAR + (c - START_CHAR + keyShift) % RANGE); // handle wraparound } result.append(c); } return result.toString(); } I'm trying to output bXsZtVYg]e^Zke^ZkeYpZc with the input being "in a land far far away" and the key being "test" but it's not printing that
how do i create the tab completion thigy
1.633s makes it so BlobExecutor can be constructed with just the JavaPlugin and the command name you provided in plugin.yml inside commands section.
I am also going to test MongoCrudManager since I just added it. I don't expect it to work without further testing but I will ensure to provide 100% functionality in 1.634s for it.
Implement TabCompletor
Then do myCommand.setTabCompletor(…)
Well you never print anything, you only return it
you dont need to set Tab if you set executor
That's because it's printed in another method...
Then i dont understand the problem. You say it doesnt print ANYTHING?
I didn't say that
I dont think your % math is correct btw
I‘ll write a vigenere when im outta the bathtub in 20 mins or so
Okay, I'm receiving dZs\tX[i_e`\me`\me[r\e
case DIAMOND_SWORD:
e.setCancelled(true);
Player p = (Player) e.getWhoClicked();
p.closeInventory();
Inventory inventory = Bukkit.createInventory(p, 45, ChatColor.translateAlternateColorCodes('&', DTAnvilRPG.enchanterName));
ItemStack wool = new ItemStack(Material.LIME_WOOL);
ItemMeta woolMeta = wool.getItemMeta();
woolMeta.setDisplayName(ChatColor.GREEN + ChatColor.BOLD.toString() + "Agregar Encantamiento.");
wool.setItemMeta(woolMeta);
inventory.setItem(25, wool);
for (int i = 0; i < inventory.getSize(); i++) {
if (inventory.getItem(i) == null) {
ItemStack glass = new ItemStack(Material.GRAY_STAINED_GLASS_PANE);
ItemMeta glassMeta = glass.getItemMeta();
glassMeta.setDisplayName(" ");
glassMeta.addEnchant(Enchantment.DURABILITY, 10, false);
glass.setItemMeta(glassMeta);
inventory.setItem(i, glass);
}
}
inventory.setItem(19, null);
inventory.setItem(23, null);
inventory.setItem(25, wool);
e.getWhoClicked().sendMessage("asdasd");
p.openInventory(inventory);```
Why the second inv isnt opening but i get the asdasd message :(
print out (Bukkit.broadcastmessage() or p.sendmessage) the inventory variable
or the name of the inventory if possible
It's probably opening the wrong inventory
does anyone knows how i fix this, ive never used gradle before
tried switching these but the 2nd doesnt work at all
public class Vigenere {
private static final char LOWER_START = 'a';
private static final char LOWER_END = 'z';
private static final char UPPER_START = 'A';
private static final char UPPER_END = 'Z';
public static String encrypt(String plainText, String key) {
StringBuilder sb = new StringBuilder();
for(int i = 0; i < plainText.length(); i++) {
char c = plainText.charAt(i);
if(Character.isLetter(c)) {
char start = Character.isUpperCase(c) ? UPPER_START : LOWER_START;
char end = Character.isUpperCase(c) ? UPPER_END : LOWER_END;
int offset = c - start;
int keyOffset = key.charAt(i % key.length()) - LOWER_START;
int newOffset = (offset + keyOffset) % (end - start + 1);
sb.append((char) (start + newOffset));
} else {
sb.append(c);
}
}
return sb.toString();
}
public static String decrypt(String cipherText, String key) {
StringBuilder sb = new StringBuilder();
for(int i = 0; i < cipherText.length(); i++) {
char c = cipherText.charAt(i);
if(Character.isLetter(c)) {
char start = Character.isUpperCase(c) ? UPPER_START : LOWER_START;
char end = Character.isUpperCase(c) ? UPPER_END : LOWER_END;
int offset = c - start;
int keyOffset = key.charAt(i % key.length()) - LOWER_START;
int newOffset = (offset - keyOffset) % (end - start + 1);
if(newOffset < 0) newOffset += end - start + 1;
sb.append((char) (start + newOffset));
} else {
sb.append(c);
}
}
return sb.toString();
}
dunno if it says that my version is outdated or that that one is
@quaint mantle seems to be working fine
obviously the code is pretty shitty but it works
ok gradle version of minestom goes brr
That's not the correct output
It should be bXsZtVYg]e^Zke^ZkeYpZc
why that?
usually it only uses a-z A-Z
show the full text of the assignment
Sick, I got that image as a metal board above my screen XD
var entityLoc = entity.getLocation();
var playerLoc = player.getLocation();
var entityVec = entityLoc.toVector();
var playerVec = playerLoc.toVector();
var angle = entityVec.angle(playerVec);
var x = Math.cos(angle) * this.distance;
var y = playerLoc.getY() + this.orbitHeight;
var z = Math.sin(angle) * this.distance;
var loc = new Location(entity.getWorld(), playerLoc.getX() + x, y, playerLoc.getZ() + z);
var diff = playerVec.clone().subtract(loc.toVector());
loc.setDirection(diff);
entity.teleport(loc);
entity.setRotation(loc.getYaw(), loc.getPitch());
```Am I stupid, or should this teleport the entity around the player?
for (int minX = 0; minX < 10; minX++) {
for (int minZ = 0; minZ < 10; minZ++) {
Chunk chunk = world.getChunkAt(minX * 16, minZ * 16);
chunk.load();
int startX = chunk.getX() * 16;
int chunkY = 51;
int startZ = chunk.getZ() * 16;
for (int y = chunkY; y < 320; y++) {
Material material = y == 51 ? Material.BEDROCK : Material.AIR;
for (int x = startX; x < startX + 16; x++) {
for (int z = startZ; z < startZ + 16; z++) {
world.setType(x, y, z, material);
}
}
}
chunk.unload();
}
}```
hwo could I make so my server doesn't crash?
[21:43:05 WARN]: Timed out waiting for world statistics
[21:43:09 ERROR]: --- DO NOT REPORT THIS TO PURPUR - THIS IS NOT A BUG OR A CRASH - git-Purpur-1918 (MC: 1.19.3) ---
[21:43:09 ERROR]: The server has not responded for 15 seconds! Creating thread dump
thanks
uhh what is this crap?
well then just adjust the START_LOWER and END_LOWER variables or however I had called them in my code
and get rid of the if/else for lower/upper case
my animation scripting system works first time 
I'm getting cY[WZh^_[l_[lZq[d
Produces this constantly
your assignment talks about "character range" but doesn't specify what this range is
it starts at space you say, but where does it end?
so space to z?
yes
can someone help me to fix that only i get the package, but the otherplayers need that package too
@Override
public void onPacketSending(PacketEvent e) {
Config config = new Config();
Player p = e.getPlayer();
Main.getInstance().log("1");
if(config.getPlayerVanishedList("de.command.vanished") != (null)){
Main.getInstance().log("2");
if(config.getPlayerVanishedList("de.command.vanished").contains(p)){
Main.getInstance().log("3");
onEventCancel(e);
Packet packet = (Packet) e.getPacket();
CraftPlayer cp = (CraftPlayer) e.getPlayer();
}
}
}
the damage isnt changing please help
https://paste.md-5.net/nucilitudo.cs
that is correct
I get the same when using space and z as bounds
Clearly it's not because I should be getting the other output
clearly it is correct when one only has access to the assignment text you sent, plus the statement that the "boundaries" are space and z
either you didn't send the full assignment, or the proposed encrypted text is not correct
man i understand why people hate gradle
I am pretty sure you didnt send the whole assignment as it was already missing the definition of what the boundaries are of the allowed characters
because it sucks
im only getting errors
that's normal
people rather spend 5 hours getting their gradle build to work than watching maven take 2 seconds to compile
some dude told me i should run gradle wrapper --gradle-version 8.0.2 --distribution-type all
is this a repo you cloned?
if so, you shouldn't run ANY wrapper commands
you should just use the wrapper that was included in the repo
gradle breaks itself on updates
uhh i cloned it from github and im running that command in a terminal yes
that's why every repo includes the huge 150 mb wrapper because if you use a different gradle version than the build script was written for, everything goes wrong
delete everything, clone the repo again, then enter gradlew build
gradlew, not gradle
ok
Just making this a thread in case anyone wants to help
it says "complete range of printable ascii characters", not just space to z
Can entities that are passenger of a player clientside only (packets) block teleports?
What?
oh
I get that
They shouldn't no
Also a quick FYI it's packets
not packages
so all 128 characters
Can they be hit through by a player if its clientside only?
Changing it still doesn't give me the output I should be getting
idk what they mean with "printable characters", ask your teacher. might as well be space to tilde
the client can probs hit them
but it won't do anything
\0 is printable kekw
So they can block a hit for example if I want to hit a player behind it?