#help-development
1 messages · Page 834 of 1
I think he did it because his IDE suggested it and he should def create a concrete impl to learn it 🙂
idk how correct i was but ide didn't give me errors whatsoever
https://paste.md-5.net/kuledabaji.coffeescript
What are you trying to do there?
That looks very out of place.
try to load soundlistener class if successful it'll proceed if not it'll catch block and it'll throw a runtimeException
though doesn't it make sense to run it on the main class cause my main class is a listener
This code doesnt make sense to run anywhere...
It is a highly specifc tool used for reflections and triggering classloader initialization.
Nothing you should worry about for at least another year of coding.
oh xd sorry again being a newbie has its fall downs ;-;
Create a new class
Let it implement Listener
Create a new instance of that class
Register that instance in your onEnable
Pls create a Listener instance and come back when you got that done 🙂
And make yourself familiar with the difference of a class and an instance of a class
i really ttired my best to make a concrete class implementation
https://paste.md-5.net/halizicedi.java
there's a lot of things wrong with this
- you reallocate the same instance within itself
- you register your events within the
PlayerJoinEvent
remove line 17 & 26, go in your Main where your onEnable is and put Bukkit.getPluginManager().registerEvents(new SoundListener(), this); within the enable method. I'd recommend having a look over Java basics too!
ohhhh sorry then i really struggle understanding sometimes so this really helps since its super clear
i understand, we all started at some point
and no worries you'll get behind all of this with enough time
Before today I didn't know how to write a parser now though I have this mess
https://pastebin.com/vHpTXj5b
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.
💀
it kinda is yeah
I think one thing I can improve on my Root parser is acting like color:greenhi</color>color:bluehello</color> is equivalent to color:greenhicolor:bluehello
though it works for now
less nesting is always better for the stack
idk what this is supposed to represent but if it's not something configurable just put everything in one line, no?
its a Syntax tree is purely internal its the visual representation of a language basically
oh ive just seen you meant syntax tree
like syntax of a language
I forget what its called
I don't work with this stuff a lot
the process is called tokenization
ahhh yes
so its tokens you're saving from your syntax
yeppers
any reason why this would be overshooting the target location by like 5 blocks?
Guys
side info: tokenization is part of lexical analysis, which is only one part of a compiler
Should I be separating my plugins?
well I'm making a MiniMessage clone that supports BungeeChat. Regex kinda falls off once you get more complex
I tried attempting this with regex and it was hell
so i looked up many things and decided maybe I should go for lexical analysis
alright, well if this syntax tree is not meant to be configurable, just put everything in one line no?
its not actually parsed into a string
hey, I have moved a class that implements PersistentDataType from a package to another one. The thing is that I used this pdt to store info in items and I have a machine that checks the item's pdc for this specific info. The problem is that this machine is not able to recognise old items because of the package (it looks for the pdt, which is in a new package, and finds the old pdt from the old package). I've managed to fix it by having 2 PDTs, one in the new package and one in the old package. Then in the new PDT I check in the fromPrimitive method wether it's the new or the old pdt.
@Nonnull
@Override
public List<MerchantRecipe> fromPrimitive(@Nonnull byte[] bytes, @Nonnull PersistentDataAdapterContext context) {
if (bytes.length == 0) {
return new ArrayList<>();
}
List<MerchantRecipe> merchantRecipes = new ArrayList<>();
try (ObjectInputStream objectStream = new ObjectInputStream(new ByteArrayInputStream(bytes))) {
int recipeCount = objectStream.readInt();
for (int i = 0; i < recipeCount; i++) {
Object object = objectStream.readObject();
MerchantRecipe recipe;
if (object instanceof SerializableMerchantRecipe smr) {
recipe = smr.toMerchantRecipe(context);
} else {
SlimeFrame.getInstance().getLogger().warning("Old MerchantRecipeList serialization detected");
me.voper.slimeframe.slimefun.datatypes.MerchantRecipeListDataType.SerializableMerchantRecipe smr = (me.voper.slimeframe.slimefun.datatypes.MerchantRecipeListDataType.SerializableMerchantRecipe) object;
recipe = smr.toMerchantRecipe(context);
}
merchantRecipes.add(recipe);
}
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
return merchantRecipes;
}
But now I also need to convert every item that has the old PDT to the new one, but I don't know how to check if an item has the old PDT given its ItemMeta. Does anybody know how I can do that?
that string is for my visualization to show that everything is working well
ah okay
in reality its just a class with 4 fields
private final BaseNode parent;
private final Token token;
private final NodeType type;
private final String source;
private final List<BaseNode> children;
but when working on it if its visualized its much easier to see where shit breaks
yeah igy
but i mean
if it works and only is to debug
who cares if it looks messy
interesting so why are we serializing recipes into PDC
seems like you overlooked things and created bad design
you'll have to manually check for the old class too
but considering you used serializables and I'm assuming you didn't use proper Serialization versioning that data may be as good as lost from what I know on the topic matter
The old class is the same class, the only difference is that it is in another package
Why wouldn't I? I needed it to persist between restarts
doesn't matter if you didn't do proper Serialization ID etc
yeah but why a RECIPE
like
why
there must be a good reason to serialize an entire RECIPE
oh wait that's a MerchantRecipe god I got tricked
xd
I thought that said something else
idk a ton about java serialization but you may be fucked
have you tried moving it back to the old package
if you don't provide a proper serialization version too when you change that class its possible to lose old data
excerpt from https://www.baeldung.com/java-serialization section 3.2 under section 3 Caveats of Serialization
The JVM associates a version (long) number with each serializable class. We use it to verify that the saved and loaded objects have the same attributes, and thus are compatible on serialization.
Most IDEs can generate this number automatically, and it’s based on the class name, attributes, and associated access modifiers. Any changes result in a different number, and can cause an InvalidClassException.
If a serializable class doesn’t declare a serialVersionUID, the JVM will generate one automatically at run-time. However, it’s highly recommended that each class declares its serialVersionUID, as the generated one is compiler dependent and thus may result in unexpected InvalidClassExceptions.
IMHO your solution going forward should be to store everything inside of a nested PersistentDataContainer or use NBT https://github.com/Morlok8k/JNBT/tree/master/src/org/jnbt.
this is not to say to use NMS internals use NBT to store everything in bytes
than parse those bytes from the PDC
alright, thanks
I want to create a NPC, for this I want to use an library, I tried NPC-lib but it doesn't permit do depalce the NPC, I want to make the NPC able to go forward
ZNpcs seems to be a trending one
Worst case you might try citizens' new packet npc system
What's a desginer pattern that takes in an object and returns the same object but modified
public interface CustomItemIdentifier {
labelItem(ItemStack customItem, String referenceName);
}
Maybe like this
it just applies a NamespacedKey into an item
UnaryOperator<Integer> operator = (value) -> value + 1;
int two = operator.apply(1);
type deal
you might want a builder pattern
I'm at the stage where I want to start making features for my custom items (the implementation) but I want the custom items to be labeled using pdc
and I also want it to all be loosely coupled
but idk how to approach this
functional interfaces / lambdas are definitely the way to go, I agree
they allow you to very easily express side effects and then store them for later
I'd probably make some sort of pdc system on your item builder
And use uh
Maps n interfaces
some of these feel like they could be abstract classes
like CustomCharacterInformation
is there any reason for ArmorContainer to be anything but a wrapper for an ItemStack[4]?
or what will T be
I guess custom item type
yeah
so a wrapper for a T[4]
could be
don't build abstractions for things that really don't need to be abstracted over
providing an overridable method for getting the armor contents that could be dynamically computed would be more than enough, I think
public interface MyCustomItem {
String getIdentifier();
}
public interface MyCustomItemProvider {
MyCustomItem provide(MyPlugin plugin, ConfigurationSection config);
}
public class MyItemRegistry {
private final Map<String, MyCustomItemProvider> providers = new ConcurrentHashMap<>();
private final MyPlugin plugin;
public MyItemRegistry(MyPlugin plugin) {
this.plugin = plugin;
registerDefaults();
}
public void register(String name, MyCustomItemProvider provider) {
this.providers.put(name, provider);
}
public MyCustomItem provide(String name, ConfigurationSection section) { // Hook this to where you scan your config
MyCustomItemProvider provider = this.providers.get(name);
if(provider == null) {
return null;
}
return provider.provide(this.plugin, section);
}
private void registerDefaults() {
register("hero-boots", MyHeroBoots::new);
register("hero-leggings", MyHeroLeggings::new);
}
}
🤔
yeah that's a good pattern if they're config dependent
That's how I usually do configurable custom items
I would sometimes do stupid shit to avoid needing to manually register them
declaration: package: redempt.redlib, class: RedLib
hacky
I used to work at a server that took that to the extreme and it wasn't fun to learn
you'd just pray for things to register themselves
it's a delicate system
And it'd add 100 hours of onboarding, development and management time to save ~5 seconds a couple times
All while hiding code flow and making sure you have no control over when things get registered or work
yeah I mean in all honesty it really wasn't worth it, but I did it because I would literally always forget to register my new classes and have to redeploy and reload twice
Our way to disable a command was just to comment out the entire class and pray it works
lol
I ended up building a lot of very broad and abstract tooling to optimize away basically every little slowdown, and that was one of them
I really just wanted to move as fast as possible and it did sometime cause me to cut corners
thing is those tools end up being a lot slower than just doing stuff manually
definitely not lol
An example is our ORM system
some of them saved me countless hours
We used reflections to serialize all player data and stick it in our database
just have to pick the right tools for the job and make sure they're capable of doing what you need
Which meant a solid 200 hours writing the system to be resilient
ouch
And another 2 hours for each project just adapting the data structure to work with the ORM
any reason to not use an existing one?
because the ORM really didn't like generics or interfaces
¯_(ツ)_/¯
What's orm
object relational mapping
shove an object in a database
a strategy for automatically converting objects into database rows
Like sure it's cool and works like magic
tbh I think you might as well use an object or document database if that's what you want
For my skyblock system I just took the abstraction approach
And made abstract classes for everything
sql is extremely rigid and seems largely incompatible with the "wave a magic wand" approach of ORM
How would you make an impl for an item tho, like let's say those hero items let you do +50% damage
I've come to really dislike OOP design
Its not
why
hi conclure
hello
it's very limiting
everything needs to be a strict hierarchy and there can be no exceptions to the rules you lay out
I mean traditional oop is goofy
a class is like 3 concepts rolleed into one
But if you modernize it, pretty decent stuff
- no sum type 🤮
https://hastebin.com/share/webikaweju.java
@ivory sleet what do u think of this
I still like OOP over (forgot what the other was)
functional?
Yes
imperative?
Functional
functional is nice but I feel like it's best interspersed with imperative
I don't know what imperative is
plain old "code code"
Object oriented
just write the code that does stuff, straight-up
Like js?
Imperative means we tell the machine what to do
instructions, function calls, statements
Or more like assembly?
assembly is one example of imperative code
as opposed to declarative (functional) where we rather describe things with expressions what will happen
I find functional amazing for smaller tasks
I find a mix to be the best
and algebraic type systems elegant for weaving everything together at larger scale
it's so simple and so powerful
Looks nice
Hm
It'd be interesting to make an abstract class to filter stuff
TBH at work we just made a listener for each custom item
And did the manual checks as it was like
5 lines
I designed an enchant system that was pretty cool
it let you abstractly define "triggers" and define behavior with them
might be a bit tough to reproduce fully tbh but I think it worked really well
this was a rewrite so ofc it was much nicer after that
so you got the PDC every time?
For each check
Pretty much
But anyway, traditional oop sucks, however if you take a little bit of lambda calculus, little bit of type theory, and little bit of data oriented programming it becomes nice
maybe I'm rly over thinking this
even if you don't want to go as deep into it as this does
You can just make methods to get an item from an event
legit the only character I've made is the flash 💀
you could do something similar
And I've been on this for a month
and a method to check if the item tag matches
The thing is tho
Boxbeam, how do you know my previous name to be conclure? Just curious :>
boxbeam is redempt silly
this one lets you declare "triggers" which can specify when an item is associated with any given event, and then you can register certain triggers to specific enchants with a handler that defines the behavior for that enchant
Oh
you could use a similar approach
don't have to copy the design outright, but the approach of triggers and handlers split up into specific items/matchers worked really well
Well that is subjective
Reminds me of the uh
You see
I mean look how simple it made it to create an enchantment in the end, you could basically just write "here's what it is, and here's what it does" in very simple terms
DRY is good, but all principles should not be taken literally, just try to get the idea of them and apply whats useful to u
I completely agree with you
public class TheFlashBoots implements CustomItem {
private final PermanentPotionEffectManager potionEffectManager;
public TheFlashBoots() {
this.potionEffectManager = new PermanentPotionEffectManager(CharacterWarPlugin.getInstance());
}
@Override
public @NotNull ItemStack getItem() {
return new CustomItemBuilder(Material.LEATHER_BOOTS, "the_flash_boots")
.setName("<yellow>The Flash's Boots")
.setLore("<gray>Grants <yellow>Speed V <gray>when equipped.")
.setColor(Color.YELLOW)
.build();
}
@Override
public void onArmorEquip(PlayerArmorChangeEvent event) {
this.potionEffectManager.applyEffectLoop(event.getPlayer().getUniqueId(), PotionEffectType.SPEED, 4);
}
@Override
public void onArmorUnEquip(PlayerArmorChangeEvent event) {
this.potionEffectManager.removeEffectLoop(event.getPlayer().getUniqueId(), PotionEffectType.SPEED);
}
@Override
public void onPlayerLeave(PlayerQuitEvent event) {
this.potionEffectManager.removeEffectLoop(event.getPlayer().getUniqueId(), PotionEffectType.SPEED);
}
}```
how are the events passed through?
listeners
that I inject a item repository into
and so it's basically I get the PDC once
so do you mean these are all like default methods that do nothing
I'd probably use the eventbus system I made for this
yeah
and when the associated event happens with this item
Sure it means manually registering stuff
it passes it through to the custom item class?
public interface CustomItemListener extends Listener {
default void onDamagedWhileWearing(EntityDamageEvent event) {}
default void onDamagedWhileHolding(EntityDamageEvent event) {}
default void onDamagedByPlayerWhileWearing(EntityDamageByEntityEvent event, DamageEventInfo info) {}
default void onDamagedByPlayerWhileHolding(EntityDamageByEntityEvent event, DamageEventInfo info) {}
default void onAttackPlayerWhileWearing(EntityDamageByEntityEvent event, DamageEventInfo info) {}
default void onAttackPlayerWhileHolding(EntityDamageByEntityEvent event, DamageEventInfo info) {}
default void onArmorEquip(PlayerArmorChangeEvent event) {}
default void onArmorUnEquip(PlayerArmorChangeEvent event) {}
/*** Not reference name specific.*/
default void onPlayerLeave(PlayerQuitEvent event) {}
default void onInteractWhileHolding(PlayerInteractEvent event) {}
}```
Wouldn't it better to pass Player instances to the onPlayerX methods?
ah...
Or if you want to be picky just a Map<Class<? extends Event>, Consumer<? extends Event>> getListeners()
but extending Listener, does that mean the events are being passed directly from the spigot event bus?
right, that's always the issue
that's the limitation of that approach
you have this special set of "supported triggers" carved out
@Override
public Map<Class<? extends Event>, Consumer<? extends Event>> getListeners() {
return Map.of(
PlayerJoinEvent.class, this::handlePlayerJoin,
PlayerQuitEvent.class, this::handlePlayerQuit
);
this is hideous 
which I am ok with tho
and if you want something special, you end up having to write the checks yourself
with this approach you can just write a custom trigger, then register things with that trigger
and how does that support every trigger?
because a trigger can react to anything, even custom events
sumn like this
all it does is register a listener to a specific kind of event and say "I can tell you the items 'associated' with this event"
that's it
Just add a void registerEvents(EventBus bus) method to your interface of use that constructor interface thing
and then the manager will look at those items, figure out what enchants are on it, see if any of those have triggers registered to the event, and call their handlers if they do
yeah but like
so all you need to do to make a trigger for something is be able to retrive the items and player from the event
How does the manager do that with an unsupported event
Basically you just adapt to bukkit's event bus
and use interfaces and listeners and maps rather than hardcoding your event types
For example, by using that EventBus util I referred
@Override
public void registerEvents(EventBus bus) {
bus.subscribe(EntityDamageByEntityEvent.class, this::handleEntityDamage);
}
type deal
Just have an event bus in your registry and call that method when your thing gets registered
it gets passed the event class
and it can then register a listener for that class
so yeah
EventListener is a helper class that registers listeners from lambdas
I have no idea what's happening
but lets say bucket releases a new event
like
PlayerDamagedByZombie (unrealistic)
how would you like
manage this new event
getEvents() returns a Map<Class<? extends Event>, Function<Event, EventItems>>
You have to manually add it, or well u could scan classes at runtime
yeah it knows the event classs at runtime
the trigger specifies it
and it maps it to a lambda that can take that event and get the EventItems from it, which is just a wrapper for any items used or changed in the event
which also captures the player
bruh
so then it can register a new listener to that event class
yeah I'm clueless rn
lol
Top notch configuration
they're probably both turing complete
Bro I used to think hypixel was running a bunch of command blocks
and ATMs are run by tiny men who hand out the money
💀
Are you telling me the aren’t!
@waxen plinth so when should I use abstract classes
because I originally had an abstract class for the CustomCharacter class
Got yelled at
So I turned it into a regular class
CustomCharacter does not sound like it should be a regular class
what would an instantiation of that base class represent?
A custom character
lol
Hold data
why do i get this error
Caused by: java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: ./world/stats/?4?lOfficer.json at sun.nio.fs.UnixPath.encode(UnixPath.java:121) ~[?:?]
This error occurs when i use § colouring ONLY on my real server. When im using gradle run server task the error does not occur
you are setting the gameprofile name to have invalid characters, the section char in this case
also offline mode
im using offline mode, and gameprofile names are allowed to have colourcodes no? why would it only error on my real server not gradle run task if thats the case
🤷 idk why its only happening sometimes, but that is what is causing that exception
people usually change the gameprofile name that is sent to clients, not the actual one stored on the server if you are wanting to add legacy color codes to it
arent gameprofiles already pretty much client side? since im not really telling the server that a gameprofile/player exists
no. each player has a gameprofile on the server
you can try just deleting that file and see what happens
org.bukkit.plugin.InvalidDescriptionException: Plugin description file is empty or not properly structured. Is nullbut should be a map.
main: com.therobokedi.main
name: testplugin
version: 0.0.1
author: TheROBOKEDi
commands:
testcmd:
description: test command
default: true```
no such file (world/stats/...officer) exists its all uuids, and i create a random uuid each creation of the gameprofile
oh wait, show the whole stacktrace
its probably erroring just trying to create the Path object to see if the file exists
is there a place for where i can see all the deprecated functions and what to use instead?
i need it for this:
Player player = event.getPlayer();
player.getItemInHand();
'getItemInHand()' is deprecated
For newer versions it is either main hand or offhand
Is there a way to cancel a knockback impulse without cancelling existing velocity? If I just set their velocity to vector 000 then his movement from before getting hit is gone as well
i cannot use .getType() with that
player.getInventory().getItemInMainHand() i think
I think that there is a knokback event you could try canceling that
EntityKnockBackByEntityEvent, event#getAccelaration and then just substract the vector to the player's one :)
or just cancel it
Oh awesome thanks!
remember to check if the entities are players too, unless you want to cancel all the knockback on the server
It's paper only 😭
Oh there has to be a spigot one too
You made me think, I can probably just get player's velocity in the damage event, and then subtract the difference 1 tick later when his knockback gets applied
Because Right now I am doing this Bukkit.getScheduler().runTaskLater(main, () -> victim.setVelocity(new Vector()), 0); I think I wouldnt need to change it much
That would work
I will try it
Yeah I don't think it exists for spigot :(
I guess either paper or the damageevent method
why are there somany functions that do the same thing....
i dont know
the one i told you works fine for me everytime
what event exists in bukkit api when triggering a tag name change in anvil
Old api and retaining compat, eg player.getItemInHand is from when you only had one hand but now you have 2 so its deprecated and tells you to use new api and the old method still exists so older plugins dont break
makes scence but can they not make like a forum post of what to use instead?
Is there an event being called for when a player's shield is broken?
No, i mean when hit by an axe
have you looked to see if PlayerItemBreakEvent fires when the shield breaks?
um, probably difficult as your plugin is instanced by Spigot
well im not making a spigot plugin :P
by the time any shutdown hook fires your plugin will already have been disposed of
its a discord bot in java
I don't think the framework im using interferes with how shutdown hooks work, so this is a general java question
I have an idea
not sure how large your cache of data is
however you could make use of memory mapped files to store it for the next start up. Memory mapped files are separate memory space from the java process and if something happens the OS ensures it gets saved 🙂
in this manner you don't have to worry about holding up a shutdown
as well as if it just shutsdown unexpectedly
how do i check if the mob spawn location is safe before spawning the mob
what if the programs shuts down before the periodic save?
Periodic plus shutdown hook 👌🏻
i thought of that
but it still doesnt gurantee
it pretty much does
anyone
Depends on what you define as safe
like mob wont suffocate
Check if blocks are at their location 🙂
im getting this error in my project, i recently switched pc's so the path to my project changed
every time i reload maven i get this error: (im trying to use nms 1.20.2)
Try to run Maven import with -U flag (force update snapshots)
i tried following the link and searched for org/spigotmc/spigot, but the only version contained in spigot was 1.8.8
here's my full pom.xml, apparently the spigot dependency is the error:
https://pastebin.com/PuHcFGM7
You need to run BuildTools for this version locally because patched NMS cant be openly distributed via repos as it would be against Mojangs TOS.
This means you need to assemble it yourself by running Buildtools.
Also running paper-api + nms spigot is wild...
Either use spigots nms approach or papers. But dont mix them.
yeah ^ they are very different
i believe they are quite the same
also NMS worked perfectly a few days ago (with paper), the error only appeared after I switched pc's
which one
Whichever one you specify
nah like where does it get it
From mojang
^^
is there an event for when a player throws a trident
:(
That is literally years behind and has no idea about the current api
Chatgpt is 2022 and 1.13 was released in 2018
This is garbage
Rip
is there an event tho?
You can backtrack the ProjectileLaunchEvent for example
But depends on your purpose
you do realize you can just use the search function in the javadocs?
?jd
yes i could find anything
?jd-s
i want to set the tridents velocity
the way you search the events is you look in the package called events
this lets you see all events that are possible
okay
Location blockLocation = block.getLocation();
Material material = block.getType();```
i have a 3x3 of green wool between those 2 points, and the material is returning LEGACY_WOOL, why is it not GREEN_WOOL
You didnt specify an api version in your plugin.yml
ah k thanks
Hey btw I ended up finding that there is attribute generic knockback resistance that I can change on my player, which works perfectly for me!
oh nice, didnt know about this one
i get an error at the end of building
https://pastebin.com/pDCqmnz7
Run BuildTools
whats not working here?
import java.awt.Point;
import java.util.Scanner;
public class Snake {
public static void main(String[] args) {
Point spielerposition = new Point(10, 9);
Point schlangePosition = new Point(30, 2);
Point goldPosition = new Point(6, 6);
Point tuerPosition = new Point(2, 5);
boolean weiter = true;
while (weiter) {
for (int y = 0; y < 10; y++) {
for (int x = 0; x < 40; x++) {
Point p = new Point(x, y);
if (p.equals(spielerposition))
System.out.print("P");
else if (p.equals(schlangePosition))
System.out.print("S");
else if (p.equals(goldPosition))
System.out.print("G");
else if (p.equals(tuerPosition))
System.out.print("T");
else
System.out.print(".");
}
System.out.println();
}
bewegespieler(spielerposition);
bewegeSchlange(schlangePosition, spielerposition);
}
}
private static void bewegeSchlange(Point schlangePosition, Point spielerposition) {
if (spielerposition.x < schlangePosition.x)
schlangePosition.x--;
else if (spielerposition.x > schlangePosition.x) {
schlangePosition.x++;
if (spielerposition.x < schlangePosition.x)
schlangePosition.x--;
else if (spielerposition.x > schlangePosition.x) {
schlangePosition.x++;
}
}
private static void bewegespieler (Point spielerposition) {
Scanner scan = new Scanner(System.in);
String input = scan.next();
if (input.equals("w")) {
if (spielerposition.y > 0)
spielerposition.y--;
} else if (input.equals("s")) {
if (spielerposition.y < 9)
spielerposition.y++;
} else if (input.equals("a")) {
if (spielerposition.x > 0)
spielerposition.x--;
} else if (input.equals("d")) {
if (spielerposition.x < 39)
spielerposition.x++;
}
}
}
}```
bewegespieler method is not working
well this isnt a normal java help server
i tought some1 can help anyways
What are you expecting to happen and what is not working
do a while(scan.hasNext()) before scan.next()
ok
while (weiter) { and not sure what's this for
if you're using this while() then just do an if()
how to learn makng plugins?
org.bukkit.plugin.InvalidDescriptionException: Plugin description file is empty or not properly structured. Is nullbut should be a map.
main: com.therobokedi.main
name: testplugin
version: 0.0.1
author: TheROBOKEDi
commands:
testcmd:
description: test command
default: true```
what is OOP?
okey
I'm making Minecraft Spigot Plugin, and I have a question about event priorities. I made a plug-in that pays coins at a certain probability when destroying blocks, but I use it with a plug-in called WorldGuard, so when you destroy a block in a protected area by WorldGuard, the block is not destroyed, only coins are given and copied. Is there a way to solve this? Below is the code of the plug-in I made.
package io.github.lucystudio.drop.event
import io.github.lucystudio.drop.Main
import org.bukkit.Material
import org.bukkit.block.Block
import org.bukkit.event.EventHandler
import org.bukkit.event.EventPriority
import org.bukkit.event.Listener
import org.bukkit.event.block.BlockBreakEvent
import org.bukkit.inventory.ItemStack
import java.util.Random
class OnBreak: Listener {
private fun hasItemDropped(block: Block): Boolean {
val drops = block.drops
return drops.isNotEmpty()
}
@EventHandler(priority = EventPriority.MONITOR)
fun onBreak(event: BlockBreakEvent) {
if (Main.instance.config.getBoolean("enabled")) {
val block = event.block
val isFullyGrown = block.blockData.asString.contains("age=7")
if (block.type == Material.WHEAT || block.type == Material.CARROTS || block.type == Material.POTATOES) {
if (isFullyGrown && hasItemDropped(block)) {
var random: Random?
random = Random()
random.setSeed(System.currentTimeMillis())
var randomNumber: Int = random.nextInt(100)
// println(randomNumber)
// println(Main.instance.config.getInt("percent"))
if (randomNumber < Main.instance.config.getInt("percent")) {
val item = Main.instance.config.getItemStack("item") ?: ItemStack(Material.DIAMOND, 1)
event.player.inventory.addItem(item)
if (Main.instance.config.getString("messages.get_coin") != "false") {
event.player.sendMessage(Main.instance.config.getString("messages.prefix").toString() + " " + Main.instance.config.getString("messages.get_coin"))
}
}
}
} else if (block.type == Material.BEETROOTS) {
val isFullyGrownThree = block.blockData.asString.contains("age=3")
if (isFullyGrownThree && hasItemDropped(block)) {
val random = Random()
val randomNumber = random.nextInt(100)
if (randomNumber < Main.instance.config.getInt("percent")) {
val item = Main.instance.config.getItemStack("item") ?: ItemStack(Material.DIAMOND, 1)
event.player.inventory.addItem(item)
if (Main.instance.config.getString("messages.get_coin") != "false") {
event.player.sendMessage(Main.instance.config.getString("messages.prefix").toString() + " " + Main.instance.config.getString("messages.get_coin"))
}
}
}
}
}
}
}
result is valid yml
P.S. I using Lands Plugin too, This is also similar to World Guard.
List<String> materialList = config.getStringList("noAlertMaterials");
// Convert the list of material names to an array of Material objects
GriefAlert3.nonAlertBlocks = new Material[materialList.size()];
for (int i = 0; i < materialList.size(); i++) {
GriefAlert3.nonAlertBlocks[i] = Material.matchMaterial(materialList.get(i));
}
List<String> placementAlertMaterialList = config.getStringList("placementAlerts");
// Convert the list of material names to an array of Material objects
GriefAlert3.placementAlertBlocks = new Material[placementAlertMaterialList.size()];
for (int i = 0; i < placementAlertMaterialList.size(); i++) { // Fix here
GriefAlert3.placementAlertBlocks[i] = Material.matchMaterial(placementAlertMaterialList.get(i));
}
}``` For some reason the materialList always gives a nullpointerexception, despite it being in the config.yml
We’d need to see the yml
- ACACIA_SAPLING
- BIRCH_SAPLING
- DARK_OAK_SAPLING
- JUNGLE_SAPLING
- OAK_SAPLING
- SPRUCE_SAPLING
- ACACIA_LEAVES
- BIRCH_LEAVES
- DARK_OAK_LEAVES
- JUNGLE_LEAVES
- OAK_LEAVES
- SPRUCE_LEAVES
- GRASS
- DIRT
- MYCELIUM
- PODZOL
- COARSE_DIRT
- TALL_GRASS
- FERN
- DANDELION
- POPPY
- BLUE_ORCHID
- ALLIUM
- AZURE_BLUET
- RED_TULIP
- ORANGE_TULIP
- WHITE_TULIP
- PINK_TULIP
- OXEYE_DAISY
- SUNFLOWER
- LILAC
- ROSE_BUSH
- PEONY
- MELON
- PUMPKIN
- VINE
- WATER_LILY
- WHEAT
- CARROTS
- POTATOES
- BEETROOTS
- MELON_STEM
- PUMPKIN_STEM
- NETHER_WART
- COCOA
- SUGAR_CANE
- BAMBOO```
Interestingly it works when the server starts
But not when the config is reloaded
private final GriefAlert3 plugin;
// Constructor that takes the main plugin instance as a parameter
public ReloadCommand(GriefAlert3 plugin) {
// Use the plugin instance to get the configuration
this.plugin = plugin;
config = plugin.getConfig();
// Now you can use this.config to access the configuration
}```
Check inside hour jar @hoary spire
How are you reloading it?
ReloadCommand.reloadConfig(); it is static
heres the full class
you never actually reload the config... also why is it static
hey I clicked some exclude option in intellij ide by accident for player object, how can i get it back?
is there a way to get mob size
So I can access it in a different class
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
^^
declaration: package: org.bukkit.entity, interface: Entity
thanks, found it xD
thanks
well is there a way tho to check if a spawn is a safe location
No reason for it to be static
How could I run the reloadConfig() method in a seperate class then?
Hello! I have a problem with ProtocolLib. I'm trying to add a fake player to the tab list and then add it to a scoreboard team.
My issue is, that I cannot add it to a team. The team exists, I also checked for outgoing packets, that are sent by the server, and the format looks exactly the same.
I'm using MC 1.19.4 and the latest version of ProtocolLib.
ProtocolManager protocolManager = Main.getManager();
PacketContainer playerInfoPacket = protocolManager.createPacket(PacketType.Play.Server.PLAYER_INFO);
playerInfoPacket.getPlayerInfoActions().write(0, EnumSet.of(
EnumWrappers.PlayerInfoAction.ADD_PLAYER,
EnumWrappers.PlayerInfoAction.UPDATE_LISTED,
EnumWrappers.PlayerInfoAction.UPDATE_DISPLAY_NAME,
EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE,
EnumWrappers.PlayerInfoAction.UPDATE_LATENCY
));
playerInfoPacket.getPlayerInfoDataLists().write(1, List.of(
new PlayerInfoData(
new WrappedGameProfile(UUID.randomUUID(), FRENSOR),
0,
EnumWrappers.NativeGameMode.CREATIVE,
WrappedChatComponent.fromText(FRENSOR)
)
));
protocolManager.sendServerPacket(player, playerInfoPacket);
PacketContainer teamUpdatePacket = protocolManager.createPacket(PacketType.Play.Server.SCOREBOARD_TEAM);
teamUpdatePacket.getModifier().write(0, 3);
teamUpdatePacket.getModifier().write(1, "1mod");
teamUpdatePacket.getModifier().write(2, List.of(FRENSOR));
teamUpdatePacket.getModifier().write(3, Optional.empty());
protocolManager.sendServerPacket(player, teamUpdatePacket);
I'm not receiving any errors.
?learnjava, then learn spigot api
How can i fix this JanTuck? Do you know?
?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.
What is the best way to save persistent data? (In my case a few HashMaps which contain custom objects)
Depends on what you are doing I'd say
I just said, few hashmaps with custom objects
that doest say that much
Well, are you trying to save it into some entity? Is it some data you need globally on the whole server?
Globally on the server. It's an alert system for staff thats tied to an index
what index
anyone knows fix?
in plugin.yml xd
After build, plugin.yml is empty (in jar)
I think I'll use SQLite maybe, I'll learn it
make sure you placed your plugin.yml in the correct folder and saved it before building the project
im sure
src/main/resources/plugin.yml
If its tied to the index, why use HashMap?
Integer, Object
Why not just List
yea so why not a list
Anyone any ideas?
Any plugin that fixes shulker box exploits?
Staying up to date and using Paper will fix exploits
anyways this is the wrong place to ask
use #help-server
How can I sort players in the player list by their rank? For example 1. Owner, 2. Supporter, 3. Normal Player. I tried using teams but it is still being sorted alphabetically
it returns null and causes an exception, what do i do?
It would be helpful if you provide a little bit more context
Stack trace?
why is player#dropItem() a bool?
How to learn spigotapi
?jd
:( why
Returns:
True if item was dropped successfully
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous usernames, global display names, and server...
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
?commands
how do i find a surface for mobs to spawn in (getHighestBlock doesn't seem to be feasible as it can cause mobs to spawn on rooftops)
Hello everyone, Is there a way to know :
- when a falling block entity is killed (for exmple sand on a torch) ?
- or that an item spawned is from a falling block that has been destroyed ?
You can try the EntityDeathEvent or EntityDropItemEvent
JanTuck
How can i fix this? Please help
What are some examples of plugins that use XMaterial for materialID support?
virtually all of them that support versions below 1.13 as well as above 1.13
Have any specific example that is reasonably well coded?
not sure what ur asking. ur tryna find out how XMaterial works?
Not really, I just want to see something to use as a reference integration.
(I recall we had trouble integrating it for some reason or another in the past; want to see how someone else has done it before trying again)
well there is really not alot to it
i assume you would use this with a config
you get an xmaterial like you would with any enum. using valueof
then to get the Material, call parseMaterial
thats pretty much it
^
Mine doesn’t use it
Thank you
JanTuck
you can help me please?
if (!plugin.getDataFolder().exists()) plugin.getDataFolder().mkdir()
thx
Forgot semi
also i get this exception:
java.lang.IllegalArgumentException: Unsupported class file major version 65
?
in pom.xml?
yeah
what? the spigot dep?
Nope <build> <plugins> ... </plugins> </build>
Hello does someone has the Java Doc of spigot 1.20.0 to 1.20.4 ? Thanks in advance !
Downgrade version for compilation or use new version to run it
source/target version
alr thx
?jd-s
Thanks, but I need the previous version of the Java Doc, not the current
they're all the same except added methods
Between these version there was some new features like the TrialSpawner that doesn't exist in Spigot 1.20.0 to 1.20.3
old docs arent hosted anywhere offical by spigot and helpchat dont seem to have them so the best you have is checking dates, updating or running buildtools with the --generate-docs flag and check the jars
EpicEbic
thats my name
Okay, thank you
Whenever I build my plugin, plugin.yml is empty
(in jar)
does it have content in ur ide
?paste your pom
ok
src/main/resources is definatelky the location of the plugin.yml you checked is not empty in your project?
yea
Me can send it in dm?
I don't do dms
Just verify
im verified but me cant send file
type !verify <yournickonspigotforum>
leave and rejoin
or ^if truly verified
Hello , after day's of thinking idecided to use mongodb to store cosmetics data , kits data , and after that i can use it on all servers connected to mongodb
but i get a bug ..
this is the loadOrSave method :
uh, plugin.txt ?
show how ur compiling
ok, close everything you have open which could be messing with yoru build. close all zip programs, text editors
run mvn clean package
$ mvn install
Ok
It is being built now. This is the first time I've had this problem. It's weird.
How do you shade something on gradle?
its generated true 💀
You use the Shadow plugin
gradle shadow plugin
shadowJar
okay let me see if i can figure it out now! thanks!
Sorry, im (semi) new to java, and the intelij IDE. how do i change the version of gradle I want a project to use?
I need to go from 7.3.3 to 8.x.x
there is this folder
its called gradlew I think or just gradle
u go in the properties file in that folder and change the version
gradle-wrapper.properties?
I dont think i have gradle in my bin
You can use gradlew
how do i actually send worldguard checks? (I have little to no idea what im doing)
private void veinMine(Block originBlock, Material material, Player player, int lvl, ItemStack itemStack) {
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
Queue<Block> blocksToCheck = new LinkedList<>();
Set<Block> visitedBlocks = new HashSet<>();
int maxSpreading = lvl * 8;
blocksToCheck.add(originBlock);
visitedBlocks.add(originBlock);
boolean creativeMode = player.getGameMode() == GameMode.CREATIVE;
while ((!blocksToCheck.isEmpty()) &&
(creativeMode || (itemStack.getDurability() < itemStack.getType().getMaxDurability() && maxSpreading > 0))) {
Block currentBlock = blocksToCheck.poll();
if (!creativeMode) {
itemStack.setDurability((short) (itemStack.getDurability() + 1));
maxSpreading--;
}
if (currentBlock.getType() == originBlock.getType()) {
for (Block relativeBlock : getAdjacentBlocks(currentBlock, lvl)) {
if (!visitedBlocks.contains(relativeBlock) && relativeBlock.getType() == material) {
visitedBlocks.add(relativeBlock);
if (query.testState(BukkitAdapter.adapt(relativeBlock.getLocation()), WorldGuardPlugin.inst().wrapPlayer(player), Flags.BUILD)) {
relativeBlock.breakNaturally();
}
blocksToCheck.add(relativeBlock);
}
}
}
}
}
Ye
your project should have a gradlew
Every gradle project should contain a gradlew and gradlew.bat file
if not you need to run gradle init
it should exist enough to run that from intellij
so just ./gradlew wrapper --gradle-version 8.5 --distribution-type all
assuming cwd is project
in the project dir?
yes
is it using powershell or cmd
gradlew.bat should work iirc
remove ./
I did
Yeah its pretty dumb
well in worst case just change the props file
8.5
alright
yeah this doesn't update the gradlew files, but it does usually work
Yeah sadly it doesn’t update those
do you use intellij?
yeah
on the right side of your screen should be a gradle tab
open that
open the project, go into tasks then setup
well build setup
then double click init
?paste the error
[13:44:25 ERROR]: Error occurred while enabling RPG v0.0.1-SNAPSHOT (Is it up to date?)
java.lang.NoClassDefFoundError: com/mongodb/client/MongoClients
at me.tls.rpg.common.RPG.onEnable(RPG.java:22) ~[RPG-0.0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:281) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:190) ~[paper-1.20.4.jar:git-Paper-330]
at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:104) ~[paper-1.20.4.jar:git-Paper-330]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:507) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_20_R3.CraftServer.enablePlugin(CraftServer.java:637) ~[paper-1.20.4.jar:git-Paper-330]
at org.bukkit.craftbukkit.v1_20_R3.CraftServer.enablePlugins(CraftServer.java:548) ~[paper-1.20.4.jar:git-Paper-330]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:274) ~[paper-1.20.4.jar:git-Paper-330]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1132) ~[paper-1.20.4.jar:git-Paper-330]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:321) ~[paper-1.20.4.jar:git-Paper-330]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.ClassNotFoundException: com.mongodb.client.MongoClients
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:197) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:164) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[?:?]
... 11 more
open the link, paste, save then send but now send ur build.gradle
I mean u need to just shade that
And well… relocate probably:>
plugins {
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'java'
}
group = 'me.tls'
version = '0.0.1-SNAPSHOT'
repositories {
mavenCentral()
maven {
name = "papermc-repo"
url = "https://repo.papermc.io/repository/maven-public/"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/groups/public/"
}
}
jar {
destinationDirectory.set(file("$rootDir/../../Servers/Paper-1.20/plugins"))
}
dependencies {
compileOnly "io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT"
compileOnly 'org.mongodb:mongodb-driver-sync:4.9.0'
// Implement later ????
compileOnly 'redis.clients:jedis:5.0.0'
}
def targetJavaVersion = 17
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
}
tasks.withType(JavaCompile).configureEach {
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release = targetJavaVersion
}
}
processResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
}
Or that yea
I'm not sure if i am being stupid or something, but what im trying to do is make a plugin which when you leave the server, it spawns a zombie, saying "offline" and when you join, it kills the zombie, However when the player leaves the server, it works fine, the zombie spawns, but when they join, the zombie does not die? does can anyone help me, here is my code:
//Player join snippet
@EventHandler
public void playerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
Entity ent = linkedPlayer.get(player);
deleteNPC(ent);
}
//spawn NPC snippet
public void spawnNPC(Player player, Location location) {
Entity npc = Bukkit.getWorld(player.getWorld().getName()).spawnEntity(location,EntityType.ZOMBIE);
npc.setMetadata("CustomNPC",new FixedMetadataValue(plugin,player));
Zombie zombieNPC = (Zombie) npc;
zombieNPC.setAI(false);
zombieNPC.setCustomName(ChatColor.translateAlternateColorCodes('&',"&7&lOffline &r&7"+player.getName()));
zombieNPC.setCustomNameVisible(true);
linkedPlayer.put(player.getName(),npc);
linkedPlayer_flip.put(npc,player.getName());
}
//Leave snippet
@EventHandler
public void playerLeave(PlayerQuitEvent event) {
Player player = event.getPlayer();
Location location = player.getLocation();
ItemStack[] playerInventoryContents = player.getInventory().getContents();
inventoryHashMap.put(player.getName(), playerInventoryContents);
linkedPlayer.remove(player.getName());
linkedPlayer_flip.remove(linkedPlayer.get(player.getName()));
spawnNPC(player, location);
}
//Delete NPC Snippet
public void deleteNPC(Entity ent) {
if(ent.hasMetadata("CustomNPC")){
if(ent instanceof Zombie){
Zombie ZombieNPC = (Zombie) ent;
ZombieNPC.setHealth(0.0);
}
}
}
?paste for big blocks pls
Oop my bad
Both of you
this should be implementation "org.mongo...."
Yeah for things you want to shade change it to implementation
I'm not sure if i am being stupid or something, but what im trying to do is make a plugin which when you leave the server, it spawns a zombie, saying "offline" and when you join, it kills the zombie, However when the player leaves the server, it works fine, the zombie spawns, but when they join, the zombie does not die? does can anyone help me, here is my code:
https://paste.md-5.net/judizoyude.cs
ok now let me try
Try zombie.remove
ill try that one second
still the same error
How are you building your project?
Just gradlew build?
Yeah i think
Run the shadowJar task instead
more axolotl smp comissions
Same thing happend, However, i bug checked it, and for some reason in the HashMap "linkedPlayer", it says that the NPC is null?
I've been with them for like a year what do you expect
idk
spot the problem
lead dev too
i want to check if the uuid is null in the database, but it throws an exception
goddamn it's a busy day today
Whats the problem?
Show full class
Hey ! i have this plugin that can use to generate a world
First, the world is created as an only roofed forest, but there are huge patches of water, any way to prevent that?
the database one?
what would be something like a HashMap but it can have multiple return values? Like HashMap x list, in my case I insert a username and I want to get returned a list of specific numbers that I can add
Spot the difference
Map<MyKey, List<MyValue>> ??
I'd make a wrapper class for the list though
hmm how could I add a value to that hashmap
map.computeIfAbsent(key, (irrelevant) -> new ArrayList<>()).add(...)
OK IT WORKS NOW
thanks
also how can i change it to build the jar right to my plugins folder?
ahh alr, what other way should i do it then?
There is also MultiMap, not sure if it's included with spigot tho
Preferences -> Artifacts
Build -> All Artifcats
Well
You're passing the player onJoin
and passing the player name onQuit
Just think about what you're doing for a second
even using the shadowJar?
Pretty much
There is a way to set a build dir on shadowjar but it was annoying iirc
The thing is, is when i sick the event to be a gamemode event, it works fine, but as soon as its a playerjoinevent it does not work
Read my message and think about it
shadowJar {
archiveBaseName.set('shadow')
archiveClassifier.set('')
archiveVersion.set('')
}
just this?
please help isOnGround is not working as expected [18:47:19 INFO]: [SumeruRTP] 222
[18:47:19 INFO]: [SumeruRTP] 333 the code first teleports and then checks if the player is on the surface, but it returns true even though I have already taken off. I need that when a player falls to the surface, he is deprived of a bow that helps him land, but the bow disappears immediately as soon as the player prescribes / rtp and falls from the sky. I'm making an rtp plugin and I want the /rtp command to display a menu with a choice of two teleportation methods. the usual one and the other one with which the problem arose. The expected behavior of 2 ways of teleportation (clicking on the golden block) is that the player will be teleported high in the sky and will fall, it is desirable that he looks down and falls more slowly and is given a bow for teleportation (I have already done this) and as soon as the player falls and is on the surface, remove this bow from his inventor code: https://pastebin.com/UzVj5K2K
p much
perfect thank you
do i delete them 2 lines then?
learnjava moment
It is :)
I'd restructure this code, it's kinda unreadable
responsibleAlerts.computeIfAbsent(player.getName(), (irrelevant) -> new ArrayList<>()).add(alerts.size() - 1);
How I understand, is this will add a new integer alerts.size()-1 in my case, to the list assosiated with the hashmap? And if it doesnt exist yet it will make a new one
Ok
Yep
I could give you the whole code, but you don't seem to want to read the terrible unreadable code.
how am i passing it through the player join? i'm only getting the data, not writing it 😕
supplyIfAbsent when?
What would that do? lol
You're passing your player on the get method of HashMap
Use a supplier rather than a function
can you tell for 1.16.5 a good way to check if a player is falling or not if he is on the surface
even though the key generic type is a String
there is putIfAbsent iirc
Get the player's hitbox and raycast stuff
LOLOLOLOL
but yeah supplyIfAbsent could be nice to lazily populate
Yeah but you're making a new object regardless
Sorry i have been staring at the same piece of code for about an hour lol
Unless you put a shared collection but that'd be immutable
is there an example of this?
Yoo tysm it works now xD
I swear projects keep disappearing from my Open Recent tab
Essentially
map.supplyIfAbsent(key, ArrayList::new).add(0)
rather than
map.computeIfAbsent(key, k -> new ArrayList<>()).add(0)
Look at all those saved bytes
so me and my friend are wanting to code a spigot plugin for 1.20.4 for making custom gui menus but dont know where to start does anyone have any tips tricks or videos they can send to help us learn
Anyone has any idea how to generate a waterless world
look up how to make custom gui in minecraft java on youtube
Yeah coll its not too dumb of an idea, looks beneficial if you have some heavy resource object
do not use yt tuts some of them show a way taht you shouldnt use
like comparing titles and stuff
isOnGround()
This value is controlled only by the client and is therefore unreliable and vulnerable to spoofing and/or desync depending on the context/time which it is accessed javadocs is there really no other method?
i tried it just comes up with plugins others have made we want tomake our own
I thought he meant like, design wise
with a resource pack
no he wants api i think to create modern gui's
?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.
his request has nothing to do with java bro
"Yeah coll its not too dumb of an idea"
Dang that's the nicest thing Conclure has ever said to me
:p
BoundingBox box = player.getBoundingBox();
Location picked = ...;
Vector direction = new Vector(0, -1, 0);
RayTraceResult result = box.rayTrace(picked.toVector(), direction, direction.length());
if(result == null) {
// unsafe
return;
}
Block hitBlock = result.getHitBlock();
...
thank you for asking for help and then telling everyone else to learn java
Lol??
shpould have probably asked if he did first sorry
ok
btw your issue is that your rs.getString(1) returns null
Lol, when have I not been nice to Coll1234567 :3
i think i gotta stop with all this project structure stuff
lmao
theres 2 things, over optimization and planning for the future
i dont call in other plugin and it work
i know some javascript im more of command block coding been doing that for 7 years just started learning data packs and plug in this year
my database is empty
javascript will not help in java
Do null checks and stuff
nor will datapcks or command blocks
i know
If there is no entry getString will obviously return null 
its a diffrent type of coding
We should start opening threads for issues there are always like 2-3 people needing help
how do i handle it
return a null profile or create one on the spot
i can try and help in dms if u want
yes plz im so confused lol
alr bet
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
If only we had a forums channel
choco says no
Choco eats glue
@worldly ingot stop having a gf and get in here we should get to trial a forum channel for like month and see how it goes
Anyone has any idea how to generate a waterless world please? ive tried everything
Mm I'd recommend getting a bit more experienced before trying to help people out
Imo forums on discord are for some reason unorganised af
Custom generator
They are
I'd still recommend opening a thread if there are multiple people asking for help
Just to make communication easier
it's annoying having to juggle between like 3 people and making sure everyone understands what message is directed to who
i already have a custom generation biome
a forum channel would make it more obvious to see new threads
bc you like just dont notice them
ever
Yeah would be so nice if they added one here
help-development-thread when
Biomes don't control the terrain that much anymore, therefor if the terrain goes below sea level it will still be filled with water
conclube can you actually pin the start of my good habits message instead of the middle of it
I'd rather people see the basics first
wait did I pin the wrong one?
and how can i modify that?
you pinned like the middle of it
Im such a troll lol
in think theres like 4 messages
lol
You can change terrain height with a datapack
Or you can write an entire custom generator 👀
Or try a plugin like Terra
Isnt there just a method i can cange like it does with the generation of biomes?
don't think so
I think data packs might be able to make tweaks instead of needing to rewrite everything
You can unpin the second one
Did it alr
there's a short list of capabilities that always felt missing from spigot
worldgen tweaks was one
don't think you did
but i really dont want to use any generation type datapack
Wait I pinned multiple middle parts
I don't think plugins can directly change the biome distribution
there's literally just 1 start and end
What the fuck was I on when pinning those
worldgen is bread
that looks like a good pin
lots of good style advice
is this gonna be pinned backwards
though I do disagree with the variable names one
so, if i want a waterless world, i need to use an other datapack/plugin?
events called e and players called p is fine imo
Ugh idk, discord on phone is laggy
for extremely obvious, common types I really do not mind abbreviating
That's certainly the easiest way
because p just means "the player"
not everywhere
whats the not easiest way
just like how n is often used for "a number"
it can also mean packet
The name of variables should be proportional to the size of the scope, is the standard nowadays iirc
Or pufferfish
ok then I'd always type out packet and only abbreviate player
or potato
rewrite the world generator
int x, y, z, i and n can be fine
or well, what’ve been taught enterprise wise
yeah I'll agree with that
I'd still use x, y, z, index and number
I usually use e in my event handlers and p in lambdas that take players
That's a you problem
Yeah totally fine
e in event handlers is one I will never change because you reference the event so many times in the handler
Well, not really
but in command methods I always do Player sender or CommandSender sender
You reference it at the top when getting all the variables you need
I don't make variables to hold fields of the event
so.. your naming is inconsistent
I just make repeated get calls, usually
Id say for smaller event handler methods, using e can be fine
yeah that's a problem
..why?
But larger ones, event is prob better
the type of the sender depends on if it's a player-only command or not
I will always defend event e and single-letter lambda parameters, but everywhere else I tend to type out the full name
This can cause problems as certain get calls return a new object every time
Yeah that might be applicable for events but for data belonging to players or inventories, no
if I reference a value like 3+ times I'll probably pull it out, but for 2-3 I often just make another get call

**Conclube **pinned a message