#help-development
1 messages ยท Page 2226 of 1
Hub.getInstance().getPrefix()
the only reason when it's okay to use a public field imho is when it's a constant
like Collections.EMPTY_LIST
Delet this
I think my brain isn't working right now.
I have this item I'm trying to make translatable, so I made this section in the config. I'm trying to update the lore in a loop, but I am ending up with duplicate lines. This is the section of code I'm working with right now. https://paste.md-5.net/esosimilib.js
I'm trying to use the values in that one list to update strings while working with another list that isn't the same size.
ok uh
basically what i'm trying to do is i'm trying to take a value from a config option in my config file and use that in my handler
except that my code in the beginning looks a bit different than the tutorials i find online, so how would i go ahead to do this?
i know why i'm getting the error, it's just that idk how to fix it and run it
what exactly is the problem? BTW I think it's not very clean to register the listener in the listener's constructor. the listener shouldn't be reponsible for registering itself
oh you mean that you cannot access "plugin"? That's because you never declared any field called plugin
public class MyListener {
private final MyPlugin plugin;
public MyListener(MyPlugin plugin) {
this.plugin = plugin;
}
...
}
alternatively, just set "config" to "plugin.getConfig()" in the constructor
public class PlayerHeldItemHandler {
private final FileConfiguration config;
public PlayerHeldItemHandler(HeavyWeapons plugin) {
this.config = plugin.getConfig();
}
caching the config object though is not a good idea if you want to have a reload command
i'm just trying this out one step at a time, i just want to be able to change the material that the code is gonna work around
so would it look something like this?
yes, that should work fine
alright, tysm!
but dont forget to now register the listener in your onEnable ๐
yup!
public class commandConfigreload implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
Player player = (Player)sender;
if (player.hasPermission(Hub.instance.getConfig().getString("configreload.permission"))) {
Colorize.sendMessage(player, "&7You are reloading the Hub Config");
Hub.instance.reloadConfig();
return true;
} else {
Colorize.sendMessage(player, Hub.instance.NO_PERMISSION);
}
return true;
}
}
any idea why this isnt reloading the config?
Gives no errors and message works fine
it does reload the config
but you cached the config values and never updated your cached stuff
if you do stuff like this:
String asd = getConfig().getString("asd");
and you then reload the config, the "asd" variable deosn't care about that, of course
you'd have to do asd = getConfig(...) again
(caching config stuff is mostly useless anyway - you can just directly get it from the config everytime)
but I dont want to reload the whole server to change some letters in the config n0?
exactly, that's why you shouldnt cache the stuff again
create a class of config paths
with public static final strings
and use that to get stuff every time
I usually don't even bother about that
i make typos ๐ฆ
that's why I just do this
that's what i meant
then I just do ```java
entity.setName(main.getConfig().getString(Config.ENTITY_NAME));
in java is a method the same thing as a function?
yes
no
well a method is a function in the programming sense
yeah
not a java Function
TL;DR: what other languages call "function" is called "method" in java
in python a function allows you to run code from inside the function
is that the same thing
yes
there's also a functional interface called "Function" in java so yo uishould just call that thing you're talking about a method
there is the Function interface
there is, but it's called Method
public void doSomething() {
// do something
}
that is a method
k pulled another dumb and internet didn't work again
so i have material: "WOODEN_AXE" in the config.yml
how do i have the code use that value in the line of code in the first picture?
you mean how do you get the WOODEN_AXE string?
Material woodenAxe = Material.valueOf(getConfig().getString("material"));
u can then use Material.valueOf to get a material from string as alex said
ah ok, ty guys
another thing
when u say this for example x.toUpperCase(). what is the word for the stuff that comes after the .
method
. the method?
but a method is what u told me
and this is how to invoke a method
^
public String toUppercase() {
return /* something */;
}
^ this is a method declaration
myString.toUppercase();
and this is an invocation of that method
?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.
is calling for a method and invoking a method the same thing?
yes
call, invoke, execute. They all mean the same thing.
so in python its like this
def func1():
print("Hi")
func1()
Is the func1() invoking the function?
yes
yes
oh ok
but you cannot compare python to java at all
you should not try to learn java by comparing it to python
you should rather check out these links
java is strictly typed and heavily object orientated
that's quite different from python
for example, you cannot just define a method somewhere. a method ALWAYS belongs to either a class, or an instance of a class
from inside a class, you dont need to invoke the method on anything since it invokes it on itself or "this" by default
however, from outside the class, you invoke the method on an object
hence why you do someObject.someMethod()
public void removeFromStat(MyClass this, Stat stat, double amount) {
this.addToStat(this, stat, -amount);
}
to make the confusion complete: this is the same thing lol
i never knew this was a thing
but why is it a thing?
isnt this always accesible anyway?
i think it is?
you cant name a variable this ๐
no fucking way
its dumb right
but why
BUT WHY
class Test {
Test(/* ?? ?? */) {}
// No receiver parameter is permitted in the constructor of
// a top level class, as there is no conceivable type or name.
void m(Test this) {}
// OK: receiver parameter in an instance method
static void n(Test this) {}
// Illegal: receiver parameter in a static method
class A {
A(Test Test.this) {}
// OK: the receiver parameter represents the instance
// of Test which immediately encloses the instance
// of A being constructed.
void m(A this) {}
// OK: the receiver parameter represents the instance
// of A for which A.m() is invoked.
class B {
B(Test.A A.this) {}
// OK: the receiver parameter represents the instance
// of A which immediately encloses the instance of B
// being constructed.
void m(Test.A.B this) {}
// OK: the receiver parameter represents the instance
// of B for which B.m() is invoked.
}
}
}
uhm wtf is that
receiver parameter
good thing that it's implicit
their own fault if they name themselves like this lol
receiver but no transmitter arguments 
if an inner class is not static, does that mean a class instance is created for each instance of the outer class?
if an inner class is not static, it means you cannot create it without the outer class
can someone kill me
30 minute build ๐
you better be using more than one thread to build all of that
otherwise you're the fool
that looks absolutely stupid
it is
You can do that??
new Test().new Inner();
i didnt think you could either
how else would you create an instance of the inner class?
ok fine it exists but usecase?
you need an instance of Inner
i feel like that could be fixed with a public static inner class and a getter method
I have yet to see someone have a need to do that. It makes sense the more I look at it, but it just looks weird.
if the inner class was static it couldn't access any instance members of the outer class
you can pass the outer class instance to the inner one via the constructor
like an inner builder class kinda ig
you could also do it the proper intended way though ๐
Hmm, I got the duplicate lines fixed, but now I'm running into an issue with the values being incorrect.
?paste again
did u use ternary operator?
Ok but thats useful tho
wait
wait
uhm
the two type parameters are of the same name?
๐
why is there a .before <>
calling doSomething with <T>
which is handy
because the <String> applies to doSomething
for when working with arrays and whatnot
OHH
how did that remove duplicated code?
this is for example also sometimes in (craft)bukkit
static Wrapper<ImmutableMap<String, ?>> newWrapper(@NotNull ConfigurationSerializable obj) {
return new Wrapper<ImmutableMap<String, ?>>(ImmutableMap.<String, Object>builder().put(ConfigurationSerialization.SERIALIZED_TYPE_KEY, ConfigurationSerialization.getAlias(obj.getClass())).putAll(obj.serialize()).build());
}
Not duplicate code, duplicate lines of text. Compare it to the original paste.
that's org.bukkit.util.io.Wrapper
sorry but what's the problem?
the 2 pastes do the same thing?
Original problem here. #help-development message
Right now, I fixed the duplicate lore lines I was getting.
I'm currently trying to figure out why the replaced values aren't correct.
cuz if the any indicator is enabled you put a checkmark
u need to do if indicator.isEnabled, s.replace(indicator.getPlaceHolder, "checkamrk");
ur not checking if the placeholder ur replacing is for the indicator that is enabled basically
^^
Well I don't have a getPlaceHolder method in my Indicator class.
Originally I was just adding the lore to a list and I could just do this.
for (Indicator indicator : indicatorList) {
if (indicator.isEnabled()) {
indicatorLore.add(" &a&l" + PluginConstants.CHECKMARK + " &a" + TextUtils.capitalizeFirstLetter(indicator.getType().getValue()));
} else {
indicatorLore.add(" &c&l" + PluginConstants.X + " &c" + TextUtils.capitalizeFirstLetter(indicator.getType().getValue()));
}
}
Now I need to take a variable from an existing list and replace it with whether or not it's enabled.
do indicators have a name?
They have a type tied to them, but I just tried that and it only worked for the first indicator in the list.
LOL
one sec
updateLore.add(s.replace("%" + indicator.getType().toString().toLowerCase() + "_indicator%", indicator.isEnabled() ? " &a&l" + PluginConstants.CHECKMARK + " &a" : " &c&l" + PluginConstants.X + " &c");
comment the entire inside of the indicators loop and put that one line
This is what I get when I use that.
oops
ah that makes sense
ok one sec
s=s.replace("%" + indicator.getType().toString().toLowerCase() + "_indicator%", indicator.isEnabled() ? " &a&l" + PluginConstants.CHECKMARK + " &a" : " &c&l" + PluginConstants.X + " &c");
Yea, just changed it to that and it works.
and add to the lore outside the loop
I'm a little confused though. Why is it that it wouldn't work with what I had before?
with this?
With this: https://paste.md-5.net/iquruvequc.pl
cuz ur checking if the indicator is enabled
lets say the list of inidcators is [CHAT,TITLES,BOSSBAR]
CHAT alone is enabled
now let's iterate
oh and the lore goes like
BossBar
Chat
Titles
so we iterate the lore and were currently in the for loop with BossBar as our lore string,
we noew iterate the Indicators first of which is Chat
chat is enabled
so ur code will set BossBar to true
or enabled
Oh wait. I think I see now.
If any one of them was enabled, I was replacing every single placeholder instead of just the one.
Man, tonight is not the night. I've been monotonously updating my code to use values from a config and when I got to this, my brain just died.
I know about Block#breakNaturally(), but is it possible to 'force' the player to break a block so that their tool is damaged as well?
With unbreaking and whatnot
player.breakBlock
^^
Is there any function to get type of material? Like if material is iron axe it would return axe
Can always do type.toString().endsWith("_AXE")
Oh nice
Thank you
Yes but if its block like grass block and item like stick?
Not sure what you mean
if you use _axe there will be only axes
That's still really vague
Create List of Materials then .contains
If you're gonna be using contains, use a Set and not a List
jst to let you know, everything works except for shouldDrop method and amount idk why
are you making weighted random stuff?
also can i see what your chance values look like?
use BukkitRunnables instead of TimerTask
Amounts in int, chance in double
chance: 0.2
min-amount: 1
max-amount: 3
I didn't even have to explain ๐
well it should be random.nextDouble < chance and are you sure that shouldDrop is the issue?
Use the scheduler lol
he already used TimerTask which is more similar to BukkitRunnable so i told him to use that
๐ค
How does one trigger an advancement at top right with custom message, etc
the randomize drop work, then it got stuck on chance so amount does not even load
huh?
it displays item from random index, but shouldDrop returns true always
something is wrong with shouldDrop function or idk
//this part works
DropItems randomItem = dropListItems.get(randomList);
if (!event.getBlock().getType().equals(Material.STONE)) return;
then it get stuck in this if
if (randomItem.shouldDrop(random)) {
player.sendMessage("item" + random);
block.breakNaturally();
}
random.nextDouble < chance should not always return true unless chance is either very close to 1 or greater
i understand ;/ but it look at the return
cuz when it doesnt drop it doesnt print?
wait where are u printing?
in or out the if?
i can do both sec
so shouldDrop(random) returns always true ;/
why
ThreadLocalRandom random = ThreadLocalRandom.current();
public boolean shouldDrop(Random random) {
return random.nextDouble() < chance;
}
I'm passing the random from StoneBreak method
So why does it not give the same result? There's typo somewhere?
did u extend random and make it always return 0 or something?
cuz that's stupid no one would do that
@EventHandler
public void onStoneBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
ThreadLocalRandom random = ThreadLocalRandom.current();
int randomList = random.nextInt(dropListItems.size());
DropItems randomItem = dropListItems.get(randomList);
if (!event.getBlock().getType().equals(Material.STONE)) return;
if (randomItem.shouldDrop(random)) {
ItemStack item = randomItem.makeItem(random);
player.sendMessage("Should drop: " + randomItem.shouldDrop(random) + ", Item: " + item.getItemMeta().getDisplayName());
}
randomList works so random.nextInt gets one item from range Ayo, Essa, Bruh
@EventHandler
public void onStoneBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
ThreadLocalRandom random = ThreadLocalRandom.current();
int randomList = random.nextInt(dropListItems.size());
DropItems randomItem = dropListItems.get(randomList);
if (!event.getBlock().getType().equals(Material.STONE)) return;
boolean drop = randomItem.shouldDrop(random);
player.sendMessage("Should drop: " + drop );
if (drop) {
ItemStack item = randomItem.makeItem(random);
}
}
let me see shouldDrop again?
public boolean shouldDrop(Random random) {
return random.nextDouble() < chance;
}
print chance
and random.nextDouble
public boolean shouldDrop(Random random) {
double num = random.nextDouble();
sout(num + " , " + chance);
return num < chance;
}
something like that
what was it the chance?
// called asynchronously
@Override
public boolean canInteractWith(@NotNull Player ownedPlayer, @NotNull Player player) {
ChatRange range = this.config.getLocalRange();
synchronized(this) {
return player.getNearbyEntities(range.getX(), range.getY(), range.getZ())
.stream()
.anyMatch(e -> e == ownedPlayer);
}
}
is synchronization bad in this instance
i dont want to cause a deadlock or race condition on the entity "map" or whatever the fuck handles it
are u doing it async?
ohhh
yeah shouldDrop had no access to chance lol ;-;
i would ping 7smile7 but hes offline
honestly i doubt
i heard it's hard to do that
not impossible tho
when a CPU attempts to do two operations at once
it can spur out something completely unwanted
or freeze
(deadlock)
btw why dont u use Bukkit.getOnlinePlayers
because they are both waiting for eachother
im getting the players near this player
what if there are 15,000 players online?
in that specific area?
one sec
also
im not checking .equals
it is a memory location check
very speedy, no need to worry about the speed of comparison
think this throws an exception
Any way to check when player held item changes? Should i use scheduletr or is there any event
for what reason?
ok i may be asking a dumb question here
but doesnt synchronised mean 2 threads cant execute it at once
it doesnt mean that it's magically on the main thread?
.
im unsure
if i synchronize it, idk if asynccatcher will recognize it
im testing it rn
it would
probably
nah i dont think thread jumping is that easy
declaration: package: org.bukkit.event.player, class: PlayerItemHeldEvent
btw what i was getting at by suggesting to use players and filter them instead of using getnearbyentities is that interanlly, getnearbyentites probably gets all entities in the world and filters them
i dont see how else getNearbyEntities could get the nearby entities
code is straight up unreadable
fair enough
i tried to figure it out but couldnt understand
it seems as if it does iterate all tho
wait no i think it does use chunks
i was about to say
wait
what am i doing
just get the distance from the players
my code was this before because i didnt haved the ownedPlayer parameter
forgot to update the code lol
hello frostalf
so, when you use getnearbyentities it will get the entities in the chunk in the location you have
but that cant be called async
it can be if you have a chunksnapshot
yeah
Kk
The method would be:
@EventHandler
public void onPlayerItemHeld(PlayerItemHeldEvent event) {}
Like this?
yeah
Kk
what I need to put here if I have an uuid as string
Thanks
How to give a strength effect to a player (Strength effect is not in PotionEffect)?
do you want to give a potioneffect?
Yeah
Best
You need to actually put an enchant to the item.
which enchantment can be applied to every item? for example paper
You can apply any enchants to any items (items with ItemMeta) iirc, as long as you add the enchant from the ItemMeta
Caused by: java.lang.IllegalArgumentException: Specified enchantment cannot be applied to this itemstack
at org.bukkit.inventory.ItemStack.addEnchantment(ItemStack.java:394) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at pl.botprzemek.methods.DropItems.makeItem(DropItems.java:98) ~[?:?]
at pl.botprzemek.handlers.StoneDrop.onStoneBreak(StoneDrop.java:65) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
... 23 more
Are you using ItemStack#addEnchant?
nah just change item.addUnsafeEnchantment instaed of addEnchantment
i guess you could do that too
I am trying to code a plugin that creates a 10 second window whenever someone joins the server where players can say "wb" and trigger an effect. I figured out how to make the 10 second window, but if a second player joins inside of that window, their welcome time gets cut short.
To solve this problem, I decided to create a counter that will detect when a player has joined inside of the window, triggering an if statement that cancels the task that would close the welcoming window.
However, I am having trouble with how to restart the task. Right now, players would be able to say "wb" and trigger the effect forever.
Or did I fix the problem?
My brain at 2:30 in the morning, LOL
so all you want is for players to have a 10 second window to say welcome back?
i woulnt do this with a single Runnable for each join tbh
i would have a Map<UUID,Long> storing the player mapped to the time they joined.
i would store a central runnable and when a new player joins reset that runnable to a new one
then just have an update runnable that runs every say 2-3 seconds to remove any expired entries. also checking this when a player sais 'wb'
that will introduce the same problem when multiple players join
cancel the one already set then
then the one set will have his 10 seconds cut short?
yea
he doesnt want that tho i think
that whatever array you are trying to read the length from is null
why do you not want to use an embeded resource?
I suggest you re-think your design then. Requiring hundreds of yaml files is probably not the best path to take
why not use the db for 100%?
what are you calling a config? Config is generally one file to configure the plugin.
If you are talking about player data, then thats db stuff
what is this "hundreds of files" then?

all data should be in the db, all config stuff should be in the plugins config.yml
I see nothing there which is deserving of its own config
Does anybody know why the if statement would return false the second time a player joins?
Sorry, I had some extra stuff in there so I could diagnose what the problem was
probably a new player instance which is being created
means the list doesnt contains that exact object
Thanks, I will give that a shot
private int needed_entries;
private int needed_clicks;
private int from_seconds;

YES!
doesnt have to be
nope
constants would be uppercase
underscores are totally fine in any variable name
there is no convention which says otherwise
it just looks so much better with camel case
depends
personally
It worked ๐
or work for 3 years on the same project and always only add features instead of refactoring
I will keep that in mind. Thanks!
and now its too big to refactor it
so you have to recode it or continue what you did the past 3 years
is there an event for enchanting?
ik there is PrepareItemEnchantEvent but I want to listen to when the player presses the enchant button and not when the player is preparing the enchantment
ok thx
how do events work in nms?
Events are API not nms
can you even react to what the api calls events in nms then?
those are packets not events
If you are looking to use NMS, have a VERY valid reason. Something you can't do with the API
I'm aware of that, I'm just a bit curious atm
NMS really is something you should steer clear of unless there is no alternative.
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
you should probably do the opposite especially if what you are doing is very minimal. Makes no sense to depend on a large lib for something small
makes sense
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
I love it when people attempt to use NMS but don't understand how to add it
those are NMS classes. you should use Mojang Mappings to use them
actually, those classes you should not use at all
they are relocatet 3rd party libraries
yep
i've added the jar to my artifacts, not working on minecraft server why
Hit a bigger blunt
who is blunt
Tbh I don't even have a joke for that
instructions unclear, hit a random woman on the street
Why is the loot always empty?
public void loot(LootGenerateEvent event){
ArrayList<ItemStack> collection = new ArrayList<ItemStack>();
Random random = new Random();
for (int i = 0; i < random.nextInt(); i++){
collection.add(getRandomItem());
}
event.setLoot(collection);
}```
getRandomItem() returns random item
when i open chests they're empty
This will most probably crash your server now and then
why
What does random.nextInt() do?
you must be very lucky for it pick a small number
You could end up with 2 billion bits of loot ๐
actually no
you will only ever have 1
hm?
Or something negative
Because it returns a random between -2.1b and +2.1b every time the loop made one cycle.
So statistically it will be far less.
ok so now I have this but the items in a chest are similar
public void loot(LootGenerateEvent event){
ArrayList<ItemStack> collection = new ArrayList<ItemStack>();
Random random = new Random();
for (int i = 0; i < random.nextInt(1, 4); i++){
collection.add(main.getRandomItem());
random = new Random();
}
event.setLoot(collection);
}```
example:
btw the solution here is to add constraints:
int lootAmount = random.nextInt(1, 33); // Will be 1 <= x <= 32
for (int i = 0; i < lootAmount; i++){
collection.add(getRandomItem());
}
Dont call nextInt inside the condition. Its an expression that gets called every time the loop made one cycle.
right
This means getRandomItem() doesnt really return a random item
how i overwrite item property like Mixin in fabric
Im just new to spigot
Define what you mean by overwrite
it does tho
example:
Nice. Then your code works
all the items are similar
example like: snowball has limit at 16 snowballs in a slot, now i want to overwrite it to 64
i don't want it to be
I think thats just how minecraft distributes the items inside a loot container
You would need to use reflections for that. And even then you cant be sure that the client wont have weird behavior.
maxStackSize is a property in Item
is that possible to create potion with unusual duration? For example regen potion for 8 seconds
Sure
Just modify the PotionMeta
declaration: package: org.bukkit.inventory.meta, interface: PotionMeta
Thank you, can i also give to player 3 stacked potions?
does anybody know why my plugin doesnt work
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
youre missing a bit of context
server not turned on?
A neutrino hit your pc while compiling and caused a bit error in your jar.
Sun Spots! we are all doomed
We need more context. Send your code or explain what you are doing.
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
i was just reading about those
near-valueless electrons, no?
falsely set off dark matter detectors
thats amazing
Show your JavaPlugin class
wdym
Looks
good to me. Is it enabled when you start the server?
Check by typing in
/pl
If he makes me read code like that then he can read answers like that
๐
i wanna pin that so badly
wait
wdym /pl
where
into the command box
Thats a command which lists your plugins. Execute it as a player or in console
in your bottom left
try /plugins
i think
no perms
are you even on spigot
that would fix all of my issues
๐
LMAO
we dont talk about this
wait
Where were you even putting your plugin jar
in the plugins thing on the server
what plugins thing if you started a vanilla server
Arenโt you on a vanilla server though?
what drugs did you take
Or did you manually make a folder called plugins
"my pLugIn isNt loAdinG on muy vaNilLa seVer. HEHLP. Why iSnt thIs wรถrKing"
Thats my laugh for the day. You have to stop now. I'm a married man and only allowed one.
F
are you a rock fan
Lmao
Wow. Thats ageist.
there was already a folder called plugins
?
on the server provider
Ok
alzheimer
Putting the server in the root folder smh
Does /version exist on your server?
but why would they bait him with a fake plugins folder
evil
It might have been some installation mistake
Did you install Spigot on your provider then switch it back to Vanilla
They probably use the same docker hierarchy and just swap out the jar for all the forks.
i think i did yeah
Ah, I guess theyโre lazy
Did you also type in the commands into console?
thats why i got confused because i forgot i went back to vanilla
wdym commands
what commands
when i was doing /plugins i did it in chat
yeah just switch to spigot then
s
oh man, it's been a long time.
How should i send a message to the console saying that the plugin has started?
I even forgot how to do this
you should not, spigot does that for you
it does?
You dont. Spigot already does that. But if you want to send a message anyways you should
use the logger for that. Something like
getLogger().info("--------------------------------------------------------------------------")
getLogger().info("
โโโโโโโโโโโโโโโโโ โโโโโโโ โโ โโโโโโโโโโโโโโ โโ โโโโโโโโ โโโโโโโโโโโ โโ โโโโโโโโโโ
โโโโโโโโโโโโโโโโโ โโโโโโโ โโ โโโโโโโโโฃโ โโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโ โโโโโโโโโโ
โโ โโโโ โโโโ โโโโ โโโโโโโ โโ โโโโ โโ โโ โโโโโโ โโโโโโโโโโโโโ โโโโโโโโโ โโโโโ โโโโ
โโ โโโโ โโโโ โโโโ โโ โโโโโโโ โโโโ โโโโโโโ โโ โโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโ โโโโ
โโโโโโโโโโโโโโโโโโโโ โโ โโโโโโโโโโโโโฉโโโโฃโ โโโ โโโ โโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโ โโ โโโโโโโโโโโโโโโโโโโโโ โโโ โโโโโโโ โโโโโ โโโโโโโโโโโโโโโโโโโโโโ
");
getLogger().info("----------------------------------------------------------------------------")
Admins love those
oh cool, thx
haha this is so true
yes, I'm always disappointed when a plugin does NOT spam the console with this
how am I supposed to know that cool plugin was enabled if it doesn't create a 2mb log file with a huge ascii banner
exactly
i would have forgot i had this plugin
i tried that once, my compiler made all unicode into ???. Did that change since then?
imho plugins should call cowsay | lolcat for these sweet banners using a ProcessBuilder and fail to enable if that's not installed
XDD
Use utf-8 file encoding
You can even do that in 1.7.10
k
You can also replicate that for newer versions with color gradients.
and then paste it every 20 seconds with a different text
I'm an annoyance not a nuisance
what's the new correct way of checking for an item's durability?
(since ItemStack#getDurability() is deprecated)
^
and import the CORRECT DAMAGEABLE
declaration: package: org.bukkit.inventory.meta, interface: Damageable
the world will end
i think we still have a few billion years
but the earth is having a midlife crisis right now
that should be reassuring since it's already this old
that's why it currently engages into selfdestructive behaviour
chasing waterfalls and stuff
aaand now theres two of them
two of what
you
set their upwards velocity to .37 iirc
yea
cool
as long as your java version is >=8
you mean jdk
both
What is the event used for Chat message sent or smt
AsyncPlayerChatEvent
like if someone sent a message in chat
what does Async mean?
why is it gray
that it's not running on the main thread
looks like it's outside of any class declaration
Please dont...
pls don't whut
oh... so that's why...
you will never use my plugins
I constantly have to explain that async doesnt mean multithreaded. Dont lead him there.
i log nothing
You can do stuff async on the main thread
but the chat thing is running on its own thread
is the 'brandon' supposed to be gray
It may run on a different thread. But thats also not always the case.
I just wanted to clarify that async != different thread
oh yeah I didn't want to say that
async means there is no thread
async = performance
While true, most will not understand this. Saying runs off the main thread is much simpler adn mor elikely they'll understand
yes. async + nms = super fast
yep! Also consider upgrading to 1.8 for that sweet delicious extra performance
some people will claim 1.8 is outdated but they just don't know better
i'm running a 1.8 server on windows xp with 11 billion players on 2mb of ram. async, of course
No ?
yes
There is actually a project that implemented the minecraft protocol which is multi threaded.
Sometimes
dont talk to me if you have "dev" in your name
No ?
yes
Lmao
If you do 1 + 1 async then its about 20% faster than 1 + 1 sync.
for larger numbers it's even faster
Lol, has this channel turned into the bullshit channel today? ๐
i have no idea if they're meming or not anymore im just confused
Good joke
I really hope theres no one here listening
buy a movie ticket sync and async and see whats faster
I bet you even get a discount on async
lufthansa is now doing their flights async too. berlin <> new york for example is 2 hours faster when the pilot goes async
Someone is going to come back in 6 months and say "But 7smile7 said it was faster!".
jokes aside though, isnt there a mod that exists that makes worldgen run on a different thread or smth?
^when the main people in this channel are bullshitting all together
minecraft already supports async chunk generation. There are spigot forks that exposed this in their api.
Ok, Professor
yesssssssss, my physical server just died whenever i had updated to 1.19 and i wanted to try and salvage it however i could so that might be it
sry but this sentence makes no sense to me...
my bad for my english. let me try and reformulate
get a defibrillator and revive it
1.17 runs fine on my server
but 1.18 and 1.19 are getting around 19TPS with everyone offline, no plugins and there isnt any crazy redstone machine hidden somewhere, its just a building world
the server has 4 cores and currently 1.19 makes it use one of them to 100% almost constantly, so i've been searching for a way to even out some load to the other cores
looks like a #help-server
ye it does
Are you running an i3 from 2004 or what?
nope
Amd FX idkthemodelanymore
so yeah its old
ddr3 even
i just cant bring myself to trash it
ddr3 isnt old. I had an i7 4770 on my root server and it was totally fine with 50 concurrent users on 1.16
yeah but did it have 7G of mismatched ram with all different frequencies?
and also this
1.16 is shit
1.16 was nice when it came out
it runs on my crappy server though
was the seaweed fixed already then
it was shit since 1.17 came out
i do like to stay at 1.16 though, if anybody ask me to
how can you live without goat horns?
note blocks
havent tried them yet so i'm not yet addicted
range sucks
custom ones
thats my new plugin idea
there are villager's horns anyways
oh true
oh right does anyone know if they mucked up note blocks ?
theyre enums
new potionEffect(potionEffectType.glowing, 100)
yeah
public void slowHisAssDown(Player player) {
int durationSeconds = 20000;
int potionLevel = 1;
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, durationSeconds * 20, potionLevel));
}
now add it
^^^^
?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.
How can I get the burn time of a certain fuel item?
Not through the api iirc.
Hover over the red warning and see what it says. You are going to jump through a few stages before you figure it out
So then how can I get the remaining time a fuel item has within a furnace?
Because the furnace only provides the current burn time
Have you tried those?
^
Cook time is the progress of the "recipe"
does anybody here wanna help in dms for rly specific questions
just ?ask
I really have to use NMS just to get how long something burns?
?ask is the real one
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
u sure? Wasnt there a getFireTick or something?
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.
GLOWING
yup
Its honestly a bit weird. Someone should make a PR for this
bukkit.getplayer(args[])
why no workz
nothing about material burn time
i'd just include the burn times in a resource file and read that
looks like the "best" option
if you want one that will work past version update and that you really shouldn't do but that still doesnt use nms
- place a furnace in the world
- put in the item you want to burn and get the game time
- repeat every time you need it
e
||Disclaimer : don't actually do this it's just bad||
e
iirc wiki has burn time in seconds
Well, how do I get the minecraft type from a item stack
Hardcoding shit is not a viable solution for this
stack.getItem().getType or smth
This is what i reverse engineered just now.
public Item fromMaterial(Material material) {
String mcKey = material.getKey().getKey();
Registry<Item> itemRegistry = Registry.ITEM;
return itemRegistry.get(new ResourceLocation(mcKey));
}
This just works, no need to overcomplicate it
Alright
where is that from
I just followed the path through the items class.
Luckily I already have stash access from fixing the worldgen random issue
I think Material should have a method getFurnaceBurnTime() that returns 0 or -1 for non burnable things
I didnt find that
yeah with "should have" I mean someone should add it ๐
Furnaces have a getCookTime#short to get the current cook time, and a getTotalCookTime#int for how long this item takes to cook in total
It would be quite easy to implement because the burn times are already exposed
Though while it has a getBurnTime#short, it lacks a getTotalBurnTime
Might as well add both then
idk why the chest is always empty. the variable item is fine after i checked but the resulted loot in the chest is nothing. any ideas?
public void loot(LootGenerateEvent event){
List<ItemStack> collection = event.getLoot();
for (int i = 0; i < collection.size(); i++){
ItemStack item = getRandomItem();
collection.set(i, item);
}
event.setLoot(collection);
}```
Is this the only listener for your LootGenerateEvent?
yes
Any exceptions being thrown? Because i can imagine that event.getLoot() returns an immutable list.
I was debugging and i saw the event.getLoot() is the actual vanila generated loot and that getRandomItem() is actually a random item.
gives a random item
yeah, code?
here is an example of debugging. the first in each box is the vanila loot and the second is getRandomItem()
If getRandomItem works then this looks fine. Make sure you actually compile -> stop server -> upload -> start server
i made sure
what?
not sure when you are using eclipse
but if you are using intellij press the hammer
i just checked and the collection.set does set the item in the slot to the random item
idk what could be the problem
Interesting. I have the same problem...
public void loot(LootGenerateEvent event){
List<ItemStack> collection = event.getLoot();
for (int i = 0; i < collection.size(); i++){
ItemStack item = main.getRandomItem();
System.out.println(collection.get(i));
System.out.println(item);
collection.set(i, item);
System.out.println(collection.get(i));
System.out.println("--------------");
}
event.setLoot(collection);
}```
it does actually set it
but the chests are empty
then event.getLoot returns the actual list of loot and not a copy, like some events do
I fixed it by creating a new collection
@EventHandler
public void loot(LootGenerateEvent event){
List<ItemStack> collection = new ArrayList<>(event.getLoot());
collection.replaceAll(current -> new ItemStack(Material.STONE));
event.setLoot(collection);
}
So for you it is:
@EventHandler
public void loot(LootGenerateEvent event){
List<ItemStack> collection = new ArrayList<>(event.getLoot());
collection.replaceAll(current -> main.getRandomItem());
event.setLoot(collection);
}
Or
@EventHandler
public void loot(LootGenerateEvent event){
event.setLoot(event.getLoot().stream().map(i -> main.getRandomItem()).toList());
}
Because less lines = faster code 
I need new code for getting new location when moving x blocks forward
Works fine when its straight, but when its rotated somehow, it doesn't work anymore
public static Location getMoveToLocation(Ship ship){
Location current = ship.getCurrentLocation();
Location newLoc = new Location(current.getWorld(),current.getX(),current.getY(),current.getZ());
Vector dir = new Vector(ship.getCurrentLocation().getDirection().getX(), 0, ship.getCurrentLocation().getDirection().getZ());
int speed = (int) (ship.getSails().getOpenStatus().getValue()/10*ship.getCurrentSpeed()*ship.getSails().getStrength());
int bpt = (int) 0.1; //Blocks Per Tick
int blocksMoved = speed;
if(dir==null){
return null;
}
newLoc.add(dir.multiply(-1*blocksMoved));
return newLoc;
}
You need to change the direction of the ships location when you rotate the ship
ye but how do I get direction from one location?
What do you mean? You already get the direction from one location.
ship.getCurrentLocation().getDirection()
the pitch and yaw gives the direction ^
ye but I need to calculate the direction so I can set it to the location when rotating
Then do that
Hello guys,
I just watched the new 1.19 version, and I can't find the "setCustomName" method on EntityLiving. I know that last time it was a(IchatBaseComponent ..).
Anyone knows new name of the method pls ?
IchatBaseComponent are you talking about NMS?
Yep
Thanks this website is sick!
EntityLiving is not an actual class (if you use the mojang mappings (which you should))
isn;t it setCustomName Component.fromText(...) or something?
In nms entity there is this method
Is there a way to convert a float into a Vector?
context
A single Float no, not unless it has an axis
In bukkit yep, but not in the net.minecraft.server.world.entity.Entity nor EntityLiving. It seams it's now called b(rn
Sure. There are tons of ways:
float f = 0.1F;
Vector v = new Vector(10 * f, (float) Math.PI * f, f * f * 0.01F);
I have yRotation ( float )
And I need to calculate based of that Vector of whole 'Ship'
With yRotation you mean yaw i suppose? Or a rotation around the y axis
How do you represent your ship ?
like this
around y axis
Pretty sure you mean the yaw...
oh yeah
im not comfortable with yaw/pitch namings
Ok so you want yaw -> projected vector
yep
I meant do you have any axis, etc... ? x)
I have current rotation in which the ship is steering aka yaw
If you want to rotate some vectors, you should multiply your vectors with the rotation Matrix
you do some sin cos shit
Vector vec = new Vector(Math.sin(yaw), 0, Math.cos(yaw));
``` i think
He's in Spigot so I'm not sure what he's trying to do. Vector has all the math you need
convert yaw to look vector
i think
but thats how you do it right
public Vector fromRot(float yaw) {
return new Vector(Math.sin(yaw), 0, Math.cos(yaw));
}
damn i got sniped
if you want to adjust a heading and get a vector just Location.setYaw(float) then getDirection()
@twilit roost We need to know what you have in input and what you're looking for in output
For those wondering, yep the setCustomName nms method is now b(IChatBaseComponent)
Most here who use nms use MojangMappings, so still use setCustomName
Okay
this should do it
like x = sin(yaw), z = cos(yaw), will give x = 0, z = 1 for yaw = 0, which is forward so that checks out
I think I may have found a spigot bug, could anyone confirm?
When you attempt to damage a mob outside of attack range, specifically if there is a block behind that mob, no interact events of any type are fired.
So in the range far enough to not attack an entity but close enough to be able to to target a block, no interactevents trigger. Does anyone know of a workaround or know of any events that do trigger in this case?
this issue was found while testing an attack range custom attribute
What version are you on?
1.19
the weird thing is that absolutely no interact events trigger, despite me definitely left clicking with an item in my hand
if i go outside this range interact events start triggering again, if i get too close i just attack the entity
This might be client side. Check the packets sent by the player.
But if you leftclick with an item in hand then the interact event will be fired regardless of any blocks or entities in your way.
in order to achieve what exactly?
yeah, it would round it to the closest whole coordinate
If you dont care about exact precision then just cast it to an int
that would result 45, 44.4999999 would output 44
casting to int i believe would round it to the first number down right? so 44.9 would become 44 i thought
havent played around with it a lot tho
because any decimal places are just chucked out
public int fastRound(double num) {
return (int) (num + 0.5);
}
Yup that works
or (int) Math.floor(double)
"slow" round
its all one line so it must be faster than your 3 line method ๐
true
Im posting this just in case you realise and delete it later ๐
or 0.499
