IdentifierSet

This commit is contained in:
Bixilon 2020-06-20 00:28:22 +02:00
parent cbfbbfd59a
commit ac240ce23b
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
3 changed files with 64 additions and 2 deletions

View File

@ -33,6 +33,16 @@ public class Identifier {
names.put(ProtocolVersion.VERSION_1_13_2, Collections.singletonList(water)); names.put(ProtocolVersion.VERSION_1_13_2, Collections.singletonList(water));
} }
public Identifier(HashMap<ProtocolVersion, List<String>> names) {
this.names = names;
}
public Identifier(IdentifierSet... sets) {
for (IdentifierSet set : sets) {
names.put(set.getKey(), set.getValue());
}
}
public Identifier(String name) { public Identifier(String name) {
names.put(Protocol.getLowestVersionSupported(), Collections.singletonList(name)); names.put(Protocol.getLowestVersionSupported(), Collections.singletonList(name));
} }

View File

@ -0,0 +1,47 @@
/*
* Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.game.datatypes;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.List;
import java.util.Map;
public class IdentifierSet implements Map.Entry<ProtocolVersion, List<String>> {
final ProtocolVersion version;
List<String> list;
public IdentifierSet(ProtocolVersion version, List<String> list) {
this.version = version;
this.list = list;
}
@Override
public ProtocolVersion getKey() {
return version;
}
@Override
public List<String> getValue() {
return list;
}
@Override
public List<String> setValue(List<String> list) {
this.list = list;
return list;
}
}

View File

@ -14,6 +14,11 @@
package de.bixilon.minosoft.game.datatypes.sounds; package de.bixilon.minosoft.game.datatypes.sounds;
import de.bixilon.minosoft.game.datatypes.Identifier; import de.bixilon.minosoft.game.datatypes.Identifier;
import de.bixilon.minosoft.game.datatypes.IdentifierSet;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.Arrays;
import java.util.Collections;
public enum Sounds { public enum Sounds {
AMBIENT_WEATHER_THUNDER(new Identifier("ambient.weather.thunder"), SoundCategories.WEATHER), AMBIENT_WEATHER_THUNDER(new Identifier("ambient.weather.thunder"), SoundCategories.WEATHER),
@ -101,7 +106,7 @@ public enum Sounds {
CROSSBOW_QUICK_CHARGE_START(new Identifier("crossbow.quick_charge.start"), SoundCategories.NEUTRAL), CROSSBOW_QUICK_CHARGE_START(new Identifier("crossbow.quick_charge.start"), SoundCategories.NEUTRAL),
CROSSBOW_QUICK_CHARGE_MIDDLE(new Identifier("crossbow.quick_charge.middle"), SoundCategories.NEUTRAL), CROSSBOW_QUICK_CHARGE_MIDDLE(new Identifier("crossbow.quick_charge.middle"), SoundCategories.NEUTRAL),
CROSSBOW_QUICK_CHARGE_END(new Identifier("crossbow.quick_charge.end"), SoundCategories.NEUTRAL), CROSSBOW_QUICK_CHARGE_END(new Identifier("crossbow.quick_charge.end"), SoundCategories.NEUTRAL),
DAMAGE_FALLBIG(new Identifier("game.player.hurt.fall.big", "damage.fallbig"), SoundCategories.PLAYER), DAMAGE_FALLBIG(new Identifier(new IdentifierSet(ProtocolVersion.VERSION_1_7_10, Arrays.asList("game.player.hurt.fall.big", "game.neutral.hurt.fall.big", "game.hostile.hurt.fall.big")), new IdentifierSet(ProtocolVersion.VERSION_1_9_4, Collections.singletonList("damage.fallbig"))), SoundCategories.PLAYER),
DAMAGE_FALLSMALL(new Identifier("damage.fallsmall"), SoundCategories.PLAYER), DAMAGE_FALLSMALL(new Identifier("damage.fallsmall"), SoundCategories.PLAYER),
ELYTRA_LOOP(new Identifier("elytra.loop"), SoundCategories.NEUTRAL), ELYTRA_LOOP(new Identifier("elytra.loop"), SoundCategories.NEUTRAL),
GAME_PLAYER_ATTACK_NODAMAGE(new Identifier("game.player.attack.nodamage"), SoundCategories.OTHER), GAME_PLAYER_ATTACK_NODAMAGE(new Identifier("game.player.attack.nodamage"), SoundCategories.OTHER),
@ -607,7 +612,7 @@ public enum Sounds {
BLOCK_BEEHIVE_SHEAR(new Identifier("block.beehive.shear"), SoundCategories.BLOCK), BLOCK_BEEHIVE_SHEAR(new Identifier("block.beehive.shear"), SoundCategories.BLOCK),
BLOCK_BEEHIVE_WORK(new Identifier("block.beehive.work"), SoundCategories.BLOCK), BLOCK_BEEHIVE_WORK(new Identifier("block.beehive.work"), SoundCategories.BLOCK),
BLOCK_BEEHIVE_DRIP(new Identifier("block.beehive.drip"), SoundCategories.BLOCK); BLOCK_BEEHIVE_DRIP(new Identifier("block.beehive.drip"), SoundCategories.BLOCK);
//ToDo add legacy names //ToDo complete per version
final Identifier identifier; final Identifier identifier;