#help-development
1 messages · Page 2064 of 1
can you print the uuid?
sure
it looks like you are creating the entity using nms
Send block change changes the block client side, but is there a way to reset it?
yep i believe so
cant you just track the locations of those block changes and update them then @fossil lily
Anyone knows if theres a good library for clientside world borders?
maybe get a list of all entities and print their uuids
It doesnt seem to be updating correctly...
why?
and then check if your entities uuid is in there
I get all these weird ghost blocks
tried that already
see Nest->getNestEnt()
did not work
then you can check if it registered your entity
where
here
System.out.println("Debugging shit: ");
System.out.println(this.getBukkitEntity() == Bukkit.getEntity(this.getBukkitEntity().getUniqueId()));
System.out.println(this.getBukkitEntity().getUniqueId());
System.out.println(nestExists(this.getBukkitEntity().getUniqueId()));
[15:59:22 INFO]: [HearthNest] [STDOUT] Debugging shit: [15:59:22 INFO]: false [15:59:22 INFO]: 65c9fcbc-79bc-4306-aa91-198b148cbc80 [15:59:22 INFO]: true
Don’t use ==
r u sure
it should be the same object right
right
that's the whole point
if i change it to .equals and that works
Evidently not
i dont think the entity uuids are always the same
oh nvm you double negatives
should it matter?
so idk if saving them in the config by entity uuid will work
theyre randomly assigned iirc
uniqueId
when they are loaded, could be wrong
didn't work to use .equals
yeah its still unique
it's generated randomly but it stays forever, no?
doesnt say getPersistentUniqueId()
when I do block.getBlockData.getMaterial it doesnt copy the type of block. Like if the block is a spruce slab, it will just show an oak slab. If you have brown concrete, it will spawn bright concrete.
idk
How can I copy more specific data?
lemme look it up
it definitely stays forever
cause in the banned-players shit
you can find their UID
UID would be useless to assign to players
if it changed.
.getType()
so am i using an entityId?
let's see
check your method calls
anyways
is it possible to force an @override without making the class abstract or an interface?
can you derive the entityId from uniqueId?
no
Still doenst work
can't u do 0b instead of (byte) 0 ?
entity id is assigned when loaded, unique id is apparently persistent
there a postfix for byte?
ok so do i ever need the entityId for these methods?
apparantly there isnt
probably not. I believe entityID is internal
yeah
ok
anyone who knows this here though?
urgh see thing is
i want to not copy paste the code for a runnable over and over again, but i want to make sure the method it in turn calls is implemented
Ok i think i've come to the conclusion then
so how do i contact mojang that their method doesn't work
or spigot or whoever
???
?jira
ty
hey there so im trying too implement my own chat renderer for my server however i cant workout how to assign it so that it is used how would i go about doing this?
Chat renderer?
ive been told i need to do it in the eventhandler but not sure what to do after that
yeah the method that gets called when a message is sent
This sounds like paper API
ahhh ok i'll try their discord then
a
a
Player player = (Player) sender;
if(!(player.hasMetadata("initiated"))){
player.sendMessage(ChatColor. + "[ArenaLocker] " + ChatColor.GOLD + "Correct Usage: /arena create");
}
if(command.getName().equalsIgnoreCase("pos1")){
String world = player.getWorld().getName();
player.sendMessage(world);
player.removeMetadata("initiated", plugin);
}
return true;
}
}```
The plugin is getting confused if it has meta data or not
So after Player inputs /arena create
unchecked casting always nice
they get initiated metadata
and then they put /pos1 command
after they put /pos1 inititated meta data should be removed
and its removing sucessfully still
it gives this message player.sendMessage(ChatColor.YELLOW + "[ArenaLocker] " + ChatColor.GOLD + "Correct Usage: /arena create");
suppose I have a item named shard with custom properties and I want that shard in a crafting recipe for another customised item. How can I do this? (pls ping if you reply)
How can I edit the entity packet before sending it with protocol lib?
I want to summon a nametagged armorstand
how can i make an entity with no ai able to be hit by arrows?
Make it vulnerable
it's not invulnerable
as in it can still take damage
but is that a separate thing?
It doesn't take damage?
That doesn't make sense
oh probably it's because of setCollidable(false)
anyone?
anyone?
you should not be using command.getName()
what to use
getServer().getPluginManager().getCommand(<command name>).setExecutor(new <command executor>)
some of the names or arguments might be wrong since i’m on mobile
but intellisense should probably show the right ones
ok thats another issue, but my main issue is this
if you haven’t done that it won’t ever be called
assuming you’ve set the executor of “arena” to that
How do I use the ExactChoice(https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/RecipeChoice.ExactChoice.html)
declaration: package: org.bukkit.inventory, interface: RecipeChoice, class: ExactChoice
Does like... no one know the answer?
just edit the entity?
I have done it
ok well then try it now
anyone got any example for this?
i havent coded plguins in a year e why doesnt this work
import it
whats the import e intellij isnt showing for some reason
click on it then press ALT + TAB
nope nothing
well whats the error
add import org.bukkit.event.EventHandler; to your imports
ty
aight working thanks
bruh
sometimes intellij might be frozen
import me.axure.bangui.utils.BanMenuUtils;
import org.bukkit.BanList;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
public class BanInventoryListener implements Listener {
@EventHandler
public void onMenuClick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
if(e.getView().getTitle().equalsIgnoreCase(ChatColor.AQUA + "Ban GUI")) {
if(e.getCurrentItem().getType() == Material.PLAYER_HEAD) {
Player toBan = p.getServer().getPlayerExact(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()));
BanMenuUtils.confirmBanMenu(p, toBan);
}
} else if (e.getView().getTitle().equalsIgnoreCase(ChatColor.RED + "Ban This Player")) {
if(e.getCurrentItem().getType() == Material.BARRIER) {
BanMenuUtils.openBanMenu(p);
} else if (e.getCurrentItem().getType() == Material.WOODEN_AXE) {
String name = ChatColor.stripColor(e.getClickedInventory().getItem(4).getItemMeta().getDisplayName());
p.getServer().getBanList(BanList.Type.NAME).addBan(name, "Banned By a Moderator", null, null);
p.sendMessage(ChatColor.GREEN + "Banned Player");
}
}
e.setCancelled(true);
}
}```
Error:
```yml
java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because the return value of "org.bukkit.event.inventory.InventoryClickEvent.getCurrentItem()" is null```
You don’t have any null checks.
null checks null checks null checks
If the player clicks on anything other than an item, it’s considered null.
No, a player head is an item and it won’t be null, but if the player clicks on another slot or outside the inventory, the “item” they clicked will be null.
That being said, other things about the head could be null. ItemMeta is an example of this.
well heres the code which makes the gui and the head
ArrayList<Player> list = new ArrayList<>(p.getServer().getOnlinePlayers());
Inventory bangui = Bukkit.createInventory(p, 45, ChatColor.AQUA + "Ban GUI");
for (int i = 0; i < list.size(); i++) {
ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD, 1);
ItemMeta meta = playerHead.getItemMeta();
meta.setDisplayName(list.get(i).getDisplayName());
ArrayList<String> lore = new ArrayList<>();
lore.add(ChatColor.GOLD + "Player Health: " + ChatColor.RED + list.get(i).getHealth());
lore.add(ChatColor.GOLD + "XP: " + ChatColor.AQUA + list.get(i).getExp());
meta.setLore(lore);
playerHead.setItemMeta(meta);
bangui.addItem(playerHead);
}
p.openInventory(bangui);```
would anyone know of a good scoreboard api that's actively being supported?
Perhaps helper
Hi, i have a problem with my /Freeze command and i don't now what(Think is somthing with event.setCancelled(true);)
Code:
https://paste.md-5.net/owewehowub.java#
Pls tag me
there is something as if else
he null checks it but doesnt do an early return wha-
also that contains check can be replaced with #remove
using Location#getWorld#getName 
hm?
then its useful
nah
link?
Objects::requireNonNull does the job
cuz assert will literally do nothing
unless u enable it with a jvm flag
🙄 it will suppress the compiler warning iirc
https://github.com/lucko/helper @patent horizon
yes but I mean a //noinspection nullableproblems would also disable the warning
Objects::requireNonNull does as well
how could i get all walls arround a block
and even just using the correct @SuppressWarnings would do the trick
screenshot?
so i just did @SuppressWarnings("all") kek
i tried getting the corner and adding a 9 but i get issues with negative cords etc
i alsoi chekced the cubid class (https://pastebin.com/raw/pv8JFXXL) but it doesnt have a method for thisi think
same for the noinspection thing
it was constantconditions
ah right i used it and i forgot it
and if not ::requireNonNull is superior
like perhaps if you're testing assert is useful
but then we still got junit
which is is just so much more sophisticated
OOP is so awesome
yesnt
I can now easily add whatever amount of new game modes I want, by just moving stuff from CompetitiveContest / CompetitiveGameLoop into abstract classes. took 2 hours but will save tons of hours in the future
nice
oh no white theme
@ivory sleet
getCurrentItem is null, did you read the stacktrace?
yea how do i fix it
null check the inventory
it shouldnt be null
don't call any methods on stuff that's null
but it is
myes implementation inheritance does solve the dry problem as well as provides polymorphic behavior but contrary it also tightly couples code and the abstraction it provides becomes extremely intricate once multithreading comes into play
if you click outside of the inventory, the inventory is null
i havent
you definitely clicked on something that made getCurrentItem return null, you can't deny that
if (thing == null) {
//TODO handle if variable thing points to null
return;
}
oh so java is kind of like javascript
i know i mean like return
no it isnt
well even C had that
good to know
conclure dont let him switch to C now ;-;
🥲
Anyone who actually uses C is a psychopath
myueah C is quite atrocious
or is writing a linux kernel ;-;
hey, i'm pasting schematic with location loc.clone().add(0, 5, 0) and i want to remove it later
As i see there is getMinimumPoint() and getMaximumPoint(), but I have no head for such mathematical things, can sb help?
java.lang.NullPointerException: Cannot invoke "org.bukkit.entity.Player.getDisplayName()" because "toBan" is null 😂
well provide some context
Inventory confirmMenu = Bukkit.createInventory(p, 9, ChatColor.RED + "Ban This Player");
ItemStack ban = new ItemStack(Material.WOODEN_AXE, 1);
ItemMeta ban_meta = ban.getItemMeta();
ban_meta.setDisplayName(ChatColor.DARK_GREEN + "Ban");
ban.setItemMeta(ban_meta);
confirmMenu.setItem(0, ban);
ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1);
ItemMeta player_meta = head.getItemMeta();
player_meta.setDisplayName(toBan.getDisplayName());
head.setItemMeta(player_meta);
confirmMenu.setItem(4, head);
ItemStack cancel = new ItemStack(Material.BARRIER, 1);
ItemMeta cancel_meta = cancel.getItemMeta();
cancel_meta.setDisplayName(ChatColor.RED + "Cancel");
cancel.setItemMeta(cancel_meta);
confirmMenu.setItem(8, cancel);
p.openInventory(confirmMenu);```
where do you declare the variable to_ban?
yeah do you have more context surrounding what exactly you're trying to do?
ye listen to FourteenBrush here
public static void confirmBanMenu(Player p, Player toBan) {
this?
or the other
Player toBan = p.getServer().getPlayerExact(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()));
the return of getPlayerExact can be null
yeah, wait
does chatcolor.stripColor actually remove all the color codes or just the \u00a7
removes \u00a7 + consecutive color code identifier char
uuuuhhhh i used it once and it didnt work
if the getPlayerExact method returns null, it means that the player with that name is not on the server
for instance it may look like (not exactly but just do demonstate)
Player getExactPlayer(String name) {
return playerMap.search(name).orElse(null);
}``` @quaint mantle
in which even tho its not a variable it may (still) be null
first of all https://github.com/dmulloy2/ProtocolLib
the read me goes thru it
altho it presupposed you use gradle/maven
so if you dont, a good start is to do it with maven/gradle
good luck 
any ideas on why it causes the server lag until it crashes if the gun.getBullets() is like 10?
I'm pasting schematic like this:
Location loc = spawnLocations.get(i);
pasteSchematic(loc.clone().add(0, 5, 0));
private static void pasteSchematic(Location loc)
{
Clipboard schematic = Main.instance.loadSchematic(schemPath.toFile());
try (EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(BukkitAdapter.adapt(loc.getWorld()), -1))
{
Operation operation = new ClipboardHolder(schematic)
.createPaste(editSession)
.to(BlockVector3.at(loc.getX(), loc.getY(), loc.getZ()))
.ignoreAirBlocks(false)
.build();
Operations.complete(operation);
} catch (Exception e)
{
Bukkit.getConsoleSender().sendMessage("§8[§3NSkyWars§8] §cError while pasting schematic: " + e.getMessage());
}
}
I want to remove it later (building)
As i see in there:
Clipboard schematic = Main.instance.loadSchematic(schemPath.toFile());
schematic.
I have getMinimumPoint and getMaximumPoint in schematic.
When i run the bat file to put in my version it doesnt work anyhelp?
could someone explain this http://pastie.org/p/2rk362tWAMdYDIgOMHCMPW, mostly the for loops, why does it x = Math.round((x + 0.05) * 1e2) / 1e2
so me and my friend are trying to collaborate on a plugin, im using vscode whereas and he is using intellij, how would we efficientely share our classes and such
uh, vsc is almost a plain text editor, you shouldn't use it to write a plugin
GitHub
Or just
Git in general
isnt there a code together thing in ij?
holy shit ok actual devs are online now
can someone help me understand how to use Bukkit.getEntity(UUID)??
if he's just sharing it then its useless
Also sessions are limited with code together aaand it's not exactly the best for sharing classes
Code together is great for teaching :)
the method in NestYML in addMember() doesn't work
feel free to bully me about my shitty code
oooh
the commented portion***
i have plenty of extensions
alright thanks
every entity on the server has an uuid, and this methods just searches for the entity with that uuid
and its nullable
should i just put our classes folder in the git?
then open my github project
what class
ah lol
I mean it's not the worst code
System.out.println(this.getBukkitEntity() == Bukkit.getEntity(this.getBukkitEntity().getUniqueId())); is always false
what'd i do
Different instances, probs
For most cases*
You can (and should) compare stuff like enums and primitives with ==
but anyhow == should work
As well as InventoryViews
because its getting the actual entity
is there a way to see how much time ive spent in intellij in total?
this man is going for the stats
yessir
what is getBukkitEntity returning?
an entity
yeap
lol
I'm a little late
lmfao
why do you even need it
a little
how would i convert my vscode project to be compatible with intellij?
because
i'm storing a "nests" entity UID in a yaml file
dont know if there is a CraftEntity class and what its equals implementation is
You can import projects with IDEA
i need to convert it back into the entity
isn't it persistent?
they always scare me
For an entity?
Probably not
I would imagine all entities are randomly assigned a new UUID when they're loaded but
Actually I have no idea
there's an entityId and an entityUniqueId
the entityUniqueId is persistent
that's what i'm using in the Bukkit.getEntity() I think
but if it's the entityId then i have no idea how to get that
how do you derive the entityId from the uniqueId
i believe that the uuid is persistent bcs entities also have an entity id which is not persistent
thas what i just said
lul
ah wait
bro this man is saying something else
but its persistent?
true
I mean I would think it would be saved in the NBT
the first is just implying the second is false
but its not incorrect
🤷
i just think it shouldn't be this hard
anyone?
OK
i just got good information
i think it is a problem with entityId vs uniqueId
watch
not really, Bukkit.getEntity requires a UID
addMember(this.getBukkitEntity().getUniqueId(), placer, "leader");
setNestSpawn(this.getBukkitEntity().getUniqueId(), placer.getUniqueId(), this.getBukkitEntity().getLocation());
System.out.println("Debugging shit: ");
System.out.println(this.getBukkitEntity() == Bukkit.getEntity(this.getBukkitEntity().getUniqueId()));
System.out.println(this.getBukkitEntity().getUniqueId());
System.out.println(nestExists(this.getBukkitEntity().getUniqueId()));
System.out.println(getNestEnt(this.getBukkitEntity().getUniqueId()).getUniqueId());
[18:58:58 INFO]: [HearthNest] [STDOUT] Debugging shit: [18:58:58 INFO]: false [18:58:58 INFO]: dfbc8a5e-6a05-45d8-b2f4-67d0b4eea6fd [18:58:58 INFO]: true [18:58:58 INFO]: b71ef53e-6026-45d6-96fd-4292b59bfd16
two different Ids!!!!
for each entity there are two Ids
an entityID and a uniqueID
yes, as said, getBukkitEntity() creates a new BukkitEntity
i have no idea which is the input to getEntity()
does it?
why 😭
that makes no sense
yes it does
public CraftEntity getBukkitEntity() {
if (this.bukkitEntity == null) {
this.bukkitEntity = CraftEntity.getEntity(this.level.getCraftServer(), this);
}
return this.bukkitEntity;
}
yeah that don't make a new entity
no, it creates a new BukkitEntity though
ohhh
(if there isn't one existing yet for this NMS entity)
ok i have no idea what the differences are between a bukkit entity and a craftentity
pls explain
those are the same
oh?
CraftEntity is the class that implements the bukkit entity
list ArrayList implements the List interface
entity is an interface
holy shit i just found something
Hello, how could I know if, for example, "DIAMOND ORE" is within a certain zone x y z?
it worked the first time and then broke
i'm very very confused.
it worked when other nests existed
and then i killed all of them and it no longer works when spawning a new one
iterate through all the blocks in the area and check the type
this is absolutely the most convoluted shit i've done so far
would be very grateful for a solution
yeah entities are pretty weird since theres always like 3 different classes for them
what are you trying to accomplish
Oh ok, but could you provide me with a URL to the section of the docs that talk about that?
ok so how should i go about this: a nest is a structure that exists in a yaml file and is tied to a world entity through its UID. I want to find the entity from its UID in these methods.
what?
like the java docs for a for loop?
would really love some help this is my 5 hour mark of working on this small problem
what are you trying to do exactly
this
i should really be making a live google docs or something detailing this one issue i have
the issue exists in addMember() in NestYML
pog
pushing all my current shit now
why ru using Allman style
okay i'm actually gonna do this lol
Allman:
void o()
{
}
K&R:
void o() {
}
oh
as you can see K&R looks awesome
opposite to Allman
and modern IDEs like Intellij stop you from using Allman
hehehe
and by default uses K&R
Nope
when importing methods
ok
wut
sir just read what it says
not when my code is broken
and u have it on github anyways?
yep
it doesnt do shit it makes it more readable for ppl helping u
yea
@desert musk bukkit.getentity is never going to return the exact same object as this.getbukkitentity
ticking all the boxes?
ok explain
and maybe detail my recourse
||ok so how should i go about this: a nest is a structure that exists in a yaml file and is tied to a world entity through its UID. I want to find the entity from its UID in these methods.||
What??
Yeah.
makes no sense
that's what ive been saying for FIVE HOURS
this.getbukkitentity is going to return the bukkit equivalent of your nms object
bukkit.getentity is going to return the bukkit entity of the entity in the world
???
its cuz
WHY
not always
explain
u can get it even without spawning
okook
the entity
what do i do instead
does the entity take time to spawn??
cuz if so then how did i apply all of these effects to it??
but Bukkit.getEntity() takes the entity that is spawned from the world
getBukkitEntity() give you an entity object with the information of ur NMS Entity not the spawned one which might not exist
what are you trying to do?
||ok so how should i go about this: a nest is a structure that exists in a yaml file and is tied to a world entity through its UID. I want to find the entity from its UID in these methods.
||
so you're trying to get a world entity from a uuid stored in a yml file?
yess
u want to find the entity from its uuid?
yeap
well, i honestly dont know if entity uuids change on server restart or not
UID does, EntityID does not
u get the uuid from the entity
EntityID is a UUID tho?
but what if i don't HAVE the entity
and only the UUID
yeah but entities have 2
a UniqueID and an EntityID
Bukkit.getEntity(UID)
UID is UniqueID i assume
UniqueID does not
i hope
dear god i hope
but ALSO
System.out.println(this.getBukkitEntity().getUniqueId()); // RETURNS SOME VALUE System.out.println(nestExists(this.getBukkitEntity().getUniqueId())); // RETURNS TRUE System.out.println(getNestEnt(this.getUUID())); // RETURNS DIFFERENT FROM LINE 58
so this does not imply that
i don't think
this.getUUID is different than this.getBukkitEntity().getUniqueId()
getting unique id on the bukkit entity wont work
ok
cuz ur getting the uid of something that doesnt exist, which makes no sensee
i think
`super(EntityType.VILLAGER,((CraftWorld) loc.getWorld()).getHandle());
this.setPos(loc.getX(),loc.getY(),loc.getZ());
CraftLivingEntity ent = (CraftLivingEntity) this.getBukkitEntity();`
constructing a nms entity doesnt spawn it into the world
ok thank you
uhh
thats what im saying
ok i see
getBukkitEntity().getUniqueID() will never work
ok store the new EntityNest(e.getClickedBlock().getLocation().add(0.5,1,0.5),e.getPlayer())
are you trying to spawn the nms entity into the world?
hold on finding that
addFreshEntity, does this method return something?
ok.
uhh
OK OK
so i just do all of this in placeNest instead
instead of EntityNest
boolean
if u wanna access the spawned entity uuid then yeah
lol
🤷
a not yet spawned entity cant have a uuid so
yeah
...
that makes so much more sense now btw
ok yeah
NMS makes more sense noww
i mean thats what my logic tells me
im not a nms professional or smth
u prob should try it
ok but yeah now how do i find the unique id of the "fresh entity"
the new EntityNest(e.getClickedBlock().getLocation().add(0.5,1,0.5),e.getPlayer())
store it in a variable
tried that
was red
hold on
oh
do i store it as an EntityNest?
or an Entity?
huh
can i convert it from EntityNest to Entity?
entitynest already is an entity
((CraftWorld)loc.getWorld()).getHandle().addEntity(nmsEntity, SpawnReason.CUSTOM);
can i get the entityId from it?
try getting the uid after u spawn it
if you can get the entityid from an nms entity yeah
if that doesnt exist
then ONLY after you spawn it
i'm skeptical
nmsentity is the name of your entitynest?
no no
nest is
i just wrote shitty example
hold on
well then do nest.getuuid
EntityNest nest = new EntityNest(e.getClickedBlock().getLocation().add(0.5,1,0.5),e.getPlayer());
world.addFreshEntity(nest);
UUID nestID = nest.getUUID(); ```
ew
that formatting
anyways
i'm highly skeptical of that nest.getUUID(); method
let's see if it works though
do it after u spawn tho
why no space in constructor arguments :((
lole

Reformat Code fixes it btw
i've come to torture you again
thought i did that
PogO
eh i'll try it again later
i answered it in DMs
Dont compare Entity objects
compare UUIDs
he is
brb
Should be but spigot is weird sometimes, ive had cases where i compared entity objects and they turn out different everytime
same with ItemStacks
yeah
so i always just found it easier to compare with UUID's
itemstacks dont stay the same object forever
@EventHandler
public void onPlaceNest(PlayerInteractEvent e) {
Player player = e.getPlayer();
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (e.getItem() == null) return;
if (e.getClickedBlock().getType().isInteractable()) return;
if (Objects.equals(Objects.requireNonNull(e.getItem()).getItemMeta(), ItemManager.nest.getItemMeta())) {
ServerLevel world = ((CraftWorld) player.getWorld()).getHandle();
EntityNest nest = new EntityNest(e.getClickedBlock().getLocation().add(0.5,1,0.5), e.getPlayer());
world.addFreshEntity(nest);
// write to data
UUID nestID = nest.getUUID();
int unnamed = 0;
while(!NestYML.nest(nestID,"Unnamed Nest "+Integer.toString(unnamed), 1)) {
unnamed++;
System.out.println("Found unnamed nest with the same name, iterating");
}
nest.setCustomName(new TextComponent(ChatColor.GOLD + "" + ChatColor.BOLD + "Unnamed Nest" + Integer.toString(unnamed)));
addMember(nestID, player, "leader");
e.setCancelled(true);
player.getInventory().getItemInMainHand().setAmount(player.getInventory().getItemInMainHand().getAmount()-1); // -1 nest
}
}
}```
here's what i have people
can't test it rn though brb 3 mins
using Integer.toString is pointless
also you should probably cancel the event before doing those other things, just in case one of them causes an exception
ok
testing now
LET'S FUCKING GOOOOOOOO
IT WORKED
STOP THE TIMER
5 HOURS EXACTLY
ALMOST
neat
this code describes itself
nest
and name your event variable something other than e
no! 😄
looks like garbage
true
ty for giving me tips though
i see nobody else nagging me about how to make it better
not sarcastic
sometimes we need someone that knows what they're doing, to show us what's wrong in order to improve
my first java programming actually
yeah some youtuber taught me that people use e instead of event
lul
most of my work nowadays is for youtubers so I can probably find my ways
In this episode, I give you a brief overview of what you can expect in this MC Plugin coding series. #Spigot #MCPlugins #PluginTutorial
Java Tutorial: https://www.youtube.com/playlist?list=PLfu_Bpi_zcDPNy6qznvbkGZi7eP_0EL77
How to Setup a Test Server: https://www.youtube.com/watch?v=58MZ4THF73g&ab_channel=KodySimpson
Discord: https://rebrand.l...
i didnt want to mention it
this guy i think
oh no please
i alr gave a few tips and i thought giving more would be rude
i appreciate it
no please do
don't be afraid to tell people that they're idiots
pog
lol
how can i correctly use an object as a constructor parameter
what
d1
private final Object object;
public WhateverMyClassIs(Object object) {
this.object = object,
}
not like this
then what
i have contry and president object
ah wait
public Country(double gun_pl, String name, President president, int population)```
public President(int iq, String isim, int yas, int experiment, String country)```
public ClassName(Country country, President president) { }
it has it already
im defining the constructor variables and trying to reach it but it shows null
what would be the best database to store userdata for a plugin in, im thinking of mysql but never done anything like this before so hoping there is something simpler than that.
u have to set the var outside the constr
like he did
in your case replace object with president
you're probably checking the args before
why is args[0] always null
nope
it's not different strings
simply checking if a string is == null
i genuinely think the ide is buggin
no
rare intellij L?
its always null
show full code
fyi
== checks references to objects in strings
bukkit never passes null strings
don't cancel the event
also if you want to cancel movement
just set movement speed to 0
:)
then set it back to 0.2
you can then cancel that
but only if they jump
looks less buggy
you can also cancel jumps by sending a fake barrier block above the player
using sendBlockChange
yeah something lik that
Hello,
I have set an option to show if there are updates available in my plugin but I see that it doesn't work as it should.
Here we can see that when my plugin starts it shows that there is an update available:
https://i.gyazo.com/e1ac4000af88eb5b89639567ec26d255.png
The website shows that the last update is the current one I have so I don't know why it shows me that there is a version available:
https://i.gyazo.com/151e807ef0421a3b5febe98557681ca7.png
And you'll say it's because of the -SNAPSHOP but I already use a split so it doesn't read that:
@Override
public void load() {
try {
HttpURLConnection con = (HttpURLConnection) new URL(
"https://api.spigotmc.org/legacy/update.php?resource=100875").openConnection();
int timed_out = 1250;
con.setConnectTimeout(timed_out);
con.setReadTimeout(timed_out);
String latestversion = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine();
String[] version = plugin.getDescription().getVersion().split("-");
if (version[1].equals("BETA")) {
CoreLogger.warn("You are using a BETA version. Some functions may not be stable, be careful and use at your own risk.");
} else if(!version[0].equals(latestversion)){
CoreLogger.warn("There is a new version available.");
CoreLogger.warn("You can download it at: https://www.spigotmc.org/resources/100875/");
} else {
CoreLogger.info("You are using the latest version: " + plugin.getDescription().getVersion());
}
} catch (Exception ex) {
CoreLogger.severe("Error while checking update...");
}
}```
So I have tried to see what values are returned and it tells me that on the web the latest version in spigot is 0.0.8 when I just updated 1 hour ago and as you can see in the following image the value is 0.0.9 in reality... what is happening?
cache or something?
I don't know... that's why I ask, to me what I find strange is that on the web appears 0.0.9 and the plugin reads 0.0.8... wtf
?paste
https://paste.md-5.net/uhoyajizod.java
ok i have a problem
the command /rewake "Unnamed Nest 0" doesn't count as passing in 1 argument
so...
how do i combine it into one argument?
you cant
cuz i can't compare it to strings
what you can do is reformat the args in the command
look for the locations of the first two "
aight i see
as for why im here, what's the event called when the wither breaks blocks?
also
do entities have PDC?
Yes
EntityChangeBlockEvent probably
What file format should I use to be both readable and have support for comments?
Yeah use yml
Yaml doesn't support comments by default
By default
No but it has support for it in modern spigot
yea but youre using bukkit
Yaml doesn't support comments
Yes it’s up to parsers to decide how to support it
FileConfiguration parses # as comments
As their convention is that comments are merely present to enrich the understanding and context of a node
Do you know any that supports it?
even my file editor that has nothing to do with bukkit already says # is yml comment
If we talk about java
Not in the writter
Uh yes?
Outside of saveResource
What
Snakeyaml literally support comments for both sink and source
And spigot does as well
Idk what you’re talking about
Comments gets removed
problem solved with this too
FileConfiguration getBakedConfig(String configFile){
return YamlConfiguration.loadConfiguration(getResourceReader(configFile));}```
When you write to a file
Only if you set them to
Literally not
Well maybe if you use a legacy version
But that’s your issue then
1.18 is legacy*
Not the parser, the writter
If you pass true to this one https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/configuration/file/YamlConfigurationOptions.html#parseComments(boolean) then it won’t parse
declaration: package: org.bukkit.configuration.file, class: YamlConfigurationOptions
Else it will
Both when you source and sink
Literally
Again, not the parser
?paste
Again that thing is a switch state for the save/load function to know if they should invoke comment support behavior for the PARSER
Does anyone know about this please?
it sends me blank text for "givenNestName"
Let me reformulate, does anyone know any file format and library that supports comments both when parsing the file and when writting to a file?
That doesn't remove comments when you write to a file
bruh
Spigot’s YamlConfiguration supports comments both for source and sink which means read / write
Snakeyaml literally is designed by the yaml specification to ignore comments when writting to a file
problem: Shift+Ctrl+F removes all comments origin: http://dadacoalition.org/yedit/ system: Eclipse Java EE IDE for Web Developers. Version: Luna Service Release 1 (4.4.1) Build id: 20140925-1800 YE...
you fucking realize thats 2014-2016
Spigot haven't update snakeyaml in a decade
literally has
https://paste.md-5.net/qiniwanifa.js
can someone help me parse command args?
When tf it was added
Because I'm literally now seeing it in the javadoc
some months ago in coordination with 1.18
myes, but it isnt terribly hard to reinstate support for older versions from your side
Nope, they can die
Anyway, thanks for the info
well I do very much concur with said statement :3
Sorry I was such a bummer
should apologize for screaming at you as well
but yeah that solves that now Ig, dope
Been scratching my head for over 3 days now and couldn't find a way to put comments in a yaml file 😅
i've been scratching my head for 5 hours about doing some stupid yaml shit as well
but the problem was actually about entity IDs
Well, gl
yeah thank you
ah, spigot got your back now :] tho otherwise I believe toml, strictyaml and hocon support it
its fixed now but i have to figure out how to parse command args
(officially)
which idfk how to do
Uhm my yaml files hold comments just fine?
I can't remember tho how to get custom objects now, but I'll figure it out
Wow that was a while back smh
yeah, might hint you at ConfigurationSerializable then if you wanna use spigot's way of dealing with it
@ivory sleet do u know much about command args?
first of all, mind sending me the entire function?
sure
Objects.requireNonNull(getCommand("rewake")).setExecutor(commands);
commands: hearthnest: description: Gives a nest to a player usage: /<command> rewake: description: Respawn at a Hearth usage: /<command> <nestname>
it says "Invalid Hearth Name"
ALSO
the uh
Use separate executors for separate commands, use swith/ifs for args
^
nah it gets extremely messy if you share an executor instance between multiple command instances
I will switch it though dw
it will make a difference?
mhm
'one function one reason to change'
long term yes
Not scratching your head
right
other words, make one class for each command
makes sense
MUCH easier to debug and simpler to write
wrong channel
more like a class must only have a single, major reason to change
whilst for functions, a function must only do one thing
Invalid Hearth Name
wym
As the command grows larger, is hard to maintain it
yeah jesus fucking christ
it says "Invalid Hearth Name"
Wish spigot would fix the issue with commands
yeah but that's cause givenNestName is null
or not null
Adding more nesting to them
im literally using my pc with one eye closed
why lmao
cuz it became red
so what exactly does not work as intended pricedown?
i didnt drink water at all today cuz im fasting sooo
the givenNestName variable in the function will not concatenate the arguments correctly, it will always be a blank value
fasting in terms of water? 😮
dam
ty ill need it
oh shit
private String trackersToString(Map<String, String> trackers) { List<String> trackerList = new ArrayList<>(); for (Map.Entry<String, String> entry : trackers.entrySet()) { trackerList.add(entry.getKey() + ": " + entry.getValue()); } return String.join(", ", trackerList); }
is this what i need?
Hmm?
It transform a map<string, string> into a single string
o
Something like key: value, key: value, etc..
wsup
so you'd have to do
oh what??
