Skip to content

Commit

Permalink
Temporary fixes to allow compiling again for testing...
Browse files Browse the repository at this point in the history
  • Loading branch information
aufdemrand committed Jun 2, 2013
1 parent ee1b747 commit e0d71e3
Show file tree
Hide file tree
Showing 46 changed files with 97 additions and 116 deletions.
6 changes: 3 additions & 3 deletions src/main/java/net/aufdemrand/denizen/CommandHandler.java
Expand Up @@ -737,11 +737,11 @@ public void save(CommandContext args, CommandSender sender, NPC npc) throws Comm
public void listener(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
Denizen denizen = ((Denizen) plugin.getServer().getPluginManager().getPlugin("Denizen"));

Player player = null;
if (sender instanceof Player) player = (Player) sender;
dPlayer player = null;
if (sender instanceof Player) player = dPlayer.mirrorBukkitPlayer((Player) sender);

if (args.hasValueFlag("player"))
player = aH.getPlayerFrom(args.getFlag("player"));
player = dPlayer.valueOf(args.getFlag("player"));

if (player == null) throw new CommandException("Specified player not online or not found!");

Expand Down
@@ -1,6 +1,7 @@
package net.aufdemrand.denizen.listeners;


import net.aufdemrand.denizen.objects.dPlayer;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

Expand Down Expand Up @@ -29,7 +30,7 @@ public AbstractListenerType as(String name) {
return this;
}

public AbstractListener createInstance(Player player, String listenerId) {
public AbstractListener createInstance(dPlayer player, String listenerId) {
try {
denizen.getListenerRegistry().addListenerFor(player, instanceClass.newInstance(), listenerId);
return denizen.getListenerRegistry().getListenerFor(player, listenerId);
Expand Down
Expand Up @@ -37,7 +37,7 @@ public ListenerRegistry(Denizen denizen) {
this.denizen = denizen;
}

public void addListenerFor(Player player, AbstractListener instance, String listenerId) {
public void addListenerFor(dPlayer player, AbstractListener instance, String listenerId) {
Map<String, AbstractListener> playerListeners;
if (listeners.containsKey(player.getName())) {
playerListeners = listeners.get(player.getName());
Expand Down Expand Up @@ -97,15 +97,15 @@ public AbstractListenerType get(String listenerType) {
return null;
}

public AbstractListener getListenerFor(Player player, String listenerId) {
public AbstractListener getListenerFor(dPlayer player, String listenerId) {
if (listeners.containsKey(player.getName())) {
Map<String, AbstractListener> playerListeners = listeners.get(player.getName());
if (playerListeners.containsKey(listenerId.toLowerCase())) return playerListeners.get(listenerId.toLowerCase());
}
return null;
}

public Map<String, AbstractListener> getListenersFor(OfflinePlayer player) {
public Map<String, AbstractListener> getListenersFor(dPlayer player) {
if (listeners.containsKey(player.getName())) {
Map<String, AbstractListener> playerListeners = listeners.get(player.getName());
return playerListeners;
Expand Down Expand Up @@ -137,7 +137,7 @@ public void playerJoin(PlayerJoinEvent event) {
dNPC npc = DenizenAPI.getDenizenNPC(CitizensAPI.getNPCRegistry().getById(denizen.getSaves().getInt(path + listenerId + ".Linked NPCID")));
if (get(type) == null) return;
dB.log(event.getPlayer().getName() + " has a LISTENER in progress. Loading '" + listenerId + "'.");
get(type).createInstance(event.getPlayer(), listenerId).load(dPlayer.mirrorBukkitPlayer(event.getPlayer()), npc, listenerId, type);
get(type).createInstance(dPlayer.mirrorBukkitPlayer(event.getPlayer()), listenerId).load(dPlayer.mirrorBukkitPlayer(event.getPlayer()), npc, listenerId, type);
} catch (Exception e) {
dB.log(event.getPlayer() + " has a saved listener named '" + listenerId + "' that may be corrupt. Skipping for now, but perhaps check the contents of your saves.yml for problems?");
}
Expand All @@ -155,7 +155,7 @@ public void deconstructPlayer(dPlayer player ) {
}

// If there are quest listeners, invoke save() for each of them.
for (Map.Entry<String, AbstractListener> entry : getListenersFor((OfflinePlayer) player).entrySet()) {
for (Map.Entry<String, AbstractListener> entry : getListenersFor(player).entrySet()) {
dB.log(player.getName() + " has a LISTENER in progress. Saving '" + entry.getKey() + "'.");
entry.getValue().save();
}
Expand Down
Expand Up @@ -15,8 +15,6 @@
import static net.aufdemrand.denizen.objects.aH.Argument;

/**
*
* TODO: Document usage
*
* Controls a NPC's 'Anchors' trait.
*
Expand Down Expand Up @@ -131,5 +129,6 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
return;
}


}
}
Expand Up @@ -53,14 +53,14 @@ public void execute(ScriptEntry scriptEntry)

switch (action) {
case OPEN:
if (sound) scriptEntry.getPlayer().playSound(location, Sound.CHEST_OPEN, 1, 1);
scriptEntry.getPlayer().playNote(location, (byte)1, (byte)1);
if (sound) scriptEntry.getPlayer().getPlayerEntity().playSound(location, Sound.CHEST_OPEN, 1, 1);
scriptEntry.getPlayer().getPlayerEntity().playNote(location, (byte)1, (byte)1);
dB.echoDebug("...opening chest");
break;

case CLOSE:
if (sound) scriptEntry.getPlayer().getWorld().playSound(location, Sound.CHEST_CLOSE, 1, 1);
scriptEntry.getPlayer().playNote(location, (byte)1, (byte)0);
if (sound) scriptEntry.getPlayer().getPlayerEntity().getWorld().playSound(location, Sound.CHEST_CLOSE, 1, 1);
scriptEntry.getPlayer().getPlayerEntity().playNote(location, (byte)1, (byte)0);
dB.echoDebug("...closing chest");
break;

Expand Down
Expand Up @@ -3,6 +3,7 @@
import net.aufdemrand.denizen.exceptions.CommandExecutionException;
import net.aufdemrand.denizen.exceptions.InvalidArgumentsException;
import net.aufdemrand.denizen.flags.FlagManager;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizen.scripts.ScriptEntry;
import net.aufdemrand.denizen.scripts.ScriptRegistry;
import net.aufdemrand.denizen.scripts.commands.AbstractCommand;
Expand Down Expand Up @@ -115,7 +116,7 @@ else if (type == AnnounceType.TO_OPS) {

else if (type == AnnounceType.TO_FLAGGED) {
for (Player player : Bukkit.getOnlinePlayers()) {
if (FlagManager.playerHasFlag(player, flag))
if (FlagManager.playerHasFlag(dPlayer.mirrorBukkitPlayer(player), flag))
player.sendMessage(message);
}
}
Expand Down
Expand Up @@ -57,7 +57,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
// Start attacking
else
scriptEntry.getNPC().getNavigator()
.setTarget(scriptEntry.getPlayer(), true);
.setTarget(scriptEntry.getPlayer().getPlayerEntity(), true);

}

Expand Down
Expand Up @@ -93,7 +93,7 @@ else if (aH.matchesValueArg("TARGETS, TARGET", arg, ArgumentType.String)) {
if (scriptEntry.getPlayer() == null)
dB.echoError("Cannot add PLAYER as a target! Attached Player is NULL!");
else
targets.add(scriptEntry.getPlayer());
targets.add(scriptEntry.getPlayer().getPlayerEntity());

// If specifying the linked NPC
} else if (aH.getStringFrom(t).equalsIgnoreCase("NPC") && scriptEntry.getNPC() != null) {
Expand Down Expand Up @@ -127,7 +127,7 @@ else if (potion == null) {
// No targets specified, let's use defaults if available
// Target Player by default
if (targets.isEmpty() && scriptEntry.getPlayer() != null)
targets.add(scriptEntry.getPlayer());
targets.add(scriptEntry.getPlayer().getPlayerEntity());
// If no Player, target the NPC by default
if (targets.isEmpty() && scriptEntry.getNPC() != null)
targets.add(scriptEntry.getNPC().getEntity());
Expand Down
Expand Up @@ -93,7 +93,7 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException

// Add default recipient as the scriptEntry Player if no recipients set otherwise
if (!context.hasRecipients() && !noTargets && scriptEntry.getPlayer() != null)
context.addRecipient(scriptEntry.getPlayer());
context.addRecipient(scriptEntry.getPlayer().getPlayerEntity());

// Verify essential fields are set
if (context.getTalker() == null)
Expand Down
Expand Up @@ -2,6 +2,7 @@

import net.aufdemrand.denizen.exceptions.CommandExecutionException;
import net.aufdemrand.denizen.exceptions.InvalidArgumentsException;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizen.objects.dScript;
import net.aufdemrand.denizen.scripts.ScriptEntry;
import net.aufdemrand.denizen.scripts.commands.AbstractCommand;
Expand Down Expand Up @@ -58,15 +59,8 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
// Define necessary fields
dScript script = scriptEntry.getScript();
Duration duration = null;
OfflinePlayer player = null;
Type type = Type.PLAYER;

// Set player in scriptEntry to the target
if (scriptEntry.getPlayer() != null)
player = scriptEntry.getPlayer();
else if (scriptEntry.getOfflinePlayer() != null)
player = scriptEntry.getOfflinePlayer();

// Parse Arguments
for (String arg : scriptEntry.getArguments()) {

Expand All @@ -86,7 +80,7 @@ else if (aH.matchesScript(arg))
}

// Check to make sure required arguments have been filled
if (type == Type.PLAYER && player == null)
if (type == Type.PLAYER && scriptEntry.getPlayer() == null)
throw new InvalidArgumentsException(Messages.ERROR_NO_PLAYER);
if (script == null)
throw new InvalidArgumentsException(Messages.ERROR_NO_SCRIPT);
Expand All @@ -95,9 +89,6 @@ else if (aH.matchesScript(arg))
scriptEntry.addObject("script", script);
scriptEntry.addObject("duration", duration);
scriptEntry.addObject("type", type);
// Store the player only when necessary
if (type == Type.PLAYER)
scriptEntry.addObject("player", player);
}

@Override
Expand All @@ -116,7 +107,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {

// Perform cooldown
if (type == Type.PLAYER)
setCooldown(((OfflinePlayer) scriptEntry.getObject("player")).getName(),
setCooldown(scriptEntry.getPlayer().getName(),
duration.getSecondsAsInt(),
script.getName(),
false);
Expand Down
Expand Up @@ -31,7 +31,7 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException

// Set some defaults
if (scriptEntry.getPlayer() != null)
location = new dLocation(scriptEntry.getPlayer().getLocation());
location = new dLocation(scriptEntry.getPlayer().getPlayerEntity().getLocation());
if (location == null && scriptEntry.getNPC() != null)
location = new dLocation(scriptEntry.getNPC().getLocation());

Expand Down
Expand Up @@ -42,7 +42,7 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
// Initialize fields
Action action = Action.ADD;
String target = scriptEntry.getPlayer().getName();
ItemStack item = scriptEntry.getPlayer().getItemInHand() != null ? scriptEntry.getPlayer().getItemInHand(): null;
ItemStack item = scriptEntry.getPlayer().getPlayerEntity().getItemInHand() != null ? scriptEntry.getPlayer().getPlayerEntity().getItemInHand(): null;

for (String arg : scriptEntry.getArguments()) {
if (aH.matchesArg("ADD, REMOVE, REMOVEALL", arg)) {
Expand Down
Expand Up @@ -73,15 +73,15 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
switch (type) {

case AS_PLAYER:
scriptEntry.getPlayer().performCommand(command);
scriptEntry.getPlayer().getPlayerEntity().performCommand(command);
return;

case AS_OP:
boolean isOp = false;
if (scriptEntry.getPlayer().isOp()) isOp = true;
if (!isOp) scriptEntry.getPlayer().setOp(true);
scriptEntry.getPlayer().performCommand(command);
if (!isOp) scriptEntry.getPlayer().setOp(false);
if (scriptEntry.getPlayer().getPlayerEntity().isOp()) isOp = true;
if (!isOp) scriptEntry.getPlayer().getPlayerEntity().setOp(true);
scriptEntry.getPlayer().getPlayerEntity().performCommand(command);
if (!isOp) scriptEntry.getPlayer().getPlayerEntity().setOp(false);
return;

case AS_NPC:
Expand Down
Expand Up @@ -56,7 +56,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
+ aH.debugObj("Quantity", level ? quantity.toString() + " levels" : quantity.toString())
+ aH.debugObj("Player", scriptEntry.getPlayer().getName()));

Player player = scriptEntry.getPlayer();
Player player = scriptEntry.getPlayer().getPlayerEntity();

switch (type) {
case SET:
Expand Down
Expand Up @@ -36,17 +36,9 @@ public class FailCommand extends AbstractCommand {

@Override
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {
// Initialize required fields
String player = null;

// Get some defaults from the ScriptEntry
dScript script = scriptEntry.getScript();

if (scriptEntry.getPlayer() != null)
player = scriptEntry.getPlayer().getName();
if (player == null && scriptEntry.getOfflinePlayer() != null)
player = scriptEntry.getOfflinePlayer().getName();

// Parse the arguments
for (String arg : scriptEntry.getArguments()) {

Expand All @@ -57,28 +49,26 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
}

// Check for required args
if (player == null)
if (scriptEntry.getPlayer() == null)
throw new InvalidArgumentsException(Messages.ERROR_NO_PLAYER);
if (script == null)
throw new InvalidArgumentsException(Messages.ERROR_NO_SCRIPT);

// Stash objects
scriptEntry.addObject("script", script);
scriptEntry.addObject("player", player);
}

@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
// Grab objects from scriptEntry
String player = (String) scriptEntry.getObject("player");
dScript script = (dScript) scriptEntry.getObject("script");

// Report to dB
dB.report(getName(),
aH.debugObj("Player", player)
scriptEntry.getPlayer().debug()
+ script.debug());

failScript(player, script.getName());
failScript(scriptEntry.getPlayer().getName(), script.getName());
}

public static void resetFails(String playerName, String scriptName) {
Expand Down
Expand Up @@ -36,17 +36,10 @@ public class FinishCommand extends AbstractCommand {

@Override
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {
// Initialize required fields
String player = null;

// Get some defaults from the ScriptEntry
dScript script = scriptEntry.getScript();

if (scriptEntry.getPlayer() != null)
player = scriptEntry.getPlayer().getName();
if (player == null && scriptEntry.getOfflinePlayer() != null)
player = scriptEntry.getOfflinePlayer().getName();

// Parse the arguments
for (String arg : scriptEntry.getArguments()) {

Expand All @@ -57,28 +50,26 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
}

// Check for required args
if (player == null)
if (scriptEntry.getPlayer() == null)
throw new InvalidArgumentsException(Messages.ERROR_NO_PLAYER);
if (script == null)
throw new InvalidArgumentsException(Messages.ERROR_NO_SCRIPT);

// Stash objects
scriptEntry.addObject("script", script);
scriptEntry.addObject("player", player);
}

@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
// Grab objects from scriptEntry
String player = (String) scriptEntry.getObject("player");
dScript script = (dScript) scriptEntry.getObject("script");

// Report to dB
dB.report(getName(),
aH.debugObj("Player", player)
scriptEntry.getPlayer().debug()
+ script.debug());

finishScript(player, script.getName());
finishScript(scriptEntry.getPlayer().getName(), script.getName());
}

public static void resetFinishes(String playerName, String scriptName) {
Expand Down
Expand Up @@ -87,8 +87,6 @@ else if (arg.split(":", 3).length > 1) {
String player = null;

if (type == Type.PLAYER) {
if (scriptEntry.getOfflinePlayer() != null)
player = scriptEntry.getOfflinePlayer().getName();
if (player == null && scriptEntry.getPlayer() != null)
player = scriptEntry.getPlayer().getName();
}
Expand Down
Expand Up @@ -51,7 +51,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
.cancelNavigation();
else
scriptEntry.getNPC().getNavigator()
.setTarget(scriptEntry.getPlayer(), false);
.setTarget(scriptEntry.getPlayer().getPlayerEntity(), false);

}

Expand Down

0 comments on commit e0d71e3

Please sign in to comment.