Me and a couple of friends are working on a Java Plugin for bukkit/craftbukkit private servers for minecraft. A very large list has been designed of things we wish to implement before we declare it a certain version. We're closing in on a half-playable plugin!
Functions Implemented:
> Player Information created in a SQL database on first login
> Player Information loaded from SQL on subsequent logins
> Player Information saved in SQL on logouts/server shutdowns
> Breaking blocks provides custom exp amounts per-item with level based drops
> Incremental exp curve makes farming materials redundant after lvl 20
> 5 SP earned per level, 1 TP
> Stats STR,DEX,LUK,INT have been listed
> SP can be distributed into stats by command
> Breaking a block stores the time at those coordinates in order to be called later
Essentially, the next thing on the list is finishing the Time-limited exp from blocks to prevent exp farming. A placed block will not provide exp until 24 hours have passed. I'm currently having some problems implementing this using a HashMap...
Code:
This isn't all of the code, but it is the only code containing both the creation, checking, and deletion of the pertinent data. As you can read, I am not able to read any of the data using coord loc; I don't understand why not?? I can't exactly press a pause button and look through a list of the data saved when i cant even get ANY data >.>
Keep in note that it's not actually causing any errors, rather just not working as desired.
*double post merge by comic*
Am i not allowed to store/call a Key in the form of a custom coord? is my code for coord properly formatted for its purpose?
Functions Implemented:
> Player Information created in a SQL database on first login
> Player Information loaded from SQL on subsequent logins
> Player Information saved in SQL on logouts/server shutdowns
> Breaking blocks provides custom exp amounts per-item with level based drops
> Incremental exp curve makes farming materials redundant after lvl 20
> 5 SP earned per level, 1 TP
> Stats STR,DEX,LUK,INT have been listed
> SP can be distributed into stats by command
> Breaking a block stores the time at those coordinates in order to be called later
Essentially, the next thing on the list is finishing the Time-limited exp from blocks to prevent exp farming. A placed block will not provide exp until 24 hours have passed. I'm currently having some problems implementing this using a HashMap...
Code:
// coordinate is a class defining x,y,z
public class coord {
Integer X;
Integer Y;
Integer Z;
}
public class newblock {
Block block;
long date;
}
// newblock is a class defining a minecraft block, and the time it was placed (long, in miliseconds)
private final HashMap<coord, newblock> blockmap = new HashMap<coord, newblock>();
// called by blockListener to modify the HashMap
public void DestroyBlock(Block block) {
coord loc = new coord();
loc.X = (int) block.getLocation().getX();
loc.Y = (int) block.getLocation().getY();
loc.Z = (int) block.getLocation().getZ();
// debug output proved loc is retrieving the proper values
// blockmap.containsKey(loc) ALWAYS returns false?
if (blockmap.containsKey(loc)) {
blockmap.remove(loc);
System.out.println("MyLeveler: Block removed from map");
} else {
System.out.println("MyLeveler: Block removal failed, did not exist");
}
}
// this code is called in order to save a new blocks data
public void SetBlock(Block block) {
coord loc = new coord();
long blk = 0;
loc.X = (int) block.getLocation().getX();
loc.Y = (int) block.getLocation().getY();
loc.Z = (int) block.getLocation().getZ();
// confirmed, x y and z are returning same values as destroyed
blk.block = block;
blk.date = System.currentTimeMillis();
if (blockmap.containsKey(loc)) {
// again, containsKey returns FALSE;
blockmap.remove(loc);
blockmap.put(loc, blk);
System.out.println("MyLeveler: Block Existed, Updated");
} else {
blockmap.put(loc, blk);
System.out.println("MyLeveler: Block added to " + loc.X + ", " + loc.Y + ", " + loc.Z);
System.out.println("MyLeveler: total blocks saved: " + blockmap.size());
// confirmed, size increases, but continues to add same key data
}
}
// collect the block data
public newblock GetBlock(Integer X, Integer Y, Integer Z) {
coord loc = new coord();
loc.X = X;
loc.Y = Y;
loc.Z = Z;
newblock blk = new newblock();
// blockmap.get(loc) returns NULL, no data found
blk.date = blockmap.get(loc);
return blk;
}
This isn't all of the code, but it is the only code containing both the creation, checking, and deletion of the pertinent data. As you can read, I am not able to read any of the data using coord loc; I don't understand why not?? I can't exactly press a pause button and look through a list of the data saved when i cant even get ANY data >.>
Keep in note that it's not actually causing any errors, rather just not working as desired.
*double post merge by comic*
Am i not allowed to store/call a Key in the form of a custom coord? is my code for coord properly formatted for its purpose?