File tree Expand file tree Collapse file tree 5 files changed +26
-8
lines changed
src/main/java/edu/whimc/positiontracker/sql Expand file tree Collapse file tree 5 files changed +26
-8
lines changed Original file line number Diff line number Diff line change 44 <modelVersion >4.0.0</modelVersion >
55 <groupId >edu.whimc</groupId >
66 <artifactId >WHIMC-PositionTracker</artifactId >
7- <version >3.2.0 </version >
7+ <version >3.2.4 </version >
88 <name >WHIMC Position Tracker</name >
99 <description >Track player positions to a database</description >
1010
Original file line number Diff line number Diff line change 77import java .sql .SQLException ;
88import java .sql .Timestamp ;
99import java .util .UUID ;
10+
11+ import org .bukkit .Bukkit ;
1012import org .bukkit .Location ;
1113
1214public class RegionEntry extends DataEntry {
@@ -52,7 +54,14 @@ public class RegionEntry extends DataEntry {
5254 public RegionEntry (RegionEvent event ) {
5355 Location loc = event .getLocation ();
5456 this .regionName = event .getRegion ().getId ();
55- this .regionMembers = String .join ("," , event .getRegion ().getMembers ().getPlayers ());
57+ this .regionMembers = String .join ("," ,
58+ event .getRegion ().getMembers ().getUniqueIds ().stream ()
59+ .map (uuid -> {
60+ String name = Bukkit .getOfflinePlayer (uuid ).getName (); //convert UUID to username
61+ return (name != null ) ? name : uuid .toString (); // fallback if name unknown
62+ })
63+ .toList ()
64+ );
5665 this .trigger = event .getTrigger ();
5766 this .isEnter = event instanceof RegionLeaveEvent ;
5867 this .x = loc .getBlockX ();
Original file line number Diff line number Diff line change @@ -52,8 +52,13 @@ public boolean initialize() {
5252 if (schema .getVersion () > curVersion ) {
5353 this .plugin .getLogger ().info ("Migrating to schema " + schema .getVersion () + "..." );
5454 if (!schema .migrate (this )) {
55+ this .plugin .getLogger ().severe ("Migration to schema " + schema .getVersion () + " failed." );
5556 return false ;
57+ } else {
58+ this .plugin .getLogger ().info ("Migration to schema " + schema .getVersion () + " completed." );
5659 }
60+ } else {
61+ this .plugin .getLogger ().info ("Skipping schema " + schema .getVersion () + ", already applied." );
5762 }
5863 schema = schema .getNextSchema ();
5964 }
Original file line number Diff line number Diff line change 88public class Schema_2 extends SchemaVersion {
99
1010 private static final String ADD_GAMEMODE =
11- "ALTER TABLE whimc_player_positions ADD COLUMN gamemode VARCHAR(16);" ;
11+ "ALTER TABLE whimc_player_positions ADD COLUMN gamemode VARCHAR(16) AFTER username ;" ;
1212
1313 public Schema_2 () {
1414 super (2 , new Schema_3 ());
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ public class Schema_3 extends SchemaVersion {
1919 private static final String ADD_REGION_PITCH =
2020 "ALTER TABLE whimc_player_region_events ADD COLUMN pitch FLOAT AFTER yaw;" ;
2121 private static final String ADD_REGION_MEMBERS =
22- "ALTER TABLE whimc_player_region_events ADD COLUMN region-members VARCHAR(64) AFTER region;" ;
22+ "ALTER TABLE whimc_player_region_events ADD COLUMN region_members TEXT AFTER region;" ;
2323
2424 public Schema_3 () {
2525 super (3 , null ); // No newer schema after this one (yet)
@@ -36,14 +36,18 @@ protected void migrateRoutine(Connection connection) throws SQLException {
3636 }
3737
3838 // Update player_region_events table
39- try (PreparedStatement addRegionYaw = connection .prepareStatement (ADD_REGION_YAW )) {
40- addRegionYaw .execute ();
39+ try (PreparedStatement addYaw = connection .prepareStatement (ADD_POS_YAW )) {
40+ addYaw .execute ();
41+ System .out .println ("✓ Adding Yaw, Pitch and Region Members" );
42+ } catch (SQLException e ) {
43+ System .err .println ("✗ Could not add to whimc_player_positions: " + e .getMessage ());
4144 }
45+
4246 try (PreparedStatement addRegionPitch = connection .prepareStatement (ADD_REGION_PITCH )) {
4347 addRegionPitch .execute ();
4448 }
45- try (PreparedStatement addRegionPitch = connection .prepareStatement (ADD_REGION_MEMBERS )) {
46- addRegionPitch .execute ();
49+ try (PreparedStatement addRegionMembers = connection .prepareStatement (ADD_REGION_MEMBERS )) {
50+ addRegionMembers .execute ();
4751 }
4852 }
4953}
You can’t perform that action at this time.
0 commit comments