summaryrefslogtreecommitdiff
path: root/NET/worlds/console/RemoveHandler.java
blob: 058abdded92716480eb60e7b50f4c13d1a10bc60 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*     */ package NET.worlds.console;
/*     */ 
/*     */ import NET.worlds.scape.BumpEventTemp;
/*     */ import NET.worlds.scape.BumpHandler;
/*     */ import NET.worlds.scape.NoSuchPropertyException;
/*     */ import NET.worlds.scape.Portal;
/*     */ import NET.worlds.scape.Restorer;
/*     */ import NET.worlds.scape.Room;
/*     */ import NET.worlds.scape.Saver;
/*     */ import NET.worlds.scape.SuperRoot;
/*     */ import NET.worlds.scape.TooNewException;
/*     */ import NET.worlds.scape.VectorProperty;
/*     */ import java.io.IOException;
/*     */ import java.util.Enumeration;
/*     */ import java.util.Vector;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class RemoveHandler
/*     */   extends SuperRoot
/*     */   implements BumpHandler
/*     */ {
/*  39 */   private Vector<Object> handlers = new Vector(1);
/*     */   
/*     */   public RemoveHandler() {}
/*     */   
/*     */   public RemoveHandler(SuperRoot oldhandler)
/*     */   {
/*  45 */     this.handlers.addElement(oldhandler);
/*     */   }
/*     */   
/*     */   public boolean handle(BumpEventTemp e) {
/*  49 */     Room sc = ((Portal)e.target).getRoom();
/*  50 */     assert (((sc instanceof Staircase)) || ((sc instanceof Stair)));
/*  51 */     Enumeration<Object> enh = this.handlers.elements();
/*  52 */     while (enh.hasMoreElements()) {
/*  53 */       SuperRoot handler = (SuperRoot)enh.nextElement();
/*  54 */       if (sc.hasHandler(handler))
/*  55 */         sc.removeHandler(handler);
/*     */     }
/*  57 */     return true;
/*     */   }
/*     */   
/*  60 */   private static Object classCookie = new Object();
/*     */   
/*     */   public void saveState(Saver s) throws IOException
/*     */   {
/*  64 */     s.saveVersion(2, classCookie);
/*  65 */     super.saveState(s);
/*  66 */     s.saveVector(this.handlers);
/*     */   }
/*     */   
/*     */   public void restoreState(Restorer r) throws IOException, TooNewException
/*     */   {
/*  71 */     switch (r.restoreVersion(classCookie)) {
/*     */     case 2: 
/*  73 */       super.restoreState(r);
/*  74 */       this.handlers = r.restoreVector();
/*  75 */       break;
/*     */     case 1: 
/*  77 */       super.restoreState(r);
/*     */     
/*     */     case 0: 
/*  80 */       if (r.restoreBoolean())
/*  81 */         this.handlers.addElement(r.restore());
/*  82 */       break;
/*     */     default: 
/*  84 */       throw new TooNewException();
/*     */     }
/*     */     
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public Object properties(int index, int offset, int mode, Object value)
/*     */     throws NoSuchPropertyException
/*     */   {
/*  94 */     Object ret = null;
/*     */     
/*  96 */     switch (index - offset) {
/*     */     case 0: 
/*  98 */       if (mode == 0) {
/*  99 */         ret = new VectorProperty(this, index, "Handlers to Remove");
/* 100 */       } else if (mode == 1) {
/* 101 */         ret = this.handlers.clone();
/* 102 */       } else if (mode == 4) {
/* 103 */         this.handlers.removeElement(value);
/* 104 */       } else if (mode == 3)
/* 105 */         this.handlers.addElement(value);
/* 106 */       break;
/*     */     default: 
/* 108 */       ret = super.properties(index, offset + 1, mode, value);
/*     */     }
/*     */     
/* 111 */     return ret;
/*     */   }
/*     */ }


/* Location:              C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\RemoveHandler.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */