#help-development
1 messages · Page 2200 of 1
was your inventory empty when you jumped in?
how can I make an item not stackable?
set the max stacksize to 1 first guess
you can apply some unique nbt
StackSizes are fixed in teh client add PDC/NBT tag
yes
Your math has to be off somewhere then
^ can't count any higher without taking shoes off. Mutant.
well you can easily change them
noob
You can? Sizes are based upon material. I know you can set teh stack size for an Inventory but don't know about an ItemStack
oh yeah that is true, it can only be changed per material, not per individual itemstack, if that's what you meant
ah ok
for view distance, which one is the tick distance?
for player.getViewDistance(), getClientViewDistance()
view-distance = how far you can see
simulation-distance = distance where physics work etc
oh so i can get that from the server instead of the player?
we live in a simulation
and its the same for every player?
is that the max stacksize for each item in the inventory?
you can get both from Bukkit
Bukkit.getViewDistance() and Bukkit.getSimulationDistance()
gotcha
yes
ahh
you can also get the player's view distance, which could be lower than the server's view distnce, but never higher
ah i see, the int is in blocks right
alright
yeah it would be weird if it'd be blocks since the default is only like 8 or so lol
from what I know, max stack sizes are set on the Material class. At least that is how I did it in my stackresize plugin lol
where is the problem with this?
wait I'll record it
to set max stack sizes per material:
- change the value on the Material class' "maxStack" field (https://github.com/JEFF-Media-GbR/JeffLib/blob/dc71756f3b0371480d4895a9c1ec7834e8aca9c9/core/src/main/java/de/jeff_media/jefflib/MaterialUtils.java#L78)
- change the value on the NMS Item's class "maxStackSize" field (or however it's called in mojang mappings) (https://github.com/JEFF-Media-GbR/JeffLib/blob/dc71756f3b0371480d4895a9c1ec7834e8aca9c9/core/src/main/java/de/jeff_media/jefflib/MaterialUtils.java#L78)
- add a shit ton of listeners to prevent weird bugs happening, for example duplication of the bowl when eating a sus stew, or stuff like disappearing buckets when you stacked them and then empty only one of those
hello my friends
i'm not your friend, pal
i'm not your pal, buddy
etc
i'm not your buddy, mah friend
and now it repeats forever
so why are you answering me?
it's from a south park episode or sth like that lol
sorry didnt want to confuse you lol
but this was a joke also #help-development message
hello, friend.
oh no not again lol
yes but you can still use it. it will not be removed
the other way would be to loop over Bukkit.getOfflinePlayers()
I would simply use the deprecated function. it's only deprecated because players can change their name and then the server wouldnt know about it
oh, okay thank you
mojang api call: am i a joke to you?
it won't be removed anytime soon I guess
really?
the getOfflinePlayer method will make an api request to mojang if it couldnt find a player with that name in the offlineplayers list
I thought about it, but I don't think it's a good idea.
oh okay friend thanks
to the person who claimed you can now get rid of NMS for totem animations: you liar!
playEffect(EntityEffect) will be visible to ALL players, not just the player one is calling this is on
i mean, you can play the effect to all players but cancel for the ones that shouldnt get it via NMS/packets
lol that idea is so stupid, I love it
basically that's the problem
it only works the first time, the 2nd time I don't appear in the set
delete guildcraft
Those are preadded, I don't play on any of those servers xd
send full code and not just a snippet
and what exactly is the problem? that the second player doesnt disappear?
yep
yeah the gui is not updated
Player#updateInventory i guess
that only updates the players inventory
its probably within the gui class
I don't really get what the problem is at all lmao. Two players online, it shows both, one leaves, it only shows one again. am I stupid or sth?
It's a custom gui
the second one leaves as well
you can add System.out.println("Something"); to check if event is called for second player quit event
Look at the end of the video, the 2nd player leaves too and it still shows him in the gui, not closing it like the first time when there was only one player
i wonder what happens if someone gets kicked who has the inventory opened 
the server crashes
oh
InventoryCloseEvent followed by PlayerKickEvent
Wait I'll send the full code
but he doesnt cover that
oh I thought your question was about in general whether an InventoryCloseEvent is called for players who get kicked
lol
my english is cursed today

maybe I shud just start tahkun lik dis
wasnt there once a guy who talked exactly like this
oh yeah and he also always send one or two words per message so
sure?
then i feel like i should use the kickhammer
yeah unfortunately you don't have any kick permission here :<
if (plugin.trollManager.getTrollableOnlinePlayers() - 1 > 0) {
are you sure that that doesnt also contain the player who opened the inv?
public int getTrollableOnlinePlayers() {
int[] trollable = new int[1];
Bukkit.getOnlinePlayers().forEach(all -> {
if(!all.isOp() && isTrollable(all) || all.isOp() && plugin.trollOperators) {
trollable[0]++;
}
});
return trollable[0];
}```
Should return everyone who is able to be trolled (also the one opening the inv) and that's why I do -1
how dare you to underestimate me

wow yeah that is one weird way of counting
yeah true was kinda a work around for now I guess
using a 1 length int array in a forEach lambda to count the members? lol
that is creative at least
xd
becuase hes using a consumer
final context
use a normal for loop or a stream
32 ServerLevel wrld = ((CraftWorld) player.getWorld()).getHandle();
33 wrld.tryAddFreshEntityWithPassengers(cart);```
--->
```Caused by: java.lang.AssertionError: Unknown entity class games.tress.railpack.Railcart
--cut for message length--
at java.util.stream.Streams$StreamBuilderImpl.forEachRemaining(Streams.java:411) ~[?:?]
at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734) ~[?:?]
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762) ~[?:?]
at net.minecraft.world.level.WorldAccess.addFreshEntityWithPassengers(WorldAccess.java:16) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3497-Spigot-b081915-b02801a]
at net.minecraft.server.level.WorldServer.tryAddFreshEntityWithPassengers(WorldServer.java:1023) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3497-Spigot-b081915-b02801a]
at net.minecraft.server.level.WorldServer.e(WorldServer.java:1011) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3497-Spigot-b081915-b02801a]
at games.tress.railpack.Railpack.onCommand(Railpack.java:33) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[spigot-api-1.18.2-R0.1-SNAPSHOT.jar:?]
... 21 more```
I know but why not just a normal for loop or a stream
you assert stuff that's false in line 33 of Railpack
What's the stream thingy? Never used it I guess
java 8 streaming api
added line numbers to codeblock
?bing
Bing your question before asking it:
https://www.bing.com/
making a test command so i can test without needing to make the item to spawn it, etc yet (cus it cant be summoned)
for example
public static int getNumberOfTrollablePlayers() {
return Bukkit.getOnlinePlayers().stream().filter(player -> !player.isOp() && isTrollable(player)).count();
}

should i apply Stream#filter on prev filter or apply all filters in the same method?
just wondering
send the full error msg pls
I'd use "one filter per purpose"
👍 couldnt fit it in msg ill split
at org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity.getEntity(CraftEntity.java:409) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3497-Spigot-b081915-b02801a]
at net.minecraft.world.entity.Entity.getBukkitEntity(Entity.java:165) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3497-Spigot-b081915-b02801a]
at org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.doEntityAddEventCalling(CraftEventFactory.java:608) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3497-Spigot-b081915-b02801a]
at net.minecraft.server.level.WorldServer.addEntity(WorldServer.java:1000) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3497-Spigot-b081915-b02801a]
at net.minecraft.server.level.WorldServer.addFreshEntity(WorldServer.java:937) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3497-Spigot-b081915-b02801a]
at net.minecraft.world.level.WorldAccess.lambda$0(WorldAccess.java:16) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3497-Spigot-b081915-b02801a]
at java.util.stream.Streams$StreamBuilderImpl.forEachRemaining(Streams.java:411) ~[?:?]
at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734) ~[?:?]
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762) ~[?:?]
at net.minecraft.world.level.WorldAccess.addFreshEntityWithPassengers(WorldAccess.java:16) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3497-Spigot-b081915-b02801a]
at net.minecraft.server.level.WorldServer.tryAddFreshEntityWithPassengers(WorldServer.java:1023) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3497-Spigot-b081915-b02801a]
at net.minecraft.server.level.WorldServer.e(WorldServer.java:1011) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3497-Spigot-b081915-b02801a]
at games.tress.railpack.Railpack.onCommand(Railpack.java:33) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[spigot-api-1.18.2-R0.1-SNAPSHOT.jar:?]
... 21 more```
you can also just use ?paste
"filter(Predicate.not(Player::isOp)).filter(Predicate.not(this::isTrollable)) lol
Predicate.and being a thing
Full Error -> https://paste.md-5.net/bamobugaji.rb
Full Main Class (if it helps) -> https://paste.md-5.net/uponohilem.java
Full Cart Class (if that helps) -> https://paste.md-5.net/wubogewewo.java
It's returning me a long somehow lol
I doubt that any server would be capable of having more than 2.7 billion players lmao
wrong quote
rip
the method to spawn entities in NMS looks like this
you are extending AbstractMinecart which is in none of those if blocks
aight got it
you have to extend an actually spawnable entity
ahh
like for example RidableMinecart
the main problem tho is still there, the gui is not updated the 2nd time :(
i thought it made more sense to do the Abstract bcus i was replacing so much
didnt realise i was being stupid
well actually the NMS code to spawn entities is stupid lol
I mean just look at what I sent
that's so weird
anyway it should work fine if you just extend any of those actual "concrete" minecart variants
heyy it actually works
didnt expect to get this far lmao thanks for feeding me the answers
RIP why did spiget stop working for paid plugins
wdym?
PaginatedGui gui = Gui.paginated().title(Component.text(StringManager.INVENTORY_TITLE_PLAYER_SELECT)).rows(6).pageSize(45).create();
for(Player all : Bukkit.getOnlinePlayers()) {
if(all.getOpenInventory().title().equals(Component.text(StringManager.INVENTORY_TITLE_PLAYER_SELECT))) {
//do stuff
}
}``` any idea why this is not working? Shouldn't I be able to compare the inventory title like this?
why are you calling a player variable all
that's put somewhere else
and make that component a variable
it was just to demonstrate
is inventory a record?
hey everyone, how can i send a colored message to console?
i tried ```java
getLogger().info(ChatColor.GOLD + "Enabled!");
but in the console output i see this:
whut?
cuz title() and not getTitle()
Don;t compare titles, compare instances
I still can't compare cause the gui is not a global variable
make the Inventory available to test against
Hey, since the new 1.19 messages of component Builders start with "<> ". Is this a bug, should I report it? Or is this a new "feature" and I have to change something in my code?
do they?
I can't post a screen here
verify
daddy
here as well
mom -> moment
no
😦
ComponentBuilder builder = new ComponentBuilder();
builder.append("\n");
builder.append(HardCoreSMP.toBaseComponent(Constants.PREFIX + "§7Herzlich Willkommen auf dem §eHardcore SMP §7von §eXYZ!\n"));
// More text here
player.spigot().sendMessage(builder.create());
Why is this giving an error?
your prefix?
what api version and what server version?
make sure they're compatible
lol
smh
Collection.singletonList when
i always see people creating a list and then adding stuff manually
i mean whats wrong with Arrays.aslist
good question. IntelliJ tells you to use Collection.singletonList when you have an Array with only one item.
his ide doesnt seem to tell that
Arrays.asList is an immutable list
would it matter?
depends on teh use case
in his use case, where he has only one line of lore
You can't add nor remove from an immutable list
ik that but i dont think the server should do that either
mwoa ye personal thing 😆
Its also habit forming.
hmm I updated to spigot-api:1.19-R0.1 and now org.apache.commons.lang.StringUtils is gone :(
?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 sure you are not depending on spigot and not spigot-api
im on spigot-api
then you are getting it from some other dependency
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, HardCoreSMP.toBaseComponent("§7Teleportation in §6" + (int) Math.ceil((20d - s) / 2) + " Sekunden"));
This will send messages in chat, not in actionbar (1.19)
update spigot
already 1 version behind 😮 that was fast
Chat in general is under a lot of changes in 1.19
you will have to stay up to date a lot, expect a lot of changes in the following days
alright, thanks
Somebody know how to correct this error?
Caused by: java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.hasItemMeta()" because the return value of "org.bukkit.event.inventory.InventoryClickEvent.getCurrentItem()" is null
tells you
getCurrentItem is null
and you're using that null value and try to call hasItemMeta on it
check if getCurrentItem returns null before you call methods on it
first check if the item is null
Oh, yeah, I understand , thanks
Anyone has some experience with Mockbukkit?
true it doesn't... now I wonder where that came from then
oh found it
Planned Removal of commons-lang
The API currently includes a very outdated copy of commons-lang. This API dependency is now deprecated and will be removed from the API and eventually the Server in a future release. Please consider switching to Google Guava (which is a supported bundled API) or using your own copy of the much more recent commons-lang3.
since java 1.3
yes
I just talked to one of the mockbukkit devs for an hour trying to solve some problem lol
Does it allow me to spawn "players" to test some features of my plugin?
yes
like if the inventory expands when more join etc
sounds good
I was about to open my launcher 55 times xD
I doubt my ram allows that tho
Now I'm running the latest version: Bungeecord commands will be executed in spigot as well. We have a global /help command on bungeecord and blocked the bukkit help command. But if a player runs /help both are executed (bungee and spigot)
lol yeah you can create 55 fake players with mockbukkit
Is it lots of work to do so or a quick thing?
it's pretty quick. just add the maven surefire plugin and mockbut as test dependencies (scope test), then create your test classes in src/test/java. you can take a look at my MorePersistentDataTypes thing to see how you can use mockbukkit
I used TextComponent to make a message which had clickable words, but if I use player.spigot().sendMessage(msg); I can't use + to add a second one, or if I use player.sendMessage("" + msg) the result will be this
wdym?
not spigot related but why is it warning me
https://cdn.discordapp.com/attachments/869965768245260358/984100177478557716/unknown.png
unchecked cast
ahh sry mb
what should i check there
do the + in the textcomponent
inside <build><plugins>:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
as normal <dependency>:
<dependency>
<groupId>com.github.seeseemelk</groupId>
<artifactId>MockBukkit-v1.18</artifactId>
<version>1.24.1</version>
<scope>test</scope>
</dependency>
(you need both)
so i literally can do nothing ?
I can't
suppress
pmz unless you are willing to provide a type provider
like Class<T> or sth as second argument
and then use Class::isInstance and Class::cast
hmmm
how is that supposed to know what T is? wouldn't that always return an Object?
how is it even supposed to know what T is smh alex just asked that
literally same question
yeah it doesn't work like that
append maybe
you need to either toss in a Class<T> or a Supplier<T> or anything similar, like here for example https://github.com/JEFF-Media-GbR/MorePersistentDataTypes/blob/master/src/main/java/com/jeff_media/morepersistentdatatypes/datatypes/collections/MapDataType.java
the componentbuilder is pretty neat
speaking of isInstance
can i check isInstance but take String like class name as the argument ?
Now I have to add classes to java/test?
yes. your classes should also include the word "Test" so that surefire finds those. Then you can use the annotations like @BeforeAll and @Test etc to setup and run your tests
like this ?
yes
Let's say I add some test commands, would I still have to register them in my main java src onEnable ?
altho that makes no inherent difference pmz
since if you for instance invoke
<ItemStack>get("blah",ItemStack.class)
and config.get("blah") returns like 1 your function will explode
why not usin' the builtin config api 🤷♂️
acc ^
return (T) config.get(path);
How do u test ur plugin in mockbukkit if it depends on a plugin thats needs to be loaded too
@tender shard
idk, my plugins never depend on any other plugins
mock mock mock mock
?
I tried doing it on mine months ago but couldn't figure out on loading other dependecy plugins
FN_FAL113 so what you do is to define an interface that facades the interaction of the other plugin
I also don't know that, but they have a discord server too
then for the test just implement a mock implementation
and use that one (or use mockito)
anyone rly bored n wanna help me register an entity (so it doesnt change back on load?) - i've been trying to learn from the pet ender dragon mod bcus it was the only one i found registering entities on 1.18
itttt does stuff but skips loading them because their id is different, so i assume means not in registry
How do u define it specifically
oh, cus it doesn't actually load the mod till after anyway 🤦♂️ idk then
yeah that's correct, where's the problem?
you can only get rid of the warning by suppressing it or by checking instanceof and throw an exception or sth if the result of config.get(...) isn't of the proper type
interface LuckpermsFacade {
boolean clearPermissions(UUID id);
}
class LuckpermsFacadeImpl implements LuckpermsFacade {
@Override boolean clearPermissions(UUID id) {
LuckPermsApiProvider.get().blah(id); //Idk if this is a thing but you get the idea
}
}
//tests
class MockLuckpermsFacade implements LuckpermsFacade {
public boolean clearPermissions;
@Override boolean clearPermissions(UUID id) { return clearPermissions; }
}
class TestSomeClass {
SomeClass some;
MockLuckpermsFacade lpFacade;
@BeforeEach void setUp() {
some = new SomeClass();
lpFacade = new MockLuckpermsFacade();
}
@Test
void givenSomeState_shouldDoStuff() {
lpFacade.clearPermissions = true;
some.blah(lpFacade);
Assertions.assertTrue(some.getState());
}
}
@sharp flare
or sth
(or use Mockito for your mocks)
i love to see that code
Great appreciate u on that
this is 99% how you test units that depend on external stuff like databases, other plugins or whatever it might be
public class AddPlayerCommandTest implements CommandExecutor {
private ServerMock server;
private Main plugin;
@Before
public void setUp() {
server = MockBukkit.mock();
plugin = MockBukkit.load(Main.class);
}
@After
public void tearDown() {
MockBukkit.unmock();
}
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String cmdLabel, @NotNull String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
if (args.length == 1) {
PlayerMock fake = server.addPlayer(args[0]);
p.sendMessage("§aAdded fake player §3" + args[0]);
}
}
return true;
}
}```
Where do I register this test command from the mock now?
and then? sry im kinda confused
then sth like
class Test {
MyCommand cmd;
@BeforeEach void setUp(){
cmd = new MyCommand();
}
@Test
void givenPlayerArgument_returnsTrue() {
cmd.onCommand(mockPlayer,mockCmd,mockLabel,"some player");
}
}```
didnt include the mocking
but yoy get the hint
you test your functions of your units
hey im trying to make tabAutocomplete for spigot, I have this class and ive registered it in onEnable()
how did you register it
getCommand("cview").setTabCompleter(new TabComplete());
``` code in onEnable
how can i make it autocomplete “glow”?
you create an array list and add "glow" then return it
if (args.length == 1) {
return StringUtil.copyPartialMatches(args[0],Collections.singletonList("glow"),new ArrayList<>(1));
}```
iirc
this is better
ill try, tysm
Hey Guys How Can I Use Vault API on my codes
Oh My bad, thanks
is it possible to use Adventure for item lore?
havent been able to find documentation for it
or is that only possible on paper
only on paper afaik
welp il just use paper api then
Im encountering an issue with yml files right now, what i had earlier was that i was loading and saving Map<String, Integer> which worked till now, and now it suddenly complains that the "killedMobs" part is a MemorySection, when earlier it accepted it as a Map. Any clue why it does that now?
I just cant tell what i changed for that to be an issue.. :(
This is my yml btw:
playerKills: 0
playerDeaths: 0
deaths: 0
suicides: 0
totalDamage: 0.0
mostDamage: 7.999999046325684
killedMobs:
pig: 1
usedWeapons:
netherite_sword: 1
usedCauses:
entity_attack: 1
When you first add a Map to teh config it stays as a Map. Once you save and reload it becomes a MemorySection
But why did it work earlier? o.O it loaded it fine as a memory section, odd
Can i just use a MemorySection in my code instead?
MemorySection#getValues(true) gets you the Map
I see, you cant use MemorySection sorta like a map directly?
/**
* If loading from file the Maps in the data
* will be stored as a MemorySection not Maps.
*
* @param entry MemorySection or Map to check.
* @return Map containing the serialised data.
*/
@SuppressWarnings("unchecked")
protected Map<String, Object> castToMap(Object entry) {
if (entry instanceof MemorySection) {
return ((MemorySection) entry).getValues(true);
} else {
return (Map<String, Object>) entry;
}
}```
Im on a bad old laptop at the moment becuase im on vacation, its windows seven so intelij is not an option and the upgrade just didnt work, does anyone know an online editor for spigot plugins?
vscode online
okay ill try it thanks
it actually works lol
time to switch to linux
what distro
Pure OS
dunno that
but the problem with the laptop is that even another OS will propably work better this thing only has an intel pentium and 4gb ram inside so you cant really use it for anything
yeah thats minimum for a lot of things, and you can only use 3.9gb
does vsc online even support spigot by default or is it an extension? @tardy delta
😂
How can I make a witch passive
you cant use the java extension pack in vsco what other alternatives are there?
thats not how an ide works, you can use maven but its not that easy as in ij
I'm trying to spawn particle at the player death location
Can you someone help me?
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e){
e.getEntity().getLocation().getWorld().spawnParticle(e.getEntity().getLocation(), Particle.FLAME);```
and i closed my browser windows and all the stuff was gone in the online vscode lol
help with what?
bumpy pumpy
Not working..
does turning off gravity avoid collision for armorstands?
you registered it?
Oh
You are right
I forgot
Please give me a minute
Huh
I still registered :/
It said, Cannot resolve method "spawnParticle"
API version 1.16
Particle comes first in teh method
bruh not working , how am i supposed to know that you got an ide error
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e){
e.getEntity().getLocation().getWorld().spawnParticle(e.getEntity().getLocation(), Particle.FLAME);
}```
also the smallest number of args is https://hub.spigotmc.org/javadocs/spigot/org/bukkit/World.html#spawnParticle(org.bukkit.Particle,org.bukkit.Location,int)
Cannot resolve method 'spawnParticle(Location, Particle)'
^^
It's not different from what wrote on the site and what I did
There is NO spawnParticle method which takes a Location as the first argument
Uh
I dont understand
Can you give me a example?
look at the order of the arguments
I'm on a really bad Laptop at the moment and can't use IntelIj, so can someone use this code https://paste.md-5.net/unitegonig.java and send me the.jar file?
lol
Just manually compile it 
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e){
spawnParticle(Particle.FLAME, e.getEntity().getLocation());
}
private void spawnParticle(Particle flame, Location location) {
}```
I tried something
Is this correct?
Closer, but no
tf
oh no
Holy whitespace batman
why are you making an extra method for that
I only saw the code. didn;t notice the extra method
I'm looking on my phone and it's bad lol
First I just did that but it wasn't enough 😄
Look at this javadoc. Look at the arguments it requires https://hub.spigotmc.org/javadocs/spigot/org/bukkit/World.html#spawnParticle(org.bukkit.Particle,org.bukkit.Location,int)
just pass in the correct parameters in the bukkits spawnparticle method
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e){
e.spawnParticle(Particle.FLAME, e.getEntity().getLocation(), 10);
}```
I think it should be correct 😄
But not
Looks fine to me
World.Environment.NORMAL is OverWorld right?
lol
Player or World has spawnParticle
what do you mean
His point is, learn to code a little bit better
Mess around in pure Java
or bruteforce it and hope for the best like me but that's a bad idea
that if you just look at the docs or the forum you wouldve found everything you need
I think he's hoping to be spoonfed
Understanding Javadocs will make your life so much better
It takes a few minutes to get the hang of it 
It's a matter of time
Just be patient and look around and you'll get what you need or something like that
No
I cant understand to javadocs
And I wanted only a example
Its not spoonfeed
Well in your use case, an example would have been the answer you need. If you want to understand the docs, watch some sort of video on how to understand documentation. That's how I learnt to read the docs. They're fairly easy to understand and it may look daunting but just try
an example is on the line of spoon feeding generally.
You can search the javadoc for what parameters you need
Javadocs are daunting to start, but once you find that search box, top right it will all fall into place.
Guys ActionBar doesnt working on 1.15+ verssion?
?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.
idk its known on 1.19 actionbar messages get sent to regular chat
That's been fixed
ah alright
I used this for ActionBar message But Its sending the message to regular chat
Are you on 1.19?
1.17.1
What version is your test servee tho
public static void copyContents(String user, String repo, String branch, String file, File output) throws IOException {
final URL url = new URL(
"https://raw.githubusercontent.com/" + user + "/" + repo + "/" + branch + "/" + file);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
FileWriter fileWriter = new FileWriter(output);
PrintWriter writer = new PrintWriter(new BufferedWriter(fileWriter));
System.out.println(reader.ready());
while(reader.ready()){
System.out.println(Character.valueOf((char) reader.read()));
writer.write(reader.read());
}
writer.close();
reader.close();
connection.disconnect();
}
Why is the reader not ready?
Its 1.17.1
you guys like my background
hey, what is an alternative to getItemInHand() if it has been deprecated?
found no alternative
MainHand
What haopwns if u just read without checking if it's ready
it's under equipment
found it thanks
@EventHandler
public void SpawnCustomMob(EntitySpawnEvent e){
Entity spawnedEntity = (Entity) e;
Player player = spawnedEntity.getServer().getPlayer("Thunderins");
player.sendMessage(spawnedEntity.getType().toString());
}```
Im manually spawning a zombie in with a spawn egg atm but why doesnt the sendMessage never happen? No error either
is your listener registed
oh good point whoops
You can't cast the Event to an Entity
use EntitySpawnEvent#getEntity
and use camelCase for method names
i didnt know that exists whoops
spawnCustomMob
yep he told me, i named it like a class lmao
got it, thanks!
Lmao i feel like everyone here is brand new
public static void copyContents(String user, String repo, String branch, String file, File output) throws IOException {
final URL url = new URL(
"https://raw.githubusercontent.com/" + user + "/" + repo + "/" + branch + "/" + file);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
FileWriter fileWriter = new FileWriter(output);
PrintWriter writer = new PrintWriter(new BufferedWriter(fileWriter));
System.out.println(reader.ready());
int chr = reader.read();
while(chr != -1){
System.out.println(chr);
writer.write(chr);
chr = reader.read();
}
writer.close();
reader.close();
connection.disconnect();
}
Is ready still false?
tryy withh resourcesssssssssss
Not sure but i think read method is blocking
pleaaasse
@EventHandler
public void spawnCustomMob(EntitySpawnEvent e){
Player player = ((Entity) e).getServer().getPlayer("Thunderins");
player.sendMessage(e.getEntity().getType().toString());
}```
my terminal is going crazy with errors, whats goin on?
If u check ready after u read it might be true
I could run this async on a production server or smth
you
cant
cast
an
event
to
entity
I'm just testing this in a regular java application
You are Still casting the Event to an Entity
use e.getEntity()
I do the same
oh fuckk right lemme remove that
well then how can i get my Player?
That's what i mean btw since read is blocking and ready is not, the stream is not ready when u check ready cuz it probably isn't connected yet
use Bukkit.getPlayer
its got all the Server methods but static
ah
getPlayerExact x)
now my events workin fine
if u have someone named carl and u do Bukkit.getPlayer("car")
Is there any way to intercept the game refusing to load an unknown entity ID? It seems like it would be better than checking tons of entities for attributes, removing and respawning
It returns carl
Your custom entity?
Yes
I was trying to learn off a far better mod that registers entities (Pet Ender Dragon one) and the ID swap on save seems to work but mine just gets skipped on load instead
Trying to figure out how I could just have an event listener for it being skipped and spawn it manually maybe
so i got the location of where the entity spawns and cancelled it but how can i spawn a new mob right there?
I copied all the stuff about registering the ID but 🤷♂️ doesn't seem to work and not particularly necessary afaik
1.18.2
I didn't even register ids
right now if i dont replace the ID, it'll just spawn a normal minecart on server restart or player loading the chunk again
Well yeah you have to do that
if i do replace the ID, it doesnt spawn on server restart, and it spawns it skinned as a pig when a player loads the chunk
How would the server know to soawn ur mob
how do you think I could go about tracking progress?
so yeah
thats where im at
bit confused why it keeps the function if i swap ID and doesnt if i dont, when it clearly still cant register it as unique entity
i never download large files so i just say starting and finished lol
do you even have a fking idea of what youre doing?
lol
yes i do fuckin now lmao
public void run() {
try {
URL url = new URL("http://downloads.sourceforge.net/project/bitcoin/Bitcoin/blockchain/bitcoin_blockchain_170000.zip");
HttpURLConnection httpConnection = (HttpURLConnection) (url.openConnection());
long completeFileSize = httpConnection.getContentLength();
java.io.BufferedInputStream in = new java.io.BufferedInputStream(httpConnection.getInputStream());
java.io.FileOutputStream fos = new java.io.FileOutputStream(
"package.zip");
java.io.BufferedOutputStream bout = new BufferedOutputStream(
fos, 1024);
byte[] data = new byte[1024];
long downloadedFileSize = 0;
int x = 0;
while ((x = in.read(data, 0, 1024)) >= 0) {
downloadedFileSize += x;
// calculate progress
final int currentProgress = (int) ((((double)downloadedFileSize) / ((double)completeFileSize)) * 100000d);
// update progress bar
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
jProgressBar.setValue(currentProgress);
}
});
bout.write(data, 0, x);
}
bout.close();
in.close();
} catch (FileNotFoundException e) {
} catch (IOException e) {
}
}
};
minion 👿
@lethal coral from stackoverflow
?paste
my lawyers will be on you
oh no
you stole off stackoverflow? youre gettin a letter bro
best be careful
why dont you use try with resources
that's from stackoverflow
just finished it sorry lol
it's so he can see how to do a progrss bar
that's a shitty way to download stuff
wdym
I mean, put your autocloseables into a try with resources statement
int completed = 0;
for(String file : files){
String filepath = "C:/Users/*****/Desktop/Gaming/Minecraft/Skripts/testfolder/" + file;
File output = GitHubUtil.getFile(filepath);
GitHubUtil.copyContents("hapily04", "Skream", "master", file, output);
completed += 1;
System.out.println(Math.round(((double) completed/files.length) * 100) + "% complete");
}
this is what I ended up doing for the progress
sth like this
try {
final HttpURLConnection httpConnection = (HttpURLConnection) new URL(apiLink).openConnection();
httpConnection.addRequestProperty("User-Agent", userAgentString);
if (timeout > 0) {
httpConnection.setConnectTimeout(timeout);
}
try (
final InputStreamReader input = new InputStreamReader(httpConnection.getInputStream());
final BufferedReader reader = new BufferedReader(input)
) {
latestVersion = mapper.apply(reader);
}
the InputStreamReader and the BufferedReader should be in a try-with-resources
what's so great about it as opposed to my current method
you never close your autocloseables when there's any exception
@EventHandler
public void spawnCustomMob(EntitySpawnEvent e){
Location location = e.getLocation();
EntityType entityType = e.getEntityType();
World world = location.getWorld();
e.setCancelled(true);
world.spawnEntity(location, entityType);```
ive gotten here so far, how can i set a custom name on that mob and custom armor?
won't this result in a stackoverflow?
as soon as any entity will spawn you just keep spawning new entities
just a boolean flag or sth
private boolean ignoreSpawnEvent = false;
public void onSpawn(EntitySpawnEvent event) {
if(ignoreSpawnEvent) return;
ignoreSpawnEvent = true;
// Spawn your entity
ignoreSpawnEvent = false;
}
well
what if there are more than one
more than one what?
Its single Threaded so multiple do not matter
custom entity being spawned
I don't see any problems with that
Its already in your code so your spawn triggers your own event. No other plugins spawning can get between that
Is it spigot 1.19 out?
bruh
Is it stable?
yes
yep, 1.20 shoudl be with us by tomorrow
july 7th
thank you alex :D dont want to ping you but ill leave a ty here
np!
shouldnt you set it to false after you return?
no
I thouth that spigot 1.19 was going to take atleast 4d to be done
that listener will only trigger once then
it works like this:
- Original event
- Flag is false
- Set Flag to true
- Spawn Entity
- Event called again
- Flag is true-> return
- set Flag to false
Hello there, I wanna save an inventory into a config file, searching up, I see that a lot of people wanna serialize the inventory to save it, but my question is, why would you do it, when you can directly save the whole inventory like config.set("sometext", p.getInventory); , maybe that's why I get errors in the console. xd
when the flag is true, there is still the original event running that set it to true
hm not really 😄
This works
I dont find this confusing
same thing alex sent
capybaras make me happy too
it's single threaded so when u spawn the evntity, the other event is called and executed before setting to false
ok that makes more sense
nasa java util 😱
isn't that basically a weak hashmap?
yes but as a set
set holds a map lol
nasa worrying about garbage collection but keep sending garbage into space
i always thought a map holds two sets
lmfao
entries
ye
sounds like a bijective map or in guava BiMap
// create weak HashSet without libraries
Set<Object> weakHashSet =
Collections.newSetFromMap(
new WeakHashMap<Object, Byte>()
);
bro NASA will shoot a rocket into your house if u keep trash talking them
lol
they have power ok
elon musk will defend us
When I use command its just returning usage
make sure to return true
yep it is
then your plugin is disabled, look at the console
No its working
if everything's working, that's nice
I thought you just said something was not working
it will only ever show the usage if you return false or if the plugin is not enabled / no executor is registered
If you see command syntax either your plugin is not running, the command is not registered, teh code threw an error while processing the command or you didn't return true from the onCommand.
Nope I mean plugin is Enabled
?paste your onCommand method
Everything is alright but its still dont working
okay what's your onEnable method?
casts sender to player
waittt I didnt register on Main like ```
new CommandInventory(this);
then checks if sender is not player
yeah that's a bit stupid lol
u may have to copy the contents to a regular inv
that's an error message
That's the error I get.
hey again, if i use the remove() method to delete an entity it only gets "marked" for removal. when will the marked entity be deleted?
a sec
show ZainiNBTag line 72
if (event.getItem().getItemMeta().getDisplayName() == "§7§oZaino Verde" && event.getItem().getType() == Material.GREEN_SHULKER_BOX) {
probably at the end of the tick
Its working since I register on Main Class
either getItem() is null or getItemMeta() is null
Thank you guys
can u show how the playerinventory looks?
also comparing strings with == ? bad idea
nope the entity i marked is still there after many seconds
for another player
which method gives me the location/block the player looks at? I cant find it
The coolest part is that sometimes this works
sure
Sometimes not
yes it works when you have an item that has itemmeta
and it doesn work when you don't
is there an method to directly delete an entity? for example an Armorstand?
and that the string comparison works is just luck
That's what I need
Should I use .equals?
yes
mh
you should always use equals() unless you have a specific reason to not use it
ty I forgot the name
Oh... Yeah
Back to my question, it's a good thing to save directly inv into a config without a serialization?
(a manual serialization).
I have hear that equsl is for comparing string and == for Objects
always serialize. its there for a reason
== is for comparing instances, although it can work on String (sometimes) due to the way they are stored
yeah but that's just pure luck
yep
only like N amount of strings get cached until it will forget about them again
I mean, at the moment, I directly save it, and it works as so: config.addDefault("zaino-" + config.getInt("avaible-id"), Bukkit.createInventory(null, 9, "Zaino"));
Also, sometimes it gives back error, and stops working.
?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 just add my whole lang.yml files in the jar as defaults for the runtime one lol
They're not, what I'm supposed to do.
print out the item and itemmeta to see if they are null. also switch to a newer java version, then the stacktrace will exactly tell you what exactly is null
how can I add data to an entity. I want to add a boolean to a witch which I would read later
little question :
i use
@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents((Listener) new onPlayerJoinClass(), this);
}```
to register an event from an other class.
But how would i register like commands from an other class (with the onCOmmand)
have a look at Player#getPersistentDataContainer
thats for player?
oh well any entity
ty
so Entity#getPersistentDataContainer
Have a look at CommandExecutor, then you can use JavaPlugin#getCommand(String name)#setExecutor(CommandExecutor executor)
your class name should start with a capital letter
also probably don't put the word 'Class' in your class names
if i added a click event onto a chat message, is there a way i can get the text in the chat message?
?
like im making a punishment system and want to make it so you can click on a message/player's name in chat if they violated a chat rule
and i wanted to auto log the violated message
That seems over complicated, can't you just use a command?
no. you should rather just save all messages for X minutes and map them to some kind of messageid. then your click thing can just run a command like /report <messageid>
but how would it get a messageid from a message?
Edit: I tried, and this problem occurs when I restart the server.
You create one
and track messages yourself
Just like alex said
whats wrong here?
is there an event when you click on a message in chat?
no
^^ but you can make it run a command
No, but you can send a json message although you can do small things with it.
Which theme is that, looks sick af
hmm
how do i change my 1.18.1 maven code to 1.19
by changing 1.18.1 to 1.19 ?
^^
where do i change this tho
like ik the one in plugin.yml
pom.xml
but what about dependencies and stuff
oh
<version>1.18.1-R0.1-SNAPSHOT</version>
to
<version>1.19</version>
?
1.19-R0.1-SNAPSHOT
Ta^
ok ty
is it better to apply enchants to an itemstack or itemmeta?
Don't think it matters much
getCommand("name").setExecutor(new CommandBlaBlaBla, this);
don't forget plugin.yml
ItemMeta
why?
cause i remember itemstack not working for me
why are there two ways
well there's CraftItemStack#addUnsafeEnchantment which directly edits the NBT values
but that should have worked
?paste
i've tried this and still it turns back into a minecart when player rejoins
can you paste it in there ^?
small portion of my main class i did make it a boolean to check it actually worked and it does say it registered
yet every time, minecart again
also unable to summon it if that's relevant
how can i make a witch passive?
cancel its target event
there should be some kind of "entity found a new target to slaughter" event or similar that you can cancel
yeah target event
that's what i meant
ok
Maybe register it on load so it happens before the world loads
just made a custom inventory holder and it got rid of so many maps lol
MaP
map
mup
muppet
why wont this work public static void formatMulti(Integer first, Integer second, Inventory inv, ItemStack item) { while (first >= second) { inv.setItem(first, item); first++; } } im trying to set multiple gui slots to the same item so i dont need to use inv.setItem a bunch of times
huh?
why the heck are you using Integers
wdym
just use setItem
why are you using Integers
why wouldnt i? its a number
because you can use the primitive type "int" instead
also it's nullable
because it takes way more time
wdym "more time"
Integer is basically the "object version" of int
sure it takes more time, for a modern computer? nope
whats quicker typing what i sent or
inv.setItem("different number each time", item) a load of times
basically dont worry abt it
just use a for loop
yeah i create a custom item for each slot of my inv and set each one with setitem and it takes less than 1 ms to do
how do i spawn an entity with its face in the same direction of the face of an block? so i'm coding an sit plugin and i want the armorstand to look out of the stair to the front
that's a stupid idea
what using setItem(int, item)?
not what im talking about im talking about typing it
i guess you'll have to manually map the BlockFaces to a float for the yaw
use a loop
changing it to int didnt do anything still doesnt work
what would i loop though
you cant loop an int
maybe you could start off by explaining what exactly doesnt work
he is incrementing
or make it overly complicated
public static void formatMulti(Integer first, Integer second, Inventory inv, ItemStack item) {
IntStream.range(first, second).forEach(num -> inv.setItem(num, item));
}
ya still no -> https://paste.md-5.net/iwepixefaf.cpp
not rly sure what the issue is with it
Very readable though
why is this a stupid idea?
i'm confused why calling setItem multiple times is stupid
didnt you say that he should use this instead
inv.setItem(1,item);
inv.setItem(2,item);
inv.setItem(3,item);
inv.setItem(4,item);
inv.setItem(5,item);
ohhh no
then I misunderstood you
I mean when one calls it twice, okay, but anything more often should be a loop lol
ItemStack[] itemStacks = new ItemStack[]{
item,item,item,item,item,item,item,item,item,
item,null,null,null,null,null,null,null,item,
item,null,null,null,null,null,null,null,item,
item,null,null,null,null,null,null,null,item,
item,null,null,null,null,null,null,null,item,
item,item,item,item,item,item,item,item,item
};
beautiful
ikr
your inv's have six rows??
So if I have like 11 worlds 10 and I want 10 of them to be with same inventory and whatnot its just multidimensional worlds and the other 1 world to be like just normal survival where u spawn where u left and all that with different inventory
double chests tend to do that
See how multiverse does it
If you want to have different gamemodes I recommend setting up a Bungeecord server
So that 11th world is just another server
that's just going to crash your server since you're checking if its greater than the second number, and then incrementing it
what
yeah funny lol
also one is not looping over the int itself but just throwing in some expression that returns either true or false
have any tutorials on this?
but im planning to just host this as 1 server on 1 of the hosting services online or mshtng
why is InventoryClickEvent#getClickedInventory nullable?
because
you can click outside of the inventory
its null when you click outside
at least in like 1.8, it fires when you click outside
WTF ITS CALLED WHEN U CLICK OUTSIDE?
btw it's also mentioned in the docs
yep
bruh
yes
yes
wtf is that christmas tree of a code block
ty man, always there when we need you <3
how do I support https://www.spigotmc.org/wiki/using-custom-colors/ these when naming items?
heeheeheehaw
got it working 👍
persists now
extremely jank way i think but it was the only way i got it to after lots of trial and error (and looking through many similar mods and tutorials)
sure ill put it on paste thing
you should ask the dev of that resource / plugin / whatever that is
i know 100% that i have not done it well but i cant see how else to do it
????
ohh
fuck
thought this was official spigot wiki
Plugin Main Class -> https://paste.md-5.net/acogisacal.java
Entity Class -> https://paste.md-5.net/urahesizih.java
@humble tulip
so ye u can see the stuff in onLoad is just.. weird and not helpful
but it did get it to work
is that logger the one that supports placeholders?
lol no. however spigot also supports hex colors, you just have to format a bit more weird. for example if you have
&x&f&f&0&0&0&0Hello and then it rhough ChatColor.translateAlternateColorCodes, you'll end up with "Hello" in solid red (#ff0000)
im not that familiar with java but it seems i needed to put it in entity class in static and also initialise(?) the entity class in onLoad
not directly from onLoad
still learning but progress is progress
ah
I knew there was some way
why not using normal hex color codes?
well all the hex colors in my config look like #ff0000
do you know if Minimessage can also compile into that format?
yes but it's like 1mb in size lol
well you must be using some other plugin, paper, or sth
cuz this dont work
public static void copyContents(String user, String repo, String branch, String file, File output) throws IOException {
final URL url = new URL(
"https://raw.githubusercontent.com/" + user + "/" + repo + "/" + branch + "/" + file);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
FileWriter fileWriter = new FileWriter(output);
PrintWriter writer = new PrintWriter(new BufferedWriter(fileWriter));
int chr = reader.read();
while(chr != -1){
writer.write(chr);
chr = reader.read();
}
fileWriter.close();
writer.close();
reader.close();
connection.disconnect();
}
public static void main(String[] args) {
try {
String[] files = Objects.requireNonNull(GitHubUtil.getFiles("hapily04", "Skream", "master"));
int completed = 0;
for(String file : files){
String filepath = "C:/Users/ryanb/Desktop/Gaming/Minecraft/Skripts/testfolder/" + file;
File output = GitHubUtil.getFile(filepath);
GitHubUtil.copyContents("hapily04", "Skream", "master", file, output);
completed += 1;
System.out.println(Math.round(((double) completed/files.length) * 100) + "% complete");
}
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
Why are the files not being written to? I didn't have this problem earlier, files were being copied correctly.
here's the console output: https://paste.md-5.net/avosotikec.shell
as I already said, you have to manually translate it
why do you keep refusing to use try with resources?
we already told this to you like an hour ago
you act as if that will solve my problem
yes I know
I don't act like if that solves your problem, in fact I haven't read your question when I asked why you are not using try with resources
well that puts my idea of using adventure for item lore/name in a tough spot
okay then my answer to your question is because it worked fine without it
yeah I kinda can't decide whether to use it or not yet
As ChunkGenerator#generateChunkData is deprecated, if you want to generate a chunk in one go, is it better to use the deprecated method or pick one of the sub methods?
I'd probably just use the generateSurface method
okay thanks!
I havnt done mc plugins in a hot minute, idk what im doing wrong here cuz im quite stuipid but im tryna get the nearest entity that has the line of sight to the original entity. Heres a ss
better?
a try with resources looks like try (Resource a = getResource()) { a.blabla() }
no need to close them if u use try with resources
the sort method takes a Comparator which you can express using sth that löooks like a BiFunciton
nearby.sort((o1, o2) -> (int) o1.getLocation().distanceSquared(o2.getLocation()));
is that not what I did?
also you should be using distanceSquared, not distance
yes that is much better
ah there are two tries
ents.sort((entity, other) ->
{
//compare
});
btw youll probably get an exception because theres no checking when casting this
what if i wanted to compare an object in the list to another outside? would i throw away o2
wouldnt know why
no you have to pass o2 anyway to tell it that it's a BiFunction
the reason that you need both objects is because it's basically just a short way to write this:
nearby.sort(new Comparator<Entity>() {
@Override
public int compare(Entity o1, Entity o2) {
return (int) o1.getLocation().distanceSquared(o2.getLocation());
}
});
and compare obviously takes two entities
what code are you running?
my own
its just when i join
it cant put me into worl
d
i changed some of them and idk why doing this
... can you post it here?
my hub world as called world and i changed it to "hub"
ik, but the 2 entities would be 2 in the list right? What if i just did
nearby.sort((o1, o2) -> (int) o1.getLocation().distance(e.getEntity().getLocation())));
e = event
its too long and idk which part to post anyway
?paste
this just happens when i join
many classes and stuff bruh
okay well I can't really help then
it happens when i try joining the server