This commit is contained in:
Luck
2016-07-21 21:40:24 +01:00
Unverified
parent a413c0a50a
commit b3b687d9b7
31 changed files with 1541 additions and 171 deletions
@@ -5,6 +5,7 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.api.data.Callback;
import me.lucko.luckperms.groups.Group;
import me.lucko.luckperms.tracks.Track;
import me.lucko.luckperms.users.User;
@@ -42,6 +43,10 @@ public abstract class Datastore {
doSync(() -> callback.onComplete(result));
}
private void runCallback(UUID result, Callback.GetUUID callback) {
doSync(() -> callback.onComplete(result));
}
/*
These methods are called immediately and in the same thread as they are called in.
*/
@@ -125,15 +130,7 @@ public abstract class Datastore {
doAsync(() -> runCallback(saveUUIDData(username, uuid), callback));
}
public void getUUID(String username, GetUUIDCallback callback) {
doAsync(() -> doSync(() -> callback.onComplete(getUUID(username))));
}
public interface Callback {
void onComplete(boolean success);
}
public interface GetUUIDCallback {
void onComplete(UUID uuid);
public void getUUID(String username, Callback.GetUUID callback) {
doAsync(() -> runCallback(getUUID(username), callback));
}
}
@@ -66,7 +66,7 @@ abstract class SQLDatastore extends Datastore {
throw new IllegalStateException("SQL connection is null");
}
@Cleanup PreparedStatement preparedStatement = connection.prepareStatement(queryPS.getQuery());
@Cleanup PreparedStatement preparedStatement = connection.prepareStatement(queryPS.getQuery());
queryPS.onRun(preparedStatement);
preparedStatement.execute();
success = true;
@@ -389,6 +389,8 @@ abstract class SQLDatastore extends Datastore {
preparedStatement.setString(1, track.getName());
}
});
if (success) plugin.getTrackManager().unloadTrack(track);
return success;
}