Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9154075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:22:23+00:00 2026-06-17T12:22:23+00:00

Ok, so I’ve been using Eclipse to work on making a Bukkit plugin for

  • 0

Ok, so I’ve been using Eclipse to work on making a Bukkit plugin for Minecraft. For some reason, I have been getting a lot of seemingly unreasonable NullPointerExceptions. I found that NullPointerExceptions occur when you attempt to use a the values and functions of the type of a varriable whose value is null. I could not find it in my code, so I wanted to see if someone else could find it.

Error:

20:16:58 [SEVERE] java.lang.NullPointerException
20:16:58 [SEVERE]       at com.tommy3244.plugins.MakeYourOwnBlocks.MakeYourOwnBl
ocks.onDisable(MakeYourOwnBlocks.java:73)
20:16:58 [SEVERE]       at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlug
in.java:219)
20:16:58 [SEVERE]       at org.bukkit.plugin.java.JavaPluginLoader.disablePlugin
(JavaPluginLoader.java:481)
20:16:58 [SEVERE]       at org.bukkit.plugin.SimplePluginManager.disablePlugin(S
implePluginManager.java:400)
20:16:58 [SEVERE]       at org.bukkit.plugin.SimplePluginManager.disablePlugins(
SimplePluginManager.java:393)
20:16:58 [SEVERE]       at org.bukkit.plugin.SimplePluginManager.clearPlugins(Si
mplePluginManager.java:434)
20:16:58 [SEVERE]       at org.bukkit.craftbukkit.v1_4_6.CraftServer.reload(Craf
tServer.java:563)
20:16:58 [SEVERE]       at org.bukkit.Bukkit.reload(Bukkit.java:184)
20:16:58 [SEVERE]       at org.bukkit.command.defaults.ReloadCommand.execute(Rel
oadCommand.java:23)
20:16:58 [SEVERE]       at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCo
mmandMap.java:186)
20:16:58 [SEVERE]       at org.bukkit.craftbukkit.v1_4_6.CraftServer.dispatchCom
mand(CraftServer.java:514)
20:16:58 [SEVERE]       at org.bukkit.craftbukkit.v1_4_6.CraftServer.dispatchSer
verCommand(CraftServer.java:506)
20:16:58 [SEVERE]       at net.minecraft.server.v1_4_6.DedicatedServer.al(Dedica
tedServer.java:260)
20:16:58 [SEVERE]       at net.minecraft.server.v1_4_6.DedicatedServer.r(Dedicat
edServer.java:225)
20:16:58 [SEVERE]       at net.minecraft.server.v1_4_6.MinecraftServer.q(Minecra
ftServer.java:494)
20:16:58 [SEVERE]       at net.minecraft.server.v1_4_6.MinecraftServer.run(Minec
raftServer.java:427)
20:16:58 [SEVERE]       at net.minecraft.server.v1_4_6.ThreadServerApplication.r
un(SourceFile:849)

And here is my actual plugin code:

package com.tommy3244.plugins.MakeYourOwnBlocks;

import java.io.File;
import java.util.*;

import org.bukkit.block.*;
import org.bukkit.command.*;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.*;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;

