Advertisement
Ravenbvutt

Untitled

Aug 11th, 2017
8,705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.64 KB | None | 0 0
  1. import java.awt.Graphics2D;
  2. import java.awt.geom.AffineTransform;
  3. import java.awt.image.BufferedImage;
  4. import java.util.ArrayList;
  5. import java.util.Collection;
  6. import java.util.Iterator;
  7. import java.util.List;
  8. import java.util.Map;
  9. import me.bigteddy98.bannerboard.Main;
  10. import me.bigteddy98.bannerboard.api.BannerBoardRenderer;
  11. import me.bigteddy98.bannerboard.api.Setting;
  12. import me.bigteddy98.bannerboard.c;
  13. import me.bigteddy98.bannerboard.cb1a1;
  14. import org.bukkit.Bukkit;
  15. import org.bukkit.ChatColor;
  16. import org.bukkit.Chunk;
  17. import org.bukkit.Location;
  18. import org.bukkit.Material;
  19. import org.bukkit.World;
  20. import org.bukkit.block.BlockFace;
  21. import org.bukkit.entity.Entity;
  22. import org.bukkit.entity.ItemFrame;
  23. import org.bukkit.entity.Player;
  24. import org.bukkit.inventory.ItemStack;
  25. import org.bukkit.plugin.Plugin;
  26. import org.bukkit.scheduler.BukkitTask;
  27.  
  28. public class e907 {
  29. private final int e907;
  30. private final List c;
  31. private final BlockFace b28;
  32. private final List db;
  33. private int d07;
  34. private final List c8f92;
  35. private int fed;
  36. private int dac4d;
  37. private int ea7fc;
  38.  
  39. private static boolean e907(Location location, Location location2) {
  40. if (location.getBlockX() == location2.getBlockX() && location.getBlockY() == location2.getBlockY() && location.getBlockZ() == location2.getBlockZ()) {
  41. return true;
  42. }
  43. return false;
  44. }
  45.  
  46. public e907(int n, List list, BlockFace blockFace) {
  47. this.db = new ArrayList();
  48. this.d07 = 0;
  49. this.c8f92 = new ArrayList();
  50. this.fed = -1;
  51. this.dac4d = -1;
  52. this.e907 = n;
  53. this.c = list;
  54. this.b28 = blockFace;
  55. }
  56.  
  57. private void c8f92(int n) {
  58. this.d07 = n;
  59. }
  60.  
  61. public final int e907() {
  62. return this.d07;
  63. }
  64.  
  65. public final List c() {
  66. return this.c;
  67. }
  68.  
  69. public final List b28() {
  70. ArrayList<ItemFrame> arrayList = new ArrayList<ItemFrame>();
  71. block0 : for (Location location : this.c) {
  72. for (Entity entity : location.getChunk().getEntities()) {
  73. if (!(entity instanceof ItemFrame)) continue;
  74. Location location2 = location;
  75. Location location3 = entity.getLocation();
  76. if (!(location3.getBlockX() == location2.getBlockX() && location3.getBlockY() == location2.getBlockY() && location3.getBlockZ() == location2.getBlockZ())) continue;
  77. arrayList.add((ItemFrame)entity);
  78. continue block0;
  79. }
  80. Bukkit.getConsoleSender().sendMessage((Object)ChatColor.RED + "[WARNING] [BannerBoard] Itemframe missing at " + location.toString() + ". Please restore the missing itemframe and restart your server to prevent errors.");
  81. }
  82. return arrayList;
  83. }
  84.  
  85. public final List e907(int n) {
  86. if (this.db.isEmpty()) {
  87. throw new RuntimeException("getMapIds() called before setSlides(), not allowed.");
  88. }
  89. return (List)this.db.get(n);
  90. }
  91.  
  92. public final int db() {
  93. return this.e907;
  94. }
  95.  
  96. public final BlockFace d07() {
  97. return this.b28;
  98. }
  99.  
  100. /*
  101. * WARNING - Removed try catching itself - possible behaviour change.
  102. */
  103. public final Collection c(int n) {
  104. List list = this.c8f92;
  105. synchronized (list) {
  106. return new ArrayList((Collection)this.c8f92.get(n));
  107. }
  108. }
  109.  
  110. /*
  111. * WARNING - Removed try catching itself - possible behaviour change.
  112. */
  113. private Collection d5bd() {
  114. ArrayList<BannerBoardRenderer> arrayList = new ArrayList<BannerBoardRenderer>();
  115. List list = this.c8f92;
  116. synchronized (list) {
  117. Iterator iterator = this.c8f92.iterator();
  118. while (iterator.hasNext()) {
  119. Object object = (List)iterator.next();
  120. object = object.iterator();
  121. while (object.hasNext()) {
  122. BannerBoardRenderer bannerBoardRenderer = (BannerBoardRenderer)object.next();
  123. arrayList.add(bannerBoardRenderer);
  124. }
  125. }
  126. }
  127. return arrayList;
  128. }
  129.  
  130. /*
  131. * WARNING - Removed try catching itself - possible behaviour change.
  132. */
  133. public final void e907(int n, BannerBoardRenderer bannerBoardRenderer) {
  134. List list = this.c8f92;
  135. synchronized (list) {
  136. if (this.c8f92.size() <= n) {
  137. this.c8f92.add(new ArrayList());
  138. }
  139. ((List)this.c8f92.get(n)).add(bannerBoardRenderer);
  140. return;
  141. }
  142. }
  143.  
  144. public final int c8f92() {
  145. if (this.fed != -1) {
  146. return this.fed;
  147. }
  148. Iterator iterator = this;
  149. iterator = iterator.c;
  150. int n = Integer.MAX_VALUE;
  151. int n2 = -2147483647;
  152. int n3 = Integer.MAX_VALUE;
  153. int n4 = -2147483647;
  154. iterator = iterator.iterator();
  155. while (iterator.hasNext()) {
  156. Location location = (Location)iterator.next();
  157. if (location.getBlockX() < n) {
  158. n = location.getBlockX();
  159. }
  160. if (location.getBlockX() > n2) {
  161. n2 = location.getBlockX();
  162. }
  163. if (location.getBlockZ() < n3) {
  164. n3 = location.getBlockZ();
  165. }
  166. if (location.getBlockZ() <= n4) continue;
  167. n4 = location.getBlockZ();
  168. }
  169. int n5 = -1;
  170. if (n3 == n4) {
  171. n5 = Math.abs(n - n2) + 1;
  172. }
  173. if (n == n2) {
  174. n5 = Math.abs(n3 - n4) + 1;
  175. }
  176. this.fed = n5;
  177. return n5;
  178. }
  179.  
  180. public final int fed() {
  181. int n;
  182. if (this.dac4d != -1) {
  183. return this.dac4d;
  184. }
  185. Iterator iterator = this;
  186. iterator = iterator.c;
  187. int n2 = Integer.MAX_VALUE;
  188. int n3 = -2147483647;
  189. iterator = iterator.iterator();
  190. while (iterator.hasNext()) {
  191. Location location = (Location)iterator.next();
  192. if (location.getBlockY() < n2) {
  193. n2 = location.getBlockY();
  194. }
  195. if (location.getBlockY() <= n3) continue;
  196. n3 = location.getBlockY();
  197. }
  198. this.dac4d = n = Math.abs(n2 - n3) + 1;
  199. return n;
  200. }
  201.  
  202. public final int dac4d() {
  203. return this.c8f92() << 7;
  204. }
  205.  
  206. public final int ea7fc() {
  207. return this.fed() << 7;
  208. }
  209.  
  210. public final BufferedImage e907(Player player, Map map, int n) {
  211. BufferedImage bufferedImage = new BufferedImage(this.dac4d(), this.ea7fc(), 2);
  212. Graphics2D graphics2D = bufferedImage.createGraphics();
  213. try {
  214. for (BannerBoardRenderer bannerBoardRenderer : this.c(n)) {
  215. Object object;
  216. if (bannerBoardRenderer.hasSetting("permission") && !player.hasPermission((String)(object = bannerBoardRenderer.getSetting("permission").getValue()))) continue;
  217. object = graphics2D.getTransform();
  218. boolean bl = bannerBoardRenderer.getSetting("angle") != null;
  219. if (bl) {
  220. String[] arrstring = bannerBoardRenderer.getSetting("angle").getValue().split(",");
  221. if (arrstring.length >= 3) {
  222. AffineTransform affineTransform = new AffineTransform();
  223. affineTransform.rotate(Math.toRadians(Integer.parseInt(arrstring[0])), Integer.parseInt(arrstring[1]), Integer.parseInt(arrstring[2]));
  224. graphics2D.transform(affineTransform);
  225. } else {
  226. bl = false;
  227. }
  228. }
  229. long l = System.currentTimeMillis();
  230. bannerBoardRenderer.render(player, bufferedImage, graphics2D);
  231. Object t = null;
  232. if (map.containsKey(bannerBoardRenderer.getId())) {
  233. t = map.get(bannerBoardRenderer.getId());
  234. }
  235. bannerBoardRenderer.render(player, bufferedImage, graphics2D, t);
  236. long l2 = System.currentTimeMillis() - l;
  237. if (l2 >= 3000) {
  238. Bukkit.getConsoleSender().sendMessage((Object)ChatColor.RED + "[WARNING] [BannerBoard] Took " + (double)l2 / 1000.0 + " second(s) to render " + bannerBoardRenderer.getClass().getSimpleName() + ", the server might be under heavy load, or did the system time change?");
  239. }
  240. if (!bl) continue;
  241. graphics2D.setTransform((AffineTransform)object);
  242. }
  243. BufferedImage bufferedImage2 = bufferedImage;
  244. return bufferedImage2;
  245. }
  246. finally {
  247. graphics2D.dispose();
  248. }
  249. }
  250.  
  251. public final void b28(int n) {
  252. long l = (long)n * 20;
  253. new c(this).runTaskTimer((Plugin)Main.e907(), l, l);
  254. }
  255.  
  256. public final void db(int n) {
  257. this.ea7fc = n;
  258. for (int i = 0; i < n; ++i) {
  259. if (i >= this.db.size()) {
  260. this.db.add(new ArrayList());
  261. }
  262. List list = this.b28();
  263. for (int j = 0; j < list.size(); ++j) {
  264. ((List)this.db.get(i)).add(Main.e907().e907.e907());
  265. }
  266. }
  267. this.d07(0);
  268. }
  269.  
  270. public final int cf79b() {
  271. if (this.ea7fc == 0) {
  272. throw new RuntimeException("getSlides() called before setSlides(), not allowed.");
  273. }
  274. return this.ea7fc;
  275. }
  276.  
  277. public final void d07(int n) {
  278. this.d07 = n;
  279. List list = this.b28();
  280. for (int i = 0; i < list.size(); ++i) {
  281. ItemStack itemStack = new ItemStack(Material.MAP, 1, ((Short)this.e907(n).get(i)).shortValue());
  282. ((ItemFrame)list.get(i)).setItem(itemStack);
  283. }
  284. }
  285.  
  286. static /* synthetic */ List e907(e907 e9072) {
  287. return e9072.c;
  288. }
  289.  
  290. public e907() {
  291. }
  292.  
  293. public static Object e907(List object) {
  294. ArrayList<String> arrayList = new ArrayList<String>();
  295. object = object.iterator();
  296. while (object.hasNext()) {
  297. Location location = (Location)object.next();
  298. arrayList.add(location.getWorld().getName() + "_" + location.getX() + "_" + location.getY() + "_" + location.getZ() + "_" + location.getYaw() + "_" + location.getPitch());
  299. }
  300. return arrayList;
  301. }
  302.  
  303. public static String e907(Location location) {
  304. return location.getWorld().getName() + "_" + location.getX() + "_" + location.getY() + "_" + location.getZ() + "_" + location.getYaw() + "_" + location.getPitch();
  305. }
  306.  
  307. public static List c(List object) {
  308. ArrayList<Location> arrayList = new ArrayList<Location>();
  309. object = object.iterator();
  310. while (object.hasNext()) {
  311. String string = (String)object.next();
  312. arrayList.add(e907.e907(string));
  313. }
  314. return arrayList;
  315. }
  316.  
  317. public static Location e907(String arrstring) {
  318. arrstring = arrstring.split("_");
  319. int n = arrstring.length - 6;
  320. StringBuilder stringBuilder = new StringBuilder();
  321. for (int i = 0; i <= n; ++i) {
  322. stringBuilder.append(arrstring[i]);
  323. if (i == n) continue;
  324. stringBuilder.append('_');
  325. }
  326. return new Location(Bukkit.getWorld((String)stringBuilder.toString()), Double.parseDouble(arrstring[n + 1]), Double.parseDouble(arrstring[n + 2]), Double.parseDouble(arrstring[n + 3]), Float.parseFloat(arrstring[n + 4]), Float.parseFloat(arrstring[n + 5]));
  327. }
  328. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement