#help-development
1 messages · Page 1710 of 1
where can i find the syntax for shading libraries into my plugin.yml
He registers listeners twice.
So likee...has anyone here ever worked with custom beehive stuff before..?
or know how they work
like when one is placed, do the bees automatically look for the nearest flowers or
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Yiu can just Bukkit.getOnlinePlayers()
Don't need Bukkit.getServer().getOnlinePlayers()
or use dependency injection
Well, trying to make a custom entity and already stuck.
public CustomBee(Location location) {
super(EntityTypes.BEE, ((CraftWorld)location.getWorld()).getHandle());
}
EntityTypes is only giving me the option for EntityTypes.g, b...
have they changed that again too?
Yes
java: cannot access net.minecraft.network.chat.ChatComponentText
bad class file: /C:/Users/jflee/.m2/repository/org/spigotmc/spigot/1.17.1-R0.1-SNAPSHOT/spigot-1.17.1-R0.1-20210708.170253-1.jar!/net/minecraft/network/chat/ChatComponentText.class
class file has wrong version 60.0, should be 52.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
Uhhhh wut
try {
PreparedStatement ps4 = plugin.SQL.getConnection().prepareStatement("SELECT * FROM wb_blocks WHERE WORLD=? and X=? and Y=? and Z=?");
ps4.setString(1, world);
ps4.setInt(2, blockx);
ps4.setInt(3, blocky);
ps4.setInt(4, blockz);
String breaker = player.getName();
ResultSet results4 = ps4.executeQuery();
while (results4.next()) {
String blockowner = results4.getString("NAME");
if(blockowner.equalsIgnoreCase(breaker)) {
return true;
}
}
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}```
anyone familiar w/ using sql in java have any idea what i am doing wrong here? getting hung up on while (results4.next()) { appears like the code never executed but everything above it does...
the query 'should' be returning this array from the database
any way to make this shorter?
Extract smaller methods
The fundamental rule of a function is that it should only do one thing
And one thing is usually defined by when you cannot meaningfully extract another function from it
As the function becomes more and more specific it’s also natural that the name of the function becomes longer because it does something more specific
if it would do one thing i need to have three methods :/
so i should make a method that handles the cooldown and one for the teleport?
Can you spawn an item frame without a block next to
@ivory sleet any insight on the issue im having above w/ the sql nonsense?
maybe if you disable the physics update
or nawww lol im stumped
Why can't I cast CustomBee to Bee? it extends EntityBee
I can't add my CustomBee to the hive 😦
and can't use the bee methods from it
how to set a hover event on a onPlayerJoin listener?
uh well it doesn’t extend Bee
Then how do I make a custom one and use the methods from Bee?
Don’t think that’s the problem, when I spawn it using world.spawnEntity it throws illegal argument exception. But i can spawn it just fine with the minecraft summon command
It doesn’t throw when there’s a block nearby tho*
I know I could implement Bee but that adds like 1000 methods
oh yeah i forgot it was an entity
idk then sorry
yeah true, 🤷♂️
Can’t u use getBukkitEntity()
bump
Anyone here have api for messages title subtitle actionbar etc 1.8-1.17?
other than ActionBarAPI...?
im making a plugin with abilities per class atm and was wondering if i split event listener classes into like one for each class would listening to the same event once for each class be worse than just having it all in one?
public class SpigotMessage {
public static TextComponent simpleMessage(String message) {
return new TextComponent(message);
}
public static TextComponent hoverMessage(String message, String hoverMessage) {
TextComponent textComponent = simpleMessage(message);
textComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(hoverMessage)));
return textComponent;
}
public static TextComponent commandHoverMessage(String message, String hoverMessage, String commandString) {
TextComponent textComponent = hoverMessage(message, hoverMessage);
textComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, commandString));
return textComponent;
}
}
Rate how sexy my utility class is out of 10
I keep forgetting the syntax for these and I'm clearly going to be using it very frequently so here we go
Pretty alright
Although you are missing 2 things that would make that a pure utility class
final on the class declaration (prevents inheritance)
private constructor (prevents instantiation)
- you can also avoid reflection via throwing an exception within the constructor
private constructor?
why would I do that?
to stop people unnecessarily instantiating your utility class? (which is important for an API)
plus it provides a bit more context as to what the class is for
ye
even throws an AssertionError in its init
I tend to throw UnsupportedOperationException myself
I guess I don't really see the point in doing that when this is for a solo project lol
yeah its not necessary ofc
fair? I typically do it all the time tho just as a personal thing tho
But I like to write my code defensively Ig
but uhhh that's coming from a person who uses final on 99% of his local variables
I used to use final quite a bit more
same
man I used to use it on fuckinnnnn
im lazy
ARM resources and parameters
I used final because it occasionally would spare some bytecode instructions
but its negligible
just kotlin it
so stopped with the final clutter
ez
it makes sense if you're working on a project with a lot of people but the opening statement of my project says I don't take pull requests lol
hehe
why not?
just want this to be a project I wrote from end to end
"code is mine, no touchy"
it's open source and gplv3, I just also want it to be something I made
ye thats totally fine
I mean GPL isn't as open as it could be, but yeah I understand
gplv3 is exactly what I want it to be
I'm an MIT License guy myself
wtfpl 😄
...
if you look at any of my projects they're all under MIT
Why would People make objects of An utility class of it has no purpose?
because people are idiots
I use mit mostly but yeah sometimes something else
Smh
by mistake
that too ^
you can also use it if you want to force your class to use a builder
since nested classes are able to instantiate their parent classes if they have private constructors
ah alr
what does that even mean
hold your horses
oh fuck
Oh
you know java? name every exception that I have triggered today
Is it a bad idea to save a list of custom objects? or should I just loop through the list and save the values I want
as you said "variable" and not "field"
fields are variables in a sense
ehhhhh it's kinda like squares and rectangles
a field is a variable, but a variable isn't a field
yeah
yeah
[a-zA-Z$_][a-zA-Z0-9_]{0,65534}
square isnt a rectangle
🌞
a rectangle is a square, it's a 4-sided, closed shape
the difference is l e n g t h
maow have u messed with jigsaw and serviceloader
Can we take this to #general You guys are ignoring someones question
I thought it was going to be tricky but it was quite simple despite going under one of the more advanced java topics
this goes too far above the maximum name limit
Indeed, good point
ah feels good to use text components like this
should've done this ages ago
TextComponent bossTrace = SpigotMessage.commandHoverMessage(ChatColor.BLUE + "Boss trace!",
"Remember, it requires debug mode to be on! This is used for advanced debugging, ask on discord if you want to know more about it.",
"/elitemobs trace " + customBossEntity.getEliteUUID().toString());
c o m f y
Lets see.
What does this code print out:
public static void main(String[] args) {
Integer a = 10;
Integer b = new Integer(10);
Integer c = Integer.valueOf(10);
System.out.println(a == b);
System.out.println(b == c);
System.out.println(a == c);
}
ye
I wonder if the autoboxing would use valueOf or the constructor?
former I presume
valueOf and implicit creation does
oh so then
false
false
true
?
Yeah. How big is the default Integer cache of the jvm?
:>
<:
hmm
I think somewhere around 100-200 values iirc
I'd guess 512
One byte in size
-127 to 128
oh nvm
How do I summon an item frame without a block next to
tho can't you like, expand the integer cache ?
Yeah there is a jvm flag for that
yea ha
all primitive wrappers do
Did you try just summoning one?
Even Float and Double?
Whenever I do world.spawnEntity for item frames it throws illegal argument exception when there’s no nearby block
Ive never seen a floating item frame to be honest.
It’s possible
They die after a while don't they ?
When I use the minecraft summon command it works just fine
Some more 😄
LinkedList is utter garbage. What is the only use case where it excels.
Hard question
I know from StackOverflow it's not very quick compared to ArrayList and it's very memory inefficient (as it uses linked nodes)
What's the parallelism for the common pool?
For the LinkedList: Removal of elements while iterating is O(1) and the only thing its good at.
parallelism i would suspect the number of cores of the cpu?
public boolean setupCore() {
if (getServer().getPluginManager().getPlugin("CadiaCore") == null) {
return false;
} else {
this.cadiaCore = (CadiaCore) getServer().getPluginManager().getPlugin("CadiaCore");
return true;
}
}
Soooo..my core plugin is saying it's null, even though the return for this is "true" (meaning it successfully found the core dependency plugin)
Ooh, that's actually cool.
whats up with that
Yeah insert and remove while iterating.
Yeah iirc something like that although changeable with a jvm flag
but if I try to reference the core, it says it's null
Do you make sure to call setupCore() before referencing cadiaCore and that you only use one instance of the class that contains this field?
Yeah,
public void onEnable() {
if (!(registerDependencies())) {
getServer().getPluginManager().disablePlugin(this);
return;
}
registerClassInstances();
configManager.loadHiveConfig();
configManager.loadHives();
registerListeners();
}
I'm not referencing it until my listener, which is the last thing called.
Let us see how you obtain your cadiaCore instance. A stack trace would be nice too 😄
and..
And registerDependencies() calls setupCore()
So this:
this.cadiaCore = (CadiaCore) getServer().getPluginManager().getPlugin("CadiaCore");
it's null, otherwise it would return false, then disable the plugin
yeah
public boolean registerDependencies() {
if (!(setupEconomy() || !(setupCore()))) {
return false;
} else {
return true;
}
}
You can make nicer return statements
just
public boolean registerDependencies() {
return setupEconomy() && setupCore();
}
We are aware but looks cleaner 😛
Could be. Your statement looks a bit off
hence grouping everything together and having my onenable just calling other methods to do the dirty work
Still have the error
Show us how your PlaceHiveListener class looks like.
actually, another error: https://pastebin.com/raw/pf4Xq3kp
Ah i know the problem. You shade your CadiaCore plugin in.
Set the
<scope>provided</scope>
in your pom.xml
Or do you use Gradle?
I'm using it as a jar dependency
Ah. F i guess.
Highly recommend looking into maven or gradle
I use maven for stuff like spigot
Why not maven?
beautiful
but I dont really feel like pushing every change I make to the core plugin to github and stuff
do u really like writing xml
Yeah floats my boat
I fucking hate XML
or cartesian product lookup of dependencies in repos
I write XML daily
<repository>
<id>project.local</id>
<name>project</name>
<url>file:${project.basedir}/repo</url>
</repository>
``` `mvn clean` `mvn install` Then you can include it as a dependency in any of your projects. Just make sure to shade it in ofc.
If there is a better way todo it lemme know lol
That goes in core?
Yes
Does that go with my other repos or up towards the top?
Yep with your other repo's
and would the id be the same as my groupID?
Yeah
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.huskydevelopment</groupId>
<artifactId>HuskyCore</artifactId>
<version>1.4</version>
<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
</properties>
<repositories>
<!-- This adds the Spigot Maven repository to the build -->
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>project.local</id>
<name>project</name>
<url>file:${project.basedir}/repo</url>
</repository>
</repositories>
<dependencies>
<!--This adds the Spigot API artifact to the build -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
``` @lavish hemlock @regal dew This one is for you bb's
Example of my pom.xml @carmine nacelle
same thing can be done in fewer lines with a build.gradle.kts
🤢
Could not find artifact com.squallz:CadiaCore:pom:1.0-SNAPSHOT in spigot-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/)
bruh
why is it looking there
Show me your pom
Dependent: https://pastebin.com/raw/2xGT70Rs
Dependency: https://pastebin.com/raw/Hx1DT9we
oh you can just have it as project.local
I do that then I click the little M at the top right to load maven changes
<dependency>
<groupId>com.huskydevelopment</groupId>
<artifactId>HuskyCore</artifactId>
<version>1.4</version>
</dependency>
``` You include it as a dependency not as a repo
ok removed that
Cannot resolve project.local:CadiaCore:1.0-SNAPSHOT
mvn clean mvn install
where do I run that.. cmd?
have to cd to my directory..?
It's in your sidebar
I opened the terminal and ran them
[ERROR] Failed to execute goal on project CadiaBees: Could not resolve dependencies for project org.example:CadiaBees:jar:1.0-SNAPSHOT: project.local:CadiaCore:jar:1.0-SNAPSHOT was not found in https://hub.spigotmc.org/nexus/content/repositories/snapshots/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of spigot-repo has elapsed or updates are forced
<repository>
<id>project.local</id>
<name>project</name>
<url>file:${project.basedir}/repo</url>
</repository>
``` Just copy and past this, don't change anything
Hey is there a way to increase knockback without the attack_knockback attribute? When I set that attribute to something like 1000 it doesnt really do more when at a lower level
project.local and project are variables
Into which one?
alright
I also keep getting this: Cannot resolve plugin org.apache.maven.plugins:maven-deploy-plugin:2.7
Thank you, I agree that is much nicer but eh
Alright, I did that
Still getting red underlines in the other one
[ERROR] Failed to execute goal on project CadiaBees: Could not resolve dependencies for project org.example:CadiaBees:jar:1.0-SNAPSHOT: project.local:CadiaCore:jar:1.0-SNAPSHOT was not found in https://hub.spigotmc.org/nexus/content/repositories/snapshots/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of spigot-repo has elapsed or updates are forced -> [Help 1]
still the same error
Show pom of both projects again.
reached my pastebin limit 🙄
Dependent: https://pastebin.com/raw/vkhxcjgQ
Dependency: https://hastebin.com/dawehuxede.xml
wait
other way around.
why is your group id for the dependency project.local? that is where you define the actual proper group id for the core
<repository>
<id>project.local</id>
<name>project</name>
<url>file:${project.basedir}/repo</url>
</repository>
``` This goes in your core POM
<dependency>
<groupId>com.huskydevelopment</groupId>
<artifactId>HuskyCore</artifactId>
<version>1.4</version>
</dependency>
``` This goes into your other projects POM
It's not hard
Yay!
wild
There yah go!
so every time I update the core I have to run the mvn commands again..?
Yep otherwise it won't know the changes
The best approach is to honestly use modules when utilizing a core
In this video, you will learn how to develop a multi-module Java Maven project in IntelliJ IDEA. In details, I will show you:
- Create a Maven root project
- Create the 1st module for Shared library project
- Create the 2nd module for Console app project
- Create the 3rd module for Desktop app project
Also, you will learn how to build the whole ...
still getting the cast error..
public boolean setupCore() {
if (getServer().getPluginManager().getPlugin("CadiaCore") == null) {
return false;
} else {
this.cadiaCore = (CadiaCore) getServer().getPluginManager().getPlugin("CadiaCore");
return true;
}
}
63 is
this.cadiaCore = (CadiaCore) getServer().getPluginManager().getPlugin("CadiaCore");
What is the Declaration for cadiaCore variable?
Isn't that what I sent?
What is the type for CadiaCore, did you make it Plugin or JavaPlugin?
I have never casted to a JavaPlugin before
What happens when you create a static instance of your core class and get it that way?
No I just mean in the core:
public class CadiaCore extends JavaPlugin {
I always use dependency injection across classes instead of a static instance method
public class CadiaCore extends JavaPlugin {
private static CadiaCore instance;
@Override
public void onEnable() {
instance = this;
}
public static CadiaCore getInstance() {
return instance;
}
}
``` Try this and see if getting the static instance works.
Yes
Do you have CadiaCore set as a dependency for CadiaBees in the plugin.yml?
yes
now im getting this tf
@carmine nacelle Did you put this in your CadiaBees plugin? You're missing the CadiaBees class now
How to create bungeecord config file?
com.squallz.CadiaBees.CadiaBees seems incorrect
this.getConfig() doesn't seem to work for bungeecord
How?
package names should be lowercase
ok but..
minor details
Idk why it suddenly can't find the main class of that plugin
Yeah but that is important to run your plugin 😛
Well, the last build on it failed with this
WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.273 s
[INFO] Finished at: 2021-09-28T05:26:08-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project CadiaBees: Fatal error compiling: Failed to run the ecj compiler: source level should be in '1.1'...'1.8','9'...'14' (or '5.0'..'14.0'): 16.0.2 -> [Help 1]
Double check your CadiaBees class definition
pretty sure its cause it didnt build correctly
but uh... Failed to run the ecj compiler: source level should be in '1.1'...'1.8','9'...'14' (or '5.0'..'14.0'): 16.0.2 -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project CadiaBees: Fatal error compiling
wot
I dont get why its just now throwing this error
anyone?
@native nexus Seems to have compiled fine but still not letting me cast it
java.lang.NullPointerException: Cannot read field "hologramManager" because the return value of "com.squallz.CadiaCore.CadiaCore.getInstance()" is null
this is so annoying holy shit.
depend: [ProtocolLib, Vault, CadiaCore] in my plugin.yml
@lost matrix yo do you know anything about java + sql?
like getting data from an sql database and using it in a method as a string or otherwise
why are there so many blockface directions? from what i can tell i only need north, south, east, west, up and down
is there anyway to modify a sent packet ?
for example an armorstand's metadata
it's displayname forexample
Because some 'blocks' can face more than just north/south/east/west/up/down
which blocks does that apply to?
Yes. You can listen for outgoing packets using ProtocolLib
please not that trash plugin
If it already was sent, no. Pretty sure there's stuff out there for listening for when packets are sent so you can modify them though.
a sent packet that i have it's id
Signs come to mind
Then inject your own netty pipeline handler
ah i see, alright thanks for the info
if i send the metadata packet again, will it change ?
i dont know how to use netty.
so if i use it, it will cause performance issues
Protocollib? Trash plugin?? LOL WHAT
best performance ngl
Then how is it trash.
the performance is trash
Yes. Its a bit of overhead but i suppose you can just overwrite the metadata by sending a second packet.
And ProtocolLib is a well established and battle hardened plugin.
I've never had a single issue with it.
Still having my issue with getting the core plugins instance btw..
the other plugins might be causing it so ?
plugins using plib
Still the casting issue?
Version of core the same as the one being used on the server? (No changes to that class?)
Well with static instance it's just null.
It's all up to date, restarted server
Re exported both.
My servers only ever have 3 plugins:
My core library
The server logic
ProtocolLib
RegisteredServiceProvider<CadiaCore> provider = Bukkit.getServicesManager().getRegistration(CadiaCore.class);
if (provider != null) {
this.cadiaCore = provider.getProvider();
}```Try this
You need to make sure that you dont export your core lib with your plugin
And dont try this
Why not?
It's set to provided.
Because this is not the root of his problem.
How do you compile your plugin?
Build > build artifacts
Do you use maven?
Yeah but to make the jar I build artifacts
Then you can throw your pom.xml in the trash because it doesnt get used anyways.
Uhhh it does for my dependencies
No it doesnt.
If you dont know what all the maven lifecycles do then just use
mvn clean install
how to get the datawatcher
If I delete my pom then I lose all my spigot API references, protocollib, it's 110% needed
The nms entity has a getter method for that
Tried it anyway. Provider is null. :D
as.getDataWatcher for example
but aren't they different for each armor stand ?
or it is the datawatcher of entityarmorstand
What you need to do is simply build your plugin with maven. What IDE do you use?
Every Entity instance has its own DataWatcher
Once the plugins are in the server, how they're compiled changed nothing
Yes it is.
Why is it just now an issue once I try using my own dependency
you mean armorstand 1 datawatcher is not the same as armorstand 2 ?
or entityarmorstand and entityzombie
Every entity has it's own.
what do you mean by entity!!!
The class
you mean armorstand 1 and armorstand 2
ok
means if i do as.getDataWatcher()
it works with another armorstand right ?
"no valid maven installation found" excuse me what
I don't get how my maven home directory is inside
Invalid*
Already did that
And it's in my path
Got it
Shows a version now
its been showing this for a while but still works fine
idk what thats about.
Then type mvn clean install into the terminal window or use IJs helper buttons
It does that all the time idk why
But
I did the clean install thing again
Now what?
Did you build the plugin?
In your "target" folder?
Try it out 😄
Ok...explain
and how can I make the mvn build export directly to my plugins folder instead of some random folder
Building artifacts doesnt use your pom.
Building with maven does.
So if you build an artifact then you copy your dependencies into your jar
if you use the pom then you can define the scope.
PS: There is also a way of not shading the dependencies without using maven
https://i.gyazo.com/183729a8e1bcda4fd86b24589e65d701.png well my artifact isnt set to include the other one
Is there any event for when a falling block lands? Tag me if replying me pls ty
@lost matrix any idea...? it keeps exporting to the target folder in the project, I need it to export to my plugins folder like it was with the artifacts
I detect falling block changes like this, it's probably not the best way, but the best way I can think of at this moment
@EventHandler
private void onBlockChange(EntityChangeBlockEvent event) {
if (event.getBlock().getType() == Material.AIR || !event.getBlock().getType().isBlock()) {
Bukkit.getScheduler().runTask(Main.getInstance(), () -> {
if (event.getBlock().getType() == Material.SAND || event.getBlock().getType() == Material.GRAVEL) {
event.getBlock().getWorld().playEffect(event.getBlock().getLocation(), Effect.STEP_SOUND, event.getBlock().getType(), 20);
event.getBlock().getWorld().getBlockAt(event.getBlock().getLocation()).setType(Material.AIR);
}
});
}
}
its just a simple thing that kills gravel and sand falls regardless of what they land on
Uhm thats probably not what you should do
Get the entitiy and cast it to FallingBlock. Then get the BlockData/Material from it.
it works, somewhat
One moment
Is there maybe event.getentity.remove, it may prevent lag on large amounts of blocks
oh so right start, wrong exit
Also why are u running it in scheduler?
private static final Set<Material> CLEANED_TYPES = EnumSet.of(Material.GRAVEL, Material.SAND);
public void onFallingBlockHit(final EntityChangeBlockEvent event) {
final Entity entity = event.getEntity();
if (entity instanceof FallingBlock fallingBlock) {
final Material material = fallingBlock.getBlockData().getMaterial();
if (CLEANED_TYPES.contains(material)) {
// Play sound here
event.setCancelled(true);
}
}
}
this mans a legend
Why scheduler?
Output path is... C:\Users\jflee\Desktop\Test Server\plugins
maven outputs to... C:\Users\jflee\IdeaProjects\CadiaCore
why.
The Block is changed after this event was fired. So he checks the type in the next tick.
to destroy the block after if I remember, since most events are pre-it-happening
You need to define the output dir in your pom somehow.
From now on everything compilation related is done in your pom.
oh so we have to do that to wait a tick and stuff?
I am actually trying to make it so when any falling block is dropping and if block below it is something then it will break
I found this page https://intellij-support.jetbrains.com/hc/en-us/community/posts/360010717260--SOLVED-Maven-Set-target-output-directory but version 2.3.1 isnt showing, how do I get the latest version..?
ok got that but I dont want my output jar to have SNAPSHOT on the end it looks dumb & is unnecessary
Then change your artifact version...
No you should not do that as it leads to quite a bit of overhead. Rather use the method i just proposed
Which one?
I didn't want a version on it at all. I just wanted the plugin name but I figured it out, thx for the help guys
What happens with you cancel the event?
I think the block just vanishes.
Sure
How so?
Either dont cancel the event and break the block one tick later
or
Cancel the event and manually drop an ItemStack at the Location
hmm I will actually just remove it
So it looks like entities are unable to actually leave 2 block deep water
As in, jumping out
Did anyone figure out how to let them leave deep water yet
What ItemStack do I get when doing getCursor() in the InventoryClickEvent?
hey can anyone help m
i am developing a server
but i can't make a void mutiverse
can anyone help?
why do i always misread "pom" to something else..
Why can't I update the scoreboard async? The timings told me it is 600% of a tick
The itemstack that the cursor is holding. If any
thank you
How may I go on about fixing this issue https://paste.md-5.net/yoyejiceke.sql ? I tried adding a delay for the method that loads a selected world but I don't think that one was the problem and I'm just not sure how to go on about this
The world does not exist @hollow bluff
The world exists, it just doesn't load when the server first starts
Everything works after when doing /rl but when first starting the server, it doesn't load
Then idk what is wrong here
do i smell 1.8?
It doesn't matter what version, have the same issue in later versions as well
still,1.8 long depricated and abandoned by paper and shit
The answer I got yesterday when I asked was that it takes time for a world to load, so I don't know how to even fix it
delay the execution of ur code
I tried adding a delay but the error still came
._. It's a minigame, for sure I dont need to wait 5min
just for testing my guy
ah ye
to see if ur code works properly at all
Added a delay, the error just comes regardless
Can't be the method I use to load them at all
then bad code
thanks for the kind help 👍
wouldnt make sense if it wasnt faulty code
could i see the piece of code that errors?
for sure! Gimme a second
Hey guys, i have a Problem: I created an entityarmorstand and put it on the player's head, the only problem is if I move over 31 blocks away from the player and then come back again, he is no longer on the head of the other player. I could of course send the packet again in the move event, but I think that's a bad solution.
https://paste.md-5.net/okaqaseluc.java this includes the config and the onEnable line
config existing?
yes
as a yml?
in the server files? yes
because there has to be smth bad going on there
does it get created in the plugin folder?
https://paste.md-5.net/ihozoruheq.java maybe the full onEnable might be relevant after all?
sure u called the config creation thingy?
It should be called
should
haha yeah... the config.yml is called at the top, the arena.yml is called right under?
well now i am completly bamboozeled
u readin the right config
i dunno if i can help
maybe someone else
is a block iterator or block raytrace faster?
I have been studying java for the last 8 months and working on a spigot plugin for the last 2 months. I've already invested about 300 hours developing the plugin and nearly everything is running smoothly. I'd love to show my code to an experienced developer to get feedback; I was thinking it would be amazing to have a one on one in a voice call to go through the code and discuss what could be improved. I have some ideas for how I can improve on the areas that aren't as fast, but I would really like to talk to someone about it. If you're interested please dm me!
stick it on github and let the masses rip into it
I'm afraid if I put it on github people will steal the code
net.minecraft.server.v1_16_R3.PacketPlayOutScoreboardDisplayObjective
net.minecraft.server.v1_16_R3.PacketPlayOutScoreboardObjective
net.minecraft.server.v1_16_R3.PacketPlayOutScoreboardScore
net.minecraft.server.v1_16_R3.PacketPlayOutScoreboardTeam
Can somebody tell me what the fields of these constructors mean?
Theres nothing you have written thats not been written a hundred times before.
It should be reading the file yeah but it's fine if you can't help, thanks anyways
there are a thousand different languages, but he chose to speak facts
If i did /foo bar baz, what would the args variable contain?
[bar, baz]
thanks
what is a task id and how to get it
you get teh task id when you schedule it
yeah but it didn’t get removed
what is a datawatcher
i used as.getDataWatcher() for example
but now i dont have an armorstand
how to get one
Hello I am trying to allow users to input a image that my plugin will read in the config, how should I do this. Ik I can let them put in a url or file path but how do I allow both to work
exampleimage: imgur.com/... or image: plugins/image.png
when a packet needs to be sent the data watcher detects it
what should i set here
there is a method under one of the entity class
bruh
what should i set
please tell
i dont have armorstand
but i have id
of the armorstand
idk how to get the data watcher of an entity that doesn’t exist lol
how can i get the servers' tps
they said datawatcher is for the class
on spigot the only way is to crudely calculate it yourself or reflect into a private field- on paper there are tick start / finish events as well as making the last tps accessible
table doesnt exist
How can I get the orientation of an dispenser? (or, to ask the question more broadly, how can I retrieve metadata of a block)
does anyone know why when i spawn a boat and add the player as a passenger it add the player but you're looking the opposite way to which you I it?
Boat boat = (Boat) player.getWorld().spawnEntity(event.getClickedBlock().getLocation(), EntityType.BOAT);
boat.addPassenger(player);
you are spawning your boat inside a block
Boat boat = (Boat) player.getWorld().spawnEntity(event.getClickedBlock().getLocation().add(0, 1, 0), EntityType.BOAT);
boat.addPassenger(player);
``` no its spawned 1 block above i just removed that part to post here
Not tyhe code you showed, but ok
and also is checked to see if on water etc... but im just wanting to know if there is a way to add the player facing the correct way
You are getting the location from the block so your boat will use the facing of the block, if it has one.
is there a way to set it to the way the player is facing?
yes, get the direction of the player and set it to the boat
i'm doing it by the clicked block as i'm detecting if a player has right clicked a block from the interact event, cancelling then spawning the boat and entering the boat.
maybe i should do it from the players loc and enter the boat?
player.getDirection?
what kind of black magic have hypixel used, so the player's can't even break the blocks ?
Adventure Mode
Don't they give you mining fatigue or smth
You can set items to not be able to break blocks.
Without adventure mode I think.
How can I check in the InventoryClickEvent if a Player clickes on a blank space? I tried both of these:
event.getCurrentItem().getType == Material.AIR
event.getCurrentItem() == null
but somehow it doesnt work
Hey quick question. I want to deny a player to interact with everything like chests aso. But when I am opening the chest from a minecart it won't get blocked. Is there a special event for these cases?
interacting with a Minecart which has a chest inside it
you can just cancel playerinteract event
InventoryOpenEvent?
you keep in mind everything that is a container
inventoryOpenEvent
Okay I will try that, but shouldn't be the interact event like superior?
just wondering
is there a character limit to the player list header?
?paste
let me post my pom
👌
this is a meme plugin im making for my friend
Well I read that wrong.
your java version needs to be 16
<java.version>1.8</java.version> oh shoot i switched my JDK to 16
why is this happening
shade plugin will also not work in that version against java 16
well your pom file is just text
switching your jdk won't edit that
can i just edit the java.version to 16
did you apply your changes ?
pretty sure the latest version of the shade plugin should work fine
oh did they release 3.3.3
:bruh:
you r right that's what they do
didnt work
oo i found some logs
[WARNING] Failure to transfer org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT/maven-metadata.xml from https://hub.spigotmc.org/nexus/content/repositories/snapshots/ was cached in the local repository, resolution will not be reattempted until the update interval of spigotmc-repo has elapsed or updates are forced. Original error: Could not transfer metadata org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT/maven-metadata.xml from/to spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/): Transfer failed for https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/1.17.1-R0.1-SNAPSHOT/maven-metadata.xml
[WARNING] Failure to transfer org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT/maven-metadata.xml from https://hub.spigotmc.org/nexus/content/repositories/snapshots/ was cached in the local repository, resolution will not be reattempted until the update interval of spigotmc-repo has elapsed or updates are forced. Original error: Could not transfer metadata org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT/maven-metadata.xml from/to spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/): Transfer failed for https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/1.17.1-R0.1-SNAPSHOT/maven-metadata.xml
[INFO] Validation error:
[ERROR] org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.spigotmc:spigot-api:jar:1.17.1-R0.1-SNAPSHOT
[ERROR] Maven server structure problem
[ERROR] org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.spigotmc:spigot-api:jar:1.17.1-R0.1-SNAPSHOT
Cannot resolve org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT
failure to transfer some stuff
macos
ok
ok
o ok
i dont get it, i can create a paper project perfectly fine
but spigot just breaks
hm
ok it started up
nope
nothing happened
same errors
package?
oh wait
a new folder appeared in the maven sidebar
the "plugins" folder wasnt here before
ok
lots of stuffs downloading
aand
Could not transfer artifact org.spigotmc:spigot-api:pom:1.17.1-R0.1-SNAPSHOT from/to spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/): Transfer failed for https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/1.17.1-R0.1-SNAPSHOT/spigot-api-1.17.1-R0.1-SNAPSHOT.pom
oo maybe because my school blocks the spigotmc.org website
ill go on my phone's hotspot
its not blocked, but
my school just does that
so i cant access it
hm ill go on my phone hotspot
change the wifi
ok
im packaging now
no errors so far
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:03 min
[INFO] Finished at: 2021-09-28T12:52:29-04:00
[INFO] ------------------------------------------------------------------------```
this is still here
yessir
thank you ;)
still lots of red squiggles in the maven sidebar but i guess it works now
ok, thanks so much : )
Hey, is it possible to have multiple lines (3/4) under a player's name (not using Bukkit scoreboard) that don't lag behind or cause server lag?
some plugins use invisible armor stands
and position the armor stands above or below the player's name
Is there a way to copy an entity but just with a different type?
pls help
Does the InventoryClickEvent even get fired if you click on an empty space
hello i have a problem with ubuntu 20.04.3, gradle and adoptopenjdk 16
when i compile my gradle project in intellij with adoptjdk 16
it is weird.
some listeners doesn't get registered
error line 113
my class is 90 lines
when i switched to windows 10 (im using grub dualboot) the problem was solved
and i opened a project created in intellij 2020 and gradle 5
what could be the problem ? if i compile with a newer version of gradle or create the project IN ubuntu will it be fixed ?
you mean the number of slot that is clicked?
And how can I check when someone clicks on an empty slot?
like this:
event.getCurrentItem().getType() == Material.AIR
as you can see, the 2nd group is optional
i want that when im getting the groups, if that group is not specified it becomes null
@last temple ok i added this. the Score score1 = blah blah blah thing
so i need more?
for it to work?
so its right how I did it?
but @last temple , when i watched kody Simpson, i believe he didnt add criteria
yeah but they lag behind, even when teleporting every tick
Whats the problem?
Error:
https://gist.github.com/ItzJustNico/e1e05ba26452fe0811f031d12783ccc0
Line 131:
if (event.getCurrentItem().getType() == Material.PLAYER_HEAD && event.isLeftClick()) {
Item is null
can someone explain me what a CompletableFuture<T> is?
a little bump
what are you trying to achieve? explain it more
@solar sable wait i think i got it
What do you need explained?
is it citizens? or its your own plugin
Own
well how are we supposed to know if its your own?
show the info or something to let us see how to remove it
Gimme a quick sec
good
this is like the carpet mod lmao but anyways
so maybe
wait
you havent made anything to remove it yet right?
like a command to remove it or something
Yea i Made it
Just acouple lines below it
Sende the PacketPlayOutDestroyEntity
Or what ITS called
Not in PC rn
hmm
And the EnumPlayerInfo.Remove_Player
well have you tried /kill @e yet?
because if the command doesnt work then idk what does
Not completly remove it
Just hide it in the tablidt
The removing Part already works
aah
well most of plugins online like citizens and such, do have that type of stuff when you are far away from the npc and then goes back to it, it loads in the name in the tablist and then dissapear
well im not an expert in this, so i will let an expert take handle of this situation
Imagine if minecraft just would add native npc support
So they do it somehow
Too good to be true
bedrock edition that already has npc
cries in java
🥲
So nobody knows the answer for it?
well i wouldnt say "nobody"
just wait until an expert of this type to respind
respond*
Yeah, create a thread maybe
yuh
Ok will do
how to detect when a player chat in mc?
or much specifically, how to detect when a player say a specific word/text in chat
AsyncPlayerChatEvent then filter the message
.contains and so on
aah
okie doke
also i asked this before but it didnt work so imma ask it again, how to set a hover event using just basic java language and not json format
What in god's name is a hover event
cause i want to make it when i join it just puts a hover event saying something like "hello"
you do not know what a hover event is?
what about click event?
Well that sounds more familiar
hover event is just basically
shows a text above a text
so like "hello" and then when you put your mouse over it, it shows a text
No clue tho sorry :c
Oh yeah
ComponentBuilder
component builder?
whats that?
i mean like whats a component builder lol
?jd
Oh
But no workin
Indeed
Well easiest way to do what u want is something like
BaseComponent b = new TextComponent("text");
b.setHoverEvent(HoverEvent(HoverEvent.Action.SHOW_ITEXT, new Text("hover text")));
player.spigot().sendMessage(b);
I think
Typed on phone so yeah
aha a thing that will be completed at some time
ah okay
Well
ill check on intellij and see if it understands it lol
More specifically a CompletableFuture is just a helper class to pass callbacks to said threads once they’re done with their work (they’ll run the callbacks)
uhh no?
wdym messed?
well just .stream()
Because streams also have a lot of similar methods to completablefuture
Main difference is that streams are for processing a sequence, whilst completablefuture process a single value with the help of your callbacks (usually on another thread)
damn theres so many error in this just hurts my brain tryna think
Technically every method you declare is a callback
It’s a function which at some point later gets called back when some event happens
In async context it could be when a large computation is done
Or when a file is downloaded
Etc
well this is a mess because i dont get this
You sure don’t
new HoverEvent(...)
Forgot the new before HoverEvent(
And
That needs to be inside a method most likely
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.
I think you'd be hard pressed to find a resource for learning java that doesn't cover methods
Yeah lol
oh i managed to fix it a bit
but
there still an error in the player.spigot() and i changed from player to "e"
managed to do this
I’m confused that it works
im confused on what to change .spigot to
e.getPlayer().spigot()
fixed now?
wait i made it e.getPlayer().spigot().sendMessage(b);
will that work or no?
Does some random gradle fanboy know how to fix
Could not download annotations-19.0.0.jar (org.jetbrains:annotations:19.0.0)
Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrains/annotations/19.0.0/annotations-19.0.0.jar'.
Could not HEAD 'https://repo.maven.apache.org/maven2/org/jetbrains/annotations/19.0.0/annotations-19.0.0.jar'.
The server may not support the client's requested TLS protocol versions: (TLSv1.2). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.1/userguide/build_environment.html#gradle_system_properties
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
unable to find valid certification path to requested target
[...]
Send ur build script (:
https://github.com/cjburkey01/ClaimChunk/blob/main/build.gradle.kts
Just note that it was not written by me, otherwise I wouldn't be using gradle in the first place
Understandable
@ivory sleet
unable to find valid certification path to requested target
that sounds more like a cert issue than a gradle issue. but the root cert I get should definitely be in the root store
holy sh- @ivory sleet it works aaahh im screaming inside my self conscious!!
aaaahhh
It’s so weird because the error seems to claim you’re trying to get annotations from some Apache repo when it’s on maven central
It is not a cert issue otherwise the java ecosystem would instantly break
well it could also just be that one of the certs in your personal cert store got removed (for whatever reason), though obviously very unlikely
Firefox is able to download it without much issues directly, is gradle using a seperate cert store or something?
most browsers have their own cert store, yes
RIP, in that case porting that mess over to maven would be my only solution
the other alternative I could think of is that some caching issue was present and the wrong cert got served (like an ad-hoc self signed one)
I don't think that maven will make any difference; if it requests the same location of the library using the same java version, it would result in the same problem
unless it's a temporary issue
it could help that I'm using IntelliJ to build it - perhaps that is the issue
anyone know how to put a player's name at the end of the line?
trying it out standalone, perhaps the most obvious thing is the thing to break
I mean it does often run using it's own bundled JRE which might have that pooped cert store
yep, it's IntelliJ being broken. Guess a reinstall is all I can do
I guess it wasn't so unlikely after all heh
geol using IntelliJ 😮
I'm kinda forced to when it comes to using kotlin gradle.
fair
it has like no good themes, the code completion is non existent
someone?
Minimal code completion is best
oh wait nvm
you're high
i think i already figured it out
talking about code gen or code inspections?
Wat
are entity IDs persistent through reload/restart?
nope
just use the UUID
Could not download commons-lang-2.6.jar (commons-lang:commons-lang:2.6)
Could not get resource 'https://papermc.io/repo/repository/maven-public/commons-lang/commons-lang/2.6/commons-lang-2.6.jar'.
Could not HEAD 'https://papermc.io/repo/repository/maven-public/commons-lang/commons-lang/2.6/commons-lang-2.6.jar'.
papermc.io: Name or service not known
yep, IntelliJ is def. broken
no gradle is that shit
oh like
code inspections - finds issues in your code, for instance "turn anonymous functional interface instantiation into lambda"
code gen - when you press enter at the end of { it'd gen a }
is there a way I could like..."inject" data into a beehive's custom data? like if I wanted to keep track of how many bees the hive had and stuff
oof
I mean, eclipse supports both :), and I quite like how it's done there
havent used eclipse since the last blue moon so cant tell which one excels here
I was talking about stuff like auto-completing entire sections of code, i. e. "machine learning"
Okay, Imma try using raw ip addresses, let's see if intelliJ can handle that at least
will be interesting
It's hard to convince a person who has their pfp as the eclipse logo to switch to IntelliJ
I mean you could try changing the boot runtime of intellij idea to fix it 🙃
At least some success there
declared mavenLocal, now it's down to a single depend that I'll likely have to build myself
am i doing something wrong? i followed the directions on the vault api page, i did https://pastebin.com/ZzKS75fz in my main class and in another class im doing main.getEconomy().depositPlayer(p, Double.parseDouble(args[1])); and im getting this error Caused by: java.lang.NullPointerException at com.abk.commands.economy.ecogive.onCommand(ecogive.java:119) ~[?:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[patched_1.16.5.jar:git-Paper-786]
main or main.getEconomy() is null. Please use Java 15 or higher for extended troubleshooting
they have to be
If you were using J15 it would be openly yelling at you what's null
Did you call #setupEconomy anyways?
yeah in the code i sent? thats everything that involves vault
You declare that method, yes, but you don't call it from the code you sent
wdym by "call"?
line 3 you are returning true, it should be false
Invoke, run, whatever you call it
Whats the right way to stop the player interact event firing twice? if(event.getHand().equals(EnumWrappers.Hand.OFF_HAND)) return; doesnt seem to be working
invoke run...? what
Do you have something like myPluginInstance.setupEconomy()?
uh no
well, it's needed otherwise econ will stay uninitalized
but dont i just call it from my command? main.getEconomy().depositPlayer(p, Double.parseDouble(args[1]));
no, you call getEconomy() with will just return econ
as such you can just short-circuit it with main.econ.depositPlayer(p, Double.parseDouble(args[1]));
if econ is never set to a value, it will be null, thus throwing a NullPointerException
i did what you sent and in intellij it just shows up in red with no context
That's because it's likely not valid code and I just made it to simplify it for you
You should be doing it the way you did it before, but initalize econ properly
Make sure you either A have a static instance of main that you’re using, or B, you’re properly passing around the main instance. If you do that, and the economy is already set up. You should be fine.
i already do if this is what you mean private static Economy econ = null;
I'm assuming it is the private modifier
Sigh
guys can i use always static or its bad?
That doesn’t need to be static if your main instance is
its bad to use all the time
Just add setupEconomy(); at the top of your onEnable()
i need help
don't invoke .toString() use .getName()
use == for enums!!
Static isn’t always bad, it had a purpose other wise it wouldn’t exist. It’s good for functional programming, not everything has to be OO.
idk what you're on about imma simplify this
in main @trail remnant
// onEnable method
this.setupEconomy();
Command
private final MyPlugin plugin;
public MyCommand(MyPlugin plugin) {
this.plugin = plugin;
}
// Command method
plugin.getEconomy().// whatever
^
ok ill try it thanks
we got the singleton pattern also and true constant 😄
Why transfer the plugin every time? better convey the Economy right away
lol cannot be applied to equipment slot.
what if you wanna reload the config
because you'll use the plugin instance for other reasons
also that
if (event.getHand() == EquipmentSlot.OFF_HAND)
it only gives me e.getPlayer()
e.getPlayer().getName()
I'm using custom config class for that
Yea I use the singleton pattern in my plugins. I like it
I transfer the Config||.java|| to the class, and then I work with this class, it already has a built-in method for reloading the config, as well as receiving messages from it
all i did was add what you said this.setupEconomy(); and i tried to use plugin.getEconomy() but intellij auto corrected back to what i originally had, main.getEconomy() and it still isnt working, same errors
public class Config {
private final Main pl;
private final FileConfiguration config;
private String playersOnly, usage, testMessage;
public Config(Main pl, FileConfiguration config) {
this.pl = pl;
this.config = config;
reload();
}
public void reload() {
pl.saveDefaultConfig();
pl.reloadConfig();
playersOnly = config.getString("players-only");
usage = config.getString("usage");
testMessage = config.getString("test-command.message");
}
public String getPlayersOnly() {
return color(playersOnly);
}
public String getUsage(String label) {
return color(usage).replace("%command%", label);
}
public String getTestMessage() {
return color(testMessage);
}
private String color(String s) {
return ChatColor().translateAlternateColorCodes('&', s);
}
}
public final class Main extends JavaPlugin {
@Override
public void onEnable() {
Config config = new Config(this, getConfig());
Objects.requireNonNull(getCommand("test")).setExecutor(new TestCommand(config));
Objects.requireNonNull(getCommand("suicide")).setExecutor(new SuicideCommand(command));
}
}
public record TestCommand(Config config) implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!(sender instanceof Player p)) {
sender.sendMessage(config.getPlayersOnly());
return true;
}
if (args.length < 1) {
p.sendMessage(config.getUsage(label));
return true;
}
config.reload();
p.sendMessage(config.getTestMessage());
return true;
}}
@Getter
public class Messages implements ConfigFile {
private final String prefix = "Hi";
@Getter(AccessLevel.PRIVATE)
@IgnoreField
private final Plugin plugin;
public Messages(Plugin plugin) {
this.plugin = plugin;
}
public void loadConfig() {
try {
YmlGenerator.generateConfig(plugin, this);
}
catch (IllegalAccessException | IOException exception) {
Logger.log("&4Cannot load config! Report this to the Discord server:");
exception.printStackTrace();
}
}
@Override
public @NotNull String getName() {
return "messages.yml";
}
}
GalaxyLib 😩
?paste
Do you understand instances? ABK? It will be difficult for you to solve your problem if you don’t
I'm on phone