[BLIND] Add a patch for WATER_LILY activating with ViaVersion.
This commit is contained in:
parent
8cecf92eff
commit
04d5253732
|
@ -0,0 +1,16 @@
|
|||
package fr.neatmonster.nocheatplus.compat.blocks;
|
||||
|
||||
import fr.neatmonster.nocheatplus.components.registry.activation.IDescriptiveActivation;
|
||||
|
||||
/**
|
||||
* A "patch", only applied if isAvailable() returns true - class construction
|
||||
* and testing functions should be fail-safe. The neutral description will
|
||||
* always be logged, if an item activates, advertise() might not be of
|
||||
* relevance.
|
||||
*
|
||||
* @author asofold
|
||||
*
|
||||
*/
|
||||
public interface IPatchBlockPropertiesSetup extends BlockPropertiesSetup, IDescriptiveActivation {
|
||||
|
||||
}
|
|
@ -19,13 +19,16 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
|
||||
import fr.neatmonster.nocheatplus.compat.blocks.BlockPropertiesSetup;
|
||||
import fr.neatmonster.nocheatplus.compat.blocks.IPatchBlockPropertiesSetup;
|
||||
import fr.neatmonster.nocheatplus.compat.blocks.init.vanilla.special.MultiClientProtocolWaterLilyPatch;
|
||||
import fr.neatmonster.nocheatplus.components.registry.activation.IActivation;
|
||||
import fr.neatmonster.nocheatplus.config.WorldConfigProvider;
|
||||
import fr.neatmonster.nocheatplus.logging.StaticLog;
|
||||
|
||||
public class VanillaBlocksFactory {
|
||||
|
||||
public Collection<String> setupVanillaBlocks(final WorldConfigProvider<?> worldConfigProvider) {
|
||||
// Standard setups (abort with first failure, low to high MC version).
|
||||
// Vanilla blocks (abort with first failure, low to high MC version).
|
||||
final List<BlockPropertiesSetup> setups = new LinkedList<BlockPropertiesSetup>();
|
||||
final List<String> success = new LinkedList<String>();
|
||||
try{
|
||||
|
@ -52,6 +55,25 @@ public class VanillaBlocksFactory {
|
|||
break;
|
||||
}
|
||||
}
|
||||
// Patches for special circumstances.
|
||||
for (IPatchBlockPropertiesSetup patch : new IPatchBlockPropertiesSetup[]{
|
||||
new MultiClientProtocolWaterLilyPatch(),
|
||||
}) {
|
||||
try {
|
||||
if (patch.isAvailable()) {
|
||||
patch.setupBlockProperties(worldConfigProvider);
|
||||
String description = patch.getNeutralDescription();
|
||||
if (description == null || description.isEmpty()) {
|
||||
description = patch.getClass().getSimpleName();
|
||||
}
|
||||
StaticLog.logInfo("BlockProperties patch applied: " + description);
|
||||
}
|
||||
}
|
||||
catch (Throwable t) {
|
||||
StaticLog.logSevere(patch.getClass().getSimpleName() + " could not be processed: " + t.getClass().getSimpleName() + " - " + t.getMessage());
|
||||
StaticLog.logSevere(t);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
package fr.neatmonster.nocheatplus.compat.blocks.init.vanilla.special;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import fr.neatmonster.nocheatplus.compat.blocks.IPatchBlockPropertiesSetup;
|
||||
import fr.neatmonster.nocheatplus.components.registry.activation.Activation;
|
||||
import fr.neatmonster.nocheatplus.config.WorldConfigProvider;
|
||||
import fr.neatmonster.nocheatplus.utilities.map.BlockFlags;
|
||||
import fr.neatmonster.nocheatplus.utilities.map.BlockProperties;
|
||||
|
||||
/**
|
||||
* WATER_LILY for multi client protocol support between 1.7.x - 1.11.x.
|
||||
*
|
||||
* @author asofold
|
||||
*
|
||||
*/
|
||||
public class MultiClientProtocolWaterLilyPatch implements IPatchBlockPropertiesSetup {
|
||||
// TODO: Later just dump these into the generic registry (on activation), let BlockProperties fetch.
|
||||
|
||||
private final Activation activation = new Activation()
|
||||
.neutralDescription("WATER_LILY block shape patch for multi client protocol support around 1.7.x - 1.11.x.")
|
||||
.advertise(true)
|
||||
.pluginExist("ViaVersion")
|
||||
// TODO: Other/More ?
|
||||
;
|
||||
|
||||
@Override
|
||||
public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider) {
|
||||
BlockFlags.addFlags(Material.WATER_LILY,
|
||||
BlockProperties.F_GROUND | BlockProperties.F_HEIGHT8_1 | BlockProperties.F_GROUND_HEIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return activation.isAvailable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNeutralDescription() {
|
||||
return activation.getNeutralDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean advertise() {
|
||||
return activation.advertise();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue