#help-development
1 messages · Page 1397 of 1
Rather use Integer.parseInt()
And you should catch the NumberFormatException to prevent invalid inputs
never say "an exception"
always specify the exception
there are millions of different exceptions
sorry I am 2 days into java...
if you were to look at my code you would loose your mind
put me at the bottom
keep it that way
lmao
Does that mean it has no loops :p
performs like shit, written like shit, balanced like shit
they excuse it by saying that the main developer was a noob when he started writing it
but in all honesty he isn't much better now
everything he still writes, 5 years later, still runs like shit and looks like shit
the 'lag profiler' he added a few months back uses more main thread time than most of the individually ticked blocks in the plugin
and is literally fucking useless because it doesn't discriminate between off-thread and main thread time
something is... odd with my code
Wait slimefun is still a thing? Fk then my machine plugin might be obsolete...
definitely not obsolete
Maybe not because my performance is actually great...
a steaming pile of shit is still a better replacement for slimefun
lol
im trying to do an integral in a maths calculation
and it one way it works perfectly
but the other way gives completely different results than a calculation on my calculator
money = Math.log((finalstock / (finalstock - finalamount)) * value);
finalstock = 2
finalamount = 1
value = 1000
Integrals are pretty hard to do in programming. Numerical mathematics can get quite complicated.
that on my calculator gives out 693.147
In Java it gives out 7.601
probably that actually
i think log10 is a separate method
this is what autocomplete does to your brain
yeah its e
but why is it not working
sellitem_money = Math.log((sellitem_sell_final_stock + sellitem_sell_final_amount) / sellitem_sell_final_stock) * sellitem_result_value;
Thats the opposite (selling items) and it works fine
But the other one doesnt give out correct results
you should use lowerCamelCase for variables by the way
yeah im going over everything once I am done, realized like 2 hours into the plugin that it was a bad decision
but still its giving out wrong answers
look at and compare the intermediate calculations with your calculator
i am
see which one of them is giving an incorrect value
What is the function what are the parameters and what integral do you want to calculate
I want to make a custom damage system, how should I go about it. My idea was to give mobs a shit ton of health and give swords alot of sharpness and just hide it. Is there a better way of doing this?
i found the issue
almost certainly yes
in one function I multiplied log(2/1) * 1000
that gave the large number
in the other I did log((2/1)*1000)
Events. And a PersistentDataContainer based attribute system.
it will be pretty difficult though, if you want to be compatible with other plugins that also fuck with damage
the way how minecraft and bukkit in particular handles damage isn't very brilliant
priority monitor and silence them all (dont)
the final solution
thats very vague
yeah ok that was the issue... thanks for the help you 2
listen to and modify damage events
but you obviously need to do the logic in between
How can I give a command autofill parameters?
yes
if you mean the brigadier named parameter shit, use some brigadier library
iirc lucko has a decent one
Listen for the EntityDamageEvent and the EntityDamageByEntityEvent
Get the defender and the attacker.
Get both parties PDCs.
Use a manager that evaluates the damage outcome based on those two PDCs plus other effects like those form potions.
Set the calculated damage in the event.
ok thanks
i've found working with brigadier directly to be kinda cancer
hi so I have this one plugin and I like it but it seems like it is missing one feature I want so I decided to edit that plugin add a custom permission and the main thing I want to use that permission is to bypass a limit that this p lugin has for example lets say a plugin has a limit of how much money you can have but It doesn't have a permission to bypass that how do I make it exactly I tried playing with eventhandler but it is more complicated than I thought lol
Same. I really dont like the structure. Just gets messy really fast without some wrapper and helper methods
zyte
So you want to bypass a limitation of another plugin?
can you elaborate
and use sentences
i will try to help you if I can read what you say without getting an aneurysm
hush
what I want to bypass is a value in the config
ItemStack hand = new ItemStack(sellitem_seller.getInventory().getItemInMainHand());
hand.setAmount(sellitem_sell_final_amount_int);
sellitem_seller.getInventory().remove(hand);
int sellitem_stock_after = (int) (sellitem_sell_final_amount + sellitem_sell_final_stock);
Why is this not removing sellitem_sell_final_amount_int amount of the Item in my hand from my Inventory?
because I want this feature and the plugin does not have this kind of permission
what
Really depends on what this value limits
to bypass that
so this plugin limits the amount of money you can have?
I'll explain in detail
I’m guessing the plugin has a max money option, and he wants a perm for users to bypass it
ah well
bingo
Not possible
bytecode injection lul
You need to modify the plugin itself or use some really shady tricks: Maybe reflections are enough, maybe injecting bytecode is needed.
depends on your economy plugin
it could have an API or something
speaking of economy plugins
what eco plugins do people use these days?
essentials eco most of them but I created my own
i think most use essentials
i've been stuck with TheNewEconomy for like ages and I feel like I will fucking die if I have to go another year with it
regrettably I don't think essentials eco works with towny properly
or, well, that's what the towny people say, anyway
Many use essentials built in one. I always implement my own service provider or scrap vault completely for personal projects.
who uses towny in 2021
i still dont get it
i think towny has been getting more popular recently tbh
well, if we ignore all of the minigame and cancer servers
fr
iCo5 for Towny
🥲
I’ve not had an issue with towny and essentials in modern versions
hello does anyone know why none of the imports work for me/
But it does still have the warning
very elaborate
i never really bothered to actually figure out what the supposed issue with essentials eco and towny was
Not with that amount of information
well I dont even know what happened
Is your computer turned on?
yes...
make sure you're not in offline mode
I'm at a loss then
like after I restarted my computer
have you tried restarting again?
yeo
invalidate your caches and restart the ide
Im getting from the imports
yeah sounds like just an ide problem
kk
eclipse vs intellij war ?

