Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Type can not be resolved!(help me!)
Type can not be resolved! [message #1419499] Mon, 08 September 2014 18:05 Go to next message
Matty widdop is currently offline Matty widdopFriend
Messages: 8
Registered: September 2014
Junior Member
Hello, so I've recently got into java and I'm pretty good with it so I decided to create a plugin for my server that links in with WG and factions, it all works fine but when I try to define the package right at the top of the page I get this error:

The type com.google.gson.Gson cannot be resolved. It is indirectly referenced from required .class files

I have tried to remove the JRE library and re-adding it, but no luck. the code for the class file is as follows:

package me.HexCraft;

import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Result;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerShearEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.PluginManager;

import com.massivecraft.factions.Factions;
import com.massivecraft.factions.cmd.CmdClaim;

public class HexListener
implements Listener
{
private HexRestrict plugin;

public HexListener(HexRestrict plugin)
{
this.plugin = plugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}

@EventHandler(ignoreCancelled=false)
public void onPlayerShear(PlayerShearEntityEvent event)
{
if (event.getEntity().toString() == "CraftSheep") {
event.setCancelled(StopShear(event.getPlayer(), event.getEntity(), event.getEntity().getLocation()));
}
}

@EventHandler(ignoreCancelled=false)
public void onPlayerShear(PlayerInteractEntityEvent event)
{
if (event.getRightClicked().toString() == "CraftSheep") {
event.setCancelled(StopShear(event.getPlayer(), event.getRightClicked(), event.getRightClicked().getLocation()));
} else {
event.setCancelled(StopShear(event.getPlayer(), event.getRightClicked(), event.getRightClicked().getLocation()));
}
}

private boolean StopShear(Player p, Entity e, Location l)
{
if (this.plugin.ItemUseRestrictedInsideOtherClaims.contains(new ItemInfo(p.getItemInHand().getTypeId(), null)))
{
Factions gp = Factions.instance;

CmdClaim claim = gp.dataStore.getClaimAt(l, true, null);
if ((!p.isOp()) &&
(claim != null))
{
String errorMessage = claim.allowBuild(p);
if (errorMessage != null) {
return true;
}
}
}
return false;
}

@EventHandler(ignoreCancelled=false)
public void onPlayerInteract(PlayerInteractEvent event)
{
if ((event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) && (event.hasItem())) {
if (this.plugin.ItemUseRestrictedInsideOtherClaims.Contains(new ItemInfo(event.getItem().getTypeId(), null)))
{
Player player = event.getPlayer();



Location loc = event.getClickedBlock().getLocation();



Factions gp = Factions.instance;

Claim claim = gp.dataStore.getClaimAt(loc, true, null);
if (!player.isOp()) {
if (claim != null)
{
String errorMessage = claim.allowBuild(player);
if (errorMessage != null)
{
event.setUseInteractedBlock(Event.Result.DENY);
event.setUseItemInHand(Event.Result.DENY);
}
}
else
{
Location placedLoc = event.getClickedBlock().getRelative(event.getBlockFace(), 1).getLocation();
claim = gp.dataStore.getClaimAt(placedLoc, true, null);
if (claim != null)
{
String errorMessage = claim.allowBuild(player);
if (errorMessage != null)
{
event.setUseInteractedBlock(Event.Result.DENY);
event.setUseItemInHand(Event.Result.DENY);

return;
}
}
}
}
}
}
if (event.hasItem()) {
if (this.plugin.ItemUseRestrictedInsideOtherClaims.Contains(new ItemInfo(event.getItem().getTypeId(), null)))
{
Player player = event.getPlayer();




Location loc = event.getPlayer().getLocation();




Factions gp = Factions.instance;

Claim claim = gp.dataStore.getClaimAt(loc, true, null);
if ((!player.isOp()) &&
(claim != null))
{
String errorMessage = claim.allowBuild(player);
if (errorMessage != null)
{
event.setUseInteractedBlock(Event.Result.DENY);
event.setUseItemInHand(Event.Result.DENY);

return;
}
}
}
}
}

@EventHandler(ignoreCancelled=true)
public void onPlace(BlockPlaceEvent placeEvent)
{
MaterialInfo blockInfo = this.plugin.BlocksRestrictedOutsideClaims.ContainsReturnName(new MaterialInfo(placeEvent.getBlock().getTypeId(), placeEvent.getBlock().getData(), null));
if (blockInfo != null)
{
Player player = placeEvent.getPlayer();
Block block = placeEvent.getBlock();


Factions gp = Factions.instance;
Claim claim = gp.dataStore.getClaimAt(block.getLocation(), true, null);
if (claim == null) {
if (!player.isOp())
{
placeEvent.getBlockPlaced().setType(Material.AIR);
placeEvent.setBuild(false);
placeEvent.setCancelled(true);
player.sendMessage(ChatColor.RED + "Unable to place " + blockInfo.description + " outside your claimed regions.");
return;
}
}
}
}
}
Re: Type can not be resolved! [message #1419504 is a reply to message #1419499] Mon, 08 September 2014 18:16 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 3518
Registered: July 2009
Senior Member

The message, "The type com.google.gson.Gson cannot be resolved. It is indirectly referenced from required .class files," means you need to add a library that contains the type, com.google.gson.Gson, to the project's Java Build Path. The message is literally telling you that some other class on the build path already refers to it.

Nitin Dahyabhai
Eclipse Web Tools Platform

[Updated on: Mon, 08 September 2014 18:18]

Report message to a moderator

Re: Type can not be resolved! [message #1419528 is a reply to message #1419504] Mon, 08 September 2014 19:01 Go to previous messageGo to next message
Matty widdop is currently offline Matty widdopFriend
Messages: 8
Registered: September 2014
Junior Member
ok, well which one is that because I didn't refer to it at all.
Re: Type can not be resolved! [message #1419555 is a reply to message #1419528] Mon, 08 September 2014 19:56 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30559
Registered: July 2009
Senior Member
You can't find it with Ctrl-Shift-T?

On 08/09/2014 9:01 PM, Matty widdop wrote:
> ok, well which one is that because I didn't refer to it at all.
Re: Type can not be resolved! [message #1419565 is a reply to message #1419555] Mon, 08 September 2014 20:17 Go to previous messageGo to next message
Matty widdop is currently offline Matty widdopFriend
Messages: 8
Registered: September 2014
Junior Member
I've never used that xD
Re: Type can not be resolved! [message #1420137 is a reply to message #1419565] Tue, 09 September 2014 14:55 Go to previous messageGo to next message
Matty widdop is currently offline Matty widdopFriend
Messages: 8
Registered: September 2014
Junior Member
could you just tell me which it is? xD
Re: Type can not be resolved! [message #1420159 is a reply to message #1420137] Tue, 09 September 2014 15:42 Go to previous messageGo to next message
Matty widdop is currently offline Matty widdopFriend
Messages: 8
Registered: September 2014
Junior Member
ok, fixed it and thanks for the help. but now I am getting this error as soon as I fixed the previous: "The method allowBuild(Player) is undefined for the type Object"
the code it below:
package me.HexCraft;

import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Result;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerShearEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.PluginManager;

import com.massivecraft.factions.Factions;
import com.massivecraft.factions.cmd.CmdClaim;
import com.massivecraft.factions.cmd.CmdUnclaim;

public class HexListener
implements Listener
{
private HexRestrict plugin;

public HexListener(HexRestrict plugin)
{
this.plugin = plugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}

@EventHandler(ignoreCancelled=false)
public void onPlayerShear(PlayerShearEntityEvent event)
{
if (event.getEntity().toString() == "CraftSheep") {
event.setCancelled(StopShear(event.getPlayer(), event.getEntity(), event.getEntity().getLocation()));
}
}

@EventHandler(ignoreCancelled=false)
public void onPlayerShear(PlayerInteractEntityEvent event)
{
if (event.getRightClicked().toString() == "CraftSheep") {
event.setCancelled(StopShear(event.getPlayer(), event.getRightClicked(), event.getRightClicked().getLocation()));
} else {
event.setCancelled(StopShear(event.getPlayer(), event.getRightClicked(), event.getRightClicked().getLocation()));
}
}

private boolean StopShear(Player p, Entity e, Location l)
{
if (this.plugin.ItemUseRestrictedInsideOtherClaims.contains(new ItemInfo(p.getItemInHand().getTypeId(), null)))
{
Factions gp = Factions.i;

CmdClaim claim = gp.DataStore.getClaimAt(l, true, null);
if ((!p.isOp()) &&
(claim != null))
{
String errorMessage = ((Object) claim).allowBuild(p);
if (errorMessage != null) {
return true;
}
}
}
return false;
}

@EventHandler(ignoreCancelled=false)
public void onPlayerInteract(PlayerInteractEvent event)
{
if ((event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) && (event.hasItem())) {
if (this.plugin.ItemUseRestrictedInsideOtherClaims.contains(new ItemInfo(event.getItem().getTypeId(), null)))
{
Player player = event.getPlayer();



Location loc = event.getClickedBlock().getLocation();



Factions gp = Factions.i;

CmdClaim claim = gp.dataStore.getClaimAt(loc, true, null);
if (!player.isOp()) {
if (claim != null)
{
String errorMessage = ((Object) claim).allowBuild(player);
if (errorMessage != null)
{
event.setUseInteractedBlock(event.Result.DENY);
event.setUseItemInHand(event.Result.DENY);
}
}
else
{
Location placedLoc = event.getClickedBlock().getRelative(event.getBlockFace(), 1).getLocation();
claim = gp.dataStore.getClaimAt(placedLoc, true, null);
if (claim != null)
{
String errorMessage = claim.allowBuild(player);
if (errorMessage != null)
{
event.setUseInteractedBlock(event.Result.DENY);
event.setUseItemInHand(event.Result.DENY);

return;
}
}
}
}
}
}
if (event.hasItem()) {
if (this.plugin.ItemUseRestrictedInsideOtherClaims.contains(new ItemInfo(event.getItem().getTypeId(), null)))
{
Player player = event.getPlayer();




Location loc = event.getPlayer().getLocation();




Factions gp = Factions.i;

CmdUnclaim claim = gp.dataStore.getClaimAt(loc, true, null);
if ((!player.isOp()) &&
(claim != null))
{
String errorMessage = ((Object) claim).allowBuild(player);
if (errorMessage != null)
{
event.setUseInteractedBlock(event.Result.DENY);
event.setUseItemInHand(event.Result.DENY);

return;
}
}
}
}
}

@EventHandler(ignoreCancelled=true)
public void onPlace(BlockPlaceEvent placeEvent)
{
MaterialInfo blockInfo = this.plugin.BlocksRestrictedOutsideClaims.ContainsReturnName(new MaterialInfo(placeEvent.getBlock().getTypeId(), placeEvent.getBlock().getData(), null));
if (blockInfo != null)
{
Player player = placeEvent.getPlayer();
Block block = placeEvent.getBlock();


Factions gp = Factions.i;
CmdClaim claim = gp.dataStore.getClaimAt(block.getLocation(), true, null);
if (claim == null) {
if (!player.isOp())
{
placeEvent.getBlockPlaced().setType(Material.AIR);
placeEvent.setBuild(false);
placeEvent.setCancelled(true);
player.sendMessage(ChatColor.RED + "Unable to place " + blockInfo.description + " outside your claimed regions.");
return;
}
}
}
}
}
Re: Type can not be resolved! [message #1420610 is a reply to message #1420159] Wed, 10 September 2014 08:09 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 295
Registered: March 2012
Senior Member
On 09/09/2014 17:42, Matty widdop wrote:
> ok, fixed it and thanks for the help. but now I am getting this error as
> soon as I fixed the previous: "The method allowBuild(Player) is
> undefined for the type Object"
> the code it below:

So? Doesn't JDT exactly tell you where the error is? I bet it does. Now
you need to understand what's going on. Here's a nice read for you:

http://docs.oracle.com/javase/tutorial/java/javaOO/usingobject.html
Re: Type can not be resolved! [message #1420968 is a reply to message #1420610] Wed, 10 September 2014 19:08 Go to previous messageGo to next message
Matty widdop is currently offline Matty widdopFriend
Messages: 8
Registered: September 2014
Junior Member
is there a video version by any chance??? xD
Re: Type can not be resolved! [message #1420983 is a reply to message #1420968] Wed, 10 September 2014 19:39 Go to previous message
Felix Dorner is currently offline Felix DornerFriend
Messages: 295
Registered: March 2012
Senior Member
On 10/09/2014 21:08, Matty widdop wrote:
> is there a video version by any chance??? xD

I think these might be good:

http://eclipsetutorial.sourceforge.net/totalbeginnerlessons.html

Haven't seen this series, but another one by the same person, and really
liked the style.
Previous Topic:how to stop the blinking cursor in eclipse 4.4.0
Next Topic:Font size
Goto Forum:
  


Current Time: Wed Oct 23 17:13:59 GMT 2019

Powered by FUDForum. Page generated in 0.02692 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top