Here is the error
Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: Children: duplicate children added: parent = Group#5ea0c6fc
at javafx.graphics/javafx.scene.Parent$3.onProposedChange(Unknown Source)
at javafx.base/com.sun.javafx.collections.VetoableListDecorator.add(Unknown Source)
at project1.Crab.setCrab(Crab.java:45)
at project1.SeaAnimals.addCrab(SeaAnimals.java:65)
at project1.ProjectOne.mouseClick(ProjectOne.java:133)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
at javafx.base/javafx.event.Event.fireEvent(Unknown Source)
at javafx.graphics/javafx.scene.Scene$ClickGenerator.postProcess(Unknown Source)
at javafx.graphics/javafx.scene.Scene$ClickGenerator.access$8300(Unknown Source)
at javafx.graphics/javafx.scene.Scene$MouseHandler.process(Unknown Source)
at javafx.graphics/javafx.scene.Scene$MouseHandler.access$1300(Unknown Source)
at javafx.graphics/javafx.scene.Scene.processMouseEvent(Unknown Source)
at javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(Unknown Source)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(Unknown Source)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
at javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
at javafx.graphics/com.sun.glass.ui.View.notifyMouse(Unknown Source)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Here is the lines of code that have the problem
public class Crab {
private final Image c = new Image("File:crab.gif");
private ArrayList<ImageView> crabList = new ArrayList<ImageView>();
private int _counter;
private Group _crab = new Group();
/** Constructor <br>
* Initializes counter to -1
*/
public Crab() {
_counter = -1;
}
/** Setter <br>
* Adds a crab to the array list
*/
public void addCrab() {
if(_counter < 5) {
crabList.add(new ImageView(c));
_counter++;
}
}
/** Setter <br>
* Deletes a crab from the array list
*/
public void deleteCrab() {
if(_counter > 0) {
crabList.remove(_counter);
_counter--;
}
}
/** Getter <br>
*
* #return returns crab group
*/
public Group setCrab() {
if(_counter >= 0) { //adds the first crab
crabList.get(0).setTranslateX(80);
crabList.get(0).setTranslateY(500);
crabList.get(0).setFitHeight(100);
crabList.get(0).setFitWidth(100);
_crab.getChildren().add(crabList.get(0));
if(_counter >= 1) { //adds the second crab
crabList.get(1).setTranslateX(230);
crabList.get(1).setTranslateY(500);
crabList.get(1).setFitHeight(100);
crabList.get(1).setFitWidth(100);
_crab.getChildren().add(crabList.get(1));
if (_counter >= 2) { // adds the third crab
crabList.get(2).setTranslateX(380);
crabList.get(2).setTranslateY(500);
crabList.get(2).setFitHeight(100);
crabList.get(2).setFitWidth(100);
_crab.getChildren().add(crabList.get(2));
if (_counter >= 3) { //adds the fourth crab
crabList.get(3).setTranslateX(530);
crabList.get(3).setTranslateY(500);
crabList.get(3).setFitHeight(100);
crabList.get(3).setFitWidth(100);
_crab.getChildren().add(crabList.get(3));
if (_counter >= 4) { //adds the fifth crab
crabList.get(4).setTranslateX(680);
crabList.get(4).setTranslateY(500);
crabList.get(4).setFitHeight(100);
crabList.get(4).setFitWidth(100);
_crab.getChildren().add(crabList.get(4));
if (_counter == 5) { //adds the sixth crab
crabList.get(5).setTranslateX(830);
crabList.get(5).setTranslateY(500);
crabList.get(5).setFitHeight(100);
crabList.get(5).setFitWidth(100);
_crab.getChildren().add(crabList.get(5));
}
}
}
}
}
}
return _crab;
}
}
public Group addCrab() {
_crab.addCrab();
_gCrab = _crab.setCrab();
return _gCrab;
}
public Group deleteCrab() {
_crab.deleteCrab();
_gCrab = _crab.setCrab();
return _gCrab;
}
}
public void mouseClick(MouseEvent mouse) {
if(mouse.getClickCount() == 1) {
root.getChildren().remove(gCrab);
gCrab.getChildren().clear();
gCrab.getChildren().add(animals.addCrab());
root.getChildren().add(gCrab);
}
else if(mouse.getClickCount() == 2) {
root.getChildren().remove(gCrab);
gCrab.getChildren().clear();
gCrab.getChildren().add(animals.deleteCrab());
root.getChildren().add(gCrab);
}
}
I do not know how to fix the problem, nor do I know what the problem is. Any help is appreciated.
Your setCrab method attempts to add all the crab images to the Group without removing any of the children. This way if there were crabs in the Group before you're trying to add them again which results in the exception since JavaFX does not allow this.
You also need to make sure never to add the same node twice to the same parent.
Furthermore hiding the setCrab from the user of the Crab class would reduce the complexity of using the class. Why make the user call 2 methods when 1 call would do the same job. You could even write a CrabGroup class that is a node itself and aviod the removing and readding of the Group to it's parent.
E.g.
public class CrabGroup extends HBox {
private static final Image c = new Image("File:crab.gif");
public CrabGroup() {
setSpacing(50);
}
/**
* Adds a crab
*/
public void addCrab() {
if(getChildren().size() < 6) {
ImageView image = new ImageView(c);
image.setFitWidth(100);
image.setFitHeight(100);
crabList.add(image);
}
}
/**
* Deletes a crab
*/
public void deleteCrab() {
if(!getChildren().isEmpty()) {
getChildren().remove(getChildren().size() - 1);
}
}
}
CrabGroup crabGroup = new CrabGroup();
crabGroup.setTranslateX(80);
crabGroup.setTranslateY(500);
crabGroup.addCrab();
...
crabGroup.deleteCrab();
Related
I get this message when trying to change the world time asynchronously
java.lang.IllegalStateException: TimeSkipEvent may only be triggered synchronously.
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:595) ~[patched_1.16.3.jar:git-Paper-253]
at org.bukkit.craftbukkit.v1_16_R2.CraftWorld.setFullTime(CraftWorld.java:948) ~[patched_1.16.3.jar:git-Paper-253]
at org.bukkit.craftbukkit.v1_16_R2.CraftWorld.setTime(CraftWorld.java:936) ~[patched_1.16.3.jar:git-Paper-253]
at ru.lmpx.lmpxserverkit.handlers.NightSkipHandler.lambda$onPlayerSleep$0(NightSkipHandler.java:29) ~[?:?]
at org.bukkit.craftbukkit.v1_16_R2.scheduler.CraftTask.run(CraftTask.java:99) ~[patched_1.16.3.jar:git-Paper-253]
at org.bukkit.craftbukkit.v1_16_R2.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:54) ~[patched_1.16.3.jar:git-Paper-253]
at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[patched_1.16.3.jar:git-Paper-253]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_271]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_271]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_271]
#EventHandler
public void onPlayerSleep(PlayerBedEnterEvent e) {
if (!(plugin.getConfig().getBoolean("skipNight.enable"))) return;
if (e.getBedEnterResult().equals(PlayerBedEnterEvent.BedEnterResult.OK)) {
if (plugin.getConfig().getBoolean("skipNight.instantSkip")) {
Bukkit.getWorld("world").setTime(0);
Bukkit.getWorld("world").setStorm(false);
} else {
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
while (Bukkit.getWorld("world").getTime() < 24000) {
Bukkit.getWorld("world").setTime(Bukkit.getWorld("world").getTime() + 10);
try {
Thread.sleep(10);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
});
}
}
}
What needs to be changed so that the asynchronous thread changes time without an IllegalStateException error?
The exception is explicit, you cannot call a synchronous method asynchronously. This is to ensure that thread safety is upheld. To fix your code, you would need to change out runTaskAsynchronously() with runTask(), however, with your current code, this would freeze the main thread.
A better solution is to use the runTaskTimer() method. You can create a new class that extends BukkitRunnable. The below code is untested but it should be close to what you need:
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.scheduler.BukkitRunnable;
public class BedTask extends BukkitRunnable {
#Override
public void run() {
World world = Bukkit.getWorld("world");
if(world.getTime() >= 24000){
this.cancel();
return;
}
world.setTime(world.getTime() + 10);
}
}
And you could then execute it like:
int sleepWaitPeriod = 10;
new BedTask().runTaskTimer(plugin, 0L, sleepWaitPeriod * 20);
I have got a JavaFX 8 VBox,and want to sort node in the VBox,But I have a Exception"Children: duplicate children added".
private void addTitledPane(ObservableList<TomatoTask> addList) {
if (!addList.isEmpty()) {
TitledPane titledPane = new TitledPane(addList.get(0).getDate());
titledPane.setItems(addList);
stackedTitledPanes.getChildren().add(titledPane);
stackedTitledPanes.getChildren().sort(comparatorTitledPane);
}
}
I found a quick fix,but I think there might be a better solution.
private void addTitledPane(ObservableList<TomatoTask> addList) {
if (!addList.isEmpty()) {
TitledPane titledPane = new TitledPane(addList.get(0).getDate());
titledPane.setItems(addList);
stackedTitledPanes.getChildren().add(titledPane);
List list = new ArrayList(stackedTitledPanes.getChildren());
list.sort(comparatorTitledPane);
Collections.reverse(list);
stackedTitledPanes.getChildren().clear();
stackedTitledPanes.getChildren().addAll(list);
}
}
This is the full stack trace
Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: Children: duplicate children added: parent = VBox#2cdae672
at javafx.scene.Parent$2.onProposedChange(Parent.java:454)
at com.sun.javafx.collections.VetoableListDecorator$VetoableListIteratorDecorator.set(VetoableListDecorator.java:768)
at java.util.List.sort(List.java:482)
at app.control.mytomato.StackedPanes.addTitledPane(StackedPanes.java:93)
at app.control.mytomato.StackedPanes.access$000(StackedPanes.java:16)
at app.control.mytomato.StackedPanes$3.onChanged(StackedPanes.java:62)
at com.sun.javafx.collections.MapListenerHelper$SingleChange.fireValueChangedEvent(MapListenerHelper.java:163)
at com.sun.javafx.collections.MapListenerHelper.fireValueChangedEvent(MapListenerHelper.java:72)
at com.sun.javafx.collections.ObservableMapWrapper.callObservers(ObservableMapWrapper.java:115)
at com.sun.javafx.collections.ObservableMapWrapper.put(ObservableMapWrapper.java:173)
at app.control.mytomato.StackedPanes.addItem(StackedPanes.java:127)
at app.control.mytomato.StackedPanes.addItems(StackedPanes.java:119)
at app.view.EditDialogControl.lambda$handleOkButton$0(EditDialogControl.java:88)
at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$3(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
For me it works like this:
private static class CoparaterAscending<T> implements Comparator<T> {
#Override
public int compare(T o1, T o2) {
int numberNode1 = Integer.parseInt(((CheckBox)o1).getText());
int numberNode2 = Integer.parseInt(((CheckBox)o2).getText());
System.out.println(numberNode1 + " " + numberNode2);
if ((numberNode1 > numberNode2)) {
return 1;
} else if ((numberNode1 < numberNode2)) {
return -1;
}
return 0;
}
}
comp = new CoparaterAscending<Node>();
FXCollections.sort(selectedItemsView.getChildren(), comp);
Where the selectedItemsView is a VBox populated with CheckBoxes that are labled with unique numbers.
When trying to set the player suffix/prefix from the GUI I am getting a null pointer exception for setting the said prefix/suffix. (I get the 'You applied the x tag' message, and it does close the inventory.)
Main class (Where the chat is defined and setup, not the entire class)
public static Chat chat = null;
#SuppressWarnings("unused")
private TagsCommands tCmd;
public void onEnable() {
if (Bukkit.getPluginManager().getPlugin("Vault") != null) {
setupChat();
createFolders();
Message.console("&fPlugin successfully loaded");
Bukkit.getPluginManager().registerEvents(new TagsGUI(), this);
tCmd = new TagsCommands(this);
} else {
Message.console("&dCouldn't enable plugin as &aVault&c was not found");
Bukkit.getPluginManager().disablePlugin(this);
return;
}
}
private boolean setupChat() {
RegisteredServiceProvider<Chat> chatProvider = getServer().getServicesManager()
.getRegistration(net.milkbowl.vault.chat.Chat.class);
if (chatProvider != null) {
chat = chatProvider.getProvider();
}
return (chat != null);
}
GUI class (Again, not the entire thing. The error lies in this class at line 55.)
#EventHandler
public void inventoryClick(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
ItemStack click = event.getCurrentItem();
if (opened.contains(player)) {
event.setCancelled(true);
File tags = new File("plugins/Tags/Pages", "One.yml");
FileConfiguration tagsC = YamlConfiguration.loadConfiguration(tags);
for (String title : tagsC.getConfigurationSection("Tags").getKeys(false)) {
String tag = tagsC.getString("Tags." + title + ".Display");
if (click.getItemMeta().getDisplayName().equals(Format.color(tag))) {
if (player.hasPermission(tagsC.getString("Tags." + title + ".Permission"))) {
if (tagsC.getString("Tags." + title + ".Type").equalsIgnoreCase("prefix")) {
player.closeInventory();
Message.player("&fYou applied the '" + tag + "&f' tag", player);
Main.chat.setPlayerPrefix(player, Format.color(tag));
break;
} else if (tagsC.getString("Tags." + title + ".Type").equalsIgnoreCase("suffix")) {
player.closeInventory();
Message.player("&fYou applied the '" + tag + "&f' tag", player);
Main.chat.setPlayerSuffix(player, Format.color(tag));
break;
}
} else {
Message.player("&fSorry, but you do not have permission to do this", player);
break;
}
}
}
return;
}
}
Line 55:
Main.chat.setPlayerSuffix(player, Format.color(tag));
Console error message:
[11:13:05 INFO]: BearToothh issued server command: /tags
[11:13:12 ERROR]: Could not pass event InventoryClickEvent to Tags v1.0
org.bukkit.event.EventException: null
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.12.2.jar:git-Spigot-2cf50f0-2b93d83]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.12.2.jar:git-Spigot-2cf50f0-2b93d83]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:500) [spigot-1.12.2.jar:git-Spigot-2cf50f0-2b93d83]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:485) [spigot-1.12.2.jar:git-Spigot-2cf50f0-2b93d83]
at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1889) [spigot-1.12.2.jar:git-Spigot-2cf50f0-2b93d83]
at net.minecraft.server.v1_12_R1.PacketPlayInWindowClick.a(SourceFile:33) [spigot-1.12.2.jar:git-Spigot-2cf50f0-2b93d83]
at net.minecraft.server.v1_12_R1.PacketPlayInWindowClick.a(SourceFile:10) [spigot-1.12.2.jar:git-Spigot-2cf50f0-2b93d83]
at net.minecraft.server.v1_12_R1.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.12.2.jar:git-Spigot-2cf50f0-2b93d83]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:?]
at java.util.concurrent.FutureTask.run(Unknown Source) [?:?]
at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [spigot-1.12.2.jar:git-Spigot-2cf50f0-2b93d83]
at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:748) [spigot-1.12.2.jar:git-Spigot-2cf50f0-2b93d83]
at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [spigot-1.12.2.jar:git-Spigot-2cf50f0-2b93d83]
at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [spigot-1.12.2.jar:git-Spigot-2cf50f0-2b93d83]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [spigot-1.12.2.jar:git-Spigot-2cf50f0-2b93d83]
at java.lang.Thread.run(Unknown Source) [?:?]
Caused by: java.lang.NullPointerException
at me.askingg.tags.TagsGUI.inventoryClick(TagsGUI.java:55) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:?]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:?]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot-1.12.2.jar:git-Spigot-2cf50f0-2b93d83]
... 15 more
public static Chat chat = null; is null so it returns a NullPointerException.
You cannot define a chat thats null and set prefixes and stuff on a chat that dont exist ^^
You have to define the Chat chat variable to an existing chat.
util.zip.ZipException: zip END header not found
exception when try to load javafx fxml view in java-9.
Details
My Application is a Javafx(uses fxml view) which is built and compiled using java-8(jdk-8 64-bit) and accessed as a WebStart with jre-9(64-bit).
Webpages(xhtml) are loaded and rendered in this javafx application.
Also note that
There are already two similar bugs reported (ie. JDK-8170276, JDK-8172872) and
these two bugs mentioned that the issue is not reproducible with latest java-9
but reproducible only with earlier java-9 ea build version.
But in my case, im using latest java-9(9.0.4 version) and
its always reproducible.
Problem
When i try to load fxml popup after login, get below exceptions.
java.util.zip.ZipException: zip END header not found
at java.base/java.util.zip.ZipFile$Source.zerror(Unknown Source)
at java.base/java.util.zip.ZipFile$Source.findEND(Unknown Source)
at java.base/java.util.zip.ZipFile$Source.initCEN(Unknown Source)
at java.base/java.util.zip.ZipFile$Source.<init>(Unknown Source)
at java.base/java.util.zip.ZipFile$Source.get(Unknown Source)
at java.base/java.util.zip.ZipFile.<init>(Unknown Source)
at java.base/java.util.zip.ZipFile.<init>(Unknown Source)
at java.base/java.util.jar.JarFile.<init>(Unknown Source)
at java.base/sun.net.www.protocol.jar.URLJarFile.<init>(Unknown Source)
at java.base/sun.net.www.protocol.jar.URLJarFile.<init>(Unknown Source)
at java.base/sun.net.www.protocol.jar.URLJarFile$1.run(Unknown Source)
at java.base/sun.net.www.protocol.jar.URLJarFile$1.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/sun.net.www.protocol.jar.URLJarFile.retrieve(Unknown Source)
at java.base/sun.net.www.protocol.jar.URLJarFile.getJarFile(Unknown Source)
at java.base/sun.net.www.protocol.jar.JarFileFactory.get(Unknown Source)
at java.base/sun.net.www.protocol.jar.JarURLConnection.connect(Unknown Source)
at jdk.deploy#9.0.1/com.sun.deploy.net.protocol.jar.DeployURLConnection.connect(Unknown Source)
at jdk.deploy#9.0.1/com.sun.deploy.net.protocol.jar.DeployURLConnection.getInputStream(Unknown Source)
at java.base/java.net.URL.openStream(Unknown Source)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml/javafx.fxml.FXMLLoader.load(Unknown Source)
at client.FxmlWrapper.initialize(FxmlWrapper.java:57)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$9(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Suppressed: java.nio.file.NoSuchFileException: C:\Users\user\AppData\Local\Temp\jar_cache8046747560626483610.tmp
at java.base/sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at java.base/sun.nio.fs.WindowsFileSystemProvider.implDelete(Unknown Source)
at java.base/sun.nio.fs.AbstractFileSystemProvider.delete(Unknown Source)
at java.base/java.nio.file.Files.delete(Unknown Source)
... 22 common frames omitted
Request if anyone could help on this issue,would be grateful.
Many Thanks.
Although this is not the full code, but this is the code for showing fxml popup which throws "java.util.zip.ZipException: zip END header not found" exceptions in java-9, but in java-8 works fine.
PopupAction.java
public class PopupAction
{
public PopupAction()
{
super();
}
public void showPopup()
{
CountDownLatch latch = new CountDownLatch(1);
Platform.runLater(
new PopupHandler(latch, "testMsg", "testTitle", "testButtonText"));
try
{
latch.await();
}
catch(InterruptedException localInterruptedException)
{
Thread.currentThread().interrupt();
}
}
}
PopupHandler.java
public class PopupHandler implements Runnable
{
private CountDownLatch latch;
private String message;
private String title;
private String buttonText;
public PopupHandler(CountDownLatch latch,
String message, String title, String buttonText)
{
this.latch = latch;
this.message = message;
this.title = title;
this.buttonText = buttonText;
}
#Override
public void run()
{
try
{
Stage stage = new Stage(StageStyle.UTILITY);
Parent root;
stage.initModality(Modality.APPLICATION_MODAL);
stage.setResizable(false);
FXMLViewLoader fXMLViewLoader = new FXMLViewLoader("/fxmlView/warningPopup.fxml");
root = fXMLViewLoader.getView();
Scene scene = new Scene(root, 400, 110);
scene.setFill(Color.TRANSPARENT);
stage.setScene(scene);
stage.setResizable(false);
stage.setTitle(this.title);
stage.initOwner(Application.getOwnerWindow());
this.localAtomicBoolean.set(true);
stage.setAlwaysOnTop(true);
stage.showAndWait();
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
this.latch.countDown();
}
}
}
FXMLViewLoader.java
public final class FXMLViewLoader
{
private FXMLLoader loader;
public FXMLViewLoader(String fxmlName)
{
super();
initialize(fxmlName);
}
private void initialize(String fxmlName)
{
final URL resource = getResourceURL(fxmlName);
this.loader = new FXMLLoader(resource);
try
{
this.loader.load();
}
catch(Exception e)
{
e.printStackTrace();
}
}
protected URL getResourceURL(String fxmlName)
{
return this.getClass().getResource(fxmlName);
}
public Parent getView()
{
return this.loader.getRoot();
}
}
I'm working in IntelliJ and I attempted to rename my Project! After doing so, and renaming everything, which I believe I did correctly, I'm unable to actually start my application.
Error:
org.bukkit.plugin.InvalidPluginException: java.lang.NullPointerException
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:133) ~[spigot-latest.jar:git-Spigot-4df3c0c-03f1e37]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:326) ~[spigot-latest.jar:git-Spigot-4df3c0c-03f1e37]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:248) [spigot-latest.jar:git-Spigot-4df3c0c-03f1e37]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.loadPlugins(CraftServer.java:302) [spigot-latest.jar:git-Spigot-4df3c0c-03f1e37]
at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:205) [spigot-latest.jar:git-Spigot-4df3c0c-03f1e37]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:544) [spigot-latest.jar:git-Spigot-4df3c0c-03f1e37]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
Caused by: java.lang.NullPointerException
at me.craftblock.MochaMessages.Config.<init>(Config.java:7) ~[?:?]
at me.craftblock.MochaMessages.MochaMessages.<init>(MochaMessages.java:18) ~[?:?]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_121]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_121]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_121]
at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_121]
at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_121]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[spigot-latest.jar:git-Spigot-4df3c0c-03f1e37]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[spigot-latest.jar:git-Spigot-4df3c0c-03f1e37]
... 6 more
The error points to my Config class, however I'm not sure why:
public class Config {
private MochaMessages instance = MochaMessages.getInstance();
private FileConfiguration config = instance.getConfig();
public Config() {
}
public String get(String node) {
System.out.println("Fetching: " + node);
return config.getString(node);
}
public void set(String node, String value) {
config.set(node, value);
}
public boolean getBoolean(String node) {
System.out.println("Fetching: " + node);
return config.getBoolean(node);
}
}
Which is being called via my MochaMessages class:
Here's the related method:
private static MochaMessages instance;
private Config config = new Config();
public void onEnable() {
instance = this;
createConfig();
te = getTokenEnchant();
if (!config.getBoolean("database.enabled")) {
disablePlugin("Enable MySQL!");
} else if (config.get("mocha.currency").equalsIgnoreCase("TokenEnchant")) {
if (te == null) {
disablePlugin("Unable to access TokenEnchant. Disabling Plugin!");
}
} else {
Bukkit.getServer().getPluginManager().registerEvents(new MochaListener(), this);
new MochaModel().createTable();
new CommandHandler();
}
}
I believe it's because instance is returning null even though it shouldn't be. This worked perfectly before the rename!
What's going on?