use of com.minecolonies.api.colony.colonyEvents.descriptions.IColonyEventDescription in project minecolonies by ldtteam.
the class BuildingTownHall method serializeToView.
@Override
public void serializeToView(@NotNull final PacketBuffer buf) {
super.serializeToView(buf);
buf.writeBoolean(MineColonies.getConfig().getServer().canPlayerUseAllyTHTeleport.get());
buf.writeInt(permissionEvents.size());
for (final PermissionEvent event : permissionEvents) {
event.serialize(buf);
}
List<IColonyEventDescription> colonyEvents = colony.getEventDescriptionManager().getEventDescriptions();
buf.writeInt(colonyEvents.size());
for (final IColonyEventDescription event : colonyEvents) {
buf.writeUtf(event.getEventTypeId().getPath());
event.serialize(buf);
}
}
use of com.minecolonies.api.colony.colonyEvents.descriptions.IColonyEventDescription in project minecolonies by ldtteam.
the class WindowInfoPage method fillEventsList.
private void fillEventsList() {
eventList = findPaneOfTypeByID(EVENTS_LIST, ScrollingList.class);
eventList.setDataProvider(new ScrollingList.DataProvider() {
@Override
public int getElementCount() {
return permissionEvents ? building.getPermissionEvents().size() : building.getColonyEvents().size();
}
@Override
public void updateElement(final int index, @NotNull final Pane rowPane) {
final Text nameLabel = rowPane.findPaneOfTypeByID(NAME_LABEL, Text.class);
final Text actionLabel = rowPane.findPaneOfTypeByID(ACTION_LABEL, Text.class);
if (permissionEvents) {
final PermissionEvent event = building.getPermissionEvents().get(index);
nameLabel.setText(event.getName() + (event.getId() == null ? " <fake>" : ""));
rowPane.findPaneOfTypeByID(POS_LABEL, Text.class).setText(event.getPosition().getX() + " " + event.getPosition().getY() + " " + event.getPosition().getZ());
if (event.getId() == null) {
rowPane.findPaneOfTypeByID(BUTTON_ADD_PLAYER_OR_FAKEPLAYER, Button.class).hide();
}
final String name = LanguageHandler.format(KEY_TO_PERMISSIONS + event.getAction().toString().toLowerCase(Locale.US));
if (name.contains(KEY_TO_PERMISSIONS)) {
Log.getLogger().warn("Didn't work for:" + name);
return;
}
actionLabel.setText(name);
} else {
final IColonyEventDescription event = building.getColonyEvents().get(index);
if (event instanceof CitizenDiedEvent) {
actionLabel.setText(((CitizenDiedEvent) event).getDeathCause());
} else {
actionLabel.setText(event.getName());
}
if (event instanceof ICitizenEventDescription) {
nameLabel.setText(((ICitizenEventDescription) event).getCitizenName());
} else if (event instanceof IBuildingEventDescription) {
IBuildingEventDescription buildEvent = (IBuildingEventDescription) event;
nameLabel.setText(buildEvent.getBuildingName() + " " + buildEvent.getLevel());
}
rowPane.findPaneOfTypeByID(POS_LABEL, Text.class).setText(event.getEventPos().getX() + " " + event.getEventPos().getY() + " " + event.getEventPos().getZ());
rowPane.findPaneOfTypeByID(BUTTON_ADD_PLAYER_OR_FAKEPLAYER, Button.class).hide();
}
}
});
}
use of com.minecolonies.api.colony.colonyEvents.descriptions.IColonyEventDescription in project minecolonies by ldtteam.
the class EventDescriptionManager method serializeNBT.
@Override
public CompoundNBT serializeNBT() {
final CompoundNBT eventManagerNBT = new CompoundNBT();
final ListNBT eventDescsListNBT = new ListNBT();
for (final IColonyEventDescription event : eventDescs) {
final CompoundNBT eventNBT = event.serializeNBT();
eventNBT.putString(TAG_NAME, event.getEventTypeId().getPath());
eventDescsListNBT.add(eventNBT);
}
eventManagerNBT.put(TAG_EVENT_DESC_LIST, eventDescsListNBT);
return eventManagerNBT;
}
Aggregations