mirror of
https://github.com/SimplexDevelopment/SimplexCore.git
synced 2024-12-22 08:37:37 +00:00
First working version of the API
This commit is contained in:
parent
2f5e2acfeb
commit
6c18f25820
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>io.github.paldiu.simplexcore</groupId>
|
||||
<artifactId>SimplexCore</artifactId>
|
||||
<version>1.0.0-BLEEDING</version>
|
||||
<version>1.1.0-EDGE</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>SimplexCore</name>
|
||||
|
52
src/main/java/io/github/paldiu/simplexcore/CoreState.java
Normal file
52
src/main/java/io/github/paldiu/simplexcore/CoreState.java
Normal file
@ -0,0 +1,52 @@
|
||||
package io.github.paldiu.simplexcore;
|
||||
|
||||
import io.github.paldiu.simplexcore.utils.Constants;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class CoreState {
|
||||
enum State {
|
||||
ON,
|
||||
DEBUG,
|
||||
SUSPENDED,
|
||||
VOLATILE
|
||||
}
|
||||
|
||||
public State getState() {
|
||||
if (SimplexCore.isDebug()) {
|
||||
return State.DEBUG;
|
||||
}
|
||||
|
||||
if (Constants.getPlugin().isEnabled()) {
|
||||
return State.ON;
|
||||
}
|
||||
|
||||
if (SimplexCore.isSuspended()) {
|
||||
return State.SUSPENDED;
|
||||
}
|
||||
|
||||
return State.VOLATILE;
|
||||
}
|
||||
|
||||
String message;
|
||||
|
||||
public CoreState() {
|
||||
switch (getState()) {
|
||||
case ON:
|
||||
message = "The Core is currently ON";
|
||||
break;
|
||||
case SUSPENDED:
|
||||
message = "The Core is currently SUSPENDED. Please report this to the developer.";
|
||||
break;
|
||||
case DEBUG:
|
||||
message = "The Core is currently in DEBUG mode. Do not use this if you don't know what you're doing.";
|
||||
break;
|
||||
case VOLATILE:
|
||||
message = "The Core state is currently unknown! Please report this to the developer!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
@ -7,6 +7,9 @@ import io.github.paldiu.simplexcore.plugin.SimplexAddon;
|
||||
import io.github.paldiu.simplexcore.utils.Constants;
|
||||
|
||||
public final class SimplexCore extends SimplexAddon<SimplexCore> {
|
||||
protected static boolean debug = false;
|
||||
protected static boolean suspended = false;
|
||||
|
||||
@Override
|
||||
public SimplexCore getPlugin() {
|
||||
return this;
|
||||
@ -14,13 +17,33 @@ public final class SimplexCore extends SimplexAddon<SimplexCore> {
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
Constants.getRegistry().register(this);
|
||||
Constants.getCommandLoader().classpath(Command_info.class).load();
|
||||
SimplexListener.register(new ServerPluginListener(), this);
|
||||
try {
|
||||
Constants.getRegistry().register(this);
|
||||
Constants.getCommandLoader().classpath(Command_info.class).load();
|
||||
SimplexListener.register(new ServerPluginListener(), this);
|
||||
} catch (Exception ex) {
|
||||
suspended = true;
|
||||
// TODO: Write an output to a file with why it suspended.
|
||||
}
|
||||
|
||||
CoreState state = new CoreState();
|
||||
Constants.getLogger().info(state.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
|
||||
public static void setDebug(boolean enable) {
|
||||
debug = enable;
|
||||
}
|
||||
|
||||
public static boolean isDebug() {
|
||||
return debug;
|
||||
}
|
||||
|
||||
public static boolean isSuspended() {
|
||||
return suspended;
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package io.github.paldiu.simplexcore.chat;
|
||||
|
||||
import io.github.paldiu.simplexcore.utils.Bean;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public final class ChatUtils {
|
||||
protected final Bean<? extends CommandSender> target;
|
||||
protected final TextComponentFactory factory = new TextComponentFactory();
|
||||
|
||||
private ChatUtils(Bean<? extends CommandSender> target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public static <T extends CommandSender> ChatUtils target(T target) {
|
||||
return new ChatUtils(new Bean<>(target));
|
||||
}
|
||||
|
||||
public void msg(String message) {
|
||||
target.get().sendMessage(message);
|
||||
}
|
||||
|
||||
public void msg(TextComponent component) {
|
||||
target.get().sendMessage(component);
|
||||
}
|
||||
|
||||
public void err(Messages message) {
|
||||
target.get().sendMessage(message.getMessage());
|
||||
}
|
||||
|
||||
public void color(String message) {
|
||||
target.get().sendMessage(factory.colorize(message));
|
||||
}
|
||||
|
||||
public void color(TextComponent component) {
|
||||
target.get().sendMessage(factory.colorize(component.getText()));
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package io.github.paldiu.simplexcore.chat;
|
||||
|
||||
public enum Messages {
|
||||
NO_PERMS("You do not have permission to use this command!"),
|
||||
DISCORD("https://discord.gg/"),
|
||||
BAN("You have been permanently banned from this server."),
|
||||
KICK("You have been kicked by a moderator."),
|
||||
AFK_KICK("You were kicked to ensure space for active players.");
|
||||
|
||||
Messages(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
String message;
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package io.github.paldiu.simplexcore.chat;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.chat.hover.content.Text;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public final class TextComponentFactory {
|
||||
@NotNull
|
||||
public TextComponent textComponent(@NotNull String message) {
|
||||
TextComponent component = new TextComponent();
|
||||
component.setText(message);
|
||||
return component;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public TextComponent clickableComponent(@NotNull String message, @NotNull String clickAction, @NotNull ClickEvent.Action actionType) {
|
||||
TextComponent comp = new TextComponent();
|
||||
ClickEvent onClick = new ClickEvent(actionType, clickAction);
|
||||
comp.setText(message);
|
||||
comp.setClickEvent(onClick);
|
||||
return comp;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public TextComponent coloredComponent(@NotNull String message, @Nullable ChatColor color) {
|
||||
TextComponent component = new TextComponent();
|
||||
if (color != null) component.setColor(color);
|
||||
component.setText(message);
|
||||
return component;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public TextComponent clickableColored(@NotNull String message, @NotNull String clickMessage, @NotNull ClickEvent.Action actionType, @Nullable ChatColor color) {
|
||||
TextComponent comp = new TextComponent();
|
||||
ClickEvent onClick = new ClickEvent(actionType, clickMessage);
|
||||
if (color != null) comp.setColor(color);
|
||||
comp.setText(message);
|
||||
comp.setClickEvent(onClick);
|
||||
return comp;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public TextComponent addColor(@NotNull TextComponent component, @NotNull ChatColor color) {
|
||||
component.setColor(color);
|
||||
return component;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public TextComponent resetColor(@NotNull TextComponent component) {
|
||||
component.setColor(ChatColor.RESET);
|
||||
return component;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public TextComponent hoverableText(@NotNull String message, @NotNull String hoverMessage, @NotNull HoverEvent.Action action) {
|
||||
TextComponent comp = new TextComponent();
|
||||
comp.setText(message);
|
||||
Text text = new Text(hoverMessage);
|
||||
HoverEvent event = new HoverEvent(action, text);
|
||||
comp.setHoverEvent(event);
|
||||
return comp;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String colorize(@NotNull String message) {
|
||||
return ChatColor.translateAlternateColorCodes('&', message);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
name: SimplexCore
|
||||
version: 1.0.0-BLEEDING
|
||||
main: pw.coomer.simplexcore.SimplexCore
|
||||
version: 1.1.0-EDGE
|
||||
main: io.github.paldiu.simplexcore.SimplexCore
|
||||
api-version: 1.16
|
||||
prefix: Simplex
|
||||
authors: [ Paldiu ]
|
||||
|
@ -1,5 +1,5 @@
|
||||
#Generated by Maven
|
||||
#Wed Jan 27 08:29:34 CST 2021
|
||||
#Sat Jan 30 08:40:18 CST 2021
|
||||
groupId=io.github.paldiu.simplexcore
|
||||
artifactId=SimplexCore
|
||||
version=1.0.0-BLEEDING
|
||||
version=1.1.0-EDGE
|
||||
|
@ -1,17 +1,23 @@
|
||||
io\github\paldiu\simplexcore\command\SimplexCommand.class
|
||||
io\github\paldiu\simplexcore\command\defaults\Command_info.class
|
||||
io\github\paldiu\simplexcore\listener\ServerPluginListener.class
|
||||
io\github\paldiu\simplexcore\command\CommandLoader.class
|
||||
io\github\paldiu\simplexcore\math\Size.class
|
||||
io\github\paldiu\simplexcore\command\CommandBase.class
|
||||
io\github\paldiu\simplexcore\command\CommandInfo.class
|
||||
io\github\paldiu\simplexcore\plugin\AddonRegistry.class
|
||||
io\github\paldiu\simplexcore\command\CommandLoader$Registry.class
|
||||
io\github\paldiu\simplexcore\utils\Constants$TimeValues.class
|
||||
io\github\paldiu\simplexcore\utils\Bean.class
|
||||
io\github\paldiu\simplexcore\utils\Constants.class
|
||||
io\github\paldiu\simplexcore\config\YamlFactory.class
|
||||
io\github\paldiu\simplexcore\future\SimplexTask.class
|
||||
io\github\paldiu\simplexcore\config\JsonFactory.class
|
||||
io\github\paldiu\simplexcore\plugin\SimplexAddon.class
|
||||
io\github\paldiu\simplexcore\SimplexCore.class
|
||||
io\github\paldiu\simplexcore\utils\Trio.class
|
||||
io\github\paldiu\simplexcore\listener\SimplexListener.class
|
||||
io\github\paldiu\simplexcore\plugin\AddonManager.class
|
||||
io\github\paldiu\simplexcore\math\Cuboid.class
|
||||
io\github\paldiu\simplexcore\plugin\Addon.class
|
||||
io\github\paldiu\simplexcore\command\defaults\DefaultCommand.class
|
||||
io\github\paldiu\simplexcore\utils\Utilities.class
|
||||
io\github\paldiu\simplexcore\chat\TextComponentFactory.class
|
||||
|
@ -1,11 +1,17 @@
|
||||
C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\listener\ServerPluginListener.java
|
||||
C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\utils\Utilities.java
|
||||
C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\command\CommandInfo.java
|
||||
C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\plugin\AddonManager.java
|
||||
C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\command\defaults\DefaultCommand.java
|
||||
C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\math\Size.java
|
||||
C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\plugin\SimplexAddon.java
|
||||
C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\future\SimplexTask.java
|
||||
C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\utils\Trio.java
|
||||
C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\command\CommandBase.java
|
||||
C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\plugin\Addon.java
|
||||
C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\config\YamlFactory.java
|
||||
C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\config\JsonFactory.java
|
||||
C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\plugin\AddonRegistry.java
|
||||
C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\command\SimplexCommand.java
|
||||
C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\listener\SimplexListener.java
|
||||
C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\utils\Bean.java
|
||||
C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\command\CommandLoader.java
|
||||
C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\command\defaults\Command_info.java
|
||||
|
Loading…
Reference in New Issue
Block a user