Skip to content

Commit

Permalink
style(*): add this qualifier
Browse files Browse the repository at this point in the history
  • Loading branch information
Siroshun09 committed May 27, 2024
1 parent bd2111d commit 9bddd64
Show file tree
Hide file tree
Showing 84 changed files with 349 additions and 349 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ public AbstractCommand(@NotNull String name, @NotNull String permissionNode, @No
}

public @NotNull String getName() {
return name;
return this.name;
}

public @NotNull String getPermissionNode() {
return permissionNode;
return this.permissionNode;
}

public @NotNull @Unmodifiable Set<String> getAliases() {
return aliases;
return this.aliases;
}

public @NotNull List<String> onTabComplete(@NotNull CommandSender sender, @NotNull String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public SubCommandHolder(@NotNull Command... subCommands) {
* @return the list of subcommands
*/
public @NotNull @Unmodifiable List<Command> getSubCommands() {
return subCommands;
return this.subCommands;
}

/**
Expand All @@ -57,7 +57,7 @@ public SubCommandHolder(@NotNull Command... subCommands) {
* @param subCommand the new subcommand
*/
public void register(@NotNull Command subCommand) {
subCommands.add(subCommand);
this.subCommands.add(subCommand);
}

/**
Expand All @@ -66,7 +66,7 @@ public void register(@NotNull Command subCommand) {
* @param subCommand the subcommand to unregister
*/
public void unregister(@NotNull Command subCommand) {
subCommands.remove(subCommand);
this.subCommands.remove(subCommand);
}

/**
Expand All @@ -78,7 +78,7 @@ public void unregister(@NotNull Command subCommand) {
public @NotNull Optional<Command> search(@NotNull String name) {
name = Objects.requireNonNull(name).toLowerCase(Locale.ROOT);

for (var subCommand : subCommands) {
for (var subCommand : this.subCommands) {
if (subCommand.getName().equals(name) || subCommand.getAliases().contains(name)) {
return Optional.of(subCommand);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public FeatureEvent(@NotNull BoxFeature feature, @NotNull Type type) {
* @return the {@link Type} of this event
*/
public @NotNull Type getType() {
return type;
return this.type;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected AbstractBoxFeature(@NotNull String name) {

@Override
public @NotNull String getName() {
return name;
return this.name;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ record DepositAllImpl(@NotNull StockHolder stockHolder,

var boxItem = itemManager.getBoxItem(item).orElse(null);

if (boxItem == null || (filter != null && !filter.test(boxItem)) || (view != null && !checkClickEvent(view, i))) {
if (boxItem == null || (this.filter != null && !this.filter.test(boxItem)) || (view != null && !checkClickEvent(view, i))) {
continue;
}

int itemAmount = item.getAmount();

stockHolder.increase(boxItem, itemAmount, cause);
this.stockHolder.increase(boxItem, itemAmount, cause);
contents[i] = null;

resultMap.mergeInt(boxItem, itemAmount, Integer::sum);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ record DepositImpl(@NotNull StockHolder stockHolder, @NotNull BoxItem boxItem,

int depositedAmount = 0;

for (int i = 0; i < contents.length && depositedAmount < limit; i++) {
for (int i = 0; i < contents.length && depositedAmount < this.limit; i++) {
var item = contents[i];

if (item == null || !boxItem.getOriginal().isSimilar(item) || (view != null && !checkClickEvent(view, i))) {
if (item == null || !this.boxItem.getOriginal().isSimilar(item) || (view != null && !checkClickEvent(view, i))) {
continue;
}

int remaining = limit - depositedAmount;
int remaining = this.limit - depositedAmount;
int itemAmount = item.getAmount();

if (itemAmount <= remaining) {
stockHolder.increase(boxItem, itemAmount, cause);
this.stockHolder.increase(this.boxItem, itemAmount, cause);
depositedAmount += itemAmount;
contents[i] = null;
} else {
stockHolder.increase(boxItem, remaining, cause);
this.stockHolder.increase(this.boxItem, remaining, cause);
depositedAmount += remaining;
contents[i] = item.asQuantity(itemAmount - remaining);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private StockHolderTransaction(@NotNull StockHolder stockHolder) {
* @throws NullPointerException if {@code item} is null
*/
public @NotNull Deposit deposit(@NotNull BoxItem item, int limit) {
return new DepositImpl(stockHolder, Objects.requireNonNull(item), limit);
return new DepositImpl(this.stockHolder, Objects.requireNonNull(item), limit);
}

/**
Expand All @@ -54,7 +54,7 @@ private StockHolderTransaction(@NotNull StockHolder stockHolder) {
* @return a {@link Deposit} instance
*/
public @NotNull Deposit depositAll() {
return new DepositAllImpl(stockHolder, null);
return new DepositAllImpl(this.stockHolder, null);
}

/**
Expand All @@ -65,7 +65,7 @@ private StockHolderTransaction(@NotNull StockHolder stockHolder) {
* @throws NullPointerException if {@code filter} is null
*/
public @NotNull Deposit depositAll(@NotNull Predicate<BoxItem> filter) {
return new DepositAllImpl(stockHolder, Objects.requireNonNull(filter));
return new DepositAllImpl(this.stockHolder, Objects.requireNonNull(filter));
}

/**
Expand All @@ -77,7 +77,7 @@ private StockHolderTransaction(@NotNull StockHolder stockHolder) {
* @throws NullPointerException if {@code item} is null
*/
public @NotNull Withdrawal withdraw(@NotNull BoxItem item, int limit) {
return new WithdrawalImpl(stockHolder, Objects.requireNonNull(item), limit);
return new WithdrawalImpl(this.stockHolder, Objects.requireNonNull(item), limit);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public record TransactionResult(@NotNull BoxItem item, int amount) {
*/
@ApiStatus.Obsolete
public @NotNull BoxItem getItem() {
return item;
return this.item;
}

/**
Expand All @@ -60,6 +60,6 @@ public record TransactionResult(@NotNull BoxItem item, int amount) {
*/
@ApiStatus.Obsolete
public int getAmount() {
return amount;
return this.amount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,36 +31,36 @@ record WithdrawalImpl(@NotNull StockHolder stockHolder, @NotNull BoxItem boxItem
Objects.requireNonNull(inventory);
Objects.requireNonNull(cause);

int maxStackSize = boxItem.getOriginal().getMaxStackSize();
int maxStackSize = this.boxItem.getOriginal().getMaxStackSize();
int withdrawnAmount = 0;

var contents = inventory.getStorageContents();

for (int i = 0; i < contents.length && withdrawnAmount < limit; i++) {
for (int i = 0; i < contents.length && withdrawnAmount < this.limit; i++) {
var item = contents[i];

if (item == null) {
if (view != null && !checkClickEvent(view, i)) {
continue;
}

int withdrawn = stockHolder.decreaseToZero(boxItem, Math.min(limit - withdrawnAmount, maxStackSize), cause);
int withdrawn = this.stockHolder.decreaseToZero(this.boxItem, Math.min(this.limit - withdrawnAmount, maxStackSize), cause);

if (withdrawn < 1) {
break;
}

withdrawnAmount += withdrawn;
contents[i] = boxItem.getOriginal().asQuantity(withdrawn);
} else if (item.isSimilar(boxItem.getOriginal())) {
contents[i] = this.boxItem.getOriginal().asQuantity(withdrawn);
} else if (item.isSimilar(this.boxItem.getOriginal())) {
if (view != null && !checkClickEvent(view, i)) {
continue;
}

int remaining = maxStackSize - item.getAmount();

if (0 < remaining) {
int withdrawn = stockHolder.decreaseToZero(boxItem, Math.min(limit - withdrawnAmount, remaining), cause);
int withdrawn = this.stockHolder.decreaseToZero(this.boxItem, Math.min(this.limit - withdrawnAmount, remaining), cause);

if (withdrawn < 1) {
break;
Expand All @@ -76,7 +76,7 @@ record WithdrawalImpl(@NotNull StockHolder stockHolder, @NotNull BoxItem boxItem
inventory.setStorageContents(contents);
}

return TransactionResult.create(boxItem, withdrawnAmount);
return TransactionResult.create(this.boxItem, withdrawnAmount);
}

private static boolean checkClickEvent(@NotNull InventoryView view, int slot) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ public final class BoxBootstrapContext implements net.okocraft.box.api.bootstrap

@Override
public @NotNull Path getDataDirectory() {
return dataDirectory;
return this.dataDirectory;
}

@Override
public @NotNull String getVersion() {
return version;
return this.version;
}

@Override
Expand All @@ -80,7 +80,7 @@ public final class BoxBootstrapContext implements net.okocraft.box.api.bootstrap
}

public @NotNull StorageRegistry getStorageRegistry() {
return storageRegistry;
return this.storageRegistry;
}

public @NotNull List<BoxFeature> getBoxFeatureList() {
Expand Down
26 changes: 13 additions & 13 deletions core/src/main/java/net/okocraft/box/core/BoxCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public boolean enable(@NotNull Storage storage) {

BoxLogger.logger().info("Initializing managers...");

userManager = new BoxUserManager(storage.getUserStorage());
this.userManager = new BoxUserManager(storage.getUserStorage());

try {
var itemLoadResult = ItemLoader.load(storage.getItemStorage(), this.context.defaultItemProvider());
Expand All @@ -103,9 +103,9 @@ public boolean enable(@NotNull Storage storage) {
this.playerMap = new BoxPlayerMapImpl(this.userManager, this.stockManager, this.context.eventManager(), this.context.scheduler(), this.context.messageProvider());
this.playerMap.loadAll();

Bukkit.getPluginManager().registerEvents(new PlayerConnectionListener(this.playerMap), context.plugin());
Bukkit.getPluginManager().registerEvents(new PlayerConnectionListener(this.playerMap), this.context.plugin());

stockManager.schedulerAutoSaveTask(this.context.scheduler());
this.stockManager.schedulerAutoSaveTask(this.context.scheduler());

BoxLogger.logger().info("Registering commands...");

Expand All @@ -121,11 +121,11 @@ public boolean enable(@NotNull Storage storage) {
}

public void disable() {
if (playerMap != null) {
playerMap.unloadAll();
if (this.playerMap != null) {
this.playerMap.unloadAll();
}

stockManager.close();
this.stockManager.close();

DebugListener.unregister(this.context.eventManager());
}
Expand Down Expand Up @@ -190,7 +190,7 @@ public void accept(Supplier<Component> componentSupplier) {

@Override
public @NotNull Path getPluginDirectory() {
return context.dataDirectory();
return this.context.dataDirectory();
}

@Override
Expand All @@ -205,17 +205,17 @@ public void accept(Supplier<Component> componentSupplier) {

@Override
public @NotNull UserManager getUserManager() {
return userManager;
return this.userManager;
}

@Override
public @NotNull ItemManager getItemManager() {
return itemManager;
return this.itemManager;
}

@Override
public @NotNull StockManager getStockManager() {
return stockManager;
return this.stockManager;
}

@Override
Expand All @@ -235,17 +235,17 @@ public void accept(Supplier<Component> componentSupplier) {

@Override
public @NotNull BoxPlayerMap getBoxPlayerMap() {
return playerMap;
return this.playerMap;
}

@Override
public @NotNull BoxCommand getBoxCommand() {
return boxCommand;
return this.boxCommand;
}

@Override
public @NotNull BoxAdminCommand getBoxAdminCommand() {
return boxAdminCommand;
return this.boxAdminCommand;
}

public void initializeFeatures(@NotNull List<BoxFeature> features) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String[] args) {
}

if (args.length == 0) {
if (commandOfNoArgument != null && sender.hasPermission(commandOfNoArgument.getPermissionNode())) {
if (this.commandOfNoArgument != null && sender.hasPermission(this.commandOfNoArgument.getPermissionNode())) {
this.scheduler.runAsyncTask(() -> this.commandOfNoArgument.onCommand(sender, args));
} else {
ErrorMessages.NOT_ENOUGH_ARGUMENT.source(source).send(sender);
Expand All @@ -54,7 +54,7 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String[] args) {
return;
}

var optionalSubCommand = subCommandHolder.search(args[0]);
var optionalSubCommand = this.subCommandHolder.search(args[0]);

if (optionalSubCommand.isEmpty()) {
if (!args[0].equalsIgnoreCase("help")) {
Expand Down Expand Up @@ -89,22 +89,22 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String[] args) {
}

if (args.length == 1) {
return subCommandHolder.getSubCommands().stream()
return this.subCommandHolder.getSubCommands().stream()
.filter(cmd -> sender.hasPermission(cmd.getPermissionNode()))
.map(Command::getName)
.filter(cmdName -> cmdName.startsWith(args[0].toLowerCase(Locale.ROOT)))
.toList();
}

return subCommandHolder.search(args[0])
return this.subCommandHolder.search(args[0])
.filter(cmd -> sender.hasPermission(cmd.getPermissionNode()))
.map(cmd -> cmd.onTabComplete(sender, args))
.orElse(Collections.emptyList());
}

@Override
public @NotNull SubCommandHolder getSubCommandHolder() {
return subCommandHolder;
return this.subCommandHolder;
}

@Override
Expand All @@ -113,7 +113,7 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String[] args) {
}

public void changeNoArgumentCommand(@Nullable Command command) {
commandOfNoArgument = command;
this.commandOfNoArgument = command;
}

@EventHandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public PlayerConnectionListener(@NotNull BoxPlayerMapImpl playerMap) {

@EventHandler
public void onJoin(@NotNull PlayerJoinEvent event) {
playerMap.scheduleLoadingData(event.getPlayer());
this.playerMap.scheduleLoadingData(event.getPlayer());
}

@EventHandler
public void onQuit(@NotNull PlayerQuitEvent event) {
playerMap.unload(event.getPlayer());
this.playerMap.unload(event.getPlayer());
}
}
Loading

0 comments on commit 9bddd64

Please sign in to comment.