Cleanup some stuff

This commit is contained in:
Luck 2017-05-02 16:36:46 +01:00
parent 152ca99276
commit f56bb251e9
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
4 changed files with 22 additions and 64 deletions

View File

@ -42,7 +42,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
public class MigrationMainCommand extends MainCommand<Object> {
private static final Map<String, String> PLUGINS = ImmutableMap.<String, String>builder()
@ -96,7 +95,7 @@ public class MigrationMainCommand extends MainCommand<Object> {
@SuppressWarnings("unchecked")
private static List<Command<Object, ?>> getAvailableCommands() {
List<SubCommand<Object>> l = new ArrayList<>();
List<Command<Object, ?>> l = new ArrayList<>();
for (Map.Entry<String, String> plugin : PLUGINS.entrySet()) {
try {
@ -105,7 +104,7 @@ public class MigrationMainCommand extends MainCommand<Object> {
} catch (Throwable ignored) {}
}
return l.stream().collect(Collectors.toList());
return l;
}
/* Dummy */

View File

@ -103,23 +103,26 @@ public class BulkUpdateCommand extends SingleCommand {
}
String action = args.remove(0).toLowerCase();
if (action.equals("delete")) {
bulkUpdateBuilder.action(DeleteAction.create());
} else if (action.equals("update")) {
if (args.size() < 2) {
throw new ArgumentUtils.DetailedUsageException();
}
switch (action) {
case "delete":
bulkUpdateBuilder.action(DeleteAction.create());
break;
case "update":
if (args.size() < 2) {
throw new ArgumentUtils.DetailedUsageException();
}
String field = args.remove(0);
QueryField queryField = QueryField.of(field);
if (queryField == null) {
throw new ArgumentUtils.DetailedUsageException();
}
String value = args.remove(0);
String field = args.remove(0);
QueryField queryField = QueryField.of(field);
if (queryField == null) {
throw new ArgumentUtils.DetailedUsageException();
}
String value = args.remove(0);
bulkUpdateBuilder.action(UpdateAction.of(queryField, value));
} else {
throw new ArgumentUtils.DetailedUsageException();
bulkUpdateBuilder.action(UpdateAction.of(queryField, value));
break;
default:
throw new ArgumentUtils.DetailedUsageException();
}
for (String constraint : args) {

View File

@ -39,6 +39,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@ -76,7 +77,7 @@ public class LegacySQLSchemaMigration implements Runnable {
backing.getPlugin().getLog().warn("Found " + uuidData.size() + " uuid data entries. Copying to new tables...");
List<Map.Entry<UUID, String>> uuidEntries = uuidData.entrySet().stream().collect(Collectors.toList());
List<Map.Entry<UUID, String>> uuidEntries = new ArrayList<>(uuidData.entrySet());
List<List<Map.Entry<UUID, String>>> partitionedUuidEntries = Lists.partition(uuidEntries, 100);
for (List<Map.Entry<UUID, String>> l : partitionedUuidEntries) {

View File

@ -1,45 +0,0 @@
/*
* This file is part of LuckPerms, licensed under the MIT License.
*
* Copyright (c) lucko (Luck) <luck@lucko.me>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.lucko.luckperms.common.utils;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import me.lucko.luckperms.common.core.model.Group;
import java.util.Comparator;
import java.util.Map;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class WeightComparator implements Comparator<Map.Entry<Integer, ? extends Group>> {
public static final WeightComparator INSTANCE = new WeightComparator();
@Override
public int compare(Map.Entry<Integer, ? extends Group> o1, Map.Entry<Integer, ? extends Group> o2) {
int result = Integer.compare(o1.getKey(), o2.getKey());
return result != 0 ? result : 1;
}
}