#help-development
1 messages · Page 1476 of 1
so just remove the stick from the inventory?
I mean, whenever it is used (idk what event you call this logic in) you replace it yes
like e.g. on right click
ok
you just update the item the player is holding in their respective hand
gotcha
Is there any way to "touch" the main world of a server ?
like remove it or change it before load ?
Did you actually change the item?
iirc Player#updateInventory wont do anything unless its the inventory that the player owns (Player#getInventory())
How do you implement placeholder support for a plugin?
it just generally updates the contents of the inventory, as in resends them
Hi, someone have some plugin for the premission?like for make vips, admins, etc
it's there to combat against client-sever desyncs and shit
fair
unless cancelling click events and spam clicking is involved, it probably does nothing
Luckperms
another?
PermissionsEx? (outdated though)
Why not LuckPerms?
where's elgar
^^ its probably your best option
because I don't know why he won't let me put the prefixes
wdym?
anyone haves some fun tools plugin? like a plugin that have spells for people or buffs, want to spice up my smp
ty
You need a separate plugin to put the prefixes
You need a chat plugin to display the prefix afaik
any?
?
Yeah read what we've sent
and then move to #help-server this is the wrong channel
what v is the volume?
isn't it volume, pitch?
yeah thats what i mean
package index
Did you even modify the lore?
thanks its volume, pitch
are you sure the code is run?
If updateInventory does not work you might be doing something wrong as I recall that this is not an issue when I last tried something like this.
However this has been quite a while so my memories could have been false there, at which point you might want to try things like Inventory#setItem explicitly a second time to see if that works
I'm super new to making a plugin but is there a way to create section with out using createSection method?
can you create a skull that has a texture of an image? like instead of having the base64 json that leads to a minecraft texture api url, can u use a plain image ? lmao
Is it possible to control mobs (if it's possible, ofcourse it will has latency) in spectator mode while we're inside of them?
ItemMeta#setLore(Collection<String>)?
It takes a List iirc
how can I create placeholder with variable in skript?
i found a plugin that starts from 1.12.2 version and has 1.8 support with Maven
can probabbly be a good way Maven?
We do not support Skript. Find their discord and ask in it.
OH OK
skript is gay
I humbly deny the request of getting spoonfed for ArisTheMage
?spoon
Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.
seems like a lot of people need help these days
?jd
package index
even then, at least have some kind of code yourself. This place is to help people who are stuck on a piece of code, not to be given code at a whim
^
it does
you just don't know what it's supposed to do
so you call it broken when it doesn't do what you want
so, uh
say I have a binary heap implementation
an array based one, that is
for removing an element, you normally would first move the last element of the array to index 0, and then down-shift it repeatedly until the heap property is restored
if I were to reimplement this operation by left-shifting the entire array by one element, and then checking restoring the heap property for its elements
that should outperform the former implementation if the elements are already sorted, yes?
mostly already sorted
trying to optimize my priority queue to take advantage of the almost-sorted input i'm giving it
so i have this class
which this class extends
and is instantiated here
shouldnt the while loop begin running when this class is instantiated, because its in the constructor?
im new to extending so i prob got something wrong there
also i know about naming conventions im just way more used to python and keep forgetting to switch
especially with methods
don't expose state directly by making fields public; write accessor methods for them and maintain the state internally
use the java naming conventions
i know with the naming conventions yeah
i don't think those fields need to be static
for 80% of the files i respect it well
for some reason if the itemstack wasnt static it would throw an error on the super method
that while loop will crash the server
i see
that while loop will never stop
which means that the method call will never return
which means that the onEnable method call will never return
which means that the server will literally never be able to progress past loading your plugin
which means that it dies
can you run a while loop asynchronously?
yes, but don't do that
alright
if you do that, you will spin an entire thread at maximum possible speed checking whether a player is shooting every 400 nanoseconds or something
you will melt down the processor
well the while loop was a solution to see if an event passed in a different class
i couldnt think of anything else
events is an instance of this class
don't check if an event happened
because if i were to write the event in the Weapon class i wouldnt be able to register it cuz it has a constructor
notify the thing that wants to know if an event happened, that an event has happened
how would i do this?
depends entirely on how you've laid out your project
just do if (event happened) do something?
no, that is checking whether an event happened
you don't want to do that
you want to do stuff when an event happens
hm
maybe i could make the shooting event run through the event
or could i make something in the event to make this run
maybe try something simpler as your first project
this isnt my first project
it kinda looks like it is
its my second project so fair enough lmao
i need to make this for someone tho so i have to finish it
the someone might be more pleased with not getting anything at all than getting what you manage to make at this stage
tell them to wait 2 months
harsh but i can agree with you
i should genuinely stick to python when someone asks me to make something
you might not notice it but you will be making a lot of rookie mistakes and if someone actually wants some sort of a product, they won't be happy when they learn that they need to basically rewrite everything if they want to actually use it on prod
if it's just something among friends or whatever it's probably fine
just make sure they know it's not your finest work
the rest of the plugin works perfectly fine
they tested it out and said it was perfect
its just the gun part
thing with development is that in addition to working, the thing should be maintainable
probably because everything else was waaay easier to make
i know
trust me im really not proud of this
somebody needs to update the project 2 years from now they'll be jumping off a bridge
if the naming convention is awful the rest of the project usually is
ok so
i want to have it
where when a play clicks their mouse
and are holding a specific itemstack
a gun right
it shoots
problem is
i cant make a playerinteractevent inside of the Weapon class
because it has a constructor
so i made one outside of it
the last 3 lines you said sound very wrong
show me what you did, in particular 'making one outside of it'
an event handler? yes
has nothing to do with constructors
every object has a constructor
add a new method
@EventHandler public void myhandler(MyEvent event) {}
then make the class implement Listener
sure you can
because the only reason they are there is for an extension to "super" it
consider deleting everything and starting from scratch
fair enough
basically, I have no clue what you are doing, but this is how it should be done
number one
i made an entirely new class that does this
object oriented
yes
thats what im doing
have each such object have an id
oh
f.e a String, "gauss-rifle"
number three
have a map that maps the id to the object
String -> Weapon
number four
have a single listener
check the persistent data container of the clicked item
check if it has a specific tag, say, myplugin:weapon-id
if it does, grab the value
yeah
alright
right now you have one class for each weapon
what you want is one object for each weapon
so i should make an object for each weapon
yeah ok
i thought extending the basic properties would save time
if you have an object per weapon, you can do
Weapon bigGun = new Weapon(10);
Weapon biggerGun = new Weapon(100);
Weapon biggestGun = new Weapon(1000);
where the number would f.e set the damage of the weapon
instead of having to write a new class for each one
big bigger and biggest
you can combine it with extension
now that i think about it
for example you can have a class Weapon with only basic attributes
you should do that if you have a configurable amount of weapons as well ^
and a GrenadeThrower that extends Weapon, that modifies the logic slightly
but don't restrict yourself to a single class per weapon
hence the extending
yeah, that's fine
but you still want to maintain the OOP nature of things
that is, using objects for things
the classes are just templates
you could have 5 different GrenadeThrowers with just writing 1 class
myeah
alright
now with that listener
how would i make it check that the gun "shoots"
assuming i cant pass the main weapon class in register events
for the listener, the listener itself shouldn't be concerned with what a gun does when a player clicks
the listener's purpose is to listen, and forward the information about the events
it is the Weapon that chooses how to deal with that information
i see
yeah
the Listener would query this map
so like
have some abstract or default methods on the base Weapon class
event runs -> get this weapon
myeah
kk
have some abstract methods like onRightClick, onLeftClick, onSneak on the Weapon base class
and then have the listener call those
Weapon clickedWeapon = map.get(weaponId);
clickedWeapon.onClick();
look this is probably obvious to you and people with a brain but thats genius why cant i think of these things
it comes with experience
you learn to leverage the advantages of object oriented programming and the language
imo before writing a single line of code you want to sit down and think about the layout of your project model
so wait this map would return what?
the extended weapon object?
it'd return a Weapon of some kind
alright
we don't need to know what kind of weapon
just that it is a weapon
and has the abstract methods declared on Weapon
and the get method just passes whatever we match the weapon too
like a string or the itemstack
the get method takes a single parameter, the key
can the key be anything or just a string?
a map aka a dictionary maps keys to values
it can be anything you want it to be, but only one type of key allowed per map
i see
f.e a Map<String, Weapon> would use String based keys
a Map<ItemStack, Weapon> would use ItemStack based keys
i see yeah
although the latter sounds good on paper, we don't want it
because maps use equals to compare keys
meaning that the keys must match exactly
so like i could pass the name of the weapon instead as a string?
with getItemMeta.getDisplayName
which means that if someone changes the name of our itemstack or it loses durability or is somehow not identical, it won't recognize it as the same key
well, that is the old fashioned way yes
Is there a way to tell when a player stops breaking a block before the block actually breaks? I wrote a plugin to allow players to break bedrock, but now I am trying to animate the breaking with ProtocolLib packets.
but then you need to stop players from renaming items and all that jazz
the preferred method is to use an item's persistent data container to store a value
but that might be a bit involved for you considering you're not familiar even with maps
well i understand maps now if they work just like dicts as u said
use the displayname for the time being and switch to proper pdc id shit later
fair enough
a persistent data container is basically a map
im dogshit with data anyways i have a seething hatred for json
but it has facilities to serialize and deserialize data to a primitive format
so the data can be persisted over restarts and shit
i see
simple on paper but it involves jumping through some java generic type parameter hoops so it looks confusing
sounds like it
thanks dude
@wraith rapids alright im gonna go try that out now
na but genuinely ur def the most helpful person ive ever met on discord
if i knew u irl id buy u a drink or smth
lol
have a great day man
Is there a way to tell when a player stops breaking a block before the block actually breaks? I wrote a plugin to allow players to break bedrock, but now I am trying to animate the breaking with ProtocolLib packets.
(Reposting so it isn't buried)
i've found that one of the best ways to get a thorough understanding of something is to figure out how to explain it to someone uninitiated
definitely
i hang around the spigot and paper discords repeatedly telling the same shit to a million people every day because they provide an endless supply of the uninitiated
there, uh, is a packet for that I think
Also a great way to figure out what is wrong with your code.
Yeah I guess I can just listen for the stop breaking packet
check if the protocol documentation mentions the packet by name
there is no event for it in the api
Since I'm already doing weird packet stuff
@wraith rapids oh one more question
if i make a hashmap
do i need to make a seperate one for each extended class?
or does having it just be <String, Weapon> enough if Weapon is extended in said classes
A map of Weapon objects can store subclasses of Weapon just fine as well
oh perfect
since each class extending Weapon is, by definition a kind of Weapon, just one map is fine
thanks guys
that is one of the big advantages of oop and polymorphism and shit
there are all sorts of rectangles, and all squares are rectangles, but not all rectangles are squares
likewise, there are all sorts of Weapons, and all Flamethrowers are Weapons but not all Weapons are Flamethrowers
this is why whenever you're extending a class, you can never remove anything from it
you can't remove any functionality
the fact that if i just did this i wouldnt have spent a week of work for nothing
you can only modify and add
which then translates to that we can have a Weapon, and not care what kind of Weapon it is
since all things that extend Weapon must provide at least the same things that Weapon itself does
this look like what u mean?
oh minus the player and boolean at the top i forgot to remove them
yeah
foremost, you aren't actually checking whether the map returns anything
if a map doesn't have a matching key, it returns nothing
aka null
in python or whatever this would i guess roughly translate to a pointer that doesn't actually point at anything
so, you'll want to check whether weapon is null, that is, whether the variable named weapon points at any object
this?
better, but now you're doing two lookups in the map, which is inefficient
you can have a variable with no value, an 'empty' variable
so i should do if weapon != null instead?
myes
alr alr
also, take heed of what the IDE is telling you
yellow underlining indicates a warning
hover over it to see what it is about
quite a few methods can return nothing
for example the event.getItem() method might return nothing
which would then make the item variable empty
fuck thats true wait
and when you try to call .getItemMeta on the object in that variable, it explodes
because there is no object in that variable
When is ItemMeta actually null? It seems to be for AIR, but that's the only one I've noticed so far.
only for air afaik
not sure about VOID_AIR and CAVE_AIR, but probably null for those too
u should figure out a way to monetize it bruh people would pay the shit outta u
yep gotcha
How do I capture the output of the console?
hi, i'm pretty stumped on how i add a soft dependency (KingdomsX) to my plugin. i'm using maven, and when i make the dependency's scope "provided", i get a ClassNotFoundException for all of those dependency's classes on runtime if the soft dependency is not installed on the server. i added Kingdoms to my plugin.yml's softdepend list. i have added several other softdepends which are "provided" as well, but they work fine; the issue is only with this plugin. does anyone have any clue as to why this is happening? or is this a problem with the KingdomsX plugin?
How to make this speedrunner variable public tough?
public class AddRunner implements CommandExecutor {
private Main plugin;
public AddRunner(Main plugin) {
this.plugin = plugin;
plugin.getCommand("runner").setExecutor(this);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
return true;
}
Player player = (Player) sender;
World world = player.getWorld();
Server server = player.getServer();
Player speedrunner = server.getPlayerExact(args[0]); // how to make this public?
return false;
}
}
why does bukkit snakeyaml not support list of configuration sections :(
Anyone know of a good way to calculate how fast a tool can break blocks? I don't really care about what the block is since I want to use it as the speed for a custom break animation and I can adjust the speed, I just want the speeds between pickaxes to be relative.
actually
@worldly ingot do you know if bukkit can get a list of configuration sections
(snakeyaml seems to support it)
yes
iirc I use it in VeinMiner
returns a List<?>. Iterate over the objects and check if instanceof ConfigurationSection
save it to a public instance variable
I can't
is there a way to call the autocomplete without having a command?
i.e. the one just from chat that completes player names? no
does Server#createBlockData(String) work like Bukkit.createBlockData("note_block[instrument=banjo,note=3]");
Yes
ty
hey guys, what's a good listener that gets triggered every time a mob gets damaged? Would that be the entitydamageevent that gets triggered?
Everything in Bukkit just directs to the Server methods, dlg
Yes, EntityDamageEvent gets called cowa but there are more specific events if you want. e.g. EntityDamageByEntityEvent
thanks man
public void creatureDmg(EntityDamageByEntityEvent event) {
if (event) {
System.out.println("mob damaged");
}
}```
This is wrong but I'm hoping someone can help me with this logic
Will the function get triggered once the entitydmagebyentityevent is called ? I'm guessing I don't need the if statement?
don't laugh! I'm trying bruh
lol
You don't, right. If you were to delete that if statement entirely, that method will get called every time an entity is damaged
Though you have to register the event as well
public class YourPlugin extends JavaPlugin {
@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(new MyEventListener(), this);
}
}
public class MyEventListener implements Listener {
@EventHandler
public void creatureDmg(EntityDamageByEntityEvent event) {
System.out.println("Entity was damaged by another entity");
}
}```
That event will provide you with the information you need
Entity damaged = event.getEntity() for instance, you can operate on damaged which is the entity that received the damage
o/
next random question, I see commandsender has a getName method. How can I reference the mob getting damaged and get its name within the method defined?
I need to find a way to identify the entity getting damaged first then drill down into its getname event?
I just want the name of the entity, not sure If I'm looking for type instead? ex: cow, zombie, chicken
ah yes entity type it is
how to check what item a player is holding?
I think what you want is getMainHand()
that's within the humanentity
not quite
That gets the hand that the player uses as their main hand in their client settings
player.getInventory().getItemInMainHand() will return you the ItemStack in their hand
Choco wb! question, I'm trying to spawn a mob at another mob's location (the one getting damaged). Location loc = event.getEntity().getLocation(); spawnEntity(loc,EntityType.ZOMBIE);
spawnEntity is getting flagged saying it's undefined
Yep. spawnEntity() is a method defined by World
Where do you think you might be able to get a World instance from?
Well, yes, but you still need an instance of it
lol ok
Much like how you get the entity with event.getEntity() to get an Entity instance
Where might you think you would find a World?
Player is one of them, or the entity that was damaged
all Entity instances have a getWorld() method
oh yes better
Additionally, even that Location has a getWorld()
loc.getWorld().spawnEntity(loc, EntityType.ZOMBIE);
That would work too though!
yours is cleaner though 😛

question, where can i get a list of all entities? i want to randomize which one is spawn
Has it ever worked with CustomModelData?
Do you know how to generate a random number?
can I just make my own list of entity types?
If you're not sure how to generate a random number, a quick Google search for "generate random number Java" will yield good results
Though EntityType is an enum and all enums will declare a static values() method which gets you an array of the elements
oh juicy
i can get something random from that array
So access that array at some random index between 0 and that array.length, you're good to go
Worth noting that not all entities are spawnable though

SecureRandom or Random
ThreadLocalRandom is also an option. Again, Google is your friend there
SecureRandom is a tad overkill here tbh
overkill is good yes

lmao
I'm making a Totems Effect plugin and I want the output totem to be the specified CustomModelData
This is the code that I am doing, also I am very nevo in this hehehehe
no
The Effect appears but not the totem with the specified modeldata 3 ...
h
Code looks fine otherwise
quick question! how would i go about converting a string like "STONE" to something equivalent to Material.STONE?
Material.matchMaterial(String)
nice thanks
null if it doesn't exist
epic
Choco he's trying to make a totem fly around the user
but a totem with a custom model data, does the api even provide a way to do that
honestly no idea
Yes it can but I don't know how to do it
But if i found this
is there a convenient way to convert JSON into some sort of table that can be accessed via code?
{
"Thing1":"yeah",
"Thing2":{
"Hello":1,
"World":2
}
}
JSON.Thing1 //yeah
JSON.Things.World //2
Maybe Jackson databind
Gson is shaded into Bukkit
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.
https://www.baeldung.com/gson-string-to-jsonobject @scarlet lintel
It is but it is very obfuscated
Oh I see
Question, how can i make a variable of the entity that just spawned here? seems like it's of type loc and not entity loc.getWorld().spawnEntity(loc,EntityType.ZOMBIE);
It seems it just sets the item in your offhand before it plays the effect
They temporarily set the item in the hand to the totem with the model data, play the animation, then set it back
Yep
That spawnEntity() method returns the Entity instance for you
You can just assign it
I'm trying to do Entity newMob = loc.getWorld().spawnEntity(loc,EntityType.ZOMBIE); newMob.setHealth(5);
Doesn't like it, says it's undefined for type entity despite importing damageable
Examplee
Oh, it has to be a LivingEntity, cowa
You can cast it as such if you want
Or, use the generic spawn() method instead
hmm
Zombie zombie = world.spawn(location, Zombie.class);
zombie.setHealth(5);```
oooo
Using spawn() instead and a Class will return the exact type you spawned
That way no need to cast it
Reason Entity doesn't have setHealth() is because things like item frames, items, boats, etc. are all entities that don't have health
LivingEntity* however, does
makes sense
how do I give an item an enchantment but hide it in the lore? I tried setting the lore after the enchant but the enchant effect is lost. if I do the enchant after, the name shows in the lore
Cannot make a static reference to the non-static method spawn(Location, Class<Zombie>) from the type World
thanks!
i feel like im getting burnt out lol so many changes
Good tip for you by the way cowa. On Google, if you search "<insert question here> Spigot", you'll probably find a thread on the Spigot forums answering your question
Especially a lot of the beginner ones 🙂
sorry yeah i should do more of that
i just have the docs open and you guys while coding
ill use google more
Is oki. I don't mind answering questions at all, but a lot of them are definitely already answered 😄
thanks!
choco hows the doggies doing
gud gud. doggoing like usual
thats good 😄
ummm? can any1 help me, i want to add placeholder (like %vault_eco_balance%) to my plugin, i have hooked to papi but no luck :/
are u sure u followed everything step by step?
yep
oh yes i know where im wrong
import in another file and call it in other
PlaceholderAPI.setPlaceholders()
any1 tell me more abt this or give me some documentations
should i check to see if they're alive to make sure i don't spawn an armor stand vs a zombie/chicken?
Hi guys, I'm trying to teleport an entity using the https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Entity.html#teleport(org.bukkit.Location)
I'm trying event.getEntity().teleport(event.getEntity().getWorld(),2.0, 5.0, 3.0); but it seems to be referring to the other method which asks to specify PlayerTeleportEvent.TeleportCause cause. Any ideas how i can just specify a location to teleport the entity away?
savage
Let's hope this works lol, no errors in code atm
event.getEntity().teleport(new Location(event.getEntity().getWorld(),2.0, 5.0, 3.0));
World.getName() = the folder* name right?
Folder name
meta.getStoredEnchants();
Why can't I use this method? It doesn't appear on the list.
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/meta/EnchantmentStorageMeta.html#getStoredEnchants()
thanks
one last question for tonight, i'd like to kill off an entity with the damage method within Damageable. So I tried event.getEntityType().damage(10.0) but it's not working. The method damagable(double) is undefined for the type EntityType
any tips? 🙂
also, idk if i can use the sethealth method because some of the entities may be not alive (zombies)?
getEntity not getEntityType
hmm still nothing @sullen marlin
and derp i should've noticed that
event.getEntity().damage(10.0);
maybe it's not damageable
the Entity has be an instance of Damageable
be sure you import the correct Damageable
gotcha, hmmm what's the best universal way to kill all types of entities? or would i have to include if statements for those who are damageable and/or those who i can set their health to 0?
oh there's more than one?
import org.bukkit.entity.Damageable;
i imported the entity one
?jd search for damageable and you will see
package index
lol
Hey ! Trying to change the portal location of an ender dragon if someone know how to do it : )
how can i get the name of a player that sends one command, in another command?
Player player = (Sender) commandSender
player.getName()
When you call a method in a other class from your onCommand method ?
ill try it thx 😉
oh okay so i want to "save" the name of the sender of one command. Then i want to get the name in another class (another command)
@grim sage
Hum
I see
so you can create a variable in an other class, when the command is executed you put the name in this variable like this
1st in your command class
YourClass.setPlayerName((Player) sender)
And you will be able to get it in an other class with
2nd In the class you wan’t use the name
YourClass.getPlayerName()
Of course your storages classe have to be setup like this :
3rd In what class you want, like a manager or a utility class for example
Private static String playerName;
public static String getPlayerName(){return playerName;}
Public static void setPlayerName(Player player){playerName = player.getName()}
How can I get an enchantment card from a book? How can you put an enchantment card on a book?
Hey ! Trying to change the portal location of an ender dragon if someone know how to do it : )
Do you mean teh portal that spawns when it dies?
even onDisable
what are you trying to achieve
yes
i have tried unloading the world onDisable
very unreliable
sometimes works
sometimes doesnt
WorldSaveEvent and ChunkUnloadEvent.
WorldSaveEvent?
Not cancelable it seems
Try listening to the ChunkUnloadEvent and call
setSaveChunk
e.getPlayer().setHealth(0);
}
```
This tries to kill the player until he is out of water, So I just want to kill him once... Can someone help
if (!e.getPlayer().isDead()
Thanks
okay
setSaveChunk isnt a thing
its 1.8
shoo
how can i say that a player can only execute the command once after a reload?
does Bukkit.reload() reload the server? like /rl?
package index
thx
if (!p.hasPermission(getPermission())) {
p.sendMessage(getConfigString(plugin, "no-permission"));
return;
}```
i have permission
this isnt working
is this for a command?
The direction where he fly when he is circling
No you can't change it
You can not change the portal location. You can mess with the AI
Hey Does anyone know how I can add custom skulls from Minecraft-Heads.com to a newly created inventory in Spigot?
Hi i'm trying to move a file to the server folder but it tell me that "the process cannot be access cause it already use by an other process"
private void moveFile() {
File source = new File(folder + File.separator + "map" + File.separator + "Daedalus");
File target = Bukkit.getServer().getWorldContainer();
System.out.println(target.getAbsolutePath());
System.out.println(source.getAbsolutePath());
try {
Files.copy(source.toPath(), target.toPath(), StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
e.printStackTrace();
}
}```
Why are you trying to replace files?
you'll have to fully unload the map first
the map doesn't exist yet in this case
hey good morning! Im currently in the progress of making a minecraft network for my school. but i want to use multiple servers with a bungeecord connection. that part is easy. What i now want to know if its possible to save minecraft world in a folder, that other servers can access
here i'm just trying to move a file to server folder nothing else
after i will load it
If it says the file is in use then its already in use
but the file doesn't exist yet to
You should move to #help-server. An why do you want to share world between servers. That can cause issues, it's better to just copy the world
what does the error say? exactly
i'm trying just to move Daedalus/ file to server file
is that a file or a folder?
folder
"The process cannot access the file because this file is in use by another process"
because i want to distribute the players to the servers, so that not all players from my school are gonna be send to one server.
Yeah don't use the same world use copies
debug and find out why it says its in use
oh okay, and could i maybe use a database that saves all the world files?
so that it saves it, then copies the world over to the server. and then loads that world?
but why
Yeah you're accessing an argument that doesn't exist
Intellij even warned you
Why did you ignore that warning
oh thanks
okay. my plan is to save the worlds on 1 file server. then let spigot access that world via a connection. when a player wants to invite another player to the world and the server is full, i want to unload and save the world, transfer both players to a diffrent server, then load that map on the new server, and teleport the players to that world
What why would you do that
There is no reason to create a new server with the same world. Just let the invited player join the server that's already running
so i can let 5000 player play on one server, from my past knowledge its not smart to let 5000 players on 1 server, which hosts all the world thats gonna lag really badly so i want multiple server which can contain those players split over multiple servers
the school im working for is really really big hahaha
Yeah why are you planning for a huge network 5k players already. Also your solution will be quite bad when it's running
ohh, lets go to #help-server
Yeah
can somebody help me?
how do you mean?
So you have to use this url from the head to get it into the plugin. But with which lines of code can I put the skull as an item in an inventory?
?jd
package index
thanks
but I also roughly know how to create an item. But I don't know which lines of code can be used to put a custom skull in an inventory
so you should probably create a cache to cache the textures fetched from the database
or like head texture thing
ok i will try, thank you
is it normal that Player.sendTitle is deprecated?
package index
What's the "right one"?
Look at the JavaDocs
The method sendTitle(String, String) in the type Player is not applicable for the arguments (String, String, int, int, int)
player.sendTitle("Spawn", "Welcome to the Lobby", 30, 150, 30);
What i'm doing wrong?
What version are you on?
1.8*
Yeah you might have to use the depricated method
Since you're way out of date
You should concider updating
I'm making a PVP server that's why
It's time to move on
iirc there's a TitleAPI that works for 1.8.8 which has a method that can specify the fade in, duration and fade out
You move on and learn new things like the 1.9 combat...
Cool
and if you're just going to copy other servers you're not going to get anywhere
Damn I cannot even ask for help to create a PvP server for my friends and me? I just asked for a question for sending titles
And we awnserd
We've told you what to do
(Use the depricated method or install the TitleAPI plugin)
I'm using the TitleAPI Plugin, thanks.
You can use packets & avoid using any apis
I'm good with the TitleAPI
Or just use an api to avoid nms
^
or just don't care about using nms because he'll stick with 1.8 regardless for previously mentioned reasons
🤷♂️
Why is NMS better than using API
or API better
I didn't say it's better, I just prefer not using API's because I like to keep my additional resources small
I mean at the end both alternatives have pros and cons so yeah can't really blame anyone
imagine if in over half a decade literally anybody would have forked the 1.8 spigot and backported any new api to it
How do I check to see if I'm on the team I created on the scoreboard?
By the way, the version is 1.16.5.
team.getEntries().contains(player.getName())
Hi again, how can we delete blocks 10 seconds after it got place? I mean when someone places a block, just delete it after 10 seconds. I know how to use the BlockPlaceEvent, but I don't know how can we "wait" 10 seconds, anyone can help me?
Look into BukkitRunnables
How to do, so that pet follow to the player
You might have to inject a custom goal into that entitys goalselector
^ sounds like a NMS thing
I looked about it but how can we start the run void when the BlockPlace event triggers
it has a method called runTask(Plugin)
You can use smtng like this
Bukkit.getScheduler().runTaskLater(JavaPlugin.getProvidingPlugin(this.getClass()), () -> {
//delayed code
},20L*10L);
yeah
use your own instance
I mean most likely your plugin class loader will be the one loading that class thus the instance of your plugin will get passed but dependency injection would be better
is it possible to print in the consol on the same line ? (i test with \r but don't work there still a line return)
for a progress bar
System.out.print()? if that doesnt work then idk
System.out.print("Progress : |" + progressString + "| [" + progressPercent + "%] | xxkB/s \r");```
and only print when a line return is done
arent you supposed to start with \r
how would i check if a item is a block (no half slabs, signs etc...)
change nothing
Might wanna try PrintStream#write instead
how i use this ?
I'm trying to make a custom anvil recipe by changing the output slot of the anvil with the PrepareAnvilEvent. The issue is that when there is no result in the anvil initially the player can't take the output item even though it shows up. Any clue how to let them take it out?
you need to handle playerInventoryClickEvent too
when player click on result it clear the anvil and setCurrent item to the result
only set result don't work
it's only "visual"
Is there a way to handle that one without having to move the click the manually? There are a lot of different click actions and I'm trying to avoid having to reimplement them all so that I don't break it.
you don't need to handle all only shiftclick and click
how do you run a class on player join?
declaration: package: org.bukkit.event.player, class: PlayerJoinEvent
you can't run a class
^
sorry haha im mega new to java
Lol
just dont know the names of stuff yet
It’s fine
to init PrintStream it required an outputstream or a file but here i only have a string
you can't run a class but you can call a function
Get type or use a translatable text component
thanks
You can only get name in ItemStack form. Placed blocks don't have a name
okay i succeed to init it but when i write it only write ALL line at once with again no \r
\r ?
you need \n\r
and don't right while process is running
as it depends which system you are on
nop i don't want line return
i wanna replace the progress line
well \r is return o.O
nop \r doing a carriage return (come back at the begining of the line)
and \n do a line return (go to next line)
what console are you using?
good question
using the mc console ?
got it
not entirely sure if the MC console respects \r or not
even so, it still matters on the console
if the console doesn't support it, then you are stuck with making a progress bar vertically more so then horizontally. Or just periodically print the progress instead
obviously you discovered that to not be true
i do wanna test that tho
it could mainly be because of the logger more so then the terminal
Spigot seems to do some cursor manipulation that the default game doesn't
the logger causing the terminal to have a new line on anything printed
cursor manipulation in what way @silk tusk ?
the only thing I see that touches anything with the console is the logger
if you do test it, try a test without the logger @severe folio
aight
log4j does quite a bit with how everything is outputted
I'd like to know in IF minutes
When you type commands in the console it lets you use the arrow keys and tab complete
that is brigadier
hi, is there a way to create a placeholder without suffix? for ex. %name% instead of %name_whatever% with PAPI?
Does anyone have a code snippet to get a player head itemstack from a skull blockstate? I dont want to dig into that stuff. This doesnt work btw:
public static ItemStack itemFromBlock(final Block block) {
final Material material = block.getType();
if (material != Material.PLAYER_HEAD) {
return new ItemStack(material);
}
final ItemStack head = new ItemStack(material);
final Skull skull = (Skull) block.getState();
final OfflinePlayer skinPlayer = skull.getOwningPlayer();
final SkullMeta meta = (SkullMeta) head.getItemMeta();
meta.setOwningPlayer(skinPlayer);
head.setItemMeta(meta);
return head;
}
paper has get/setPlayerProfile. Spigot does not complete gameprofiles for offline players so they are not copied to the skull
if you want to actively copy it over, you'd have to reflectively copy over the profile and serializedProfile fields
im tying to make an aternos server for 7 people and i found the coding at this the website so i need help in installing this coding
can someone help me please
is there an event fired when a shield is disabled?
Why would you want to?
^
would like to randomly do stuff ahah
if there isn’t an event fired whats the best way to detect when a shield is disabled?
have you tried the playerItemBreak event?
is the shield set as broken when its disabled?
that would make sense ig
im looking to extend/change the cooldown of the shield disable thats all
@kind coral Well first you learn git then go to stash and clone the repo then learn java and make your changes
?stash
yes i already done that
just searched up on the forum where i could find the stash
just used buildtools
do you wanna upstream
sorry for the childish start most people asking this question are 9 year olds who dont even know what git is
wdym
nvm then
Do you want to be able to submit pull requests?
or is it for personal use
if you dont know how to get spigot's source, you probably shouldnt be messing with it
?stash
so hard
What will an asynchronous method give me? I load data from the database, if this method is asynchronous, then it will not hang if the server hangs?
it is run on an asynchronous thread
Yeah it won't freeze the server
it may or may not hang, regardless of the server's state
threads can hang depending on what you do on them
A large number of requests will be sent to the database!
Hey there I could use some help with my DAO. I always end receiving this exception:
[14:46:06] [Server thread/WARN]: java.sql.SQLSyntaxErrorException: (conn=1183127) Could not set parameter at position 2 (values was 1)
My DAO looks like this:
@Override
public boolean insertUser(UserDTO user) {
Connection connection = DatabaseHandler.getDbConnection();
try {
PreparedStatement ps = connection.prepareStatement("INSERT INTO Users VALUES ('?', ?)");
ps.setString(1, user.getUUID());
ps.setInt(2, user.getXp());
int result = ps.executeUpdate();
if (result == 1) { return true; }
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}```
It says that line 7 here is the problem and my Call looks like this:
@EventHandler
public void onJoin(PlayerJoinEvent event)
{
/* UserDTO user = new UserDTO(event.getPlayer().getUniqueId().toString());*/
if (event == null)
{
Bukkit.getConsoleSender().sendMessage("PlayerJoinEvent is none!");
return;
}
String UUID = event.getPlayer().getUniqueId().toString();
UsersDAO usersDAO = new UsersDAOImpl();
UserDTO user = usersDAO.getUserByPk(UUID);
if (user == null)
{
user = new UserDTO(UUID, 1);
if ( !usersDAO.insertUser(user) )
{
Bukkit.getConsoleSender().sendMessage("Could not find, nor create the user with UUID " + UUID + " in the database");
}
else
{
Bukkit.getConsoleSender().sendMessage("User with the UUID " + UUID + " was created in the Database");
}
}
else
{
Bukkit.getConsoleSender().sendMessage("User with the UUID " + UUID + " was found in the database");
}
}
when handling an InventoryOpenEvent how can I see if the opened inventory is an enderchest?
I tried inventory == player.getEnderChest() but that doesn't seem to be working
line 7 is Bukkit.getConsoleSender().sendMessage("PlayerJoinEvent is none!");?
@valid vigil Inventory#getType
oh, thanks
@candid galleon here is my stacktrace
I was refering to my first message so the line would be:
ps.setInt(2, user.getXp());```
what type does getXp return?
Integer
I will
@candid galleon same error, only the line java.sql.SQLSyntaxErrorException: (conn=1183127) Could not set parameter at position 2 (values was 1) changed to
[14:59:50] [Server thread/WARN]: java.sql.SQLSyntaxErrorException: (conn=1183764) Could not set parameter at position 2 (values was 0)
Yes I am already sitting on this problem for a few houes
I need these bc the UUID contains "-" and mariadb/mysql cant handle these without putting it in ' '
youll have to look into mariadb drivers then
looks like youre using native drivers
Nah I use the MariaDB driver
oh yeah i see that
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.7.3</version>
</dependency>
I use this dependency /version of mariadb jdbc
when does ItemStack#getItemMeta() return null?
what's the error when you use it without the 's?
AIR
there might be other edge cases, but AIR will return null
Ok I have to admin I dont know how this happend. you were right @candid galleon it works without the ' '. I thought that it didnt work and I found out that I need these. Maybe I miss understood one of my Errors and then applyed a wrong solution
So thank you a lot I wasted to much time on this xD
❤️
nice 🙂 👍
Hello, I would like to ask about the problem. java.lang.NoClassDefFoundError: org/json/JSONObject
I'm using library json but can't run the plugin. this is log (https://pastebin.com/3gSWSfGc) Ty!🙏
Use org.json.simple instead
if use org.json.simple JsonObject / JsonArray can't use anyway
its said (The constructor JSONObject(String) is undefined)
@candid galleon So I was still right xD In my SQL statements, when I use ... WHERE UUID=? I need to use ' ' ... WHERE UUID='?', else it will create problems
But in case I want to insert it I am not allowed to use them
Now it works just fine
I got it thanks
How do I make something happen after a second of being executed?
How can i detect if a hit is a critical hit in EntityDamageEntityEvent?
public void onHit(EntityDamageByEntityEvent e) {
if(e.getDamager() instanceof Player) {
Player p = (Player) e.getDamager();
if(critical) {} // How?
}
}
event.getLastDamageCause().isCritical() I think.
getLastDamageCause is undefined
schedule it.
It's part of the Entity, not the event
Though I'm not certain if that would return the last event or the one you're listening to
^^^^
the damaged
getEntity returns the damaged?
.getLastDamageCause() is defined there but not isCritical
I'm not seeing anything to check for critical actually. might have to do some research on that one.
I Don't think thats the right channel for that
What's the best way to programmatically generate a vanilla structure at a given location?
Is it possible to do without using third-party libraries? (this is a private project)
Otherwise
Where can the vanilla structures NBT data be found on a server?
You need NMS for this. Maybe look at stuff like WorldGenVillage
Hey! I am trying to make a plugin where the recipient can add new lockpicks to a list of lockpicks. In the config I need to make a list of parameters like so
lockpicks:
- item1:
- name: "§aScrewdriver"
- item-type: iron_hoe
- description:
- "description"
- custommodeldata: 1
#the durability indicates the amount of time the user can use the item
- durability: 10
#the efficiency is the chance in % to lockpick, every time the user use the item
- efficiency: 10
But I am not sure if this is the right way to do it because If I retrieve a list from the config called lockpicks I cannot access the name of the objects returned. If there is a better way to do this I would love some help!
im not sure if this is what you mean but... yaml lockpicks: item1: name: "§aScrewdriver" and use getConfig().getString("lockpicks.item1.name")
I want the user to add as many lockpicks as they want
So they can add item1 and 2 and 3 and my code will be able to handle them
hey there so i have this code
https://imgur.com/a/LGWoeFo
but how would i go about getting OverWorldLastLoc transfered to the other if statement?
what does it mean its not assigned? assigned to what
you never gave it a value
my logic is:
when i run the command it adds the items and opens the inv in open()
and then if you click on it it checks if the inv clicked is the one created
this.inv = inv;
}```
its telling me to add this
what are you trying to do
just testing, i would normally check the title and clicked item, but i want to check the invs instead
so its better quality
yea
all that means is that it's never being used
you can just ignore that i'm pretty sure
does anyone know how to use the EntityShootBowEvent
hey there how would i go about passing around an location?
here is my code
@EventHandler
public void PortalCheckOverWorldNether(PlayerPortalEvent e) {
Player player = e.getPlayer();
if (player.getWorld().getName() == "ManHunt") {
if (e.getCause() == TeleportCause.NETHER_PORTAL) {
World w = Bukkit.getWorld("ManHunt");
double x = player.getLocation().getX();
double y = player.getLocation().getY();
double z = player.getLocation().getZ();
Location OverWorldLastLoc = new Location(w, x, y, z);
e.setTo(Bukkit.getWorld("ManHunt_nether").getSpawnLocation());
}
}
}
@EventHandler
public void PortalCheckNetherOverWorld(PlayerPortalEvent e) {
Player player = e.getPlayer();
if (player.getWorld().getName() == "ManHunt_nether") {
if (e.getCause() == TeleportCause.NETHER_PORTAL) {
e.setTo(OverWorldLastLoc);
}
}
}
```the error is at `e.setTo(OverWorldLastLoc);`becuase it can't be resolved to an variable since i have not passed it around
player.getWorld().getName() == "ManHunt"
use .equals() for strings
whts the point of adding
return;
}```
isint the holder always a player? what else can hold an inv?
entire code:
https://paste.md-5.net/homubayaro.java
AbstractHorse, AbstractVillager, Barrel, BlastFurnace, BlockInventoryHolder, BrewingStand, Chest, ChestedHorse, Container, Dispenser, Donkey, Dropper, Furnace, Hopper, HopperMinecart, Horse, HumanEntity, Lectern, Llama, Mule, Piglin, Pillager, Player, ShulkerBox, SkeletonHorse, Smoker, StorageMinecart, TraderLlama, Villager, WanderingTrader, ZombieHorse
All interfaces which inherit the InventoryHolder interface
cuz it isnt a thing compiler can know about
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
dont look at history
using InventoryHolder to compare inventories isn't ideal at all
It may cause weird side effects and the api is not designed to be extended by you
and why does he use HumanEntity instead of player?
