Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package net.minecraft.server;
2
3public class PlayerList {
4
5 private transient PlayerListEntry[] a = new PlayerListEntry[16];
6 private transient int b;
7 private int c = 12;
8 private final float d = 0.75F;
9 private transient volatile int e;
10
11 public PlayerList() {
12 }
13
14 private static int e(long i) {
15 return a((int) (i ^ i >>> 32));
16 }
17
18 private static int a(int i) {
19 i ^= i >>> 20 ^ i >>> 12;
20 return i ^ i >>> 7 ^ i >>> 4;
21 }
22
23 private static int a(int i, int j) {
24 return i & j - 1;
25 }
26
27 public Object a(long i) {
28 int j = e(i);
29
30 for (PlayerListEntry playerlistentry = this.a[a(j, this.a.length)]; playerlistentry != null; playerlistentry = playerlistentry.c) {
31 if (playerlistentry.a == i) {
32 return playerlistentry.b;
33 }
34 }
35
36 return null;
37 }
38
39 public void a(long i, Object object) {
40 int j = e(i);
41 int k = a(j, this.a.length);
42
43 for (PlayerListEntry playerlistentry = this.a[k]; playerlistentry != null; playerlistentry = playerlistentry.c) {
44 if (playerlistentry.a == i) {
45 playerlistentry.b = object;
46 }
47 }
48
49 ++this.e;
50 this.a(j, i, object, k);
51 }
52
53 private void b(int i) {
54 PlayerListEntry[] aplayerlistentry = this.a;
55 int j = aplayerlistentry.length;
56
57 if (j == 1073741824) {
58 this.c = Integer.MAX_VALUE;
59 } else {
60 PlayerListEntry[] aplayerlistentry1 = new PlayerListEntry[i];
61
62 this.a(aplayerlistentry1);
63 this.a = aplayerlistentry1;
64 this.c = (int) ((float) i * this.d);
65 }
66 }
67
68 private void a(PlayerListEntry[] aplayerlistentry) {
69 PlayerListEntry[] aplayerlistentry1 = this.a;
70 int i = aplayerlistentry.length;
71
72 for (int j = 0; j < aplayerlistentry1.length; ++j) {
73 PlayerListEntry playerlistentry = aplayerlistentry1[j];
74
75 if (playerlistentry != null) {
76 aplayerlistentry1[j] = null;
77
78 PlayerListEntry playerlistentry1;
79
80 do {
81 playerlistentry1 = playerlistentry.c;
82 int k = a(playerlistentry.d, i);
83
84 playerlistentry.c = aplayerlistentry[k];
85 aplayerlistentry[k] = playerlistentry;
86 playerlistentry = playerlistentry1;
87 } while (playerlistentry1 != null);
88 }
89 }
90 }
91
92 public Object b(long i) {
93 PlayerListEntry playerlistentry = this.c(i);
94
95 return playerlistentry == null ? null : playerlistentry.b;
96 }
97
98 final PlayerListEntry c(long i) {
99 int j = e(i);
100 int k = a(j, this.a.length);
101 PlayerListEntry playerlistentry = this.a[k];
102
103 PlayerListEntry playerlistentry1;
104 PlayerListEntry playerlistentry2;
105
106 for (playerlistentry1 = playerlistentry; playerlistentry1 != null; playerlistentry1 = playerlistentry2) {
107 playerlistentry2 = playerlistentry1.c;
108 if (playerlistentry1.a == i) {
109 ++this.e;
110 --this.b;
111 if (playerlistentry == playerlistentry1) {
112 this.a[k] = playerlistentry2;
113 } else {
114 playerlistentry.c = playerlistentry2;
115 }
116
117 return playerlistentry1;
118 }
119
120 playerlistentry = playerlistentry1;
121 }
122
123 return playerlistentry1;
124 }
125
126 private void a(int i, long j, Object object, int k) {
127 PlayerListEntry playerlistentry = this.a[k];
128
129 this.a[k] = new PlayerListEntry(i, j, object, playerlistentry);
130 if (this.b++ >= this.c) {
131 this.b(2 * this.a.length);
132 }
133 }
134
135 static int d(long i) {
136 return e(i);
137 }
138}