Skip to content

Commit

Permalink
Merge branch 'master' of github.com:atlan1/ApiPlus
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown committed Jun 14, 2012
2 parents 987435b + e0143e7 commit 6c41917
Show file tree
Hide file tree
Showing 18 changed files with 1,677 additions and 8 deletions.
18 changes: 18 additions & 0 deletions Api+/.classpath
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="lib" path="C:/Users/Tyler/workspace/Plugins/craftbukkit.jar" sourcepath="C:/Users/Robert/Downloads/craftbukkit-1.2.3-R0.1.jar">
<attributes>
<attribute name="javadoc_location" value="http://jd.bukkit.org/apidocs/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="C:/Users/Tyler/workspace/Plugins/spoutplugin-dev-SNAPSHOT.jar">
<attributes>
<attribute name="javadoc_location" value="http://jd.spout.org/plugin/latest/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="C:/Users/Tyler/workspace/Plugins/WorldGuard.jar"/>
<classpathentry kind="lib" path="C:/Users/Tyler/workspace/Plugins/FurnaceAPI.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions Api+/.project
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Api+</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions Api+/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
1 change: 1 addition & 0 deletions Api+/general.yml
@@ -0,0 +1 @@
debug: false
6 changes: 6 additions & 0 deletions Api+/plugin.yml
@@ -0,0 +1,6 @@
name: ApiPlus
main: team.ApiPlus.ApiPlus
version: 1.0
authors: [SirTyler, Atlan1]
depend: [Spout]
softdepend: [WorldGaurd]
37 changes: 37 additions & 0 deletions Api+/src/team/ApiPlus/API/PluginPlus.java
@@ -0,0 +1,37 @@
package team.ApiPlus.API;

import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;

import team.ApiPlus.Item;
import team.ApiPlus.Manager.ItemManager;

/**
* PluginPlus class for use with API+.
* @author SirTyler (Tyler Martin)
* @version 1.0
*/
abstract public class PluginPlus extends JavaPlugin {

abstract public void loadConfig(FileConfiguration con);

/**
* Method used for building an Item and Adding it to the ItemManager.
* @param name String name of new Item.
* @param texture String texture of new Item.
* @param baseType String name of Type to base Item off.
* @return boolean True if action completed successfully, False if not.
*/
public boolean addItem(String name, String texture, String baseType) {
try {
Item it = ItemManager.getInstance().buildItem(this, name, texture, baseType);
ItemManager.getInstance().addItem(it);
return true;
} catch (Exception e) {
Bukkit.getLogger().log(Level.INFO, String.format("[%s][ERROR] %s %s", this.getName(), e.getMessage(), e.getCause()));
return false;
}
}
}
87 changes: 87 additions & 0 deletions Api+/src/team/ApiPlus/ApiPlus.java
@@ -0,0 +1,87 @@
package team.ApiPlus;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;

import team.ApiPlus.Manager.ConfigManager;
import team.ApiPlus.Manager.ItemManager;
import team.ApiPlus.Manager.TypeManager;
import team.ApiPlus.Manager.Loadout.LoadoutManager;
import team.ApiPlus.Util.FileUtil;
import team.ApiPlus.Util.Utils;

@SuppressWarnings("unused")
public class ApiPlus extends JavaPlugin {

private String version;
private static ApiPlus instance;
private ItemManager iManager;
private LoadoutManager lManager;
private TypeManager tManager;
private ConfigManager cManager;
public static Map<String,Plugin> hooks = new HashMap<String,Plugin>();

@Override
public void onEnable() {
instance = this;
version = getDescription().getVersion();
iManager = ItemManager.getInstance();
lManager = LoadoutManager.getInstance();
tManager = TypeManager.getInstance();
cManager = ConfigManager.getInstance();
lManager.loadAll();
Utils.debug(lManager.read());
hook();
loadGeneral();
Utils.info(String.format("API+ Version:%s Enabled.", version));
}

private void hook() {
Plugin _wg = getServer().getPluginManager().getPlugin("WorldGuard");
Plugin _fur = getServer().getPluginManager().getPlugin("FurnaceAPI");
if(_wg != null) {
hooks.put("WorldGuard", _wg);
Utils.info("Hooked into WorldGuard");
}
if(_fur != null) {
hooks.put("FurncaeAPI", _fur);
Utils.info("Hooked into FurnaceAPI");
}
}

private void loadGeneral() {
File general = new File(this.getDataFolder().getPath() + File.separator + "general.yml");
if(!general.exists()) FileUtil.copy(this.getResource("genearl.yml"), general);
cManager.add(general);
FileConfiguration con = cManager.get(general);
if(con != null) {
Utils.setDebug(Boolean.valueOf(con.getString("debug","false")));
} else return;
}

/**
* Method used for adding a hook into API+.
* @param p Plugin to be added.
* @return boolean True if action completed successfully, False if not.
*/
public static boolean addHook(Plugin p) {
if(hooks.containsValue(p)) return false;
else {
hooks.put(p.getName(), p);
return true;
}
}

/**
* Method used for getting Server's Instance of Api+.
* @return ApiPlus Instance of Api+.
*/
public static ApiPlus getInstance() {
return instance;
}
}
157 changes: 157 additions & 0 deletions Api+/src/team/ApiPlus/Item.java
@@ -0,0 +1,157 @@
package team.ApiPlus;

import java.util.HashMap;

import org.bukkit.plugin.Plugin;
import org.getspout.spoutapi.material.item.GenericCustomItem;

import team.ApiPlus.Manager.ItemManager;

/**
* API+ Custom Item
* @author SirTyler (Tyler Martin)
* @version 1.0
*/
public class Item extends GenericCustomItem {

private HashMap<String, Float> values = new HashMap<String, Float>();
private HashMap<String, String> resources = new HashMap<String, String>();
private HashMap<String, Object> objects = new HashMap<String, Object>();

public Item(GenericCustomItem it) {
super(it.getPlugin(), it.getName(), it.getTexture());
ItemManager.getInstance().addItem(this);
}

public Item(Plugin plugin, String name, String texture) {
super(plugin, name, texture);
ItemManager.getInstance().addItem(this);
}

/**
* Method used for getting corresponding Item Resource based on Input String.
* @param s The Name to look for.
* @return String
*/
public String getResource(String s) {
return resources.containsKey(s) ? resources.get(s) : null;
}

/**
* Method used for setting Item Resource.
* @param name Name to be associated with the Resource.
* @param resource String to be used as Item Resource.
*/
public void setResource(String name, String resource) {
this.resources.put(name, resource);
}

/**
* Method used for getting corresponding Item Object based on Input String.
* @param s The Name to search for.
* @return Object
*/
public Object getObject(String s) {
return objects.containsKey(s) ? objects.get(s) : null;
}

/**
* Method used for setting Item Object.
* @param name Name to be associated with the Object.
* @param o Object to be used as Item Object.
*/
public void setObject(String name, Object o) {
this.objects.put(name, o);
}

/**
* Method used for setting Item Value.
* @param name Name to be associated with the Value.
* @param value Value to be used as Item Value.
*/
public void setValue(String name, Float value) {
values.put(name, value);
}

/**
* Method used for getting Item Value.
* @param name The Name to search for.
* @return
*/
public float getValue(String name) {
return values.containsKey(name) ? values.get(name) : 0;
}

/**
* Method used for getting the HashMap of Resources.
* @return HashMap<String,String>
*/
public HashMap<String, String> getResources() {
return resources;
}

/**
* Method used for getting the HashMap of Objects.
* @return HashMap<String,Object>
*/
public HashMap<String, Object> getObjects() {
return objects;
}

/**
* Method used for getting the HashMap of Values.
* @return HashMap<String,Float>
*/
public HashMap<String, Float> getValues() {
return values;
}

/**
* Method used for setting the HashMap of Resources. !!Warning, Overwrites any old data!!
* @param resources HashMap<String, String> containing replacement Resources.
* @see #setResource(String, String)
*/
public void setResources(HashMap<String, String> resources) {
HashMap<String, String> list = new HashMap<String, String>(resources);
this.resources = list;
}

/**
* Method used for setting the HashMap of Objects. !!Warning, Overwrites any old data!!
* @param objects HashMap<String, Objects> containing replacement Objects.
* @see #setObject(String, Object)
*/
public void setObjects(HashMap<String, Object> objects) {
HashMap<String, Object> list = new HashMap<String, Object>(objects);
this.objects = list;
}

/**
* Method used for setting the HashMap of Values. !!Warning, Overwrites any old data!!
* @param values HashMap<String, Float> containing replacement Values.
* @see #setValue(String, Float)
*/
public void setValues(HashMap<String, Float> values) {
HashMap<String, Float> list = new HashMap<String, Float>(values);
this.values = list;
}

/**
* Method for copying property data from one Item to this Item.
* @param parent Item to copy data from.
*/
public void copyData(Item parent) {
this.setValues(parent.getValues());
this.setResources(parent.getResources());
this.setObjects(parent.getObjects());
}

/**
* Method used for checking if Item is empty, meaning it contains no values.
* @return boolean True if empty, False is contains data.
*/
public boolean isEmpty() {
if(values.isEmpty() && objects.isEmpty() && resources.isEmpty()) return true;
else return false;
}
}

0 comments on commit 6c41917

Please sign in to comment.