mirror of
https://github.com/garbagemule/MobArena.git
synced 2025-02-16 20:41:56 +01:00
Reformat code in things
package.
This is mostly just line breaks at the top and bottom of classes and interfaces, but also marks some fields `final`.
This commit is contained in:
parent
cad2eef8ba
commit
7b9a9505b9
@ -4,6 +4,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class BootsThing extends ItemStackThing {
|
||||
|
||||
public BootsThing(ItemStack stack) {
|
||||
super(stack);
|
||||
}
|
||||
@ -24,4 +25,5 @@ public class BootsThing extends ItemStackThing {
|
||||
public boolean heldBy(Player player) {
|
||||
return super.getItemStack().equals(player.getInventory().getBoots());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ChestplateThing extends ItemStackThing {
|
||||
|
||||
public ChestplateThing(ItemStack stack) {
|
||||
super(stack);
|
||||
}
|
||||
@ -24,4 +25,5 @@ public class ChestplateThing extends ItemStackThing {
|
||||
public boolean heldBy(Player player) {
|
||||
return super.getItemStack().equals(player.getInventory().getChestplate());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
|
||||
import java.util.Objects;
|
||||
|
||||
public class CommandThing implements Thing {
|
||||
|
||||
private final String command;
|
||||
private final String title;
|
||||
|
||||
@ -65,4 +66,5 @@ public class CommandThing implements Thing {
|
||||
}
|
||||
return command;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.garbagemule.MobArena.things;
|
||||
|
||||
class CommandThingParser implements ThingParser {
|
||||
|
||||
private static final String PREFIX_LONG = "command";
|
||||
private static final String PREFIX_SHORT = "cmd";
|
||||
|
||||
@ -54,8 +55,14 @@ class CommandThingParser implements ThingParser {
|
||||
int stack = 1;
|
||||
for (int i = 1; i < trimmed.length() - 1; i++) {
|
||||
switch (trimmed.charAt(i)) {
|
||||
case '(': stack++; break;
|
||||
case ')': stack--; break;
|
||||
case '(': {
|
||||
stack++;
|
||||
break;
|
||||
}
|
||||
case ')': {
|
||||
stack--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (stack == 0) {
|
||||
return i;
|
||||
@ -63,4 +70,5 @@ class CommandThingParser implements ThingParser {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,9 +3,12 @@ package com.garbagemule.MobArena.things;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
class Equippable {
|
||||
|
||||
@FunctionalInterface
|
||||
interface Wrapper {
|
||||
|
||||
ItemStackThing wrap(ItemStack stack);
|
||||
|
||||
}
|
||||
|
||||
static Wrapper getWrapperByPrefix(String prefix) {
|
||||
@ -45,4 +48,5 @@ class Equippable {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.garbagemule.MobArena.things;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ExperienceThing implements Thing {
|
||||
|
||||
private final int experience;
|
||||
|
||||
public ExperienceThing(int experience) {
|
||||
@ -44,4 +45,5 @@ public class ExperienceThing implements Thing {
|
||||
public boolean heldBy(Player player) {
|
||||
return player.getTotalExperience() > experience;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class HelmetThing extends ItemStackThing {
|
||||
|
||||
public HelmetThing(ItemStack stack) {
|
||||
super(stack);
|
||||
}
|
||||
@ -24,4 +25,5 @@ public class HelmetThing extends ItemStackThing {
|
||||
public boolean heldBy(Player player) {
|
||||
return super.getItemStack().equals(player.getInventory().getHelmet());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
package com.garbagemule.MobArena.things;
|
||||
|
||||
public class InvalidThingInputString extends RuntimeException {
|
||||
private String input;
|
||||
|
||||
private final String input;
|
||||
|
||||
InvalidThingInputString(String input) {
|
||||
super("Invalid input: " + input);
|
||||
@ -11,4 +12,5 @@ public class InvalidThingInputString extends RuntimeException {
|
||||
public String getInput() {
|
||||
return input;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ItemStackParser {
|
||||
|
||||
/**
|
||||
* Parse the given string, returning an {@link ItemStack} instance on
|
||||
* success, otherwise null.
|
||||
@ -16,4 +17,5 @@ public interface ItemStackParser {
|
||||
* @return an instance of {@link ItemStack}, or null
|
||||
*/
|
||||
ItemStack parse(String s);
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,8 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class ItemStackThing implements Thing {
|
||||
private ItemStack stack;
|
||||
|
||||
private final ItemStack stack;
|
||||
|
||||
public ItemStackThing(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
@ -50,4 +51,5 @@ public class ItemStackThing implements Thing {
|
||||
.replace("_", " ")
|
||||
.toLowerCase();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,8 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
class ItemStackThingParser implements ThingParser {
|
||||
private List<ItemStackParser> parsers;
|
||||
|
||||
private final List<ItemStackParser> parsers;
|
||||
|
||||
ItemStackThingParser() {
|
||||
this.parsers = new ArrayList<>();
|
||||
@ -75,4 +76,5 @@ class ItemStackThingParser implements ThingParser {
|
||||
.findFirst()
|
||||
.orElseGet(() -> ItemParser.parseItem(s, false));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class LeggingsThing extends ItemStackThing {
|
||||
|
||||
public LeggingsThing(ItemStack stack) {
|
||||
super(stack);
|
||||
}
|
||||
@ -24,4 +25,5 @@ public class LeggingsThing extends ItemStackThing {
|
||||
public boolean heldBy(Player player) {
|
||||
return super.getItemStack().equals(player.getInventory().getLeggings());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,8 +6,9 @@ import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class MoneyThing implements Thing {
|
||||
private Economy economy;
|
||||
private double amount;
|
||||
|
||||
private final Economy economy;
|
||||
private final double amount;
|
||||
|
||||
public MoneyThing(Economy economy, double amount) {
|
||||
this.economy = economy;
|
||||
@ -47,4 +48,5 @@ public class MoneyThing implements Thing {
|
||||
}
|
||||
return economy.format(amount);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,10 +4,11 @@ import com.garbagemule.MobArena.MobArena;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
class MoneyThingParser implements ThingParser {
|
||||
|
||||
private static final String PREFIX_LONG = "money:";
|
||||
private static final String PREFIX_SHORT = "$";
|
||||
|
||||
private MobArena plugin;
|
||||
private final MobArena plugin;
|
||||
|
||||
MoneyThingParser(MobArena plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -35,4 +36,5 @@ class MoneyThingParser implements ThingParser {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class OffHandThing extends ItemStackThing {
|
||||
|
||||
public OffHandThing(ItemStack stack) {
|
||||
super(stack);
|
||||
}
|
||||
@ -24,4 +25,5 @@ public class OffHandThing extends ItemStackThing {
|
||||
public boolean heldBy(Player player) {
|
||||
return super.getItemStack().equals(player.getInventory().getItemInOffHand());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
|
||||
public class PermissionThing implements Thing {
|
||||
|
||||
private final String perm;
|
||||
private final boolean value;
|
||||
private final MobArena plugin;
|
||||
@ -60,4 +61,5 @@ public class PermissionThing implements Thing {
|
||||
}
|
||||
return "-" + perm;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,9 +3,10 @@ package com.garbagemule.MobArena.things;
|
||||
import com.garbagemule.MobArena.MobArena;
|
||||
|
||||
class PermissionThingParser implements ThingParser {
|
||||
|
||||
private static final String PREFIX = "perm:";
|
||||
|
||||
private MobArena plugin;
|
||||
private final MobArena plugin;
|
||||
|
||||
PermissionThingParser(MobArena plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -30,4 +31,5 @@ class PermissionThingParser implements ThingParser {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
class PotionEffectThing implements Thing {
|
||||
|
||||
private final PotionEffect effect;
|
||||
|
||||
PotionEffectThing(PotionEffect effect) {
|
||||
@ -25,4 +26,5 @@ class PotionEffectThing implements Thing {
|
||||
public boolean heldBy(Player player) {
|
||||
return player.hasPotionEffect(effect.getType());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.garbagemule.MobArena.util.PotionEffectParser;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
class PotionEffectThingParser implements ThingParser {
|
||||
|
||||
private static final String PREFIX = "effect:";
|
||||
|
||||
@Override
|
||||
@ -25,4 +26,5 @@ class PotionEffectThingParser implements ThingParser {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import org.bukkit.entity.Player;
|
||||
* thing (which is the same as failing).
|
||||
*/
|
||||
public interface Thing {
|
||||
|
||||
/**
|
||||
* Give this thing to the given player.
|
||||
*
|
||||
@ -37,4 +38,5 @@ public interface Thing {
|
||||
* @return true, if the player has this thing, false otherwise
|
||||
*/
|
||||
boolean heldBy(Player player);
|
||||
|
||||
}
|
||||
|
@ -6,8 +6,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ThingManager implements ThingParser {
|
||||
private List<ThingParser> parsers;
|
||||
private ItemStackThingParser items;
|
||||
|
||||
private final List<ThingParser> parsers;
|
||||
private final ItemStackThingParser items;
|
||||
|
||||
public ThingManager(MobArena plugin, ItemStackThingParser parser) {
|
||||
parsers = new ArrayList<>();
|
||||
@ -88,4 +89,5 @@ public class ThingManager implements ThingParser {
|
||||
}
|
||||
return items.parse(s);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ package com.garbagemule.MobArena.things;
|
||||
* {@link Thing} or null.
|
||||
*/
|
||||
public interface ThingParser {
|
||||
|
||||
/**
|
||||
* Parse the given string, returning a {@link Thing} instance on success,
|
||||
* otherwise null.
|
||||
@ -13,4 +14,5 @@ public interface ThingParser {
|
||||
* @return an instance of {@link Thing}, or null
|
||||
*/
|
||||
Thing parse(String s);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user