diff options
Diffstat (limited to 'NET/worlds/console/WhisperManager.java')
| -rw-r--r-- | NET/worlds/console/WhisperManager.java | 183 |
1 files changed, 183 insertions, 0 deletions
diff --git a/NET/worlds/console/WhisperManager.java b/NET/worlds/console/WhisperManager.java new file mode 100644 index 0000000..518aa46 --- /dev/null +++ b/NET/worlds/console/WhisperManager.java @@ -0,0 +1,183 @@ +/* */ package NET.worlds.console; +/* */ +/* */ import NET.worlds.network.NetUpdate; +/* */ import NET.worlds.scape.InventoryManager; +/* */ import java.awt.Window; +/* */ import java.util.Enumeration; +/* */ import java.util.Hashtable; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class WhisperManager +/* */ { +/* */ private static WhisperManager manager_; +/* */ private Hashtable<String, WhisperDialog> dialogs_; +/* */ private Hashtable<String, TradeDialog> tradeDialogs_; +/* */ private Window parent; +/* 24 */ private String inventory = ""; +/* 25 */ final String tradeServerName = "TRADE"; +/* */ static GiftDialog outstandingGift; +/* */ +/* */ private WhisperManager() { +/* 29 */ this.dialogs_ = new Hashtable(); +/* 30 */ this.tradeDialogs_ = new Hashtable(); +/* */ } +/* */ +/* */ public static WhisperManager whisperManager() { +/* 34 */ if (manager_ == null) { +/* 35 */ manager_ = new WhisperManager(); +/* */ } +/* */ +/* 38 */ return manager_; +/* */ } +/* */ +/* */ void setParent(Window p) { +/* 42 */ this.parent = p; +/* */ } +/* */ +/* */ public Hashtable<String, WhisperDialog> dialogs() { +/* 46 */ return this.dialogs_; +/* */ } +/* */ +/* */ public Hashtable<String, TradeDialog> tradeDialogs() { +/* 50 */ return this.tradeDialogs_; +/* */ } +/* */ +/* */ private WhisperDialog findWhisperDialog(String to) { +/* 54 */ if (!this.dialogs_.containsKey(to)) +/* 55 */ return null; +/* 56 */ return (WhisperDialog)this.dialogs_.get(to); +/* */ } +/* */ +/* */ private TradeDialog findTradeDialog(String to) { +/* 60 */ if (!this.tradeDialogs_.containsKey(to)) +/* 61 */ return null; +/* 62 */ return (TradeDialog)this.tradeDialogs_.get(to); +/* */ } +/* */ +/* */ private WhisperDialog start(String to, boolean takeFocus) { +/* 66 */ WhisperDialog wd = findWhisperDialog(to); +/* 67 */ if (wd == null) { +/* 68 */ this.dialogs_.put(to, wd = new WhisperDialog(this.parent, to)); +/* */ } +/* 70 */ if (takeFocus) +/* 71 */ wd.takeFocus(); +/* 72 */ wd.ready(); +/* 73 */ return wd; +/* */ } +/* */ +/* */ public void remove(String name) { +/* 77 */ this.dialogs_.remove(name); +/* */ } +/* */ +/* */ +/* */ +/* */ public void startTo(String to) +/* */ { +/* 84 */ WhisperDialog wd = start(to, true); +/* */ } +/* */ +/* */ public TradeDialog startToTrade(String to) +/* */ { +/* 89 */ TradeDialog wd = findTradeDialog(to); +/* 90 */ if (wd == null) { +/* 91 */ this.tradeDialogs_.put(to, wd = new TradeDialog(this.parent, to)); +/* */ } +/* 93 */ wd.takeFocus(); +/* 94 */ wd.ready(); +/* 95 */ wd.setTrading(true); +/* 96 */ wd.whisperPart.println(Console.message("trade-start")); +/* */ +/* 98 */ return wd; +/* */ } +/* */ +/* */ public void printFrom(String from, String msg) { +/* 102 */ if (!msg.startsWith("&|+")) { +/* 103 */ WhisperDialog it = findWhisperDialog(from); +/* 104 */ if ((msg.equals("&|+trade>cancel")) && ( +/* 105 */ (it == null) || (!it.isActive()) || (!it.isTrading))) { +/* 106 */ return; +/* */ } +/* 108 */ it = start(from, false); +/* 109 */ it.print(msg); +/* 110 */ } else if ((msg.startsWith("&|+gift>")) && +/* 111 */ (from.equalsIgnoreCase("TRADE"))) +/* */ { +/* 113 */ maybeQueryGift(msg.substring(8)); +/* */ } +/* 115 */ else if ((msg.startsWith("&|+inv>")) && +/* 116 */ (from.equalsIgnoreCase("TRADE"))) { +/* 117 */ tradeMsg(msg.substring(7)); +/* 118 */ } else if (msg.startsWith("&|+trade>")) { +/* 119 */ TradeDialog it = findTradeDialog(from); +/* 120 */ if ((msg.equals("&|+trade>cancel")) && ( +/* 121 */ (it == null) || (!it.isActive()) || (!it.isTrading))) { +/* 122 */ return; +/* */ } +/* 124 */ it = startToTrade(from); +/* 125 */ it.print(msg); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void tradeMsg(String newInv) +/* */ { +/* 138 */ if (!newInv.equals(this.inventory)) { +/* 139 */ for (Enumeration<TradeDialog> e = this.tradeDialogs_.elements(); e.hasMoreElements();) { +/* 140 */ TradeDialog wd = (TradeDialog)e.nextElement(); +/* 141 */ wd.doneDeal(); +/* */ } +/* */ +/* 144 */ InventoryManager.getInventoryManager().setInventory(newInv); +/* */ } +/* */ } +/* */ +/* */ public void printTo(String to, String msg) +/* */ { +/* 150 */ if ((to.equals("world")) || (to.equals("TRADE"))) { +/* 151 */ return; +/* */ } +/* 153 */ if ((!msg.startsWith("&|+")) || (msg.startsWith("&|+trade>"))) { +/* 154 */ WhisperDialog it = start(to, false); +/* 155 */ it.send(msg); +/* */ } +/* */ } +/* */ +/* */ public void giftDialogDone() { +/* 160 */ outstandingGift = null; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public static void maybeQueryGift(String inv) +/* */ { +/* 169 */ if (!NetUpdate.isInternalVersion()) { +/* 170 */ return; +/* */ } +/* 172 */ Console c = Console.getActive(); +/* 173 */ if ((c != null) && (outstandingGift == null) && (!c.isSleeping())) { +/* 174 */ outstandingGift = new GiftDialog(inv, 3000000); +/* */ } +/* */ } +/* */ } + + +/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\WhisperManager.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 0.7.1 + */
\ No newline at end of file |