rmichela cd732ee3f7 [Bleeding] Added a Metadata framework for Entities, Blocks, and Worlds
This metadata implementation has the following features:

- All metadata is lazy. Metadata values are not actually computed until another plugin requests them. Memory and CPU are conserved by not computing and storing unnecessary metadata values.

- All metadata is cached. Once a metadata value is computed its value is cached in the metadata store to prevent further unnecessary computation. An invalidation mechanism is provided to flush the cache and force recompilation of metadata values.

- All metadata is stored in basic data types. Convenience methods in the MetadataValue class allow for the conversion of metadata data types when possible. Restricting metadata to basic data types prevents the accidental linking of large object graphs into metadata. Metadata is persistent across the lifetime of the application and adding large object graphs would damage garbage collector performance.

- Metadata access is thread safe. Care has been taken to protect the internal data structures and access them in a thread safe manner.

- Metadata is exposed for all objects that descend from Entity, Block, and World. All Entity and World metadata is stored at the Server  level and all Block metadata is stored at the World level.

- Metadata is NOT keyed on references to original objects - instead metadata is keyed off of unique fields within those objects. Doing this allows metadata to exist for blocks that are in chunks not currently in memory. Additionally, Player objects are keyed off of player name so that Player metadata remains consistent between logins.

- Metadata convenience methods have been added to all Entities, Players, Blocks, BlockStates, and World allowing direct access to an individual instance's metadata.

- Players and OfflinePlayers share a single metadata store, allowing player metadata to be manipulated regardless of the player's current online status.
2012-02-29 19:16:04 +01:00

131 lines
3.5 KiB
Java

package org.bukkit.plugin.messaging;
import java.io.File;
import java.io.InputStream;
import org.bukkit.Server;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginLoader;
import org.bukkit.plugin.PluginLogger;
import com.avaje.ebean.EbeanServer;
public class TestPlugin extends Plugin {
private boolean enabled = true;
final private String pluginName;
public TestPlugin(String pluginName) {
this.pluginName = pluginName;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public String getName() {
return pluginName;
}
public File getDataFolder() {
throw new UnsupportedOperationException("Not supported.");
}
public PluginDescriptionFile getDescription() {
return new PluginDescriptionFile(pluginName, "1.0", "test.test");
}
public FileConfiguration getConfig() {
throw new UnsupportedOperationException("Not supported.");
}
public InputStream getResource(String filename) {
throw new UnsupportedOperationException("Not supported.");
}
public void saveConfig() {
throw new UnsupportedOperationException("Not supported.");
}
public void saveDefaultConfig() {
throw new UnsupportedOperationException("Not supported.");
}
public void saveResource(String resourcePath, boolean replace) {
throw new UnsupportedOperationException("Not supported.");
}
public void reloadConfig() {
throw new UnsupportedOperationException("Not supported.");
}
public PluginLogger getLogger() {
throw new UnsupportedOperationException("Not supported.");
}
public PluginLoader getPluginLoader() {
throw new UnsupportedOperationException("Not supported.");
}
public Server getServer() {
throw new UnsupportedOperationException("Not supported.");
}
public boolean isEnabled() {
return enabled;
}
public void onDisable() {
throw new UnsupportedOperationException("Not supported.");
}
public void onLoad() {
throw new UnsupportedOperationException("Not supported.");
}
public void onEnable() {
throw new UnsupportedOperationException("Not supported.");
}
public boolean isNaggable() {
throw new UnsupportedOperationException("Not supported.");
}
public void setNaggable(boolean canNag) {
throw new UnsupportedOperationException("Not supported.");
}
public EbeanServer getDatabase() {
throw new UnsupportedOperationException("Not supported.");
}
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
throw new UnsupportedOperationException("Not supported.");
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
throw new UnsupportedOperationException("Not supported.");
}
@Override
public int hashCode() {
return getName().hashCode();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
return getName().equals(((TestPlugin) obj).getName());
}
}