Reflection actually demanded ImmutableList so revert to that
This commit is contained in:
parent
04f6ae211f
commit
05b632e8d5
@ -0,0 +1,58 @@
|
||||
package com.massivecraft.massivecore.item;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableList.Builder;
|
||||
|
||||
public class ConverterListImmutable<EX, EY> extends Converter<Iterable<EX>, ImmutableList<EY>>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// FIELD
|
||||
// -------------------------------------------- //
|
||||
|
||||
private final Converter<EX, EY> converterElement;
|
||||
public Converter<EX, EY> getConverterElement() { return this.converterElement; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CREATE
|
||||
// -------------------------------------------- //
|
||||
|
||||
public ConverterListImmutable(Converter<EX, EY> converterElement)
|
||||
{
|
||||
this.converterElement = converterElement;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public ImmutableList<EY> convert(Iterable<EX> exs)
|
||||
{
|
||||
// Null
|
||||
if (exs == null) return null;
|
||||
|
||||
// Create
|
||||
Builder<EY> eys = ImmutableList.builder();
|
||||
|
||||
// Fill
|
||||
for (EX ex : exs)
|
||||
{
|
||||
EY ey = null;
|
||||
try
|
||||
{
|
||||
ey = this.getConverterElement().convert(ex);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
t.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
|
||||
eys.add(ey);
|
||||
}
|
||||
|
||||
// Return
|
||||
return eys.build();
|
||||
}
|
||||
|
||||
}
|
@ -2,7 +2,7 @@ package com.massivecraft.massivecore.item;
|
||||
|
||||
import org.bukkit.Color;
|
||||
|
||||
public class ConverterToColors extends ConverterList<Integer, Color>
|
||||
public class ConverterToColors extends ConverterListImmutable<Integer, Color>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
|
@ -1,11 +1,12 @@
|
||||
package com.massivecraft.massivecore.item;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class WriterFireworkEffectColors extends WriterAbstractFireworkEffect<List<Integer>, List<Color>>
|
||||
public class WriterFireworkEffectColors extends WriterAbstractFireworkEffect<List<Integer>, ImmutableList<Color>>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
@ -37,9 +38,9 @@ public class WriterFireworkEffectColors extends WriterAbstractFireworkEffect<Lis
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Color> getB(FireworkEffect cb, Object d)
|
||||
public ImmutableList<Color> getB(FireworkEffect cb, Object d)
|
||||
{
|
||||
return cb.getColors();
|
||||
return (ImmutableList<Color>) cb.getColors();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
package com.massivecraft.massivecore.item;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class WriterFireworkEffectFadeColors extends WriterAbstractFireworkEffect<List<Integer>, List<Color>>
|
||||
public class WriterFireworkEffectFadeColors extends WriterAbstractFireworkEffect<List<Integer>, ImmutableList<Color>>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
@ -37,9 +38,9 @@ public class WriterFireworkEffectFadeColors extends WriterAbstractFireworkEffect
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Color> getB(FireworkEffect cb, Object d)
|
||||
public ImmutableList<Color> getB(FireworkEffect cb, Object d)
|
||||
{
|
||||
return cb.getFadeColors();
|
||||
return (ImmutableList<Color>) cb.getFadeColors();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user