Skip to content

Commit

Permalink
feat: 1.21
Browse files Browse the repository at this point in the history
Took 1 hour 41 minutes
  • Loading branch information
Swofty-Developments committed Jun 23, 2024
1 parent a87ebb8 commit 1e94518
Show file tree
Hide file tree
Showing 36 changed files with 85 additions and 72 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[<img src="https://discordapp.com/assets/e4923594e694a21542a489471ecffa50.svg" alt="" height="55" />](https://discord.gg/atlasmc)

A 1.8 to 1.20.4 recreation of HypixelSkyBlock utilizing Minestom, with the intention of actually having a properly abstracted, scalable codebase.
A 1.8 to 1.21 recreation of HypixelSkyBlock utilizing Minestom, with the intention of actually having a properly abstracted, scalable codebase.

#### Releases

Expand Down Expand Up @@ -33,7 +33,7 @@ A video of me going through the guide [can be found here](https://www.youtube.co

### Proxy Setup Guide
1. Download 'SkyBlockProxy.jar' from the releases page [here](https://github.com/Swofty-Developments/HypixelSkyBlock/releases/tag/latest)
2. Download the Velocity proxy from [here](https://api.papermc.io/v2/projects/velocity/versions/3.3.0-SNAPSHOT/builds/388/downloads/velocity-3.3.0-SNAPSHOT-388.jar)
2. Download the Velocity proxy from [here](https://api.papermc.io/v2/projects/velocity/versions/3.3.0-SNAPSHOT/builds/400/downloads/velocity-3.3.0-SNAPSHOT-400.jar)
3. Download `velocity.toml` from [here](https://github.com/Swofty-Developments/HypixelSkyBlock/tree/master/configuration) and move it to where you want your Proxy server to run.
4. Move your Velocity proxy JAR into that folder aswell, and run the proxy using `java -jar velocity-3.3.0-SNAPSHOT-316.jar` as a command in that directory.
5. Close this proxy once it has generated the `plugins` folder, just by pressing `CTRL + C` or closing the CMD Prompt.
Expand Down
2 changes: 1 addition & 1 deletion commons/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ java {

dependencies {
implementation(project(":packer"))
implementation("com.github.Minestom:Minestom:914ddd8dc6") {
implementation("com.github.Minestom:Minestom:277dceacf1") {
exclude(group = "org.jboss.shrinkwrap.resolver", module = "shrinkwrap-resolver-depchain")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public enum MinecraftVersion {
MINECRAFT_1_20_2(764, new String[]{"1.20.2"}),
MINECRAFT_1_20_3(765, new String[]{"1.20.3", "1.20.4"}),
MINECRAFT_1_20_5(766, new String[]{"1.20.5", "1.20.6"}),
MINECRAFT_1_21(767, new String[]{"1.21", "1.21.1"}),
;

private final int protocol;
Expand Down
4 changes: 2 additions & 2 deletions loader/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ dependencies {
implementation(project(":proxy.api"))
implementation(project(":spark"))
implementation("org.slf4j:slf4j-api:2.0.13")
implementation("com.github.Minestom:Minestom:914ddd8dc6") {
implementation("com.github.Minestom:Minestom:277dceacf1") {
exclude(group = "org.jboss.shrinkwrap.resolver", module = "shrinkwrap-resolver-depchain")
}
implementation("dev.hollowcube:polar:1.7.2")
implementation("dev.hollowcube:polar:1.10.0")
}

application {
Expand Down
2 changes: 1 addition & 1 deletion loader/src/main/java/net/swofty/loader/SkyBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,6 @@ private static void checkProxyConnected(Scheduler scheduler) {
}, TaskSchedule.tick(4), TaskSchedule.stop());

return TaskSchedule.seconds(1);
} , ExecutionType.ASYNC);
} , ExecutionType.TICK_END);
}
}
2 changes: 1 addition & 1 deletion proxy.api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repositories {
dependencies {
implementation(project(":commons"))
implementation("com.github.Swofty-Developments:AtlasRedisAPI:1.1.2")
implementation("com.github.Minestom:Minestom:914ddd8dc6") {
implementation("com.github.Minestom:Minestom:277dceacf1") {
exclude(group = "org.jboss.shrinkwrap.resolver", module = "shrinkwrap-resolver-depchain")
}
implementation("net.kyori:adventure-api:4.17.0")
Expand Down
6 changes: 5 additions & 1 deletion proxy.api/src/main/java/net/swofty/proxyapi/ProxyPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ public CompletableFuture<MinecraftVersion> getVersion() {
json.put("actions", "version");

RedisMessage.sendMessageToProxy("player-handler", json.toString(), (s) -> {
future.complete(MinecraftVersion.byProtocolId(Integer.parseInt(s)));
try {
future.complete(MinecraftVersion.byProtocolId(Integer.parseInt(s)));
} catch (Exception e) {
future.complete(MinecraftVersion.MINECRAFT_1_21);
} // ViaVersion is disabled
});

return future;
Expand Down
Binary file modified server/proxy/velocity.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion spark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repositories {
}

dependencies {
implementation("com.github.Minestom:Minestom:914ddd8dc6") {
implementation("com.github.Minestom:Minestom:277dceacf1") {
exclude(group = "org.jboss.shrinkwrap.resolver", module = "shrinkwrap-resolver-depchain")
}
implementation(files("dependencies/spark-1.10.1.10-minestom.jar"))
Expand Down
2 changes: 1 addition & 1 deletion spark/src/main/java/net/swofty/spark/Spark.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public Stream<? extends CommandSender> getCommandSenders() {

@Override
public void executeAsync(Runnable runnable) {
MinecraftServer.getSchedulerManager().scheduleNextTick(runnable, ExecutionType.ASYNC);
MinecraftServer.getSchedulerManager().scheduleNextTick(runnable, ExecutionType.TICK_END);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions type.generic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ dependencies {
implementation(project(":commons"))
implementation(project(":packer"))
implementation(project(":proxy.api"))
implementation("com.github.Minestom:Minestom:914ddd8dc6") {
implementation("com.github.Minestom:Minestom:277dceacf1") {
exclude(group = "org.jboss.shrinkwrap.resolver", module = "shrinkwrap-resolver-depchain")
}
implementation("dev.hollowcube:polar:1.9.5")
implementation("dev.hollowcube:polar:1.10.0")
}

tasks.withType<JavaCompile> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ public void initialize(MinecraftServer server) {
SkyBlockRegion.cacheRegions();
SkyBlockMiningConfiguration.startRepeater(MinecraftServer.getSchedulerManager());
MinecraftServer.getDimensionTypeRegistry().register(
DimensionType.builder(NamespaceID.from("skyblock:island"))
NamespaceID.from("skyblock:island"),
DimensionType.builder()
.ambientLight(2)
.build());
SkyBlockIsland.runVacantLoop(MinecraftServer.getSchedulerManager());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,18 +231,23 @@ public enum Data {
}, (player, datapoint) -> {
SkyBlockInventory skyBlockInventory = (SkyBlockInventory) datapoint.getValue();

player.setHelmet(skyBlockInventory.getHelmet().getItemStack());
player.setChestplate(skyBlockInventory.getChestplate().getItemStack());
player.setLeggings(skyBlockInventory.getLeggings().getItemStack());
player.setBoots(skyBlockInventory.getBoots().getItemStack());
player.setHelmet(new SkyBlockItem(skyBlockInventory.getHelmet()).getItemStack());
player.setChestplate(new SkyBlockItem(skyBlockInventory.getChestplate()).getItemStack());
player.setLeggings(new SkyBlockItem(skyBlockInventory.getLeggings()).getItemStack());
player.setBoots(new SkyBlockItem(skyBlockInventory.getBoots()).getItemStack());

skyBlockInventory.getItems().forEach((integer, itemStack) -> {
skyBlockInventory.getItems().forEach((integer, understandableSkyBlockItem) -> {
PlayerItemOrigin origin = PlayerItemOrigin.INVENTORY_SLOT;
origin.setData(integer);

player.getInventory().setItemStack(integer, itemStack.getItemStack());
player.getInventory().setItemStack(integer, new SkyBlockItem(understandableSkyBlockItem).getItemStack());

ItemStack loadedItem = PlayerItemUpdater.playerUpdate(
player,
new SkyBlockItem(understandableSkyBlockItem).getItemStack(),
true
).build();

ItemStack loadedItem = PlayerItemUpdater.playerUpdate(player, itemStack.getItemStack(), true).build();
origin.setStack(player, loadedItem);
});

Expand All @@ -254,25 +259,25 @@ public enum Data {

ItemStack helmet = player.getHelmet();
if (SkyBlockItem.isSkyBlockItem(helmet)) {
skyBlockInventory.setHelmet(new SkyBlockItem(helmet));
skyBlockInventory.setHelmet(new SkyBlockItem(helmet).toUnderstandable());
}
ItemStack chestplate = player.getChestplate();
if (SkyBlockItem.isSkyBlockItem(chestplate)) {
skyBlockInventory.setChestplate(new SkyBlockItem(chestplate));
skyBlockInventory.setChestplate(new SkyBlockItem(chestplate).toUnderstandable());
}
ItemStack leggings = player.getLeggings();
if (SkyBlockItem.isSkyBlockItem(leggings)) {
skyBlockInventory.setLeggings(new SkyBlockItem(leggings));
skyBlockInventory.setLeggings(new SkyBlockItem(leggings).toUnderstandable());
}
ItemStack boots = player.getBoots();
if (SkyBlockItem.isSkyBlockItem(boots)) {
skyBlockInventory.setBoots(new SkyBlockItem(boots));
skyBlockInventory.setBoots(new SkyBlockItem(boots).toUnderstandable());
}

for (int i = 0; i <= 36; i++) {
ItemStack stack = player.getInventory().getItemStack(i);
if (SkyBlockItem.isSkyBlockItem(stack)) {
skyBlockInventory.getItems().put(i, new SkyBlockItem(stack));
skyBlockInventory.getItems().put(i, new SkyBlockItem(stack).toUnderstandable());
}
}
return new DatapointInventory("inventory", skyBlockInventory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
import net.swofty.commons.item.UnderstandableSkyBlockItem;
import net.swofty.types.generic.data.Datapoint;
import net.swofty.types.generic.item.SkyBlockItem;
import net.swofty.commons.protocol.serializers.InventorySerializer;
Expand All @@ -25,7 +26,7 @@ public DatapointBackpacks(String key) {
@Getter
@JsonIgnoreProperties(ignoreUnknown = true)
public static class PlayerBackpacks {
private final Map<Integer, SkyBlockItem> backpacks;
private final Map<Integer, UnderstandableSkyBlockItem> backpacks;
@Setter
private int unlockedSlots;

Expand All @@ -34,7 +35,7 @@ public PlayerBackpacks() {
this.unlockedSlots = 1;
}

public PlayerBackpacks(Map<Integer, SkyBlockItem> backpacks, int unlockedSlots) {
public PlayerBackpacks(Map<Integer, UnderstandableSkyBlockItem> backpacks, int unlockedSlots) {
this.backpacks = backpacks;
this.unlockedSlots = unlockedSlots;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.swofty.types.generic.event.actions.custom;

import net.minestom.server.entity.attribute.Attribute;
import net.minestom.server.potion.Potion;
import net.minestom.server.potion.PotionEffect;
import net.swofty.types.generic.SkyBlockConst;
Expand All @@ -17,7 +18,6 @@ public void run(PlayerRegionChangeEvent event) {

if (SkyBlockConst.isIslandServer()) return;

if (!player.getActiveEffects().stream().map(f -> f.potion().effect()).toList().contains(PotionEffect.MINING_FATIGUE))
player.addEffect(new Potion(PotionEffect.MINING_FATIGUE, (byte) 255, 9999999));
player.getAttribute(Attribute.PLAYER_MINING_EFFICIENCY).setBaseValue(0D);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.kyori.adventure.text.Component;
import net.minestom.server.entity.Player;
import net.minestom.server.event.Event;
import net.minestom.server.event.player.PlayerSpawnEvent;
import net.minestom.server.network.packet.server.play.TeamsPacket;
import net.swofty.types.generic.SkyBlockGenericLoader;
Expand All @@ -27,6 +26,8 @@ public void run(PlayerSpawnEvent event) {
Rank player2Rank = player2.getDataHandler().get(DataHandler.Data.RANK, DatapointRank.class).getValue();
Rank playerRank = ((SkyBlockPlayer) player).getDataHandler().get(DataHandler.Data.RANK, DatapointRank.class).getValue();

if (player2.getUuid().equals(player.getUuid())) return;

player2.sendPacket(new TeamsPacket("ZZZZZ" + player.getUsername(), new TeamsPacket.CreateTeamAction(
Component.text(playerRank.getPrefix()),
(byte) 0x01,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minestom.server.inventory.click.ClickType;
import net.minestom.server.item.ItemStack;
import net.minestom.server.item.Material;
import net.swofty.commons.item.UnderstandableSkyBlockItem;
import net.swofty.types.generic.data.DataHandler;
import net.swofty.types.generic.data.datapoints.DatapointBackpacks;
import net.swofty.types.generic.data.datapoints.DatapointStorage;
Expand Down Expand Up @@ -100,7 +101,7 @@ public ItemStack.Builder getItem(SkyBlockPlayer player) {
DataHandler.Data.BACKPACKS, DatapointBackpacks.class
).getValue();

Map<Integer, SkyBlockItem> backpackItems = backpacks.getBackpacks();
Map<Integer, UnderstandableSkyBlockItem> backpackItems = backpacks.getBackpacks();

for (int backpack_slot = 27; backpack_slot <= 44; backpack_slot++) {
int slot = backpack_slot - 26;
Expand Down Expand Up @@ -138,7 +139,7 @@ public void runPost(InventoryClickEvent e2, SkyBlockPlayer player) {
if (item.isNA()) return;
if (!(item.getGenericInstance() instanceof Backpack)) return;

backpackItems.put(slot, item);
backpackItems.put(slot, item.toUnderstandable());
player.getDataHandler().get(DataHandler.Data.BACKPACKS, DatapointBackpacks.class).setValue(
new DatapointBackpacks.PlayerBackpacks(backpackItems, backpacks.getUnlockedSlots())
);
Expand All @@ -161,7 +162,7 @@ public ItemStack.Builder getItem(SkyBlockPlayer player) {
continue;
}

SkyBlockItem item = backpackItems.get(slot);
SkyBlockItem item = new SkyBlockItem(backpackItems.get(slot));

set(new GUIClickableItem(backpack_slot) {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public void onOpen(InventoryGUIOpenEvent e) {
@Override
public void run(InventoryPreClickEvent e, SkyBlockPlayer player) {
new GUIStorageBackpackPage(data.getHighestBackpackSlot(),
data.getBackpacks().get(data.getHighestBackpackSlot())).open(player);
new SkyBlockItem(data.getBackpacks().get(data.getHighestBackpackSlot()))
).open(player);
}

@Override
Expand All @@ -67,7 +68,7 @@ public ItemStack.Builder getItem(SkyBlockPlayer player) {
set(new GUIClickableItem(7) {
@Override
public void run(InventoryPreClickEvent e, SkyBlockPlayer player) {
new GUIStorageBackpackPage(page + 1, data.getBackpacks().get(page + 1)).open(player);
new GUIStorageBackpackPage(page + 1, new SkyBlockItem(data.getBackpacks().get(page + 1))).open(player);
}

@Override
Expand All @@ -81,7 +82,7 @@ public ItemStack.Builder getItem(SkyBlockPlayer player) {
set(new GUIClickableItem(5) {
@Override
public void run(InventoryPreClickEvent e, SkyBlockPlayer player) {
new GUIStorageBackpackPage(data.getLowestBackpackSlot(), data.getBackpacks().get(data.getLowestBackpackSlot())).open(player);
new GUIStorageBackpackPage(data.getLowestBackpackSlot(), new SkyBlockItem(data.getBackpacks().get(data.getLowestBackpackSlot()))).open(player);
}

@Override
Expand All @@ -95,7 +96,7 @@ public ItemStack.Builder getItem(SkyBlockPlayer player) {
set(new GUIClickableItem(6) {
@Override
public void run(InventoryPreClickEvent e, SkyBlockPlayer player) {
new GUIStorageBackpackPage(page - 1, data.getBackpacks().get(page - 1)).open(player);
new GUIStorageBackpackPage(page - 1, new SkyBlockItem(data.getBackpacks().get(page - 1))).open(player);
}

@Override
Expand Down Expand Up @@ -139,7 +140,7 @@ public void onClose(InventoryCloseEvent e, CloseReason reason) {
item.getAttributeHandler().getBackpackData().items().add(new SkyBlockItem(getInventory().getItemStack(i)).toUnderstandable());
}

getPlayer().getDataHandler().get(DataHandler.Data.BACKPACKS, DatapointBackpacks.class).getValue().getBackpacks().put(page, item);
getPlayer().getDataHandler().get(DataHandler.Data.BACKPACKS, DatapointBackpacks.class).getValue().getBackpacks().put(page, item.toUnderstandable());
}

@Override
Expand All @@ -150,7 +151,7 @@ public void suddenlyQuit(Inventory inventory, SkyBlockPlayer player) {
item.getAttributeHandler().getBackpackData().items().add(new SkyBlockItem(getInventory().getItemStack(i)).toUnderstandable());
}

getPlayer().getDataHandler().get(DataHandler.Data.BACKPACKS, DatapointBackpacks.class).getValue().getBackpacks().put(page, item);
getPlayer().getDataHandler().get(DataHandler.Data.BACKPACKS, DatapointBackpacks.class).getValue().getBackpacks().put(page, item.toUnderstandable());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public List<Ability> getAbilities() {

@Override
public @NotNull AbilityActivation getAbilityActivation() {
return null;
return AbilityActivation.RIGHT_CLICK;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void start() {
exception.printStackTrace();
}
return TaskSchedule.tick(3);
}, ExecutionType.ASYNC);
}, ExecutionType.TICK_END);
}

private void minionLoop() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,15 @@ public boolean addViewer(@NotNull Player player) {
@Override
public boolean removeViewer(@NotNull Player player) {
final boolean result = this.viewers.remove(player);
if (!result) return false;

ScoreboardObjectivePacket scoreboardObjectivePacket = this.getDestructionObjectivePacket();
player.sendPacket(scoreboardObjectivePacket);
for (ScoreboardLine line : lines) {
player.sendPacket(line.getScoreDestructionPacket(objectiveName)); // Is it necessary?
player.sendPacket(line.sidebarTeam.getDestructionPacket());
}
return result;
return true;
}

@NotNull
Expand Down Expand Up @@ -381,7 +383,6 @@ private void refreshContent(Component content) {
* This class is used to create a team for the {@link SwoftySidebar}
*/
private static class SidebarTeam {

private final String teamName;
private Component prefix, suffix;
private final String entityName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public <R extends ServerAttribute<T>, T> R get(Attributes attribute, Class<R> ty
public static void saveAttributeLoop() {
MinecraftServer.getSchedulerManager().scheduleTask(() -> {
AttributeDatabase.saveDocument(toDocument());
}, TaskSchedule.seconds(3), TaskSchedule.seconds(3) , ExecutionType.ASYNC);
}, TaskSchedule.seconds(3), TaskSchedule.seconds(3) , ExecutionType.TICK_END);
}

public enum Attributes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@ public void runScheduler(Scheduler scheduler) {
} catch (Exception e) {}
});
});
}, TaskSchedule.seconds(5), TaskSchedule.seconds(3), ExecutionType.ASYNC);
}, TaskSchedule.seconds(5), TaskSchedule.seconds(3), ExecutionType.TICK_END);
}
}
Loading

0 comments on commit 1e94518

Please sign in to comment.