public class MakeYourOwnBlocks extends JavaPlugin implements Listener
{
public Map<NewItem, List<ItemStack>> items;
public File configfile;
@SuppressWarnings("unchecked")
public void onEnable()
{
try
{
Map<List<Map<String, Object>>, NewItem> smap;
smap = SaveLoadAPI.load(this.getDataFolder().getPath()+"\\Items.data");
for(List<Map<String, Object>> maps : smap.keySet())
{
NewItem item = smap.get(maps);
List<ItemStack> stacks = new ArrayList<ItemStack>();
for(Map<String, Object> map : maps)
{
stacks.add(ItemStack.deserialize(map));
}
items.put(item, stacks);
}
}
catch(Exception e)
{
items = new HashMap<NewItem, List<ItemStack>>();
}
try
{
this.getDataFolder().mkdirs();
}
catch(Exception e)
{

}
configfile = new File(getDataFolder(), "config.yml");
if(!configfile.exists())
{
saveResource("config.yml", false);
}
try
{
getConfig().load(configfile);
}
catch(Exception error)
{
getLogger().severe("Could not load config!");
error.printStackTrace();
}
getServer().getPluginManager().registerEvents(this, this);
getLogger().info("MakeYourOwnBlocks successfully enabled!");
}
public void onDisable()
{
try
{
Map<List<Map<String, Object>>, NewItem> smap = new HashMap<List<Map<String, Object>>, NewItem>();
for(NewItem item : items.keySet())
{
List<ItemStack> stacks = items.get(item);
List<Map<String, Object>> stacks2 = new ArrayList<Map<String, Object>>();
for(ItemStack stack : stacks)
{
stacks2.add(stack.serialize());
}
smap.put(stacks2, item);
}
SaveLoadAPI.save(smap, this.getDataFolder().getPath()+"\\Items.data");
}
catch (Exception e)
{
getLogger().severe("Was unable to save the items file to the default path of: "+this.getDataFolder().getPath()+"\\Items.data");
e.printStackTrace();
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onItemStackRightClick(PlayerInteractEvent e)
{
Player player = e.getPlayer();
//getLogger().info("Player "+player.getName()+" has right clicked.");
for(NewItem item : items.keySet())
{
for(ItemStack curstack : items.get(item))
{
ItemMeta lore = ((ItemStack)curstack).getItemMeta();
List<String> lore2 = player.getItemInHand().getItemMeta().getLore();
if(lore == null || lore2 == null)
{
getLogger().info("Pointer null!");
if(lore == null)
{
getLogger().info("Pointer 1 null");
}
else
{
getLogger().info("Pointer 2 null");
}
}
if(lore2.equals(lore))
{
getLogger().info(player.getDisplayName()+" right clicked with the same item!");
boolean right = e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK;
boolean block = e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_BLOCK;
boolean worked;
if(right)
{
worked = item.onRightClick(player, right, block);
}
else
{
worked = item.onLeftClick(player, right, block);
}
if(!worked)
{
player.sendMessage("Script fault! Error raised.");
}
}
}
}
}
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
{
if(sender instanceof Player)
{

}
else
{
sender.sendMessage("You must be a player to perform this command!");
return false;
}
if(cmd.getName().equalsIgnoreCase("makeitem"))
{
if(args.length < 4)
{
return false;
}
String name = args[0];
String type = args[1];
String data = args[2];
String damage = args[3];
try
{
int dmg = Integer.parseInt(damage);
byte dta = (byte)Integer.parseInt(data);
int id = Integer.parseInt(type);
if(getConfig().contains("items."+name))
{
ConfigurationSection section = getConfig();
List<List<String>> lines = new ArrayList<List<String>>();
lines.add(null);
lines.add(null);
if(getConfig().contains("items."+name+".onrightclick"))
{
List<String> cur = getConfig().getStringList("items."+name+".onrightclick");
lines.set(0, cur);
}
else
{
lines.set(0, null);
}
if(getConfig().contains("items."+name+".onleftclick"))
{
List<String> cur = getConfig().getStringList("items."+name+".onleftclick");
lines.set(1, cur);
}
else
{
lines.set(1, null);
}
List<ItemStack> stacks = new ArrayList<ItemStack>();
ItemStack stack = new ItemStack(id, 1, dta);
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(name);
List<String> lore;
if(getConfig().contains("items."+name+".description"))
{
lore = getConfig().getStringList("items."+name+".description");
}
else
{
lore = new ArrayList<String>();
}
lore.add(name);
NewItem item = new NewItem(lore, name, id, dta, lines, dmg, false, section);
meta.setLore(lore);
stack.setItemMeta(meta);
getLogger().info(stack.toString());
stacks.add(stack);
if(items == null)
{
getLogger().info("unused");
}
items.put(item, stacks);
Player player = (Player)sender;
player.getLocation().getWorld().dropItem(player.getLocation(), stack);
player.sendMessage("Here you go!");
}
else
{
sender.sendMessage("No configuration section at \""+"items."+name+"\"");
return true;
}
}
catch(Exception error)
{
//sender.sendMessage("Error: "+error.getLocalizedMessage());
//System.out.println(error);
//throw error;
//makeitem test 272 0 0
error.printStackTrace();
return true;
}
sender.sendMessage("Error: No command specified");
}
return true;
}
}

UPDATE:

nakib answered my question, and the error is fixed! Thanks a lot!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:22:24+00:00Added an answer on June 17, 2026 at 12:22 pm

    On line 73, you have

    for(NewItem item : items.keySet())
    

    The property items is null when onDisable() is called.

    To solve this, you should initialize the items on declaration

    public Map<NewItem, List<ItemStack>> items = new HashMap<NewItem, List<ItemStack>>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have been unable to fix a problem with Java Unicode and encoding. The
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.