-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create editorconfig and switch code from crlf to lf
- Loading branch information
1 parent
166303d
commit 77e94ef
Showing
17 changed files
with
1,118 additions
and
1,107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = false | ||
|
||
[.github/workflows/*.yml] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
pluginManagement { | ||
repositories { | ||
maven { | ||
name = 'Fabric' | ||
url = 'https://maven.fabricmc.net/' | ||
} | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
} | ||
|
||
rootProject.name = 'discord-bridge' | ||
|
||
pluginManagement { | ||
repositories { | ||
maven { | ||
name = 'Fabric' | ||
url = 'https://maven.fabricmc.net/' | ||
} | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
} | ||
|
||
rootProject.name = 'discord-bridge' |
132 changes: 66 additions & 66 deletions
132
src/main/java/net/kings_world/discord_bridge/DiscordBridgeEvents.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,66 @@ | ||
package net.kings_world.discord_bridge; | ||
|
||
import dev.kord.core.entity.Message; | ||
import net.fabricmc.fabric.api.event.Event; | ||
import net.fabricmc.fabric.api.event.EventFactory; | ||
import net.minecraft.advancement.AdvancementDisplay; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.text.Text; | ||
|
||
public final class DiscordBridgeEvents { | ||
public static final Event<PlayerJoin> PLAYER_JOIN = EventFactory.createArrayBacked(PlayerJoin.class, callbacks -> player -> { | ||
for (PlayerJoin callback : callbacks) { | ||
callback.onPlayerJoin(player); | ||
} | ||
}); | ||
|
||
public static final Event<PlayerLeave> PLAYER_LEAVE = EventFactory.createArrayBacked(PlayerLeave.class, callbacks -> (player, reason) -> { | ||
for (PlayerLeave callback : callbacks) { | ||
callback.onPlayerLeave(player, reason); | ||
} | ||
}); | ||
|
||
public static final Event<PlayerDeath> PLAYER_DEATH = EventFactory.createArrayBacked(PlayerDeath.class, callbacks -> (entity, reason) -> { | ||
for (PlayerDeath callback : callbacks) { | ||
callback.onPlayerDeath(entity, reason); | ||
} | ||
}); | ||
|
||
public static final Event<PlayerAdvancement> PLAYER_ADVANCEMENT = EventFactory.createArrayBacked(PlayerAdvancement.class, callbacks -> (player, advancement) -> { | ||
for (PlayerAdvancement callback : callbacks) { | ||
callback.onPlayerAdvancement(player, advancement); | ||
} | ||
}); | ||
|
||
public static final Event<DiscordMessage> DISCORD_MESSAGE = EventFactory.createArrayBacked(DiscordMessage.class, callbacks -> message -> { | ||
for (DiscordMessage callback : callbacks) { | ||
callback.onDiscordMessage(message); | ||
} | ||
}); | ||
|
||
@FunctionalInterface | ||
public interface PlayerJoin { | ||
void onPlayerJoin(ServerPlayerEntity player); | ||
} | ||
|
||
@FunctionalInterface | ||
public interface PlayerLeave { | ||
void onPlayerLeave(ServerPlayerEntity player, Text reason); | ||
} | ||
|
||
@FunctionalInterface | ||
public interface PlayerDeath { | ||
void onPlayerDeath(LivingEntity entity, Text reason); | ||
} | ||
|
||
@FunctionalInterface | ||
public interface PlayerAdvancement { | ||
void onPlayerAdvancement(ServerPlayerEntity player, AdvancementDisplay advancement); | ||
} | ||
|
||
@FunctionalInterface | ||
public interface DiscordMessage { | ||
void onDiscordMessage(Message message); | ||
} | ||
} | ||
package net.kings_world.discord_bridge; | ||
|
||
import dev.kord.core.entity.Message; | ||
import net.fabricmc.fabric.api.event.Event; | ||
import net.fabricmc.fabric.api.event.EventFactory; | ||
import net.minecraft.advancement.AdvancementDisplay; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.text.Text; | ||
|
||
public final class DiscordBridgeEvents { | ||
public static final Event<PlayerJoin> PLAYER_JOIN = EventFactory.createArrayBacked(PlayerJoin.class, callbacks -> player -> { | ||
for (PlayerJoin callback : callbacks) { | ||
callback.onPlayerJoin(player); | ||
} | ||
}); | ||
|
||
public static final Event<PlayerLeave> PLAYER_LEAVE = EventFactory.createArrayBacked(PlayerLeave.class, callbacks -> (player, reason) -> { | ||
for (PlayerLeave callback : callbacks) { | ||
callback.onPlayerLeave(player, reason); | ||
} | ||
}); | ||
|
||
public static final Event<PlayerDeath> PLAYER_DEATH = EventFactory.createArrayBacked(PlayerDeath.class, callbacks -> (entity, reason) -> { | ||
for (PlayerDeath callback : callbacks) { | ||
callback.onPlayerDeath(entity, reason); | ||
} | ||
}); | ||
|
||
public static final Event<PlayerAdvancement> PLAYER_ADVANCEMENT = EventFactory.createArrayBacked(PlayerAdvancement.class, callbacks -> (player, advancement) -> { | ||
for (PlayerAdvancement callback : callbacks) { | ||
callback.onPlayerAdvancement(player, advancement); | ||
} | ||
}); | ||
|
||
public static final Event<DiscordMessage> DISCORD_MESSAGE = EventFactory.createArrayBacked(DiscordMessage.class, callbacks -> message -> { | ||
for (DiscordMessage callback : callbacks) { | ||
callback.onDiscordMessage(message); | ||
} | ||
}); | ||
|
||
@FunctionalInterface | ||
public interface PlayerJoin { | ||
void onPlayerJoin(ServerPlayerEntity player); | ||
} | ||
|
||
@FunctionalInterface | ||
public interface PlayerLeave { | ||
void onPlayerLeave(ServerPlayerEntity player, Text reason); | ||
} | ||
|
||
@FunctionalInterface | ||
public interface PlayerDeath { | ||
void onPlayerDeath(LivingEntity entity, Text reason); | ||
} | ||
|
||
@FunctionalInterface | ||
public interface PlayerAdvancement { | ||
void onPlayerAdvancement(ServerPlayerEntity player, AdvancementDisplay advancement); | ||
} | ||
|
||
@FunctionalInterface | ||
public interface DiscordMessage { | ||
void onDiscordMessage(Message message); | ||
} | ||
} |
46 changes: 23 additions & 23 deletions
46
src/main/java/net/kings_world/discord_bridge/mixins/DamageTrackerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
package net.kings_world.discord_bridge.mixins; | ||
|
||
import net.kings_world.discord_bridge.DiscordBridgeEvents; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.entity.damage.DamageTracker; | ||
import net.minecraft.text.Text; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(DamageTracker.class) | ||
public class DamageTrackerMixin { | ||
@Shadow | ||
@Final | ||
private LivingEntity entity; | ||
|
||
@Inject(at = @At(value = "RETURN"), method = "getDeathMessage") | ||
private void onGetDeathMessage(CallbackInfoReturnable<Text> cir) { | ||
DiscordBridgeEvents.PLAYER_DEATH.invoker().onPlayerDeath(entity, cir.getReturnValue()); | ||
} | ||
package net.kings_world.discord_bridge.mixins; | ||
|
||
import net.kings_world.discord_bridge.DiscordBridgeEvents; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.entity.damage.DamageTracker; | ||
import net.minecraft.text.Text; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(DamageTracker.class) | ||
public class DamageTrackerMixin { | ||
@Shadow | ||
@Final | ||
private LivingEntity entity; | ||
|
||
@Inject(at = @At(value = "RETURN"), method = "getDeathMessage") | ||
private void onGetDeathMessage(CallbackInfoReturnable<Text> cir) { | ||
DiscordBridgeEvents.PLAYER_DEATH.invoker().onPlayerDeath(entity, cir.getReturnValue()); | ||
} | ||
} |
58 changes: 29 additions & 29 deletions
58
src/main/java/net/kings_world/discord_bridge/mixins/PlayerAdvancementTrackerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
package net.kings_world.discord_bridge.mixins; | ||
|
||
import net.kings_world.discord_bridge.DiscordBridge; | ||
import net.kings_world.discord_bridge.DiscordBridgeEvents; | ||
import net.minecraft.advancement.Advancement; | ||
import net.minecraft.advancement.AdvancementDisplay; | ||
import net.minecraft.advancement.PlayerAdvancementTracker; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(PlayerAdvancementTracker.class) | ||
public abstract class PlayerAdvancementTrackerMixin { | ||
@Shadow | ||
private ServerPlayerEntity owner; | ||
|
||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/PlayerManager;broadcast(Lnet/minecraft/text/Text;Z)V"), method = "grantCriterion") | ||
private void onAdvancementBroadcast(Advancement advancement, String criterionName, CallbackInfoReturnable<Boolean> cir) { | ||
AdvancementDisplay display = advancement.getDisplay(); | ||
if (display == null) { | ||
DiscordBridge.INSTANCE.getLogger().warn("Advancement " + advancement.getId().toString() + " has no display!"); | ||
return; | ||
} | ||
DiscordBridge.INSTANCE.getLogger().info(owner.getName().getString() + " unlocked " + display.getTitle().getString()); | ||
DiscordBridgeEvents.PLAYER_ADVANCEMENT.invoker().onPlayerAdvancement(owner, display); | ||
} | ||
package net.kings_world.discord_bridge.mixins; | ||
|
||
import net.kings_world.discord_bridge.DiscordBridge; | ||
import net.kings_world.discord_bridge.DiscordBridgeEvents; | ||
import net.minecraft.advancement.Advancement; | ||
import net.minecraft.advancement.AdvancementDisplay; | ||
import net.minecraft.advancement.PlayerAdvancementTracker; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(PlayerAdvancementTracker.class) | ||
public abstract class PlayerAdvancementTrackerMixin { | ||
@Shadow | ||
private ServerPlayerEntity owner; | ||
|
||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/PlayerManager;broadcast(Lnet/minecraft/text/Text;Z)V"), method = "grantCriterion") | ||
private void onAdvancementBroadcast(Advancement advancement, String criterionName, CallbackInfoReturnable<Boolean> cir) { | ||
AdvancementDisplay display = advancement.getDisplay(); | ||
if (display == null) { | ||
DiscordBridge.INSTANCE.getLogger().warn("Advancement " + advancement.getId().toString() + " has no display!"); | ||
return; | ||
} | ||
DiscordBridge.INSTANCE.getLogger().info(owner.getName().getString() + " unlocked " + display.getTitle().getString()); | ||
DiscordBridgeEvents.PLAYER_ADVANCEMENT.invoker().onPlayerAdvancement(owner, display); | ||
} | ||
} |
36 changes: 18 additions & 18 deletions
36
src/main/java/net/kings_world/discord_bridge/mixins/PlayerManagerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
package net.kings_world.discord_bridge.mixins; | ||
|
||
import net.kings_world.discord_bridge.DiscordBridgeEvents; | ||
import net.minecraft.network.ClientConnection; | ||
import net.minecraft.server.PlayerManager; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(PlayerManager.class) | ||
public class PlayerManagerMixin { | ||
@Inject(at = @At("TAIL"), method = "onPlayerConnect") | ||
private void onPlayerJoin(ClientConnection connection, ServerPlayerEntity player, CallbackInfo info) { | ||
DiscordBridgeEvents.PLAYER_JOIN.invoker().onPlayerJoin(player); | ||
} | ||
} | ||
package net.kings_world.discord_bridge.mixins; | ||
|
||
import net.kings_world.discord_bridge.DiscordBridgeEvents; | ||
import net.minecraft.network.ClientConnection; | ||
import net.minecraft.server.PlayerManager; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(PlayerManager.class) | ||
public class PlayerManagerMixin { | ||
@Inject(at = @At("TAIL"), method = "onPlayerConnect") | ||
private void onPlayerJoin(ClientConnection connection, ServerPlayerEntity player, CallbackInfo info) { | ||
DiscordBridgeEvents.PLAYER_JOIN.invoker().onPlayerJoin(player); | ||
} | ||
} |
42 changes: 21 additions & 21 deletions
42
src/main/java/net/kings_world/discord_bridge/mixins/ServerPlayNetworkHandlerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
package net.kings_world.discord_bridge.mixins; | ||
|
||
import net.kings_world.discord_bridge.DiscordBridgeEvents; | ||
import net.minecraft.server.network.ServerPlayNetworkHandler; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.text.Text; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(ServerPlayNetworkHandler.class) | ||
public class ServerPlayNetworkHandlerMixin { | ||
@Shadow | ||
public ServerPlayerEntity player; | ||
|
||
@Inject(at = @At("HEAD"), method = "onDisconnected") | ||
private void onPlayerLeave(Text reason, CallbackInfo info) { | ||
DiscordBridgeEvents.PLAYER_LEAVE.invoker().onPlayerLeave(player, reason); | ||
} | ||
package net.kings_world.discord_bridge.mixins; | ||
|
||
import net.kings_world.discord_bridge.DiscordBridgeEvents; | ||
import net.minecraft.server.network.ServerPlayNetworkHandler; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.text.Text; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(ServerPlayNetworkHandler.class) | ||
public class ServerPlayNetworkHandlerMixin { | ||
@Shadow | ||
public ServerPlayerEntity player; | ||
|
||
@Inject(at = @At("HEAD"), method = "onDisconnected") | ||
private void onPlayerLeave(Text reason, CallbackInfo info) { | ||
DiscordBridgeEvents.PLAYER_LEAVE.invoker().onPlayerLeave(player, reason); | ||
} | ||
} |
Oops, something went wrong.