Remove Commons

This commit is contained in:
Myles 2016-09-27 17:48:56 +01:00
parent d5108061c1
commit 866e494d3c
8 changed files with 18 additions and 30 deletions

View File

@ -1,7 +1,7 @@
package us.myles.ViaVersion.api;
import com.google.common.base.Preconditions;
import lombok.Getter;
import org.apache.commons.lang.Validate;
import us.myles.ViaVersion.ViaManager;
import us.myles.ViaVersion.api.platform.ViaPlatform;
@ -17,7 +17,7 @@ public class Via {
* @param viaManager The ViaManager
*/
public static void init(ViaManager viaManager) {
Validate.isTrue(manager == null, "ViaManager is already set");
Preconditions.checkArgument(manager == null, "ViaManager is already set");
Via.platform = viaManager.getPlatform();
Via.manager = viaManager;
@ -29,7 +29,7 @@ public class Via {
* @return API instance
*/
public static ViaAPI getAPI() {
Validate.isTrue(platform != null, "ViaVersion has not loaded the Platform");
Preconditions.checkArgument(platform != null, "ViaVersion has not loaded the Platform");
return Via.platform.getApi();
}
@ -39,7 +39,7 @@ public class Via {
* @return Config instance
*/
public static ViaVersionConfig getConfig() {
Validate.isTrue(platform != null, "ViaVersion has not loaded the Platform");
Preconditions.checkArgument(platform != null, "ViaVersion has not loaded the Platform");
return Via.platform.getConf();
}
}

View File

@ -1,6 +1,5 @@
package us.myles.ViaVersion.api.boss;
import org.apache.commons.lang.NotImplementedException;
import us.myles.ViaVersion.api.Via;
import java.util.Set;
@ -76,7 +75,7 @@ public abstract class BossBar<T> {
*/
@Deprecated
public BossBar addPlayer(T player) {
throw new NotImplementedException("This method is not implemented for the platform " + Via.getPlatform().getPlatformName());
throw new UnsupportedOperationException("This method is not implemented for the platform " + Via.getPlatform().getPlatformName());
}
/**
@ -96,7 +95,7 @@ public abstract class BossBar<T> {
*/
@Deprecated
public BossBar addPlayers(T... players) {
throw new NotImplementedException("This method is not implemented for the platform " + Via.getPlatform().getPlatformName());
throw new UnsupportedOperationException("This method is not implemented for the platform " + Via.getPlatform().getPlatformName());
}
/**
@ -108,7 +107,7 @@ public abstract class BossBar<T> {
*/
@Deprecated
public BossBar removePlayer(T player) {
throw new NotImplementedException("This method is not implemented for the platform " + Via.getPlatform().getPlatformName());
throw new UnsupportedOperationException("This method is not implemented for the platform " + Via.getPlatform().getPlatformName());
}
/**

View File

@ -1,11 +1,11 @@
package us.myles.ViaVersion.boss;
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.Validate;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.boss.BossBar;
import us.myles.ViaVersion.api.boss.BossColor;
@ -29,8 +29,8 @@ public abstract class CommonBoss<T> extends BossBar<T> {
private Set<BossFlag> flags;
public CommonBoss(String title, float health, BossColor color, BossStyle style) {
Validate.notNull(title, "Title cannot be null");
Validate.isTrue((health >= 0 && health <= 1), "Health must be between 0 and 1");
Preconditions.checkNotNull(title, "Title cannot be null");
Preconditions.checkArgument((health >= 0 && health <= 1), "Health must be between 0 and 1");
this.uuid = UUID.randomUUID();
this.title = title;
@ -51,7 +51,7 @@ public abstract class CommonBoss<T> extends BossBar<T> {
@Override
public BossBar setHealth(float health) {
Validate.isTrue((health >= 0 && health <= 1), "Health must be between 0 and 1");
Preconditions.checkArgument((health >= 0 && health <= 1), "Health must be between 0 and 1");
this.health = health;
sendPacket(CommonBoss.UpdateAction.UPDATE_HEALTH);
return this;

View File

@ -1,8 +1,8 @@
package us.myles.ViaVersion.commands;
import com.google.common.base.Preconditions;
import lombok.NonNull;
import net.md_5.bungee.api.ChatColor;
import org.apache.commons.lang.Validate;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.command.ViaCommandSender;
import us.myles.ViaVersion.api.command.ViaSubCommand;
@ -25,7 +25,7 @@ public abstract class ViaCommandHandler implements ViaVersionCommand {
@Override
public void registerSubCommand(@NonNull ViaSubCommand command) throws Exception {
Validate.isTrue(command.name().matches("^[a-z0-9_-]{3,15}$"), command.name() + " is not a valid subcommand name");
Preconditions.checkArgument(command.name().matches("^[a-z0-9_-]{3,15}$"), command.name() + " is not a valid subcommand name");
if (hasSubCommand(command.name()))
throw new Exception("ViaSubCommand " + command.name() + " does already exists!"); //Maybe another exception later.
commandMap.put(command.name().toLowerCase(), command);

View File

@ -1,5 +1,7 @@
package us.myles.ViaVersion.protocols.base;
import com.google.common.base.Joiner;
import com.google.common.base.Strings;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
@ -8,7 +10,6 @@ import io.netty.channel.ChannelFuture;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;
import net.md_5.bungee.api.ChatColor;
import org.apache.commons.lang.StringUtils;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Pair;
import us.myles.ViaVersion.api.Via;
@ -110,7 +111,7 @@ public class BaseProtocol extends Protocol {
new Object[]{
wrapper.get(Type.STRING, 1),
info.getProtocolVersion(),
StringUtils.join(info.getPipeline().pipes(), ", ")
Joiner.on(", ").join(info.getPipeline().pipes(), ", ")
});
}
}

View File

@ -1,6 +1,6 @@
package us.myles.ViaVersion.update;
import org.apache.commons.lang.StringUtils;
import com.google.common.base.Joiner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -72,7 +72,7 @@ public class Version implements Comparable<Version> {
for (int i = 0; i < parts.length; i += 1)
split[i] = String.valueOf(parts[i]);
return StringUtils.join(split, ".") + (tag.length() != 0 ? "-" + tag : "");
return Joiner.on(".").join(split) + (tag.length() != 0 ? "-" + tag : "");
}
@Override

View File

@ -57,10 +57,6 @@
<pattern>org.javassist</pattern>
<shadedPattern>us.myles.viaversion.libs.javassist</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache</pattern>
<shadedPattern>us.myles.viaversion.libs.apache</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>

View File

@ -100,14 +100,6 @@
<optional>true</optional>
</dependency>
<!-- Apache Commons Lang -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<scope>compile</scope>
</dependency>
<!-- ChatColour API -->
<dependency>
<groupId>net.md-5</groupId>