Thorinwasher
Thorinwasher
JCHJava Community | Help. Code. Learn.
Created by Thorinwasher on 11/13/2024 in #java-help
How to find generics when running a java process
So to clarify, every method in the mirror API will kind of look like this, all autogenerated with the same method names as the API it is based out of:
public String toString() {
return MirrorHandler.handle("toString", this);
}
public String toString() {
return MirrorHandler.handle("toString", this);
}
MirrorHandler does network processing
6 replies
JCHJava Community | Help. Code. Learn.
Created by Thorinwasher on 11/13/2024 in #java-help
How to find generics when running a java process
Other than that, I can just say that it's meant to be an integration testing library where you run the process on a docker container, and then have a mirror instance of the API for the process that you can use like the original library, where every method call just does some networking and such to communicate with the containerized process using reflection and that API. Most definitely a stupid idea, but at least interesting, which is why I'm pursuing it at the moment
6 replies
JCHJava Community | Help. Code. Learn.
Created by Thorinwasher on 9/21/2024 in #java-help
Asyncronous task queue
Yes, that's how I want it to be
53 replies
JCHJava Community | Help. Code. Learn.
Created by Thorinwasher on 9/21/2024 in #java-help
Asyncronous task queue
That might partly fix the issue, does still require the thread to be interupted though
53 replies
JCHJava Community | Help. Code. Learn.
Created by Thorinwasher on 9/21/2024 in #java-help
Asyncronous task queue
Oh... that's stupid on my end. I just thought it threw an exception :facepalm:
53 replies
JCHJava Community | Help. Code. Learn.
Created by Thorinwasher on 9/21/2024 in #java-help
Asyncronous task queue
I think I know what's happening now. I made a disable queue item and an enable queue item. These items sets the value of asyncQueueThreadIsEnabled to true or false. It's a way to avoid dealing with concurrency issues. Now to the actual issue this is how I'm cycling through the queue:
do {
try {
Runnable runnable = asyncQueue.take();
runnable.run();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (Exception e) {
Stargate.log(e);
}
} while (asyncQueueThreadIsEnabled || !asyncQueue.isEmpty());
do {
try {
Runnable runnable = asyncQueue.take();
runnable.run();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (Exception e) {
Stargate.log(e);
}
} while (asyncQueueThreadIsEnabled || !asyncQueue.isEmpty());
If per say the last item would be a enable queue item in the queue. Then the boolean switch asyncQueueThreadIsEnabled would be true, therefore blocking the thread in the next BlockingQueue#take() call.
53 replies
JCHJava Community | Help. Code. Learn.
Created by Thorinwasher on 9/21/2024 in #java-help
Asyncronous task queue
Okay. (need to eat some dinner first)
53 replies
JCHJava Community | Help. Code. Learn.
Created by Thorinwasher on 9/21/2024 in #java-help
Asyncronous task queue
(Like my main fallback has just been to let external classes handle this. But in this case, I think I need to get better at concurency)
53 replies
JCHJava Community | Help. Code. Learn.
Created by Thorinwasher on 9/21/2024 in #java-help
Asyncronous task queue
Alright, thanks
53 replies
JCHJava Community | Help. Code. Learn.
Created by Thorinwasher on 9/21/2024 in #java-help
Asyncronous task queue
(Your recomendation here will definitely help, thanks btw)
53 replies
JCHJava Community | Help. Code. Learn.
Created by Thorinwasher on 9/21/2024 in #java-help
Asyncronous task queue
Alright, btw do you have a good source I can read up on concurrency?
53 replies
JCHJava Community | Help. Code. Learn.
Created by Thorinwasher on 9/21/2024 in #java-help
Asyncronous task queue
Let's see, good idea to check that
53 replies
JCHJava Community | Help. Code. Learn.
Created by Thorinwasher on 9/21/2024 in #java-help
Asyncronous task queue
Yeah. Might be a good idea
53 replies
JCHJava Community | Help. Code. Learn.
Created by Thorinwasher on 9/21/2024 in #java-help
Asyncronous task queue
yep
53 replies
JCHJava Community | Help. Code. Learn.
Created by Thorinwasher on 9/21/2024 in #java-help
Asyncronous task queue
It's an task run in another thread, with some wrapper stuff. (mostly because I want to be sure the tasks get executed whenever the srerver shuts down)=
53 replies
JCHJava Community | Help. Code. Learn.
Created by Thorinwasher on 9/21/2024 in #java-help
Asyncronous task queue
@Test
void portalInvalidBlockPlaceTest() {
Location bottomLeft = new Location(world, 0, 7, 0);
Location insidePortal = new Location(world, 0, 9, 0);
Block signBlock = PortalBlockGenerator.generatePortal(bottomLeft);
Block irisBlock = new Location(world, 1, 9, 0).getBlock();


((Directional) signBlock.getBlockData()).setFacing(BlockFace.SOUTH);
blockEventListener
.onSignChange(new SignChangeEvent(signBlock, player, new String[]{"test", "", CUSTOM_NETNAME, ""}));

BlockPlaceEvent event = new BlockPlaceEvent(irisBlock, irisBlock.getState(), irisBlock,
new ItemStack(Material.ANDESITE), player, false);
blockEventListener.onBlockPlace(event);
blockEventListener.onBlockBreak(new BlockBreakEvent(insidePortal.getBlock(), player));
Assertions.assertTrue(event.isCancelled());
}
@Test
void portalInvalidBlockPlaceTest() {
Location bottomLeft = new Location(world, 0, 7, 0);
Location insidePortal = new Location(world, 0, 9, 0);
Block signBlock = PortalBlockGenerator.generatePortal(bottomLeft);
Block irisBlock = new Location(world, 1, 9, 0).getBlock();


((Directional) signBlock.getBlockData()).setFacing(BlockFace.SOUTH);
blockEventListener
.onSignChange(new SignChangeEvent(signBlock, player, new String[]{"test", "", CUSTOM_NETNAME, ""}));

BlockPlaceEvent event = new BlockPlaceEvent(irisBlock, irisBlock.getState(), irisBlock,
new ItemStack(Material.ANDESITE), player, false);
blockEventListener.onBlockPlace(event);
blockEventListener.onBlockBreak(new BlockBreakEvent(insidePortal.getBlock(), player));
Assertions.assertTrue(event.isCancelled());
}
53 replies
JCHJava Community | Help. Code. Learn.
Created by Thorinwasher on 9/21/2024 in #java-help
Asyncronous task queue
It's quite layered though
53 replies
JCHJava Community | Help. Code. Learn.
Created by Thorinwasher on 9/21/2024 in #java-help
Asyncronous task queue
Sure, this is one test that blocks everything, but that relates to the test that ran before it
53 replies
JCHJava Community | Help. Code. Learn.
Created by Thorinwasher on 9/21/2024 in #java-help
Asyncronous task queue
I think you need more info than that though
53 replies
JCHJava Community | Help. Code. Learn.
Created by Thorinwasher on 9/21/2024 in #java-help
Asyncronous task queue
53 replies