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