Skip to content

Instantly share code, notes, and snippets.

@windy1
Created October 9, 2012 23:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save windy1/3862054 to your computer and use it in GitHub Desktop.
Save windy1/3862054 to your computer and use it in GitHub Desktop.
BasicEntityProtocol
/*
* This file is part of Vanilla.
*
* Copyright (c) 2011-2012, VanillaDev <http://www.spout.org/>
* Vanilla is licensed under the SpoutDev License Version 1.
*
* Vanilla is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* In addition, 180 days after any changes are published, you can use the
* software, incorporating those changes, under the terms of the MIT license,
* as described in the SpoutDev License Version 1.
*
* Vanilla 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License,
* the MIT license and the SpoutDev License Version 1 along with this program.
* If not, see <http://www.gnu.org/licenses/> for the GNU Lesser General Public
* License and see <http://www.spout.org/SpoutDevLicenseV1.txt> for the full license,
* including the MIT license.
*/
package org.spout.vanilla.protocol.entity;
import java.util.ArrayList;
import java.util.List;
import org.spout.api.entity.Entity;
import org.spout.api.protocol.Message;
import org.spout.api.util.Parameter;
import org.spout.vanilla.protocol.msg.entity.EntityMetadataMessage;
public abstract class BasicEntityProtocol extends VanillaEntityProtocol {
protected final int typeId;
public BasicEntityProtocol(int typeId) {
this.typeId = typeId;
}
public int getTypeId() {
return typeId;
}
public List<Parameter<?>> getSpawnParameters(Entity entity) {
return new ArrayList<Parameter<?>>(0);
}
public List<Parameter<?>> getUpdateParameters(Entity entity) {
return new ArrayList<Parameter<?>>(0);
}
@Override
public final List<Message> getUpdateMessages(Entity entity) {
List<Message> messages = super.getUpdateMessages(entity);
messages.add(new EntityMetadataMessage(entity.getId(), getUpdateParameters(entity)));
return messages;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment