Skip to content

Commit

Permalink
Changed OWNER req. logic , also started working on inventory features
Browse files Browse the repository at this point in the history
  • Loading branch information
spaceemotion committed Apr 30, 2013
1 parent 6a88fb4 commit 3422575
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 21 deletions.
Expand Up @@ -34,6 +34,7 @@ public static void _registerCoreTypes() {
_registerType("procedure", ProcedureScriptContainer.class);
_registerType("world", WorldScriptContainer.class);
_registerType("format", FormatScriptContainer.class);
_registerType("inventory", InventoryScriptContainer.class);
}

public static boolean containsScript(String id) {
Expand Down
Expand Up @@ -98,13 +98,13 @@ public List<ScriptEntry> getEntries(Player player, dNPC npc, String path) {
List<ScriptEntry> list = new ArrayList<ScriptEntry>();
if (path == null) path = "script";
List<String> stringEntries = contents.getStringList(path.toUpperCase());
if (stringEntries == null || stringEntries.size() == 0) return list;
if (stringEntries == null || stringEntries.isEmpty()) return list;
list = ScriptBuilder.buildScriptEntries(stringEntries, this, player, npc);
return list;
}

public boolean checkCooldown(Player player) {
return DenizenAPI._commandRegistry().get(CooldownCommand.class).checkCooldown(player.getName(), name);
return CooldownCommand.checkCooldown(player.getName(), name);
}

}
Expand Up @@ -2,7 +2,6 @@

import net.aufdemrand.denizen.npc.dNPC;
import net.aufdemrand.denizen.scripts.containers.ScriptContainer;
import net.aufdemrand.denizen.utilities.DenizenAPI;
import net.aufdemrand.denizen.utilities.arguments.dItem;

import org.bukkit.Material;
Expand All @@ -11,6 +10,7 @@
import org.bukkit.inventory.meta.BookMeta;

import java.util.List;
import net.aufdemrand.denizen.tags.TagManager;

public class BookScriptContainer extends ScriptContainer {

Expand All @@ -27,28 +27,23 @@ public dItem writeBookTo(dItem book, Player player, dNPC npc) {
// Get current ItemMeta from the book
BookMeta bookInfo = (BookMeta) book.getItemStack().getItemMeta();



if (contains("TITLE")) {
String title = getString("TITLE");
title = DenizenAPI.getCurrentInstance().tagManager()
.tag(player, npc, title, false);
title = TagManager.tag(player, npc, title, false);
bookInfo.setTitle(title);
}

if (contains("AUTHOR")) {
String author = getString("AUTHOR");
author = DenizenAPI.getCurrentInstance().tagManager()
.tag(player, npc, author, false);
author = TagManager.tag(player, npc, author, false);
bookInfo.setAuthor(author);
}

if (contains("TEXT")) {
List<String> pages = getStringList("TEXT");

for (String page : pages) {
page = DenizenAPI.getCurrentInstance().tagManager()
.tag(player, npc, page, false);
page = TagManager.tag(player, npc, page, false);
bookInfo.addPage(page);
}
}
Expand Down
@@ -0,0 +1,35 @@
package net.aufdemrand.denizen.scripts.containers.core;

import net.aufdemrand.denizen.scripts.containers.ScriptContainer;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryType;

public class InventoryScriptContainer extends ScriptContainer {

public InventoryScriptContainer(ConfigurationSection configurationSection, String scriptContainerName) {
super(configurationSection, scriptContainerName);
}

public int getSize() {
InventoryType invType = getInventoryType();

if(invType == InventoryType.CHEST) {
return Integer.parseInt(getString("size", "27"));
}

return invType.getDefaultSize();
}

public InventoryType getInventoryType() {
String typeStr = getString("inventory", "chest");

try {
InventoryType type = InventoryType.valueOf(typeStr);
return type;

} catch(Exception e) {
return InventoryType.CHEST;
}
}

}
Expand Up @@ -11,11 +11,7 @@ public class OwnerRequirement extends AbstractRequirement{

@Override
public boolean check(RequirementsContext context, List<String> args) throws RequirementCheckException {
if (context.getNPC().getCitizen().getTrait(Owner.class)
.getOwner().equalsIgnoreCase(context.getPlayer().getName()))
return true;

return false;
return context.getNPC().getCitizen().getTrait(Owner.class).isOwnedBy(context.getPlayer());
}

}
@@ -1,7 +1,3 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.aufdemrand.denizen.utilities.debugging;

import java.io.PrintWriter;
Expand All @@ -18,7 +14,7 @@
*
* Handles debug logs
*
* @uathor SpaceEmotion
* @author SpaceEmotion
*/
public class DebugLog extends Logger {
private final static DebugFormatter formatter = new DebugFormatter();
Expand Down

0 comments on commit 3422575

Please sign in to comment.