1
0
mirror of https://github.com/GeyserMC/Geyser.git synced 2025-12-19 14:59:27 +00:00

Cleanup api, remove unused stored item mappings

This commit is contained in:
onebeastchris
2025-10-03 20:21:44 +02:00
parent e80863d490
commit ca23e501b4
4 changed files with 6 additions and 17 deletions

View File

@@ -65,7 +65,7 @@ public class SessionAcceptCodeOfConductEvent extends ConnectionEvent {
/**
* Sets {@link SessionAcceptCodeOfConductEvent#wasSavedElsewhere()} to {@code true}.
*/
public void setSavedElsewhere() {
public void savedElsewhere() {
this.wasSavedElsewhere = true;
}
}

View File

@@ -59,12 +59,12 @@ public final class ServerCodeOfConductEvent extends ConnectionEvent {
/**
* @return {@code true} if Geyser should not show the code of conduct to the player, because they have already accepted it
*/
public boolean hasAccepted() {
public boolean accepted() {
return hasAccepted;
}
/**
* Sets {@link ServerCodeOfConductEvent#hasAccepted()} to {@code true}.
* Sets {@link ServerCodeOfConductEvent#accepted()} to {@code true}.
*/
public void accept() {
this.hasAccepted = true;

View File

@@ -40,37 +40,25 @@ import java.util.Map;
@Getter
@Accessors(fluent = true)
public class StoredItemMappings {
private final ItemMapping banner;
private final ItemMapping barrier;
private final ItemMapping bow;
private final ItemMapping carrotOnAStick;
private final ItemMapping compass;
private final ItemMapping crossbow;
private final ItemMapping glassBottle;
private final ItemMapping milkBucket;
private final ItemMapping powderSnowBucket;
private final ItemMapping shield;
private final ItemMapping totem;
private final ItemMapping upgradeTemplate;
private final ItemMapping warpedFungusOnAStick;
private final ItemMapping wheat;
private final ItemMapping writableBook;
private final ItemMapping writtenBook;
public StoredItemMappings(Map<Item, ItemMapping> itemMappings) {
this.banner = load(itemMappings, Items.WHITE_BANNER); // As of 1.17.10, all banners have the same Bedrock ID
this.barrier = load(itemMappings, Items.BARRIER);
this.bow = load(itemMappings, Items.BOW);
this.carrotOnAStick = load(itemMappings, Items.CARROT_ON_A_STICK);
this.compass = load(itemMappings, Items.COMPASS);
this.crossbow = load(itemMappings, Items.CROSSBOW);
this.glassBottle = load(itemMappings, Items.GLASS_BOTTLE);
this.milkBucket = load(itemMappings, Items.MILK_BUCKET);
this.powderSnowBucket = load(itemMappings, Items.POWDER_SNOW_BUCKET);
this.shield = load(itemMappings, Items.SHIELD);
this.totem = load(itemMappings, Items.TOTEM_OF_UNDYING);
this.upgradeTemplate = load(itemMappings, Items.NETHERITE_UPGRADE_SMITHING_TEMPLATE);
this.warpedFungusOnAStick = load(itemMappings, Items.WARPED_FUNGUS_ON_A_STICK);
this.wheat = load(itemMappings, Items.WHEAT);
this.writableBook = load(itemMappings, Items.WRITABLE_BOOK);
this.writtenBook = load(itemMappings, Items.WRITTEN_BOOK);

View File

@@ -56,7 +56,8 @@ public class CodeOfConductManager {
GeyserImpl.getInstance().getLogger().debug("Loading codeofconducts.json");
try (Reader reader = new FileReader(savePath.toFile())) {
JsonObject object = JsonParser.parseReader(reader).getAsJsonObject();
//noinspection deprecation - otherwise 1.16.5 doesn't work
JsonObject object = new JsonParser().parse(reader).getAsJsonObject();
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
playerAcceptedCodeOfConducts.put(entry.getKey(), entry.getValue().getAsInt());
}
@@ -74,7 +75,7 @@ public class CodeOfConductManager {
public boolean hasAcceptedCodeOfConduct(GeyserSession session, String codeOfConduct) {
ServerCodeOfConductEvent event = new ServerCodeOfConductEvent(session, codeOfConduct);
session.getGeyser().getEventBus().fire(event);
return event.hasAccepted() || playerAcceptedCodeOfConducts.getInt(session.xuid()) == codeOfConduct.hashCode();
return event.accepted() || playerAcceptedCodeOfConducts.getInt(session.xuid()) == codeOfConduct.hashCode();
}
public void saveCodeOfConductAccepted(GeyserSession session, String codeOfConduct) {