-
-
Notifications
You must be signed in to change notification settings - Fork 104
/
Handler_v1_12_R1.java
231 lines (200 loc) · 8.55 KB
/
Handler_v1_12_R1.java
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
package net.aufdemrand.denizen.nms;
import com.google.common.collect.Iterables;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import net.aufdemrand.denizen.nms.abstracts.AnimationHelper;
import net.aufdemrand.denizen.nms.abstracts.BiomeNMS;
import net.aufdemrand.denizen.nms.abstracts.BlockLight;
import net.aufdemrand.denizen.nms.abstracts.ParticleHelper;
import net.aufdemrand.denizen.nms.abstracts.ProfileEditor;
import net.aufdemrand.denizen.nms.abstracts.Sidebar;
import net.aufdemrand.denizen.nms.helpers.*;
import net.aufdemrand.denizen.nms.impl.BiomeNMS_v1_12_R1;
import net.aufdemrand.denizen.nms.impl.ProfileEditor_v1_12_R1;
import net.aufdemrand.denizen.nms.impl.Sidebar_v1_12_R1;
import net.aufdemrand.denizen.nms.impl.blocks.BlockLight_v1_12_R1;
import net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_12_R1;
import net.aufdemrand.denizen.nms.impl.packets.handlers.DenizenPacketListener_v1_12_R1;
import net.aufdemrand.denizen.nms.interfaces.*;
import net.aufdemrand.denizen.nms.interfaces.packets.PacketHandler;
import net.aufdemrand.denizen.nms.util.PlayerProfile;
import net.aufdemrand.denizen.nms.util.jnbt.CompoundTag;
import net.aufdemrand.denizen.nms.util.jnbt.Tag;
import net.aufdemrand.denizencore.utilities.debugging.dB;
import net.minecraft.server.v1_12_R1.MinecraftServer;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Biome;
import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import java.util.Map;
public class Handler_v1_12_R1 extends NMSHandler {
private final AdvancementHelper advancementHelper = new AdvancementHelper_v1_12_R1();
private final AnimationHelper animationHelper = new AnimationHelper_v1_12_R1();
private final BlockHelper blockHelper = new BlockHelper_v1_12_R1();
private final ChunkHelper chunkHelper = new ChunkHelper_v1_12_R1();
private final CustomEntityHelper customEntityHelper = new CustomEntityHelper_v1_12_R1();
private final EntityHelper entityHelper = new EntityHelper_v1_12_R1();
private final FishingHelper fishingHelper = new FishingHelper_v1_12_R1();
private final ItemHelper itemHelper = new ItemHelper_v1_12_R1();
private final SoundHelper soundHelper = new SoundHelper_v1_12_R1();
private final PacketHelper packetHelper = new PacketHelper_v1_12_R1();
private final ParticleHelper particleHelper = new ParticleHelper_v1_12_R1();
private final PlayerHelper playerHelper = new PlayerHelper_v1_12_R1();
private final WorldHelper worldHelper = new WorldHelper_v1_12_R1();
private final ProfileEditor profileEditor = new ProfileEditor_v1_12_R1();
@Override
public void disableAsyncCatcher() {
org.spigotmc.AsyncCatcher.enabled = false;
}
@Override
public Thread getMainThread() {
return ((CraftServer) Bukkit.getServer()).getServer().primaryThread;
}
@Override
public double[] getRecentTps() {
return ((CraftServer) Bukkit.getServer()).getServer().recentTps;
}
@Override
public AdvancementHelper getAdvancementHelper() {
return advancementHelper;
}
@Override
public AnimationHelper getAnimationHelper() {
return animationHelper;
}
@Override
public BlockHelper getBlockHelper() {
return blockHelper;
}
@Override
public ChunkHelper getChunkHelper() {
return chunkHelper;
}
@Override
public CustomEntityHelper getCustomEntityHelper() {
return customEntityHelper;
}
@Override
public EntityHelper getEntityHelper() {
return entityHelper;
}
@Override
public FishingHelper getFishingHelper() {
return fishingHelper;
}
@Override
public ItemHelper getItemHelper() {
return itemHelper;
}
@Override
public SoundHelper getSoundHelper() {
return soundHelper;
}
@Override
public PacketHelper getPacketHelper() {
return packetHelper;
}
@Override
public ParticleHelper getParticleHelper() {
return particleHelper;
}
@Override
public PlayerHelper getPlayerHelper() {
return playerHelper;
}
@Override
public WorldHelper getWorldHelper() {
return worldHelper;
}
@Override
public void enablePacketInterception(PacketHandler packetHandler) {
DenizenPacketListener_v1_12_R1.enable(packetHandler);
}
@Override
public CompoundTag createCompoundTag(Map<String, Tag> value) {
return new CompoundTag_v1_12_R1(value);
}
@Override
public Sidebar createSidebar(Player player) {
return new Sidebar_v1_12_R1(player);
}
@Override
public BlockLight createBlockLight(Location location, int lightLevel, long ticks) {
return BlockLight_v1_12_R1.createLight(location, lightLevel, ticks);
}
@Override
public PlayerProfile fillPlayerProfile(PlayerProfile playerProfile) {
try {
if (playerProfile != null) {
GameProfile gameProfile = new GameProfile(playerProfile.getUniqueId(), playerProfile.getName());
gameProfile.getProperties().get("textures").clear();
if (playerProfile.getTextureSignature() != null) {
gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture(), playerProfile.getTextureSignature()));
}
else {
gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture()));
}
MinecraftServer minecraftServer = ((CraftServer) Bukkit.getServer()).getServer();
GameProfile gameProfile1 = null;
if (gameProfile.getId() != null) {
gameProfile1 = minecraftServer.getUserCache().a(gameProfile.getId());
}
if (gameProfile1 == null && gameProfile.getName() != null) {
gameProfile1 = minecraftServer.getUserCache().getProfile(gameProfile.getName());
}
if (gameProfile1 == null) {
gameProfile1 = gameProfile;
}
if (playerProfile.hasTexture()) {
gameProfile1.getProperties().get("textures").clear();
if (playerProfile.getTextureSignature() != null) {
gameProfile1.getProperties().put("textures", new Property("textures", playerProfile.getTexture(), playerProfile.getTextureSignature()));
}
else {
gameProfile1.getProperties().put("textures", new Property("textures", playerProfile.getTexture()));
}
}
if (Iterables.getFirst(gameProfile1.getProperties().get("textures"), null) == null) {
gameProfile1 = minecraftServer.az().fillProfileProperties(gameProfile1, true);
}
Property property = Iterables.getFirst(gameProfile1.getProperties().get("textures"), null);
return new PlayerProfile(gameProfile1.getName(), gameProfile1.getId(),
property != null ? property.getValue() : null,
property != null ? property.getSignature() : null);
}
}
catch (Exception e) {
if (dB.verbose) {
dB.echoError(e);
}
}
return null;
}
@Override
public int getPort() {
return ((CraftServer) Bukkit.getServer()).getServer().P();
}
@Override
public String getTitle(Inventory inventory) {
return inventory.getTitle();
}
@Override
public PlayerProfile getPlayerProfile(Player player) {
GameProfile gameProfile = ((CraftPlayer) player).getProfile();
Property property = Iterables.getFirst(gameProfile.getProperties().get("textures"), null);
return new PlayerProfile(gameProfile.getName(), gameProfile.getId(),
property != null ? property.getValue() : null,
property != null ? property.getSignature() : null);
}
@Override
public ProfileEditor getProfileEditor() {
return profileEditor;
}
@Override
public BiomeNMS getBiomeNMS(Biome biome) {
return new BiomeNMS_v1_12_R1(biome);
}
}