#help-development
1 messages · Page 485 of 1
how do i check exactly how it's spelled?
i keep getting errors in console because i dont have the right plugin apparently
/plugins
oh nvm i was messing with the formatting its loading now
im still getting the same error though
And you added it in plugin yml
yeah
And that namtagedit or whatever is loaded when you do /plugins
It's probably because it was not able to find plugin
yep add a provided scope
i do not know what that is
<scope>provided</scope>
add to the nametagedit in your pom, the same as you have on spigot-api
does gradle support nested multi module projects yet
maybe?
it would be very disappointing and surprising if it would NOT support that
What is CraftPlayer#getHandle().b.a.k in the remapped mojang nms version?
It should. It's mainly down to teh IDE if it supports nested
ahh ok
if you know from which version you took that "b.a.k" part, you should be able to check it yourself on the mappings website btw
?switchmappings
I checked, but is a Bukkit class
no
set it to spigot mappings
CraftPlayer#getHandle() returns a ServerPlayer
intellij has been dying for random reasons recently
like multiple times this week its opened and then said "String isnt String" or other classes
yeah
did you also start it through toolbox?
uninstall the manually installed version
then start the 2023 version
but yeah IJ starts to suck more every day
I also noticed that
e.g. CVS -> Share on Github -> all files are empty on github until you push stuff again
it's funny that the files are not completely empty though
cvs pharmacy?!?!?
public class MyClass {
private String something;
}
then after VCS -> Share on GitHub, on gh it looks like this
public class MyClass { }
like wtf lol
Found it
have you had ij start to say a class isnt a class
do you still ahve it open lol
im using a Listiner in my command and when i try to give it my main class for the plugin it says that it is not a enclosing class
im trying to add custom items that get consumed when used, but they get consumed in bulks of 5 instead of 1 by 1, why could that be? code (line 170 is where the onUse is): https://paste.md-5.net/bizezivude.java
i would deffo delete the mc dev plugin if someway to create a gradle project with specific build.gradle existed
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
}
yea thats what im doin
Also why creating new anonymous listener every time command is executed
Pluggg is my main class
Don't do that
Pluggg.this doesn't mean anything
wait i got it
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
i thinl
But don't register listeners like that dynamicly
It isn't spawning the corpse, CODE https://pastebin.com/J4mh7kt9
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
how would you reccomend to do it
Have 1 listener for all players and when player execute cmd put him in set or whatever
And if player is in set, execute logic
wait what
so like just have a thing of all the players then only they get through the Event
What
What's a good way of storing worlds/groups of chunks to be persisted for skyblock-type worlds?
I'm just saying you should have 1 onMove listener
Not add new one every time command is executed
As it can be really slow
yea i can understand that
but i want there to be a specified y lkevel that will teleport the player
and i dont know how else to do that
anyone know of an ij plugin that lets you create a gradle project with customiazble params? or just something that allows me to create a gradle project with a custom build.gradle
ah lovely
you mean like maven archetypes?
similar
gradle only has gradle init but that only lets you choose project type (application, etc) and group id etc
Who can help me to
Rank :
Default
User :
User
Money :
Money
Like at the rigth
Starred
a scoreborad
Like
thats called a scoreboard, find a plugin online or lookup how to make scoreboard
ayy clout
I have do
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
I use SimpleScore
how would i do that, i tried something and didnt work
Helpoooo
Code: ```java
@EventHandler
public void PlayerScoreboardEvent(PlayerJoinEvent event){
ScoreHelper helper = ScoreHelper.createScore(event.getPlayer());
YamlConfiguration config = new Scoreboard().getConfig();
ReplacePH placeholder = new ReplacePH();
if (event.getPlayer().hasPermission("naohcf.scoreboard.staff")){
String title = config.getString("staffScoreboardTitle");
title = PlaceholderAPI.setPlaceholders(event.getPlayer(), title); // 64
title = placeholder.replaceAllPlaceholders(title, event.getPlayer().getUniqueId(), event.getPlayer().toString());
title = ChatColor.translateAlternateColorCodes('&', title);
helper.setTitle(title);
List<String>slots = PlaceholderAPI.setPlaceholders(event.getPlayer(), config.getStringList("staffScoreboard"));
for (int i = 0; i < slots.size(); i++){
String slot = slots.get(i);
slot = placeholder.replaceAllPlaceholders(slot, event.getPlayer().getUniqueId(), event.getPlayer().toString());
slots.set(i, slot);
}
helper.setSlotsFromList(slots);
} else {
String title = config.getString("scoreboardTitle");
title = PlaceholderAPI.setPlaceholders(event.getPlayer(), title);
title = placeholder.replaceAllPlaceholders(title, event.getPlayer().getUniqueId(), event.getPlayer().toString());
title = ChatColor.translateAlternateColorCodes('&', title);
helper.setTitle(title);
List<String>slots = PlaceholderAPI.setPlaceholders(event.getPlayer(), config.getStringList("scoreboard"));
for (int i = 0; i < slots.size(); i++){
String slot = slots.get(i);
slot = placeholder.replaceAllPlaceholders(slot, event.getPlayer().getUniqueId(), event.getPlayer().toString());
slots.set(i, slot);
}
helper.setSlotsFromList(slots);
}
}```
Config: ```yml
Default scoreboard
no permission needed
scoreboardTitle: "&b&lNaoHCF &7(Map I)"
scoreboard:
- "&7- &b&lKills: &7%kills%"
- "&7- &b&lDeaths: &7%deaths%"
- ""
- "&7- &b&lHome: &7%home%"
- "&7- &b&lFocus: &7%focus%"
- ""
- "&7dsc.gg/voidciroo"
Staff scoreboard
Use naohcf.scoreboard.staff permission.
staffScoreboardTitle: "&b&lNaoHCF &7(Map I)"
staffScoreboard:
- "&7TPS: &b%tps%"
- "&7Vanish: %vanish%"
- "&7Gamemode: %gamemode%"
- "&7Players: %players%"
- ""
- "&7dsc.gg/voidciroo"
There's no Placeholder in the title btw...
Maybe its that?
what's onJoinEvent line 64?
title = PlaceholderAPI.setPlaceholders(event.getPlayer(), title); // 64
title is null
scoreboardTitle: "&b&lNaoHCF &7(Map I)"
it isnt
String title = config.getString("scoreboardTitle");
print out the value of title
k
how can I listen to an anvil breaking? (running out of uses, not broken by a player)
so what was the value of "title" when you printed it out?
null
there you go
BlockChangeEvent
but what can i do then
Im still working on my block breaking thing and ive got here so far
Pickaxe pickaxe = Utils.getPickaxeFromItemStack(player.getInventory().getItemInMainHand());
Ore ore = main.getMiningEvent().getOreLocations().get(e.getBlock().getLocation());
long speed = (long) pickaxe.getMiningSpeed() * ore.getHardness();
@Override
public void run() {
e.getPlayer().sendMessage(String.valueOf(speed));
if (!blockProgress.containsKey(e.getBlock())) {
blockProgress.put(e.getBlock(), 0L);
}
blockProgress.replace(e.getBlock(), blockProgress.get(e.getBlock()) + (speed / 10));
player.sendBlockDamage(e.getBlock().getLocation(), blockProgress.get(e.getBlock()) / 10f);
if (blockProgress.get(e.getBlock()) < 0L || blockProgress.get(e.getBlock()) >= 9) {
Bukkit.getPluginManager().callEvent(new BlockBreakEvent(e.getBlock(), player));
blockProgress.remove(e.getBlock());
this.cancel();
}
}
}.runTaskTimer(main, 0L, 1L);```
I dont know why it only works when speed is 10 and not when its 5
lemme check craftbukkit's code
HighlightBracketPair for Intellij highlights brackets of the selected scope
so you can tell easily if your code is within the scope you're looking to have
Doesn't intellij do that by default?
Sublime had something like this
now it prints out
kinda it does, but you need to select the bracket
the brackets
Oh cool
i guess the only proper solution is to listen to ClientboundLevelEventPackets being sent
what's replaceph line 59?
nah
nah 💀
Now
the join event
doesnt give a error
but now i dont see scoreboard
im using this resource
and im creating the scoreboard
well fuck that
if there's one thing im not in the mood for it's packets
you could ofc also just listen to InventoryClickEvent, check if the clicked slot is the result thing of an anvil, then wait a tick and check if the anvil is now gone
such a shame this doesnt work on Clion
although ofc it might also be that a player has broke the anvil in the same tick as someone used it
but I guess that's pretty rare. and to prevent that you could also listn to BlockBraekEvent
well it kinda does work on clion but not exactly like on intellij i showed in this picture
im using Bukkit.getScheduler().runTaskTimer but i cant seem to throw the main class for the first paramater
you have to pass an instance
how bc i am stumped
?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.
i have passed the instance and it just issnt working
so give the code
you will get an error if you do new MainClassName()
Pass the instance, not create new one
i love 2:30 am coding
i woke up from 2:30 am coding this morning and had no clue what i was looking at
i like going to bed and instantly falling into a dream
can someone help me out with this
print the block progress
in acf how do I specify a player name as an argument
right now I have this
but when I run it the invitee is just the player who ran the command
use String, and then @Completion("@players") or sth like that
ah
so are there certain types that can be passed in as an argument
or is it all only strings
well String, int, etc ofc works. If you want to directly get actual class instances passed, you have to setup erm
whats it called again
you can pass most things, if its a custom class you have to setup a context handler iirc
it's called a COmmand Context
close enough
https://github.com/aikar/commands/blob/master/bukkit/src/main/java/co/aikar/commands/BukkitCommandContexts.java here you can see the builtin ones for bukkit
Player should definitely work btw
it is a context handler
for players you gotta use a flag
public void onCommand(Player sender, @Flag("other") Player target)
ah thank you
Or just use OnlinePlayer
Player sender, OnlinePlayer theOtherPlayer
Easiest way ^
@wise mesa just use OnlinePlayer
thanks
could it maybe be since it isnt a multiple of 10?
did you use 5, or 5f?
5
but the 10 isnt set to f either
its good practice to set them as floats but that wouldnt be the difference in one working vs another
ok so i kinda fixed it
only thing now is im using .runTaskTimer(main, 0L, Math.round(100f / speed));
that to calculate speed
and it looks really weird
fixed it by sending the packet instead of sendBlockDamage(
Im developing a mini staff mode, how tf when you use /staff and disable it continue with the same inventory you had when you activate it?
i really dont know how to
save the inventory when they activate
and when they disable set their inventory to the saved one
theres no way w/o listening to packets see if a player has text displayed in their actionbar right?
?jd-s
whats the event for when a player sneaks out of whatever theyre riding
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class ping implements CommandExecutor {
@Override
public boolean onCommand(CommandSender thePlayer, Command mycommand, String s, String[] strings) {
Player p;
p = (Player) thePlayer;
int theplayerping = p.getPing();
if(thePlayer instanceof Player){
p.sendMessage(ChatColor.DARK_PURPLE + "Your Ping :" + " " + theplayerping);
return false;
}else{
p.sendMessage(ChatColor.DARK_RED + "[Error] : You cant use this Command !");
}
return false;
}
}
``` Hi , sorry but what is problem of my code , because in the game is not worked ! ?
yes wait , i will send error
"An internal error occurred while attempting to perfrom this command"
?paste
Player#getPing doesn't exist
how are you not getting an error in your IDE
Caused by: java.lang.NoSuchMethodError: 'int org.bukkit.entity.Player.getPing()'
oh not in his version okay
Compiling against new API running on old server
why i get an error here
public class testCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) {
if(sender instanceof Player){
Player player = (Player) sender;
player.getLocation();
}
return true;
}
``` i remember is was a method
it says getLocation is not defined
Lol , md_5 is here that cool ! xD
💟 omg its md_5 please give me head pats!!!
- Please follow naming conventions for your classes
- Player#getLocation() does exist make sure you have the proper imports etc you may need to restart your ide
i use intellij idea and i use plugin but IDE is not give a error to me
as md said compiling against new API running on an older server
so your API version isn't targeting 1.12.2
i use java 1.12.2 because my java version is 8 xD
update java
it doesn't take that long
surely you have time to update java if you have time to code a plugin as well
Lol , because is end of my project and i will to sleeping ...
if you are too lazy just change your api version in your plugin
warning a bit of your code will probably break
I reccomend updating however
ok , no problem so in new version is have this ? what version ?
You should know your own server version...
1.12.2 is your server version 1.19.4 is latest
1.19.1 is ok ?
ok , xD
?nms
hello guys i was working lately on an plugin from some reason the gui is always empty and i cant find the reason
?paste
cloud anyone tell me where i messed up what cloud i do not correctly?
"playerData" is the way i accses playerData quickly via hashmap of player , custom object containing all data is nessecary...
i get this error
https://paste.md-5.net/vohupufiru.bash
on executing this code
class Scared Zombie
public ScaredZombie(Location location){
super(EntityType.ZOMBIE , ((CraftWorld) location.getWorld()).getHandle());
this.setPos(location.getX(),location.getY(),location.getZ());
}```
class testCommand:
```java
public class testCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if(commandSender instanceof Player){
Player player = (Player) commandSender;
ScaredZombie scaredZombie = new ScaredZombie(player.getLocation());
}
return true;
}
}```
i am unable to know what went wrong
on chat it just says internal error
hm
maybe send full class
and not half?
the command wont work
because u didnt do a constractur
between the main class and the testCommand class
so a singleton between them would solve the problem
as well register the command in plugin.yml , if you want u can either make commands work using asyncchatevent and change first char for example commands on .
i did register it
public class ScaredZombie extends Zombie {
public ScaredZombie(Location location){
super(EntityType.ZOMBIE , ((CraftWorld) location.getWorld()).getHandle());
this.setPos(location.getX(),location.getY(),location.getZ());
}
}
``` full class of the zombie
i dont think anything is wrong with command as when i changed it to send a message 'hello' it worked
there must be smething wrong with my zombie class
hey can someone help me i wanna make a riddle plugin thingy so there are 2 command, command A and command B. so, command A is a command which can be run by an admin to enable the riddle and command B is used by players to get the riddle info so how do i make it so only when a admin runs command A then players can run command B
you use is sender#hasPermission
Anyone here, I need help with this event.getCurrentItem() and event.getCursor()?
?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!
i see
I creating a farming rod like EpicFarming but more realistic that does not multiply items. I try to place/remove a item to/from its inventory, it does not do anything? Most of the time and I think my code is broke
line 14 is ScaredZombie?
yah
try it like this
Wait, I see what is happening. Its nothing wrong with these 2 functions. Just forget about the gui, its more for player.getTargetBlock(). How do I get the end rod I use for the farming rod thru plants like WHEAT, CARROTS and all that you farm?
public class ScaredZombie extends Zombie {
public ScaredZombie(Location location){
super(location.getWorld().spawnEntity(location, EntityType.ZOMBIE));
}
}
tell me if it works now
I have this code``` Set<Material> farmSet = new HashSet<Material>(); farmSet.add(Material.AIR);
for( Material material : farmBlocks ) { farmSet.add(material); }
Player player = (Player) event.getWhoClicked(); Block block = player.getTargetBlock(farmSet,10); FarmLib farmLib = new FarmLib();```
x y problem please describe whats wrong..
about the api go thru docs
?docs
does it work?
It does not always detect the end rod (Farming Rod) when my cursor is right on it
describe Farming Rod == ?
is this a new itemstack or something?
...
Just look at EpicFarming, you will see what I talking about. I cannot upload images
u use someone else API its not related to this chanel..
Songoda
go contact the creator of EpicFarming its not related to here...
it gives syntax error
'spawnEntity(org.bukkit.Location, org.bukkit.entity.EntityType)' in 'org.bukkit.RegionAccessor' cannot be applied to '(org.bukkit.Location, net.minecraft.world.entity.EntityType<net.minecraft.world.entity.monster.Zombie>)'
But its using the official API, player.getTargetBlock() is apart of the API. I searched everywhere for hours
yah
make the class abstract to not implement all the not nessacery shit
extend it as zombie
and make summon method in it
and later just call the method
later you can make a bit more advanced like modifing things for example depending on int level set hp * lvl..
what IDE do u use?
weird it didnt force to implement all the methods the way you did it before
i tried rn and i didnt even let me compile lol without adding 3k lines of that shit
hm
nms packages always change so much , i tried using my last code but it due to so many changes it does not work
now i have to find more way to do the code , idk why do they make things so complicated
thats not my question it is players should able to execute command B when an admin executes command B. before admin executes command B players cannot access command A
mojang 😆
use a boolean
..
public field
oh , then you can set a public flag and when admin executes it it should set true
an check if admin executed change it
yeah i got it thanks guys!
and learn java at least... dont try to fly straight forwards those things are simple to do i see you can use your imagenattion
there so many ways to do it
for something static use yaml config to make it static so restarts wont affect it
else if its liike condom used only once per restart then keep it that way using an boolean
lol abuot to say that
almost done ,i forgot the method to add an entity to the world , what was that?
yah fresh entity
Ok, I looked at the whole source code of EpicFarming. I cannot even find where they use InventoryClickEvent like how they get the end rod. I also joined their server and noticed I not allowed to ping anyone there or send PMs so its only here it seems. While I not trying to make the exect copy of EpicFarming, I like to access the farming rod (End Rod) from any angle. I had to disable access to farming rod while sneaking due to this issue
its not related here
we wont help you with someone else resource API
I can look at the farming rod (End Rod) and player.getTargetBlock() returns Material.AIR or Material.WATER while the bounding box of the farming rod is shown
imma just ignore u legit x y problem
for (int i = 0; i > gui.getSize(); i++) {
Shouldn't that be i < gui.getSize()
true
since it never starts the loop
lmao thanks i wasnt able to notice that ;/
thanks alot KonijkiNoYami you cant imagine how much time i was staring thru it and not finding a realistic reason why it works like that
So there is no way to get any block in view using spigot?
wdym any block in view
there many ways
from player cross?
you can getDirection and do some math and check if block is air
till u hit non air
and then return the block
while loop
and do max distance so wont be infinity loop
I am now trying to add a custom block. I have created these codes for that purpose.
CustomBlock class
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.material.Material;
public class CustomBlock extends Block {
public CustomBlock() {
super(BlockBehaviour.Properties.of(Material.STONE).strength(1.5F, 6.0F));
}
}
CustomBlockRegistry class
package ponme.nonameplugin.blocks;
import net.minecraft.core.Holder;
import net.minecraft.core.MappedRegistry;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.material.Material;
import ponme.nonameplugin.biomes.OriginalBiomeBase;
import java.lang.reflect.Field;
public class CustomBlockRegistry {
public static Holder<Block> addBlockTest() {
ResourceKey<Block> newKey = ResourceKey.create(Registries.BLOCK, new ResourceLocation("ponme", "test_block"));
MappedRegistry<Block> registry = OriginalBiomeBase.getRegistry(Registries.BLOCK);
Holder<Block> holder = null;
try {
Class<?> registryMaterialsClass = Class.forName("net.minecraft.core.RegistryMaterials");
for (Field field : registryMaterialsClass.getDeclaredFields()) {
if (field.getType() == boolean.class) {
field.setAccessible(true);
field.setBoolean(registry, false);
}
}
holder = registry.register(newKey,new CustomBlock(),com.mojang.serialization.Lifecycle.experimental());
registry.freeze();
} catch (ClassNotFoundException | IllegalAccessException e) {
e.printStackTrace();
}
return holder;
}
}
I used this CustomBlockRegistry and tried to add it with the onEnable method.
Then I get this error on startup.
java.lang.IllegalStateException: This registry can't create intrusive holders
I see.
When I added the custom biome, I thought I could do it because it worked the same way as this. Thank you.
im trying to add custom items that get consumed when used, but they get consumed in bulks of 5 instead of 1 by 1, why could that be? code (line 170 is where the consume code is): https://paste.md-5.net/orulaxojug.java
for whatever reason the item with the namespaced key "kick" only consumes one
your math is flawed
nvm, your math is fine read it wrong, but your issue is actually quite simple
you have 5 if statements to check for custom items, if all 5 match, then it will reduce by 5 since all 5 statements reduce by 1
so to fix that, add a return statement
where would i add it?
at the end of the block of code that did something, or re-organize your code in such a way where if it enters one of the if blocks and it doesn't exit out to move to another one
so, using if else for example
but it shouldnt move to another one, the namespaced keys are different on each if statement
well, you have 5 if statements that remove items
and you said that items are being reduced in 5's
so seems like you need to check your items out then
or you didn't account if an item could have all 5
items can have more then one namespaced key in their metadata
otherwise we wouldn't need a namespaced key 😉
but at least now you know why the problem is happening and can now work on resolving the issue or figuring out why more then one key is being assigned to the item if that isn't what is meant to happen
yeah, thanks
evidently, checking instanceof on a generic is not possible. what workaround could i use? or should i abolish the default method overall and let the dev do it?
pass in a class
or do T extends EntityEvent if it really can only be that
or make it a method to implement yes
i want to allow EntityEvent and PlayerEvent, because for some reason PlayerEvent doesn't extend EntityEvent
probably will just make it a method to implement
bruh what college is that
I'm finding out the more and more I work on this interchangeable database storage system, the more complicated it gets. Is it normal for monolithic interfaces to have unused methods in some implementations?
wondering what i was doing again 😳
Class: https://sourceb.in/5NbTcSzGE4
Error: java.lang.ClassNotFoundException: javax.activation.UnsupportedDataTypeException
Runner:
BlendCameraAnimation animation = null;
try {
animation = BlendCameraAnimation.parse(new File(AlixAPI.getInstance().getDataFolder(), "test.animation")); //Line where's the error is
} catch (IOException e) {
throw new RuntimeException(e);
}
BlendCutscene cutscene = new BlendCutscene(animation, player.getLocation());
cutscene.play(player);
im not sure where the error is, google reports the error only for sending emails
why are you throwing a UnsupportedDataTypeException
where?
line 84 in the code you sent
because the file is not a .animation and doesn't have a string at the start
but the file that i made im sure is the one who supports it
looks like you made it wrongly then
just use a proper exception, e.g. IllegalArgumentException
but how can i fix this?
just use a proper exception, e.g. IllegalArgumentException
ok, but thats not the main cause
then send the full stacktrace, and it'll reveal what the cause is
i just send it, the full stack trace return to a section in https://sourceb.in/5NbTcSzGE4 line 83
Where did you send the stacktrace?
maybe instead of writing those ridiculous instructions, use a real programming language like our beloved Java
then you can’t forget what you’re doing because it’s verbose :)
you dare to challenge me hmm?
dare
bro its not needed the stack trace litteraly the problem is there, in the stacktrace is not needed because it sends you there
with this error
Ok good luck fixing it then
A NEW CHALLENGER APPROACHES!!!
me trying to figure out why i cant iterate over 0..2 💀
counter is supposed to go -2 -1 0 but it goes -1 0 -1 1 0 💀
feeling stupid today, how do I get the type of the generic?
you can’t throw an UnsupportedDataTypeEzception because javax isn’t included by default in the jar, only at compile time. Same reason why you can’t use Pair and have to make your own
@grizzled oasis
you dont
ah, cool
so instead of being lazy and just finding some random exception that’s named like what you want, make your own
perhaps i should review my approach and not use a generic
like I do that myself sometimes, but seriously ? javax?
or maybe instanceof RegisterableTrigger<Whatever>?
i want to see if in this list there's already a RegistrableTrigger with its type matching the type of this new registrable trigger
so i don't know the generic type of neither
ah you dont
or you have a class field
you can do plenty of hacky shit
the answers to this question will do basically what you wanted for T instanceof : https://stackoverflow.com/questions/1901164/get-type-of-a-generic-parameter-in-java-with-reflection
kind of ironic that the answers to that SO post have literally nothing to do with the question though
damn my program was working but it was just me outputting twice
what were you evrn coding, and in what
printing an array
Were they JVM opcodes or something else?
made smth custom
ah okay
design question: should I return silently or throw an exception?
First mistake, but yk who cares
my c++ knowledge is shit so thats why
good design is to throw an exception
definitely not that, an enum lmao
is it supposed to happen that it gets tried to register it more than once? if no, throw an exception
streams 🥰
i want to prevent the dev from registering it twice
alright
since it’s not checked though I’ll be the first to ignore coding the catch ngl
wdym?
it’s not a checked exception so you don’t need to code the catch, it’s not forced
oh like, do you mean that I should put it in the signature
no definitely don’t
not sure what you mean by checked exception haha
yeah that’s okay just ignore me
well you got me curious now
a checked exception is something that’s in the method signature like: public void ignore() throws IOException. You NEED to use a throw/catch since IOException is a checked exception. IllegalArgumentException is not a checked exception, so you don’t need to write the throw catch, instead if it’s thrown then the program will exit
oh I see
yeah i got it ty
would it be a better practice to use a checked exception in this case?
I don’t even know that you can
can you even put IllegalArgumentException in the throws line
true haha
though i also wonder why you suggested to not use an enum
wouldn't that be easier to handle
just a switch
that’s like returning an Integer where 0 is success and 1 is fail, it’s just not right
not sure i'm following, integers are magic values and enums are named
the proper way to handle this problem is an exception, every API with registration uses exceptions to prevent double registries
What I’m saying is that it’s equally silly
alrighty, thanks a lot, i'll take your help into account and code my api with it in mind
take inspiration from other libraries, just not ones predating dinosaurs, when doing that
gl
ty 🙂
hmm ye sql
hmm my parser doesnt really want to work
trying to read from memory indexed by a register value but its like nah ill give you the register value instead
nah that's python 💀
i thought it was javascript but it seems to be sql
hmm time to really not copy the c preprocessor
i somehow want to write this in rust but i dont know much rust 🤔
hey lets say green chunk is the chunk im in, how can i get chunks marked as red?
Chunk X +/- 1
and
Chunk Z +/- 1
I'm trying to make the tool in player's hand change its value of "tooldurability" tag whenever the player break a block.
But nothing change eventually.
Take a item having 300 as its "tooldurability" at first for an example.
output test1 is 299
but output test2 is 300
Is there any wrong with my code?
@EventHandler
public void ToolEffect(BlockBreakEvent event) {
ItemStack tool = event.getPlayer().getInventory().getItemInMainHand();
if (tool != null && tool.hasItemMeta() && tool.getItemMeta().getPersistentDataContainer().has(new NamespacedKey(plugin, "tooldurability"), PersistentDataType.INTEGER)) {
ItemMeta item_meta = tool.getItemMeta();
int durability = tool.getItemMeta().getPersistentDataContainer().get(new NamespacedKey(plugin, "tooldurability"), PersistentDataType.INTEGER) - 1;
tool.getItemMeta().getPersistentDataContainer().remove(new NamespacedKey(plugin, "tooldurability"));
tool.getItemMeta().getPersistentDataContainer().set(new NamespacedKey(plugin, "tooldurability"), PersistentDataType.INTEGER, durability);
System.out.println(durability + "test1");
System.out.println(tool.getItemMeta().getPersistentDataContainer().get(new NamespacedKey(plugin, "tooldurability" + "test2"), PersistentDataType.INTEGER));
tool.setItemMeta(item_meta);
event.getPlayer().getInventory().setItem(event.getPlayer().getInventory().getHeldItemSlot(), tool);
}
}
ever heard of variables
you never change the itemmeta
all you do is change a clone of the itemmeta, then you set it back to the original, unchanged meta
instead of calling getItemMeta() all the item, use your already stored item_meta
It worked! Thank you so much.
i have created an entity class using nms , how can i spawn it ? by a command or event
Using the prepare smithing event how can i make it so the current recipe yields no result
set result to null
thats what she said
You sure
lmao
Why are you throwing out of memory error 💀
I wonder if I can make my scripting engine overflow somehow
I already handle stack overflows by copying over variables to a temp cache and dumping the stack
just put your stack offheap
well
no more overflows
stackoverflows happened when I had a recursive script play for too long
so when I play a script, I copy the variables from this script to the other
and dump the stack
and then play it
lol
hmm
minimum size of arrays to store anything is 2n-1
i got a problem with my plugin,
If i join i can not take anything out of any inventory while only it needs to be turn off for the bangui
This is the code i used for it
Don't compare inventories by their name
compare the inventory objects
how i do that?
reason for not using the name is because someone could send a packet with the inventory name
do you not know what an object is?
im in my learning fase
the way I did it back in like 1.12 was I created a custom invholder and then I could just compare the invholder w that
inventory inventory = new inventory ideally your custom inventory AKA gui
now hold a reference to it, maybe in your main class
anytime you come across an inventory compare the inventory objects
if its not yours they won't match
i don't get it
personally I’d say storing a reference to each inv is pretty taxing, take a look at this small plugin I made while I was learning: https://github.com/poilet66/BannerEdit
then you really need to learn more about java
obv you don’t need a custom class for each gui tho
Storing a reference is fine
while true, it is probably advised as it keeps it organized
tomato tomato I guess, if you’re tryna improve performance though there’s no way that’s advantageous
in what way?
I don't see how it wouldn't be optimal other then taking up a few more bytes of memory
otherwise it would be fine
well it just doesn’t scale very well at all
yes it does scale if you use classes to organize your stuff
in what way does it not scale?
^
what happens when you’re running like a 400 person server with each of them trying to interact with different inventories
That's 400 things in a list or set
there shouldn't be 400 copies of your inventory
why wouldnt you try minimise the memory you’re consuming?
Depends on the type of inventory
because memory is cheap first off, and the amount of memory consumed is not as much as you think it is
oh do you mean storing an instance of each type of gui rather than each open one?
true, but since we are talking in general for gui's typically only need 1 copy
yes
that’s better, but does vary with the type of inventory
what if it’s like a randomised mini game or something
as I said it isn't going to take up as much memory as you think it would
at most with 400 copies of an inventory, you are looking at anywhere between 100-200mb of memory
Probably less
because that is a waste of time
if you want the best might as well just drop to asm only
nothing else
lmao
Keeping things in a set isn't going to take hundreds of mb
but then your time for making something exponentially increases. So its a trade off. You shouldn't waste your time on micro-optimizations unless that is all you have left to do and it is needed.
lets just do that java stuff in c++ lol
kinda sucks that you cant store values in c++ enums
i want to summon lightning couple block in front of me, how do i do that?
there's ^ ^ ^ symbol in minecraft command whenever i want to summon thing on my eye level, but i dont know how in here
sry bad english 😭
you could strike the lightning at the block the player is targeting
Get the players look vector, normalize it so it has a length of one, then multiple it by how far you want the lightning to be in front
You can then add said vector to the players location
always fun when creating a new project and you dont know how you're gonna call it
so now its "untitled"
I usually just hit my keyboard so half my projects are "adsfdraadsafes"
thank you sir
ive got this problem i cant fix, my custom items get used 5 times in one tick and i dont know why/how to stop it, if you could help itd be very appreciated
code (line 193 for the "onPlayerInteract" method):https://paste.md-5.net/epacuseged.java
line 50, 117, 136, 155, 172.
Does someone know how to get a superclass instance from a class?
For now I have gotten only the class, but without the instance
With reflection?
yes
.newInstance or whatever
yeah, but I need the instance of the superclass
I already have the instance of the base class, but I need the superclass instance
if I do that then I just get an empty new instance
I need the one from the base class provided
wouldn't this just make an empty new instance? Or use the one which is provided from the base class?
I need to just get one field from the super class
which field is declared on the base class
Well it will create new instance
Just get field from superclass
And call field.get(baseObject)
It should work
I tried it
whats wrong with those lines
No it throws a java.lang.NoSuchFieldException
can you show your code
Sure
Does anyone have any information on how to create custom configuration files? I ideally want to have a file that saves a list of player warp locations which I can read and write to
I can dm on how you can do this and explain it you?
yeah sounds good
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Field[] anvilContainerFields = ReflectiveUtils.getPrivateFields(container.getClass().getSuperclass()); for(Field field : anvilContainerFields) { System.out.println(""); System.out.println("Field: " + field.getName()); System.out.println(ReflectiveUtils.getPrivateField(container, field.getName())); }
dk what is ReflectiveUtils
Container obj = ...;
Class<?> superclass = obj.getClass().getSuperclass();
Field field = superclass.getDeclaredField("foo");
field.setAccessable(true);
Object bar = field.get(obj);
this should work
my own util class for faster Reflection
will try it in 1 second
varhandles 🥰
aren't you some type of magician? I literally tried that before and it didn't work, but right now it just worked, WHAT?
idk what your utils are, but it looks like according to this line ReflectiveUtils.getPrivateField(container, field.getName()) that you are just trying to get field from subclass again by name
and that wouldn't really work
yes you're right I need to do some tweaking a little bit. They work perfectly for normal classes and instances, but not for subclasses
glad it worked 👍
IJ drunk again
(and yes, I know the method calls itself, it's still bullshit to say that it's unused)
not surprised its confused with an infinite loop.
Yeah thank you very much! Right now I can do some NMS stuff
intellisense can only do so much
how can i add explosion power to a fireball?
Um, what would I put as the contracts with getPlayer() and all that ik that's wrong but it's not new nor fail? Would it be this? But it ain't returning the interface class https://github.com/Outspending/MobCore/blob/main/mobcore-api/src/main/java/org/mobgens/PlayerGenerator.java
Ig I could just remove the contract
Theoretically it's unused
how to get an EventPriority from a String in bungeecordApi?
whos a nerd who can help me rq?
?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!
how i can set ItemStack nbt?
Im having trouble with external inventories/commands. Im getting these errors, the first is the /ec command(not opening) and the second is a different plugin for a vault plugin(null inventory screen/no gui access)
Depend NBT API
I mean it tells you that inventory is null, so whatever you're trying to open is null 
Hard to really point you to a direct problem without seeing the code
where do i see the code for it, ive looked and I have no idea where im looking
./ec command as in the /enderchest command from EssentialsX?
yes

