#help-development
1 messages · Page 2135 of 1
nope, not in a normal for loop
Pretty sure it does
only in "enhanced" for loops
Really? Interesting.
yeah it makes total sense
you cannot access the "n"th element in a set
the normal for loop works like this:
you say "for int i = 0; i < size; i++" so it checks the size: it's now let's say, 2, so it executes your statement
you add something, now it calls "list.size()" again, now it's 3
etc
no problem, and no concurrent modification
just an infinite loop
im not sure what you're doing here, but what i'll do is to save lore.size() inside a variable int size = lore.size(); and use that variable inside for loop and i'll see if that fixes your problems
Yeah that makes sense
Well it's infinite because he's calling lore.add() everytime because the string that's being added doesn't start with a space
It starts with a color
So it's just infinitely adding that Nightmare Infused line
to insert a line at a certain point, you can just use List#add(int,T)
e.g. to add a line between line 2 and 3, you can do lore.add(2,"my new line between line 2 and 3");
how do i check if an inventory is an AnvilInventory
instanceof?
I used this and it returned false
event.getClickedInventory() instanceof AnvilInventory
will this work? player.getOpenInventory().getTopInventory().getType().equals(InventoryType.ANVIL
Okay so we're trying to store the data of a container inside an array however whenever we check for if the block is an instanceof a container, it doesn't detect any containers. This is the code for the check:
if(loc.getBlock() instanceof Container) {
blocks.add(((Container) loc.getBlock()).getInventory());
}```
Does anyone know why this doesn't work?
P.S. blocks is an ArrayList of Inventories
?
not the block itself
This: loc.getBlock().getState()
i guess ye
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Server.html#createWorldBorder()
is this persistent?
declaration: package: org.bukkit, interface: Server
If I want to prevent vanilla crafts from using "custom" items (with, let's say a special PDC or something), do I have to check everytime a click happens in a crafting table and adjust accordingly, or do vanilla crafts not accept items with lore or such?
Ok thanks
is there boss bar api in spigot ?
Vanilla crafting tends to completely ignore any added nbt of an ingredient
But cancelling the prepare item craft event if an ingredient has that particular PDC will work
There is
could u point me where to look because all I get those out dated bossbars api plugins
thanks
how do you make the elder guardian "jumpscare" effect
Play the MOB_APPEARANCE particle for them
I'm trying to learn how to display the scoreboard text on the middle right of the screen
Is it per-player, or do I set it to the entire server?
Could you tell me is it possible to have specific order
of multiple boss bars
Elder guardian effect is jumpscare by itself
I'd assume it's just the order the Player is added in
if you understand what I mean
Where new ones are on top I'd assume
that would beat the shit outta me
Good idea
and to reorder them
I asume there is no way
if you're looking for text alignment for playerlist footer and header, unfortunately true text alignment is not possible due to how there's no one uniform font in minecraft, neither does minecraft natively supports it
Oh I didn't mean putting it exactly in the middle I mean just the scoreboard thing at the side of the screen
Even if you manage to left align text, it wouldnt be accurate if the unicode font would be turned on for a player
oh
its time for sleep for me
i guess
i misread scoreboard as a tablist lol
oh lol
iirc scoreboard header is only center aligned
does anyone have a link to an example of a console log filter for 1.18
is it possible to make a plugin message listener in bungee?
ik about the default ones, but idk if there’s a way to make custom ones
What would a custom one provide that the current doesn't already allow?
lol i just smh managed to flatten an entire class into one line
my listeners class
it looks scary
ok maybe not 1 sec
that has a log filter
what
that post has nothing to do with what he wants
well yes it does, but it's about the least helpful thing u could've linked lol
that's a security issue that got patched in Log4j
What is the tag for all types of stone I can't seem to find it
if not is there a way i can make one with the Tag<? extends Keyed> Interface
how do i get a spot along a vector?
multiply the vector
by what tho
BASE_STONE_OVERWORLD is DIORITE, STONE, GRANITE, TUFF, DEEPSLATE, ANDESITE
a length
i tried doing player.getDirection().multiply(3).toLocation() but it doesnt seem to spawn anything
also how would i make it look at the player
player.getLocation().add(player.getDirection().multiply(3))
oh
would move the Location 3 forward
whats the official FAWE download
page
https://ci.athion.net/job/FastAsyncWorldEdit/ where on here doo i download it
how would i make smth not affected by gravity
like i dont want it to float
just not fall
setGravity(false)
yes
but dont they float away?
no lol
my question is, is there a better way?
wdym float away lol
oh i thought they like can float away when pushed upwards
write it better
also how would i remove an axis from a vector
also use lexing and parsing
tf is lexing?
declaration: package: org.bukkit.block.data, interface: Orientable
cant, gotta study
burh
Then don't ask for help?
^
Also you have duplicate code so extract it
If you want them to stay completely still just remove their AI
https://github.com/Redempt/RedLex you could use this since you have no idea what ur doing @waxen plinth
its an armor stand
You can't push armorstands anyways
just i dont want it to float away if it hits a slab or smth
because that moves them upwards
LMAO
oh
you're taking away the blocks
that only allows one axis in setAxis
?!?
i mean minecraft cant even do that
wdym
im not rotating a block
?
x and z, removing y
how tho
My guy
is it just vector.setY
and also how do eulerangles work like what are the min/max
because changing it doesnt seem to do anything
The Euler angles are three angles introduced by Leonhard Euler to describe the orientation of a rigid body with respect to a fixed coordinate system.They can also represent the orientation of a mobile frame of reference in physics or the orientation of a general basis in 3-dimensional linear algebra. Alternative forms were later introduced by Pe...
Just bear in mind that Euler angles are generally calculated in radians (as is the case with Bukkit's Euler angles)
So 2pi is 360 degrees, pi is 180, pi/2 is 90, you can extrapolate from there
ye i got it
i just dont get why the x, y, and z axes are different than the x, y, and z axes in gmae
like if i rotate it on x, it rotates upwards, as if on the y
also stand.setVelocity(player.getLocation().toVector().subtract(stand.getLocation().toVector()).normalize()); is zooming at the speed of light despite there being a normalize
and its from 3 blocks away
so whats happening
ok just multiplied it by a decimal that fixed it
and finally, how do i stop it from playing the equip noise when i set equipment?
im guessing theres a bool in there
yep
URLClassLoader loader = new URLClassLoader(new URL[]{file.toURI().toURL()});
InputStream in = loader.getResourceAsStream("/block.yml");
URLClassLoader loader = new URLClassLoader(new URL[]{file.toURI().toURL()});
InputStream in = loader.getResourceAsStream("/block.yml");```
why is the InputStream null?
Hey, how would I pass i as an index here?
I know it needs to be final, however I'm not sure how I would use arguments on a runnable, or have a way to store each iteration's index for its corresponding delayed task.
oh. just got an idea
nvm
for some reason vectors dont work without gravity
Does it work if you use int i instead of Integer i?
I don't think that would affect it
the problem is that the variable cannot be a constant
Integer is just a data type after all
is it possible to access the bukkit config file through api or do i need to load it with yamlconfig
InputStream in = loader.getResourceAsStream("/block.yml");```
why is the InputStream null?
probably invalid path
wdym by that tho
like no file
are u using the normal maven filestructure>
?
people are gonna love this when i release it
bruh
its 38 villagers why
apparently NPC exists?
bruh i had just finished a plugin using nms to do that
?
do you not hear it?
dude theres no audio
bruh discord
the original has audio
apparently foxes can attack players
i accidentally did setTarget on a player with a fox
he he he haw
those little things are vicious
they do two and a half hearts
and theyre rlly fast
x,y,z on a square is different then x,y,z on a sphere
why would it be on a sphere
Think of it less as a coordinate on a cartesian plane where x, y, and z can represent a point in 3D space. It's more of a way to point a unit vector in a direction from 0 to 2pi on a sphere
They all share the same origin
If it helps you think about it better, consider x, y, and z as pitch, yaw, and roll
(you can see why the x axis, or "pitch", would rotate it up and down)
cat rolls on its side, a pitcher is pitched to pour, a door is opened with its yaw
Guys I'm so dumb
After 3 days of trying to understand what a hashmap is with complicated tutorials
I realized it simply was the equivalent to a python dictionary
Like my brain is so slow 😭
lol
Lol
Ya put in a key, ya put in a value, ya get stored data. Ya put in the same key again, it overrides. Thats the basics of a hashmap
u guys replyquestions from beginner devs ?
Usually yes. But not if it is "pls send code for x" - as long as you tried your best, you will get answers :)
i find a plugin this plugin works with action bar and titleapi but i don't have a titleapi or actionbarapi
how this plugin works ?
Not sure whether I understand your question correctly. Do you want to know how to use them inside your own plugin or do you want to know how the other plugin works even if you don't have those installed?
actually if i want to make a tab plugin some ppls say me u need tabapi
this i a plugin?
if tabapi is a plugin how can i make tablist plugin without upload tabapi
It is an api that you can either provide as a plugin to your server (which is recommended) or you can compile it into your own source code with maven.
Uploading it as a plugin makes more sense since every plugin on your server can make use of it. Otherwise you have to compile it into multiple plugins.
Tabapi is not needed to do anything with the tablist. An api is also "just code". You can use it but you can also code everything yourself - whatever suits you best
if you don't want to depend on an API you could just make a similar thing code wise yourself
but your line of questioning though however, means you have a bit to learn in regards to java especially when it comes to use of external libraries
ohh thanks
i think i can't code 😄
yes
I'm impatient
i have a more question i want to make "Authme" addon and use authme events
i need upload authme to my plugin's library ?
Learning to code can be fun. If it is demotivating for you, you won't get far^^
learning code is fun but only if i learn spigot for minecraft
You have to register authme as a dependency and use it as a library for your own plugin, yes. However you don't have to compile it into your own plugin since it is already on the server
youtube tutorials doesnt make examples for spigot 😄
how can i register authme as a dependency ?
for intellij ?=
project structure > libraries ?
?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.
also take a look at Maven. It will help you handle your dependencies
You can also add it directly in intellij but I wouldn't recommend that
Can I set the amount of an ItemStack to more that 64?
Not sure if the api lets you do it but with NMS yes you can
it doesn't show me any errors in the api
Client can display up to 127 items in a stack
im trying to make an ItemStack of a custom item and than give it with amount that may be larger than 64
so if it's inv.add() and not inv.set() i don't think that would be a problem
Add and set aren't that different, add just adds it to the next free slot while set adds it to the slot u provide
How to override a default plugin command and replace it with a custom command ? with
bukkit have a execute command event ?
If you want override their command you can set (soft-) depend and then register your command executor
How can I display text above a block?
public void onPlayerTeleportEvent(PlayerTeleportEvent event) {
World fromWorld = event.getFrom().getWorld();
World toWorld = event.getTo().getWorld();
this.getLogger().info(toWorld.getName());
this.getLogger().info(fromWorld.getName());
if (event.getCause() == PlayerTeleportEvent.TeleportCause.COMMAND) {
if(!fromWorld.getName().equals(toWorld.getName())) {
event.setCancelled(true);
this.getLogger().info("Cancelling TP");
}
}
}
I am trying to cancel teleports from different worlds when done by a command.
The thing is, the event doesn't appear to be recognized at all because nothing prints.
I also added this line in the onEnable event:
getServer().getPluginManager().registerEvents(this, this);
yup
No errors / warnings in the IDE
Same with console
I added this line this.getLogger().info("TPChecker Enabled!"); on the plugin enable
Nothing prints out
But the plugin appears as green in /plugins
armorstand?
Are you sure the event handler is in the same class as your main class?
it is
show full code
and in the console?
package net.retonix.teleportchecker;
import org.bukkit.World;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.plugin.java.JavaPlugin;
public final class TeleportChecker extends JavaPlugin implements Listener {
@Override
public void onEnable() {
// Plugin startup logic
this.getLogger().info("TPChecker Enabled!");
getServer().getPluginManager().registerEvents(this, this);
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
@EventHandler
public void onPlayerTeleportEvent(PlayerTeleportEvent event) {
World fromWorld = event.getFrom().getWorld();
World toWorld = event.getTo().getWorld();
this.getLogger().info(toWorld.getName());
this.getLogger().info(fromWorld.getName());
if (event.getCause() == PlayerTeleportEvent.TeleportCause.COMMAND) {
if(!fromWorld.getName().equals(toWorld.getName())) {
event.setCancelled(true);
this.getLogger().info("Cancelling TP");
}
}
}
}
none
and "TPChecker Enabled!" is not being print?
nope
are you sure you have the latest version of your plugin on the server?
I uploaded it like 5 times
otherwise build and try again
and reloaded the plugin 3 times
its impossible so rebuild it
not what we meant
Anyways I rebuilt the plugin
and uploaded it
it says [TeleportChecker] Enabling TeleportChecker v1.0-SNAPSHOT but not what I coded it to say
thats just what spigot says
Sounds like you forgot to recompile the jar
does anyone know how to listen in the netty channels of players?
Hello team hope you are all good, I'm trying to do that : When a player have diamons in there inventory and click on a special item in inventory, i would like to remove 1 of this diamond so if he had 3 diamonds, after clicking he just had 2 diamonds, how is it possible to do that ? thanks u for reading 🙂
Use containsAtleast() and removeItem()
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/Inventory.html
declaration: package: org.bukkit.inventory, interface: Inventory
Yes i think about that, but I have a special itemStack and remove item do not match with int, I cant do p.getInventory().removeItems(diamonds, 1 or diamonds -1) ?
I'm working on a plugin for a server that im hosting for someone but i cant seem to figure out why the profession isnt working
this is the code im using to basically capture the Entity
if(player.isSneaking()) {
if(entity instanceof LivingEntity) {
NamespacedKey type = new NamespacedKey(EasyDetain.getInstance(), "easy_detain_type");
NamespacedKey rez = new NamespacedKey(EasyDetain.getInstance(), "easy_detain_rez");
NamespacedKey prof = new NamespacedKey(EasyDetain.getInstance(), "easy_detain_prof");
ItemStack itemStack = new ItemStack(Material.TOTEM_OF_UNDYING);
ItemMeta itemMeta = itemStack.getItemMeta();
if(entity.getType() == EntityType.VILLAGER) {
Villager villager = (Villager) entity;
itemMeta.setDisplayName(entity.getName());
itemMeta.getPersistentDataContainer().set(type, PersistentDataType.STRING, entity.getType().toString());
itemMeta.getPersistentDataContainer().set(prof, PersistentDataType.STRING, villager.getProfession().toString());
itemMeta.getPersistentDataContainer().set(rez, PersistentDataType.STRING, "rez");
} else {
itemMeta.setDisplayName(entity.getName());
itemMeta.getPersistentDataContainer().set(type, PersistentDataType.STRING, entity.getType().toString());
itemMeta.getPersistentDataContainer().set(rez, PersistentDataType.STRING, "rez");
}
itemStack.setItemMeta(itemMeta);
player.getInventory().addItem(itemStack);
entity.remove();
}
}
this is the code im using to spawn the Entity back into the world again
if(action.equals(Action.RIGHT_CLICK_AIR) && player.getInventory().getItemInMainHand().getType().equals(Material.TOTEM_OF_UNDYING)) {
if(container.has(type, PersistentDataType.STRING)) {
String getType = container.get(type, PersistentDataType.STRING);
if(getType.equalsIgnoreCase("villager")) {
String getProf = container.get(prof, PersistentDataType.STRING);
Villager villager = (Villager) player.getWorld().spawnEntity(player.getLocation(), EntityType.VILLAGER);
villager.setProfession(Profession.valueOf(getProf));
player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
} else {
}
}
}
so right now i have only been working on the villager part as i figure that would be the hardest to get done but since im storing the profession into a pdc but it seems when i read it back its not working no matter what way i try to do it so im coming here for help with it
you dont really want to create 3 NamespacedKeys everytime the code runs. store them somewhere
did you try to debug what getProf returns?
If I try to execute this line while the player has no inventory space left, this will not give or drop any items.
Does it also return some error or exception when it happens so that I can catch it?
player.getInventory().addItem(event.getCurrentItem());
addItem returns a boolean iirc
whether the item has been added or not
nvm its a HashMap with the items which couldnt fit
ok
no no you were right
I can see that the console says false a couple of times
probably because of this
pretty weird to declare it as hashmap instead of map, but so be it
Cant we just disable the fucking custom join message
you can disable the default join message if that's what you mean
How
Im not unable to code rn
event.setJoinMessage(null);
Inside an OnPlayerJoin event
😭
Cant i disable it via bukkits own ymls
Hey, i just come back with my problems, so i have this code : ```if (e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase(deposit1)){
e.setCancelled(true);
if (getAmount(p, diamond) >= 1){
plugin.economyCore.depositPlayer(p.getUniqueId().toString(), 1);
for (ItemStack i : p.getInventory().getContents()){
p.getInventory().removeItem(diamond);
}
} else {
p.closeInventory();
p.sendMessage("You need diamonds on you");
}``` and there is the ItemStack ```ItemStack diamond = new ItemStack(Material.DIAMOND, 1);``` so how i would like to remove one diamond and not for exemple the 32 diamonds the player had in their inventory, i need help please! 🙂
show us the diamond
nvm
How do I set a players inventory to another inventory?
I wanna save an inventory of the player and than if some condition is true I want the inventory to be back to the saved inventory
loop through first inventory
set each slot in player inv to the i'th slot of the stored inventory
newInv.setContents(oldInv.getContents()); ??
that's exactly what removeItem is supposed to do
It will try to remove 'as much as possible' from the types and amounts you give as arguments.
that seems longer that it can be
do what mfnalex did
Is there a way I could save a gamemode in a config?
Or convert a gamemode to a string?
if(gamemode == GameMode.CREATIVE){
string = c
}
Can I do Gamemode.tostring?
i diont think so
probably
I can
u can do that with all enums
and then use valueof
Hey i'm trying to run the gradle task "run spigot" but i'm stuck with this error :
Picked up _JAVA_OPTIONS: -Djdk.net.URLClassPath.disableClassPathURLCheck=true
openjdk version "17.0.3" 2022-04-19
OpenJDK Runtime Environment Temurin-17.0.3+7 (build 17.0.3+7)
OpenJDK 64-Bit Server VM Temurin-17.0.3+7 (build 17.0.3+7, mixed mode, sharing)
*** The version you have requested to build requires Java versions between [Java 8, Java 16], but you are using Java 17
I tried to change my java version in 16 but it doesn't work either
Make sure gradle is using java 17
Settings -> Build, Execution, Deployment -> Build Tools -> Gradle -> Gradle JVM select [17.0.3]
Thanks it's working now!
Hallo, I need a developer for making me a new plugin for my server
I'll pay for the task
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
Your spigot Version does Not Support J17
What kind of plugin?
is there any way to encrypt a string in a yamlconfiguration for passwords
Sure. Just use a sufficiently secure encryption standard like AES
You can also just create sha256 hashes with guava (which is already provided by spigot)
String sha256hex = Hashing.sha256()
.hashString(originalString, StandardCharsets.UTF_8)
.toString();
Definitely do not encrypt a password
You don’t want it to be decryptable
You want a one way hashed password with a salt and a pepper if you’re going to store passwords
not sure what a pepper is supposed to be
but a salt is an extra string that is appended to the input before hashing
and stored
so an attacker cant precalculate hashes
i think he want some encryption that uses salt
bcrypt and argon2 are good alternatives
Not encryption, hash
you understand what i meant
In cryptography, a salt is random data that is used as an additional input to a one-way function that hashes data, a password or passphrase. Salts are used to safeguard passwords in storage. Historically, only a cryptographic hash function of the password was stored on a system, but over time, additional safeguards were developed to protect agai...
In cryptography, a pepper is a secret added to an input such as a password during hashing with a cryptographic hash function. This value differs from a salt in that it is not stored alongside a password hash, but rather the pepper is kept separate in some other medium, such as a Hardware Security Module. Note that the National Institute of Stan...
Nice didnt know that
Always gotta salt and pepper your hashes
Enum#toString
I already got an answer, but thanks anyway.
I do have another issue
I want to get the location of a /spawnpoint in a world
declaration: package: org.bukkit, interface: World
What is the best way to keep a cache on BungeeCord? (All data is on the MySQL database)
- Getting all the data from the database every second
- Getting all data if Bungee starts, and let Spigot add / remove from the cache via messaging. The database is fully updated by Spigot
- Sending new objects through messaging to Bungee (but saving them in MySQL is hard, because they all need other columns (there are base columns, but the extended class might want to save additional data)
that gets the /setworldspawn
Thats the spawn location of this world
No method on Player?
When do you need this spawn location? When the player respawns?
yup
I am making a system where if you die you respawn in the same world
Then use the respawn event
but I need to check if any parkour map did /spawnpoint
@lost matrix
Anyone?
Is there a way to load an inventory from an inventory variable?
i heard that redis is good for these cases
but i am not experienced
I think bungeecord should not be used as a caching service.
Its a proxy and you should keep it that way.
with
Yes, but the idea is that it is available over multiple server instances across the network instead of querying the database every time
I have no experience too
Best you can do is iterate over the content and add it to another inventory.
What if you need load balancing? Then you have to start multiple proxies and have a problem with caching again.
What is load balancing? And what else is the best way to get an up-to-date view of all the servers?
Currently im a pretty big fan of redis for cross-server communication and/or caching.
How to use that?
I would use the Redisson library on the Java side.
Other than that redis is just an in-memory key-value database.
So a bit like a HashMap<K, V> that can be accessed by multiple applications at the same time.
Ok but my client uses external hosting. Will he have access to this?
Probably not
Then we cannot use it
Maybe I can also just select the data I need when a command is run on Bungee
What do you mean by "external hosting"? Doesnt he have root access?
If its a game-server then something like this is redundant anyways. Such a setup barely
gets more than 20 concurrent players.
He hosts by a Minecraft hosting service
He already has 300+ players
Then he should have the liquidity to get at least a V-Server for 20 bucks a month.
Or a full dedicated for 50
Idk if he wants to, but I think I will go for the option above
With 300 players you might need to load balance bungeecord already. Especially if you have a weaker cpu.
I prefer jedis though
And topics are also great
But you did not yet explain load balances
Redisson >> Jedis
Having multiple bungees
Oh understainable
And the bungee served to each player is based on their relative loads
Then I don't want to use MySQL as cache
But how do I send players then to the required server if that one is on another Bungee instance?
Multiple bungees can point to the same server
The server has no concept of what bungee the player is on
Now I am confused
Should I use public ItemStack name{
//ItemStack Codes
}
to use ItemStack on another class?
plugin messaging channel or sockets. Also MySQL should not be used as a cache. Its a DB so it should be used for persistent storage.
And having 300 concurrent players but then using flat files is just asking for problems.
Yes
Thats not even valid java or kotlin...
when a user connects to play.whatever.com, they get sent whatever bungee has the lowest utilization
Let’s say it’s bungee C
Ok
If your friend is playing on bungee A, you can still both be on server 2 and see each other and interact with each other
Ok, but will the message from SPIGOT server 1 (Bungee A) land on the same place as the messages from Spigot 2 (Bungee C)?
How are you sending the message from spigot
Just to the player
plugin message?
Wait wait wait
Yes
plugin message is not the best btw
The message is sent via the player, so it ends up on whatever bungee that player is connected to
Ok, but if one is for example on spigot1, and the other on spigot2
I know, and I only send messages when players are online
Plugin messages are transmitted via the player’s connection
I know everything about plugin messaging, but the problem is that I need to know about load balancing
So that message winds up on whatever bungee the player is connected through
Ok so keeping a cache is useless on Bungee
But I can still send queries to the database if I need data
Correct
And that will be less frequent
Depends heavily on what it’s a cache of
Yes, but all settings are saved on the database
Some might be on the same server
And they need to be able to join gamemodes on Bungee level
I would suggest caching it in Redis or something similar if the bungee doesn’t need to know it at all times
That is why I need to know what arenas are there per server
You can use a cache like Redis for that
Well he definitely can
I think I will just query the database
Yes? Why?
Because anyone can…
But I don't know how he hosted the server and if the hosting allows non-minecraft servers
That will likely work, but it may be slow and you run the risk of overloading the database depending on frequency of cache updates
He can just acquire additional hosting
It’s not difficult
I won't have a cache then, just querying it once per command. And having a cooldown on the command isn't that bad
¯_(ツ)_/¯
i have created a custom mob and is it possible to customize their drops
why players can be damaged by arrows if they are outside spawn region by players inside the spawn region
the isInRegion works fine, works on blockbreakevent and stuff
I mean, the damager in that case is the arrow
not the player that launched the arrow
ok so i need to cast it to an arrow and then check for the shooter ?
Well yea but you'd also want to be able to run code if it is the player
so, eeek smth like
Player damager = null;
if (event.getDamager() instanceOf Player player) damager = p;
else if (event.getDamager() instanceOf Projectile projectile && projectile.getShooter() instanceOf Player player) damager = player;
else return;
You can also just tag an arrow by using their scoreboard tags or PDC.
Just give it an "PLAYER_ARROW" tag.
This way you dont need to get the shooter.
ikr
1.8 💀
Well... why do you use ancient software?
Anways, scoreboard tags should be available in 1.8 so something like this might work
@EventHandler
fun onShoot(event: PlayerLaunchProjectileEvent) {
event.projectile.scoreboardTags.add("PLAYER_PROJECTILE")
}
@EventHandler
fun onHit(event: EntityDamageByEntityEvent) {
(event.entity as? Player)?.let {
(event.damager as? Projectile)?.let{ projectile ->
if (projectile.scoreboardTags.contains("PLAYER_PROJECTILE")) {
event.isCancelled = true
}
}
}
}
thanks but i won't need it 💀
and i use 1.8 because of the pvp version and performance and i have my own reasons so let's not have an argument with no end and reason and about it
This is probably cleaner
@EventHandler
fun onHit(event: EntityDamageByEntityEvent) {
if (event.entity is Player && (event.damager as? Projectile ?: return).scoreboardTags.contains("PLAYER_PROJECTILE")) event.isCancelled = true
}
XD
kotlin aaaa
I have a love/hate relationship with it. I think its 'neat'.
But i honestly prefer java
i thought i saw rust for a second
i usually will use kotlin for a while and then do one thing in java and kind of drift back to java
still like kotlin though
so many utility things that java just doesn’t have
But i feel like java is way more explicit and has sturdier standards and constraints. (Which i like)
well yeah, but sometimes the constraints can get in the way
it does make it more straightforward though
Bukkit support for scoreboard tags wasn't added until 1.10
The downside of using outdated shit is that you don't get basic APIs
Keep track of a Set<UUID>
Nice
one more argument against 1.8
1.8 rocks!
Been dealing with a lot of 1.8 threads on the forums lately, which is annoying. The worst part is, people suggest just terrible solutions
yeah
The amount of people that don't know about MaterialData is painful
also since there is like no persistent data support in 1.8
people always resort to super bloated yml file stuff
what are scoreboard tags tho
Vanilla feature of scoreboards to attribute arbitrary string data to entities
Useful for datapacks to keep track of entities
Oh I see
Beyond that they have no use in plugins
I feel like 1.13+ spigot complicated some stuff tho
mainly mojangs fault tho probably
Like what? It removes a ton of magic numbers and crawls towards data driven structures.
Yeah. I'd argue it made it far simpler
datawatchers are a lot more annoying to work with
since now you have to reflect and grab some arbitrary named class to set a value instead of just passing in a simple byte
you could argue that the byte is just as arbitrary though
Entity classes generally abstract out their data watchers with simple getter/setters
So NMS has gotten more complicated. Because there is a lot more abstraction and data driven concepts like registries present.
But that doesnt have anything to do with Spigot... its only logical that more features and grater modularity make a system more complicated.
not all of em
and the difference between the byte is that you can easily just look on the protocol metadata wiki page
and no reflection is required
both are just as magical
one is just 2x faster to use

and how are you supposed to make birch wood for example without magic numbers I'm not sure
Material.BIRCH_WOOD
why i can't pickup items that i added nbt tags to them
How do I schedule a repeating async task?
So did they add a bunch of new materials
declaration: package: org.bukkit.scheduler, interface: BukkitScheduler
when i break the lucky block, it drops this item with a tag
and i can't pick it up
This means there is some listener preventing the pickup
the only time getting cancelled
Or the pickup delay is weird
Add a debug message and see if its being called
did you add a pickup delay?
What is a real life class?
You mean in the context of school?
Or in the context of ranking? Or a clase social
What does class refer to? A group of students? A course like math?
"math class" or "class A2"
public class Class?
Ok so a group of students. Then call it StudentGroup
Is it possible to store a location in a config file?
yes
Yes. Just throw it in
Ah, then I've been converting it to a string this whole time for nothing😅
ClassroomContent
lol. The students are the content? XD
Guys i have problem, before every message or ranks or npcs its ââ how to fix it
Cus it looks ugly
what else
sounds like a plugin
Use utf-8 file encoding when compiling. And also stop using 1.8
oh
what is that
only their messages 😅
i once tried FileConfiguration#getLocation and it gave me a classcast exception and only manually casting worked lol
hm
wtf is the difference between Class#getComponentType() and Class#componentType()
they both do the same thing as it seems
Call it a StudentFlock
cmd+click and check the source
as I said, it does the same
but i know alex is
@Override
public Class<?> componentType() {
return isArray() ? componentType : null;
}
...
public Class<?> getComponentType() {
// Only return for array types. Storage may be reused for Class for instance types.
if (isArray()) {
return componentType;
} else {
return null;
}
}
well
actually only on vacation
otherwise I use my desktop pc lol
well
what is utf-8?
in that case
@boreal whalecle fix
Are you using maven?
the thing that allows you tö üse nice chäräcters
A charset
bro i dont know anything othat
i just use spigot some plugins and thats it
nice chäräctërs
It's how a computer understands letters
so how to fix it?
its a set of characters
how letters are turned into bytes
lets get some sausage lol
getComponentType() and componentType() is really so stupid, it's the same, and it has the same code twice
is there a way to store PersistentData on a block that isn't a TileState? Like can I store data in a block of dirt?
no, you can only use workarounds
𝔑𝔦𝔠𝔢 ℭ𝔥𝔞𝔯𝔞𝔠𝔱𝔢𝔯𝔰
ah alright. So like maybe storing the blocks in a config or something?
????
check my link above
@tender shard they are the implementation for Constable
getComponentType() existed prior
but componentType() could just call getComponentType() instead of copy pasting the code lol
What ide are you using? (Matters if you dont use maven or gradle)
that was a very good sausage
Thank you!
bro i dont even know what that means ???
oh but Constable doesn't even declare componentType()
https://openjdk.java.net/jeps/303 was the initial jep for that
just tell me what to do
In what program do you type in you code text?
Then give us the information we need
notepad++
i cant give cus i dont know what that means
i just uploaded files to panel
and i cant see characters
I already thought I'm stupid lol
I hate stuff like this. I see that both getComponentType() and componentType() exists, then I ask on Discord WHY, and in the end I lost 15 minutes of time without doing anything useful lol
what bro?
cmn just say what to doo mannnn
Ok so if you type in your code in notepad++ then you compile using the javac via the command line or what?
Ok im just going to tell you what to do:
Use the UTF-8 file encoding when compiling your sources.
and i asking how to fix it
no one responding there
this isnt the right channel
then why are you in help-development?
do not ask for help in this channel and not expect programming help
and then you wonder why you don't understand a thing when you ask in the wrong channel on purpose?
ok can someone come to help server?
jesus
ok stop being angry man
why toxic
It might have something to do with your terminal settings. My suggestion: Stop using 1.8
I'm not angry, I just don't get it. Please don't spam this channel and head back to #help-server
no wtf
pvp system better there
why u dont allow me to type in this channel
holy shitr
congratz, you're the 50th person on my block list in 5, 4, 3, 2, 1...
like i will ever type to you xD
im going to help server bye
about time
hm did I forget any special cases? I think this should work fine, right?
public static <T> T[] shiftArray(T[] original) {
if(original.length == 0) return original;
T[] shifted = (T[]) Array.newInstance(original.getClass().getComponentType(),original.length-1);
if(shifted.length == 0) return shifted;
System.arraycopy(original, 1, shifted, 0, shifted.length);
return shifted;
}
it's supposed to always remove the first array element
why not just do this the normal way
Its not a good idea to return the original half of the time and the shifted one the other half.
what do you mean?
the original is only returned when it's already empty
If the original has a length of 0 then you return a reference to the original.
If not then you return a new reference.
oh yeah, sure, that MIGHT be a problem, but not in this case as it's only to parse arguments, so the contents will never be changed
but yeah I should instead return a clone, thanks for the suggestion
public static <T> T[] shiftArray(T[] original) {
if(original.length == 0) return original.clone();
T[] shifted = (T[]) Array.newInstance(original.getClass().getComponentType(),original.length-1);
if(shifted.length == 0) return shifted;
System.arraycopy(original, 1, shifted, 0, shifted.length);
return shifted;
}
okay how's this? 😄
oh wait
I only return the original when it's empty
so nothing can ever be changed anyway
Why do you shift an array (which is not exactly cheap) just to parse arguments?
Cant you just use an ArrayDeque and pop arguments?
so actually the clone is useless
I probably could, but... in fact all I need to do is to remove the first element from a string[] once (to separate the command name, args[0], from the remaining args that get passed to the actual command class)
since spigot is using String[] for arguments, I decided to do the same thing
(this is for a discord bot, nothing related to spigot)
Well... LinkedList and Deque both support removal on both head and tail in constant time.
as said, it's for a discord bot, I don't really care if "shifting" the argument takes 2ns or 0.3ns so I guess I'm fine 🙂
I honestly feel like doing it the original way is better than creating a list, allocating tons of objects and all
Wrapping the array into an ArrayDeque -> one new object.
Shifting an array of 3 arguments 3 times -> 3 new objects
Hello idk why my BuildTools makes no Jar? D:
exceptions?
You can do arraycopy onto itself and it shouldn't allocate new objects
but then the last element is duplicated
then use something different: https://paste.jeff-media.com
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.
have you deleted the entire work directory and tried from a clean start ?
the folder with Build Tools`?
Yea
An empty array is de-facto immutable either way, no reason to return a clone there
yeah that's what I realized shortly after I added the .clone(), too lol
fun fact: you cannot ctrl+B to the .clone method of an array
use maven/ gradle?
yeah this is better way ^
or doesnt that longer work in 1.18
It works
its weird in that version
@kind patrol do you use IntelliJ ?
Okay it would have been a lot less of a work if it was IntelliJ cuz it has a minecraft development plug-in that auto created pom.xml for maven
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
you should use maven or gradle
graven or madle
any idea how can i loop through this yaml file?
4255030d-bb79-3185-9265-1c21e4464bca:
coins: 0
tokens: 2
4255030d-bb79-3185-9265-1c21es4464bca:
coins: 23
tokens: 21
4255030d-bb79-3185-9265-s1c21e4464bca:
coins: 123
tokens: 223
getKeys(false)::foreach?
FileConfiguration#getKeys(boolean deep)
i actually thought you needed a configsection to be able to loop
is there a way to add a command to tab completions without actually registering it?
smth like this?
for (String users : this.config.getKeys()) {
}
Nah iirc you can without a config sectoon
false as parameter in getKeys
I would make the class serializable and then store them as a List or Map
aah
eeeh i would like smh need to like loop through the list and set for all the entries the coins to 0
for string k : getKeys(false) {
config.set(k + ".data", something)
}
save()```
whats a static context then
what you’re doing
so how would i do it
referencing it by the class and not an instance (is what you’re doing)
oh ok
static stuff belongs to a class and not an instance
make the method static or get an instance of dynamiccommands
and instance stuff cannot be accessed from the class
This is how you can make this a really short process:
class EconAccount(private val uuid: UUID, private val tokens: Long, private val coins: Long) : ConfigurationSerializable {
companion object {
fun valueOf(map: MutableMap<String, Any>) : EconAccount {
return EconAccount(map["uuid"] as UUID, map["tokens"] as Long, map["coins"] as Long)
}
}
override fun serialize(): MutableMap<String, Any> {
val map = mutableMapOf<String, Any>()
map["uuid"] = uuid
map["tokens"] = tokens
map["coins"] = coins
return map
}
}
// Then in another class:
fun saveData(map: Map<UUID, EconAccount>, config: FileConfiguration) {
config["accounts"] = map
}
fun loadData(config: FileConfiguration) : Map<UUID, EconAccount> {
return config["accounts"] as Map<UUID, EconAccount>
}
that syntax looks kinda ugh
i cant make it static because then i wont be able to use this which i need
then get an instance of it 🙃
Is there a way to check if a given ItemStack is an ItemFrame?
just dont use this then
kotlin 🤢
kotlin 😍
imajin ?docs command when
?jd-s
wait
?jd
well thats not working
how so
best thing
?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.
im trying ive got a lot of it down
yeah well not enough
?
Yeah you can use that with any entity
even Items
addPassanger
setPassanger is deprecated because an entity can now have multiple passangers
addPassanger
so i have had this issue since forever, i cannot register/unregister a command outside of the onEnable. if i unregister it, it works but its ban command so it should return to vanilla ban command. if i register it, it wont register. but this all works if i do it during onEnable
What if I add a passenger that has already got passengers?
Would they add togheyer as the passengers of the main entity?
Then both are mounted at the same time
Or would they count differently?
Why does it say Condition 'player.getInventory().addItem(event.getCurrentItem()) == null' is always 'false' ?
If the action of adding this item isn't complete it should return a hashMap which wouldn't be null
.isEmpty()
^
what is that
use it instead of == null
isn’t additem void or a boolean
so use .isEmpty then
If you want to drop items on the ground when giving them to a player but his inventory overflows, then i would recommend something like
player.getInventory()
.addItem(item)
.values()
.forEach(overflown -> player.getWorld().dropItem(player.getLocation(), overflown));
it wont return null, it will return either an empty of a hashmap with stuff in
How can one make a CLI program like the spigot server CLI (printing info while giving the user a way to enter input)
With Java?
Yep
Just make an executable jar file. Use Sysout to print into console and a Scanner to get console input.
All you need is an entry point public static void main(String[] args)
does anyone know if JDA has a feature to replace emojis?
E.g. :) -> :slight_smile:
anyone know how i can fix "Could not connect to a default or fallback server. Incorrectly configured address/port/firewall? io.netty.channel.AbstractChannel$AnnotatedConnectException"
bungeecord
Correctly configure your servers and start them
This message tells us otherwise
When I use if (player.getInventory().addItem(event.getCurrentItem()).isEmpty())
Does it only give me hashMap or does it also add the items?
?jd
it adds the items. the hashmap is to notify you about items that couldn't be added
like i typed in all the stuff, all the ips, ports, everything, i checked 7 times and nothing
ok
Did you open the ports?
I mean to me it sounds like you either configured it wrong or didn’t open the firewall
Is the bungee on the same box as the minecraft servers?
I has this problem so I tried to clone the item in the slot and set this slot to the cloned item after I add the item to the player but this problem isn't fixed for some reason
You’ve discovered the difference between addItem and setItem
ItemStack clone = event.getCurrentItem().clone();
if (player.getInventory().addItem(clone).isEmpty()){
event.getClickedInventory().setItem(9, clone);
Good god
?
What do you think that code will do
Why are you checking if the hashmap is empty
because I want to check if it can be added and if not than remove the given items
no
Wrong section and discord
@quaint mantle this guy do be breaking rule tho
@brave sparrow are you here?
?ban @turbid moth repeated breaking of the rules
Done. That felt good.
F
tyty
The hashmap may not be empty even if some items were added
Let’s say you add 10 items and they only have space for 3
The hashmap won’t be empty but the inventory will now be full
there would be 7 items in hasmap?
yes
yes i know
i'll set this slot to what it was before
that's not the problem
the problem is in the video
it is a custom inventory
Why don’t you just cancel the click event
because slot 9 is inside the custom inventory. You are setting it on that slot
yes that's what it should do
But it's already there so why set it again?
I want the items to be added but they become 1 and not stack
because it becomes one rather than stack
as in the video
If i don't set it, the slot that has a stack is replaced with the slot of the items that were in the inventory
Ok lets go one step up: What exactly is your goal
I am trying to make an inventory that lets you get these coin items when you press on them
anyone know how i can fix my bungeecord? pls dm
In that case you just take the clicked item and add it to the players inventory. Additionally you want to cancel the click event so it isn't actually getting removed from the inventory (more like duplicated)
I want the given items to be given and stay in the inventory of coins
yes that's what this method will do
that’s why you cancel the event
pseudocode:
- check if it's your custom inventory that is clicked
- cancel event
- get clicked slot
- get item in slot
- add item to players inventory
i usually put it as early as possible just in case an exception gets thrown somehow
True. I usually follow that pattern aswell. Good to mention that
Hello I have my proxy on asia and backened servers on Germany my launcher as well as default spigot ping shows asian ping but when I install any tab plugin it shows me backened germany ping can anyone help ?
Also edited the message for clarity
event.setCancelled(true);```
the problem still happens
the slot with a stack becomes one and not stack
because I don't want the item to be moved
that's what I did
no
so i have had this issue since forever, i cannot register/unregister a command outside of the onEnable. if i unregister it, it works but its ban command so it should return to vanilla ban command. if i register it, it wont register. but this all works if i do it during onEnable
I have in the end a cancel
in the end of the command
but it's inside an if, isn't it?
wdym
the event.setcancelled only happens if the map is empty
it's inside the if statement that tells me if the item clicked is in the custom inventory
because you guys told me to just cancel and not clone
huh? How does that give any info about a custom inventory?
if (inv.getHolder() instanceof getCoinsInv){
dude what
its inside this
that isn't what you sent before
that isn’t even the same if statement
what am i looking at here
the event only get cancelled if the map is empty
the map isn’t always empty
the if statement that I sent before is inside this one
the event isn’t always cancelled
so you have 2 ifs before cancelling? Why?
I it was always canceled no items could even be moved in any inventory
oml
you aren’t checking the inventory type in that if statement
you’re checking if the map is empty
the map isn’t always empty
You can put the cancelled statement in the beginning after the holder check an remove all other cancellations
hey i am trying to use a plugin on my server, but when i try running it, this is whats happens
[19:30:27 ERROR]: Could not load 'plugins/ChangeSkin (1).jar' in folder 'plugins'
org.bukkit.plugin.UnknownDependencyException: ProtocolLib
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:219) [server.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:292) [server.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:198) [server.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525) [server.jar:git-Spigot-21fe707-741a1bd]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_312]
I starting to think that I should just delete this entire event and start over
probably
Install protocollib
it worked and then i messed it up 😢
I mean your code has a lot of duplication and could be shortened to like 1 10th
i know
i'll just start over
:(
What are you trying to do here?
He wants to hand out items on click of a custom inventory
