Implement events required by Simple Discord Link
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package com.hypherionmc.craterlib.api.event.common;
|
||||
|
||||
import com.hypherionmc.craterlib.core.event.CraterEvent;
|
||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
|
||||
public class CraterLivingDeathEvent extends CraterEvent {
|
||||
|
||||
private final DamageSource damageSource;
|
||||
private final LivingEntity entity;
|
||||
|
||||
public CraterLivingDeathEvent(LivingEntity entity, DamageSource source) {
|
||||
this.entity = entity;
|
||||
this.damageSource = source;
|
||||
}
|
||||
|
||||
public LivingEntity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public DamageSource getDamageSource() {
|
||||
return damageSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCancel() {
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
package com.hypherionmc.craterlib.api.event.server;
|
||||
|
||||
import com.hypherionmc.craterlib.core.event.CraterEvent;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public class CraterAdvancementEvent extends CraterEvent {
|
||||
|
||||
private final Advancement advancement;
|
||||
private final Player player;
|
||||
|
||||
public CraterAdvancementEvent(Player player, Advancement advancement) {
|
||||
this.player = player;
|
||||
this.advancement = advancement;
|
||||
}
|
||||
|
||||
public Advancement getAdvancement() {
|
||||
return advancement;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCancel() {
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
package com.hypherionmc.craterlib.api.event.server;
|
||||
|
||||
import com.hypherionmc.craterlib.core.event.CraterEvent;
|
||||
import com.mojang.brigadier.ParseResults;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
|
||||
public class CraterCommandEvent extends CraterEvent {
|
||||
|
||||
private ParseResults<CommandSourceStack> parseResults;
|
||||
private Throwable exception;
|
||||
private String command;
|
||||
|
||||
public CraterCommandEvent(ParseResults<CommandSourceStack> parseResults, String command) {
|
||||
this.parseResults = parseResults;
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public ParseResults<CommandSourceStack> getParseResults() {
|
||||
return parseResults;
|
||||
}
|
||||
|
||||
public void setParseResults(ParseResults<CommandSourceStack> parseResults) {
|
||||
this.parseResults = parseResults;
|
||||
}
|
||||
|
||||
public Throwable getException() {
|
||||
return exception;
|
||||
}
|
||||
|
||||
public void setException(Throwable exception) {
|
||||
this.exception = exception;
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public void setCommand(String command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCancel() {
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
package com.hypherionmc.craterlib.api.event.server;
|
||||
|
||||
import com.hypherionmc.craterlib.core.event.CraterEvent;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
public class CraterPlayerEvent extends CraterEvent {
|
||||
|
||||
private final Player player;
|
||||
|
||||
public CraterPlayerEvent(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCancel() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class PlayerLoggedIn extends CraterPlayerEvent {
|
||||
|
||||
public PlayerLoggedIn(Player player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class PlayerLoggedOut extends CraterPlayerEvent {
|
||||
|
||||
public PlayerLoggedOut(Player player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
package com.hypherionmc.craterlib.api.event.server;
|
||||
|
||||
import com.hypherionmc.craterlib.core.event.CraterEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class CraterServerChatEvent extends CraterEvent {
|
||||
|
||||
private final String message, username;
|
||||
private final ServerPlayer player;
|
||||
private Component component;
|
||||
|
||||
public CraterServerChatEvent(ServerPlayer player, String message, Component component) {
|
||||
this.message = message;
|
||||
this.player = player;
|
||||
this.username = player.getGameProfile().getName();
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
public void setComponent(Component component) {
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
public Component getComponent() {
|
||||
return component;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public ServerPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCancel() {
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
package com.hypherionmc.craterlib.api.event.server;
|
||||
|
||||
import com.hypherionmc.craterlib.core.event.CraterEvent;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
public class PlayerPreLoginEvent extends CraterEvent {
|
||||
|
||||
private final SocketAddress address;
|
||||
private final GameProfile gameProfile;
|
||||
private Component message;
|
||||
|
||||
public PlayerPreLoginEvent(SocketAddress address, GameProfile profile) {
|
||||
this.address = address;
|
||||
this.gameProfile = profile;
|
||||
}
|
||||
|
||||
public Component getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(Component message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public GameProfile getGameProfile() {
|
||||
return gameProfile;
|
||||
}
|
||||
|
||||
public SocketAddress getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCancel() {
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user