You might just have to take that up with them specifically
Just make sure your version is right
ok i really need help lol who can vc with me semi soon.
im sorry im dumb, is the other one something that is a spigot
The second one just looks like the name of the inventory is "nul"
it also just has me take things out of it, instead of opening a new gui
its a player vault plugin
Same thing then, try the plugin author, they'll have a way better idea what's going wrong.
player.getInventory().setItem(itemSlot, CraftItemStack.asBukkitCopy(net.minecraft.server.v1_7_R4.ItemStack.createStack((NBTTagCompound) MojangsonParser.parse(tag))));
why this not works?
item... immediately removes from inventory after changing nbt
If I'm not mistaken (and honestly I might be), you can do this
enum OpCode : uint8_t {
HLT = 0x00,
MOV,
ADD,
SUB,
MUL,
DIV,
INC,
IN,
OUT,
JMP,
JP, // 0x0A
JPZ = 0x0A,
JNE,
PD
}
hmm?
The following constants will just increment
Two opcodes have the same value
ye
Yeah, that's why I set JPZ to 0x0A
ah bruh cant even count in hex
I'm like 40% sure you can do it twice
I completely disregarded that autoincrement thing
what have i been doing in college
kinda intresting approach to go from java to c++
cant even store data in an enum here so no idea how ill get a functional interface in there
a class ig
How do you have two projects opened at the same time in IntelliJ?
What you're doing with an enum in C++ is nothing more than restricting a set of numerical values
Two instances of IJ I think
Oh my god...
ij and clion

