Java Reference
In-Depth Information
@Column(columnName = "x" ,
dataType = DataType.DOUBLE)
public double x;
Now the system will know how to store each coordinate. We can do almost
the same thing for the player's name:
@Column(columnName = "player_name" ,
dataType = DataType.STRING)
public String player_name;
this time, specifying that it's a String type. But we need to add a little something
extra for the player_name . We want this field in the database to be unique: the
primary key . There should only be one record in the database with an x, y,
and z for any one player name. You specify that as the columnType , like this:
@Column(columnName = "player_name" ,
columnType = Column.ColumnType.PRIMARY,
dataType = DataType.STRING)
public String player_name;
Now that the columns are specified, you need to name the database table
that will hold these records. You do that right in the constructor:
public AllPlayerLocations() {
super( "all_player_locations" );
}
That tells the database that you want to save these fields in a database table
named all_player_locations .
Finally, you need to make this class extend the DataAccess parent class, and
add a method named getInstance that returns an object of this class. So all
together, the final DataAccess class looks like this:
LocationSnapshot/src/locationsnapshot/AllPlayerLocations.java
package locationsnapshot;
import net.canarymod.database.Column;
import net.canarymod.database.Column.DataType;
import net.canarymod.database.DataAccess;
public class AllPlayerLocations extends DataAccess {
@Column(columnName = "player_name" ,
columnType = Column.ColumnType.PRIMARY,
dataType = DataType.STRING)
public String player_name;
@Column(columnName = "x" , dataType = DataType.DOUBLE)
public double x;
 
 
 
Search WWH ::




Custom Search