File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed
src/main/java/com/github/elic0de/thejpspit Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 44import co .aikar .commands .annotation .CommandAlias ;
55import co .aikar .commands .annotation .CommandPermission ;
66import co .aikar .commands .annotation .Subcommand ;
7+ import com .github .elic0de .thejpspit .TheJpsPit ;
78import com .github .elic0de .thejpspit .player .PitPlayer ;
89import com .github .elic0de .thejpspit .player .PitPlayerManager ;
910import org .bukkit .entity .Player ;
1011
1112@ CommandAlias ("pit|tjp|p" )
1213public class PitCommand extends BaseCommand {
1314
15+ private final TheJpsPit pit = TheJpsPit .getInstance ();
16+
1417 @ Subcommand ("data" )
1518 @ CommandPermission ("tjp.data" )
1619 public void onCommand (Player player ) {
1720 final PitPlayer pitPlayer = PitPlayerManager .getPitPlayer (player );
1821
1922 pitPlayer .sendStatus ();
2023 }
24+
25+ @ Subcommand ("reset" )
26+ @ CommandPermission ("tjp.reset" )
27+ public void onReset (Player player ) {
28+ pit .getDatabase ().deletePlayerData ();
29+ }
2130}
Original file line number Diff line number Diff line change @@ -58,6 +58,8 @@ public abstract CompletableFuture<Optional<Integer>> getPlayerRanking(PitPlayer
5858
5959 public abstract CompletableFuture <Void > updateUserData (PitPlayer player );
6060
61+ public abstract void deletePlayerData ();
62+
6163 public abstract void terminate ();
6264
6365 public enum RankType {
Original file line number Diff line number Diff line change @@ -257,6 +257,19 @@ public CompletableFuture<Void> updateUserData(PitPlayer player) {
257257 });
258258 }
259259
260+ @ Override
261+ public void deletePlayerData () {
262+ try (Connection connection = getConnection ()) {
263+ try (PreparedStatement statement = connection .prepareStatement (formatStatementTables ("""
264+ DELETE FROM `%players_table%`
265+ """ ))) {
266+ statement .executeUpdate ();
267+ }
268+ } catch (SQLException e ) {
269+ getLogger ().log (Level .SEVERE , "Failed to delete playerData from table" , e );
270+ }
271+ }
272+
260273 @ Override
261274 public void terminate () {
262275 try {
You can’t perform that action at this time.
0 commit comments