intellij best
Preference. But i like IJ+
Moved from Eclipse to IJ a week and a bit ago, honestly I don't get the hypw
its better but not THAT much better
It takes time.
using the mc dev plugin?
For example. Go into your IDE and hit the shift key two times. Then type a class name in there for example.
ItemStack hand = new ItemStack(sellitem_seller.getInventory().getItemInMainHand());
hand.setAmount(sellitem_sell_final_amount_int);
sellitem_seller.getInventory().remove(hand);
int sellitem_stock_after = (int) (sellitem_sell_final_amount + sellitem_sell_final_stock);
Why is this not removing sellitem_sell_final_amount_int amount of the Item in my hand from my Inventory?
very helpful
the search function is trash
it doesn't work properly with tab and is slow as shit and doesn't find things half of the time
in intellij?
yeah
is ur pc good?
no
intellij is very heavy to be fair
I really like it to be honest.
my stance is that I shouldn't need a giga chad computer to use a fucking search function
i hate intellij and would use eclipse but eclipse just lacks so much functionality and features in comparison that I don't really have a choice
I still haven't figured out how to auto-import all unimported refs yet?
on eclipse it was ctrl shift O
but in IJ it looks like you have to do each one manually
Same...
if you type getServer().getPluginManager().registerEvents(new Events(), this); then it learns that ur gonna be using registerEvents the most
theres a setting for auto importing in intellij
also, one thing that really fucking grinds my gears with ij is that it's constantly grabbing window focus
I have a slow computer and it takes around 30 seconds to open a project
during this time, it constantly opens pop ups and steals window focus
if i'm f.e typing on discord at the same time, the popup will steal window focus, and when I press space
that is very true
it hits the fucking cancel button
and I need to start all over again
not only this but literally every single fucking thing the ide does tries to grab window focus
@drowsy helm
instead of redo
ah thats awesome thankyou
🤮
Thank you sooooooo much
np
imagine using dark mode
I’ve been looking for this
let me show you some theme
material themes best themes
do u use everything in light themes
ofc I have light theme in everything discorc my server panel pycharm visual studio code even ON ROLBLOX STUDIO
you're just all light mode fucknuggets to me
ew
for example, i cant see the words properly in a light theme, theyre too small
yes thats how i felt when taking the ss
light theme only
why tf is it even an option
:000000000000
pls stop
i really wish the atom material icons plugin would change the icon for .yml files
its a bit bad
what even is that
when all the other ones are clean
like these for example
ItemStack hand = new ItemStack(sellitem_seller.getInventory().getItemInMainHand());
hand.setAmount(sellitem_sell_final_amount_int);
sellitem_seller.getInventory().remove(hand);
int sellitem_stock_after = (int) (sellitem_sell_final_amount + sellitem_sell_final_stock);
Why is this not removing sellitem_sell_final_amount_int amount of the Item in my hand from my Inventory?
Removes all stacks in the inventory matching the given stack.
oh so it would remove all stacks matching sellitem_sell_final_amount_int ?
ooooh ok that makes sense
read ze docs
what can I use instead then
i don't know if there is a built in way to remove x items of a type from an inventory tbh
you might just have to iterate over the slots and remove them manually
I have no idea how to do that
do you know how to iterate over a collection
kool beans
but
you do know how to iterate over a collection, right
might be something you want to look into if not 👀
I will...
is it possible to store the ItemStack in a String in a MySQL?
Like does that work?
yeeees, but not very well on spigot
you will want to do something called serialization to the itemstack, which converts it into a serial format, usually raw bytes or a string or something like that
mhm okay
the only serialization method spigot provides converts the item into what is basically a ConfigurationSection
BukkitObjectOutputStream -> Base64
lemme try around a bit to see if I can get it working
does that take care of data conversions and shit?
i remember there being issues with serialized stuff exploding when the data version is incremented
like, with server updates and what have you
Yeah that was a problem
This shouldnt cause any issues as long as the item column type is TEXT right?
now, put on the brakes
before give you the answer you want, let me first say that your question is wrong
in object oriented programming, everything is an object
your problem is not that you can't find the config object
your question of "how to find the config outside of my main class" is wrong
it should be "how to find the config outside of my main class instance"
... yes
the answer is that you give the config object to the object that needs it
you don't give it to a "class file"
you give it to another object
drop the whole thought pattern of being restricted by "class files"
you are always restricted by which object you are in, not which class you are in
Ideally inject your plugin instance into that other instance challenger
how do I do that
do you know what a constructor is
no
do you know what new does
kinda
give me an example of you using new in your code
ItemStack hand = new ItemStack(sellitem_seller.getInventory().getItemInMainHand());
https://gist.github.com/Conclure/a01d187ab9127149a919daec6547757f#file-datamanager-java-L1 this is an example if you’re getting too lost I guess
right there, you are invoking ItemStack's constructor
new calls a constructor
constructor creates a new object
that's why it's called new
now, let's try creating a constructor
open up the class file where you want to access your config
NNY nice explanation
mk
have you opened it? what is the class called
buyitem.java
now, we will create a constructor
write public buyitem() {} somewhere in the class
ok
wait do I put that just anywhere in the class or inside my public class buyitem which I have a lot of shit in
like I mean
you have to put it inside the class declaration
below the imports or inside the code block of the CommandExecutor
ok
public class buyitem { } is the class declaration
so you put it somewhere in between the { }
yes
so now you have something like
public class buyitem {
public buyitem() {
System.out.println("the final solution");
}
}
congratulations, you have created a constructor
now, whenever you create a new instance of buyitem with new buyitem(), that code is run
wait
no that doesnt work
public class buyitem implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
public buyitem() {
System.out.println("the final solution");
}
if (args.length == 0) {
...
next, put something in between the ()
let's say Object myObject
you will have something like this
so now you have something like
public class buyitem {
public buyitem(Object myObject) {
System.out.println("the final solution");
}
}
ye
yeah I see that
new buyitem() will throw an error, because it wants a parameter
you have created a constructor that takes 1 parameter
you can no longer create instances of this class without giving it some arguments
and the argument tells it stuff about the plugins data I guess?
and I can use that to do .getConfig()?
now, to create an instance of it, you need an Object to give to it
Object object = new Object();
buyitem item = new buyitem(object)
here we are creating a dummy object and then passing it to the constructor of buyitem
now, we can do stuff with this object in the constructor
public class buyitem {
public buyitem(Object myObject) {
System.out.println("the final solution");
System.out.println("We got an object: " + myObject);
}
}
if we're feeling hardcore, we can create a field and store that object
public class buyitem {
private Object myStoredObject;
public buyitem(Object myObject) {
System.out.println("the final solution");
System.out.println("We got an object: " + myObject);
myStoredObject = myObject;
}
}
and now, the buyitem object will forever remember the object you passed to it in its constructor
it can do stuff with that object later
ok
public class buyitem {
private Object myStoredObject;
public buyitem(Object myObject) {
System.out.println("the final solution");
System.out.println("We got an object: " + myObject);
myStoredObject = myObject;
}
public boolean onCommand() {
System.out.println("The object we have is " + myStoredObject);
}
}
next, do you know what this does
now, I want you to embrace the thought that methods belong to an object
mhm
see that onCommand method? I want you to stop thinking that it's a couple of lines of text in a text file named buyitem.java
lmao i know
i want you to imagine that it's part of an object
that is
Object object = new Object();
buyitem item = new buyitem(object)
it belongs to 'item'
we can call it with item.onCommand()
now, when we have a this inside the method
public class buyitem {
public boolean onCommand() {
System.out.println("The object we have is " + myStoredObject);
System.out.println("My name is " + this);
}
}
how can I get the jar file if I have all java files made?
it will refer to item
okay
u mean export it?
because item owns the method, and this refers to the current object, which is item
yes
I mean get the jar to be able to use the plugin
so how can I export
now, next we need to make some assumptions with what bukkit does with plugins
idk I took it from github
what is the name of your main class
konstanius
right
what program are you using rn
somewhere in the abyssal fucking spaghetti depths of bukkit, something goes konstanius thatPlugin = new konstanius()
it takes your main class
and it calls your constructor
creating an instance of your main class
an object
run that @strong kelp
I have this in build.gradle ```
version = '1.0'
ext.pluginName = 'MyFirstPlugin'
ext.author = 'daark'
ext.website = 'google.com'
ext.mainPackage = 'me.daark.myplugin'
ext.mainClass = mainPackage + ".MyFirstPlugin"
How do I use placeholders in plugin.yml with it?
I tried this but it shows same when I build
name: ${pluginName}
author: ${author}
website: ${website}
version: ${project.version}
main: ${mainClass}
it will then do some shit for a while, and then it will call thatPlugin.onLoad()
with java?
and a whule later, it will call thatPlugin.onEnable()
that is for maven, you have to use @version@ etc, i think
can you help me in DM?
and before the server shuts down, it will call thatPlugin.onDisable()
processResources.expand "pluginName": "blah" @quaint mantle
sure
thanks
yes i knew that
I tried that too but it also showed up as @version@ when I built it
now, we can apply the knowledge we have learned of this
and include this in your onEnable method
Using replacetokens is redundant
it will refer to the object that bukkit told your main class's constructor to create
Just expand
that is, it refers to your plugin object
now, we can apply the knowledge we learned of constructors
and we can give this to the constructor of your buyitem class
now, we can apply the knowledge that we can do stuff with the objects we are passed in constructors, and we can store the plugin object in the buyitem object
processResources {
expand "pluginName": project.name,
"author": "Drak"
}``` @quaint mantle
Etc
And then I use @pluginName@ or ${pluginName}?
and you end up with something like this
public class buyitem {
private konstantinus myPlugin;
public buyitem(konstantinus plugin) {
System.out.println("the final solution");
System.out.println("We got an object: " + plugin);
myPlugin = plugin;
}
public boolean onCommand() {
System.out.println("The plugin we have is " + myPlugin);
}
}
okay
and now, in your buyitem's methods, you can take the myPlugin object
and do stuff with it
like, for example, call getConfig()
But about project.name Should I then delete rootProject.name = 'MyFirstPlugin' from gradle settings?
If I expand project.name in build.gradle, should I remove rootProject.name from gradle settings?
no lol
note that you can shove some this'es in the code and it will do just the same:
public class buyitem {
private konstantinus myPlugin;
public buyitem(konstantinus plugin) {
System.out.println("the final solution");
System.out.println("We got an object: " + plugin);
this.myPlugin = plugin;
}
public boolean onCommand() {
System.out.println("The plugin we have is " + this.myPlugin);
}
}
Most likely your project property is also your rootProject
If you’re not using modules or smtng
because this refers to the current object, and myPlugin is a field on the current object, both this.myPlugin and myPlugin are the same
wait project.name in expand points to rootProject.name? Soo basically I don't have to type that name into build.gradle?
Wat
It thought I should do this
processResources {
expand "MyFirstPlugin": project.name,
"author": "Drak"
}```
Yes
No I keep PluginName there right?
what ide u using?
IntelliJ
with the minecraft dev plugin?
No
public class buyitem implements CommandExecutor {
private konstanius myplugin;
public buyitem(konstanius plugin) {
myplugin = plugin;
myplugin.getConfig();
}
So I have this right?
use it
Putting $MyFirstPlugin$ into plugin.yml would then translate to the project.name when building
Yes
well, you aren't really doing anything with the config there yet
the project.name gives it the name
so there's no need to call myplugin.getConfig yet
Yes0
if(!configFile.exists())
{
configFile.getParentFile().mkdirs();
InputStream is = plugin.getResource(configFile.getName());
try
{
Files.copy(is, configFile.toPath());
loadConfig();
}
catch(IOException e)
{
e.printStackTrace();
}
}
else
{
loadConfig();
}
Why is 'is' null?
And project.name is same as rootProject.name right?
call it later when you need it
Yes
yes but what do I put into the main instance now?
aaaah
In this case it is drak
what exactly?
Do I need that plugin too?
what do you mean
The inputstream
Wym drak
That minecraft dev plugin
No
in the main instance, we had
Object object = new Object();
and
getCommand("buyitem").setExecutor(new buyitem(object));
It’s crap
it makes it easier
yes, well, we changed the constructor to take in an instance of your main class
It just helps you negligibly
it no longer accepts any random Object
it needs to be an instance of your konstanius class
the instance that bukkit creates
Do I use expand for ext.mainPackage too?
the instance that bukkit calls the onEnable method on
how do we get this instance?
this
Drak I mean you can expand anything I guess or what hinders you?
good job
Fixed
now, give the constructor this
that will give the buyitem object the instance of your main class
oh bruh i tried doing it in the Object object = new Object(this)
which the buyitem object can then call getConfig on
public class buyitem implements CommandExecutor {
public buyitem(konstanius plugin) {
plugin.getConfig();
}
Does this work too?
processResources {
expand "pluginName": project.name,
"author": "dark"
"website": "google.com"
"mainPackage": "me.dark.myplugin"
"mainClass": mainPackage + ".MyFirstPlugin"
}
This is probably not correct.
But what about this line "mainClass": mainPackage + ".MyFirstPlugin"
NNYaKNpGms0eUVpiSdHx does that work too?
Lol you actually wrote his entire name
copy pasta
processResources {
expand "pluginName": project.name,
"author": "dark",
"website": "google.com",
"mainPackage": "me.dark.myplugin",
"mainClass": "${mainPackage}.MyFirstPlugin"
}
Like this?
Yeah
Could not get unknown property 'mainPackage' for task ':processResources' of type org.gradle.language.jvm.tasks.ProcessResources.
no, that doesn't work anymore
because now you are no longer storing the instance of your plugin
public class buyitem implements CommandExecutor {
public buyitem(konstanius plugin) {
plugin.getConfig();
}
you're just taking it
and then throwing it away
java.lang.ClassNotFoundException:net.minecraft.server.v1_16_R3.ServerPing.ServerData, Why do I get this? I am 100% sure it exists
a field is an object's way of remembering things
@quaint mantle send ur entire build script
you need a field to remember your plugin
ok ty
Thanks a lot
Oh that should work Drak but maybe mainPackage is a reserved one ?
What should I do then?
pluginEntrypoint or smtng mb
I don't know how
Just use that name for your plugin main class path instead of mainPackage
Also why do you use gradle groovy if you’re a kotlin programmer lol
Hey guys so I’m working on a plugin that summons tnt on a player when ever they crouch and I want to know how would i get the location of any player that crouches
Idk I just never did plugins
Fair enough
What events should I look to make an item non-usable?
I already cancel block place events
is there an easy way to do this for all other item functions (e.g. dyeing)
define non usable
can still punch with it but can't perform functions such as special right-click functionality
ideally also can't use in crafting or smelting but that is more complex ig
listen to all interact events
and cancel any right click ones with that item held
you can still use it in recipes and whatever
will this affect item-nonspecific events such as trying to open a chest while holding the item?
yes
is it difficult to make it ignore those
i'm not sure
i.e. without doing it on a case-by-case basis
okay, I'll give it a go anyway
thank you!
PlayerInteractEvent.isCancelled is deprecated for some reason?
I think it uses Event.Result instead
Because it can be cancelled in different ways sort of
What does it say
the interact event is cancer
A lot of errors
Deprecated.
This event has two possible cancellation states, one for useInteractedBlock() and one for useItemInHand(). It is possible a call might have the former false, but the latter true, eg in the case of using a firework whilst gliding. Callers should check the relevant methods individually.
this what it says on the javadoc
When I use ext.pluginName it builds but the placeholders aren't working
When trying to use processResources I dig my self a deeper rabbit hole
I’m asking how would I spawn tnt on anyone that sneaks
primed tnt or the block tnt
true @quaint mantle, thought the Javadocs were embedded in the API code and didnt see it there but it looks like they aren't
Tried those two
author: @author@
website: @website@
version: @project.version@
main: @mainClass@
and
author: ${author}
website: ${website}
version: ${project.version}
main: ${mainClass}```
if I do setUseItemInHand, will that stop e.g. a sheep being dyed or just stop the dye from being consumed?
probably both
its useItemInHand()
okay perfect
@novel hornet
e.getPlayer().getWorld().spawnEntity(l, EntityType.PRIMED_TNT);```
I have this in build.gradle version = '1.0'
i wanna get back into plugin development but idk what to make
yeah I was referring to the twin function that sets the result rather than gets it
ah ok
literally every last one is somehow garbage
i worked for this server owner
one way or the other
lootcrates?
let me see if i've checked that
are u allowed to curse on here
I mean its kinda good that plugins to exploit children are all trash lol
yeah
Look
When I try to build
I get this
> Could not copy file 'D:\GitHub\bMoreFish\src\main\resources\locale\lang_de.yml' to 'D:\GitHub\bMoreFish\build\resources\main\locale\lang_de.yml'.
> Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:
SimpleTemplateScript44.groovy: 1: illegal string body character after dollar sign;
solution: either escape a literal dollar sign "\$5" or bracket the value expression "${5}" @ line 1, column 10.
out.print("""#```
That is with processResources
When I use ext it builds but placeholders don't work
how can I change the direction of a lever in 1.16.5? Because when I place the lever it is in the air(like its on a wall) and not down on the block.
something to do with nbt isnt it
@brittle nova setFacingDirection
^^
unless that is just the rotation
But its deprecated
the class is deprecated
it says use the BlockData class
declaration: package: org.bukkit.block.data, interface: BlockData
group = 'me.dark'
version = '1.0'
ext.mainPackage = 'me.dark.myplugin'
processResources {
expand "pluginName": project.name,
"author": "dark",
"website": "google.com",
"mainClass": "${mainPackage}.MyFirstPlugin"
}
This is currently my build.gradle
ohh true, google came up with this one
@quaint mantle wrap it into
filesMatching("plugin.yml") {
expand ...
}
but what do I have to do then?
Replacing processresources with filesMatching?
No
im not too sure
I said wrap
can maven do something like this
declaration: package: org.bukkit.block.data, interface: BlockData
like setting the plugin.yml
it doesn't look like the plugin supports complex items properly
Location#.getBlock().setData((byte) 2)
through <properties></properties>
group = 'me.dark'
version = '1.0'
ext.mainPackage = 'me.dark.myplugin'
filesMatching("plugin.yml") {
expand
processResources {
expand "pluginName": project.name,
"author": "dark",
"website": "google.com",
"mainClass": "${mainPackage}.MyFirstPlugin"
}
}
How can I, in a config, have say
missing-amount-usage: "§eUsage: §c/buyitem %item% <Amount>"
translate to:
"§eUsage: §c/buyitem " + item + "<Amount>"
in my Code?
Like this?
f.e how would I apply a PDC tag with this plugin's config?
ChatColor.translateAlternateColorCodes(#CharCode, #String)
i have a bunch of plugins that identify items based on PDC tags
processResources {
filesMatching(...) {
expand ...
}
}
i guess I'll just have to write my own crate plugin once I get around to it
BlockData blockData = block.getBlockData();
if(blockData instanceof Rotatable) {
Rotatable rotatable = (Rotatable) blockData;
rotatable.setRotation(BlockFace.EAST);
}
block.setBlockData(blockData);
@brittle nova
how would I use that for the variable? Its not colors im translating
oh
I will try
should work
make sure the lever block is the variable "block"
or just replace the variable name
string.replace("%item%", item.toString())
with whatever ur using
or something
then you should do #String.replace("placeholder with escaped chars", "your replacement");
> Could not copy file 'D:\GitHub\bMoreFish\src\main\resources\plugin.yml' to 'D:\GitHub\bMoreFish\build\resources\main\plugin.yml'.
> Missing property (project) for Groovy template expansion. Defined keys [pluginName, author, website, mainClass, out].```
or use glorified version of it - PlaceholderAPI
lemme try
wait
Yes I hope you removed project.version
i think its supposed to be directional not rotatable
BlockData blockData = block.getBlockData();
if(blockData instanceof Directional) {
Directional rotatable = (Directional) blockData;
rotatable.setRotation(BlockFace.EAST);
}
block.setBlockData(blockData);
Make it into a variable like:
expand "pluginVersion": project.version
anyway setRotation()?
sender.sendMessage(messages_prefix + myplugin.getConfig().getString("buyitem.missing-amount-usage").replace("%item%", "args[0]"));
Like that?
(:
yea
I only can use setFacingDirection(). Is it right too?
and you will literally send the player "args[0]"
give me a second
yeah just realized that too thanks
sure try it
seems about right
ok
im not sure how BlockFaces work in terms of levers so i guess just experiment
no partying allowed
only for nitro booster cucks
i see i see
It doesn't work
only boosterers have the perm
what happens
it's still like it was before
what is that screensho
have you tried changing the blockface?
any errors in console
does Skript count as interpreter for java bytecode?
skript counts as shit
it isn't really bytecode
no because of the if statement
well you gonna get errors if its not there
blockdata isn't directinal
not all blocks are directional
well yeah, but it uses some kind of reflection shit to work properly i guess
of course
im wondering does it count as interpreter
imagine indentation LOL
but that does not make it an interpreter for java bytecode
show me your block of code
are you using it in like a interaction event?
It likely falls under the same realm as a python interpreter though
joinEvent
what block are you using
That it sits on a JVM and translates stuff to bukkit objects changes little
use this
pretty sure Directional is for stuff like chests/furnaces
now i see that
directional controls the rotation of the lever
faceattachable controls the block face it's attached to
iirc
which is what this guys looking for is it not?
the lever can be rotated?
yeah like pointing north-south/east-west right?
you can rotate them when they're placed on horizontal surfaces
the lever is placed like on a wall but I want to be it on the ground. So what do I have to do?
set the faceattachable
make it
ground
or sum
FaceAttachable.FLOOR
FaceAttachable.AttachedFace.FLOOR
one of those
idk
latter yeah
dowanrds
The switch is mounted to the ceiling and pointing dowanrds.
mounted on the ceiling
he wants it on the floor
lol
greentns let us know if it doesnt work
it worked thank you
how to define a item stack as a string and get a string as a item stack?
Def dont do that.
Do you want to save it in a yml file or do you have other plans for the String
how would you go about taking a string and converting it into an item stack
Probably abuse the fact that it is config serialializable
there are myriads of ways of doing that
database sql
and it all depends on how it was converted into a string originally
u could make ur own format
and then use the string function to turn it back into an itemstack
public static void spawnLoot(String name, ItemStack item, int chance, Location loc) {
spawnArmorStand(loc, item);
String sql = " INSERT INFO loot ("
+ "NAME, ITEM, CHANCE, LOCAL"
+ ") VALUES(?, ?, ?, ?);";
PreparedStatement ps;
ps = ConnectionSQL.preparedStatement(sql);
try {
ps.setString(1, name);
} catch(SQLException e) {
}```
im not rlly sure taken a break from coding
Don't make your own format
Im normally using BukkitObjectOutputStreams for serializing ItemStacks.
public static String itemStackToBase64(final ItemStack item) {
try (final ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
final BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
dataOutput.writeObject(item);
final String line = Base64Coder.encodeLines(outputStream.toByteArray());
dataOutput.close();
return line;
} catch (final IOException e) {
e.printStackTrace();
return null;
}
}
public static ItemStack itemStackFromBase64(final String base64) {
try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(base64))) {
final BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
final ItemStack itemStack = (ItemStack) dataInput.readObject();
dataInput.close();
return itemStack;
} catch (final IOException | ClassNotFoundException e) {
e.printStackTrace();
return null;
}
}
do they handle data versioning properly
i've had issues with spigot's itemstack serializers exploding over version upgrades
especially the configuration serialization
No idea.
intellij or eclipse
vim
Doesn’t matter but I use IntelliJ
vim and javac
swag
"glorified text editors like Eclipse" lol
It's made by someone on here, so I can confirm that it works nicely
im sticking to eclipse
eh
has a item stack defined the quantity?
ok ill get intelij
ItemStack has an amount property if that’s what u mean vinny
okay
I haven't seen many people asking for IntelliJ help
So I cannot really give numbers on whether you'll actually get more help, because I'd debate that
is there an efficient way to get the total amount of players on the network from bungeecord to a spigot server
more people use ij so you're more likely to get help with it
Probs with plugin messages
it usually takes eclipse people a while before anyone who uses eclipse comes around
Then maybe do it less frequently
because the people who use eclipse are the more intelligent ones actually doing the coding instead of needing help 😎
There are quite a few using eclipse
because if you use intellij you're not gonna need any help :p
Wat lol
In general few people ask for IDE-specific help
Except when where I'm the only one answering, at which point it always has to be people asking for intelliJ help, but it's biased
most of the time the ide specific questions are "how to maven"
school is for plebians
real men learn the nature of the universe through meditation and contemplation
correct.
Better go to sleep right now then
How do I do command arguments with an OfflinePlayer?
become the unmoved mover of your life
cant wait for next year when i get eligible for computer programming classes
they do python
and some c++
So nothing
C++ is complicated
indeed it is
Well, G++ is, but you'd need it
Uhm. Meh. Not really that similar.
yeah but the basics
i havent used c++ too much
public void onPlayerHit(EntityDamageByEntityEvent e) {
if (e.getEntity() instanceof Player) {
Entity p = e.getEntity();
new BukkitRunnable() {
public void run() {
p.setVelocity(e.getDamager().getLocation().getDirection().multiply(getConfig().getDouble("knockback-of-players")));
}
}.runTaskLater(this, Knockback.getInstance().getConfig().getInt("delay-of-kb-players") * 20L);
} else if (e.getEntity() != null) {
Entity p = e.getEntity();
new BukkitRunnable() {
public void run() {
p.setVelocity(e.getDamager().getLocation().getDirection().multiply(getConfig().getDouble("knockback-of-mobs")));
}
}.runTaskLater(this, Knockback.getInstance().getConfig().getInt("delay-of-kb-mobs") * 20L);
}
}```
This is my code for delaying a custom amount of knockback, but when the hits are delayed the knkockback hit happens AFTER the regular hit. (this is only when the person has it enabled in config) I need to get it so it cancels the regular knockback and implemetns the new delay i have set anyone know any methods for this
is there a way to replicate this without making it an actual autocomplete entry (i.e. pressing tab shouldn't fill in the argument name) https://i.imgur.com/D48N0iE.png
or just use pointers and manage your memory by hand
positionIsCurrentPosition = true;
}
else {
positionIsCurrentPosition = false;
}``` Why it is false although one of the location is similar to location?
pointers confused me
malloc
you cant fuck up the pointers tho
the & and * stuff
cause memory corruption lol
If I want to make sure a potion be a specific type of potion (ex: fire resistance), do I use I use the addAttributeModifier method for that?
@brittle nova
but yes, yeah pointers is a big thing in C++
ok
Doesn't C++ destroy everything that goes out of scope?
No you use the PotionMeta for that
.equals compares the actual data in the class
Java: int[][]
C++: **int
== compares if the classes are the same
Instances*
yeah
more specifically, a memory reference
it is such a relief using Java again after using mostly C for uni
no
equals does not compare the data in the class
it may or may not compare the data in the object
still some things I miss from C# (structs, out keyword) but Java has a lot of cool stuff that C# doesn't as I'm beginning to find out
the instance
a == b is true if and only if a is b
.equals ONLY compares the data if it is overriden with that intent of comparing data
I think?
yes, location overrides equals
yeah should b
it checks not only the location but also the direction
Still looking for some help on this.
You mean how to resolve a command argument to an OfflinePlayer or how to provide auto completion for OfflinePlayers
ok goodnight guys
1st one
getOfflinePlayer and call hasPlayedBefore to make sure the player actually exists
or something
alternatively, call mojang
getOfflinePlayer is deprecated
bukkit deprecations aren't deprecations
you can still use them
just make sure to read the deprecation message
alr ig ill usse it
and see if there is something more suitable
I think the getOfflinePlayer(String) is deprecated right? That’s because it might make a request to mojang iirc
It is
Deprecated.
Persistent storage of users should be by UUID as names are no longer unique past a single session.
this basically just means that you can't fetch offline players reliably by name anymore
without calling mojang
I think there’s a better description in the paper javadocs
this is from paper javadocs
like, yeah, this will not give 100% accurate results if players change their usernames while they're offline
but the only way around that is to ring a call to mojang's api
which is probably excessive for what you want
Hmm ye
looks like the method might call mojang and do that for you actually
which means that it's going to blockeroni and you probably don't want to do it on the main thread
does 1.16 spigot support custom TileEntities or would I have to store and manage them manually (using ChunkEvents and some database)?
Yeah wait did mojang ever use names as their primary key :0
spigot doesn't support custom anything really
or, well, bukkit doesn't
i mean, yes, it ""supports"" custom entity types and shit but it's pretty lousy
we don't even have custom biome support yet even though they've been a thing on mojang's end for like years
ahhh unfortunate
I think its better to try use my own system alongside vanilla rather than trying to hook into vanilla when its unsupported
if you're on paper, they have a chunk based PDC which probably does mostly what you want
not on paper but that sounds really good
you'll still have to have like 20 million listeners trying to track when blocks break and shit, but at least you don't need to worry about an external db
I wanna keep my plugin on spigot if possible since you can use spigot plugins on paper but not vice-versa
prob should look at source code for some world protection plugins
a nice thought i suppose but paper people probably won't like your plugin because it can't take advantage of their api
public void onPlayerHit(EntityDamageByEntityEvent e) {
if (e.getEntity() instanceof Player) {
Entity p = e.getEntity();
new BukkitRunnable() {
public void run() {
p.setVelocity(e.getDamager().getLocation().getDirection().multiply(getConfig().getDouble("knockback-of-players")));
}
}.runTaskLater(this, Knockback.getInstance().getConfig().getInt("delay-of-kb-players") * 20L);
} else if (e.getEntity() != null) {
Entity p = e.getEntity();
new BukkitRunnable() {
public void run() {
p.setVelocity(e.getDamager().getLocation().getDirection().multiply(getConfig().getDouble("knockback-of-mobs")));
}
}.runTaskLater(this, Knockback.getInstance().getConfig().getInt("delay-of-kb-mobs") * 20L);
}
}```
This is my code for delaying a custom amount of knockback, but when the hits are delayed the knkockback hit happens AFTER the regular hit. (this is only when the person has it enabled in config) I need to get it so it cancels the regular knockback and implemetns the new delay i have set anyone know any methods for this
so while it does run on paper, it runs in a subpar fashion and people probably want to look for a paper-specific alternative
its mostly a plugin for myself anyway
Then use paper if you want?
no reason not to use paper by this point tbh
afaik, the leading cause of spigot usage is not knowing that paper exists
im down to use paper ofc but if I want to use this framework later on for something public it will not be usable on spigot
why would you eat next to a clown when you can dine with a king
it is very enticing though
you should use spigot for the compatability only
is there a way to use Forge 1.16 mods alongside Paper?
but even so, the spigot api is still not a bad api
yes, but it's very buggy
Mohist
they won't work very well always
and tend to die every 2 months
or they might just self combust
Forge is built of sticks and ego so not surprised it is buggy as shit
No, forge itself isnt buggy
forge alone is fine
the hybrid is
bukkit alone is fine
forge bukkit hybrid is like trying to merge a cow with a chicken
Forge is not buggy at all, and probably infinitely better than server apis at some degree
Forge itself on the inside is really bad though. Maybe not buggy, but a huge mess
you don't know whether it's eggs or milk that's going to come out of it and either way it won't be pleasant
Spigot seems a lot more clean
Because it is less complex?
debatable
yes that contributes to it lol
bukkit is pretty crummy at some parts
You realize how complex it is to write a mod loader
and make it decent
LexManos and other devs spent a lot of time on Forge
shit like material enum and the infinitely wise decisions of using bytecode fucknuggetry for legacy compat don't help
not saying I could do it better lol
you misread what I said I think
oh
xd
Yeah i misread lmao
but my point is, yeah it does a very impressive amount of work, but nevertheless working with it is not pleasant
also some of the forge devs seem very toxic (look at their forums)
They are toxic because they've been through a lot
fabric looking very promising though and more mods are switching over
hi peeps, where can i find more info on the use of api.spigotmc.org? My update checking code relies on https://api.spigotmc.org/legacy/update.php but it seems like that doesnt work anymore, i think? Gives me the wrong output at least
well, it says legacy on the tin
yeah, but it worked for me in the past with the same url
legacy stuff tends to expire
Yeah I mean only odd thing could be that their api is a mod
well, if it really is outdated, does anyone know of an alternative way?
I think the idea is to be lightweight and modular
most fabric mods follow that mentality too
Why not just have the api shaded in?
muh jar size
Feels like most fabric mods are using the api anyways so wouldn’t be weird decision to shade it in or do I miss something here