Yep I'm out of there.
fwiw I suppose IJ can dedicate more resources to just a single project as opposed to Eclipse's workspace, but even still, I close like most of my projects if I'm not actively working on them
I upgraded to 32 Gb a year ago.
It was much needed - no idea how I survived with 16 Gb
I need an upgrade bad
16 weak
oh shet laptop hardware expensive thb
and my battery somehow broke
I'm starting to need more ram since everything is chrome in disguise
I mainly need ram to counteract the memory leaks present in large minecraft modpacks
ye firefox is chrome in disguise
idk why i even switched, probably because of the crashes
that too basically
I have no idea how people manage to make java use 20 Gb of RAM even with -Xmx9G in the first place to be entirely honest
Though the last few days I've spent on just fixing bugs on a single medium-sized mod and sometimes I question the sanity of mod devs
hmm lets just make my enum a struct and put some constants of it in a cpp file
You don't you use a function pointer array?
chatgpt told me about that, i was using a std::function before
So you map each opcode to an index on that array and here you have your "functional interfaces" (completely disregarding that those are not functional interfaces)
well it said smth like: have a struct with your data and a function pointer, then have a map to map a hex value to that struct
I'd just use a global array
actually lets use a simple array
anyone wanna hop in a vc rq and help me debug something
Chances are we don't need to be in VC for that
100% do
my turn switching method is broken for armourstands only but it says its working with the debug
so it calls the mthod right but doesnt allow the other player to do their move/turn
the method works for other moves
just not this one
all call it the same
public void switchTurns(UUID playerUniqueId, UUID opponentUniqueId) {
if (playerExtraTurns.getOrDefault(playerUniqueId, 0) > 0) {
playerExtraTurns.put(playerUniqueId, playerExtraTurns.get(playerUniqueId) - 1);
Bukkit.getLogger().log(Level.INFO, "Player " + playerUniqueId + " has extra turns. Not switching turns.");
} else if (playerSkippedTurns.getOrDefault(opponentUniqueId, 0) > 0) {
playerSkippedTurns.put(opponentUniqueId, playerSkippedTurns.get(opponentUniqueId) - 1);
Bukkit.getLogger().log(Level.INFO, "Opponent " + opponentUniqueId + " has skipped turns. Not switching turns.");
} else {
currentTurn = opponentUniqueId;
Bukkit.getLogger().log(Level.INFO, "Switched turn from player " + playerUniqueId + " to player " + opponentUniqueId);
}
playerUsedFireworks.put(playerUniqueId, 0);
playerMoves.put(playerUniqueId, null);
playerMoves.put(opponentUniqueId, null);
// Inform players about the turn switch
Player currentPlayer = Bukkit.getPlayer(playerUniqueId);
Player opponentPlayer = Bukkit.getPlayer(opponentUniqueId);
if (currentPlayer != null && opponentPlayer != null) {
currentPlayer.sendMessage(ChatColor.YELLOW + "It's now " + opponentPlayer.getName() + "'s turn.");
opponentPlayer.sendMessage(ChatColor.GREEN + "It's your turn!");
}
}
thats a lot of puts bruh
nah just clean up your code
this is clean for what it does
have a gameloop which handles everything
i remove one line and it breaks
breaks it
Ok its either yes i can help or no i can not help
I mean I can help but I'd like to avoid vc
I've never seen a problem where I had to use vc to be entirely honest
bc the rest rely on block places not entity place/spawn
Chances are some preconditions are not set
You are missing return;s in your two if statements
that block works for every other move
actually, it's more complicated than that
imma just be lazy and make it think its a block im placeing when i place a armor stand.
regardless playerExtraTurns and playerSkippedTurns is a bit flawed
how so?
public void addExtraTurn(UUID playerId) {
int currentExtraTurns = playerExtraTurns.getOrDefault(playerId, 0);
playerExtraTurns.put(playerId, currentExtraTurns + 1);
}
public void skipTurn(UUID playerId) {
int currentSkippedTurns = playerSkippedTurns.getOrDefault(playerId, 0);
playerSkippedTurns.put(playerId, currentSkippedTurns + 1);
}
i mean that also works lol
the move that skips the opps next move works
if any of the two values are > 0 then the players are still reminded of the turn switch
Actually wtf how can this method work in the first place
Ok i go in i place a cake it goes to my opp i cant place summion drop anything my opp can. and it just works
so either u dont know what you are talking about or sum
bc it works lol
just having a problem with the entity swaping turns
The message that is sent always remains the same
Unless you swap out playerUniqueId and opponentUniqueId somewhere else
but at that point you could just not make use of currentTurn
ok explain to me how my code works for everything else but u are saying it doesnt?
i can go in and play a whole game only use block moves and it works
ugh fine.
I'll go to vc and see if you can explain it that way
Naw u clearly dont know tf ur talking about.
"doesnt work at all"
i just did the lazy thing and trick it into thinking the Armor stand was a block.
I am just talking with the info I know at the very moment
works the same
But if your switchTurns method ends up to be broken you'll remember me
No whining on that front
hmm smth like this ig
hasnt broke in 4 months
e
works fine for blocks.
AH I get it
but then you are using a very nonstandard form of flow-control
And the method name is called misleadingly
Should be onSwitchTurns
Or full enterprise-style name: informPlayerOnChangedTurnsOnPostSwitchTurns
What?
Basically that enterprise-style name signifies three things
- Players are informed that their turns have changed
- Only called after turns have changed
- The method does not act a form of flow-control but rather purely informational
Hi everybody, does anyone know why when I click on a block, the event happens twice
Code:
@EventHandler
private void PlayerInteractEvent(PlayerInteractEvent playerInteractEvent){
if(playerInteractEvent.getAction() == Action.RIGHT_CLICK_BLOCK){
if(Objects.requireNonNull(playerInteractEvent.getClickedBlock()).getBlockData().getMaterial() == Material.CAMPFIRE){
playerInteractEvent.getPlayer().sendMessage(ChatColor.GREEN + "campfire");
}
}
}
?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
}
really people
Thanks
I am having problems with this code because it runs for the attacker and for the victim, so it runs twice and causes bugs. I tried using the EntityDamageEvent but I couldn't find a way to check if the attacker is a player.
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if (event.getEntity() instanceof Player) {
Player victim = (Player) event.getEntity();
startCombat(victim);
Bukkit.getLogger().info("victim " + victim);
}
if (event.getDamager() instanceof Player) {
Player attacker = (Player) event.getDamager();
startCombat(attacker);
Bukkit.getLogger().info("attacker "+ attacker);
}
}```
I dont really understand what you mean. But if you want to check if the player, and the attacker are both players do
if (event.getEntity() instanceof Player && event.getDamager() instanceof Player) {
// Here the victim, and attacker are both players
}
lol
That's not my problem The problem is that when I hit something, this function gets run twice.
Or when I get hit
What function?
the startCombat fucntuion?
Yeah you are running it for the victim , and the attacker in your code
so thats twice
My bad I meant the event happening twice.
one time because I hit the entity and one time because the entity got hit, I think I am not sure
Are you rgersting the event class twice?
Oh yeah that might happen
Who are you and who invited me here?
You should know
Thanks for the help. I solved it I registered theEventHandler on my main class so it ran twice 😄
We do not know
does this looks good @quiet ice
Amazing!
oh god
I mean this is like your 4th time asking this question
To be honest I have 0 experience with C++
But I wouldn't even dare to use C++ in any way similar to java
Well I'd probably just write plain C code at that point
hmm manually memory allocation, fun
Just don't use the new keyword
Or if you do, delete it
Why write c when cpp is extension to c
- cpp compiles to machine code still
CPP is OOP. That being said writing procedural code is back in fashion at the moment
Basically OOP is not seen as a bonus but rather as a detriment to some. I share that opinion when it comes to working at such a low level
classes dont feel low level at all
Why would you use extern in cpp
It's basically considered bad pratcice
And not object oriented
idk im still figuring out stuff
when i tried to learn cpp i got bored after 3 days
Discord mobile is very buggy atm
Player#hideEntity is deprecated, is there a different way?
i think my server has a memory leak, i have used spark to create a heap dump, and looked at it, but i have no clue what could be causing it? can anone help me?
hideEntity(Player, Plugin)
This method is also deprecated.
I don't want to hide players, but entities
the deprecated are hidePlayer but also i think the hidePlayer now use the hideEntity then its the same..
hmm
Weird, my IDE is complaining about it being depecrated 🤷
XD
what version u on?
if i would have to guess i would say paper xd
I don't depend on paper though 🤔
oh i remember in what case is deprecated.. in olds build Deprecated was for "you dont need use this" and also "this method is draft-api or experimental then we advise"
in a few PR i make this use Experimental for make the difference
hideEntity() was deprecated as draft API up until recently when we started using @Experimental instead
You can either update your API version or suppress the deprecation. That method isn't going anywhere
component pr when
for who manage how rebase things in spigot? xd
I'll see if I can get the motivation to do it in May after my gf goes home
Does someone know how I can change the holder of the inventory?
is she not canadian?
Okay, perfect. Now I just need to figure out why it doesn't hide the entity 🤔
bump
bump what?
How can I change the holder of an inventory?
in normal circumstances you can just open the inventory with the new owner
But it depends on what exactly you wish to accomplish
Just do player.openInventory(inv) or something
most likely need to create a new inv with that holder
But I can't create a new one
why not
won't that change the holder?
?jd-s it's been ages since I touched that part of spigot though
because the inventory is created through NMS and then converted to Bukkit with a method which seems to not change the holder
Well I guess you can't change the holder
You shouldn't need a holder anyways - consider it an implementation detail
Yeah, but it makes my event handlers much easier
how can i open a bookpage in my gui and save the contents as a string when they click save thingy
I mean the extra logic that would be needed is only like 50 lines of code at the very most
As far as I know it's possible.
Just wondering what is Ass-pressure?
declaration: package: org.bukkit.event.block, enum: Action
what a javadoc
The term is still a bit foreign to me
It's an old reference
Are the examples not clear
pincher pressure
alright
dayum
Later refined by Wolfe (or, at least commited by him) https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/commits/d8b48c2ec9f38a921ac54f5655a2da2d88f10ec5#src/main/java/org/bukkit/event/block/Action.java
literally just ass presure
I don't remember what the original reference was. I wanted to say it was Monty Python but I don't think it is
The idea though is that your ass is so heavy that it activates the pressure plate
our mc characters got a dumpy
I've not spoken to them personally, but Dinnerbone was on the forums at a time
fast forward 2 years choco now works for mojang
choco if you got hired at mojank woud you revive the built in modding api
import net.minecraft.server.v1_8_R3.ItemStack;
import net.minecraft.server.v1_8_R3.NBTBase;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.NBTTagList;
Hello, can someone tell me why the import won't? I already have the code done and it still won't work
they turn red
how can I summon 2 item frame in the same place?
can someone explain me why original minecraft classes named NMS?
net.minecraft.server
