#help-development
1 messages · Page 1650 of 1
world has a method to get the folder
Dependency injection good tho
you can use your plugins data folder to get its parent(s)
Why hyperlink
Yeah you just need to set up the instance in the Main class though
oh
Add this:
private static Main instance;
public Main() {
instance = this;
}
public static Main getInstance() {
return instance;
}
Change Main to your main class name
I’m on mobile so it’s harder or I would of done it
Go with dependency injection tho
Add that to your main class
yea, getWorldFolder, thanks
singleton is so oldschool and wrong
and bukkit already provides this
no need to reinvent the wheel
let alone the example above there isn't even a singleton
that
I don't think that code would really work unless you construct the class
which goes against one of the points of a singleton
?
instance isn't set until new Main()
it is a singleton
but new Main() is public, meaning you can override instance multiple times
its not set until onEnable is invoked
no. he have it in his constructor
oh right
means as soon as bukkit builds the plugin it gets instantiated
yeah thus breaking the singleton pattern
how can i know if a world is overworld, nether or end type?
getEnvironment iirc
which isnt really possible in bukkit since it will throw exception on your head
for plugins essentially
basically what the name says
Represents a custom dimension
in overworld maps the region files are inside world_name/region/, for nether they are inside world_name/DIM-1/region/, and for end world_name/DIM1/region, so what about that custom type?
Represents a custom dimension
would it be smarter to have a key lets say "Economy" and then a hash map with all players and their balance or have it under the players other data? (in a database)
wait wym now
uhh
if you dont just want to have it local you would have to use a database-alike
to cache it a hashmap seems fine
but i would go with OOP
I have a database, should I store all players balance under 1 key or under the players basic data. I ahve no idea how to explain this
wait
what type of database first
now you are confusing me
like a total server balance amount desk?
ok, i have never worked with enums before
time to get learning then!
Arent they just like 1 2 3 but with names instead of numbers?
example:
Economy
someuuid : 522
someuuid : 3533
someuuid : 3263
or
playeruuid
balance: 235
other data..
playeruuid
balance: 633
other data..
that depends on how much data you have to save
the latter makes the most sense for an object oriented language
barely any
the second way is the one i would recommend
the latter is extendable
whats this error mean bro
but are both good ways too go? or is the first one just dumb?
thats only error tho
if your purpose is to just store the balance the first way would be fine aswell
I mean there's no real benefits choosing the former over the latter apart from less verbosity
alright thanks
1.16
see
Not 1.16.5
so no .5
api-version can just be full version (1.16, 1.15, 1.14)
cuz i has the stupid
you has the stupid
yes
Can someone explain why this would be useful, i know nothing of enums..
pinaaple
oh
it gud tho
have you tried it?
yes
cap
what r u trying to do?
def would not pick over salami/kebab but it's not "ew".
Im making a bunch of items, and trying to keep track of them neatly
He suggested i use an enum
pineapple on pizza is great
and idk what he meant
disgusting
hmm yeah well using an enum or not is probably an insignificant choice
I am proud of sweden and kebab pizza
in this case
Well i was asking if i should just have a method to return the item for every item i create, all in the same class/file
Or if i should have every item be created in a method inside its own file/class
how can I place blocks without any server lag?
I think one class is fine
Bet
but it depends on the design here
😳
Location.setBlock(); go brrrrr
by not lagging it 
without lag
"async" nms
or setType
or whatever it is
how in 1.17
bru
ok
someone link 7smile7s post thx
not sure where to look lmao
really...
FAWE
Google your question before asking it:
https://www.google.com/
i have ._.
FAWE’s GitHub repo
i mean in FAWE source
https://www.spigotmc.org/resources/fast-async-worldedit.13932/ i even just wrote "FWE" and got the right link
bruv
Blazingly fast world manipulation for artists, builders and everyone else: https://www.spigotmc.org/resources/13932/ - GitHub - IntellectualSites/FastAsyncWorldEdit: Blazingly fast world manipulati...
i know how to internet sometimes
👍
ty
You'd have to spend an hour at least if you want to read through fawes abstractions and what not
did you mean onEnable() not Main()?
or did you mean to make it a constructor
he mean’t it in onEnable
thanks
he meant dependency injection 😄
i mean puting plugin in every time, or just doing it once...
hold up
nvm im using static methods
i cant do this can i?
then ur main plugin class violates the single responsibility principle if every other class of yours has to depend on your main plugin class
mhhhhhhhhhhhhhhh
i didnt understand that at all..
bukkit actually already griefs the SRP by itself
anyways hyper, its not anything near enterprise of what you're doing so that getInstance() will do fine
it doesnt work since im using static methods
😐
public static ItemStack getWateringCan(FarmingOverhaul plugin) {

HyperLink I guess you could do that
is that not something i should do?
well
Cause why create an instance of the class every time?
Idk I cant see the entire method
thats a bad practice
Im just creating a item..
ItemStack wateringCan = new ItemStack(Material.CLOCK);
ItemMeta canMeta = wateringCan.getItemMeta();
PersistentDataContainer canData = canMeta.getPersistentDataContainer();
List<String> lore = getCanLore(10);
canData.set(new NamespacedKey(plugin, "isWateringCan"), PersistentDataType.BYTE, (byte) 1);
canData.set(new NamespacedKey(plugin, "waterLeft"), PersistentDataType.INTEGER, 10);
canMeta.setDisplayName(ChatColor.DARK_BLUE + "Watering Can");
canMeta.setLore(lore);
wateringCan.setItemMeta(canMeta);
return wateringCan;
instead you could create it one time and store it as a class variable
if you have like a set of items then you should probably have a registry
what..
or use an enum
👀 enums in 2021
enums are lit
just stick with godciphers solution, not working with independent deployment or smtng anyways
just dont use it as a dependency magnet
?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.
Cause enums are just like a list of numbers with names right
like
if you were to do a switch statement
tbh enums that create items are pretty trash ngl

didnt mojang use an enum as registries back in the days?
myes
if your enum creates item stacks on init you can't even touch that class in unit tests
the enum that used to crash ides
or you explode
yeah, the spigot enums
ah yes
only way you could remotely do stuff like this pre hardfork would be a fat fat bytecode rewrite of half the plugins xD
kind of defeats the speed aspect of the fork
good point
The material Enum likes to crash my IDE
Wait, i could create my own object that has the item information getters. Then just make an item creater and use the object and its values to create an item that way no?
I was considering jumping over to sponge until they started keyfying everything
Fabric
meh sponge is pretty overkill in their API design tbh
kashike does pretty overkilling stuff
Like an interface connected to a bunch of classes, with value getters
yea
suppose its better than some underengineered design
has the advantage of being pretty future proof
would that be too much?
yeah indeed
ah then I am up to date at least
not like I am that useful
nor do I really know anyone besides commenting on github PRs xD
lol well someone has to do that 
I still think fabric is a good way forward for servers
idk I just gotta get in touch with the people 🙂
I will inject you conclure
What framework are you using?
I used to like fabric
but they're bumping yarn frequently with pretty unjustified refactors apart from "I love these refactors"
As you can probably tell its a disaster when using libs during dev tests
I think spigot api is gonna be the best baseline ¯_(ツ)_/¯
tho tbh, major breaking changes need to happen
btw do u have ur code open source?
yeah, I suppose paper will yeet the string methods as soon as they hard fork
🙏 Yea hopefully. It is already at the point where either your plugin will update to the newest version pretty fast or it is just not maintained anyway
see the 1.17 NMS changes
a LOT of plugins had their issues, but all of the maintained ones updated already
oo yeah
Remap reflection wen
Some things are private
And we don't have access transformers
mixins wen 😛
aye
And then I can make my pistons push everything plugin
what in the hell is "CAVE_AIR" and "VOID_AIR", is void just like damaging air?
No blocks exist in the void
Speaking of pushing blocks, is it possible to make blocks get pushed (without a piston) with a plugin?
I honestly don’t know how void air works
what about cave_air
Caves
I think light level is also used for that
No idea, it used to be anyway
Cave air is useful for terrain generators
And if you fill it with water you can go for a nice swim
class ItemRegistry {
IdentityHashMap<Class<? extends Item>,Item> map = new IdentityHashMap<>();
<S extends Item> void register(S item) {
map.put(item.getClass(),item);
}
<S extends Item> S get(Class<S> type) {
return type.cast(map.get(type));
}
}
@FunctionalInterface interface Item {
ItemStack supply();
}
class HeroSwordItem implements Item {
Plugin plugin;
HeroSwordItem(Plugin plugin) {
this.plugin = plugin;
}
@Override public ItemStack supply() {
//do whatever u want here
}
}
class MainPluginClass extends JavaPlugin {
@Overrie public void onEnable() {
ItemRegistry registry = new ItemRegistry();
//register items
registry.register(new HeroSwordItem(this));
//then to access HeroSwordItem
ItemStack stack = registry.get(HeroSwordItem.class).supply();
}
}```
@somber hull You could have something like this
and sorry for the spoon
Hello everyone !
I'm trying to setup a custom config and I'm trying things with spigot config file...
I'd like to change a value in the config file then save it, but It doesn't save idk why ... 😦
mainConfig.set("test.enabled", true);
try {
mainConfig.save(new File(this.pluginTest.getDataFolder(), "test.yml"));
} catch (IOException e) {
e.printStackTrace();
}
Please ♥ 😦
What do you need ? x_x'
the entire class is always a good start
I won't, it's not for me so I can't give codes like that 🤷♂️
And these 2 lines are the only one I use with config
well nothing is wrong from the snippet you sent me
Ah 🤔
Thank you :/
that said it is guaranteed a bug outside that code
or for that part just something you missed
cheers
Hi
Anyone knows why i my ide dont detects the api where im using?
this show me when i try to build
i added the .jar to the libraries
you are using maven to build and manage your project
adding things to your libraries manually isn't going to work out too well
how i can add the api correctly?
by adding it to the pom.xml like any other library
concerning this is your own api, you will have to install it into your local maven repo
run mvn install in the project root of the API you are trying to use
ok...
Yea it is sadly a bit more complicated to work between multiple projects than the minecraft development plugin just nicely setting things up for you 😭
i get this
that seems to still be in progress
give it some time
if it fails, maven usually is quite good at spitting you a stacktrace
Who the hell inlines their annotations like that 🤢
I bet you do
@CommandHook("thing") public void thing(CommandSender sender) {
}```
@Override
public String toString() {
//
}```
Yeah that's the only acceptable inline annotation
I never use those though lol
Bad
Oh hey rack quick question
Were you one of the people who objected to a plugin dependency command framework
whats the api equivalent for the /save-all command?
if no chunk has been modified, will it write to or read from disk anyway? i mean, it will be slow or not if there is no chunks modified?
Bukkit.getWorlds().forEach(World::save);
Probably this
Not 100% sure though
Of course, you could always just Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "minecraft:save-all");
beep
what this icon mean?
i have added an .jar to the libraries but i get this icon
the other api's have the first one
so to create a second command do i have to create a whole 2nc @overide or do i just start at the if statement below that
I don't really have time to test it out, but does anyone know if Bukkit's ServiceManager can be used in the onLoad method? Trying to register manager classes without worrying about load order
Hmm try and see actually.
If it’s your api, just have one context interface and the a concrete implementation to it
Well, I imagine Bukkit is loaded before plugins so I don't see why it wouldn't be. I'll just see if it does when I actually deploy everything for testing 🙂
Idr but it might be the case that onLoad is invoked before Bukkit::setServer is called
Personally haven’t needed to try it out so would appreciate if you could let me know about your findings
World#save() is sync, right?
Probably depends on where you would calll it
You use a second if
But doing commands that way is very ugly
Basically everything is sync unless it explicitly says otherwise
is there a better tuturial
No I mean that's basically the way you have to do it unless you use a command framework
I have a good one you can use if you want
😌
And it's SHADED now
even if it is, i dont think thats the problem, im trying to delete mca region files, but for some reason, File#isFile() returns false, and therefore, i cant delete the file, even tho it actually exists, im seeing it, even before calling the method that tries to delete it. is there any way to make theFile#delete method show me the reason why it cant delete a file? instead of just returning false
So you won't need a plugin dependency
~~idk wha that is so uhhh ill pass sorry
~~
the ide says something about java.nio.file.Files, but i cant use that bc its private, or something like that
I don’t know frankly, I stopped using File long time ago
Files is just a helper class for Path
what do you use then
If you're gonna do it the standard way at least use CommandExecutors
what should i use
Path (:
mmm
Wait are you trying to delete a file or just save?
now im trying to delete
Delete a world?
no, just some specific region files
so copy the first if and then change some of the custimizations?
That’s probably disastrous in a sense to achieve
Basically
But I'm telling you, there is only pain down that road
At least use CommandExecutors
Cause you’d need to save the world, unload those chunks corresponding to the region files and then pray it to make those chunks actually unload.
im already doing that
Why are you trying to delete region files
im just using eclipse idk what that is i guess google it is
^ also a good question
It's part of the standard command library
bc im generating chunks, and only 1 will be used at the end
can i discard the changes somehow?
Yes
or do i have to restart the sv
Disable auto save for the chunks
ok, sounds good, how can i do that
And set them to not save in ChunkUnloadEvent
If you really really need the world to not save changes then you can also unload the world without saving on shutdown
i can set autosaving independently on each chunk?
You can choose per event
So you can listen for ChunkUnloadEvents and tell them to not save if you don't want them to
ChunkUnloadEvent#setSaveChunk(boolean)
do i need to set autosave false to the world if im stopping it from saving in that event?
or its bc it can save the chunk even if its still loaded
I'm not sure about autosave but if you don't want the world saving I would set it to false
Not fully sure but I think autosave saves loaded chunks periodically whereas they otherwise only save when they're unloaded
Dunno
when a chunk is unloaded, it will always be saved, right?
wouldnt make sense otherwise, i think
unless the chunk didnt change, that would be nice, but i dont think thats how it works
Unless you set it to not save, I believe so, yes
Can someone help me please
I got this error:
Im trying to connect to a server on my bungee cord world and its not working
Just to say all of my other bungeecord servers are working correctly
do the touch handlers not work anymore in holographic displays api?
Hey i am using multiverse core and I want to use /summon from the console. Is there a way to specify the world? Or, since it is a vanilla command is that not an option?
kits:
no:
items:
AIR:
slot: 0
armor:
AIR:
slot: 0```
why when i try to do this:
```java
ConfigurationSection kit = kits.getConfigurationSection("kits." + name);
ConfigurationSection items = kit.getConfigurationSection("items");```
does it say "kit" is null
name = "no"
?
ConfigurationSection items = kit.getConfigurationSection("kits." + name + ".items");
with teams you can do ordering
ik
im doign rn
gyys
i made a method to convert name to uuid
for making a team
but longer then 16
niow i wanna die
bcuz took em ages
Caused by: java.lang.IllegalArgumentException: Team name '4124ca7131b046dcb2e55eea68e47a94' is longer than the limit of 16 characters
getting a problem where i have an multiple if statements and in these statements i have event.setCancelled(true); and the first 1 works, but if the second case happens, the event does not get canceled, but everything else in the if statement works (does happen)
k
if (statement) { event.setCancelled(true); do some other stuff... } else if (statement) { event.setCancelled(true); do some other stuff... }
the both if statements work fine, but only cancels the event on the first one
everything else about them work fine
only cancels if the first one is true, if the second one is true, it wont cancel but will do everything else.
is there a
way
to
loop through all teams
and
then
unregister
Hey there,
what's the name of the packet for changing sign data(sign lines)?
where can I find placeholder API action bar plugin
huh
yes
tf is that supposed to mena
what
tf is a placeholder api action bar plugin
really big
assuming u mean a plugin to change action bar that supports papi?
yes sorry english
k
i have image for example
Sign#setLine()
thanks cimex
thanks so much
I said packet not a bukkit method
thanks anyways I found it myself
nvm i solved my problem aswell
who knew programming was legit just problem solving. 😅
how to rename a configuration section without deleting its child sections?
why aint the spigot web API updating?
Which of them are you using?
why??
I currently use
if(target == null); sender.sendMessage("This player isn't online or doesn't exist!");
I have also used if(!target.isOnline blah blah blah)
Remove ;
On if
And return or prevent the other code from running
!target?
I’ll look at this. I’m on my phone rn and it’s 1 am
jk i knew that
for (String string : config.getConfigurationSection("warps." + warp).getKeys(false)) {
config.set("warps." + message + "."+string, config.get("warps." + warp +string));
}
ez
Send your entire code
entire class?
Method or class
does config.set create a new section if one does not already exist
like
config.set("lol.lol" , "e");
what if lol.lol didnt exist
only lol did
You still need the null check
will it make a new one and set it to "e"
pls someone say yes or no
Send code with null check
i have to put it in that thing?
config.set("newWarps", config.getConfigurationSection("warps))
No
ah
You need to stop the other code from running too
Then delete the old warps section
by return false?
my config looks like:
warps:
e:
b:
a:
That's one way
yes, you wanted to rename a config section
thats what you showed
w ha t
config.set("warps." + message + "."+string, config.get("warps." + warp +string));
i showed that
.
i replaced this return with return false
yeah but the configuration section in my case is a child section
that also has child sections
does player persistent meta transfer over a bungee network?
if not i have to learn mysql
no
You might have missed a .
anyways
wait i will ask for help in 5 mins
if i need any
is there an opposite of null?
okay i have tried all possible combinations i know, and still it gives me null
yes
It already was in code tho
Where is your null check?
hm
stoopid question but
where to put it
cause i put it in the uh
the offline message place
and deleted it soon after
You put your null check straight after you get the target variable
Player target = Bukkit.getPlayer(args[0]);
if(target == null) return;
ahh
ok
sorry for asking for the plane to go into the mouth
(aka spoonfeeding)
yeah but return what
false?
hm
now the command doesnt execute at all
nothing in console
ffs
as you can see- nothing
You probably returned before sending a message
oh yeah
help
im stuck
pluginManager.registerEvents(new ChatEvent(new ClickEvent()));
ClickEvent
wants ChatEvent as a param
and click event needs chat event as a param
circular dependencies 🥳
basically solved by extracting the logic/data needed into a third type
that is then passed to both listeners
@eternal night u there'
You can't check isOnline if player is null
ok i fixed it thanks <3
Well what do your two classes need each other for
uh
so i can fix it
but i have my arraylist
in a class
i want it in my chatevent class
if there were pdcs in 1.8.8 i wouldnt need to do this :/
👀
but if you only need the array list from the click event in the chat event, how are you failing
because im a failure
5head
yeah, change these with another thing
i have no clue what i am looking at
how to check how many times has the code ran in a enhanced for loop
extract a counter variable that is ticked on every run
so somethin like
int i = 0;
for (foo bar : bars) {
i++;
}
yes, because you always redefine i
nvm its cuz i is inside the for
i needs to be defined outside the loop in order to work as intended
ok tyyy
Also, you should increment i at the END of the loop
Otherwise you could get some strange behaviour if you are not carefull enough
How disable physics sand, gravel etc?
But how player place block
this is in a foor loop: if(i < 54) {
i++;
gui.addItem(item);
}
you cant permamently turn gravity off
will the i++ still work
yes, as long as i is under 54
no
i++ is outside of the if
my bad
if(i < 54) { gui.addItem(item); } i++;
like dis
why not use a traditional loop at this point?
it would even get rid of the .iterator() overhead
of a collection
for(int i=0; i<54; i++)
gui.setItem(i, item);
I think this is possible but can be hard
well, it wont be a one-liner then
Turn gravity off on what?
sand
Gravel sand etc
This was discussed before hold on...
Oh it was you that asked xD
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPhysics(BlockPhysicsEvent e) {
if(e.getSourceBlock().getType() == Material.SAND)
e.setCancelled(true);
} // This event isn't needed
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
if(e.getEntityType() == EntityType.FALLING_BLOCK) {
if(e.getTo() == Material.AIR && e.getBlock().getType() == Material.SAND) {
e.setCancelled(true);
e.getBlock().getState().update(false, false);
}
}
}
```https://www.spigotmc.org/threads/prevent-sand-from-falling-upon-placing-sand.133386/
Yea xD
But this is method no perfect
This is work in 99% but
What part doesn't work?
sand & co aren't tile entities and as such vanilla wont store any data on them for this particular usecase. You will have to use inefficent event listeners
Or do what I said when you asked in the past and send packs to the player then just set the block
EntityChangeBlockEvent when you place block server set air in this place and latter set your block again and create falling block after remove
hence.... blockphysicsevent
BlockPhysicsEvent blocked update block around
Don't work on block which you place
I am writing code that can disable physics but it has 200 lines and is terrible
Is there an event when TNT actually primes and becomes an entity? I expected BlockRedstoneEvent to fire before it happens, but nope. Neither does ExplosionPrimeEvent.
I once wrote 2k lines just to rotate the colours of materials and it works fine (as long as mojang doesnt add more colours). Not everything should be measured by the line count
is there a way to store some data on a player without persistentDataContainer
A hashmap
that wont persist either
no
only till the player logs out
well then, Meta or Maps
oke ty!
maps are more common in such usecases, just dont forget to remove the key (the player) on logout to avoid really small memory leaks if you got the Map<Player, Value> route
how do i remove all snowballs in onEnable?
From where???
^^^^^^^^^^^^^
probably a stupid question but how would i store them
how though
Again.... remove them from where???
map.put()?
from existence? idk what u mean
how do i kill all snowballs on onEnable
is a better way to put it
you first need to have worlds loaded, onEnable does not gurantee that
cycle thru world#getEntities and remove if snowball
whats an inventory max slots
for(Entity e = Bukkit.getWorld("world").getEntities()) doesnt work tho
you have to use : and not = in foreach loops
From the world? From inventories etc...
from the world
for (Entity e : Bukkit.getWorld("world").getEntities()) {
}
whats an inventory max slots
the size of the inventory?
Usually a multiple of 9
are you for real
54
That is if I understood your question right
how can i make passive mobs attack players?
If in doubt consult https://wiki.vg
not possible without a lot of code. I. e. you need to decide what the damage values are and etc. Goals could do the trick on actually going towards the player for attacking them
how do you get the current world with Bukkit.getWorld()?
they just need to make the mob go towards a player then damage the player if the mob is in the reach of the player
not lots of code
?paste
you still need the damage tables. You can't make a bat deal as much damage as a cow
i use this method in a command class
but the command class is empty it only has GuiMenu.openMenu(player);
https://paste.md-5.net/yoxofedocu.java thing thing has a problem
some one who doesnt mind pls help kthx
stacktrace or bust
wdym
oh right
lemme check the console
bruh
i got npe'd
for (String childSection : section.getKeys(false)) {
thats the line
section is null.
omg right i forgot to add it onenable
wait nvm
if (warps.getConfig().getConfigurationSection("warps") != null) {
is ok?
Should use isSet
what
if (warps.getConfig().isSet("warps")) {
but
ok 1s
my config looks like this
warps:
something:
e:
e:
is ur solution fine with that
isSet() just checks if the path you input "is set"
So I need to save Locations. I did it in an ArrayList. But can I somehow save Locations that are relative to the player? Example: the Location I want to save is 2 Blocks above the Player and should be still 2 Blocks above the player if the player moved. Can someone help me with that pls?
safe offsets / vectors
Location centerLocation = new Location(this.chunk.getWorld(), this.chunk.getX() << 4, 64, this.chunk.getZ() << 4).add(8, 0, 8).clone().subtract(0, 1, 0);
centerLocation.getBlock().setType(Material.GOLD_BLOCK);
// Sets the blocks manually, because I'm bad in math
centerLocation.add(1, 0, 0).getBlock().setType(Material.GOLD_BLOCK);
centerLocation.add(0, 0, 1).getBlock().setType(Material.GOLD_BLOCK);
centerLocation.subtract(1, 0, 0).getBlock().setType(Material.GOLD_BLOCK);
centerLocation.subtract(0, 0, 1).getBlock().setType(Material.GOLD_BLOCK);
centerLocation.add(1, 0, 1).getBlock().setType(Material.GOLD_BLOCK);
centerLocation.subtract(1, 0, 1).getBlock().setType(Material.GOLD_BLOCK);
centerLocation.subtract(1, 0, 0).add(0, 0, 1).getBlock().setType(Material.GOLD_BLOCK);
centerLocation.subtract(0, 0, 1).add(1, 0, 0).getBlock().setType(Material.GOLD_BLOCK);
centerLocation.add(0, 1, 0).getBlock().setType(Material.BEACON);
Why does it look like this? It should be this:
beat me to it
okay so I should save the x y and z offsett of the playersLocation ?
Sorry. I forgot to add it. I already did.
updated code?
I updated @candid galleon
I don't see clone
Show the updated code
oh
you have to do it on every line
centerLocation.clone().add(1, 0, 1).getBlock().setType(Material.GOLD_BLOCK);
Ah. Thanks
maybe compress it into a for loop
I will try,
Later.
👍 hf changing 9 lines of code for 1 bug
so I should save the x y and z offsett of the playersLocation ?
yes
Block bottom = centerLocation.getBlock().getRelative(BlockFace.DOWN);
for(BlockFace bf : BlockFace.values) {
if(bf != BlockFace.UP && bf != BlockFace.DOWN)
bottom.getRelative(bf).setType(Material.GOLD_BLOCK)
}
```psuedo code might need to alter it.
what can I use to save 3 objects? I never needed that
List, Map, Array etc...
[12:49:30] [Server thread/ERROR]: [org.bukkit.craftbukkit.v1_17_R1.CraftServer] de/cimeyclust/utils/mysql/MySQLConnector initializing CimeyRolePlay v1.0.0 (Is it up to date?)
java.lang.NoClassDefFoundError: de/cimeyclust/utils/mysql/MySQLConnector
at de.cimeyclust.Plugin.onLoad(Plugin.java:44) ~[CimeyRolePlay-1.0.jar:?]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.loadPlugins(CraftServer.java:410) ~[patched_1.17.1.jar:git-Paper-157]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:276) ~[patched_1.17.1.jar:git-Paper-157]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1126) ~[patched_1.17.1.jar:git-Paper-157]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:316) ~[patched_1.17.1.jar:git-Paper-157]
at java.lang.Thread.run(Thread.java:831) [?:?]
Caused by: java.lang.ClassNotFoundException: de.cimeyclust.utils.mysql.MySQLConnector
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:146) ~[patched_1.17.1.jar:git-Paper-157]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:103) ~[patched_1.17.1.jar:git-Paper-157]
at java.lang.ClassLoader.loadClass(ClassLoader.java:519) ~[?:?]
... 6 more
this.connector = new MySQLConnector(this); // Line 44
I just moved MySQLConnector.java from package utils to utils.mysql
Why I get this error now?
I can save x,y and z multiple times in a normal List?
Yes.
@rigid hazel rebuild it along with any dependencies you are using and that should fix it
I did. but same error
I cklied the reload icon in the left corner and packaged
try using clean before packaging
How to set custommodeldata to slot chestplate
Thanks. It worked
👍
can i create a book (not physical) from vanilla json?
it's quite a large book and I don't want to risk anything as it's easily obtainable :))
Plss help me
you can't
What are some things I should add to my plug-in?
Can I subtract 1 number of the other a better way than checking before if one of the numbers is negative every time?
why originrealms do it
ip?
Example pls. This makes no sense to me.
They use armor stands which are mounted on the player and have a negative y offset.
doesn't sound right :))
maybe they make "fake" armor
Was just a suspicion. Now at second thought the item would move with the head.
What do you mean by "fake"
you can make an item
to be like an armor
like have "armor points"
idk how it's callled exactly
The problem is the custom model. You cant display a custom model in the armor slots.
You mean attributes.
yeah
oooh
didn't know that
but wouldn't putting it in a armor slot just show the in-hand model?
hello i need some help so i want to add time to my scoreboard could someone help me there?
I want to store a Location relative to the player. So I store the x, y and z difference between the 2 Locations. But if I would do:
x = location.getBlockX() - player.getLocation().getBlockX();
Then if both would be negative I wouldn't get the difference only if both would be positive. And I think there is a better solution than checking every coordinate if its negative or positive before thats what I want to know.
Just use a vector for relative locations
like how can i code this with java?
oh thank you
that it shows the esact time of a country at the sscoreboard
public Vector getRelativeLocation(final Player player, final Location absoluteLocation) {
return absoluteLocation.toVector().subtract(player.getLocation().toVector());
}
public Location getAbsoluteLocation(final Player player, final Vector relativeVector) {
return player.getLocation().add(relativeVector);
}
Thank you a lot!
TimeZone timeZone = TimeZone.getTimeZone("GMT+05:30");
Calendar calendar = Calendar.getInstance(timeZone);
String mHour = calendar.get(Calendar.HOUR_OF_DAY);
String mMinute calendar.get(Calendar.MINUTE);
Hello, i have a question about adding team to player. Do i need to do it by HashMaps ?
thx how do i add this to the scoreboard?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Does anyone know why this code seems to cause an infinite loop?
essentially all it does is if a player tries to close a certain inventory it will try to reopen that inventory for the player
delay it by a tick
this
modifying the inventory open during the close event kindly destroys the internal tracking
I see
I dont understand what you mean by that. You can just add a players name to a Team.
yep this is worked, thanks
I am making a small minigame based on 2 player fights each other. But i don't know how to set spawn for each player. I mean i have set the spawn location and command (/setspawn1 for first player and /setspawn2 for second player), but i don't know how to spawn first player on spawn1 and second player on spawn2.
Player#teleport
Make it object oriented.
Create a class called Duel which contains 2 Locations and 2 UUIDs of each of the participants. Then simply teleport them to the corresponding locations.
Okay and how do i add the player UUID to the for example first location ?
Hey, Is it possible to check if player is left or right of a location? and if so how?
Either hard code it or use a Map<UUID, Location>
If its just a duel then i would hard code it.
Player player = Bukkit.getPlayer(firstID);
if(player == null) {
// player is offline...
return;
}
player.teleport(firstLocation);
Same with secondID and secondLocation.
when you create a duel pass in the UUID of both players and store them, as well as your spawning locations. When you want to teleport the players to the spawning locations, so for example at the start, use player#teleport(location)
"left" and "right" are not really useful without the axis you consider the basis
This depends what you mean by "left" and "right" as those are relative terms
you can get a player from a UUID by using Bukkit.getPlayer()
Use .equals() or .isSimilar()
I want to check the location relative to the player and determine if the location is right to the players view, or left of the players view. so i can use that data to send audio to my audioserver
even if it is an variable?
I thought that was for strings
Use it for every object but primitives and enums
Calculate the angle between the vector pointing to the audio source and the vector defining the direction the player is looking in.
okay thanks i will look into it 😄
And you should check custom ItemStacks by PersistentDataContainer anyways.
@lost matrix Ehm... Okay and so if i have more players than 2 and i want let them to select what team they want for example like in some minigames like bedwars ... Can i do it with HashMap ? If yes can you tell me how?
Just make a bunch of classes until it makes sense.
Create a class Team which contains a Set<UUID> so you can add playerIDs to a Team. Then each Team instance also has a Location and a Name.
Then a class TeamManager which contains a Map<String, Team> so you can get a Team by its name. And so on.
Okay thank you.
Is there a way to set the damage for the next hit? So what I am trying to do is make a sword that on right click, deals double damage for the next 2 hits
Use the PDC of the sword and add an Integer in there that counts down in the EntityDamageByEntityEvent.
What is pdc?
?pdc
I now have this:
Vector look = p.getLocation().getDirection().normalize();
Location head = p.getLocation().add(0, p.getEyeHeight(), 0);
Vector direction = head.subtract(target).toVector().normalize();
Vector cp = direction.crossProduct(look);
p.sendMessage(String.valueOf(cp.normalize().getZ()));
return cp.normalize().getZ();
you think this is good?
Here is an example:
private static final NamespacedKey DAMAGE_KEY = NamespacedKey.minecraft("extra-damage-amount");
private static final NamespacedKey COUNT_KEY = NamespacedKey.minecraft("extra-damage-count");
public void grantExtraDamage(final ItemStack itemStack, final double damage, final int amount) {
final ItemMeta meta = itemStack.getItemMeta();
final PersistentDataContainer container = meta.getPersistentDataContainer();
container.set(DAMAGE_KEY, PersistentDataType.DOUBLE, damage);
container.set(COUNT_KEY, PersistentDataType.INTEGER, amount);
itemStack.setItemMeta(meta);
}
private double getExtraDamageAndDecrement(final ItemStack itemStack) {
if (itemStack == null || itemStack.getType() == Material.AIR) {
return 0;
}
final ItemMeta meta = itemStack.getItemMeta();
final PersistentDataContainer container = meta.getPersistentDataContainer();
final Integer count = container.get(COUNT_KEY, PersistentDataType.INTEGER);
final Double damage = container.get(DAMAGE_KEY, PersistentDataType.DOUBLE);
if (count == null || damage == null || count < 1) {
return 0;
}
container.set(COUNT_KEY, PersistentDataType.INTEGER, count - 1);
itemStack.setItemMeta(meta);
return damage;
}
@EventHandler
public void onDamage(final EntityDamageByEntityEvent event) {
final Entity attacker = event.getDamager();
if (attacker instanceof LivingEntity livingAttacker) {
final EntityEquipment equipment = livingAttacker.getEquipment();
if (equipment == null) {
return;
}
final double extraDamage = this.getExtraDamageAndDecrement(equipment.getItemInMainHand());
event.setDamage(event.getDamage() + extraDamage);
}
}

