use of net.minecraft.server.v1_14_R1.Path in project dishevelled by heuermh.
the class AssemblyModel method setPath.
/**
* Set the selected path for this assembly model to <code>path</code>.
*
* <p>This is a bound property.</p>
*
* @param path selected path for this assembly model, if any
*/
void setPath(final Path path) {
Path oldPath = this.path;
this.path = path;
traversals.clear();
if (this.path != null && traversalsByPath.containsKey(path)) {
traversals.addAll(traversalsByPath.get(path));
}
propertyChangeSupport.firePropertyChange("path", oldPath, this.path);
}
use of net.minecraft.server.v1_14_R1.Path in project dishevelled-bio by heuermh.
the class ReassemblePaths method call.
@Override
public Integer call() throws Exception {
BufferedReader reader = null;
PrintWriter writer = null;
try {
reader = reader(inputGfa1File);
writer = writer(outputGfa1File);
final PrintWriter w = writer;
final List<Path> paths = new ArrayList<Path>();
final ListMultimap<String, Traversal> traversalsByPathName = ArrayListMultimap.create();
Gfa1Reader.stream(reader, new Gfa1Listener() {
@Override
public boolean record(final Gfa1Record gfa1Record) {
if (gfa1Record instanceof Path) {
Path path = (Path) gfa1Record;
paths.add(path);
} else if (gfa1Record instanceof Traversal) {
Traversal traversal = (Traversal) gfa1Record;
traversalsByPathName.put(traversal.getPathName(), traversal);
} else {
Gfa1Writer.write(gfa1Record, w);
}
return true;
}
});
for (Path path : paths) {
List<Traversal> traversals = traversalsByPathName.get(path.getName());
Collections.sort(traversals, new Comparator<Traversal>() {
@Override
public int compare(final Traversal t0, final Traversal t1) {
return t0.getOrdinal() - t1.getOrdinal();
}
});
List<Reference> segments = new ArrayList<Reference>();
List<String> overlaps = new ArrayList<String>();
for (Traversal traversal : traversals) {
if (segments.isEmpty()) {
segments.add(traversal.getSource());
}
segments.add(traversal.getTarget());
if (traversal.hasOverlap()) {
overlaps.add(traversal.getOverlap());
}
}
Gfa1Writer.write(new Path(path.getName(), segments, overlaps.isEmpty() ? null : overlaps, path.getAnnotations()), w);
}
return 0;
} finally {
try {
reader.close();
} catch (Exception e) {
// ignore
}
try {
writer.close();
} catch (Exception e) {
// ignore
}
}
}
use of net.minecraft.server.v1_14_R1.Path in project dishevelled-bio by heuermh.
the class TruncatePaths method call.
@Override
public Integer call() throws Exception {
BufferedReader reader = null;
PrintWriter writer = null;
try {
reader = reader(inputGfa1File);
writer = writer(outputGfa1File);
final PrintWriter w = writer;
Gfa1Reader.stream(reader, new Gfa1Listener() {
@Override
public boolean record(final Gfa1Record gfa1Record) {
if (gfa1Record instanceof Path) {
Path path = (Path) gfa1Record;
Gfa1Writer.write(new Path(path.getName(), EMPTY_SEGMENTS, null, path.getAnnotations()), w);
} else {
Gfa1Writer.write(gfa1Record, w);
}
return true;
}
});
return 0;
} finally {
try {
reader.close();
} catch (Exception e) {
// ignore
}
try {
writer.close();
} catch (Exception e) {
// ignore
}
}
}
use of net.minecraft.server.v1_14_R1.Path in project SilkSpawners by timbru31.
the class NMSHandler method setMobNameOfSpawner.
@Override
public boolean setMobNameOfSpawner(final BlockState blockState, final String mobID) {
// Prevent ResourceKeyInvalidException: Non [a-z0-9/._-] character in path of location
final String safeMobID = caseFormatOf(mobID.replace(" ", "_")).to(CaseFormat.LOWER_UNDERSCORE, mobID.replace(" ", "_")).toLowerCase(Locale.ENGLISH);
final CraftCreatureSpawner spawner = (CraftCreatureSpawner) blockState;
try {
final TileEntityMobSpawner tile = (TileEntityMobSpawner) tileField.get(spawner);
tile.getSpawner().setMobName(IRegistry.ENTITY_TYPE.get(new MinecraftKey(safeMobID)));
return true;
} catch (IllegalArgumentException | IllegalAccessException e) {
Bukkit.getLogger().warning("[SilkSpawners] Reflection failed: " + e.getMessage());
e.printStackTrace();
}
return false;
}
Aggregations