forked from chipmunkmc/chipmunkbot
use project lombok to reduce boilerplate code
This commit is contained in:
parent
549eef6647
commit
fa827a934d
4 changed files with 14 additions and 99 deletions
|
@ -9,9 +9,10 @@ import java.util.Map;
|
|||
import java.util.HashMap;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import lombok.Getter;
|
||||
|
||||
public class Client {
|
||||
private Session session;
|
||||
@Getter private final Session session;
|
||||
private Map<String, Plugin> plugins = new HashMap();
|
||||
|
||||
public Client (ClientOptions options) {
|
||||
|
@ -21,10 +22,6 @@ public class Client {
|
|||
session.connect();
|
||||
}
|
||||
|
||||
public Session session () {
|
||||
return session;
|
||||
}
|
||||
|
||||
public Plugin getPlugin (String id) { return plugins.get(id); }
|
||||
|
||||
public void loadPlugin (Class<? extends Plugin> pluginClass) {
|
||||
|
|
|
@ -5,20 +5,17 @@ import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
|||
import com.github.steveice10.packetlib.ProxyInfo;
|
||||
import com.github.steveice10.packetlib.Session;
|
||||
import com.github.steveice10.packetlib.tcp.TcpClientSession;
|
||||
import lombok.Data;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class ClientOptions {
|
||||
private String host;
|
||||
private int port;
|
||||
private MinecraftProtocol protocol;
|
||||
private ProxyInfo proxy;
|
||||
|
||||
public ClientOptions (String host, int port, MinecraftProtocol protocol, ProxyInfo proxy) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.protocol = protocol;
|
||||
this.proxy = proxy;
|
||||
}
|
||||
|
||||
public ClientOptions () { // So it can easily be used as a builder
|
||||
}
|
||||
|
||||
|
@ -31,24 +28,6 @@ public class ClientOptions {
|
|||
return this;
|
||||
}
|
||||
|
||||
public int port () {
|
||||
return port;
|
||||
}
|
||||
|
||||
public ClientOptions port (int value) {
|
||||
port = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MinecraftProtocol protocol () {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public ClientOptions protocol (MinecraftProtocol value) {
|
||||
protocol = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/* public ClientOptions profile (GameProfile profile) {
|
||||
protocol(new MinecraftProtocol(profile));
|
||||
return this;
|
||||
|
@ -58,13 +37,4 @@ public class ClientOptions {
|
|||
protocol(new MinecraftProtocol(username));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProxyInfo proxy () {
|
||||
return proxy;
|
||||
}
|
||||
|
||||
public ClientOptions proxy (ProxyInfo value) {
|
||||
proxy = value;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,36 +2,17 @@ package land.chipmunk.chipmunkbot.chat;
|
|||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import java.util.UUID;
|
||||
import lombok.Data;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class ChatMessage {
|
||||
// * I do not really care about signatures, they were likely made for the sus chat reporting system anyway, but I still include the sender as it really helps with stuff such as commands.
|
||||
private Component component;
|
||||
private UUID sender;
|
||||
|
||||
public ChatMessage (Component component, UUID sender) {
|
||||
this.component = component;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
public ChatMessage (Component component) {
|
||||
this(component, new UUID(0, 0));
|
||||
}
|
||||
|
||||
public Component component () {
|
||||
return component;
|
||||
}
|
||||
|
||||
public ChatMessage component (Component value) {
|
||||
component = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UUID sender () {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public ChatMessage sender (UUID value) {
|
||||
sender = value;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,46 +2,13 @@ package land.chipmunk.chipmunkbot.chat;
|
|||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import com.github.steveice10.mc.protocol.data.game.PlayerListEntry;
|
||||
import lombok.Data;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class PlayerMessage {
|
||||
private PlayerListEntry sender;
|
||||
private Component contents;
|
||||
private MessageType type;
|
||||
|
||||
PlayerMessage (PlayerListEntry sender, Component contents, MessageType type) {
|
||||
this.sender = sender;
|
||||
this.contents = contents;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
PlayerMessage (PlayerListEntry sender, Component contents) {
|
||||
this(sender, contents, MessageType.TEXT);
|
||||
}
|
||||
|
||||
public PlayerListEntry sender () {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public PlayerMessage sender (PlayerListEntry value) {
|
||||
sender = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Component contents () {
|
||||
return contents;
|
||||
}
|
||||
|
||||
public PlayerMessage contents (Component value) {
|
||||
contents = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MessageType type () {
|
||||
return type;
|
||||
}
|
||||
|
||||
public PlayerMessage type (MessageType value) {
|
||||
type = value;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue