Refactoring

This commit is contained in:
GeorgH93 2020-02-22 16:52:14 +01:00
parent c7c8ac81f2
commit ba3331d16a
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
8 changed files with 19 additions and 16 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 GeorgH93
* Copyright (C) 2020 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -29,7 +29,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Method;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
/**
@ -162,7 +162,7 @@ public abstract class MinepacksCommand extends SubCommand
@Override
public @Nullable List<HelpData> getHelp(@NotNull CommandSender requester)
{
List<HelpData> help = new LinkedList<>();
List<HelpData> help = new ArrayList<>(1);
help.add(new HelpData(getTranslatedName(), null, getDescription()));
return help;
}

View File

@ -33,7 +33,7 @@ import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ -244,7 +244,7 @@ public class Backpack implements at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack
public @NotNull List<ItemStack> setSize(int newSize)
{
opened.forEach((key, value) -> key.closeInventory()); // Close all open views of the inventory
List<ItemStack> removedItems = new LinkedList<>();
List<ItemStack> removedItems = new ArrayList<>();
ItemStack[] itemStackArray;
if(bp.getSize() > newSize)
{

View File

@ -29,7 +29,7 @@ import at.pcgamingfreaks.Minepacks.Bukkit.Permissions;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
public class BackupCommand extends MinepacksCommand
@ -81,7 +81,7 @@ public class BackupCommand extends MinepacksCommand
@Override
public List<HelpData> getHelp(final @NotNull CommandSender requester)
{
List<HelpData> help = new LinkedList<>();
List<HelpData> help = new ArrayList<>(1);
help.add(new HelpData(getTranslatedName(), helpParam, getDescription()));
return help;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 GeorgH93
* Copyright (C) 2020 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -25,8 +25,8 @@ import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
public class HelpCommand extends MinepacksCommand
@ -49,7 +49,7 @@ public class HelpCommand extends MinepacksCommand
public void execute(@NotNull CommandSender sender, @NotNull String mainCommandAlias, @NotNull String alias, @NotNull String[] args)
{
messageHeader.send(sender);
Collection<HelpData> help = new LinkedList<>(), temp;
Collection<HelpData> help = new ArrayList<>(), temp;
for(MinepacksCommand cmd : commands)
{
temp = cmd.doGetHelp(sender);

View File

@ -32,7 +32,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@ -118,7 +118,7 @@ public class OpenCommand extends MinepacksCommand
@Override
public List<HelpData> getHelp(@NotNull CommandSender requester)
{
List<HelpData> help = new LinkedList<>();
List<HelpData> help = new ArrayList<>(2);
help.add(new HelpData(getTranslatedName(), null, getDescription(), MessageClickEvent.ClickEventAction.RUN_COMMAND));
if(requester.hasPermission(Permissions.OTHERS))
{

View File

@ -179,7 +179,7 @@ public class RestoreCommand extends MinepacksCommand
if(args.length == 1)
{
List<String> backups = ((Minepacks) getMinepacksPlugin()).getDatabase().getBackups();
autoComplete = new LinkedList<>();
autoComplete = new ArrayList<>();
for(String backupId : backups)
{
if(backupId.toLowerCase(Locale.ROOT).startsWith(arg)) autoComplete.add(backupId);
@ -191,7 +191,7 @@ public class RestoreCommand extends MinepacksCommand
}
else if(args.length == 2)
{
autoComplete = new LinkedList<>();
autoComplete = new ArrayList<>();
for(Player player : Bukkit.getOnlinePlayers())
{
if(player.getName().toLowerCase(Locale.ROOT).startsWith(arg)) autoComplete.add(player.getName());
@ -203,7 +203,7 @@ public class RestoreCommand extends MinepacksCommand
@Override
public List<HelpData> getHelp(final @NotNull CommandSender requester)
{
List<HelpData> help = new LinkedList<>();
List<HelpData> help = new ArrayList<>();
help.add(new HelpData(getTranslatedName() + " " + listCommands[0], null, ((Minepacks) getMinepacksPlugin()).getLanguage().getTranslated("Commands.Description.RestoreList"), MessageClickEvent.ClickEventAction.RUN_COMMAND));
help.add(new HelpData(getTranslatedName(), helpParam, getDescription(), MessageClickEvent.ClickEventAction.SUGGEST_COMMAND));
return help;

View File

@ -124,7 +124,7 @@ public abstract class SQL extends Database
try(Connection connection = getConnection())
{
Map<String, UpdateData> toConvert = new HashMap<>();
List<UpdateData> toUpdate = new LinkedList<>();
List<UpdateData> toUpdate = new ArrayList<>();
try(Statement stmt = connection.createStatement(); ResultSet res = stmt.executeQuery(queryGetUnsetOrInvalidUUIDs))
{
while(res.next())

View File

@ -36,4 +36,7 @@ public class Permissions
public static final String BACKUP = BASE + "backup";
public static final String RESTORE = BASE + "restore";
public static final String VERSION = BASE + "version";
public static final String INVENTORY_CLEAR = "clearInventory";
public static final String INVENTORY_CLEAR_OTHER = "clearInventory.other";
}