diff --git a/common/src/main/java/me/lucko/luckperms/common/bulkupdate/PreparedStatementBuilder.java b/common/src/main/java/me/lucko/luckperms/common/bulkupdate/PreparedStatementBuilder.java index f8dfc56cf..0e076c0a7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/bulkupdate/PreparedStatementBuilder.java +++ b/common/src/main/java/me/lucko/luckperms/common/bulkupdate/PreparedStatementBuilder.java @@ -45,7 +45,13 @@ public class PreparedStatementBuilder { return this; } + public PreparedStatementBuilder append(char c) { + this.sb.append(c); + return this; + } + public PreparedStatementBuilder variable(String variable) { + this.sb.append('?'); this.variables.add(variable); return this; } diff --git a/common/src/main/java/me/lucko/luckperms/common/bulkupdate/action/UpdateAction.java b/common/src/main/java/me/lucko/luckperms/common/bulkupdate/action/UpdateAction.java index e9ecf9ce8..4fb41e039 100644 --- a/common/src/main/java/me/lucko/luckperms/common/bulkupdate/action/UpdateAction.java +++ b/common/src/main/java/me/lucko/luckperms/common/bulkupdate/action/UpdateAction.java @@ -93,7 +93,7 @@ public class UpdateAction implements Action { @Override public void appendSql(PreparedStatementBuilder builder) { - builder.append("UPDATE {table} SET " + this.field.getSqlName() + "=?"); + builder.append("UPDATE {table} SET " + this.field.getSqlName() + "="); builder.variable(this.value); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/bulkupdate/comparison/Constraint.java b/common/src/main/java/me/lucko/luckperms/common/bulkupdate/comparison/Constraint.java index a9fa5232c..d08b1e252 100644 --- a/common/src/main/java/me/lucko/luckperms/common/bulkupdate/comparison/Constraint.java +++ b/common/src/main/java/me/lucko/luckperms/common/bulkupdate/comparison/Constraint.java @@ -55,9 +55,9 @@ public class Constraint { public void appendSql(PreparedStatementBuilder builder, String field) { // e.g. field LIKE ? - builder.append(field + " "); + builder.append(field).append(' '); this.comparison.appendSql(builder); - builder.append(" ?"); + builder.append(' '); builder.variable(this.expressionValue); } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/file/SeparatedConfigurateStorage.java b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/file/SeparatedConfigurateStorage.java index 345a2d596..54fcc70c7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/file/SeparatedConfigurateStorage.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/file/SeparatedConfigurateStorage.java @@ -54,6 +54,7 @@ import java.util.stream.Stream; public class SeparatedConfigurateStorage extends AbstractConfigurateStorage { private final String fileExtension; + private final Predicate fileExtensionFilter; private Path usersDirectory; private Path groupsDirectory; @@ -74,6 +75,7 @@ public class SeparatedConfigurateStorage extends AbstractConfigurateStorage { public SeparatedConfigurateStorage(LuckPermsPlugin plugin, String implementationName, ConfigurateLoader loader, String fileExtension, String dataFolderName) { super(plugin, implementationName, loader, dataFolderName); this.fileExtension = fileExtension; + this.fileExtensionFilter = path -> path.getFileName().toString().endsWith(this.fileExtension); } @Override @@ -120,10 +122,6 @@ public class SeparatedConfigurateStorage extends AbstractConfigurateStorage { } } - private Predicate getFileTypeFilter() { - return path -> path.getFileName().toString().endsWith(this.fileExtension); - } - private void registerFileAction(StorageLocation type, Path file) { switch (type) { case USER: @@ -210,7 +208,7 @@ public class SeparatedConfigurateStorage extends AbstractConfigurateStorage { public void applyBulkUpdate(BulkUpdate bulkUpdate) throws Exception { if (bulkUpdate.getDataType().isIncludingUsers()) { try (Stream s = Files.list(getDirectory(StorageLocation.USER))) { - s.filter(getFileTypeFilter()).forEach(file -> { + s.filter(this.fileExtensionFilter).forEach(file -> { try { registerFileAction(StorageLocation.USER, file); ConfigurationNode object = readFile(file); @@ -227,7 +225,7 @@ public class SeparatedConfigurateStorage extends AbstractConfigurateStorage { if (bulkUpdate.getDataType().isIncludingGroups()) { try (Stream s = Files.list(getDirectory(StorageLocation.GROUP))) { - s.filter(getFileTypeFilter()).forEach(file -> { + s.filter(this.fileExtensionFilter).forEach(file -> { try { registerFileAction(StorageLocation.GROUP, file); ConfigurationNode object = readFile(file); @@ -246,7 +244,7 @@ public class SeparatedConfigurateStorage extends AbstractConfigurateStorage { @Override public Set getUniqueUsers() throws IOException { try (Stream stream = Files.list(this.usersDirectory)) { - return stream.filter(getFileTypeFilter()) + return stream.filter(this.fileExtensionFilter) .map(p -> p.getFileName().toString()) .map(s -> s.substring(0, s.length() - this.fileExtension.length())) .map(Uuids::fromString) @@ -259,7 +257,7 @@ public class SeparatedConfigurateStorage extends AbstractConfigurateStorage { public List> searchUserNodes(ConstraintNodeMatcher constraint) throws Exception { List> held = new ArrayList<>(); try (Stream stream = Files.list(getDirectory(StorageLocation.USER))) { - stream.filter(getFileTypeFilter()) + stream.filter(this.fileExtensionFilter) .forEach(file -> { String fileName = file.getFileName().toString(); try { @@ -285,7 +283,7 @@ public class SeparatedConfigurateStorage extends AbstractConfigurateStorage { public void loadAllGroups() throws IOException { List groups; try (Stream stream = Files.list(this.groupsDirectory)) { - groups = stream.filter(getFileTypeFilter()) + groups = stream.filter(this.fileExtensionFilter) .map(p -> p.getFileName().toString()) .map(s -> s.substring(0, s.length() - this.fileExtension.length())) .collect(Collectors.toList()); @@ -302,7 +300,7 @@ public class SeparatedConfigurateStorage extends AbstractConfigurateStorage { public List> searchGroupNodes(ConstraintNodeMatcher constraint) throws Exception { List> held = new ArrayList<>(); try (Stream stream = Files.list(getDirectory(StorageLocation.GROUP))) { - stream.filter(getFileTypeFilter()) + stream.filter(this.fileExtensionFilter) .forEach(file -> { String fileName = file.getFileName().toString(); try { @@ -328,7 +326,7 @@ public class SeparatedConfigurateStorage extends AbstractConfigurateStorage { public void loadAllTracks() throws IOException { List tracks; try (Stream stream = Files.list(this.tracksDirectory)) { - tracks = stream.filter(getFileTypeFilter()) + tracks = stream.filter(this.fileExtensionFilter) .map(p -> p.getFileName().toString()) .map(s -> s.substring(0, s.length() - this.fileExtension.length())) .collect(Collectors.toList()); diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java index 6e6789224..fd1ed9de5 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java @@ -50,6 +50,7 @@ import me.lucko.luckperms.sponge.listeners.SpongePlatformListener; import me.lucko.luckperms.sponge.messaging.SpongeMessagingFactory; import me.lucko.luckperms.sponge.model.manager.SpongeGroupManager; import me.lucko.luckperms.sponge.model.manager.SpongeUserManager; +import me.lucko.luckperms.sponge.service.LuckPermsService; import me.lucko.luckperms.sponge.service.ProxyFactory; import me.lucko.luckperms.sponge.service.events.UpdateEventHandler; import me.lucko.luckperms.sponge.service.model.LPPermissionService; @@ -89,7 +90,7 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin { private SpongeGroupManager groupManager; private StandardTrackManager trackManager; private SpongeContextManager contextManager; - private me.lucko.luckperms.sponge.service.LuckPermsService service; + private LuckPermsService service; private UpdateEventHandler updateEventHandler; private boolean lateLoad = false; @@ -166,7 +167,7 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin { protected void setupPlatformHooks() { getLogger().info("Registering PermissionService..."); this.updateEventHandler = UpdateEventHandler.obtain(this); - this.service = new me.lucko.luckperms.sponge.service.LuckPermsService(this); + this.service = new LuckPermsService(this); PermissionService oldService = this.bootstrap.getGame().getServiceManager().provide(PermissionService.class).orElse(null); if (oldService != null && !(oldService instanceof ProxiedServiceObject)) { @@ -316,7 +317,7 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin { return this.contextManager; } - public me.lucko.luckperms.sponge.service.LuckPermsService getService() { + public LuckPermsService getService() { return this.service; }