if someone uses the minecraft namespace for pdc the spigot contributors shall smite them
ngl
I personally have a NamespaceFactory for that. It just bothered me to inject my plugin instance everywhere i need NamespacedKeys
Nowadays you can just use two Strings for that.
yea there are a lot of neat ways to distribute your namespaced keys around
do the touch handlers not work anymore in holographic displays api?
Is there a way to add grouped recipes similar to how items like logs are handled? I'm planning on adding a recipe that lets players craft an item between it's 16 states, but I don't want 16 or more spaces in the book.
Hi guys i need help. I want to create a permission plugin for bungeecord but i need to find a way to get the permissions of the other bungee plugins but i don't find a solution. Someone can help me with that?
Hey, I keep getting:
java.net.ConnectException: Connection refused: connect
I'm trying to emit an event from a node.js server to my papermc spigot plugin. I'm not sure what is causing this error so any help will be appreciated.
https://gist.github.com/zoonii/a20aab3d52991b2e2c12d6f9888b90a4
Believe the API doesn’t support it right now
Conclure can you help me please?
Hmm, got it :/ any idea what the ShapelessRecipe.setGroup() method is then?
Set the group of this recipe. Recipes with the same group may be grouped together when displayed in the client.
I'm assuming that's it, I was still digging around after sending my message.
I am not experienced with bungeecord permissions but maybe checkout how something like LuckPerms do it? @quaint hedge
oh mov51 yeah that might be it
i tried to search how Luckperms do that but there is no answer in google or spigot
LuckPerms is open source
However when I created recipes last time (in fabric) you could define a group of materials and then use that group as an ingredient
Afaict not possible with spigot
Look at it
then go in the bungeecord module
i saw their open source but he is very complicated to understand
Awesome, lol. I'll give it a shot then. Sorry for asking prematurely.
The code is well over engineered for being a plugin maybe but it’s great since it protects itself from code symptoms
Here's their bungee section, so lol
https://github.com/lucko/LuckPerms/tree/master/bungee/src/main/java/me/lucko/luckperms/bungee
do you know someone from this server that understand in bungeecord?
By the looks of it. Bungeecord has little to no permission api
Basically a PermissionCheckEvent, then CommandSender with the addGroup, removeGroup, hasPermission, setPermission and so on
Very minimal
Unlike spigot every plugin does not define permissions and their default level etc
Maybe with PermissionCheckEvent i can get all the permissions?
Ok i will try to get the permissions with PermissionCheckEvent
thank you
And one last question. If i will need more help with this topic can i mention you?
Ok thank you!
Hey everyone, i'd like to know how to get the tagCompoung of an ItemStack
and how to set it , thx in advance
@rare crater I don't think you can mess with nbt tags directly like in forge
Generally you'd use the pdc
in fact i'd like to store a data (where T<PotionEffect>) inside an intemStack
u know what i mean ?
@ivory sleet Well after a few minutes i saw that there is no way to get all Permissions through PermissionCheckEvent. i think Luckperms know how to analyze the main class of every plugin and get the lines of register commands and with that they go to commands class and their they taking the permissions. But this is very complicated to make something like that. What do you think?
btw im on a Spigot fork > Paper
.
So why are you making your own permission system? Why not just use LuckPerms?
for fun i think
what's the alternative to internalin Java ?
and to learn of course
Let me peek into luckperms
Ok
@rare crater for more complex types I prefer to serialise to bytes and store as a bytearray in the pdc
I really appreciate your help and that of the rest of the company here
java 9 allows you to encapsulate an entire module, preventing any access to its members through reflection etc
If you want more efficient storage you can write your own data type
There is reflection in Java
UwU
yes
thx for the advice
C# = Java > Ctrl + C V
lol
imagine sorting java array without Linq
yeah ofc
what event should i use to disable flowers from dropping if they not in Grass Block ?
3 B devices kappa
yo guys, having some problems
the command aint executing, aint anything
also doesnt disable fall damage where i tell it to
@quaint hedge actually looks like it’s just using PermissionCheckEvent
do Player variables delete when the player in question leaves?
But how?
Did you return to early again
timezone.addEntry(ChatColor.GRAY+ "" );
timezone.setPrefix(ChatColor.GRAY+ TimeZone.getTimeZone("GMT+05:30"));
``` so i am trying to put time on a scoreboard
no, the gc will not just clear a variable of yours
but iuts an error
nah, tried doing some stuff

