#help-development
1 messages Β· Page 2188 of 1
?paste
huh?
package com.cyan.elytrarace;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.plugin.java.JavaPlugin;
public final class Main extends JavaPlugin {
@EventHandler
public void onPlayerUse(PlayerInteractEvent event){
Player p = event.getPlayer();
if(p.getItemInHand().getType() == Material.PHANTOM_MEMBRANE); {
Player#performCommand (/tp @p 0 200 0)
}
}
}
performcommand is red now
Hi when i spawn the armorstand the item in the main hand will not show up
https://cdn.discordapp.com/attachments/741875863271899136/982430237293961226/unknown.png
Don't put /
You need to wrap strings
And replace @p with player name
Not sure if @p works
It may
yeah i asked around because i didnt know how to perform a command and thats what others told me
I just started so i dont have that much
i already learned the basics but ill watch it later
i didnt exactly know how to perform a command and another person told me itll work like that, but i guess ill never trust others again goodbye
Lol
I wonder if he tried to register the events
I dont think there's an onenable
It is
Check the curly braces at the end
first for the if, then the method, then the class
https://pastebin.com/ZbszvVn0 i keep getting an error at line 47 https://gyazo.com/472266c17409268a59f6a4ffe0bade87
Probably missing closing curly brackets }
learn java pls
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
i tried removing it, but then the other one got error
have you thought about reading the error message and trying to understand what it means?
i have
looks like you need one more }
it says
Expected }
Expected }
2 times
yea but when i add, it still says the same error
wait
itsn ot fixed
i think
really confusing.
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
how to move an entity (with pathfinder) to a 20+ blocks location?
i want move
:/
You need to either use paper and their pathfinder API or
access the pathfinder goals of the NMS entity and change them.
Does bungeecord contains a packet for redirecting a player to a specific server? (Im creating a fake client and connecting it throw proxy. So i need to he based on minecraft protcol)
A fake client doesnt have a connection. Thats why the proxy doesnt know about it at all.
Alternatively it is also possible to do CraftCreature#getHandle()#getNavigation()#moveTo()
if pathfinder isnt that important that is
Which might get overridden in the next tick if the ai goal is changed. But yes if the entity is moving already then this also works.
@final monolith
the moveTo() have a limit of 20 blocks
Im connecting a fake client throw the proxy
A plain socket which do handshake and login packet
So its literally a fake client
what do you mean?
if the target's location distance > 20 blocks, the method returns false, and the mob didnt start pathfind
this is the method, I dont see anything about 20
it returns false when the path is null
please do tell me how it went! I am planning to use this soon aswell
well that method is from minecraft
its nms with mojang mappings... could there be another reason? maybe the location targetted is not reachable?
its a common issue, didnt work
oh well
"minecraft:" + material.name().toLowerCase() ?
that
yw
?notworking
define not working
"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.
have you registered the listener
Your Configuration is defined but not Initialized
config.addDefault will be throwing an NPE
I have not a error
yes you do, if that code is running
getConfig; != getConfig();
its a runtime error
we dont know what you mean by this. Is your IDE not showing an error? Are you trying it and the console isnt showing an error?
@quaint mantle
i think your listener class arent registered
your main class aswell please
specifically the onEnable()
you have to register the class which the Listener is in, not only the Main class
nooooooooooo
getServer().getPluginManager().registerEvents(new youAreAwesome(), this);
π
that
Which is why I told you to learn some Java before starting with Spigot
To a listener class catch events, its needs to be registered
They've already done it once
to register a listener class, you need to use Bukkit.getPluginManager().registerEvents(new ListenerClass(), plugin);
you need an instance of the class, not the actual class
what do you mean?
new
β¦ new ListenerClass()
not .class
yeah, new youAreAwesome()
I usually circumvent the whole Listener registration by doing it with reflections
gross
the code
ive done something similar using @annotations
nice code dude
thanks, its stolen π
basic dev things
Calling the class Reflections is a bit wrong for me
I know, but it won't actually use the reflection API there
that is more lines of code than just a List.of and a for loop
this
did you insert this into the onEnable(), right?
Not working as in not compiling?
without the dependency
What I am saying is that the dependency called "reflections" does not use the java reflection API
you can create the same method with 2+ lines
wow you removed a dependency?
im so confused?
There are 100 ways of not working
youre pink nametag does not mean I wont get you
π
lol
(the name is bad even if it were to use the reflection API)
π€£
meh, it works and its fine
Go back to #general
no console errors?
I am calling it now: it does not compile because either:
a) The class "youAreAwesome" does not exist
b) The class "youAreAwesome" does not have a no-args constructor
Even better lol
config is null
geol
omg
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
no
DONT LEAVE ME HERE
How do I get rid of multiple ItemStacks?
Sometimes I should create 4-5 ItemStacks and I'm setting ItemMetas for each them. Its being really long code..
what do you mean with "rid o multiple itemstacks"?
This is the tamer variant of issues
make a method which takes the burden of creating and editing the stacks
There are some people on here I really want to kill for their stupidity
hey so sometimes the ConfigurationSection#get(String) returns LinkedHashMap instead of ConfigurationSection?
depends if it has been saved to disk iirc
(not that I will, I do not have time for that)
and that is and always will be the only reason
Thanks
what do you mean by that? I am not saving it in the mean time, only loading
Object result = config.get("test");
if (result instanceof LinkedHashMap<?, ?>) {
// Its a LinkedHashMap
}
well yes but why doesn't it just return ConfigurationSection
omg
java cannot do this
id need geol to weigh in here, but am pretty sure once it is saved to disk it will be a config section, otherwise it is a memory section. Or something like that
returns a Object
and you need to work inside that object
The reason it returns a LinkedHashMap is simply because someone inserted a LinkedHashMap in there
someone...
Though it is a bit strange that it does not convert it to a config section
someone = who writted the code
?stash time to question the source code heh
= you
a Map added to teh config remains a Map until it is saved and reloaded. Then it becomes a MemorySection
This is a bukkit issue
it should be a config section
to get it as a Map from a ConfigurationSection/MemorySection you getValues(true)
if i understand it correctly, an ItemStack builder might be useful, there is an implementation on forums
https://www.spigotmc.org/threads/utility-itemstack-builder.91812/
how change the blocks limit of a PathNavigation? (moveTo method)
hey i didnt say that with that inttention
im sorry dude
isnt really a way to do that, either use paper and hook into their Brain api, dig through internals or use your own pathfindeer
if i create my own pathfinder i can change that?
well, you can manually move the entity?
no more 20 blocks of distance
no as in generate the path with a custom pathfinder and then move it manually
π€
@quaint mantle Yeah, no clue why this happens
Could be a spigot bug, who knows
Could also be a snakeyaml issue
ok, to create that pathfinder its like create a new instance? or its is an abstract class or something?
very annoying
the issue is, my system is relying on a yaml section being 1 type
i mean like literally implement a pathfinder
forget i said anything
π€
Is there a way to make a configurationSection from a map?
oh cool
this throws when using empty string, so this doesn't allow you to make the map the section itself
it needs a key
Yeah, you need to do it on the parent
it has no parent bc im doing new MemorySection()
Myeah, I think this is the cause
You should use YamlConfig not whatever system you have in place
are spigot builds for release candidates planned to be available this update cycle
Probably no
what do you mean by this
oh I see why it is returning LinkedHashMap btw
object:
- a: 1
b: 2
- c: 3
d: 4
```Its this yaml section
You should have something like
[... load yaml via YamlConfig ...]
ConfigurationSection section = cfg.createSection("path.to.broken.section", (Map<?, ?>) cfg.get("path.to.broken.section"));
in theory yes
Oh
get("object") returns a map not configSection
Technically you want to do check whether .get really returns a map or not, but you should understand what I mean
yup
Hello! I was thinking in creating a skyblock plugin, but i don't really know how to make a region for all islands, could someone help me what to use?
???????? what is this about
Why is it taking issue with those two lines in my config file and nothing else
And it doesn't even seem to be affecting the functioning
Did you accidentally add a tab in there?
Do I have to always use spaceS?
Yeah ... because yaml
line 10
Yes I know it's line 10 π
seems correct. are you sure the file included in your plugin is exactly the same as the one you sent?
Yea I just copypasted it out of the config that's on the server
huh then I have no idea
The error doesn't seem to affect the functioning of the thing at all either
Like it says it can't parse it blah blah but it still finds all the strings lol
I have no idea :/
I might try server restart
Still happening after a restart
Oh well it doesn't stop the plugin from wokring
Maybe it will go away eventually
put it in a yaml validator
snakeyaml moment
google yaml validator and click first thing that shiws up
Yea I found it
Still valid
I don't think this error is actually an error
Or something
guys, why entities with sleeping animation turns invisible if goes 16 blocks of distance?
I copypasted the yaml out of the validator into the file and it still takes issue with that
This error is just bs
Update: if I use a command in my plugin that updates the booleans at the top of the yaml file, the error goes away until a restart
After the restart it comes back until I do that command again
I have this code that's supposed to give hero of the village 10 but when I finish a raid I get hero of the village V. any ideas?
The schedule is there because if it isn't there, the default minecraft code overrides it and gives hero of the village V
public void Hero(RaidFinishEvent event){
PotionEffect effect = new PotionEffect(PotionEffectType.HERO_OF_THE_VILLAGE, 120000, 10));
Set<UUID> heroes = event.getRaid().getHeroes();
heroes.forEach(id -> {
Player player = Bukkit.getPlayer(id);
if (player == null) return;
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
player.removePotionEffect(PotionEffectType.HERO_OF_THE_VILLAGE);
player.addPotionEffect(effect);
}
}, 2L);
});```
i mean a for loop and a lambda would look more elegant
heroes.foreach is like a for loop
The schedule is there because if it isn't there, the default minecraft code overrides it and gives hero of the village V
I said
i guess the max level is 5
not minecraft's code
.
people still not using lambdas?
what is lambdas
Well I changes it to this so that the delay only happens once
public void Hero(RaidFinishEvent event) {
PotionEffect effect = new PotionEffect(PotionEffectType.HERO_OF_THE_VILLAGE, 120000, 10));
Set<UUID> heroes = event.getRaid().getHeroes();
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
heroes.forEach(id -> {
Player player = Bukkit.getPlayer(id);
if (player == null) return;
player.removePotionEffect(PotionEffectType.HERO_OF_THE_VILLAGE);
player.addPotionEffect(effect);
RaidLevels.remove(event.getRaid());
});
}
}, 2L);
}```
but I still get level V and not 10
any ideas?
Full tutorial for Lamba expressions in Java.
Complete Java course: https://codingwithjohn.thinkific.com/courses/java-for-beginners
Lambdas in Java can be very confusing and hard to understand for a beginner Java learner, but they don't have to be. Lambda expressions allow you to create a method implementation as an object, and you can learn ho...
your ide should tell you about that too
unless youre using java7 or lower
Hi mfalex, how are you?
Nice to see you again with nitro
they even used lambdas in the code they sent π
Fine,
I love ho you asked and you
Hahaha
Its like a developer communication
hahaha
isnt that how it usually works lol
Why does it matter in this case
it doesnt
cuz its much cleaner
how would you have done this?
what ide are you using?
IntelliJ
runTaskLater(() -> { /* your code */ }, delay)
what java version are you using then?
@EventHandler
public void Hero(RaidFinishEvent event) {
PotionEffect effect = new PotionEffect(PotionEffectType.HERO_OF_THE_VILLAGE, 120000, 10));
Set<UUID> heroes = event.getRaid().getHeroes();
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> heroes.forEach(id -> {
Player player = Bukkit.getPlayer(id);
if (player == null) return;
player.removePotionEffect(PotionEffectType.HERO_OF_THE_VILLAGE);
player.addPotionEffect(effect);
RaidLevels.remove(event.getRaid());
}), 2L);
}
should the name in AttributeModifier be snake case or camel case?
generic.attackDamage or generic.attack_damage
just do runTaskLater
Anyone else has used this library https://github.com/GeyserMC/MCProtocolLib
I once did
erm well if with "client" you mean a bot etc, yes
that's exactly what I did
You do it for PMS?
Plugin message channel?
π
I want to do it with that reason
it was a commission, no idea what the dude needed it for
at least I cant show you the source code
Also where did you find the lib documentation?
i usually invalidate cache
it called sender!!
Is there any way to bypass world guard mob-spawning false with your own plugin? I tried setting the priority to the highest
i think I just questions on their discord
And you using commandSender
it's called however one calls it
Allright i asked but they didnt much answer
Look he call it sender, and them he is doing instanceof commandSender. Instead of doing instanceof sender
πΏ
im not good with code
where do we download Java 17 at?
it was quite annoying IIRC
trying to download on a windows machine
allright
oh then at oracle -> https://www.oracle.com/java/technologies/downloads/
java,com is not anymore used, it used oracle.com
I have orcale downloaded already, trying to run buildtools and just says I need java 17 when I have JDK 17 installed
you also have to use java 17 to run buildtools
yes but I cannot locate where to download it
C:\LocationToJava17\bin\java17.exe -jar BuildTools.jar ...
mfalex
Sorry for bein annoying
But i have been wondering to doa proxy bot since 2021
So i will try do it
I wont give up
reinstalled JDk17 to see where its location was https://gyazo.com/94b0aee51b3be221e011179c1366392a and its literally not even there
why?
i never learnt it
then install it again and write down the location lol
thats what I've done twice now, it's not even creating a 17 file, only java 8 is there
maybe i'll get better in the future if my 2 brain cells can contain information
the thing above you sent is called "casting". You know, you only have a CommendSender object. It MIGHT be a player but you don't know yet. so you cannot access any player related methods unless you tell java "okay we can treat this commandsender as player, because I know it'll be a player"
also what tutorial do you follow? send link pls
mfalex
In this video I show you the standard way to create commands as well as how to create a custom command handler to create your commands in an easier way.
π Take my FREE Java course today by starting a free trial of Skillshare:
https://wornoffkeys.com/java-for-free
πΊ Updated playlist:
https://www.youtube.com/playlist?list=PLaxxQQak6D_e-4s_rDzmUq...
Its fucking annoyingmy claim plugin
When the build flag is active and player is claim member, it told me as i cannot build on that claim
looks good. finally someone who doesn't compare the command's name in their executor
why do you keep misspelling my name
Lmao send your code again
idk how to make it show the version loading
Ah shit here we go again
should that work
no that won't work
oh
Use plugin. Get Description. Get version
i know alex is cringing rn
getLogger().info("MyPlugin version " + getDescription().getVersion() + " is loading");
HI, nice to see you again
hahaha
the ${ ... stuff are maven placeholders. maven doesn't filter source code normally though, only resources (text files, etc)
@EventHandler(priority = EventPriority.HIGHEST)
public void onBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
Claim claim = this.plugin.getClaims().getClaim(block.getLocation());
if (claim == null) return;
if (claim.getLocation().equals(block.getLocation()) && claim.getOwner().equals(player.getUniqueId())) {
this.plugin.getClaims().delete(claim);
player.sendMessage("Β§4Claim Β§f" + claim.getUuid() + " Β§4has been deleted");
return;
}
if (claim.getLocation().equals(block.getLocation()) && !claim.getOwner().equals(player.getUniqueId())) {
event.setCancelled(true);
return;
}
if (claim.getOwner().equals(player.getUniqueId())) return;
if (!claim.getFlags().contains(Flag.Build) && claim.getMembers().contains(player.getUniqueId())) {
event.setCancelled(true);
player.sendMessage("Β§f[BlockBreak] Β§cBuild flag is not enabled");
return;
}
if (claim.getMembers().contains(player.getUniqueId())) return;
event.setCancelled(true);
player.sendMessage("Β§f[BlockBreak] Β§cYou cannot build on Β§f" + claim.getUuid() + " Β§c claim");
}```
btw you should directly check out a tutorial that uses maven
So I have this HashMap private HashMap<Raid, Integer> RaidLevels = new HashMap<Raid, Integer>();
When a raid starts this is registered to the Hashmap @EventHandler public void BadOmen(RaidTriggerEvent event){ RaidLevels.put(event.getRaid(), event.getPlayer().getPotionEffect(PotionEffectType.BAD_OMEN).getAmplifier()); }
when a raid is finished I execute this PotionEffect effect = new PotionEffect(PotionEffectType.HERO_OF_THE_VILLAGE, 120000, RaidLevels.get(event.getRaid()));
and it gives me Cannot invoke "java.lang.Integer.intValue()" because the return value of "java.util.HashMap.get(Object)" is null
I output the HashMap after the RaidLevels.put() and it's ok
idk what is wrong here
then your raid is not in the map
Just use the nested ifs
What message are you getting?
the last one, beina claim member and flag added
does the raid variable change from the start to the end?
i don't know. you could try printing out the hashcode of the event's raid and the raid you had saved and see if they're different
Do the player uuids match?
Yes
Are you sure
I ill check it
ok π€
I dont wanna happenwhat happened yestetday
if I was you i'd switch to maven NOW https://blog.jeff-media.com/how-to-create-your-first-minecraft-plugin-using-the-spigot-api-and-maven/
you can still follow the youtube tutorial for the actual content
it is building using maven
K i'll try
use this:
hey, i changed the swords attack damage and it's attack speed got reset to the base 4 but i want it to be regular 1.6, should i just add -2.6 attack speed with attribute modifiers or is there a better way? and how do i make it look like vanilla sword (just hide attributes and manually add lore?)
but where's the pom.xml
btw that message is useless because spigot itself automatically prints messages like that
minion, uuid match
mfnalex what did the bot tht you receive comission from?
what did the bot?
you mean what it did?
nothing. it just logged a player in and then kept them standing there doing nothing
What kinda bot? Discord bot or mc bot
mc
Someone paid him to do a bot that connecto to server and still afk until server goes don
Is exactly what we are looking minion
I'd still prefer being able to add the player thru bungee itself without connecting a player
Also i dont know why their discord is like dead
You cannot i think because the plugin message is a packet
And that type of packets are delivered by a player connection
yep
if you wanna send a message with plugin messaging from spigot server A to B it requires at least 2 players online, one online per server
Conclure the one that will works is a fake client staying afk right?
yeah you could mock a player in principle
Conclure u think it's possible to create a fake proxyplayer and connect to each spigot server?
technically it would be
Anyone?
What do you mean by mock?
I dont understand netty enough to do it
With netty would be more diff
Yes but a cleaner impl
Because you have to use lot of reflections to get the spigot ad bungee netty instance
But yeah i would prefer doing it with netty rather than plugin message
You won't have to deal with spigot if eberything goes on in bungee
Reflection would be needed though I'm pretty sure
The biggest issue I can see here would be proper authentication and stuff like that
just connecting to the server socket isnt that hard
well im talking about mocking a player
what its mocking?
it can mean different things
Conclure im already doing that
in this case faking is a good synonym
Yep that's what i wanna try
Im connecting a socket to proxy, sending handsahke and login packet
yeah good for you
But the fake client get disconnected fromlobby some seconds after
Idk why
What can be conclure?
idk
Conclure do you want to see the full code?
uh sure Ig
send a github link or sth
imaging not using gh
ok i will upload it
Conclure please ait
I really want to make this works
Its my main achive
yes and it has been for quite some time
Im so fucking confused
why olie?
welcome to my life
Why are you annoying
Its simple the logic:
Plugin message channel on spigot side require a 1 player atleast, so im faking a client which connect to proxy
So i am looking at this value of out, its purely sin(1) * 2*32
use an alt lol
hang on let me get my calc
here
ok
WTF
dependency injection
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
aa
that works, altho dependency injection is favored
?di just for good measure
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
I mean depends on how you're going to scale your project in the future
?di to make sure u see
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
so sin(1) is about 0.84147098
2^32 is 4294967296
why is java giving
0.84147098 * 4294967296 = 2147483647
getPlugin does some weird stuff with the classloader iirc
but it doesnt if i jsut do the sum
whattttt
Maybe it's bigger than integer.maxvalue
@ivory sleet here you have https://github.com/Alexito2060/FakeClient/
I thought it's supposed to go negative then though
OMG you are a genius
that must be it
static final fields are instantiated when the class gets loaded
Static variables are declared when the class loads
so obviously way before onEnable
Not declared
If an integer multiplication overflows, then the result is the low-order bits of the mathematical product as represented in some sufficiently large two's-complement format.
use a lazy class
im just search and replacing int -> long
since your main class is gonna be loaded its gonna cause some issues storing your plugin instance as a constant in your main class
Use a class that you call onenable
^
Conclure i sent the repo?
I cannot remember now
Some people told me that i the client was being kicked cause of not sending keepalive packet or anwering the ping packet
Conclure are classes loaded into memory when you first reference them or are they loaded before and the jvm just decides to do stuff associated with it when it's first referenced?
I feel like you'd know this cuz ur bigπ§
whenever a field or method from the class is invoked, then it gets loaded (or explicitly loaded with classloaders)
so this excludes using merely Class.class
Does that mean a HUGE class can theoretically lag the application?
probably, just depends on the use case i guess
PSJahn yes, you most likely are going to have dependencies
yeah using it for dep injection is fine
since your command executor is gonna be a pretty low level class, thus depending on higher level classes
That was for testing pupoue
ah okay
Hello! I'm trying to use "WorldEditPlugin" that is supposed to be in the API but I can't use it. How can i solve this?
but anyway why dont you make it to a spigot plugin?
Do you have the right maven dependency?
I think so, I can use other features of the API
Up to now the handashake and login packet are okay, because the fake client connect the server, but some seconds after get disconnected from server. So maybe im not sending a packet
Send what you're using
sure
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-core</artifactId>
<version>6.1.4-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
check out this verano https://wiki.vg/Protocol_FAQ#What.27s_the_normal_login_sequence_for_a_client.3F
I would deal with this by letting this fake client send a special packet
offline mode?
tho
nvm
I have also tried the latest version and still
and then you handle that special packet, so if bungee/spigot encounters the special packets you make sure to undergo a special login
he?
Oh ok
Good idea
But now i want to fix this
without caring for premiuym
and then you might have to inject some other stuff to make sure that this fake client is a player
Just do the player keep afk on the server
mye
how
I dont know lmao
I tried many times
The most shity part is that they dont have a getter
π‘
i would pay someone
But they will ask too much
Use worldedit-bukkit
okay, i'll try
conclure?
now thanks!
ye verano
just get the ProxyServer instance, believe the impl BungeeCord has a direct field to the nio event thing instance
so just reflect that
myeah sth like that
or if you create a decorator around existing stuff
and then inject the decorator
decorator?
Ok
x)
sorry
no its fine
why i get that exception?
server issues = #help-server
development issue = #help-development
but is development no? i working on my code and get it
Well can we see how you spawned in the armorstand?
Oh you are coding a plugin?
yep
String currentDir = System.getProperty("user.dir"); reader = new BufferedReader(new InputStreamReader(new FileInputStream(new File(currentDir + "/" + "nicks.txt"))));
i cant get file
Huhhhh
Can we see spawnBullet?
File file = new File("nicks.txt");
Just do that
Why generate a skull every time
Do it once and save it
Conclure, how do i read server response?
But why generate one everytime to check if it's similar
wait
Save them to a set or map or something
I know that i have to use Socket#getInputStream()
but i need reader
Well pass that file into the fileinputstream
well what is your error?
how
It's not but it's hard to read your code
You did it above, just do it with this instead
Why don't u just add some data to the pdc and check if the skull has that data
Instead of checking issimilar
where is this file creating
In your server folder
No you need to do new File(plugin.getDataFolder, "nicks.txt") ; for that
no ty i dont want it in that folder
sooo are you getting an exception? or is the broadcast just not getting triggered
well can you send the error then?
error again
[19:13:34 WARN]: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
[19:13:34 WARN]: at java.util.ArrayList.rangeCheck(Unknown Source)
[19:13:34 WARN]: at java.util.ArrayList.get(Unknown Source)
Ur trying ti read an empty list
its not empty
it seems like there is a problem with however you are creating the skull
Can i see your code?
what
File file = new File("nicks.txt");
reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
Yes but where do you read from the reader
can i send it in dm?
?paste
Copt it there and send the link here
why not lol
yeah just using a plain text file is probably not a great idea either
its probably classified
accept friend request
probably shouldnt be asking about it in a public discord then lol
you dont want to be interacting with a player object if theyve logged offline
because it wont take effect ingame
well for one itll change the next time they log in, so there could end up being 2 of the same player in your list
and also it could cause issues when you try to use certain methods on it
then store the OfflinePlayer object
well then just store their uuid, and use Bukkit.getOfflinePlayer when you need the offline player
Just save to a file or something
use a Set<UUID> and check if set.contains(player.getUniqueId())
Or in their persistent data container
set their mode in the Players PDC. then set the right mode when they log back in
and then that ^^
?pdc
i love pdc
What the heck means the number 3 in minecraft protocol?
Because after doing handshake and login packet, im reading the socket input stream. And the input its literally a number "3"
@ivory sleet reading socket input stream is literally saying shity number 3
3
3 is 3
what packet?
Because its said x0F shit
or isnt that a packet
I dotnt know
Im doing handshake and login packet
And after that im reading the input stream
Really shity info there
Say 0x0F but what shit is x0f?
I dont understand LMAO
i aint understanding anything of bitwise
Classic reddit support subs
can someone help with buildtools install
there is an error
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
RIP
Haven't used it before
i just doing a socket connect a spigot server
And sending handshake and login pacekt
there is no error in the log you sent
AngelChest lol
what about it?
breh scroll down mate
I did
your log suddenly ends without any error
Β―_(γ)_/Β―
wait wot thats not the end
?paste
hm that's weird, I have no idea
you could try to cd into the SPigot directory, then manually run mvn clean package -U, then run buildtools again
buildtools directory or
this?
yes
Hey guys, I'm trying to make a spigot plugin that increases the player's KB the more they are hit, I've so far constructed the following code. One issue with it is that it stops knocking the player further once the knockback sends you 18 blocks away due to some Player class restriction(All other entities can be hit further than 18 blocks and don't have such a threshold, it's also might be because Knockback is managed by the client not the server "that's why anti-kb hacks are possible" and I don't want it to be a mod nor want it to have a custom client to run the plugin) I've tried to work around it by damaging the player artificially and sending them further away once after 3 hits of reaching the threshold, but it didn't quite work, the first "natural" damage doesn't knock the player at all, the second "artificial" hit does, how can I make both of them knock the player the desired amount? thanks in advance.
code:```cpp
public class Knockback implements Listener {
int heatValue = 0;
public void ArtificialHit(LivingEntity en, Vector v2, EntityDamageByEntityEvent event){
en.damage(1);
en.setVelocity(v2.subtract(event.getDamager().getLocation().toVector()).normalize().multiply(heatValue));
}
@EventHandler
public void onPlayerHitPlayer(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof Player && event.getEntity() instanceof Player) {
heatValue++;
LivingEntity en = (LivingEntity) event.getEntity();
Vector v2 = en.getLocation().toVector();
if(heatValue >= 8){
ArtificialHit(en,v2,event);
try
{
Thread.sleep(1000);
}
catch(InterruptedException ex)
{
Thread.currentThread().interrupt();
}
ArtificialHit(en,v2,event);
}
}
}
}
never let the thread sleep
WTF
why not?
?scheduling
cuz it will the block the whole main thread
that will stop the whole server for one second
what should I do instead?
this
is there no other way but that scheduler :<
no
but the scheduler uses a pool of thread and thats faster
well, how about if I replace the damage() with an invisible explosion. wouldn't that knock the player back more?
no
all I'm trying to do here is knock back more than 18 blocks
If it has a max velocity
I really didn't think it'd be that complicated
U can't hit the player back more than that
what's the problem with using the scheduler?
Just tp the player small amounts
yeah in a repeating task
fineeee I will see what's that all about
or apply the velocity over and over again
wait that works?
why didn't you guys tell me from the beginning lol
well you said that there's a max velocity for players. I haven't checked that, but if it's true, then you can simply apply the velocity every tick until you've pushed them far enough
Let x be the multiplier
because you didn't ask for this?
it's a dirty workaround at best
all I asked for is any way to knock the player more than 18 blocks
yeah but you only said 1 minute ago that there's a hardcoded velocity limit for players
I didn't know that before
a guy yesterday told me that knockback is handled by the client not the server
that's why it knocks entities back more than 18 blocks but not players
maybe something like double those 18 blocks the more the heat value increases?
and that's also why anti kb works
vibration vibes intensify
bzzz
bash: mvn: command not found
yeah you need to have maven installed
that'ss wat it says@tender shard
just to be clear, does setVelocity ACTUALLY do the kb or does it sit how much kb the player will get the next time they are hit?
oh
I mean anti kb is just trying to bypass the velocity change by sending a set of packets to deceive the server
but tbh my idea probably won't fix anything anyway
where to download from
have you tried deleting EVERYTHING besides BuildTools.jar then try again?
setVelocity literally is like a push
tried
it has nothing to do with the knockback mechanism
so if I don't need a damage() to push the player
correct
the name is kinda deceiving
it's really not lmao
I mean it's like setting a value, not actually doing a push
you are setting a value
the effect is like a push, in certain situations
for example if they enable fly right after setVelocity(), their velocity is something like 0.55 or some shit
it fluctuates, Minecraft handles velocity. when you setVelocity, you're overriding hte previous velocity and the one you set is completely up to the circumstances of the world
if they are "pushed" into water, they might stop immediately
^the velocity is a vector which can be seen as a force which translates into some sort of acceleration
exactly that, when you call setVelocity, you're just overriding the previous value & it'll change from right after you set it
oh wow, thanks for the clarification
can I make a zombie hit twice per second in 1.8.8?
You can make a zombie hit twice in any version lol. Subtract health 
What happens if I set the velocity of a player continously to 0,1,0 and then I set it in another method to 1,0,0?
?
i dont want double damage
i want double attack speed
but that's only for players and not mobs
they will be randomly pushed on the x-axis I guess, assuming you're on the same thread
tias
in https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/RecipeChoice.html
This class is not legal for implementation by plugins Did mojang tell you not to do that? Or was that your decision?
declaration: package: org.bukkit.inventory, interface: RecipeChoice
will this also stop the server? TimeUnit.SECONDS.sleep(1);
I want to try to use multiple (setVelocity)'s but I still have to figure out how to make the program "wait" before the second setVelocity
why I'm not using the scheduler is because I'm a bit short on time and I don't want to delve into something completely new to me
schedule the 2nd after some time with the scheduler
what would happen if i set a repeating task with the wrong plugin? as in the plugin that does not contain the code for the task?
Bukkit.getScheduler().runTask(plugin, () -> {
// set thing
}, seconds * 20);```
anyway to make it millisecond accurate?
when it says legal, that doesn't actually mean it's law, it just means creating a new class that implements RecipeChoice won't do anything
doesnt the scheduler wants a plugin instance for in case the plugin disables so it stops all the tasks that plugin is doing?
you need to use one of the two existing implementations, ExactChoice or MaterialChocie
oh
idc
you can only works in ticks, which is 1/20 of a second
if one plugin disables my entire server is broken anyways haha
at least I'm about 99.99% sure that it won't work, but it definitely doesn't mean it's law to not implement that class
Oohhh.. that makes sense
is the 20 the tics or the seconds ?
the program wants ticks. you are giving it seconds * 20, because there are 20 ticks in a second.
if you pass in 1, its 1 tick
Wdym continuously?
so 20 would be after a second
That'll freeze the server
so if I do it like that ```cpp
if(heatValue >= 8){
Bukkit.getScheduler().runTask(plugin, () -> {
}, 2); damaged.setVelocity(damagedV.subtract(event.getDamager().getLocation().toVector()).normalize().multiply(heatValue));
}
also keep in mind, 20 ticks = 1 second is the perfect case, there are cases when 4 ticks is 1 second
it all depends on what the server is doing at the moment
Yes
4 tps lmao
exactly
Hello. I am trying to use the ArmorEquipEvent (https://github.com/JEFF-Media-GbR/ArmorEquipEvent) to give a potion effect when a specific player head is equipped. And also to remove a potion effect when the player head is unequipped. What I have below works with recently created player heads. If a player leaves the game with the player head in their inventory, the player head will get "deactivated" meaning the potion effect will not be given.
if (event.getNewArmorPiece().getType() == Material.PLAYER_HEAD) {
String texture1 = getBase64Skin((SkullMeta) event.getNewArmorPiece().getItemMeta());
String texture2 = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTgxODUyOTQzZTM2YzhhM2YxZTNkMGU0OTEyNTQ5Y2JjMjA1ZDk0NzM5NGFkYmU2NWY0ZDgxZDYxMWJlMmM4NyJ9fX0=";
if (texture1 == texture2) {
event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 999999, 2, false, false));
}
}
what do I fill as plugin in the scheduler? my main? or my Knockback class?
even when the scheduler is in the knockback class right? just making sure
Yes
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
That fixed it. Thank you.
so ```cpp
new MCBrawl
I read the documentation, just make a method and a variable and make the method set the variable plugin?
oh a constructor?
I did it like that in main: getServer().getPluginManager().registerEvents(new Knockback(), this);
wouldn't that point to the main class?
oh I see
this points to the class that you're using it in
knockbock
this doesn't pass constructor, it passes the class
knock knock who's there
you need to put the class that extends JavaPlugin into plugin place
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
pass 'this' in as constructor param
no need to use this.plugin, you can just do plugin
Confusion 100
not for me
step by step please, first I make a private plugin variable right?
hey, please show us the code you're making
in Knockback class
my brain went brr when i wrote if (this.datasource != null && this.datsource.isClosed())
if I access the main class 50 times I'd write out "this." 50 times unnecessarily
and everyone, he can't pass in this, in class that doesn't extend JavaPlugin class for parameter that asks for JavaPlugin
what's the issue?
I didn't put them, they caused errors and didn't understand what you guys were saying
i mean
I can't use the scheduler, I have 2 errors there
private McBrawl plugin;
public Knockback(McBrawl plugin) {
this.plugin = plugin;
}```
okay, I do this by having the JavaPlugin instance in main class which is static and then static function to get that instance
like this:
private static JavaPlugin instance;
onEnable() {
instance = this;
}
public static JavaPlugin get() {
return instance;
}