Browse Source

Initial Commit, little bug fixes from the original code

for/master
pintu 5 years ago
commit
db9c34c9e1
  1. 16
      MultiArena-TheBridge/.classpath
  2. 17
      MultiArena-TheBridge/.project
  3. 10
      MultiArena-TheBridge/.settings/org.eclipse.core.resources.prefs
  4. 13
      MultiArena-TheBridge/.settings/org.eclipse.jdt.core.prefs
  5. 2
      MultiArena-TheBridge/.settings/org.eclipse.ltk.core.refactoring.prefs
  6. 433
      MultiArena-TheBridge/achievement.yml
  7. 1
      MultiArena-TheBridge/bin/.gitignore
  8. 37
      MultiArena-TheBridge/cages.yml
  9. BIN
      MultiArena-TheBridge/clear.schematic
  10. 132
      MultiArena-TheBridge/config.yml
  11. 3
      MultiArena-TheBridge/killsounds.yml
  12. 396
      MultiArena-TheBridge/lang.yml
  13. BIN
      MultiArena-TheBridge/normal-blue.schematic
  14. BIN
      MultiArena-TheBridge/normal-green.schematic
  15. BIN
      MultiArena-TheBridge/normal-red.schematic
  16. BIN
      MultiArena-TheBridge/normal-yellow.schematic
  17. 10
      MultiArena-TheBridge/plugin.yml
  18. 3
      MultiArena-TheBridge/signs.yml
  19. 13
      MultiArena-TheBridge/sounds.yml
  20. 467
      MultiArena-TheBridge/src/cx/sfy/TheBridge/Main.java
  21. 102
      MultiArena-TheBridge/src/cx/sfy/TheBridge/Settings.java
  22. 120
      MultiArena-TheBridge/src/cx/sfy/TheBridge/archievements/Archi.java
  23. 11
      MultiArena-TheBridge/src/cx/sfy/TheBridge/archievements/ArchiType.java
  24. 15
      MultiArena-TheBridge/src/cx/sfy/TheBridge/client/ClientPacket.java
  25. 1069
      MultiArena-TheBridge/src/cx/sfy/TheBridge/cmds/SetupCMD.java
  26. 174
      MultiArena-TheBridge/src/cx/sfy/TheBridge/controllers/WorldController.java
  27. 159
      MultiArena-TheBridge/src/cx/sfy/TheBridge/cosmetics/cages/Cage.java
  28. 9
      MultiArena-TheBridge/src/cx/sfy/TheBridge/cosmetics/killsounds/KillSound.java
  29. 255
      MultiArena-TheBridge/src/cx/sfy/TheBridge/database/Cosmeticbase.java
  30. 570
      MultiArena-TheBridge/src/cx/sfy/TheBridge/database/Database.java
  31. 254
      MultiArena-TheBridge/src/cx/sfy/TheBridge/database/PlayerStat.java
  32. 65
      MultiArena-TheBridge/src/cx/sfy/TheBridge/fanciful/ArrayWrapper.java
  33. 407
      MultiArena-TheBridge/src/cx/sfy/TheBridge/fanciful/FancyMessage.java
  34. 11
      MultiArena-TheBridge/src/cx/sfy/TheBridge/fanciful/JsonRepresentedObject.java
  35. 42
      MultiArena-TheBridge/src/cx/sfy/TheBridge/fanciful/JsonString.java
  36. 152
      MultiArena-TheBridge/src/cx/sfy/TheBridge/fanciful/MessagePart.java
  37. 211
      MultiArena-TheBridge/src/cx/sfy/TheBridge/fanciful/TextualComponent.java
  38. 753
      MultiArena-TheBridge/src/cx/sfy/TheBridge/game/Game.java
  39. 944
      MultiArena-TheBridge/src/cx/sfy/TheBridge/game/GameFour.java
  40. 83
      MultiArena-TheBridge/src/cx/sfy/TheBridge/game/InventoryData.java
  41. 83
      MultiArena-TheBridge/src/cx/sfy/TheBridge/game/PlayerData.java
  42. 21
      MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologram.java
  43. 46
      MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologramAPI.java
  44. 283
      MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologram_v1_10_R1.java
  45. 283
      MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologram_v1_11_R1.java
  46. 283
      MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologram_v1_12_R1.java
  47. 283
      MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologram_v1_8_R3.java
  48. 283
      MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologram_v1_9_R2.java
  49. 85
      MultiArena-TheBridge/src/cx/sfy/TheBridge/hooks/PlaceholderHook.java
  50. 87
      MultiArena-TheBridge/src/cx/sfy/TheBridge/kit/Hotbar.java
  51. 82
      MultiArena-TheBridge/src/cx/sfy/TheBridge/kit/Kit.java
  52. 22
      MultiArena-TheBridge/src/cx/sfy/TheBridge/leaderheads/TheBridgeFourGoals.java
  53. 22
      MultiArena-TheBridge/src/cx/sfy/TheBridge/leaderheads/TheBridgeFourKills.java
  54. 22
      MultiArena-TheBridge/src/cx/sfy/TheBridge/leaderheads/TheBridgeFourWins.java
  55. 22
      MultiArena-TheBridge/src/cx/sfy/TheBridge/leaderheads/TheBridgeNormalGoals.java
  56. 22
      MultiArena-TheBridge/src/cx/sfy/TheBridge/leaderheads/TheBridgeNormalKills.java
  57. 22
      MultiArena-TheBridge/src/cx/sfy/TheBridge/leaderheads/TheBridgeNormalWins.java
  58. 1421
      MultiArena-TheBridge/src/cx/sfy/TheBridge/listeners/PlayerListener.java
  59. 159
      MultiArena-TheBridge/src/cx/sfy/TheBridge/listeners/SetupListener.java
  60. 393
      MultiArena-TheBridge/src/cx/sfy/TheBridge/listeners/SpectatorListener.java
  61. 82
      MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/ArchiManager.java
  62. 70
      MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/CageManager.java
  63. 44
      MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/FileManager.java
  64. 380
      MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/GameManager.java
  65. 252
      MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/GlassManager.java
  66. 5
      MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/KillSoundManager.java
  67. 128
      MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/LocationManager.java
  68. 288
      MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/ScoreboardManager.java
  69. 45
      MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/SetupManager.java
  70. 202
      MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/SignManager.java
  71. 73
      MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/TitleManager.java
  72. 251
      MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/TopManager.java
  73. 212
      MultiArena-TheBridge/src/cx/sfy/TheBridge/menus/AchievementsMenu.java
  74. 121
      MultiArena-TheBridge/src/cx/sfy/TheBridge/menus/GameMenu.java
  75. 33
      MultiArena-TheBridge/src/cx/sfy/TheBridge/menus/GlassMenu.java
  76. 29
      MultiArena-TheBridge/src/cx/sfy/TheBridge/menus/ShopMenu.java
  77. 49
      MultiArena-TheBridge/src/cx/sfy/TheBridge/menus/SpectOptionsMenu.java
  78. 81
      MultiArena-TheBridge/src/cx/sfy/TheBridge/menus/SpectPlayerMenu.java
  79. 97
      MultiArena-TheBridge/src/cx/sfy/TheBridge/menus/TeamMenu.java
  80. 54
      MultiArena-TheBridge/src/cx/sfy/TheBridge/nms/GenericNMS.java
  81. 12
      MultiArena-TheBridge/src/cx/sfy/TheBridge/nms/NMS.java
  82. 31
      MultiArena-TheBridge/src/cx/sfy/TheBridge/packets/PacketHandler.java
  83. 104
      MultiArena-TheBridge/src/cx/sfy/TheBridge/packets/PacketInjector.java
  84. 33
      MultiArena-TheBridge/src/cx/sfy/TheBridge/packets/PacketMain.java
  85. 332
      MultiArena-TheBridge/src/cx/sfy/TheBridge/packets/Reflection.java
  86. 29
      MultiArena-TheBridge/src/cx/sfy/TheBridge/packets/ServerPackage.java
  87. 43
      MultiArena-TheBridge/src/cx/sfy/TheBridge/signs/GameFourSign.java
  88. 43
      MultiArena-TheBridge/src/cx/sfy/TheBridge/signs/GameNormalSign.java
  89. 180
      MultiArena-TheBridge/src/cx/sfy/TheBridge/team/Team.java
  90. 247
      MultiArena-TheBridge/src/cx/sfy/TheBridge/team/TeamFour.java
  91. 12
      MultiArena-TheBridge/src/cx/sfy/TheBridge/tops/BoardType.java
  92. 36
      MultiArena-TheBridge/src/cx/sfy/TheBridge/tops/Top.java
  93. 165
      MultiArena-TheBridge/src/cx/sfy/TheBridge/utils/CenterMessage.java
  94. 30
      MultiArena-TheBridge/src/cx/sfy/TheBridge/utils/Chat.java
  95. 73
      MultiArena-TheBridge/src/cx/sfy/TheBridge/utils/ConvertBase64.java
  96. 189
      MultiArena-TheBridge/src/cx/sfy/TheBridge/utils/ItemBuilder.java
  97. 19
      MultiArena-TheBridge/src/cx/sfy/TheBridge/utils/MathUtils.java
  98. 7
      MultiArena-TheBridge/src/cx/sfy/TheBridge/utils/PaperOnly.java
  99. 179
      MultiArena-TheBridge/src/cx/sfy/TheBridge/utils/ScoreboardUtil.java
  100. 49
      MultiArena-TheBridge/src/cx/sfy/TheBridge/utils/Tagged.java

16
MultiArena-TheBridge/.classpath

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="C:/Users/pintu/Desktop/SpigotJars/FastAsyncWorldEdit-bukkit-19.04.22-57c85d0-1271-22.0.6.jar"/>
<classpathentry kind="lib" path="C:/Users/pintu/Desktop/SpigotJars/LeaderHeads.jar"/>
<classpathentry kind="lib" path="C:/Users/pintu/Desktop/SpigotJars/PlaceholderAPI-2.9.2.jar"/>
<classpathentry kind="lib" path="C:/Users/pintu/Desktop/SpigotJars/spigot-1.9.4-R0.1-SNAPSHOT-latest.jar"/>
<classpathentry kind="lib" path="C:/Users/pintu/Desktop/SpigotJars/spigot-1.8.8-R0.1-SNAPSHOT-latest.jar"/>
<classpathentry kind="lib" path="C:/Users/pintu/Desktop/SpigotJars/worldedit-bukkit-6.1.9.jar"/>
<classpathentry kind="lib" path="C:/Users/pintu/Desktop/SpigotJars/paperspigot-api-1.8.8-R0.1-20160806.221350-1.jar"/>
<classpathentry kind="lib" path="C:/Users/pintu/Desktop/SpigotJars/spigot-1.10.2-R0.1-SNAPSHOT-latest.jar"/>
<classpathentry kind="lib" path="C:/Users/pintu/Desktop/SpigotJars/spigot-1.11.2.jar"/>
<classpathentry kind="lib" path="C:/Users/pintu/Desktop/SpigotJars/spigot-1.12.2.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

17
MultiArena-TheBridge/.project

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>MultiArena-TheBridge</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

10
MultiArena-TheBridge/.settings/org.eclipse.core.resources.prefs

@ -0,0 +1,10 @@
eclipse.preferences.version=1
encoding//src/cx/sfy/TheBridge/game/Game.java=UTF-8
encoding//src/cx/sfy/TheBridge/game/GameFour.java=UTF-8
encoding//src/cx/sfy/TheBridge/kit/Hotbar.java=UTF-8
encoding//src/cx/sfy/TheBridge/listeners/PlayerListener.java=UTF-8
encoding//src/cx/sfy/TheBridge/menus/AchievementsMenu.java=UTF-8
encoding//src/cx/sfy/TheBridge/packets/PacketMain.java=UTF-8
encoding//src/cx/sfy/TheBridge/packets/Reflection.java=UTF-8
encoding//src/cx/sfy/TheBridge/team/TeamFour.java=UTF-8
encoding//src/cx/sfy/TheBridge/utils/ScoreboardUtil.java=UTF-8

13
MultiArena-TheBridge/.settings/org.eclipse.jdt.core.prefs

@ -0,0 +1,13 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8

2
MultiArena-TheBridge/.settings/org.eclipse.ltk.core.refactoring.prefs

@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false

433
MultiArena-TheBridge/achievement.yml

@ -0,0 +1,433 @@
title: "&b&lArchievements - &e<player>"
archivements: "&aArchievements <arrow>"
back: "&eBack Page <back>"
next: "&eNext Page <next>"
close:
item: BARRIER
data: 0
amount: 1
name: "&cClose"
lore: |-
&7Click to close
&7this menu.
kills:
item: DIAMOND_SWORD
data: 0
amount: 1
name: "&aKill Archievements"
lore: |-
&7Archievements of kills
&7players in games.
wins:
item: DIAMOND
data: 0
amount: 1
name: "&aWin Archievements"
lore: |-
&7Archievements of win
&7games.
goals:
item: ENDER_PORTAL_FRAME
data: 0
amount: 1
name: "&aGoal Archievements"
lore: |-
&7Archievements of goals
&7players in games.
blocks_placed:
item: WOOD
data: 0
amount: 1
name: "&aBlocks Place Archievements"
lore: |-
&7Archievements of blocks
&7placed in games.
blocks_bloken:
item: DIAMOND_PICKAXE
data: 0
amount: 1
name: "&aBlocks Break Archievements"
lore: |-
&7Archievements of blocks
&7broken in games.
unlocked:
item: STAINED_GLASS_PANE
data: 5
amount: 1
name: "&a<name>"
lore:
- "&e<description>"
- "&7"
- "&7Reward:"
- "&8+ &3<xp> TheBridge Experience"
- "&8+ &6<money> TheBridge Coins"
- "&7"
- "&7Completed: &aDONE! &7(&a<current>&7)"
- "&7"
- "&aAchievement Unlocked!"
locked:
item: STAINED_GLASS_PANE
data: 14
amount: 1
name: "&c<name>"
lore:
- "&e<description>"
- "&7"
- "&7Reward:"
- "&8+ &3<xp> TheBridge Experience"
- "&8+ &6<money> TheBridge Coins"
- "&7"
- "&7Completed: &a<current>&7/&a<max>"
- "&7"
- "&cAchievement Locked!"
archievements:
kills-I:
type: KILLS
name: "Killer I"
description: "Kill 50 TheBridge Players"
amount: 50
messages:
- "&aAchievement: Killer I Completed!"
- "&7 &8+ &320 The Bridge Experience."
- "&7 &8+ &620 The Bridge Coins."
rewards:
xp: 20
money: 20
commands:
- "none"
wins-I:
type: WINS
name: "Winner I"
description: "Win 5 TheBridge Games"
amount: 5
messages:
- "&aAchievement: Winner I Completed!"
- "&7 &8+ &320 The Bridge Experience."
- "&7 &8+ &620 The Bridge Coins."
rewards:
xp: 20
money: 20
commands:
- "none"
goals-I:
type: GOALS
name: "Scorer I"
description: "Score 50 TheBridge Goals"
amount: 50
messages:
- "&aAchievement: Scorer I Completed!"
- "&7 &8+ &320 The Bridge Experience."
- "&7 &8+ &620 The Bridge Coins."
rewards:
xp: 20
money: 20
commands:
- "none"
placed-I:
type: BLOCKS_PLACED
name: "Block Placer I"
description: "Place 250 Blocks TheBridge Games"
amount: 250
messages:
- "&aAchievement: Block Placer I Completed!"
- "&7 &8+ &320 The Bridge Experience."
- "&7 &8+ &620 The Bridge Coins."
rewards:
xp: 20
money: 20
commands:
- "none"
broken-I:
type: BLOCKS_BROKEN
name: "Block Breaker I"
description: "Break 50 Blocks TheBridge Games"
amount: 50
messages:
- "&aAchievement: Block Breaker I Completed!"
- "&7 &8+ &320 The Bridge Experience."
- "&7 &8+ &620 The Bridge Coins."
rewards:
xp: 20
money: 20
commands:
- "none"
kills-II:
type: KILLS
name: "Killer II"
description: "Kill 100 TheBridge Players"
amount: 100
messages:
- "&aAchievement: Killer II Completed!"
- "&7 &8+ &340 The Bridge Experience."
- "&7 &8+ &640 The Bridge Coins."
rewards:
xp: 40
money: 40
commands:
- "none"
wins-II:
type: WINS
name: "Winner II"
description: "Win 15 TheBridge Games"
amount: 15
messages:
- "&aAchievement: Winner II Completed!"
- "&7 &8+ &340 The Bridge Experience."
- "&7 &8+ &640 The Bridge Coins."
rewards:
xp: 40
money: 40
commands:
- "none"
goals-II:
type: GOALS
name: "Scorer II"
description: "Score 100 TheBridge Goals"
amount: 100
messages:
- "&aAchievement: Scorer II Completed!"
- "&7 &8+ &340 The Bridge Experience."
- "&7 &8+ &640 The Bridge Coins."
rewards:
xp: 40
money: 40
commands:
- "none"
placed-II:
type: BLOCKS_PLACED
name: "Block Placer II"
description: "Place 600 Blocks TheBridge Games"
amount: 600
messages:
- "&aAchievement: Block Placer II Completed!"
- "&7 &8+ &340 The Bridge Experience."
- "&7 &8+ &640 The Bridge Coins."
rewards:
xp: 40
money: 40
commands:
- "none"
broken-II:
type: BLOCKS_BROKEN
name: "Block Breaker II"
description: "Break 100 Blocks TheBridge Games"
amount: 100
messages:
- "&aAchievement: Block Breaker II Completed!"
- "&7 &8+ &340 The Bridge Experience."
- "&7 &8+ &640 The Bridge Coins."
rewards:
xp: 40
money: 40
commands:
- "none"
kills-III:
type: KILLS
name: "Killer III"
description: "Kill 150 TheBridge Players"
amount: 150
messages:
- "&aAchievement: Killer III Completed!"
- "&7 &8+ &360 The Bridge Experience."
- "&7 &8+ &660 The Bridge Coins."
rewards:
xp: 60
money: 60
commands:
- "none"
wins-III:
type: WINS
name: "Winner III"
description: "Win 50 TheBridge Games"
amount: 50
messages:
- "&aAchievement: Winner III Completed!"
- "&7 &8+ &360 The Bridge Experience."
- "&7 &8+ &660 The Bridge Coins."
rewards:
xp: 60
money: 60
commands:
- "none"
goals-III:
type: GOALS
name: "Scorer III"
description: "Score 150 TheBridge Goals"
amount: 150
messages:
- "&aAchievement: Scorer III Completed!"
- "&7 &8+ &360 The Bridge Experience."
- "&7 &8+ &660 The Bridge Coins."
rewards:
xp: 60
money: 60
commands:
- "none"
placed-III:
type: BLOCKS_PLACED
name: "Block Placer III"
description: "Place 1500 Blocks TheBridge Games"
amount: 1500
messages:
- "&aAchievement: Block Placer III Completed!"
- "&7 &8+ &360 The Bridge Experience."
- "&7 &8+ &660 The Bridge Coins."
rewards:
xp: 60
money: 60
commands:
- "none"
broken-III:
type: BLOCKS_BROKEN
name: "Block Breaker III"
description: "Break 150 Blocks TheBridge Games"
amount: 150
messages:
- "&aAchievement: Block Breaker III Completed!"
- "&7 &8+ &360 The Bridge Experience."
- "&7 &8+ &660 The Bridge Coins."
rewards:
xp: 60
money: 60
commands:
- "none"
kills-IV:
type: KILLS
name: "Killer IV"
description: "Kill 200 TheBridge Players"
amount: 200
messages:
- "&aAchievement: Killer IV Completed!"
- "&7 &8+ &380 The Bridge Experience."
- "&7 &8+ &680 The Bridge Coins."
rewards:
xp: 80
money: 80
commands:
- "none"
wins-IV:
type: WINS
name: "Winner IV"
description: "Win 200 TheBridge Games"
amount: 200
messages:
- "&aAchievement: Winner IV Completed!"
- "&7 &8+ &380 The Bridge Experience."
- "&7 &8+ &680 The Bridge Coins."
rewards:
xp: 80
money: 80
commands:
- "none"
goals-IV:
type: GOALS
name: "Scorer IV"
description: "Score 200 TheBridge Goals"
amount: 200
messages:
- "&aAchievement: Scorer IV Completed!"
- "&7 &8+ &380 The Bridge Experience."
- "&7 &8+ &680 The Bridge Coins."
rewards:
xp: 80
money: 80
commands:
- "none"
placed-IV:
type: BLOCKS_PLACED
name: "Block Placer IV"
description: "Place 3000 Blocks TheBridge Games"
amount: 3000
messages:
- "&aAchievement: Block Placer IV Completed!"
- "&7 &8+ &380 The Bridge Experience."
- "&7 &8+ &680 The Bridge Coins."
rewards:
xp: 80
money: 80
commands:
- "none"
broken-IV:
type: BLOCKS_BROKEN
name: "Block Breaker IV"
description: "Break 200 Blocks TheBridge Games"
amount: 200
messages:
- "&aAchievement: Block Breaker IV Completed!"
- "&7 &8+ &380 The Bridge Experience."
- "&7 &8+ &680 The Bridge Coins."
rewards:
xp: 80
money: 80
commands:
- "none"
kills-V:
type: KILLS
name: "Killer V"
description: "Kill 250 TheBridge Players"
amount: 250
messages:
- "&aAchievement: Killer V Completed!"
- "&7 &8+ &3100 The Bridge Experience."
- "&7 &8+ &6100 The Bridge Coins."
rewards:
xp: 100
money: 100
commands:
- "none"
wins-V:
type: WINS
name: "Winner V"
description: "Win 250 TheBridge Games"
amount: 250
messages:
- "&aAchievement: Winner V Completed!"
- "&7 &8+ &3100 The Bridge Experience."
- "&7 &8+ &6100 The Bridge Coins."
rewards:
xp: 100
money: 100
commands:
- "none"
goals-IV:
type: GOALS
name: "Scorer V"
description: "Score 250 TheBridge Goals"
amount: 250
messages:
- "&aAchievement: Scorer V Completed!"
- "&7 &8+ &3100 The Bridge Experience."
- "&7 &8+ &6100 The Bridge Coins."
rewards:
xp: 100
money: 100
commands:
- "none"
placed-V:
type: BLOCKS_PLACED
name: "Block Placer V"
description: "Place 5000 Blocks TheBridge Games"
amount: 5000
messages:
- "&aAchievement: Block Placer V Completed!"
- "&7 &8+ &3100 The Bridge Experience."
- "&7 &8+ &6100 The Bridge Coins."
rewards:
xp: 100
money: 100
commands:
- "none"
broken-V:
type: BLOCKS_BROKEN
name: "Block Breaker V"
description: "Break 250 Blocks TheBridge Games"
amount: 250
messages:
- "&aAchievement: Block Breaker V Completed!"
- "&7 &8+ &3100 The Bridge Experience."
- "&7 &8+ &6100 The Bridge Coins."
rewards:
xp: 100
money: 100
commands:
- "none"

1
MultiArena-TheBridge/bin/.gitignore

@ -0,0 +1 @@
/cx/

37
MultiArena-TheBridge/cages.yml

@ -0,0 +1,37 @@
size: 36
title: "&aThe Bridge - Cages"
unlocked:
- "<description>"
- "&7"
- "&eClick to select!"
noPerm:
- "<description>"
- "&7"
- "&aPrice: &6<price>"
- "&7"
- "&cYou dont have permission!"
locked:
- "<description>"
- "&7"
- "&aPrice: &6<price>"
- "&7"
- "&eClick to buy this!"
cages:
default:
icon: GLASS
data: 0
amount: 1
slot: 0
price: 0
isBuy: true
name: "Default Glass"
clearFile: "clear.schematic"
files:
red: "normal-red.schematic"
blue: "normal-blue.schematic"
yellow: "normal-yellow.schematic"
green: "normal-green.schematic"
permission: bridges.cage.default
description:
- "&fDefault glass to all"
- "&fplayers"

BIN
MultiArena-TheBridge/clear.schematic

Binary file not shown.

132
MultiArena-TheBridge/config.yml

@ -0,0 +1,132 @@
mainLobby: null
server: ServerName
update: true
cages: false
permFormat: pex user <name> add <permission>
defaultCage: "default"
chat:
enabled: true
lobby: "&b[TheBridge] &e<player>: &7<msg>"
ingame: "<teamColor>[<teamName>] <player>: &7<msg>"
global: "&6[GLOBAL] <teamColor> <teamName> <player>: &7<msg>"
archievements:
disable: false
remove:
absorption: false
regeneration: false
bow:
seconds: 3
shop:
size: 27
glass:
slot: 4
icon: STAINED_GLASS
data: 0
amount: 1
close:
slot: 22
icon: BARRIER
data: 0
amount: 1
coins:
normal:
kill: 2
win: 50
goals: 0
four:
kill: 2
win: 50
goals: 0
xp:
normal:
kill: 1
win: 10
goals: 0
four:
kill: 1
win: 10
goals: 0
items:
shop:
enabled: false
material: DIAMOND
data: 0
amount: 1
slot: 3
nameItem: "&aThe Bridge | Shop"
loreItem: |-
&7Click to open
&7shop of the bridge.
hotbar:
enabled: false
material: CHEST
data: 0
amount: 1
slot: 5
nameItem: "&aHotbar Editor"
loreItem: |-
&7Click to open
&7hotbar editor.
menu:
enabled: false
material: BOOK
data: 0
amount: 1
slot: 4
nameItem: "&aGame Selector"
loreItem: |-
&7Click to open
&7menu of select games.
random:
enabled: false
material: FEATHER
data: 0
amount: 1
slot: 8
nameItem: "&eRandom Join"
loreItem: |-
&7Click to random
&7join a game.
names:
red: "Red"
blue: "Blue"
yellow: "Yellow"
green: "Green"
signs:
waiting: 5
starting: 4
pregame: 6
ingame: 14
finish: 11
restart: 15
MySQL:
enabled: false
username: Insider
password: spigot
database: Martu
host: 127.0.0.1
port: 3306
stats: null
tops:
normal:
kills: null
wins: null
goals: null
four:
kills: null
wins: null
goals: null
title:
prestart:
fadein: 0
stayin: 21
fadeout: 0
start:
fadein: 0
stayin: 21
fadeout: 0
restart:
fadein: 0
stayin: 21
fadeout: 0
kit: null

3
MultiArena-TheBridge/killsounds.yml

@ -0,0 +1,3 @@
killsounds:
default:

396
MultiArena-TheBridge/lang.yml

@ -0,0 +1,396 @@
prefix: "&6&lTheBridge &7:"
error: "&c&lERROR!"
signs:
normal:
line-1: "&lTheBridge Normal"
line-2: <state>
line-3: "Map: <name>"
line-4: "&7<players>/<max>"
four:
line-1: "&lTheBridge Four"
line-2: <state>
line-3: "Map: <name>"
line-4: "&7<players>/<max>"
states:
waiting: "&aWaiting..."
starting: "&eStarting"
pregame: "&cPre-Game"
ingame: "&4In-Game"
finish: "&9Finishing"
restarting: "&5Restarting"
shop:
title: "&aThe Bridge | Shop"
glass:
nameItem: "&aCage Shop"
loreItem: |-
&7Click to open
&7the cage Shop.
close:
nameItem: "&cClose"
loreItem: |-
&7Click to close
&7this shop
holograms:
your: "Your"
portal:
you:
- "<color>&l<team> Goal"
- "&7Defend!"
enemy:
- "<color>&l<team> Goal"
- "&eJump in to score!"
tops:
normal:
kills:
- "&b&lTop TheBridge Kills"
- "&aNormal mode"
- <top>
wins:
- "&b&lTop TheBridge Winners"
- "&aNormal mode"
- <top>
goals:
- "&b&lTop TheBridge Goal scorers"
- "&aNormal mode"
- <top>
four:
kills:
- "&b&lTop TheBridge Kills"
- "&aFour mode"
- <top>
wins:
- "&b&lTop TheBridge Winners"
- "&aFour mode"
- <top>
goals:
- "&b&lTop TheBridge Goal scorers"
- "&aFour mode"
- <top>
stats:
- "&a%player_name% &6&lThe Bridge &astatistics"
- "&aNormal Kills: &6%bridges_normal_kills%"
- "&aNormal Wins: &6%bridges_normal_wins%"
- "&aNormal Goals: &6%bridges_normal_goals%"
- "&aFour Kills: &6%bridges_four_kills%"
- "&aFour Wins: &6%bridges_four_wins%"
- "&aFour Goals: &6%bridges_four_goals%"
- "&aBlocks Placed: &6%bridges_blocks_placed%"
- "&aBlocks Broken: &6%bridges_blocks_broken%"
- "&aCoins: &6%bridges_coins%"
- "&aXP: &6%bridges_xp%"
deathMessages:
void: <TDColor><death> &7was thrown into the void
damage: <TDColor><death> &7was killed
custom: <TDColor><death> &7was death
player: "&7 by <TKColor><player>&7."
none: .
messages:
noPermission: "&cYou dont have permissions to run this command."
noBreak: "&cYou can only break blocks allowed blocks."
noPlace: "&cYou are not allowed to build here."
starting: "&eThe game starts in &b<time> &e<units>."
prestart: "&eCages are opening in &b<time> &e<units>."
restart: "&eCages are reopening in &b<time> &e<units>."
alreadyGame: "&cThis player is already in a game."
noGame: "&cYou are not in any game."
join: "&7<player> &ehas joined the game &b(&e<players>&b/&e<max>&b)!"
quit: "&7<player> &ehas left the game &b(&e<players>&b/&e<max>&b)!"
eliminated: <color>&l<player> &c&lhas been eliminated.
gameFull: "&cThis game is already full."
gameAlreadyStart: "&cThis game has already started."
joinedTeam: "&eYou joined a team <team>&e."
unbalancedTeam: "&cThat team is full. Try joining another one"
noHaveKit: "&cYou haven't set up the main kit yet."
noGames: "&cThere are no free games available."
hotbarSaved: "&aYour hotbar has been saved."
noBuy: "&cYou are not allowed to buy this."
noMoney: "&cYou dont have money to do this."
buyCage: "&aYou successfuly bought the &e<cage> cage."
selectedCage: "&aYou have just selected the &e<cage>&a cage."
leftGame: "&cYou left the game."
noShoot: "&cYou can not shoot the bow yet."
archiDisabled: "&cAchievements are currently disabled."
noEnabedGlass: "&cCages are currently not enabled. Please use FastAsyncWorldEdit to enable them."
start:
- "&a&m&l---------------------------------------------"
- "&7&f&lThe Bridge"
- "&7"
- "&e&lThe only goal is to enter the portal of the"
- "&e&lAnother team in order to score a goal."
- "&e&lThe team that bequeath 5 goals first"
- "&e&lwin the game."
- "&7"
- "&a&m&l---------------------------------------------"
startFour:
- "&a&m&l---------------------------------------------"
- "&7&f&lThe Bridge"
- "&7"
- "&eCross bridges to score goals on enemy teams,"
- "&egoals you steal. Each team starts with &a2<heart> (lifes)&e."
- "&eScoring &a+1<heart> &efor your computer while allowing you to"
- "&ethose affected lose &c-1<heart> &eof your team."
- "&7"
- "&eWhen there are 2 teams left, you can not"
- "&eregaining lives! The last team on foot wins!"
- "&7"
- "&a&m&l---------------------------------------------"
goal:
- "&a&m&l---------------------------------------------"
- "&7"
- "&7<color>&l<player> &7(&a<health>&c<heart>&7) &ehas scored! &7(&6<goals> Gol<s>&7)"
- "&7"
- "&7<color>&l<team> GOAL!!"
- "&7&c&l<redGoals> &e&l- &9&l<blueGoals> "
- "&7"
- "&a&m&l---------------------------------------------"
stole:
- "&a&m&l---------------------------------------------"
- "&7"
- <color>&l<player> &7(&a<health>&c<heart>&7) scored &c<teamStole>&7! (&6<goals> Gol<es>&7)
- <teamOther> &7stolen <color>1<heart> &7of <teamStole>&7!
- "&7"
- <green> &8- <greenLife>
- <blue> &8- <blueLife>
- <red> &8- <redLife>
- <yellow> &8- <yellowLife>
- "&7"
- "&a&m&l---------------------------------------------"
final:
- "&a&m&l---------------------------------------------"
- "&7"
- <color>&l<player> &7(&a<health>&c<heart>&7) scored &c<teamStole>&7! (&6<goals> Gol<es>&7)
- <teamStole> &7lost &c-1<heart>&7!
- "&7"
- <green> &8- <greenLife>
- <blue> &8- <blueLife>
- <red> &8- <redLife>
- <yellow> &8- <yellowLife>
- "&7"
- "&a&m&l---------------------------------------------"
win:
- "&a&m&l---------------------------------------------"
- "&7&f&lThe Bridge"
- "&7"
- "&7<color>&l<team> WIN!"
- "&7<color>&l<player> &7(&a<health>&c<heart>&7) &ehas scored! &7(&6<goals> Gol<s>&7)"
- "&7"
- "&c&l<redGoals> &7&l- &9&l<blueGoals>"
- "&7"
- "&a&m&l---------------------------------------------"
winFour:
- "&a&m&l---------------------------------------------"
- "&7&f&lThe Bridge"
- "&7"
- <color>&l<team> WIN!
- <color>&l<player> &7(&a<health>&c<heart>&7) scored &c<teamStole>&7! (&6<goals> Gol<es>&7)
- "&7"
- <green> &8- <greenLife>
- <blue> &8- <blueLife>
- <red> &8- <redLife>
- <yellow> &8- <yellowLife>
- "&7"
- "&a&m&l---------------------------------------------"
setup:
worldCreated: "&aThe world &e<name> &ahas been created."
minSet: "&aMinimum established. At location: &e<world> - <x>, <y>, <z>, <yaw>, <pitch>&a."
maxSet: "&aMaximum established. At location: &e<world> - <x>, <y>, <z>, <yaw>, <pitch>&a."
menus:
team:
title: "&eTeam Selector"
team:
nameItem: "Team <#>"
loreItem:
- "&bPlayers:"
- "&7"
- "<teamPlayers>"
teamFour:
title: "&eTeam Four Selector"
team:
nameItem: "Team Four <#>"
loreItem:
- "&bPlayers:"
- "&7"
- "<teamPlayers>"
options:
title: "Spectator Options"
enable: "&aEnable"
disable: "&cDisable"
velocidad:
nameItem: "&aSpeed <#>"
loreItem: |-
&7Click to change your
&7speed leve <#>.
vision:
nameItem: "<type> Night Vision"
loreItem: |-
&7Click to <type> the
&7night vission.
teleport:
title: "Teleporter"
team:
nameItem: "<color>Team <team>"
loreItem: |-
&7Show the players with
&7life of team.
player:
nameItem: "&7<player>"
loreItem: |-
&7
&eLife: &b<health>
&7
&aClick to teleport!
save:
nameItem: "&aSave Layout"
loreItem: |-
&7Click to save
&7in to default layout
close:
nameItem: "&cClose"
loreItem: |-
&7Click to close
&7this menu.
hotbar:
title: "&8Editor Hotbar - TheBridge"
type:
title: "&aSelect Type - Menu"
normal:
nameItem: "&aGame Normal"
loreItem: |-
&7Click to select
&7normal game menu.
four:
nameItem: "&aGame Four"
loreItem: |-
&7Click to select
&7four game menu.
game:
title: "&aNormal Game Menu"
generalDesc: |-
&7
&ePlayers: &b<players>/<max>
&eMode: &b<mode>
&eState: <state>
&e
&eClick to enter!
gameFour:
title: "&aFour Game Menu"
generalDesc: |-
&7
&ePlayers: &b<players>/<max>
&eMode: &b<mode>
&eState: <state>
&e
&eClick to enter!
items:
leave:
nameItem: "&cLeave &7(Right Click)"
loreItem: |-
&7Click to exit and
&7finish the fun.
teams:
nameItem: "&aTeam Selector &7(Right Click)"
loreItem: |-
&7Click to select computers
&7and play with friends.
spectate:
nameItem: "&aSpect Players &7(Right Click)"
loreItem: |-
&7Click to expect the
&7players per team.
config:
nameItem: "&bSpectator settings &7(Right Click)"
loreItem: |-
&7Set up your way of seeing
&7in game.
titles:
start:
title: <time>
subtitle: <none>
prestart:
title: <none>
subtitle: "&7Open cages in &a<time><s>&7..."
restart:
title: <color><player> scored!
subtitle: "&7Open cages in &a<time><s>&7..."
goalNormal:
title: <color><player> &7scored in <teamStole>&7!
subtitle: <teamOther> &7stole <color>1<heart> &7of &c<teamStole>&7!
goalFinal:
title: <color><player> &7scored in <teamStole>&7!
subtitle: <teamStole> &c&lhas eliminated!
win:
title: <color>&l<team> WIN!
subtitle: "&c&l<redGoals> &7&l- &9&l<blueGoals>"
winFour:
title: <color>&l<team> WIN!
subtitle: <color><life>
scoreboards:
main-title: "&e&lTHE BRIDGE LOBBY"
main: |-
&f
&fName: &a<player>
&f
&fLobby: &a#1
&f
&fOnline: &a<online>/100
&f
&6www.servername.net
lobby-title: "&e&lTHE BRIDGE"
lobby: |-
&f
&fPlayers: &e<players>/<max>
&f
&fMode: &a<mode>
&fMap: &e<map>
&f
&fServer: &e<server>
&f
&6www.servername.net
starting-title: "&e&lTHE BRIDGE"
starting: |-
&f
&fPlayers: &e<players>/<max>
&f
&fStarting in: &e<time><s>
&f
&fMode: &a<mode>
&fMap: &e<map>
&f
&fServer: &e<server>
&f
&6www.servername.net
game-normal-title: "&e&lTHE BRIDGE"
game-normal: |-
&7<date>
&f
&cRed Color Team: &e<redGoals>&7/5
&9Blue Color Team: &e<blueGoals>&7/5
&f
&fKills: &e<kills>
&fGoals: &c<goals>
&f
&fMode: &e<mode>
&fMap: &e<map>
&f
&6www.servername.net
game-four-title: "&e&lTHE BRIDGE"
game-four: |-
&7<date>
&7
<red>&7: <redLife>
<blue>&7: <blueLife>
<yellow>&7: <yellowLife>
<green>&7: <greenLife>
&7
&fKills: &a<kills>
&fGoals: &a<goals>
&7
&fMode: &e<mode>
&fMap: &a<map>
&f
&6mc.servername.net
units:
minutes: minutes
minute: minute
seconds: seconds
second: second

BIN
MultiArena-TheBridge/normal-blue.schematic

Binary file not shown.

BIN
MultiArena-TheBridge/normal-green.schematic

Binary file not shown.

BIN
MultiArena-TheBridge/normal-red.schematic

Binary file not shown.

BIN
MultiArena-TheBridge/normal-yellow.schematic

Binary file not shown.

10
MultiArena-TheBridge/plugin.yml

@ -0,0 +1,10 @@
main: cx.sfy.TheBridge.Main
name: TheBridge
version: 2.3.10
authors: [Stefatorus, Leonardo0013YT]
softdepend: [PlaceholderAPI, LeaderHeads, FastAsyncWorldEdit, WorldEdit, MultiWorld, Multiverse-Core]
commands:
bridges:
permissions:
bridges.join:
default: true

3
MultiArena-TheBridge/signs.yml

@ -0,0 +1,3 @@
signs:
normal: {}
four: {}

13
MultiArena-TheBridge/sounds.yml

@ -0,0 +1,13 @@
sounds:
archievement:
reward: LEVEL_UP
game:
join: NOTE_PLING
quit: NOTE_BASS
restart: SUCCESSFUL_HIT
prestart: SUCCESSFUL_HIT
starting: SUCCESSFUL_HIT
shop:
buy: NOTE_PLING
teamFour:
death: WITHER_DEATH

467
MultiArena-TheBridge/src/cx/sfy/TheBridge/Main.java

@ -0,0 +1,467 @@
package cx.sfy.TheBridge;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import cx.sfy.TheBridge.cmds.SetupCMD;
import cx.sfy.TheBridge.controllers.WorldController;
import cx.sfy.TheBridge.database.Cosmeticbase;
import cx.sfy.TheBridge.database.Database;
import cx.sfy.TheBridge.database.PlayerStat;
import cx.sfy.TheBridge.game.Game;
import cx.sfy.TheBridge.game.GameFour;
import cx.sfy.TheBridge.game.InventoryData;
import cx.sfy.TheBridge.game.PlayerData;
import cx.sfy.TheBridge.game.Game.State;
import cx.sfy.TheBridge.game.GameFour.FState;
import cx.sfy.TheBridge.hooks.PlaceholderHook;
import cx.sfy.TheBridge.kit.Hotbar;
import cx.sfy.TheBridge.kit.Kit;
import cx.sfy.TheBridge.leaderheads.TheBridgeFourGoals;
import cx.sfy.TheBridge.leaderheads.TheBridgeFourKills;
import cx.sfy.TheBridge.leaderheads.TheBridgeFourWins;
import cx.sfy.TheBridge.leaderheads.TheBridgeNormalGoals;
import cx.sfy.TheBridge.leaderheads.TheBridgeNormalKills;
import cx.sfy.TheBridge.leaderheads.TheBridgeNormalWins;
import cx.sfy.TheBridge.listeners.PlayerListener;
import cx.sfy.TheBridge.listeners.SetupListener;
import cx.sfy.TheBridge.listeners.SpectatorListener;
import cx.sfy.TheBridge.managers.ArchiManager;
import cx.sfy.TheBridge.managers.CageManager;
import cx.sfy.TheBridge.managers.FileManager;
import cx.sfy.TheBridge.managers.GameManager;
import cx.sfy.TheBridge.managers.GlassManager;
import cx.sfy.TheBridge.managers.LocationManager;
import cx.sfy.TheBridge.managers.ScoreboardManager;
import cx.sfy.TheBridge.managers.SetupManager;
import cx.sfy.TheBridge.managers.SignManager;
import cx.sfy.TheBridge.managers.TitleManager;
import cx.sfy.TheBridge.managers.TopManager;
import cx.sfy.TheBridge.menus.AchievementsMenu;
import cx.sfy.TheBridge.menus.GameMenu;
import cx.sfy.TheBridge.menus.GlassMenu;
import cx.sfy.TheBridge.menus.ShopMenu;
import cx.sfy.TheBridge.menus.SpectOptionsMenu;
import cx.sfy.TheBridge.menus.SpectPlayerMenu;
import cx.sfy.TheBridge.menus.TeamMenu;
import cx.sfy.TheBridge.nms.GenericNMS;
import cx.sfy.TheBridge.nms.NMS;
import cx.sfy.TheBridge.packets.PacketMain;
public class Main extends JavaPlugin {
private static Main instance;
private PacketMain refl;
private SpectOptionsMenu som;
private SpectPlayerMenu spm;
private TeamMenu tem;
private boolean placeholder;
private TitleManager tm;
private GameManager gm;
private GameMenu gmu;
private WorldController wc;
private Settings lang;
private Settings cages;
private Settings signs;
private Settings sounds;
private Settings achievement;
private Settings killsounds;
private NMS nms;
private FileManager fm;
private SetupManager sm;
private GlassManager glm;
private LocationManager lm;
private Location mainLobby;
private Kit kit;
private Database db;
private TopManager top;
private SignManager sim;
private Hotbar hotbar;
private boolean stop;
private ScoreboardManager sb;
private ArchiManager am;
private AchievementsMenu archimenu;
private CageManager cm;
private GlassMenu glam;
private boolean isCage = false;
private boolean archiDisabled = false;
private ShopMenu shop;
private Cosmeticbase cb;
public static Main get() {
return instance;
}
@Override
public void onEnable() {
refl = new PacketMain(this);
instance = this;
stop = false;
getConfig().options().copyDefaults(true);
saveConfig();
File s = new File(getDataFolder() + "/cages");
if (!s.exists()) {
s.mkdirs();
}
saveResources();
lang = new Settings(this, "lang");
signs = new Settings(this, "signs");
cages = new Settings(this, "cages");
sounds = new Settings(this, "sounds");
achievement = new Settings(this, "achievement");
//killsounds = new Settings(this, "killsounds");
if (getServer().getPluginManager().isPluginEnabled("FastAsyncWorldEdit")) {
if (!getConfig().getBoolean("cages")) {
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "You have " + ChatColor.RED + "FAWE installed." + ChatColor.GREEN + "Cage System Enabled");
} else {
cm = new CageManager(this);
isCage = true;
}
} else {
if (getConfig().getBoolean("cages")) {
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.RED + "You don't have " + ChatColor.YELLOW + "FAWE installed." + ChatColor.RED + "Cage System Disabled");
isCage = false;
}
}
archiDisabled = getConfig().getBoolean("archievements.disable");
if (getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
placeholder = true;
new PlaceholderHook(this).register();
}
loadNMS();
File a = new File(getDataFolder() + "/arenas");
if (!a.exists()) {
a.mkdirs();
}
File a1 = new File(getDataFolder() + "/maps");
if (!a1.exists()) {
a1.mkdirs();
}
db = new Database(this);
cb = new Cosmeticbase(this);
kit = new Kit();
lm = new LocationManager(this);
fm = new FileManager(this);
wc = new WorldController(this);
tm = new TitleManager(this);
sim = new SignManager(this);
gm = new GameManager(this);
gmu = new GameMenu(this);
sm = new SetupManager(this);
glm = new GlassManager();
top = new TopManager(this);
tem = new TeamMenu(this);
som = new SpectOptionsMenu(this);
spm = new SpectPlayerMenu(this);
hotbar = new Hotbar(this);
sb = new ScoreboardManager(this);
am = new ArchiManager(this);
archimenu = new AchievementsMenu(this);
glam = new GlassMenu(this);
shop = new ShopMenu(this);
lm.reloadLocations();
top.updateTops();
if (getConfig().getString("mainLobby") == null) {
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "The main lobby hasn't been set up. Please use " + ChatColor.YELLOW + "/bridges setmainlobby");
} else {
mainLobby = getStringLocation(getConfig().getString("mainLobby"));
}
getCommand("bridges").setExecutor(new SetupCMD(this));
Bukkit.getServer().getPluginManager().registerEvents(new SetupListener(this), this);
Bukkit.getServer().getPluginManager().registerEvents(new PlayerListener(this), this);
Bukkit.getServer().getPluginManager().registerEvents(new SpectatorListener(this), this);
new BukkitRunnable() {
@Override
public void run() {
top.updateTops();
}
}.runTaskTimer(this, 6000, 6000);
new BukkitRunnable() {
@Override
public void run() {
for (Game game : getGM().getGames()) {
if (game.isState(State.WAITING) || game.isState(State.STARTING) || game.isState(State.PREGAME)) {
game.updateGame();
}
}
for (GameFour game : getGM().getGamesFour()) {
if (game.isState(FState.WAITING) || game.isState(FState.STARTING) || game.isState(FState.PREGAME)) {
game.updateGame();
}
}
}
}.runTaskTimer(this, 20, 20);
if (getServer().getPluginManager().isPluginEnabled("LeaderHeads")) {
new TheBridgeNormalKills();
new TheBridgeNormalWins();
new TheBridgeNormalGoals();
new TheBridgeFourKills();
new TheBridgeFourWins();
new TheBridgeFourGoals();
}
}
@Override
public void onDisable() {
stop = true;
getTOP().removeHolo();
getServer().getScheduler().cancelAllTasks();
for (InventoryData inv : InventoryData.getInventoryData().values()) {
inv.restore();
}
for (GameFour gamef : getGM().getGamesFour()) {
for (PlayerData pd : gamef.getPD().values()) {
pd.restore();
}
}
for (Game gamef : getGM().getGames()) {
for (PlayerData pd : gamef.getPD().values()) {
pd.restore();
}
}
for (Player on : Bukkit.getOnlinePlayers()) {
getDB().saveData(PlayerStat.getPlayerStat(on));
getCB().saveData(PlayerStat.getPlayerStat(on));
}
}
public boolean isArchiDisabled() {
return archiDisabled;
}
public Settings getSounds() {
return sounds;
}
public Cosmeticbase getCB() {
return cb;
}
public boolean isCage() {
return isCage;
}
public Settings getKS() {
return killsounds;
}
public ShopMenu getShop() {
return shop;
}
public GlassMenu getGLAM() {
return glam;
}
public CageManager getCM() {
return cm;
}
public boolean isStop() {
return stop;
}
public AchievementsMenu getArchiMenu() {
return archimenu;
}
public ArchiManager getAM() {
return am;
}
public Hotbar getHotbar() {
return hotbar;
}
public ScoreboardManager getSB() {
return sb;
}
public SpectPlayerMenu getSPM() {
return spm;
}
public SpectOptionsMenu getSOM() {
return som;
}
public TeamMenu getTEM() {
return tem;
}
public void loadNMS() {
// Replaced with reflection.
nms = new GenericNMS();
}
public void saveResources() {
saveResource("clear.schematic", false);
saveResource("normal-red.schematic", false);
saveResource("normal-blue.schematic", false);
saveResource("normal-green.schematic", false);
saveResource("normal-yellow.schematic", false);
File cage = new File(getDataFolder(), "cages");
File c = new File(getDataFolder(), "clear.schematic");
File r = new File(getDataFolder(), "normal-red.schematic");
File b = new File(getDataFolder(), "normal-blue.schematic");
File g = new File(getDataFolder(), "normal-green.schematic");
File y = new File(getDataFolder(), "normal-yellow.schematic");
copyFiles(c, new File(cage, "clear.schematic"));
copyFiles(r, new File(cage, "normal-red.schematic"));
copyFiles(b, new File(cage, "normal-blue.schematic"));
copyFiles(g, new File(cage, "normal-green.schematic"));
copyFiles(y, new File(cage, "normal-yellow.schematic"));
c.delete();
r.delete();
g.delete();
b.delete();
y.delete();
}
public void copyFiles(File file, File file2) {
try {
if (!new ArrayList<String>(Arrays.asList("uid.dat", "session.dat")).contains(file.getName())) {
if (file.isDirectory()) {
if (!file2.exists()) {
file2.mkdirs();
}
String[] list;
for (int length = (list = file.list()).length, i = 0; i < length; ++i) {
String s = list[i];
copyFiles(new File(file, s), new File(file2, s));
}
}
else {
FileOutputStream fileOutputStream;
try (FileInputStream fileInputStream = new FileInputStream(file)) {
fileOutputStream = new FileOutputStream(file2);
byte[] array = new byte[1024];
int read;
while ((read = fileInputStream.read(array)) > 0) {
fileOutputStream.write(array, 0, read);
}
}
fileOutputStream.close();
}
}
}
catch (IOException ex) {}
}
/*public boolean isOnePointNine() {
return onepointnine;
}*/
public SignManager getSIM() {
return sim;
}
public Settings getSigns() {
return signs;
}
public TopManager getTOP() {
return top;
}
public Kit getKit() {
return kit;
}
public void reloadMainLobby() {
mainLobby = getStringLocation(getConfig().getString("mainLobby"));
}
public Database getDB() {
return db;
}
public LocationManager getLM() {
return lm;
}
public Location getMainLobby() {
return mainLobby;
}
public GlassManager getGLM() {
return glm;
}
public FileManager getFM() {
return fm;
}
public SetupManager getSM() {
return sm;
}
public WorldController getWC() {
return wc;
}
public NMS getNMS() {
return nms;
}
public GameMenu getGMU() {
return gmu;
}
public GameManager getGM() {
return gm;
}
public TitleManager getTM() {
return tm;
}
public Settings getAchievement() {
return achievement;
}
public Settings getLang() {
return lang;
}
public Settings getCages() {
return cages;
}
public boolean getPlaceholder() {
return placeholder;
}
public Location getStringLocation(String location) {
String[] l = location.split(";");
World world = Bukkit.getWorld(l[0]);
double x = Double.parseDouble(l[1]);
double y = Double.parseDouble(l[2]);
double z = Double.parseDouble(l[3]);
float yaw = Float.parseFloat(l[4]);
float pitch = Float.parseFloat(l[5]);
return new Location(world, x, y, z, yaw, pitch);
}
public PacketMain getRefl() {
return refl;
}
public void setRefl(PacketMain refl) {
this.refl = refl;
}
}

102
MultiArena-TheBridge/src/cx/sfy/TheBridge/Settings.java

@ -0,0 +1,102 @@
package cx.sfy.TheBridge;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.List;
public class Settings {
private FileConfiguration config;
private File file;
private Main u;
public Settings(Main u, String s) {
this.u = u;
this.file = new File(this.u.getDataFolder(), s + ".yml");
this.config = YamlConfiguration.loadConfiguration(this.file);
Reader reader = new InputStreamReader(u.getResource(String.valueOf(String.valueOf(String.valueOf(s))) + ".yml"));
YamlConfiguration loadConfiguration = YamlConfiguration.loadConfiguration(reader);
try {
if (!this.file.exists()) {
this.config.addDefaults((Configuration) loadConfiguration);
this.config.options().copyDefaults(true);
this.config.save(this.file);
} else {
this.config.addDefaults((Configuration) loadConfiguration);
this.config.options().copyDefaults(true);
this.config.save(this.file);
this.config.load(this.file);
}
} catch (IOException | InvalidConfigurationException ex) {
}
}
protected void sDefault(String s, String s2) {
if (!this.config.contains(s)) {
this.config.set(s, (Object) s2);
this.save();
}
}
public void save() {
try {
this.config.save(this.file);
} catch (IOException ex) {
}
}
public FileConfiguration getConfig() {
return this.config;
}
protected File getFile() {
return this.file;
}
public String get(String s) {
return this.config.getString(s).replaceAll("&", "§");
}
public String get(Player p, String s) {
if (u.getPlaceholder()) {
return PlaceholderAPI.setPlaceholders(p, config.getString(s).replaceAll("&", "§"));
}
return config.getString(s).replaceAll("&", "§");
}
public int getInt(String s) {
return this.config.getInt(s);
}
public List<String> getList(String s) {
return (List<String>) this.config.getStringList(s);
}
public List<String> getList(Player p, String s) {
if (u.getPlaceholder()) {
return PlaceholderAPI.setPlaceholders(p, (List<String>) config.getStringList(s));
}
return (List<String>) config.getStringList(s);
}
public boolean isSet(String s) {
return this.config.isSet(s);
}
public void set(String s, Object o) {
this.config.set(s, o);
}
public boolean getBoolean(String s) {
return this.config.getBoolean(s);
}
}

120
MultiArena-TheBridge/src/cx/sfy/TheBridge/archievements/Archi.java

@ -0,0 +1,120 @@
package cx.sfy.TheBridge.archievements;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.database.PlayerStat;
public class Archi {
Main plugin;
private String name;
private String description;
private int max;
private int xp;
private int money;
private ArchiType type;
private ArrayList<String> cmds = new ArrayList<String>();
private ArrayList<String> message = new ArrayList<String>();
public Archi(Main plugin, String path) {
this.plugin = plugin;
this.type = ArchiType.valueOf(plugin.getAchievement().get(path + ".type"));
this.name = plugin.getAchievement().get(path + ".name");
this.description = plugin.getAchievement().get(path + ".description");
this.max = plugin.getAchievement().getInt(path + ".amount");
this.xp = plugin.getAchievement().getInt(path + ".rewards.xp");
this.money = plugin.getAchievement().getInt(path + ".rewards.money");
for (String d : plugin.getAchievement().getList(path + ".messages")) {
message.add(d);
}
for (String d : plugin.getAchievement().getList(path + ".commands")) {
if (!d.equals("none")) {
cmds.add(d);
}
}
}
public void execute(Player p) {
for (String cmd : cmds) {
cmd = cmd.replace("%player%", p.getName());
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd);
}
PlayerStat ps = PlayerStat.getPlayerStat(p);
ps.addCoins(money);
ps.addXP(xp);
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.archievement.reward")), 1.0f, 1.0f);
for (String msg : message) {
p.sendMessage(msg.replaceAll("&", "§"));
}
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getMax() {
return max;
}
public void setMax(int max) {
this.max = max;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public int getXp() {
return xp;
}
public void setXp(int xp) {
this.xp = xp;
}
public int getMoney() {
return money;
}
public void setMoney(int money) {
this.money = money;
}
public ArchiType getType() {
return type;
}
public void setType(ArchiType type) {
this.type = type;
}
public ArrayList<String> getCmds() {
return cmds;
}
public void setCmds(ArrayList<String> cmds) {
this.cmds = cmds;
}
public ArrayList<String> getMessage() {
return message;
}
public void setMessage(ArrayList<String> message) {
this.message = message;
}
}

11
MultiArena-TheBridge/src/cx/sfy/TheBridge/archievements/ArchiType.java

@ -0,0 +1,11 @@
package cx.sfy.TheBridge.archievements;
public enum ArchiType {
BLOCKS_BROKEN,
BLOCKS_PLACED,
KILLS,
GOALS,
WINS;
}

15
MultiArena-TheBridge/src/cx/sfy/TheBridge/client/ClientPacket.java

@ -0,0 +1,15 @@
package cx.sfy.TheBridge.client;
import org.bukkit.entity.Player;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
public class ClientPacket {
public static boolean hidePacket(Player p, ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
return false;
}
}

1069
MultiArena-TheBridge/src/cx/sfy/TheBridge/cmds/SetupCMD.java

File diff suppressed because it is too large

174
MultiArena-TheBridge/src/cx/sfy/TheBridge/controllers/WorldController.java

@ -0,0 +1,174 @@
package cx.sfy.TheBridge.controllers;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Difficulty;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldCreator;
import org.bukkit.entity.Player;
import cx.sfy.TheBridge.Main;
public class WorldController {
public Main plugin;
public WorldController(Main plugin) {
this.plugin = plugin;
}
public void resetWorld(String name) {
unloadWorld(name);
copyWorld(new File(plugin.getDataFolder() + "/maps", name), name);
}
protected void unloadWorld(String world) {
if (Bukkit.getWorld(world) == null)
return;
Bukkit.getServer().unloadWorld(world, false);
}
public World createEmptyWorld(Player p, String name) {
if (Bukkit.getWorld(name) == null) {
World world = null;
final boolean loaded = loadWorld(name, Environment.NORMAL);
if (loaded)
world = Bukkit.getWorld(name);
if (world != null) {
world.getBlockAt(0, 80, 0).setType(Material.STONE);
p.teleport(new Location(world, 0, 81, 0));
p.sendMessage(plugin.getLang().get("setup.worldCreated").replaceAll("<name>", world.getName()));
return world;
}
}
return null;
}
public boolean loadWorld(String worldName, World.Environment environment) {
boolean loaded = false;
if (Bukkit.getWorld(worldName) != null) {
final World world = Bukkit.getWorld(worldName);
world.setDifficulty(Difficulty.NORMAL);
world.setSpawnFlags(true, true);
world.setPVP(true);
world.setStorm(false);
world.setThundering(false);
world.setWeatherDuration(Integer.MAX_VALUE);
world.setKeepSpawnInMemory(false);
world.setTicksPerAnimalSpawns(1);
world.setTicksPerMonsterSpawns(1);
world.setAutoSave(false);
world.setGameRuleValue("doMobSpawning", "false");
world.setGameRuleValue("mobGriefing", "false");
world.setGameRuleValue("doFireTick", "false");
world.setGameRuleValue("showDeathMessages", "false");
return true;
}
final WorldCreator worldCreator = new WorldCreator(worldName);
worldCreator.environment(environment);
worldCreator.generateStructures(false);
worldCreator.generator(plugin.getNMS().getChunkGenerator());
final World world = worldCreator.createWorld();
world.setDifficulty(Difficulty.NORMAL);
world.setSpawnFlags(true, true);
world.setPVP(true);
world.setStorm(false);
world.setThundering(false);
world.setWeatherDuration(Integer.MAX_VALUE);
world.setKeepSpawnInMemory(false);
world.setTicksPerAnimalSpawns(1);
world.setTicksPerMonsterSpawns(1);
world.setAutoSave(false);
world.setGameRuleValue("doMobSpawning", "false");
world.setGameRuleValue("mobGriefing", "false");
world.setGameRuleValue("doFireTick", "false");
world.setGameRuleValue("showDeathMessages", "false");
world.getBlockAt(0, 75, 0).setType(Material.STONE);
for(final World w : plugin.getServer().getWorlds())
if(w.getName().equals(world.getName())) {
loaded = true;
break;
}
return loaded;
}
public void copyWorld(World world) {
copyFileStructure(world.getWorldFolder(), new File(plugin.getDataFolder() + "/maps/" + world.getName()));
}
protected void copyWorld(File originalWorld, String newWorldName) {
copyFileStructure(originalWorld, new File(Bukkit.getWorldContainer(), newWorldName));
final WorldCreator worldc = new WorldCreator(newWorldName);
worldc.generateStructures(false);
worldc.generator(plugin.getNMS().getChunkGenerator());
worldc.createWorld();
final World world = Bukkit.getWorld(newWorldName);
world.setTime(500);
world.setMonsterSpawnLimit(0);
world.setWeatherDuration(0);
world.setAnimalSpawnLimit(0);
world.setAmbientSpawnLimit(0);
world.setGameRuleValue("doDaylightCycle", "false");
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "Se ha reiniciado el mapa " + ChatColor.YELLOW + newWorldName + ChatColor.GREEN + ".");
}
protected void copyFileStructure(File source, File target) {
try {
final ArrayList<String> ignore = new ArrayList<>(Arrays.asList("uid.dat", "session.lock"));
if (!ignore.contains(source.getName()))
if (source.isDirectory()) {
if (!target.exists())
if (!target.mkdirs())
throw new IOException("Couldn't create world directory!");
final String files[] = source.list();
for (final String file : files) {
final File srcFile = new File(source, file);
final File destFile = new File(target, file);
copyFileStructure(srcFile, destFile);
}
} else {
final InputStream in = new FileInputStream(source);
final OutputStream out = new FileOutputStream(target);
final byte[] buffer = new byte[1024];
int length;
while ((length = in.read(buffer)) > 0)
out.write(buffer, 0, length);
in.close();
out.close();
}
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
public void deleteWorld(String name) {
unloadWorld(name);
final File target = new File (plugin.getServer().getWorldContainer().getAbsolutePath(), name);
deleteWorld(target);
}
protected void deleteWorld(File path) {
if (path.exists()) {
final File[] files = path.listFiles();
if (files != null)
for (final File file: files)
if(file.isDirectory())
deleteWorld(file);
else
file.delete();
}
}
}

159
MultiArena-TheBridge/src/cx/sfy/TheBridge/cosmetics/cages/Cage.java

@ -0,0 +1,159 @@
package cx.sfy.TheBridge.cosmetics.cages;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import cx.sfy.TheBridge.Main;
public class Cage {
Main plugin;
private ItemStack icon;
private String id;
private String name;
private String permission;
private ArrayList<String> lore;
private File filered;
private File fileblue;
private File fileyellow;
private File filegreen;
private File clear;
private int price;
private int slot;
private boolean isBuy;
public Cage(Main plugin, String path, String id) {
this.plugin = plugin;
this.icon = new ItemStack(Material.valueOf(plugin.getCages().get(path + ".icon")), plugin.getCages().getInt(path + ".amount"), (short)plugin.getCages().getInt(path + ".data"));
this.lore = new ArrayList<String>();
for (String l : plugin.getCages().getList(path + ".description")) {
lore.add(l.replaceAll("&", "§"));
}
this.filered = new File(plugin.getDataFolder(), "cages/" + plugin.getCages().get(path + ".files.red"));
this.fileblue = new File(plugin.getDataFolder(), "cages/" + plugin.getCages().get(path + ".files.blue"));
this.fileyellow = new File(plugin.getDataFolder(), "cages/" + plugin.getCages().get(path + ".files.yellow"));
this.filegreen = new File(plugin.getDataFolder(), "cages/" + plugin.getCages().get(path + ".files.green"));
this.clear = new File(plugin.getDataFolder(), "cages/" + plugin.getCages().get(path + ".clearFile"));
this.id = id;
this.name = plugin.getCages().get(path + ".name");
this.permission = plugin.getCages().get(path + ".permission");
this.price = plugin.getCages().getInt(path + ".price");
this.slot = plugin.getCages().getInt(path + ".slot");
this.isBuy = plugin.getCages().getBoolean(path + ".isBuy");
}
public File getClear() {
return clear;
}
public String getPermission() {
return permission;
}
public String getName() {
return name;
}
public int getPrice() {
return price;
}
public int getSlot() {
return slot;
}
public boolean isBuy() {
return isBuy;
}
public ItemStack getHasIcon() {
ItemStack perm = icon;
ItemMeta permM = perm.getItemMeta();
List<String> nLore = new ArrayList<String>();;
for (String msg : plugin.getCages().getList("unlocked")) {
if (msg.contains("<description>")) {
for (String l : lore) {
nLore.add(l);
}
} else {
nLore.add(msg.replaceAll("&", "§").replaceAll("<price>", String.valueOf(price)));
}
}
permM.setLore(nLore);
permM.setDisplayName("§a" + name);
perm.setItemMeta(permM);
return perm;
}
public ItemStack getPermIcon() {
ItemStack perm = icon;
ItemMeta permM = perm.getItemMeta();
List<String> nLore = new ArrayList<String>();;
for (String msg : plugin.getCages().getList("noPerm")) {
if (msg.contains("<description>")) {
for (String l : lore) {
nLore.add(l);
}
} else {
nLore.add(msg.replaceAll("&", "§").replaceAll("<price>", String.valueOf(price)));
}
}
permM.setLore(nLore);
permM.setDisplayName("§c" + name);
perm.setItemMeta(permM);
return perm;
}
public ItemStack getBuyIcon() {
ItemStack perm = icon;
ItemMeta permM = perm.getItemMeta();
List<String> nLore = new ArrayList<String>();;
for (String msg : plugin.getCages().getList("locked")) {
if (msg.contains("<description>")) {
for (String l : lore) {
nLore.add(l);
}
} else {
nLore.add(msg.replaceAll("&", "§").replaceAll("<price>", String.valueOf(price)));
}
}
permM.setLore(nLore);
permM.setDisplayName("§c" + name);
perm.setItemMeta(permM);
return perm;
}
public ItemStack getNormalIcon() {
return icon;
}
public String getId() {
return id;
}
public ArrayList<String> getLore() {
return lore;
}
public File getFileRed() {
return filered;
}
public File getFileBlue() {
return fileblue;
}
public File getFileYellow() {
return fileyellow;
}
public File getFileGreen() {
return filegreen;
}
}

9
MultiArena-TheBridge/src/cx/sfy/TheBridge/cosmetics/killsounds/KillSound.java

@ -0,0 +1,9 @@
package cx.sfy.TheBridge.cosmetics.killsounds;
public class KillSound {
public KillSound() {
}
}

255
MultiArena-TheBridge/src/cx/sfy/TheBridge/database/Cosmeticbase.java

@ -0,0 +1,255 @@
package cx.sfy.TheBridge.database;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.TimeZone;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import cx.sfy.TheBridge.Main;
public class Cosmeticbase {
public Main plugin;
private Connection connection;
public Cosmeticbase(Main plugin) {
this.plugin = plugin;
conectar();
}
public void conectar() {
if (plugin.getConfig().getBoolean("MySQL.enabled")){
try {
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://" + (plugin.getConfig().getString("MySQL.host") +":"+ plugin.getConfig().getString("MySQL.port")) + "/" + plugin.getConfig().getString("MySQL.database") + "?serverTimezone=" + TimeZone.getDefault().getID() + "&autoReconnect=true&wait_timeout=31536000&interactive_timeout=31536000", plugin.getConfig().getString("MySQL.username"), plugin.getConfig().getString("MySQL.password"));
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "[TheBridge] MySQL conectada.");
newTables();
} catch (Exception e) {
e.printStackTrace();
}
} else {
File DataFile = new File(plugin.getDataFolder(), "/TheBridge.db");
if (!DataFile.exists()) {
try {
DataFile.createNewFile();
} catch (IOException ex) {
ex.printStackTrace();
Bukkit.getPluginManager().disablePlugin(plugin);
}
}
try {
Class.forName("org.sqlite.JDBC");
try {
connection = DriverManager.getConnection("jdbc:sqlite:" + DataFile);
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "[TheBridge] SQLLite conectado.");
newTables();
} catch (SQLException ex2) {
ex2.printStackTrace();
Bukkit.getPluginManager().disablePlugin(plugin);
}
} catch (ClassNotFoundException ex3) {
ex3.printStackTrace();
Bukkit.getPluginManager().disablePlugin(plugin);
}
}
}
public void checkConnection() {
try {
if (connection.isClosed() || connection == null){
conectar();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
public void createNewPlayer(String fId, String name) {
PreparedStatement preparedStatement = null;
try {
StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append("INSERT INTO `BG_Cosmetic` ");
queryBuilder.append("(`UUID`, `Name`, `Cage`, `Taunt`, `Trail`, `KillSound`) ");
queryBuilder.append("VALUES ");
queryBuilder.append("(?, ?, ?, ?, ?, ?);");
preparedStatement = connection.prepareStatement(queryBuilder.toString());
preparedStatement.setString(1, fId);
preparedStatement.setString(2, name);
preparedStatement.setString(3, "default");
preparedStatement.setString(4, "default");
preparedStatement.setString(5, "default");
preparedStatement.setString(6, "default");
preparedStatement.executeUpdate();
} catch (final SQLException sqlException) {
sqlException.printStackTrace();
} finally {
if (preparedStatement != null) {
try {
preparedStatement.close();
} catch (final SQLException ignored) {
}
}
}
}
public boolean hasPlayer(Player p, String uuid) {
PreparedStatement statement = null;
try {
statement = this.connection.prepareStatement("SELECT UUID FROM BG_Cosmetic WHERE UUID ='" + uuid + "'");
ResultSet result = statement.executeQuery();
if (result.next()) {
return true;
}
} catch (SQLException e) {
e.printStackTrace();
if (statement != null) {
try {
statement.close();
}
catch (SQLException e2) {
e2.printStackTrace();
}
return false;
}
return false;
} finally {
if (statement != null) {
try {
statement.close();
}
catch (SQLException e2) {
e2.printStackTrace();
}
}
}
if (statement != null) {
try {
statement.close();
}
catch (SQLException e2) {
e2.printStackTrace();
}
}
return false;
}
public void loadData(PlayerStat stat) {
new BukkitRunnable() {
@Override
public void run() {
Connection connection = getConnection();
if (!hasPlayer(stat.getPlayer(), stat.getUUID())) {
createNewPlayer(stat.getUUID(), stat.getPlayer().getName());
loadData(stat);
return;
}
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append("SELECT `Cage`, `Taunt`, `Trail`, `KillSound` ");
queryBuilder.append("FROM `BG_Cosmetic` ");
queryBuilder.append("WHERE `UUID` = ? ");
queryBuilder.append("LIMIT 1;");
preparedStatement = connection.prepareStatement(queryBuilder.toString());
preparedStatement.setString(1, stat.getUUID().toString());
resultSet = preparedStatement.executeQuery();
if (resultSet != null && resultSet.next()) {
stat.setCage(resultSet.getString("Cage"));
}
} catch (SQLException sqlException) {
sqlException.printStackTrace();
} finally {
if (resultSet != null) {
try {
resultSet.close();
} catch (SQLException ignored) {
}
}
if (preparedStatement != null) {
try {
preparedStatement.close();
} catch (SQLException ignored) {
}
}
}
}
}.runTaskAsynchronously(plugin);
}
public void saveData(PlayerStat stat) {
checkConnection();
Connection connection = getConnection();
PreparedStatement preparedStatement = null;
try {
StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append("UPDATE `BG_Cosmetic` SET ");
queryBuilder.append("`Cage` = ?, `Taunt` = ?, `Trail` = ?, `KillSound` = ? ");
queryBuilder.append("WHERE `UUID` = ?;");
preparedStatement = connection.prepareStatement(queryBuilder.toString());
preparedStatement.setString(1, stat.getCage());
preparedStatement.setString(2, "default");
preparedStatement.setString(3, "default");
preparedStatement.setString(4, "default");
preparedStatement.setString(5, stat.getUUID());
preparedStatement.executeUpdate();
} catch (SQLException sqlException) {
sqlException.printStackTrace();
} finally {
if (preparedStatement != null) {
try {
preparedStatement.close();
} catch (SQLException ignored) {
}
}
}
}
public Connection getConnection() {
return connection;
}
public void newTables() {
Connection connection = getConnection();
try {
Statement statement = connection.createStatement();
try {
statement.executeUpdate("CREATE TABLE IF NOT EXISTS BG_Cosmetic (UUID VARCHAR(60), Name VARCHAR(60), Cage TEXT, Taunt TEXT, Trail TEXT, KillSound TEXT)");
} catch (SQLException ex) {
try {
if (statement != null) {
statement.close();
}
} catch (SQLException ex2) {
}
return;
} finally {
try {
if (statement != null) {
statement.close();
}
} catch (SQLException ex3) {
}
} try {
if (statement != null) {
statement.close();
}
} catch (SQLException ex4) {
}
} catch (SQLException ex5) {
}
}
}

570
MultiArena-TheBridge/src/cx/sfy/TheBridge/database/Database.java

@ -0,0 +1,570 @@
package cx.sfy.TheBridge.database;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.TimeZone;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.tops.BoardType;
import cx.sfy.TheBridge.tops.Top;
public class Database {
public Main plugin;
private Connection connection;
public Database(Main plugin) {
this.plugin = plugin;
conectar();
}
public void conectar() {
if (plugin.getConfig().getBoolean("MySQL.enabled")){
try {
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://" + (plugin.getConfig().getString("MySQL.host") +":"+ plugin.getConfig().getString("MySQL.port")) + "/" + plugin.getConfig().getString("MySQL.database") + "?serverTimezone=" + TimeZone.getDefault().getID() + "&autoReconnect=true&wait_timeout=31536000&interactive_timeout=31536000", plugin.getConfig().getString("MySQL.username"), plugin.getConfig().getString("MySQL.password"));
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "[TheBridge] MySQL conectada.");
newTables();
} catch (Exception e) {
e.printStackTrace();
}
} else {
File DataFile = new File(plugin.getDataFolder(), "/TheBridge.db");
if (!DataFile.exists()) {
try {
DataFile.createNewFile();
} catch (IOException ex) {
ex.printStackTrace();
Bukkit.getPluginManager().disablePlugin(plugin);
}
}
try {
Class.forName("org.sqlite.JDBC");
try {
connection = DriverManager.getConnection("jdbc:sqlite:" + DataFile);
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "[TheBridge] SQLLite conectado.");
newTables();
} catch (SQLException ex2) {
ex2.printStackTrace();
Bukkit.getPluginManager().disablePlugin(plugin);
}
} catch (ClassNotFoundException ex3) {
ex3.printStackTrace();
Bukkit.getPluginManager().disablePlugin(plugin);
}
}
}
public void checkConnection() {
try {
if (connection.isClosed() || connection == null){
conectar();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
public void loadNormalKills() {
new BukkitRunnable() {
@Override
public void run() {
Connection connection = getConnection();
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append("SELECT `UUID`, `Name`, `NKills` ");
queryBuilder.append("FROM `BG_Data` ");
queryBuilder.append("GROUP BY `UUID` ");
queryBuilder.append("ORDER BY `NKills` DESC LIMIT 10;");
preparedStatement = connection.prepareStatement(queryBuilder.toString());
resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
new Top(resultSet.getString(2), resultSet.getInt(3), BoardType.NORMAL_KILLS);
}
} catch (SQLException sqlException) {
sqlException.printStackTrace();
} finally {
if (resultSet != null) {
try {
resultSet.close();
} catch (SQLException ignored) {
}
}
if (preparedStatement != null) {
try {
preparedStatement.close();
} catch (SQLException ignored) {
}
}
}
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
if (plugin.getLM().getNormalKills() != null) {
plugin.getTOP().createTop(plugin.getLM().getNormalKills(), BoardType.NORMAL_KILLS);
}
}
}, 0);
}
}.runTaskAsynchronously(plugin);
}
public void loadNormalWins() {
new BukkitRunnable() {
@Override
public void run() {
Connection connection = getConnection();
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append("SELECT `UUID`, `Name`, `NWins` ");
queryBuilder.append("FROM `BG_Data` ");
queryBuilder.append("GROUP BY `UUID` ");
queryBuilder.append("ORDER BY `NWins` DESC LIMIT 10;");
preparedStatement = connection.prepareStatement(queryBuilder.toString());
resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
new Top(resultSet.getString(2), resultSet.getInt(3), BoardType.NORMAL_WINS);
}
} catch (SQLException sqlException) {
sqlException.printStackTrace();
} finally {
if (resultSet != null) {
try {
resultSet.close();
} catch (SQLException ignored) {
}
}
if (preparedStatement != null) {
try {
preparedStatement.close();
} catch (SQLException ignored) {
}
}
}
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
if (plugin.getLM().getNormalWins() != null) {
plugin.getTOP().createTop(plugin.getLM().getNormalWins(), BoardType.NORMAL_WINS);
}
}
}, 0);
}
}.runTaskAsynchronously(plugin);
}
public void loadNormalGoals() {
new BukkitRunnable() {
@Override
public void run() {
Connection connection = getConnection();
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append("SELECT `UUID`, `Name`, `NGoals` ");
queryBuilder.append("FROM `BG_Data` ");
queryBuilder.append("GROUP BY `UUID` ");
queryBuilder.append("ORDER BY `NGoals` DESC LIMIT 10;");
preparedStatement = connection.prepareStatement(queryBuilder.toString());
resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
new Top(resultSet.getString(2), resultSet.getInt(3), BoardType.NORMAL_GOALS);
}
} catch (SQLException sqlException) {
sqlException.printStackTrace();
} finally {
if (resultSet != null) {
try {
resultSet.close();
} catch (SQLException ignored) {
}
}
if (preparedStatement != null) {
try {
preparedStatement.close();
} catch (SQLException ignored) {
}
}
}
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
if (plugin.getLM().getNormalGoals() != null) {
plugin.getTOP().createTop(plugin.getLM().getNormalGoals(), BoardType.NORMAL_GOALS);
}
}
}, 0);
}
}.runTaskAsynchronously(plugin);
}
public void loadFourKills() {
new BukkitRunnable() {
@Override
public void run() {
Connection connection = getConnection();
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append("SELECT `UUID`, `Name`, `FKills` ");
queryBuilder.append("FROM `BG_Data` ");
queryBuilder.append("GROUP BY `UUID` ");
queryBuilder.append("ORDER BY `FKills` DESC LIMIT 10;");
preparedStatement = connection.prepareStatement(queryBuilder.toString());
resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
new Top(resultSet.getString(2), resultSet.getInt(3), BoardType.FOUR_KILLS);
}
} catch (SQLException sqlException) {
sqlException.printStackTrace();
} finally {
if (resultSet != null) {
try {
resultSet.close();
} catch (SQLException ignored) {
}
}
if (preparedStatement != null) {
try {
preparedStatement.close();
} catch (SQLException ignored) {
}
}
}
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
if (plugin.getLM().getFourKills() != null) {
plugin.getTOP().createTop(plugin.getLM().getFourKills(), BoardType.FOUR_KILLS);
}
}
}, 0);
}
}.runTaskAsynchronously(plugin);
}
public void loadFourWins() {
new BukkitRunnable() {
@Override
public void run() {
Connection connection = getConnection();
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append("SELECT `UUID`, `Name`, `FWins` ");
queryBuilder.append("FROM `BG_Data` ");
queryBuilder.append("GROUP BY `UUID` ");
queryBuilder.append("ORDER BY `FWins` DESC LIMIT 10;");
preparedStatement = connection.prepareStatement(queryBuilder.toString());
resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
new Top(resultSet.getString(2), resultSet.getInt(3), BoardType.FOUR_WINS);
}
} catch (SQLException sqlException) {
sqlException.printStackTrace();
} finally {
if (resultSet != null) {
try {
resultSet.close();
} catch (SQLException ignored) {
}
}
if (preparedStatement != null) {
try {
preparedStatement.close();
} catch (SQLException ignored) {
}
}
}
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
if (plugin.getLM().getFourWins() != null) {
plugin.getTOP().createTop(plugin.getLM().getFourWins(), BoardType.FOUR_WINS);
}
}
}, 0);
}
}.runTaskAsynchronously(plugin);
}
public void loadFourGoals() {
new BukkitRunnable() {
@Override
public void run() {
Connection connection = getConnection();
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append("SELECT `UUID`, `Name`, `FGoals` ");
queryBuilder.append("FROM `BG_Data` ");
queryBuilder.append("GROUP BY `UUID` ");
queryBuilder.append("ORDER BY `FGoals` DESC LIMIT 10;");
preparedStatement = connection.prepareStatement(queryBuilder.toString());
resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
new Top(resultSet.getString(2), resultSet.getInt(3), BoardType.FOUR_GOALS);
}
} catch (SQLException sqlException) {
sqlException.printStackTrace();
} finally {
if (resultSet != null) {
try {
resultSet.close();
} catch (SQLException ignored) {
}
}
if (preparedStatement != null) {
try {
preparedStatement.close();
} catch (SQLException ignored) {
}
}
}
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
if (plugin.getLM().getFourGoals() != null) {
plugin.getTOP().createTop(plugin.getLM().getFourGoals(), BoardType.FOUR_GOALS);
}
}
}, 0);
}
}.runTaskAsynchronously(plugin);
}
public void createNewPlayer(String fId, String name) {
PreparedStatement preparedStatement = null;
try {
StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append("INSERT INTO `BG_Data` ");
queryBuilder.append("(`UUID`, `Name`, `Coins`, `NKills`, `NWins`, `NGoals`, `FKills`, `FWins`, `FGoals`, `Inventory`, `XP`, `Placed`, `Broken`) ");
queryBuilder.append("VALUES ");
queryBuilder.append("(?, ?, 0, 0, 0, 0, 0, 0, 0, ?, 0, 0, 0);");
preparedStatement = connection.prepareStatement(queryBuilder.toString());
preparedStatement.setString(1, fId);
preparedStatement.setString(2, name);
preparedStatement.setString(3, "none");
preparedStatement.executeUpdate();
} catch (final SQLException sqlException) {
sqlException.printStackTrace();
} finally {
if (preparedStatement != null) {
try {
preparedStatement.close();
} catch (final SQLException ignored) {
}
}
}
}
public boolean hasPlayer(Player p, String uuid) {
PreparedStatement statement = null;
try {
statement = this.connection.prepareStatement("SELECT UUID FROM BG_Data WHERE UUID ='" + uuid + "'");
ResultSet result = statement.executeQuery();
if (result.next()) {
return true;
}
} catch (SQLException e) {
e.printStackTrace();
if (statement != null) {
try {
statement.close();
}
catch (SQLException e2) {
e2.printStackTrace();
}
return false;
}
return false;
} finally {
if (statement != null) {
try {
statement.close();
}
catch (SQLException e2) {
e2.printStackTrace();
}
}
}
if (statement != null) {
try {
statement.close();
}
catch (SQLException e2) {
e2.printStackTrace();
}
}
return false;
}
public void loadData(PlayerStat stat) {
new BukkitRunnable() {
@Override
public void run() {
Connection connection = getConnection();
if (!hasPlayer(stat.getPlayer(), stat.getUUID())) {
createNewPlayer(stat.getUUID(), stat.getPlayer().getName());
loadData(stat);
return;
}
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append("SELECT `NKills`, `NWins`, `NGoals`, `FKills`, `FWins`, `FGoals`, `Coins`, `Inventory`, `XP`, `Placed`, `Broken` ");
queryBuilder.append("FROM `BG_Data` ");
queryBuilder.append("WHERE `UUID` = ? ");
queryBuilder.append("LIMIT 1;");
preparedStatement = connection.prepareStatement(queryBuilder.toString());
preparedStatement.setString(1, stat.getUUID().toString());
resultSet = preparedStatement.executeQuery();
if (resultSet != null && resultSet.next()) {
stat.setNormalKills(resultSet.getInt("NKills"));
stat.setNormalWins(resultSet.getInt("NWins"));
stat.setNormalGoals(resultSet.getInt("NGoals"));
stat.setFourKills(resultSet.getInt("FKills"));
stat.setFourWins(resultSet.getInt("FWins"));
stat.setFourGoals(resultSet.getInt("FGoals"));
stat.setCoins(resultSet.getInt("Coins"));
if (!resultSet.getString("Inventory").equals("none")) {
try {
stat.setHotbar(plugin.getKit().fromBase64(resultSet.getString("Inventory")).getContents());
} catch (IOException e) {
e.printStackTrace();
}
} else {
stat.setHotbar(null);
}
stat.setXP(resultSet.getInt("XP"));
stat.setPlaced(resultSet.getInt("Placed"));
stat.setBroken(resultSet.getInt("Broken"));
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
plugin.getTOP().createInfo(stat.getPlayer());
plugin.getSB().createLobbyBoard(stat.getPlayer());
for (Player on : plugin.getSB().getSB().keySet()) {
plugin.getSB().update(on);
}
}
}, 0);
}
} catch (SQLException sqlException) {
sqlException.printStackTrace();
} finally {
if (resultSet != null) {
try {
resultSet.close();
} catch (SQLException ignored) {
}
}
if (preparedStatement != null) {
try {
preparedStatement.close();
} catch (SQLException ignored) {
}
}
}
}
}.runTaskAsynchronously(plugin);
}
public void saveData(PlayerStat stat) {
checkConnection();
Connection connection = getConnection();
PreparedStatement preparedStatement = null;
try {
StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append("UPDATE `BG_Data` SET ");
queryBuilder.append("`NKills` = ?, `NWins` = ?, `NGoals` = ?, `FKills` = ?, `FWins` = ?, `FGoals` = ?, `Coins` = ?, `Inventory` = ?, `XP` = ?, `Placed` = ?, `Broken` = ? ");
queryBuilder.append("WHERE `UUID` = ?;");
preparedStatement = connection.prepareStatement(queryBuilder.toString());
preparedStatement.setInt(1, stat.getNormalKills());
preparedStatement.setInt(2, stat.getNormalWins());
preparedStatement.setInt(3, stat.getNormalGoals());
preparedStatement.setInt(4, stat.getFourKills());
preparedStatement.setInt(5, stat.getFourWins());
preparedStatement.setInt(6, stat.getFourGoals());
preparedStatement.setInt(7, stat.getCoins());
if (stat.getHotbar() != null) {
preparedStatement.setString(8, plugin.getKit().itemStackArrayToBase64(stat.getHotbar()));
} else {
preparedStatement.setString(8, "none");
}
preparedStatement.setInt(9, stat.getXP());
preparedStatement.setInt(10, stat.getPlaced());
preparedStatement.setInt(11, stat.getBroken());
preparedStatement.setString(12, stat.getUUID());
preparedStatement.executeUpdate();
} catch (SQLException sqlException) {
sqlException.printStackTrace();
} finally {
if (preparedStatement != null) {
try {
preparedStatement.close();
} catch (SQLException ignored) {
}
}
}
}
public Connection getConnection() {
return connection;
}
public void newTables() {
Connection connection = getConnection();
try {
Statement statement = connection.createStatement();
try {
statement.executeUpdate("CREATE TABLE IF NOT EXISTS BG_Data (UUID VARCHAR(60), Name VARCHAR(60), NKills INT, NWins INT, NGoals INT, FKills INT, FWins INT, FGoals INT, Coins INT, Inventory TEXT, XP INT, Placed INT, Broken INT, Cage TEXT)");
} catch (SQLException ex) {
try {
if (statement != null) {
statement.close();
}
} catch (SQLException ex2) {
}
return;
} finally {
try {
if (statement != null) {
statement.close();
}
} catch (SQLException ex3) {
}
} try {
if (statement != null) {
statement.close();
}
} catch (SQLException ex4) {
}
} catch (SQLException ex5) {
}
}
}

254
MultiArena-TheBridge/src/cx/sfy/TheBridge/database/PlayerStat.java

@ -0,0 +1,254 @@
package cx.sfy.TheBridge.database;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.archievements.ArchiType;
public class PlayerStat {
public static HashMap<Player, PlayerStat> players = new HashMap<Player, PlayerStat>();
private Player p;
private UUID uuid;
private String name;
private ItemStack[] hotbar;
private String cage;
private int normalWins;
private int fourWins;
private int normalKills;
private int fourKills;
private int normalDeaths;
private int fourDeaths;
private int normalGoals;
private int fourGoals;
private int coins;
private int xp;
private int broken;
private int placed;
public PlayerStat(Player p) {
this.p = p;
this.uuid = p.getUniqueId();
this.name = p.getName();
Main.get().getDB().loadData(this);
Main.get().getCB().loadData(this);
players.put(p, this);
}
public static PlayerStat getPlayerStat(Player p) {
return players.get(p);
}
public String getCage() {
return cage;
}
public void setCage(String cage) {
this.cage = cage;
}
public void addBroken() {
broken = broken + 1;
if (!Main.get().isArchiDisabled()) {
Main.get().getAM().check(p, broken, ArchiType.BLOCKS_BROKEN);
}
}
public void addPlaced() {
placed = placed + 1;
if (!Main.get().isArchiDisabled()) {
Main.get().getAM().check(p, placed, ArchiType.BLOCKS_PLACED);
}
}
public int getBroken() {
return broken;
}
public void setBroken(int broken) {
this.broken = broken;
}
public int getPlaced() {
return placed;
}
public void setPlaced(int placed) {
this.placed = placed;
}
public Player getPlayer() {
return p;
}
public String getUUID() {
return uuid.toString();
}
public String getName() {
return name;
}
public ItemStack[] getHotbar() {
return hotbar;
}
public void setHotbar(ItemStack[] hotbar) {
this.hotbar = hotbar;
}
public void addNormalKills() {
normalKills = normalKills + 1;
xp += Main.get().getConfig().getInt("xp.normal.kill");
coins += Main.get().getConfig().getInt("coins.normal.kill");
if (!Main.get().isArchiDisabled()) {
Main.get().getAM().check(p, normalKills + fourKills, ArchiType.KILLS);
}
}
public void addNormalWins() {
normalWins = normalWins + 1;
xp += Main.get().getConfig().getInt("xp.normal.win");
coins += Main.get().getConfig().getInt("coins.normal.win");
if (!Main.get().isArchiDisabled()) {
Main.get().getAM().check(p, normalWins + fourWins, ArchiType.WINS);
}
}
public void addNormalGoals() {
normalGoals = normalGoals + 1;
xp += Main.get().getConfig().getInt("xp.normal.goals");
coins += Main.get().getConfig().getInt("coins.normal.goals");
if (!Main.get().isArchiDisabled()) {
Main.get().getAM().check(p, normalGoals + fourGoals, ArchiType.GOALS);
}
}
public void addFourKills() {
fourKills = fourKills + 1;
xp += Main.get().getConfig().getInt("xp.four.kill");
coins += Main.get().getConfig().getInt("coins.four.kill");
if (!Main.get().isArchiDisabled()) {
Main.get().getAM().check(p, normalKills + fourKills, ArchiType.KILLS);
}
}
public void addFourWins() {
fourWins = fourWins + 1;
xp += Main.get().getConfig().getInt("coins.four.win");
coins += Main.get().getConfig().getInt("coins.four.win");
if (!Main.get().isArchiDisabled()) {
Main.get().getAM().check(p, normalWins + fourWins, ArchiType.WINS);
}
}
public void addFourGoals() {
fourGoals = fourGoals + 1;
xp += coins + Main.get().getConfig().getInt("xp.four.goals");
coins += Main.get().getConfig().getInt("coins.four.goals");
if (!Main.get().isArchiDisabled()) {
Main.get().getAM().check(p, normalGoals + fourGoals, ArchiType.GOALS);
}
}
public void addCoins(int coins) {
this.coins = this.coins + coins;
}
public void removeCoins(int coins) {
this.coins = this.coins - coins;
}
public void addXP(int xp) {
this.xp = this.xp + xp;
}
public void removeXP(int xp) {
this.xp = this.xp - xp;
}
public int getNormalWins() {
return normalWins;
}
public int getFourWins() {
return fourWins;
}
public int getNormalKills() {
return normalKills;
}
public int getFourKills() {
return fourKills;
}
public int getNormalDeaths() {
return normalDeaths;
}
public int getFourDeaths() {
return fourDeaths;
}
public int getNormalGoals() {
return normalGoals;
}
public int getFourGoals() {
return fourGoals;
}
public int getCoins() {
return coins;
}
public int getXP() {
return xp;
}
public void setNormalWins(int normalWins) {
this.normalWins = normalWins;
}
public void setFourWins(int fourWins) {
this.fourWins = fourWins;
}
public void setNormalKills(int normalKills) {
this.normalKills = normalKills;
}
public void setFourKills(int fourKills) {
this.fourKills = fourKills;
}
public void setNormalDeaths(int normalDeaths) {
this.normalDeaths = normalDeaths;
}
public void setFourDeaths(int fourDeaths) {
this.fourDeaths = fourDeaths;
}
public void setNormalGoals(int normalGoals) {
this.normalGoals = normalGoals;
}
public void setFourGoals(int fourGoals) {
this.fourGoals = fourGoals;
}
public void setCoins(int coins) {
this.coins = coins;
}
public void setXP(int xp) {
this.xp = xp;
}
}

65
MultiArena-TheBridge/src/cx/sfy/TheBridge/fanciful/ArrayWrapper.java

@ -0,0 +1,65 @@
package cx.sfy.TheBridge.fanciful;
import org.apache.commons.lang.Validate;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Collection;
public final class ArrayWrapper<E> {
public ArrayWrapper(@SuppressWarnings("unchecked") E... elements) {
setArray(elements);
}
private E[] _array;
public E[] getArray() {
return _array;
}
public void setArray(E[] array) {
Validate.notNull(array, "The array must not be null.");
_array = array;
}
@SuppressWarnings("rawtypes")
@Override
public boolean equals(Object other) {
if (!(other instanceof ArrayWrapper)) {
return false;
}
return Arrays.equals(_array, ((ArrayWrapper) other)._array);
}
@Override
public int hashCode() {
return Arrays.hashCode(_array);
}
@SuppressWarnings("unchecked")
public static <T> T[] toArray(Iterable<? extends T> list, Class<T> c) {
int size = -1;
if (list instanceof Collection<?>) {
@SuppressWarnings("rawtypes")
Collection coll = (Collection) list;
size = coll.size();
}
if (size < 0) {
size = 0;
for (@SuppressWarnings("unused") T element : list) {
size++;
}
}
T[] result = (T[]) Array.newInstance(c, size);
int i = 0;
for (T element : list) {
result[i++] = element;
}
return result;
}
}

407
MultiArena-TheBridge/src/cx/sfy/TheBridge/fanciful/FancyMessage.java

@ -0,0 +1,407 @@
package cx.sfy.TheBridge.fanciful;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.stream.JsonWriter;
import cx.sfy.TheBridge.fanciful.ArrayWrapper;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
import org.bukkit.entity.Player;
import static cx.sfy.TheBridge.fanciful.TextualComponent.rawText;
import java.io.IOException;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<MessagePart>, ConfigurationSerializable {
static {
ConfigurationSerialization.registerClass(FancyMessage.class);
}
private List<MessagePart> messageParts;
private String jsonString;
private boolean dirty;
@Override
public FancyMessage clone() throws CloneNotSupportedException {
FancyMessage instance = (FancyMessage) super.clone();
instance.messageParts = new ArrayList<MessagePart>(messageParts.size());
for (int i = 0; i < messageParts.size(); i++) {
instance.messageParts.add(i, messageParts.get(i).clone());
}
instance.dirty = false;
instance.jsonString = null;
return instance;
}
public FancyMessage(final String firstPartText) {
this(rawText(firstPartText));
}
public FancyMessage(final TextualComponent firstPartText) {
messageParts = new ArrayList<MessagePart>();
messageParts.add(new MessagePart(firstPartText));
jsonString = null;
dirty = false;
}
public FancyMessage() {
this((TextualComponent) null);
}
public FancyMessage text(String text) {
MessagePart latest = latest();
latest.text = rawText(text);
dirty = true;
return this;
}
public FancyMessage text(TextualComponent text) {
MessagePart latest = latest();
latest.text = text;
dirty = true;
return this;
}
public FancyMessage color(final ChatColor color) {
if (!color.isColor()) {
throw new IllegalArgumentException(color.name() + " is not a color");
}
latest().color = color;
dirty = true;
return this;
}
public FancyMessage style(ChatColor... styles) {
for (final ChatColor style : styles) {
if (!style.isFormat()) {
throw new IllegalArgumentException(style.name() + " is not a style");
}
}
latest().styles.addAll(Arrays.asList(styles));
dirty = true;
return this;
}
public FancyMessage file(final String path) {
onClick("open_file", path);
return this;
}
public FancyMessage link(final String url) {
onClick("open_url", url);
return this;
}
public FancyMessage suggest(final String command) {
onClick("suggest_command", command);
return this;
}
public FancyMessage insert(final String command) {
latest().insertionData = command;
dirty = true;
return this;
}
public FancyMessage command(final String command) {
onClick("run_command", command);
return this;
}
public FancyMessage achievementTooltip(final String name) {
onHover("show_achievement", new JsonString("achievement." + name));
return this;
}
public FancyMessage tooltip(final String text) {
onHover("show_text", new JsonString(text));
return this;
}
public FancyMessage tooltip(final Iterable<String> lines) {
tooltip(ArrayWrapper.toArray(lines, String.class));
return this;
}
public FancyMessage tooltip(final String... lines) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < lines.length; i++) {
builder.append(lines[i]);
if (i != lines.length - 1) {
builder.append('\n');
}
}
tooltip(builder.toString());
return this;
}
public FancyMessage formattedTooltip(FancyMessage text) {
for (MessagePart component : text.messageParts) {
if (component.clickActionData != null && component.clickActionName != null) {
throw new IllegalArgumentException("The tooltip text cannot have click data.");
} else if (component.hoverActionData != null && component.hoverActionName != null) {
throw new IllegalArgumentException("The tooltip text cannot have a tooltip.");
}
}
onHover("show_text", text);
return this;
}
public FancyMessage formattedTooltip(FancyMessage... lines) {
if (lines.length < 1) {
onHover(null, null);
return this;
}
FancyMessage result = new FancyMessage();
result.messageParts.clear();
for (int i = 0; i < lines.length; i++) {
try {
for (MessagePart component : lines[i]) {
if (component.clickActionData != null && component.clickActionName != null) {
throw new IllegalArgumentException("The tooltip text cannot have click data.");
} else if (component.hoverActionData != null && component.hoverActionName != null) {
throw new IllegalArgumentException("The tooltip text cannot have a tooltip.");
}
if (component.hasText()) {
result.messageParts.add(component.clone());
}
}
if (i != lines.length - 1) {
result.messageParts.add(new MessagePart(rawText("\n")));
}
} catch (CloneNotSupportedException e) {
Bukkit.getLogger().log(Level.WARNING, "Failed to clone object", e);
return this;
}
}
return formattedTooltip(result.messageParts.isEmpty() ? null : result); // Throws NPE if size is 0, intended
}
public FancyMessage formattedTooltip(final Iterable<FancyMessage> lines) {
return formattedTooltip(ArrayWrapper.toArray(lines, FancyMessage.class));
}
public FancyMessage translationReplacements(final String... replacements) {
for (String str : replacements) {
latest().translationReplacements.add(new JsonString(str));
}
dirty = true;
return this;
}
public FancyMessage translationReplacements(final FancyMessage... replacements) {
for (FancyMessage str : replacements) {
latest().translationReplacements.add(str);
}
dirty = true;
return this;
}
public FancyMessage translationReplacements(final Iterable<FancyMessage> replacements) {
return translationReplacements(ArrayWrapper.toArray(replacements, FancyMessage.class));
}
public FancyMessage then(final String text) {
return then(rawText(text));
}
public FancyMessage then(final TextualComponent text) {
if (!latest().hasText()) {
throw new IllegalStateException("previous message part has no text");
}
messageParts.add(new MessagePart(text));
dirty = true;
return this;
}
public FancyMessage then() {
if (!latest().hasText()) {
throw new IllegalStateException("previous message part has no text");
}
messageParts.add(new MessagePart());
dirty = true;
return this;
}
@Override
public void writeJson(JsonWriter writer) throws IOException {
if (messageParts.size() == 1) {
latest().writeJson(writer);
} else {
writer.beginObject().name("text").value("").name("extra").beginArray();
for (final MessagePart part : this) {
part.writeJson(writer);
}
writer.endArray().endObject();
}
}
public String toJSONString() {
if (!dirty && jsonString != null) {
return jsonString;
}
StringWriter string = new StringWriter();
JsonWriter json = new JsonWriter(string);
try {
writeJson(json);
json.close();
} catch (IOException e) {
throw new RuntimeException("invalid message");
}
jsonString = string.toString();
dirty = false;
return jsonString;
}
public void send(Player player) {
send(player, toJSONString());
}
private void send(CommandSender sender, String jsonString) {
if (!(sender instanceof Player)) {
sender.sendMessage(toOldMessageFormat());
return;
}
Player player = (Player) sender;
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " " + jsonString);
}
public void send(CommandSender sender) {
send(sender, toJSONString());
}
public void send(final Iterable<? extends CommandSender> senders) {
String string = toJSONString();
for (final CommandSender sender : senders) {
send(sender, string);
}
}
public String toOldMessageFormat() {
StringBuilder result = new StringBuilder();
for (MessagePart part : this) {
result.append(part.color == null ? "" : part.color);
for (ChatColor formatSpecifier : part.styles) {
result.append(formatSpecifier);
}
result.append(part.text);
}
return result.toString();
}
private MessagePart latest() {
return messageParts.get(messageParts.size() - 1);
}
private void onClick(final String name, final String data) {
final MessagePart latest = latest();
latest.clickActionName = name;
latest.clickActionData = data;
dirty = true;
}
private void onHover(final String name, final JsonRepresentedObject data) {
final MessagePart latest = latest();
latest.hoverActionName = name;
latest.hoverActionData = data;
dirty = true;
}
public Map<String, Object> serialize() {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("messageParts", messageParts);
return map;
}
@SuppressWarnings("unchecked")
public static FancyMessage deserialize(Map<String, Object> serialized) {
FancyMessage msg = new FancyMessage();
msg.messageParts = (List<MessagePart>) serialized.get("messageParts");
msg.jsonString = serialized.containsKey("JSON") ? serialized.get("JSON").toString() : null;
msg.dirty = !serialized.containsKey("JSON");
return msg;
}
public Iterator<MessagePart> iterator() {
return messageParts.iterator();
}
private static JsonParser _stringParser = new JsonParser();
public static FancyMessage deserialize(String json) {
JsonObject serialized = _stringParser.parse(json).getAsJsonObject();
JsonArray extra = serialized.getAsJsonArray("extra");
FancyMessage returnVal = new FancyMessage();
returnVal.messageParts.clear();
for (JsonElement mPrt : extra) {
MessagePart component = new MessagePart();
JsonObject messagePart = mPrt.getAsJsonObject();
for (Map.Entry<String, JsonElement> entry : messagePart.entrySet()) {
if (TextualComponent.isTextKey(entry.getKey())) {
Map<String, Object> serializedMapForm = new HashMap<String, Object>();
serializedMapForm.put("key", entry.getKey());
if (entry.getValue().isJsonPrimitive()) {
serializedMapForm.put("value", entry.getValue().getAsString());
} else {
for (Map.Entry<String, JsonElement> compositeNestedElement : entry.getValue().getAsJsonObject().entrySet()) {
serializedMapForm.put("value." + compositeNestedElement.getKey(), compositeNestedElement.getValue().getAsString());
}
}
component.text = TextualComponent.deserialize(serializedMapForm);
} else if (MessagePart.stylesToNames.inverse().containsKey(entry.getKey())) {
if (entry.getValue().getAsBoolean()) {
component.styles.add(MessagePart.stylesToNames.inverse().get(entry.getKey()));
}
} else if (entry.getKey().equals("color")) {
component.color = ChatColor.valueOf(entry.getValue().getAsString().toUpperCase());
} else if (entry.getKey().equals("clickEvent")) {
JsonObject object = entry.getValue().getAsJsonObject();
component.clickActionName = object.get("action").getAsString();
component.clickActionData = object.get("value").getAsString();
} else if (entry.getKey().equals("hoverEvent")) {
JsonObject object = entry.getValue().getAsJsonObject();
component.hoverActionName = object.get("action").getAsString();
if (object.get("value").isJsonPrimitive()) {
component.hoverActionData = new JsonString(object.get("value").getAsString());
} else {
component.hoverActionData = deserialize(object.get("value").toString() /* This should properly serialize the JSON object as a JSON string */);
}
} else if (entry.getKey().equals("insertion")) {
component.insertionData = entry.getValue().getAsString();
} else if (entry.getKey().equals("with")) {
for (JsonElement object : entry.getValue().getAsJsonArray()) {
if (object.isJsonPrimitive()) {
component.translationReplacements.add(new JsonString(object.getAsString()));
} else {
component.translationReplacements.add(deserialize(object.toString()));
}
}
}
}
returnVal.messageParts.add(component);
}
return returnVal;
}
}

11
MultiArena-TheBridge/src/cx/sfy/TheBridge/fanciful/JsonRepresentedObject.java

@ -0,0 +1,11 @@
package cx.sfy.TheBridge.fanciful;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
interface JsonRepresentedObject {
public void writeJson(JsonWriter writer) throws IOException;
}

42
MultiArena-TheBridge/src/cx/sfy/TheBridge/fanciful/JsonString.java

@ -0,0 +1,42 @@
package cx.sfy.TheBridge.fanciful;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import com.google.gson.stream.JsonWriter;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
final class JsonString implements JsonRepresentedObject, ConfigurationSerializable {
private String _value;
public JsonString(CharSequence value) {
_value = value == null ? null : value.toString();
}
@Override
public void writeJson(JsonWriter writer) throws IOException {
writer.value(getValue());
}
public String getValue() {
return _value;
}
public Map<String, Object> serialize() {
HashMap<String, Object> theSingleValue = new HashMap<String, Object>();
theSingleValue.put("stringValue", _value);
return theSingleValue;
}
public static JsonString deserialize(Map<String, Object> map) {
return new JsonString(map.get("stringValue").toString());
}
@Override
public String toString() {
return _value;
}
}

152
MultiArena-TheBridge/src/cx/sfy/TheBridge/fanciful/MessagePart.java

@ -0,0 +1,152 @@
package cx.sfy.TheBridge.fanciful;
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap;
import com.google.gson.stream.JsonWriter;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
final class MessagePart implements JsonRepresentedObject, ConfigurationSerializable, Cloneable {
ChatColor color = ChatColor.WHITE;
ArrayList<ChatColor> styles = new ArrayList<ChatColor>();
String clickActionName = null, clickActionData = null, hoverActionName = null;
JsonRepresentedObject hoverActionData = null;
TextualComponent text = null;
String insertionData = null;
ArrayList<JsonRepresentedObject> translationReplacements = new ArrayList<JsonRepresentedObject>();
MessagePart(final TextualComponent text) {
this.text = text;
}
MessagePart() {
this.text = null;
}
boolean hasText() {
return text != null;
}
@Override
@SuppressWarnings("unchecked")
public MessagePart clone() throws CloneNotSupportedException {
MessagePart obj = (MessagePart) super.clone();
obj.styles = (ArrayList<ChatColor>) styles.clone();
if (hoverActionData instanceof JsonString) {
obj.hoverActionData = new JsonString(((JsonString) hoverActionData).getValue());
} else if (hoverActionData instanceof FancyMessage) {
obj.hoverActionData = ((FancyMessage) hoverActionData).clone();
}
obj.translationReplacements = (ArrayList<JsonRepresentedObject>) translationReplacements.clone();
return obj;
}
static final BiMap<ChatColor, String> stylesToNames;
static {
ImmutableBiMap.Builder<ChatColor, String> builder = ImmutableBiMap.builder();
for (final ChatColor style : ChatColor.values()) {
if (!style.isFormat()) {
continue;
}
String styleName;
switch (style) {
case MAGIC:
styleName = "obfuscated";
break;
case UNDERLINE:
styleName = "underlined";
break;
default:
styleName = style.name().toLowerCase();
break;
}
builder.put(style, styleName);
}
stylesToNames = builder.build();
}
public void writeJson(JsonWriter json) {
try {
json.beginObject();
text.writeJson(json);
json.name("color").value(color.name().toLowerCase());
for (final ChatColor style : styles) {
json.name(stylesToNames.get(style)).value(true);
}
if (clickActionName != null && clickActionData != null) {
json.name("clickEvent")
.beginObject()
.name("action").value(clickActionName)
.name("value").value(clickActionData)
.endObject();
}
if (hoverActionName != null && hoverActionData != null) {
json.name("hoverEvent")
.beginObject()
.name("action").value(hoverActionName)
.name("value");
hoverActionData.writeJson(json);
json.endObject();
}
if (insertionData != null) {
json.name("insertion").value(insertionData);
}
if (translationReplacements.size() > 0 && text != null && TextualComponent.isTranslatableText(text)) {
json.name("with").beginArray();
for (JsonRepresentedObject obj : translationReplacements) {
obj.writeJson(json);
}
json.endArray();
}
json.endObject();
} catch (IOException e) {
Bukkit.getLogger().log(Level.WARNING, "A problem occured during writing of JSON string", e);
}
}
public Map<String, Object> serialize() {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("text", text);
map.put("styles", styles);
map.put("color", color.getChar());
map.put("hoverActionName", hoverActionName);
map.put("hoverActionData", hoverActionData);
map.put("clickActionName", clickActionName);
map.put("clickActionData", clickActionData);
map.put("insertion", insertionData);
map.put("translationReplacements", translationReplacements);
return map;
}
@SuppressWarnings("unchecked")
public static MessagePart deserialize(Map<String, Object> serialized) {
MessagePart part = new MessagePart((TextualComponent) serialized.get("text"));
part.styles = (ArrayList<ChatColor>) serialized.get("styles");
part.color = ChatColor.getByChar(serialized.get("color").toString());
part.hoverActionName = (String) serialized.get("hoverActionName");
part.hoverActionData = (JsonRepresentedObject) serialized.get("hoverActionData");
part.clickActionName = (String) serialized.get("clickActionName");
part.clickActionData = (String) serialized.get("clickActionData");
part.insertionData = (String) serialized.get("insertion");
part.translationReplacements = (ArrayList<JsonRepresentedObject>) serialized.get("translationReplacements");
return part;
}
static {
ConfigurationSerialization.registerClass(MessagePart.class);
}
}

211
MultiArena-TheBridge/src/cx/sfy/TheBridge/fanciful/TextualComponent.java

@ -0,0 +1,211 @@
package cx.sfy.TheBridge.fanciful;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.gson.stream.JsonWriter;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public abstract class TextualComponent implements Cloneable {
static {
ConfigurationSerialization.registerClass(TextualComponent.ArbitraryTextTypeComponent.class);
ConfigurationSerialization.registerClass(TextualComponent.ComplexTextTypeComponent.class);
}
@Override
public String toString() {
return getReadableString();
}
public abstract String getKey();
public abstract String getReadableString();
@Override
public abstract TextualComponent clone() throws CloneNotSupportedException;
public abstract void writeJson(JsonWriter writer) throws IOException;
static TextualComponent deserialize(Map<String, Object> map) {
if (map.containsKey("key") && map.size() == 2 && map.containsKey("value")) {
return ArbitraryTextTypeComponent.deserialize(map);
} else if (map.size() >= 2 && map.containsKey("key") && !map.containsKey("value")) {
return ComplexTextTypeComponent.deserialize(map);
}
return null;
}
static boolean isTextKey(String key) {
return key.equals("translate") || key.equals("text") || key.equals("score") || key.equals("selector");
}
static boolean isTranslatableText(TextualComponent component) {
return component instanceof ComplexTextTypeComponent && ((ComplexTextTypeComponent) component).getKey().equals("translate");
}
private static final class ArbitraryTextTypeComponent extends TextualComponent implements ConfigurationSerializable {
public ArbitraryTextTypeComponent(String key, String value) {
setKey(key);
setValue(value);
}
@Override
public String getKey() {
return _key;
}
public void setKey(String key) {
Preconditions.checkArgument(key != null && !key.isEmpty(), "The key must be specified.");
_key = key;
}
public String getValue() {
return _value;
}
public void setValue(String value) {
Preconditions.checkArgument(value != null, "The value must be specified.");
_value = value;
}
private String _key;
private String _value;
@Override
public TextualComponent clone() throws CloneNotSupportedException {
return new ArbitraryTextTypeComponent(getKey(), getValue());
}
@Override
public void writeJson(JsonWriter writer) throws IOException {
writer.name(getKey()).value(getValue());
}
@SuppressWarnings("serial")
public Map<String, Object> serialize() {
return new HashMap<String, Object>() {{
put("key", getKey());
put("value", getValue());
}};
}
public static ArbitraryTextTypeComponent deserialize(Map<String, Object> map) {
return new ArbitraryTextTypeComponent(map.get("key").toString(), map.get("value").toString());
}
@Override
public String getReadableString() {
return getValue();
}
}
private static final class ComplexTextTypeComponent extends TextualComponent implements ConfigurationSerializable {
public ComplexTextTypeComponent(String key, Map<String, String> values) {
setKey(key);
setValue(values);
}
@Override
public String getKey() {
return _key;
}
public void setKey(String key) {
Preconditions.checkArgument(key != null && !key.isEmpty(), "The key must be specified.");
_key = key;
}
public Map<String, String> getValue() {
return _value;
}
public void setValue(Map<String, String> value) {
Preconditions.checkArgument(value != null, "The value must be specified.");
_value = value;
}
private String _key;
private Map<String, String> _value;
@Override
public TextualComponent clone() throws CloneNotSupportedException {
return new ComplexTextTypeComponent(getKey(), getValue());
}
@Override
public void writeJson(JsonWriter writer) throws IOException {
writer.name(getKey());
writer.beginObject();
for (Map.Entry<String, String> jsonPair : _value.entrySet()) {
writer.name(jsonPair.getKey()).value(jsonPair.getValue());
}
writer.endObject();
}
@SuppressWarnings("serial")
public Map<String, Object> serialize() {
return new java.util.HashMap<String, Object>() {{
put("key", getKey());
for (Map.Entry<String, String> valEntry : getValue().entrySet()) {
put("value." + valEntry.getKey(), valEntry.getValue());
}
}};
}
public static ComplexTextTypeComponent deserialize(Map<String, Object> map) {
String key = null;
Map<String, String> value = new HashMap<String, String>();
for (Map.Entry<String, Object> valEntry : map.entrySet()) {
if (valEntry.getKey().equals("key")) {
key = (String) valEntry.getValue();
} else if (valEntry.getKey().startsWith("value.")) {
value.put(((String) valEntry.getKey()).substring(6), valEntry.getValue().toString());
}
}
return new ComplexTextTypeComponent(key, value);
}
@Override
public String getReadableString() {
return getKey();
}
}
public static TextualComponent rawText(String textValue) {
return new ArbitraryTextTypeComponent("text", textValue);
}
public static TextualComponent localizedText(String translateKey) {
return new ArbitraryTextTypeComponent("translate", translateKey);
}
private static void throwUnsupportedSnapshot() {
throw new UnsupportedOperationException("This feature is only supported in snapshot releases.");
}
public static TextualComponent objectiveScore(String scoreboardObjective) {
return objectiveScore("*", scoreboardObjective);
}
public static TextualComponent objectiveScore(String playerName, String scoreboardObjective) {
throwUnsupportedSnapshot();
return new ComplexTextTypeComponent("score", ImmutableMap.<String, String>builder()
.put("name", playerName)
.put("objective", scoreboardObjective)
.build());
}
public static TextualComponent selector(String selector) {
throwUnsupportedSnapshot();
return new ArbitraryTextTypeComponent("selector", selector);
}
}

753
MultiArena-TheBridge/src/cx/sfy/TheBridge/game/Game.java

@ -0,0 +1,753 @@
package cx.sfy.TheBridge.game;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.database.PlayerStat;
import cx.sfy.TheBridge.hologram.TruenoHologram;
import cx.sfy.TheBridge.hologram.TruenoHologramAPI;
import cx.sfy.TheBridge.team.Team;
import cx.sfy.TheBridge.utils.CenterMessage;
import cx.sfy.TheBridge.utils.ItemBuilder;
import cx.sfy.TheBridge.utils.Utils;
public class Game {
private final Main plugin;
private final HashMap<ChatColor, Team> teams;
private final HashMap<Player, ChatColor> teamPlayer;
private final ArrayList<Player> players;
private final HashMap<Player, PlayerData> pd = new HashMap<>();
private final HashMap<Player, Integer> goals = new HashMap<>();
private final HashMap<Player, Integer> kills = new HashMap<>();
private final ArrayList<TruenoHologram> holograms = new ArrayList<>();
private final ArrayList<Location> build = new ArrayList<>();
private final ArrayList<Location> placed = new ArrayList<>();
private final String name;
private final String mode;
private final int min;
private final int max;
private final int teamSize;
private int starting;
private int prestart;
private int restart;
private final Location lobby;
private final Location spect;
private BukkitTask start;
private BukkitTask prestarts;
private State state;
int time = 0;
int tick = 0;
public Game(Main plugin, String name, int min, int max, int teamSize, int starting, int prestart, int restart,
Location lobby, Location spect, Location buildMin, Location buildMax, Location spawnsRed,
Location spawnsBlue, ArrayList<Location> portalRed, ArrayList<Location> portalBlue, Location respawnsRed,
Location respawnsBlue, Location hRed, Location hBlue) {
this.plugin = plugin;
this.starting = starting;
this.prestart = prestart;
this.restart = restart;
this.max = max;
this.min = min;
this.teamSize = teamSize;
this.mode = teamSize + "v" + teamSize;
this.name = name;
this.lobby = lobby;
this.spect = spect;
this.teamPlayer = new HashMap<>();
this.teams = new HashMap<>();
this.players = new ArrayList<>();
final int gn = Math.min(buildMin.getBlockX(), buildMax.getBlockX());
final int gn2 = Math.max(buildMin.getBlockX(), buildMax.getBlockX());
final int gn3 = Math.min(buildMin.getBlockZ(), buildMax.getBlockZ());
final int gn4 = Math.max(buildMin.getBlockZ(), buildMax.getBlockZ());
final int gn5 = Math.min(buildMin.getBlockY(), buildMax.getBlockY());
final int gn6 = Math.max(buildMin.getBlockY(), buildMax.getBlockY());
for (int i = gn; i <= gn2; ++i)
for (int j = gn5; j <= gn6; ++j)
for (int k = gn3; k <= gn4; ++k) {
final Location location3 = new Location(buildMin.getWorld(), i, j, k);
build.add(location3);
}
this.teams.put(ChatColor.BLUE, new Team(plugin.getConfig().getString("names.blue"), ChatColor.BLUE, Color.BLUE,
respawnsBlue, spawnsBlue, portalBlue, hBlue));
this.teams.put(ChatColor.RED, new Team(plugin.getConfig().getString("names.red"), ChatColor.RED, Color.RED,
respawnsRed, spawnsRed, portalRed, hRed));
setState(State.WAITING);
updateSign();
}
public void checkCancel() {
if (isState(State.STARTING) && players.size() <= getMin()) {
if (start != null)
start.cancel();
if (prestarts != null)
prestarts.cancel();
setState(State.WAITING);
starting = 30;
updateSign();
for (final Player on : players)
updateSB(on);
}
}
public void updateSB(Player p) {
plugin.getSB().update(p);
}
public void updateSign() {
plugin.getSIM().updateGameSign(this);
}
public void addPlayer(Player p) {
pd.put(p, new PlayerData(p));
Utils.setCleanPlayer(p);
players.add(p);
kills.put(p, 0);
goals.put(p, 0);
new BukkitRunnable() {
@Override
public void run() {
givePlayerItems(p);
}
}.runTaskLater(plugin, 20);
p.teleport(getLobby());
updateSign();
if (isState(State.WAITING) || isState(State.STARTING))
for (final Player on : players) {
on.sendMessage(plugin.getLang().get("messages.join").replaceAll("<player>", p.getName())
.replaceAll("<players>", String.valueOf(players.size()))
.replaceAll("<max>", String.valueOf(getMax())));
on.playSound(on.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.join")), 1.0f, 1.0f);
updateSB(on);
}
}
public void removePlayer(Player p) {
Utils.setCleanPlayer(p);
pd.get(p).restore();
removeAllPlayerTeam(p);
players.remove(p);
if (isState(State.WAITING) || isState(State.STARTING))
for (final Player on : players) {
on.sendMessage(plugin.getLang().get("messages.quit").replaceAll("<player>", p.getName())
.replaceAll("<players>", String.valueOf(players.size()))
.replaceAll("<max>", String.valueOf(getMax())));
on.playSound(on.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.quit")), 1.0f, 1.0f);
updateSB(on);
}
else if (getTeamsAlive() == 1 && players.size() >= 1)
checkWin(p, getLastTeam(), getLastTeam().getGoals());
updateSign();
checkCancel();
}
// FIXME: Not properly giving coins
public boolean checkWin(Player w, Team team, int goals) {
if (isState(State.FINISH))
return false;
final DecimalFormat df = new DecimalFormat("#.##");
if (getTeamsAlive() <= 1 && players.size() >= 1) {
final Team win = getLastTeam();
setState(State.FINISH);
firework(getSpect(), win.getFColor());
for (final Player r : win.getTeamPlayers())
PlayerStat.getPlayerStat(r).addNormalWins();
for (final Player p : players) {
p.teleport(lobby);
updateSB(p);
plugin.getNMS().sendTitle(p, 0, 60, 0,
plugin.getLang().get("titles.win.title")
.replaceAll("<blueGoals>", String.valueOf(teams.get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(teams.get(ChatColor.RED).getGoals()))
.replaceAll("<team>", team.getTeamName()).replaceAll("<color>", team.getColor() + ""),
plugin.getLang().get("titles.win.subtitle")
.replaceAll("<blueGoals>", String.valueOf(teams.get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(teams.get(ChatColor.RED).getGoals()))
.replaceAll("<team>", team.getTeamName()).replaceAll("<color>", team.getColor() + ""));
for (final String msg : plugin.getLang().getList("messages.win"))
CenterMessage.sendCenteredMessage(p,
msg.replaceAll("&", "§").replaceAll("<player>", w.getName())
.replaceAll("<blueGoals>", String.valueOf(teams.get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(teams.get(ChatColor.RED).getGoals()))
.replaceAll("<s>", getGoals(w) > 1 ? "es" : "")
.replaceAll("<goals>", String.valueOf(getGoals(w)))
.replaceAll("<health>", df.format(w.getHealth())).replaceAll("<heart>", "❤")
.replaceAll("<color>", "" + team.getColor())
.replaceAll("<team>", win.getTeamName().toUpperCase()));
}
new BukkitRunnable() {
@Override
public void run() {
for (final TruenoHologram th : holograms)
th.delete();
for (final Player p : spect.getWorld().getPlayers())
if (pd.containsKey(p))
plugin.getGM().removePlayerAllGames(p);
else
p.teleport(plugin.getMainLobby());
}
}.runTaskLater(plugin, 20 * 10);
new BukkitRunnable() {
@Override
public void run() {
plugin.getGM().resetNormalGame(getName());
}
}.runTaskLater(plugin, 20 * 12);
updateSign();
return true;
}
if (team.getGoals() >= goals) {
setState(State.FINISH);
final Team win = getLastTeam();
firework(getSpect(), team.getFColor());
for (final Player r : win.getTeamPlayers())
PlayerStat.getPlayerStat(r).addNormalWins();
for (final Player p : players) {
p.teleport(lobby);
plugin.getNMS().sendTitle(p, 0, 60, 0,
plugin.getLang().get("titles.win.title")
.replaceAll("<blueGoals>", String.valueOf(teams.get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(teams.get(ChatColor.RED).getGoals()))
.replaceAll("<team>", team.getTeamName()).replaceAll("<color>", team.getColor() + ""),
plugin.getLang().get("titles.win.subtitle")
.replaceAll("<blueGoals>", String.valueOf(teams.get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(teams.get(ChatColor.RED).getGoals()))
.replaceAll("<team>", team.getTeamName()).replaceAll("<color>", team.getColor() + ""));
for (final String msg : plugin.getLang().getList("messages.win"))
CenterMessage.sendCenteredMessage(p,
msg.replaceAll("&", "§").replaceAll("<player>", w.getName())
.replaceAll("<blueGoals>", String.valueOf(teams.get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(teams.get(ChatColor.RED).getGoals()))
.replaceAll("<s>", getGoals(w) > 1 ? "es" : "")
.replaceAll("<goals>", String.valueOf(getGoals(w)))
.replaceAll("<health>", df.format(w.getHealth())).replaceAll("<heart>", "❤")
.replaceAll("<color>", "" + team.getColor())
.replaceAll("<team>", team.getTeamName().toUpperCase()));
}
new BukkitRunnable() {
@Override
public void run() {
for (final Player p : spect.getWorld().getPlayers())
if (pd.containsKey(p))
plugin.getGM().removePlayerAllGames(p);
else
p.teleport(plugin.getMainLobby());
}
}.runTaskLater(plugin, 20 * 10);
new BukkitRunnable() {
@Override
public void run() {
plugin.getGM().resetNormalGame(getName());
}
}.runTaskLater(plugin, 20 * 12);
updateSign();
return true;
}
return false;
}
public void celebrateGoal(Team team, Player e) {
restart = 5;
team.addGoal();
addGoal(e);
PlayerStat.getPlayerStat(e).addNormalGoals();
if (checkWin(e, team, 5))
return;
firework(getSpect(), team.getFColor());
if (plugin.isCage()) {
for (final Team te : teams.values())
if (!te.isCage())
if (te.getTeamPlayers().get(0) != null) {
te.createCage(plugin.getCM()
.getCageByName(PlayerStat.getPlayerStat(te.getTeamPlayers().get(0)).getCage()));
te.setCage(true);
} else {
te.createCage(plugin.getCM().getCageByName(plugin.getConfig().getString("defaultCage")));
te.setCage(true);
}
} else
for (final ChatColor color : teams.keySet())
plugin.getGLM().createCage(teams.get(color).getTeamSpawn(), color);
for (final Player p : players) {
p.teleport(getTeamPlayer(p).getTeamSpawn().clone().add(0, 1, 0));
updateSB(p);
}
checkRestart(team, team.getColor(), e);
}
public void firework(Location loc, Color c1) {
time = 0;
new BukkitRunnable() {
@Override
public void run() {
final Firework fa = loc.getWorld().spawn(loc.clone().add(new Random().nextInt(5) + 1,
new Random().nextInt(1) + 1, new Random().nextInt(5) + 1), Firework.class);
final FireworkMeta fam = fa.getFireworkMeta();
final FireworkEffect.Type tipo = FireworkEffect.Type.STAR;
final Color c2 = Color.WHITE;
final FireworkEffect ef = FireworkEffect.builder().withColor(c1).withFade(c2).with(tipo).build();
fam.addEffect(ef);
fam.setPower(0);
fa.setFireworkMeta(fam);
time++;
if (time == 10)
cancel();
}
}.runTaskTimer(plugin, 0, 10);
}
public void checkRestart(Team team, ChatColor color, Player e) {
final DecimalFormat df = new DecimalFormat("#.##");
for (final Player p : players) {
Utils.setCleanPlayer(p);
p.setGameMode(GameMode.ADVENTURE);
giveKit(p, getTeamPlayer(p));
for (final String msg : plugin.getLang().getList("messages.goal"))
CenterMessage.sendCenteredMessage(p,
msg.replaceAll("&", "§").replaceAll("<player>", e.getName())
.replaceAll("<blueGoals>", String.valueOf(teams.get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(teams.get(ChatColor.RED).getGoals()))
.replaceAll("<s>", getGoals(e) > 1 ? "es" : "")
.replaceAll("<goals>", String.valueOf(getGoals(e)))
.replaceAll("<health>", df.format(e.getHealth())).replaceAll("<heart>", "❤")
.replaceAll("<color>", "" + team.getColor())
.replaceAll("<team>", team.getTeamName().toUpperCase()));
}
new BukkitRunnable() {
@Override
public void run() {
if (restart == 10 || restart == 5 || restart == 4 || restart == 3 || restart == 2)
for (final Player p : players) {
p.sendMessage(plugin.getLang().get(p, "messages.restart").replaceAll("<color>", "" + color)
.replaceAll("<player>", e.getName()).replaceAll("<time>", String.valueOf(restart))
.replaceAll("<s>", "s")
.replaceAll("<units>", plugin.getLang().get(p, "units.seconds")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.restart")), 1.0f,
1.0f);
plugin.getTM().sendReStartTitle(e, p, restart, true);
}
if (restart == 1)
for (final Player p : players) {
p.sendMessage(plugin.getLang().get(p, "messages.restart").replaceAll("<color>", "" + color)
.replaceAll("<player>", e.getName()).replaceAll("<time>", String.valueOf(restart))
.replaceAll("<s>", "").replaceAll("<units>", plugin.getLang().get(p, "units.second")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.restart")), 1.0f,
1.0f);
plugin.getTM().sendReStartTitle(e, p, restart, false);
}
if (restart == 0) {
if (plugin.isCage()) {
for (final Team team : teams.values())
if (team.isCage()) {
team.removeCage();
team.setCage(false);
}
} else
for (final ChatColor color : teams.keySet())
plugin.getGLM().removeGlass(teams.get(color).getTeamSpawn());
for (final Player p : players)
p.setGameMode(GameMode.SURVIVAL);
cancel();
}
restart--;
}
}.runTaskTimer(get(), 0, 20);
}
public void updateGame() {
tick++;
if (isState(State.WAITING) && players.size() >= getMin()) {
setState(State.STARTING);
updateSign();
for (final Player p : players)
p.setGameMode(GameMode.ADVENTURE);
}
if (isState(State.STARTING)) {
if (tick % 20 == 0)
for (final Player p : players)
updateSB(p);
if (starting == 240 || starting == 180 || starting == 120)
for (final Player p : players) {
p.sendMessage(plugin.getLang().get(p, "messages.starting")
.replaceAll("<time>", String.valueOf(starting / 60))
.replaceAll("<units>", plugin.getLang().get(p, "units.minutes")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.starting")), 1.0f,
1.0f);
plugin.getTM().sendStartTitle(p, starting, true);
}
else if (starting == 60)
for (final Player p : players) {
p.sendMessage(plugin.getLang().get(p, "messages.starting")
.replaceAll("<time>", String.valueOf(starting / 60))
.replaceAll("<units>", plugin.getLang().get(p, "units.minute")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.starting")), 1.0f,
1.0f);
plugin.getTM().sendStartTitle(p, starting, true);
}
else if (starting == 30 || starting == 15 || starting == 10 || starting == 5 || starting == 4
|| starting == 3 || starting == 2)
for (final Player p : players) {
p.sendMessage(
plugin.getLang().get(p, "messages.starting").replaceAll("<time>", String.valueOf(starting))
.replaceAll("<units>", plugin.getLang().get(p, "units.seconds")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.starting")), 1.0f,
1.0f);
plugin.getTM().sendStartTitle(p, starting, true);
}
else if (starting == 1) {
setState(State.PREGAME);
updateSign();
for (final Player p : players) {
p.sendMessage(
plugin.getLang().get(p, "messages.starting").replaceAll("<time>", String.valueOf(starting))
.replaceAll("<units>", plugin.getLang().get(p, "units.second")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.starting")), 1.0f,
1.0f);
plugin.getTM().sendStartTitle(p, starting, false);
if (getTeamPlayer(p) == null)
addRandomTeam(p);
p.getInventory().clear();
}
if (plugin.isCage()) {
for (final Team team : teams.values())
if (!team.isCage())
if (team.getTeamPlayers().get(0) != null) {
team.createCage(plugin.getCM().getCageByName(
PlayerStat.getPlayerStat(team.getTeamPlayers().get(0)).getCage()));
team.setCage(true);
} else {
team.createCage(
plugin.getCM().getCageByName(plugin.getConfig().getString("defaultCage")));
team.setCage(true);
}
} else
for (final ChatColor color : teams.keySet())
plugin.getGLM().createCage(teams.get(color).getTeamSpawn(), color);
for (final Player p : players) {
p.teleport(getTeamPlayer(p).getTeamSpawn().clone().add(0, 1, 0));
giveKit(p, getTeamPlayer(p));
}
final Location hRed = teams.get(ChatColor.RED).getHologram();
final Location hBlue = teams.get(ChatColor.BLUE).getHologram();
if (hRed != null && hBlue != null) {
for (final Player p : teams.get(ChatColor.RED).getTeamPlayers()) {
final ArrayList<String> pRed = new ArrayList<>();
final TruenoHologram phRed = TruenoHologramAPI.getNewHologram();
for (final String portal : plugin.getLang().getList("holograms.portal.you"))
pRed.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.RED)
.replaceAll("<team>", plugin.getLang().get("holograms.your")));
final ArrayList<String> pBlue = new ArrayList<>();
final TruenoHologram phBlue = TruenoHologramAPI.getNewHologram();
for (final String portal : plugin.getLang().getList("holograms.portal.enemy"))
pBlue.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.BLUE)
.replaceAll("<team>", teams.get(ChatColor.BLUE).getTeamName()));
phBlue.setupPlayerHologram(p, hBlue, pBlue);
phBlue.display();
phRed.setupPlayerHologram(p, hRed, pRed);
phRed.display();
holograms.add(phRed);
holograms.add(phBlue);
}
for (final Player p : teams.get(ChatColor.BLUE).getTeamPlayers()) {
final ArrayList<String> pRed = new ArrayList<>();
final TruenoHologram phRed = TruenoHologramAPI.getNewHologram();
for (final String portal : plugin.getLang().getList("holograms.portal.you"))
pRed.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.BLUE)
.replaceAll("<team>", plugin.getLang().get("holograms.your")));
final ArrayList<String> pBlue = new ArrayList<>();
final TruenoHologram phBlue = TruenoHologramAPI.getNewHologram();
for (final String portal : plugin.getLang().getList("holograms.portal.enemy"))
pBlue.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.RED)
.replaceAll("<team>", teams.get(ChatColor.RED).getTeamName()));
phBlue.setupPlayerHologram(p, hRed, pBlue);
phBlue.display();
phRed.setupPlayerHologram(p, hBlue, pRed);
phRed.display();
holograms.add(phRed);
holograms.add(phBlue);
}
}
teams.get(ChatColor.RED).createPortal();
teams.get(ChatColor.BLUE).createPortal();
}
starting--;
}
if (isState(State.PREGAME)) {
if (prestart == 10 || prestart == 5 || prestart == 4 || prestart == 3 || prestart == 2)
for (final Player p : players) {
p.sendMessage(
plugin.getLang().get(p, "messages.prestart").replaceAll("<time>", String.valueOf(prestart))
.replaceAll("<units>", plugin.getLang().get(p, "units.seconds")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.prestart")), 1.0f,
1.0f);
plugin.getTM().sendPreTitle(p, prestart, true);
updateSB(p);
}
else if (prestart == 1)
for (final Player p : players) {
p.sendMessage(
plugin.getLang().get(p, "messages.prestart").replaceAll("<time>", String.valueOf(prestart))
.replaceAll("<units>", plugin.getLang().get(p, "units.second")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.prestart")), 1.0f,
1.0f);
plugin.getTM().sendPreTitle(p, prestart, false);
for (final String msg : plugin.getLang().getList("messages.start"))
CenterMessage.sendCenteredMessage(p, msg.replaceAll("&", "§"));
updateSB(p);
}
else if (prestart == 0) {
setState(State.INGAME);
updateSign();
if (plugin.isCage()) {
for (final Team team : teams.values())
if (team.isCage()) {
team.removeCage();
team.setCage(false);
}
} else
for (final ChatColor color : teams.keySet())
plugin.getGLM().removeGlass(teams.get(color).getTeamSpawn());
for (final Player p : players) {
updateSB(p);
p.setGameMode(GameMode.SURVIVAL);
}
}
prestart--;
}
}
public Team getTeamPlayer(Player p) {
return teams.get(teamPlayer.get(p));
}
public void addPlayerTeam(Player p, Team t) {
t.addPlayer(p);
teamPlayer.put(p, t.getColor());
}
public void addRandomTeam(Player p) {
final Team red = teams.get(ChatColor.RED);
final Team blue = teams.get(ChatColor.BLUE);
if (red.getTeamSize() <= blue.getTeamSize()) {
red.addPlayer(p);
teamPlayer.put(p, red.getColor());
} else {
blue.addPlayer(p);
teamPlayer.put(p, blue.getColor());
}
}
public void removeAllPlayerTeam(Player p) {
for (final Team t : teams.values())
if (t.getTeamPlayers().contains(p))
t.removePlayer(p);
}
public ArrayList<Location> getBuild() {
return build;
}
public HashMap<ChatColor, Team> getTeams() {
return teams;
}
public int getTeamsAlive() {
int cantidad = 0;
for (final Team team : teams.values())
if (team.getTeamSize() > 0)
cantidad++;
return cantidad;
}
public Team getLastTeam() {
for (final Team team : teams.values())
if (team.getTeamSize() > 0)
return team;
return null;
}
public int getPlayers() {
return players.size();
}
public ArrayList<Player> getGamePlayers() {
return players;
}
public String getName() {
return this.name;
}
public int getMax() {
return this.max;
}
public String getMode() {
return mode;
}
public int getMin() {
return this.min;
}
public Main get() {
return plugin;
}
public State getState() {
return this.state;
}
public void setState(State state) {
this.state = state;
}
public boolean isState(State state) {
if (this.state == state)
return true;
return false;
}
public enum State {
WAITING, STARTING, PPGAME, PREGAME, INGAME, FINISH, RESTARTING;
}
public int getGoals(Player p) {
return goals.get(p);
}
public int getKills(Player p) {
return kills.get(p);
}
public void addGoal(Player p) {
goals.put(p, goals.get(p) + 1);
updateSB(p);
}
public void addKill(Player p) {
kills.put(p, kills.get(p) + 1);
updateSB(p);
}
public void giveKit(Player p, Team team) {
final ItemStack helmet = new ItemStack(Material.LEATHER_HELMET, 1);
final LeatherArmorMeta helmetM = (LeatherArmorMeta) helmet.getItemMeta();
helmetM.setColor(team.getFColor());
helmet.setItemMeta(helmetM);
final ItemStack peche = new ItemStack(Material.LEATHER_CHESTPLATE, 1);
final LeatherArmorMeta pecheM = (LeatherArmorMeta) peche.getItemMeta();
pecheM.setColor(team.getFColor());
peche.setItemMeta(pecheM);
final ItemStack panta = new ItemStack(Material.IRON_LEGGINGS, 1);
final ItemMeta pantaM = panta.getItemMeta();
panta.setItemMeta(pantaM);
final ItemStack boots = new ItemStack(Material.IRON_BOOTS, 1);
final ItemMeta bootsM = boots.getItemMeta();
boots.setItemMeta(bootsM);
p.getInventory().setHelmet(helmet);
p.getInventory().setChestplate(peche);
p.getInventory().setLeggings(panta);
p.getInventory().setBoots(boots);
if (PlayerStat.getPlayerStat(p).getHotbar() == null) {
final ItemStack[] items = plugin.getGM().getKit().getContents();
for (int slot = 0; slot < 35; slot++) {
final ItemStack item = items[slot];
if (item == null || item.getType() == Material.BARRIER) {
p.getInventory().setItem(slot, new ItemStack(Material.AIR));
continue;
}
if (item.getType().equals(Material.STAINED_CLAY)) {
final ItemStack item2 = new ItemStack(item.getType(), item.getAmount(), getColor(team.getFColor()));
p.getInventory().setItem(slot, item2);
continue;
}
p.getInventory().setItem(slot, item);
}
} else {
final ItemStack[] items = PlayerStat.getPlayerStat(p).getHotbar();
for (int slot = 0; slot < 35; slot++) {
final ItemStack item = items[slot];
if (item == null || item.getType() == Material.BARRIER) {
p.getInventory().setItem(slot, new ItemStack(Material.AIR));
continue;
}
if (item.getType().equals(Material.STAINED_CLAY)) {
final ItemStack item2 = new ItemStack(item.getType(), item.getAmount(), getColor(team.getFColor()));
p.getInventory().setItem(slot, item2);
continue;
}
p.getInventory().setItem(slot, item);
}
}
}
public void givePlayerItems(Player p) {
if (teamSize > 1) {
final ItemStack team = ItemBuilder.item(Material.PAPER, 1, (short) 0,
plugin.getLang().get("items.teams.nameItem"), plugin.getLang().get("items.teams.loreItem"));
p.getInventory().setItem(0, team);
}
final ItemStack leave = ItemBuilder.item(Material.BED, 1, (short) 0,
plugin.getLang().get("items.leave.nameItem"),
plugin.getLang().get("items.leave.loreItem"));
p.getInventory().setItem(8, leave);
}
public byte getColor(Color color) {
if (color.equals(Color.RED))
return 14;
if (color.equals(Color.BLUE))
return 11;
return 0;
}
public int getTeamSize() {
return teamSize;
}
public void addPlace(Location loc) {
placed.add(loc);
}
public ArrayList<Location> getPlaced() {
return placed;
}
public int getStarting() {
return starting;
}
public Location getLobby() {
return lobby;
}
public Location getSpect() {
return spect;
}
public HashMap<Player, PlayerData> getPD() {
return pd;
}
}

944
MultiArena-TheBridge/src/cx/sfy/TheBridge/game/GameFour.java

@ -0,0 +1,944 @@
package cx.sfy.TheBridge.game;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.database.PlayerStat;
import cx.sfy.TheBridge.hologram.TruenoHologram;
import cx.sfy.TheBridge.hologram.TruenoHologramAPI;
import cx.sfy.TheBridge.team.TeamFour;
import cx.sfy.TheBridge.utils.CenterMessage;
import cx.sfy.TheBridge.utils.ItemBuilder;
import cx.sfy.TheBridge.utils.Utils;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;
public class GameFour {
private Main plugin;
private HashMap<ChatColor, TeamFour> teams;
private HashMap<Player, ChatColor> teamPlayer;
private ArrayList<Player> players;
private ArrayList<Player> spects;
private HashMap<Player, PlayerData> pd = new HashMap<Player, PlayerData>();
private HashMap<Player, Integer> goals = new HashMap<Player, Integer>();
private HashMap<Player, Integer> kills = new HashMap<Player, Integer>();
private ArrayList<Location> build = new ArrayList<Location>();
private ArrayList<Location> placed = new ArrayList<Location>();
private ArrayList<TruenoHologram> holograms = new ArrayList<TruenoHologram>();
private Location lobby;
private Location spect;
private String name;
private String mode;
private int min;
private int max;
private int teamSize;
private int starting;
private int prestart;
private BukkitTask start;
private FState state;
public GameFour(Main plugin, String name, int min, int max, int teamSize, int starting, int prestart,
Location lobby, Location spect, Location buildMin, Location buildMax, Location spawnRed, Location spawnBlue,
Location spawnGreen, Location spawnYellow, Location respawnRed, Location respawnBlue, Location respawnGreen,
Location respawnYellow, ArrayList<Location> portalRed, ArrayList<Location> portalBlue,
ArrayList<Location> portalGreen, ArrayList<Location> portalYellow, Location hRed, Location hBlue,
Location hGreen, Location hYellow) {
this.plugin = plugin;
this.name = name;
this.starting = starting;
this.prestart = prestart;
this.mode = teamSize + "v" + teamSize + "v" + teamSize + "v" + teamSize;
this.max = max;
this.min = min;
this.lobby = lobby;
this.spect = spect;
this.teamSize = teamSize;
this.teamPlayer = new HashMap<>();
this.teams = new HashMap<>();
this.players = new ArrayList<>();
this.spects = new ArrayList<>();
int gn = Math.min(buildMin.getBlockX(), buildMax.getBlockX());
int gn2 = Math.max(buildMin.getBlockX(), buildMax.getBlockX());
int gn3 = Math.min(buildMin.getBlockZ(), buildMax.getBlockZ());
int gn4 = Math.max(buildMin.getBlockZ(), buildMax.getBlockZ());
int gn5 = Math.min(buildMin.getBlockY(), buildMax.getBlockY());
int gn6 = Math.max(buildMin.getBlockY(), buildMax.getBlockY());
for (int i = gn; i <= gn2; ++i) {
for (int j = gn5; j <= gn6; ++j) {
for (int k = gn3; k <= gn4; ++k) {
Location location3 = new Location(buildMin.getWorld(), (double) i, (double) j, (double) k);
build.add(location3);
}
}
}
this.teams.put(ChatColor.BLUE, new TeamFour(this, ChatColor.BLUE, Color.BLUE,
plugin.getConfig().getString("names.blue"), spawnBlue, respawnBlue, portalBlue, hBlue));
this.teams.put(ChatColor.RED, new TeamFour(this, ChatColor.RED, Color.RED,
plugin.getConfig().getString("names.red"), spawnRed, respawnRed, portalRed, hRed));
this.teams.put(ChatColor.GREEN, new TeamFour(this, ChatColor.GREEN, Color.GREEN,
plugin.getConfig().getString("names.green"), spawnGreen, respawnGreen, portalGreen, hGreen));
this.teams.put(ChatColor.YELLOW, new TeamFour(this, ChatColor.YELLOW, Color.YELLOW,
plugin.getConfig().getString("names.yellow"), spawnYellow, respawnYellow, portalYellow, hYellow));
setState(FState.WAITING);
updateSign();
}
public void checkCancel() {
if (isState(FState.STARTING) && players.size() <= getMin()) {
if (start != null) {
start.cancel();
}
setState(FState.WAITING);
starting = 30;
updateSign();
for (Player on : players) {
updateSB(on);
}
}
}
public void updateSB(Player p) {
plugin.getSB().update(p);
}
public void updateSign() {
plugin.getSIM().updateGameFourSign(this);
}
public String getMode() {
return mode;
}
public boolean checkWin(TeamFour win, TeamFour death, Player e) {
if (getTeamsAlive() <= 1 && !isState(FState.FINISH)) {
setState(FState.FINISH);
updateSign();
DecimalFormat df = new DecimalFormat("#.##");
for (Player w : win.getTeamPlayers()) {
PlayerStat.getPlayerStat(w).addFourWins();
}
for (Player p : players) {
plugin.getNMS().sendTitle(p, 0, 60, 0,
plugin.getLang().get("titles.winFour.title").replaceAll("<life>", win.getLifeString())
.replaceAll("<team>", win.getTeamName()).replaceAll("<color>", win.getColor() + ""),
plugin.getLang().get("titles.winFour.subtitle").replaceAll("<life>", win.getLifeString())
.replaceAll("<team>", win.getTeamName()).replaceAll("<color>", win.getColor() + ""));
for (String msg : plugin.getLang().getList("messages.winFour")) {
CenterMessage.sendCenteredMessage(p, msg.replaceAll("&", "§").replaceAll("<player>", e.getName())
.replaceAll("<health>", df.format(e.getHealth())).replaceAll("<team>", win.getTeamName())
.replaceAll("<goals>", String.valueOf(goals.get(e)))
.replaceAll("<es>", (goals.get(e) > 1) ? "es" : "")
.replaceAll("<red>", teams.get(ChatColor.RED).getTeamName())
.replaceAll("<redLife>", teams.get(ChatColor.RED).getLifeString())
.replaceAll("<blue>", teams.get(ChatColor.BLUE).getTeamName())
.replaceAll("<blueLife>", teams.get(ChatColor.BLUE).getLifeString())
.replaceAll("<yellow>", teams.get(ChatColor.YELLOW).getTeamName())
.replaceAll("<yellowLife>", teams.get(ChatColor.YELLOW).getLifeString())
.replaceAll("<green>", teams.get(ChatColor.GREEN).getTeamName()).replaceAll("<heart>", "❤")
.replaceAll("<greenLife>", teams.get(ChatColor.GREEN).getLifeString())
.replaceAll("<teamStole>", (death.getTeamName() == null) ? "Stole" : death.getTeamName())
.replaceAll("<color>",
(win.getColor() == null) ? ChatColor.WHITE + "" : win.getColor() + ""));
}
}
new BukkitRunnable() {
@Override
public void run() {
for (TruenoHologram th : holograms) {
th.delete();
}
for (Player p : spect.getWorld().getPlayers()) {
if (pd.containsKey(p)) {
for (Player on : Bukkit.getOnlinePlayers()) {
on.showPlayer(p);
p.showPlayer(on);
}
plugin.getGM().removePlayerFourGames(p);
} else {
p.teleport(plugin.getMainLobby());
}
}
}
}.runTaskLater(plugin, 20 * 10);
new BukkitRunnable() {
@Override
public void run() {
plugin.getGM().resetFourGame(getName());
}
}.runTaskLater(plugin, 20 * 12);
return true;
}
return false;
}
public void celebrateGoal(TeamFour team, TeamFour death, Player e) {
DecimalFormat df = new DecimalFormat("#.##");
addGoal(e);
PlayerStat.getPlayerStat(e).addFourGoals();
firework(getSpect(), team.getFColor());
e.teleport(team.getTeamRespawn());
if (getTeamsAlive() == 2) {
death.removeLife(1);
if (death.getLife() == 0) {
death.killTeam();
if (checkWin(team, death, e)) {
return;
}
for (Player p : players) {
plugin.getNMS().sendTitle(p, 0, 20, 0,
plugin.getLang().get("titles.goalFinal.title").replaceAll("<player>", e.getName())
.replaceAll("<heart>", "❤").replaceAll("<teamOther>", team.getTeamName())
.replaceAll("<teamStole>", death.getTeamName())
.replaceAll("<color>", team.getColor() + ""),
plugin.getLang().get("titles.goalFinal.subtitle").replaceAll("<player>", e.getName())
.replaceAll("<heart>", "❤").replaceAll("<teamOther>", team.getTeamName())
.replaceAll("<teamStole>", death.getTeamName())
.replaceAll("<color>", team.getColor() + ""));
}
} else {
for (Player p : players) {
plugin.getNMS().sendTitle(p, 0, 20, 0,
plugin.getLang().get("titles.goalNormal.title").replaceAll("<player>", e.getName())
.replaceAll("<heart>", "❤").replaceAll("<teamOther>", team.getTeamName())
.replaceAll("<teamStole>", death.getTeamName())
.replaceAll("<color>", team.getColor() + ""),
plugin.getLang().get("titles.goalNormal.subtitle").replaceAll("<player>", e.getName())
.replaceAll("<heart>", "�").replaceAll("<teamOther>", team.getTeamName())
.replaceAll("<teamStole>", death.getTeamName())
.replaceAll("<color>", team.getColor() + ""));
}
}
for (Player p : players) {
updateSB(p);
for (String msg : plugin.getLang().getList("messages.final")) {
CenterMessage.sendCenteredMessage(p,
msg.replaceAll("&", "§").replaceAll("<teamStole>", death.getTeamName())
.replaceAll("<goals>", String.valueOf(goals.get(e)))
.replaceAll("<es>", (goals.get(e) > 1) ? "es" : "")
.replaceAll("<teamOther>", team.getTeamName())
.replaceAll("<color>", "" + team.getColor()).replaceAll("<player>", e.getName())
.replaceAll("<health>", df.format(e.getHealth()))
.replaceAll("<team>", team.getTeamName())
.replaceAll("<red>", teams.get(ChatColor.RED).getTeamName())
.replaceAll("<redLife>", teams.get(ChatColor.RED).getLifeString())
.replaceAll("<blue>", teams.get(ChatColor.BLUE).getTeamName())
.replaceAll("<blueLife>", teams.get(ChatColor.BLUE).getLifeString())
.replaceAll("<yellow>", teams.get(ChatColor.YELLOW).getTeamName())
.replaceAll("<yellowLife>", teams.get(ChatColor.YELLOW).getLifeString())
.replaceAll("<green>", teams.get(ChatColor.GREEN).getTeamName())
.replaceAll("<greenLife>", teams.get(ChatColor.GREEN).getLifeString())
.replaceAll("<heart>", "❤"));
}
}
} else {
team.addLife(1);
death.removeLife(1);
if (death.getLife() == 0) {
death.killTeam();
if (checkWin(team, death, e)) {
return;
}
for (Player p : players) {
plugin.getNMS().sendTitle(p, 0, 20, 0,
plugin.getLang().get("titles.goalFinal.title").replaceAll("<player>", e.getName())
.replaceAll("<heart>", "❤").replaceAll("<teamOther>", team.getTeamName())
.replaceAll("<teamStole>", death.getTeamName())
.replaceAll("<color>", team.getColor() + ""),
plugin.getLang().get("titles.goalFinal.subtitle").replaceAll("<player>", e.getName())
.replaceAll("<heart>", "❤").replaceAll("<teamOther>", team.getTeamName())
.replaceAll("<teamStole>", death.getTeamName())
.replaceAll("<color>", team.getColor() + ""));
}
} else {
for (Player p : players) {
plugin.getNMS().sendTitle(p, 0, 20, 0,
plugin.getLang().get("titles.goalNormal.title").replaceAll("<player>", e.getName())
.replaceAll("<heart>", "❤").replaceAll("<teamOther>", team.getTeamName())
.replaceAll("<teamStole>", death.getTeamName())
.replaceAll("<color>", team.getColor() + ""),
plugin.getLang().get("titles.goalNormal.subtitle").replaceAll("<player>", e.getName())
.replaceAll("<heart>", "❤").replaceAll("<teamOther>", team.getTeamName())
.replaceAll("<teamStole>", death.getTeamName())
.replaceAll("<color>", team.getColor() + ""));
}
}
for (Player p : players) {
updateSB(p);
for (String msg : plugin.getLang().getList("messages.stole")) {
CenterMessage.sendCenteredMessage(p,
msg.replaceAll("&", "§").replaceAll("<teamStole>", death.getTeamName())
.replaceAll("<goals>", String.valueOf(goals.get(e)))
.replaceAll("<es>", (goals.get(e) > 1) ? "es" : "")
.replaceAll("<color>", "" + team.getColor())
.replaceAll("<teamOther>", team.getTeamName()).replaceAll("<player>", e.getName())
.replaceAll("<health>", df.format(e.getHealth()))
.replaceAll("<red>", teams.get(ChatColor.RED).getTeamName())
.replaceAll("<redLife>", teams.get(ChatColor.RED).getLifeString())
.replaceAll("<blue>", teams.get(ChatColor.BLUE).getTeamName())
.replaceAll("<blueLife>", teams.get(ChatColor.BLUE).getLifeString())
.replaceAll("<yellow>", teams.get(ChatColor.YELLOW).getTeamName())
.replaceAll("<yellowLife>", teams.get(ChatColor.YELLOW).getLifeString())
.replaceAll("<green>", teams.get(ChatColor.GREEN).getTeamName())
.replaceAll("<greenLife>", teams.get(ChatColor.GREEN).getLifeString())
.replaceAll("<heart>", "❤"));
}
}
}
}
public void firework(Location loc, Color c1) {
Firework fa = (Firework) loc.getWorld().spawn(
loc.clone().add(new Random().nextInt(5) + 1, new Random().nextInt(1) + 1, new Random().nextInt(5) + 1),
Firework.class);
FireworkMeta fam = fa.getFireworkMeta();
FireworkEffect.Type tipo = FireworkEffect.Type.STAR;
Color c2 = Color.WHITE;
FireworkEffect ef = FireworkEffect.builder().withColor(c1).withFade(c2).with(tipo).build();
fam.addEffect(ef);
fam.setPower(0);
fa.setFireworkMeta(fam);
new BukkitRunnable() {
@Override
public void run() {
Firework fa = (Firework) loc.getWorld().spawn(loc.clone().add(new Random().nextInt(5) + 1,
new Random().nextInt(1) + 1, new Random().nextInt(5) + 1), Firework.class);
FireworkMeta fam = fa.getFireworkMeta();
FireworkEffect.Type tipo = FireworkEffect.Type.STAR;
Color c2 = Color.WHITE;
FireworkEffect ef = FireworkEffect.builder().withColor(c1).withFade(c2).with(tipo).build();
fam.addEffect(ef);
fam.setPower(0);
fa.setFireworkMeta(fam);
}
}.runTaskLater(plugin, 2);
}
public void addPlayer(Player p) {
pd.put(p, new PlayerData(p));
Utils.setCleanPlayer(p);
players.add(p);
kills.put(p, 0);
goals.put(p, 0);
p.teleport(getLobby());
if (isState(FState.WAITING) || isState(FState.STARTING)) {
new BukkitRunnable() {
@Override
public void run() {
givePlayerItems(p);
}
}.runTaskLater(plugin, 20);
for (Player on : players) {
on.sendMessage(plugin.getLang().get("messages.join").replaceAll("<player>", p.getName())
.replaceAll("<players>", String.valueOf(players.size()))
.replaceAll("<max>", String.valueOf(getMax())));
on.playSound(on.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.join")), 1.0f, 1.0f);
updateSB(on);
}
}
updateSign();
}
public void removePlayer(Player p) {
Utils.setCleanPlayer(p);
pd.get(p).restore();
removeAllPlayerTeam(p);
players.remove(p);
if (isState(FState.WAITING) || isState(FState.STARTING)) {
for (Player on : players) {
on.sendMessage(plugin.getLang().get("messages.quit").replaceAll("<player>", p.getName())
.replaceAll("<players>", String.valueOf(players.size()))
.replaceAll("<max>", String.valueOf(getMax())));
on.playSound(on.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.quit")), 1.0f, 1.0f);
updateSB(on);
}
} else {
if (getTeamsAlive() == 1) {
checkWin(getLastTeam(), getTeamPlayer(p), getLastTeam().getTeamPlayers().get(0));
}
}
updateSign();
checkCancel();
}
public void updateGame() {
if (isState(FState.WAITING) && players.size() >= getMin()) {
setState(FState.STARTING);
updateSign();
for (Player p : players) {
p.setGameMode(GameMode.ADVENTURE);
}
}
if (isState(FState.STARTING)) {
for (Player p : players) {
updateSB(p);
}
if (starting == 240 || starting == 180 || starting == 120) {
for (Player p : players) {
p.sendMessage(plugin.getLang().get(p, "messages.starting")
.replaceAll("<time>", String.valueOf(starting / 60))
.replaceAll("<units>", plugin.getLang().get(p, "units.minutes")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.starting")), 1.0f,
1.0f);
plugin.getTM().sendStartTitle(p, starting, true);
}
}
if (starting == 60) {
for (Player p : players) {
p.sendMessage(plugin.getLang().get(p, "messages.starting")
.replaceAll("<time>", String.valueOf(starting / 60))
.replaceAll("<units>", plugin.getLang().get(p, "units.minute")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.starting")), 1.0f,
1.0f);
plugin.getTM().sendStartTitle(p, starting, true);
}
}
if (starting == 30 || starting == 15 || starting == 10 || starting == 5 || starting == 4 || starting == 3
|| starting == 2) {
for (Player p : players) {
p.sendMessage(
plugin.getLang().get(p, "messages.starting").replaceAll("<time>", String.valueOf(starting))
.replaceAll("<units>", plugin.getLang().get(p, "units.seconds")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.starting")), 1.0f,
1.0f);
plugin.getTM().sendStartTitle(p, starting, true);
}
}
if (starting == 1) {
setState(FState.PREGAME);
updateSign();
for (Player p : players) {
p.sendMessage(
plugin.getLang().get(p, "messages.starting").replaceAll("<time>", String.valueOf(starting))
.replaceAll("<units>", plugin.getLang().get(p, "units.second")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.starting")), 1.0f,
1.0f);
p.getInventory().clear();
p.getOpenInventory().close();
plugin.getTM().sendStartTitle(p, starting, false);
if (getTeamPlayer(p) == null) {
addRandomTeam(p);
}
}
if (plugin.isCage()) {
for (TeamFour team : teams.values()) {
if (!team.isCage()) {
if (team.getTeamPlayers().size() > 0 && team.getTeamPlayers().get(0) != null) {
team.createCage(plugin.getCM().getCageByName(
PlayerStat.getPlayerStat(team.getTeamPlayers().get(0)).getCage()));
team.setCage(true);
} else {
team.createCage(
plugin.getCM().getCageByName(plugin.getConfig().getString("defaultCage")));
team.setCage(true);
}
}
}
} else {
for (ChatColor color : teams.keySet()) {
plugin.getGLM().createCage(teams.get(color).getTeamSpawn(), color);
}
}
for (Player p : players) {
p.teleport(getTeamPlayer(p).getTeamSpawn().clone().add(0, 1, 0));
giveKit(p, getTeamPlayer(p));
}
Location hRed = teams.get(ChatColor.RED).getHologram();
Location hBlue = teams.get(ChatColor.BLUE).getHologram();
Location hGreen = teams.get(ChatColor.GREEN).getHologram();
Location hYellow = teams.get(ChatColor.YELLOW).getHologram();
if (hRed != null && hBlue != null && hGreen != null && hYellow != null) {
for (Player p : teams.get(ChatColor.RED).getTeamPlayers()) {
ArrayList<String> pRed = new ArrayList<String>();
TruenoHologram phRed = TruenoHologramAPI.getNewHologram();
for (String portal : plugin.getLang().getList("holograms.portal.you")) {
pRed.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.RED)
.replaceAll("<team>", plugin.getLang().get("holograms.your")));
}
ArrayList<String> pBlue = new ArrayList<String>();
TruenoHologram phBlue = TruenoHologramAPI.getNewHologram();
for (String portal : plugin.getLang().getList("holograms.portal.enemy")) {
pBlue.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.BLUE)
.replaceAll("<team>", teams.get(ChatColor.BLUE).getTeamName()));
}
ArrayList<String> pGreen = new ArrayList<String>();
TruenoHologram phGreen = TruenoHologramAPI.getNewHologram();
for (String portal : plugin.getLang().getList("holograms.portal.enemy")) {
pGreen.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.GREEN)
.replaceAll("<team>", teams.get(ChatColor.GREEN).getTeamName()));
}
ArrayList<String> pYellow = new ArrayList<String>();
TruenoHologram phYellow = TruenoHologramAPI.getNewHologram();
for (String portal : plugin.getLang().getList("holograms.portal.enemy")) {
pYellow.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.YELLOW)
.replaceAll("<team>", teams.get(ChatColor.YELLOW).getTeamName()));
}
phBlue.setupPlayerHologram(p, hBlue, pBlue);
phBlue.display();
phRed.setupPlayerHologram(p, hRed, pRed);
phRed.display();
phGreen.setupPlayerHologram(p, hGreen, pGreen);
phGreen.display();
phYellow.setupPlayerHologram(p, hYellow, pYellow);
phYellow.display();
holograms.add(phRed);
holograms.add(phBlue);
holograms.add(phGreen);
holograms.add(phYellow);
}
for (Player p : teams.get(ChatColor.BLUE).getTeamPlayers()) {
ArrayList<String> pRed = new ArrayList<String>();
TruenoHologram phRed = TruenoHologramAPI.getNewHologram();
for (String portal : plugin.getLang().getList("holograms.portal.enemy")) {
pRed.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.RED)
.replaceAll("<team>", teams.get(ChatColor.RED).getTeamName()));
}
ArrayList<String> pBlue = new ArrayList<String>();
TruenoHologram phBlue = TruenoHologramAPI.getNewHologram();
for (String portal : plugin.getLang().getList("holograms.portal.you")) {
pBlue.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.BLUE)
.replaceAll("<team>", plugin.getLang().get("holograms.your")));
}
ArrayList<String> pGreen = new ArrayList<String>();
TruenoHologram phGreen = TruenoHologramAPI.getNewHologram();
for (String portal : plugin.getLang().getList("holograms.portal.enemy")) {
pGreen.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.GREEN)
.replaceAll("<team>", teams.get(ChatColor.GREEN).getTeamName()));
}
ArrayList<String> pYellow = new ArrayList<String>();
TruenoHologram phYellow = TruenoHologramAPI.getNewHologram();
for (String portal : plugin.getLang().getList("holograms.portal.enemy")) {
pYellow.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.YELLOW)
.replaceAll("<team>", teams.get(ChatColor.YELLOW).getTeamName()));
}
phBlue.setupPlayerHologram(p, hBlue, pBlue);
phBlue.display();
phRed.setupPlayerHologram(p, hRed, pRed);
phRed.display();
phGreen.setupPlayerHologram(p, hGreen, pGreen);
phGreen.display();
phYellow.setupPlayerHologram(p, hYellow, pYellow);
phYellow.display();
holograms.add(phRed);
holograms.add(phBlue);
holograms.add(phGreen);
holograms.add(phYellow);
}
for (Player p : teams.get(ChatColor.GREEN).getTeamPlayers()) {
ArrayList<String> pRed = new ArrayList<String>();
TruenoHologram phRed = TruenoHologramAPI.getNewHologram();
for (String portal : plugin.getLang().getList("holograms.portal.enemy")) {
pRed.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.RED)
.replaceAll("<team>", teams.get(ChatColor.RED).getTeamName()));
}
ArrayList<String> pBlue = new ArrayList<String>();
TruenoHologram phBlue = TruenoHologramAPI.getNewHologram();
for (String portal : plugin.getLang().getList("holograms.portal.enemy")) {
pBlue.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.BLUE)
.replaceAll("<team>", teams.get(ChatColor.BLUE).getTeamName()));
}
ArrayList<String> pGreen = new ArrayList<String>();
TruenoHologram phGreen = TruenoHologramAPI.getNewHologram();
for (String portal : plugin.getLang().getList("holograms.portal.you")) {
pGreen.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.GREEN)
.replaceAll("<team>", plugin.getLang().get("holograms.your")));
}
ArrayList<String> pYellow = new ArrayList<String>();
TruenoHologram phYellow = TruenoHologramAPI.getNewHologram();
for (String portal : plugin.getLang().getList("holograms.portal.enemy")) {
pYellow.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.YELLOW)
.replaceAll("<team>", teams.get(ChatColor.YELLOW).getTeamName()));
}
phBlue.setupPlayerHologram(p, hBlue, pBlue);
phBlue.display();
phRed.setupPlayerHologram(p, hRed, pRed);
phRed.display();
phGreen.setupPlayerHologram(p, hGreen, pGreen);
phGreen.display();
phYellow.setupPlayerHologram(p, hYellow, pYellow);
phYellow.display();
holograms.add(phRed);
holograms.add(phBlue);
holograms.add(phGreen);
holograms.add(phYellow);
}
for (Player p : teams.get(ChatColor.YELLOW).getTeamPlayers()) {
ArrayList<String> pRed = new ArrayList<String>();
TruenoHologram phRed = TruenoHologramAPI.getNewHologram();
for (String portal : plugin.getLang().getList("holograms.portal.enemy")) {
pRed.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.RED)
.replaceAll("<team>", teams.get(ChatColor.RED).getTeamName()));
}
ArrayList<String> pBlue = new ArrayList<String>();
TruenoHologram phBlue = TruenoHologramAPI.getNewHologram();
for (String portal : plugin.getLang().getList("holograms.portal.enemy")) {
pBlue.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.BLUE)
.replaceAll("<team>", teams.get(ChatColor.BLUE).getTeamName()));
}
ArrayList<String> pGreen = new ArrayList<String>();
TruenoHologram phGreen = TruenoHologramAPI.getNewHologram();
for (String portal : plugin.getLang().getList("holograms.portal.enemy")) {
pGreen.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.GREEN)
.replaceAll("<team>", teams.get(ChatColor.GREEN).getTeamName()));
}
ArrayList<String> pYellow = new ArrayList<String>();
TruenoHologram phYellow = TruenoHologramAPI.getNewHologram();
for (String portal : plugin.getLang().getList("holograms.portal.you")) {
pYellow.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.YELLOW)
.replaceAll("<team>", plugin.getLang().get("holograms.your")));
}
phBlue.setupPlayerHologram(p, hBlue, pBlue);
phBlue.display();
phRed.setupPlayerHologram(p, hRed, pRed);
phRed.display();
phGreen.setupPlayerHologram(p, hGreen, pGreen);
phGreen.display();
phYellow.setupPlayerHologram(p, hYellow, pYellow);
phYellow.display();
holograms.add(phRed);
holograms.add(phBlue);
holograms.add(phGreen);
holograms.add(phYellow);
}
}
teams.get(ChatColor.RED).createPortal();
teams.get(ChatColor.BLUE).createPortal();
teams.get(ChatColor.YELLOW).createPortal();
teams.get(ChatColor.GREEN).createPortal();
}
starting--;
}
if (isState(FState.PREGAME)) {
for (Player p : players) {
updateSB(p);
}
if (prestart == 10 || prestart == 5 || prestart == 4 || prestart == 3 || prestart == 2) {
for (Player p : players) {
p.sendMessage(
plugin.getLang().get(p, "messages.prestart").replaceAll("<time>", String.valueOf(prestart))
.replaceAll("<units>", plugin.getLang().get(p, "units.seconds")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.prestart")), 1.0f,
1.0f);
plugin.getTM().sendPreTitle(p, prestart, true);
}
}
if (prestart == 1) {
for (Player p : players) {
p.sendMessage(
plugin.getLang().get(p, "messages.prestart").replaceAll("<time>", String.valueOf(prestart))
.replaceAll("<units>", plugin.getLang().get(p, "units.second")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.prestart")), 1.0f,
1.0f);
plugin.getTM().sendPreTitle(p, prestart, false);
for (String msg : plugin.getLang().getList("messages.startFour")) {
CenterMessage.sendCenteredMessage(p, msg.replaceAll("&", "§").replaceAll("<heart>", "❤"));
}
}
}
if (prestart == 0) {
setState(FState.INGAME);
updateSign();
for (Player p : players) {
p.setGameMode(GameMode.SURVIVAL);
}
if (plugin.isCage()) {
for (TeamFour team : teams.values()) {
if (team.isCage()) {
team.removeCage();
team.setCage(false);
}
}
} else {
for (ChatColor color : teams.keySet()) {
plugin.getGLM().removeGlass(teams.get(color).getTeamSpawn());
}
}
}
prestart--;
}
}
public void addPlayerTeam(Player p, TeamFour t) {
t.addPlayer(p);
teamPlayer.put(p, t.getColor());
}
public void addRandomTeam(Player p) {
TeamFour red = teams.get(ChatColor.RED);
TeamFour blue = teams.get(ChatColor.BLUE);
TeamFour green = teams.get(ChatColor.GREEN);
TeamFour yellow = teams.get(ChatColor.YELLOW);
if (red.getTeamSize() <= blue.getTeamSize() && red.getTeamSize() <= green.getTeamSize()
&& red.getTeamSize() <= yellow.getTeamSize()) {
red.addPlayer(p);
teamPlayer.put(p, red.getColor());
} else if (blue.getTeamSize() <= red.getTeamSize() && blue.getTeamSize() <= green.getTeamSize()
&& blue.getTeamSize() <= yellow.getTeamSize()) {
blue.addPlayer(p);
teamPlayer.put(p, blue.getColor());
} else if (green.getTeamSize() <= red.getTeamSize() && green.getTeamSize() <= blue.getTeamSize()
&& green.getTeamSize() <= yellow.getTeamSize()) {
green.addPlayer(p);
teamPlayer.put(p, green.getColor());
} else {
yellow.addPlayer(p);
teamPlayer.put(p, yellow.getColor());
}
}
public TeamFour getTeamPlayer(Player p) {
return teams.get(teamPlayer.get(p));
}
public HashMap<ChatColor, TeamFour> getTeams() {
return teams;
}
public Location getLobby() {
return lobby;
}
public Location getSpect() {
return spect;
}
public String getName() {
return name;
}
public int getMax() {
return max;
}
public int getMin() {
return min;
}
public Main get() {
return plugin;
}
public FState getState() {
return this.state;
}
public void setState(FState state) {
this.state = state;
}
public boolean isState(FState state) {
if (this.state == state) {
return true;
}
return false;
}
public int getGoals(Player p) {
return goals.get(p);
}
public int getKills(Player p) {
return kills.get(p);
}
public void addGoal(Player p) {
goals.put(p, goals.get(p) + 1);
updateSB(p);
}
public void addKill(Player p) {
kills.put(p, kills.get(p) + 1);
updateSB(p);
}
public enum FState {
WAITING, STARTING, PREGAME, INGAME, FINISH, RESTARTING;
}
public int getTeamsAlive() {
int cantidad = 0;
for (TeamFour team : teams.values()) {
if (team.getTeamSize() == 0) {
team.setDeath(true);
continue;
}
if (!team.getDeath() || team.getTeamSize() > 0) {
cantidad++;
}
}
return cantidad;
}
public TeamFour getLastTeam() {
for (TeamFour team : teams.values()) {
if (team.getTeamSize() > 0) {
return team;
}
}
return null;
}
public void removeAllPlayerTeam(Player p) {
for (TeamFour t : teams.values()) {
if (t.getTeamPlayers().contains(p)) {
t.removePlayer(p);
}
}
}
public ArrayList<Player> getPlayers() {
return players;
}
public ArrayList<Player> getSpects() {
return spects;
}
public void setSpect(Player p) {
Utils.setCleanPlayer(p);
removeAllPlayerTeam(p);
spects.add(p);
for (Player on : players) {
on.hidePlayer(p);
}
for (Player on : spects) {
on.hidePlayer(p);
}
new BukkitRunnable() {
@Override
public void run() {
giveSpectItems(p);
}
}.runTaskLater(plugin, 5);
}
public void giveSpectItems(Player p) {
ItemStack team = ItemBuilder.item(Material.COMPASS, 1, (short) 0,
plugin.getLang().get("items.spectate.nameItem"), plugin.getLang().get("items.spectate.loreItem"));
ItemStack option = ItemBuilder.item(Material.REDSTONE_COMPARATOR, 1, (short) 0,
plugin.getLang().get("items.config.nameItem"), plugin.getLang().get("items.config.loreItem"));
ItemStack leave = ItemBuilder.item(Material.BED, 1, (short) 0, plugin.getLang().get("items.leave.nameItem"),
plugin.getLang().get("items.leave.loreItem"));
p.getInventory().setItem(0, team);
p.getInventory().setItem(4, option);
p.getInventory().setItem(8, leave);
}
public void givePlayerItems(Player p) {
ItemStack team = ItemBuilder.item(Material.PAPER, 1, (short) 0, plugin.getLang().get("items.teams.nameItem"),
plugin.getLang().get("items.teams.loreItem"));
ItemStack leave = ItemBuilder.item(Material.BED, 1, (short) 0, plugin.getLang().get("items.leave.nameItem"),
plugin.getLang().get("items.leave.loreItem"));
p.getInventory().setItem(0, team);
p.getInventory().setItem(8, leave);
}
public void giveKit(Player p, TeamFour team) {
ItemStack peche = new ItemStack(Material.LEATHER_CHESTPLATE, 1);
LeatherArmorMeta pecheM = (LeatherArmorMeta) peche.getItemMeta();
pecheM.setColor(team.getFColor());
peche.setItemMeta(pecheM);
ItemStack panta = new ItemStack(Material.LEATHER_LEGGINGS, 1);
LeatherArmorMeta pantaM = (LeatherArmorMeta) panta.getItemMeta();
pantaM.setColor(team.getFColor());
panta.setItemMeta(pantaM);
ItemStack boots = new ItemStack(Material.LEATHER_BOOTS, 1);
LeatherArmorMeta bootsM = (LeatherArmorMeta) boots.getItemMeta();
bootsM.setColor(team.getFColor());
boots.setItemMeta(bootsM);
p.getInventory().setChestplate(peche);
p.getInventory().setLeggings(panta);
p.getInventory().setBoots(boots);
if (PlayerStat.getPlayerStat(p).getHotbar() == null) {
ItemStack[] items = plugin.getGM().getKit().getContents();
for (int slot = 0; slot < 35; slot++) {
ItemStack item = items[slot];
if (item == null || item.getType() == Material.BARRIER) {
p.getInventory().setItem(slot, new ItemStack(Material.AIR));
continue;
}
if (item.getType().equals(Material.STAINED_CLAY)) {
ItemStack item2 = new ItemStack(item.getType(), item.getAmount(), getColor(team.getFColor()));
p.getInventory().setItem(slot, item2);
continue;
}
p.getInventory().setItem(slot, item);
}
} else {
ItemStack[] items = PlayerStat.getPlayerStat(p).getHotbar();
for (int slot = 0; slot < 35; slot++) {
ItemStack item = items[slot];
if (item == null || item.getType() == Material.BARRIER) {
p.getInventory().setItem(slot, new ItemStack(Material.AIR));
continue;
}
if (item.getType().equals(Material.STAINED_CLAY)) {
ItemStack item2 = new ItemStack(item.getType(), item.getAmount(), getColor(team.getFColor()));
p.getInventory().setItem(slot, item2);
continue;
}
p.getInventory().setItem(slot, item);
}
}
}
public void addPlace(Location loc) {
placed.add(loc);
}
public ArrayList<Location> getPlaced() {
return placed;
}
public byte getColor(Color color) {
if (color.equals(Color.RED)) {
return 14;
}
if (color.equals(Color.BLUE)) {
return 11;
}
if (color.equals(Color.YELLOW)) {
return 4;
}
if (color.equals(Color.GREEN)) {
return 5;
}
return 0;
}
public int getTeamSize() {
return teamSize;
}
public ArrayList<Location> getBuild() {
return build;
}
public int getStarting() {
return starting;
}
public HashMap<Player, PlayerData> getPD() {
return pd;
}
}

83
MultiArena-TheBridge/src/cx/sfy/TheBridge/game/InventoryData.java

@ -0,0 +1,83 @@
package cx.sfy.TheBridge.game;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import cx.sfy.TheBridge.Main;
public class InventoryData {
private static HashMap<Player, InventoryData> inventoryData = new HashMap<Player, InventoryData>();
private UUID uuid;
private Inventory inv;
private ItemStack[] armor;
private boolean restored;
public InventoryData(Player p) {
this.uuid = p.getUniqueId();
this.armor = p.getInventory().getArmorContents();
this.restored = false;
this.inv = Bukkit.createInventory(null, InventoryType.PLAYER, p.getName());
this.inv.setContents(p.getInventory().getContents());
inventoryData.put(p, this);
p.getInventory().clear();
p.getInventory().setArmorContents(null);
}
public void restore() {
if (!restored) {
Player p = this.getPlayer();
if (p == null) {
return;
}
if (Main.get().isStop()) {
p.getInventory().setContents(inv.getContents());
p.getInventory().setArmorContents(armor);
p.updateInventory();
return;
}
p.getInventory().clear();
p.getInventory().setArmorContents(null);
restored = true;
new BukkitRunnable() {
@Override
public void run() {
p.getInventory().setContents(inv.getContents());
p.getInventory().setArmorContents(armor);
p.updateInventory();
}
}.runTaskLater(Main.get(), 1);
}
}
public Player getPlayer() {
return Bukkit.getPlayer(uuid);
}
public UUID getUUID() {
return uuid;
}
public static void remove(Player p) {
inventoryData.remove(p);
}
public static HashMap<Player, InventoryData> getInventoryData() {
return inventoryData;
}
public static InventoryData getInventoryData(Player p) {
if (inventoryData.containsKey(p)) {
return inventoryData.get(p);
}
return null;
}
}

83
MultiArena-TheBridge/src/cx/sfy/TheBridge/game/PlayerData.java

@ -0,0 +1,83 @@
package cx.sfy.TheBridge.game;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scoreboard.Scoreboard;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.database.PlayerStat;
import cx.sfy.TheBridge.utils.Utils;
public class PlayerData {
private UUID uuid;
private double health;
private boolean fly;
private int food;
private Inventory inv;
private ItemStack[] armor;
private Scoreboard sb;
private GameMode gm;
private boolean restored;
private float flySpeed;
public PlayerData(Player p) {
this.uuid = p.getUniqueId();
this.sb = p.getScoreboard();
this.food = p.getFoodLevel();
this.health = p.getHealth();
this.gm = p.getGameMode();
this.armor = p.getInventory().getArmorContents();
this.flySpeed = p.getFlySpeed();
this.fly = p.getAllowFlight();
this.restored = false;
this.inv = Bukkit.createInventory(null, InventoryType.PLAYER, p.getName());
this.inv.setContents(p.getInventory().getContents());
}
public void restore() {
if (!restored) {
Player p = this.getPlayer();
if (p == null) {
return;
}
restored = true;
p.closeInventory();
p.setGameMode(gm);
p.getInventory().clear();
p.getInventory().setContents(inv.getContents());
p.getInventory().setArmorContents(armor);
p.setFoodLevel(food);
p.setHealth(health);
p.resetPlayerTime();
p.resetPlayerWeather();
p.setFlySpeed(flySpeed);
p.setAllowFlight(fly);
p.setFireTicks(0);
p.setScoreboard(sb);
Location respawn = Main.get().getMainLobby();
p.teleport(respawn, TeleportCause.END_PORTAL);
Utils.setPlayerExperience(p, PlayerStat.getPlayerStat(p).getXP());
if (!Main.get().isStop()) {
Main.get().getTOP().createInfo(p);
}
}
}
public Player getPlayer() {
return Bukkit.getPlayer(uuid);
}
public UUID getUUID() {
return uuid;
}
}

21
MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologram.java

@ -0,0 +1,21 @@
package cx.sfy.TheBridge.hologram;
import java.util.ArrayList;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public interface TruenoHologram {
public void setupWorldHologram(Location loc, ArrayList<String> lines);
public void setupPlayerHologram(Player player, Location loc, ArrayList<String> lines);
public Location getLocation();
public Player getPlayer();
public void setDistanceBetweenLines(Double distance);
public void display();
public void update(ArrayList<String> lines);
public void updateLine(int index, String text);
public void removeLine(int index);
public void delete();
}

46
MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologramAPI.java

@ -0,0 +1,46 @@
package cx.sfy.TheBridge.hologram;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import cx.sfy.TheBridge.hologram.TruenoHologram_v1_10_R1;
import cx.sfy.TheBridge.hologram.TruenoHologram_v1_11_R1;
import cx.sfy.TheBridge.hologram.TruenoHologram_v1_8_R3;
import cx.sfy.TheBridge.hologram.TruenoHologram_v1_9_R2;
import net.md_5.bungee.api.ChatColor;
public class TruenoHologramAPI {
private static String version;
private static void setupVersion(){
try {
version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
} catch (ArrayIndexOutOfBoundsException ex) {
ex.printStackTrace();
}
}
public static TruenoHologram getNewHologram(){
if(version==null){
setupVersion();
}
if (version.equals("v1_8_R3")) {
return new TruenoHologram_v1_8_R3();
} else if (version.equals("v1_9_R2")) {
return new TruenoHologram_v1_9_R2();
} else if (version.equals("v1_10_R1")) {
return new TruenoHologram_v1_10_R1();
} else if (version.equals("v1_11_R1")) {
return new TruenoHologram_v1_11_R1();
} else if (version.equals("v1_12_R1")) {
return new TruenoHologram_v1_12_R1();
} else {
Bukkit.getLogger().log(Level.SEVERE, ChatColor.RED + "Unsopported server version.");
return null;
}
}
}

283
MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologram_v1_10_R1.java

@ -0,0 +1,283 @@
package cx.sfy.TheBridge.hologram;
import java.util.ArrayList;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import cx.sfy.TheBridge.hologram.TruenoHologram;
import net.minecraft.server.v1_10_R1.EntityArmorStand;
import net.minecraft.server.v1_10_R1.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_10_R1.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_10_R1.WorldServer;
public class TruenoHologram_v1_10_R1 implements TruenoHologram{
private Location location;
private ArrayList<String> lines;
private double linesdistance = 0.30;
private ArrayList<ArmorStand> armor_lines = new ArrayList<ArmorStand>();
private ArrayList<EntityArmorStand> NmsArmorLines = new ArrayList<EntityArmorStand>();
private Player player = null;
@Override
public void setupWorldHologram(Location loc, ArrayList<String> lines) {
this.location = loc.clone();
this.lines = lines;
}
@Override
public void setupPlayerHologram(Player player, Location loc, ArrayList<String> lines) {
this.player = player;
this.location = loc.clone();
this.lines = lines;
}
public Location getLocation(){
return this.location;
}
public Player getPlayer(){
return player;
}
private void NmsDestroy(EntityArmorStand hololine){
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(hololine.getId());
((CraftPlayer) this.player).getHandle().playerConnection.sendPacket(packet);
}
private Location getNmsLocation(EntityArmorStand hololine){
return new Location(hololine.getWorld().getWorld(), hololine.locX, hololine.locY, hololine.locZ);
}
private void NmsSpawn(EntityArmorStand stand, String line, Location loc){
stand.setLocation(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
stand.setCustomName(line);
stand.setCustomNameVisible(true);
stand.setNoGravity(true);
stand.setSmall(true);
stand.setInvisible(true);
stand.setBasePlate(false);
stand.setArms(false);
if(!line.equals("")){
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(stand);
((CraftPlayer) this.player).getHandle().playerConnection.sendPacket(packet);
}
}
private void spawn(){
int ind = 0;
for(String line : lines){
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(this.player!=null){
if(ind>0) finalLoc = getNmsLocation(NmsArmorLines.get(ind-1)); finalLoc.setY(finalLoc.getY()-linesdistance);
WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle();
EntityArmorStand stand = new EntityArmorStand(s);
NmsSpawn(stand, line, finalLoc);
NmsArmorLines.add(stand);
}
else{
if(ind>0) finalLoc = armor_lines.get(ind-1).getLocation(); finalLoc.setY(finalLoc.getY()-linesdistance);
ArmorStand Armorline = (ArmorStand) location.getWorld().spawnEntity(finalLoc, EntityType.ARMOR_STAND);
Armorline.setBasePlate(false);
Armorline.setCustomNameVisible(true);
Armorline.setGravity(false);
Armorline.setCanPickupItems(false);
Armorline.setCustomName(line);
Armorline.setSmall(true);
Armorline.setVisible(false);
armor_lines.add(Armorline);
if(line.equals("")) Armorline.remove();
}
ind++;
}
}
private void despawn(){
if(this.player!=null){
for(EntityArmorStand nmsStand : NmsArmorLines){
NmsDestroy(nmsStand);
}
NmsArmorLines.clear();
}
else{
for(ArmorStand line : armor_lines){
line.remove();
}
armor_lines.clear();
}
}
public void setDistanceBetweenLines(Double distance){
this.linesdistance = distance;
}
public void display(){
spawn();
}
public void update(ArrayList<String> lines){
if(this.player != null){
int ind = 0;
for(String newline : lines){
if(this.lines.size()>= ind){
String oldline = this.lines.get(ind);
if(!newline.equals(oldline)){
if(!newline.equals("")){
final EntityArmorStand oldstand = NmsArmorLines.get(ind);
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(ind>0) finalLoc = getNmsLocation(NmsArmorLines.get(ind-1)); finalLoc.setY(finalLoc.getY()-linesdistance);
WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle();
EntityArmorStand stand = new EntityArmorStand(s);
NmsSpawn(stand, newline, finalLoc);
this.NmsArmorLines.set(ind, stand);
this.lines.set(ind, newline);
NmsDestroy(oldstand);
}
else{
this.lines.set(ind, newline);
final EntityArmorStand oldstand = NmsArmorLines.get(ind);
NmsDestroy(oldstand);
}
}
ind++;
}
else{
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(ind>0) finalLoc = getNmsLocation(NmsArmorLines.get(ind-1)); finalLoc.setY(finalLoc.getY()-linesdistance);
WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle();
EntityArmorStand stand = new EntityArmorStand(s);
NmsSpawn(stand, newline, finalLoc);
this.NmsArmorLines.add(stand);
this.lines.add(newline);
}
}
if(lines.size() > this.lines.size()){
int dif = lines.size() - this.lines.size();
for(int in = 0; in <=dif; in++){
int arrayind = (this.lines.size()-1)-in;
this.lines.remove(arrayind);
NmsDestroy(this.NmsArmorLines.get(arrayind));
this.NmsArmorLines.remove(arrayind);
}
}
}
else{
int ind = 0;
for(String newline : lines){
if(this.lines.size()>= ind){
String oldline = this.lines.get(ind);
if(!newline.equals(oldline)){
if(newline != ""){
this.armor_lines.get(ind).setCustomName(newline);
}
else{
this.lines.set(ind, newline);
final ArmorStand oldstand = armor_lines.get(ind);
oldstand.remove();
}
}
ind++;
}
else{
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(ind>0) finalLoc = armor_lines.get(ind-1).getLocation(); finalLoc.setY(finalLoc.getY()-linesdistance);
ArmorStand Armorline = (ArmorStand) location.getWorld().spawnEntity(finalLoc, EntityType.ARMOR_STAND);
Armorline.setBasePlate(false);
Armorline.setCustomNameVisible(true);
Armorline.setGravity(false);
Armorline.setCanPickupItems(false);
Armorline.setCustomName(newline);
Armorline.setSmall(true);
Armorline.setVisible(false);
armor_lines.add(Armorline);
this.lines.add(newline);
}
}
if(lines.size() > this.lines.size()){
int dif = lines.size() - this.lines.size();
for(int in = 0; in <=dif; in++){
int arrayind = (this.lines.size()-1)-in;
this.lines.remove(arrayind);
this.armor_lines.get(arrayind).remove();
this.armor_lines.remove(arrayind);
}
}
}
}
public void updateLine(int index, String text){
if(this.lines.size() >= index){
int realindex = (this.lines.size()-1)-index;
String oldtext = this.lines.get(realindex);
if(!text.equals(oldtext)){
if(this.player != null){
if(text != ""){
final EntityArmorStand oldstand = NmsArmorLines.get(realindex);
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(realindex>0) finalLoc = getNmsLocation(NmsArmorLines.get(realindex-1)); finalLoc.setY(finalLoc.getY()-linesdistance);
WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle();
EntityArmorStand stand = new EntityArmorStand(s);
NmsSpawn(stand, text, finalLoc);
this.NmsArmorLines.set(realindex, stand);
NmsDestroy(oldstand);
}
else{
this.lines.set(realindex, text);
final EntityArmorStand oldstand = NmsArmorLines.get(realindex);
NmsDestroy(oldstand);
}
}
else{
if(text != ""){
this.armor_lines.get(realindex).setCustomName(text);
}
else{
final ArmorStand oldstand = armor_lines.get(realindex);
oldstand.remove();
}
}
this.lines.set(realindex, text);
}
}
}
public void removeLine(int index){
if(this.lines.size() >= index){
int realindex = (this.lines.size()-1)-index;
if(this.player != null){
final EntityArmorStand stand = NmsArmorLines.get(realindex);
this.NmsArmorLines.remove(stand);
NmsDestroy(stand);
}
else{
this.armor_lines.get(realindex).remove();
}
this.lines.remove(realindex);
}
}
public void delete(){
despawn();
this.player = null;
this.NmsArmorLines = new ArrayList<EntityArmorStand>();
this.armor_lines = new ArrayList<ArmorStand>();
this.lines = new ArrayList<String>();
this.location = null;
}
}

283
MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologram_v1_11_R1.java

@ -0,0 +1,283 @@
package cx.sfy.TheBridge.hologram;
import java.util.ArrayList;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_11_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import cx.sfy.TheBridge.hologram.TruenoHologram;
import net.minecraft.server.v1_11_R1.EntityArmorStand;
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_11_R1.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_11_R1.WorldServer;
public class TruenoHologram_v1_11_R1 implements TruenoHologram{
private Location location;
private ArrayList<String> lines;
private double linesdistance = 0.30;
private ArrayList<ArmorStand> armor_lines = new ArrayList<ArmorStand>();
private ArrayList<EntityArmorStand> NmsArmorLines = new ArrayList<EntityArmorStand>();
private Player player = null;
@Override
public void setupWorldHologram(Location loc, ArrayList<String> lines) {
this.location = loc.clone();
this.lines = lines;
}
@Override
public void setupPlayerHologram(Player player, Location loc, ArrayList<String> lines) {
this.player = player;
this.location = loc.clone();
this.lines = lines;
}
public Location getLocation(){
return this.location;
}
public Player getPlayer(){
return player;
}
private void NmsDestroy(EntityArmorStand hololine){
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(hololine.getId());
((CraftPlayer) this.player).getHandle().playerConnection.sendPacket(packet);
}
private Location getNmsLocation(EntityArmorStand hololine){
return new Location(hololine.getWorld().getWorld(), hololine.locX, hololine.locY, hololine.locZ);
}
private void NmsSpawn(EntityArmorStand stand, String line, Location loc){
stand.setLocation(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
stand.setCustomName(line);
stand.setCustomNameVisible(true);
stand.setNoGravity(true);
stand.setSmall(true);
stand.setInvisible(true);
stand.setBasePlate(false);
stand.setArms(false);
if(!line.equals("")){
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(stand);
((CraftPlayer) this.player).getHandle().playerConnection.sendPacket(packet);
}
}
private void spawn(){
int ind = 0;
for(String line : lines){
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(this.player!=null){
if(ind>0) finalLoc = getNmsLocation(NmsArmorLines.get(ind-1)); finalLoc.setY(finalLoc.getY()-linesdistance);
WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle();
EntityArmorStand stand = new EntityArmorStand(s);
NmsSpawn(stand, line, finalLoc);
NmsArmorLines.add(stand);
}
else{
if(ind>0) finalLoc = armor_lines.get(ind-1).getLocation(); finalLoc.setY(finalLoc.getY()-linesdistance);
ArmorStand Armorline = (ArmorStand) location.getWorld().spawnEntity(finalLoc, EntityType.ARMOR_STAND);
Armorline.setBasePlate(false);
Armorline.setCustomNameVisible(true);
Armorline.setGravity(false);
Armorline.setCanPickupItems(false);
Armorline.setCustomName(line);
Armorline.setSmall(true);
Armorline.setVisible(false);
armor_lines.add(Armorline);
if(line.equals("")) Armorline.remove();
}
ind++;
}
}
private void despawn(){
if(this.player!=null){
for(EntityArmorStand nmsStand : NmsArmorLines){
NmsDestroy(nmsStand);
}
NmsArmorLines.clear();
}
else{
for(ArmorStand line : armor_lines){
line.remove();
}
armor_lines.clear();
}
}
public void setDistanceBetweenLines(Double distance){
this.linesdistance = distance;
}
public void display(){
spawn();
}
public void update(ArrayList<String> lines){
if(this.player != null){
int ind = 0;
for(String newline : lines){
if(this.lines.size()>= ind){
String oldline = this.lines.get(ind);
if(!newline.equals(oldline)){
if(!newline.equals("")){
final EntityArmorStand oldstand = NmsArmorLines.get(ind);
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(ind>0) finalLoc = getNmsLocation(NmsArmorLines.get(ind-1)); finalLoc.setY(finalLoc.getY()-linesdistance);
WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle();
EntityArmorStand stand = new EntityArmorStand(s);
NmsSpawn(stand, newline, finalLoc);
this.NmsArmorLines.set(ind, stand);
this.lines.set(ind, newline);
NmsDestroy(oldstand);
}
else{
this.lines.set(ind, newline);
final EntityArmorStand oldstand = NmsArmorLines.get(ind);
NmsDestroy(oldstand);
}
}
ind++;
}
else{
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(ind>0) finalLoc = getNmsLocation(NmsArmorLines.get(ind-1)); finalLoc.setY(finalLoc.getY()-linesdistance);
WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle();
EntityArmorStand stand = new EntityArmorStand(s);
NmsSpawn(stand, newline, finalLoc);
this.NmsArmorLines.add(stand);
this.lines.add(newline);
}
}
if(lines.size() > this.lines.size()){
int dif = lines.size() - this.lines.size();
for(int in = 0; in <=dif; in++){
int arrayind = (this.lines.size()-1)-in;
this.lines.remove(arrayind);
NmsDestroy(this.NmsArmorLines.get(arrayind));
this.NmsArmorLines.remove(arrayind);
}
}
}
else{
int ind = 0;
for(String newline : lines){
if(this.lines.size()>= ind){
String oldline = this.lines.get(ind);
if(!newline.equals(oldline)){
if(newline != ""){
this.armor_lines.get(ind).setCustomName(newline);
}
else{
this.lines.set(ind, newline);
final ArmorStand oldstand = armor_lines.get(ind);
oldstand.remove();
}
}
ind++;
}
else{
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(ind>0) finalLoc = armor_lines.get(ind-1).getLocation(); finalLoc.setY(finalLoc.getY()-linesdistance);
ArmorStand Armorline = (ArmorStand) location.getWorld().spawnEntity(finalLoc, EntityType.ARMOR_STAND);
Armorline.setBasePlate(false);
Armorline.setCustomNameVisible(true);
Armorline.setGravity(false);
Armorline.setCanPickupItems(false);
Armorline.setCustomName(newline);
Armorline.setSmall(true);
Armorline.setVisible(false);
armor_lines.add(Armorline);
this.lines.add(newline);
}
}
if(lines.size() > this.lines.size()){
int dif = lines.size() - this.lines.size();
for(int in = 0; in <=dif; in++){
int arrayind = (this.lines.size()-1)-in;
this.lines.remove(arrayind);
this.armor_lines.get(arrayind).remove();
this.armor_lines.remove(arrayind);
}
}
}
}
public void updateLine(int index, String text){
if(this.lines.size() >= index){
int realindex = (this.lines.size()-1)-index;
String oldtext = this.lines.get(realindex);
if(!text.equals(oldtext)){
if(this.player != null){
if(text != ""){
final EntityArmorStand oldstand = NmsArmorLines.get(realindex);
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(realindex>0) finalLoc = getNmsLocation(NmsArmorLines.get(realindex-1)); finalLoc.setY(finalLoc.getY()-linesdistance);
WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle();
EntityArmorStand stand = new EntityArmorStand(s);
NmsSpawn(stand, text, finalLoc);
this.NmsArmorLines.set(realindex, stand);
NmsDestroy(oldstand);
}
else{
this.lines.set(realindex, text);
final EntityArmorStand oldstand = NmsArmorLines.get(realindex);
NmsDestroy(oldstand);
}
}
else{
if(text != ""){
this.armor_lines.get(realindex).setCustomName(text);
}
else{
final ArmorStand oldstand = armor_lines.get(realindex);
oldstand.remove();
}
}
this.lines.set(realindex, text);
}
}
}
public void removeLine(int index){
if(this.lines.size() >= index){
int realindex = (this.lines.size()-1)-index;
if(this.player != null){
final EntityArmorStand stand = NmsArmorLines.get(realindex);
this.NmsArmorLines.remove(stand);
NmsDestroy(stand);
}
else{
this.armor_lines.get(realindex).remove();
}
this.lines.remove(realindex);
}
}
public void delete(){
despawn();
this.player = null;
this.NmsArmorLines = new ArrayList<EntityArmorStand>();
this.armor_lines = new ArrayList<ArmorStand>();
this.lines = new ArrayList<String>();
this.location = null;
}
}

283
MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologram_v1_12_R1.java

@ -0,0 +1,283 @@
package cx.sfy.TheBridge.hologram;
import java.util.ArrayList;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import cx.sfy.TheBridge.hologram.TruenoHologram;
import net.minecraft.server.v1_12_R1.EntityArmorStand;
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_12_R1.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_12_R1.WorldServer;
public class TruenoHologram_v1_12_R1 implements TruenoHologram{
private Location location;
private ArrayList<String> lines;
private double linesdistance = 0.30;
private ArrayList<ArmorStand> armor_lines = new ArrayList<ArmorStand>();
private ArrayList<EntityArmorStand> NmsArmorLines = new ArrayList<EntityArmorStand>();
private Player player = null;
@Override
public void setupWorldHologram(Location loc, ArrayList<String> lines) {
this.location = loc.clone();
this.lines = lines;
}
@Override
public void setupPlayerHologram(Player player, Location loc, ArrayList<String> lines) {
this.player = player;
this.location = loc.clone();
this.lines = lines;
}
public Location getLocation(){
return this.location;
}
public Player getPlayer(){
return player;
}
private void NmsDestroy(EntityArmorStand hololine){
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(hololine.getId());
((CraftPlayer) this.player).getHandle().playerConnection.sendPacket(packet);
}
private Location getNmsLocation(EntityArmorStand hololine){
return new Location(hololine.getWorld().getWorld(), hololine.locX, hololine.locY, hololine.locZ);
}
private void NmsSpawn(EntityArmorStand stand, String line, Location loc){
stand.setLocation(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
stand.setCustomName(line);
stand.setCustomNameVisible(true);
stand.setNoGravity(true);
stand.setSmall(true);
stand.setInvisible(true);
stand.setBasePlate(false);
stand.setArms(false);
if(!line.equals("")){
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(stand);
((CraftPlayer) this.player).getHandle().playerConnection.sendPacket(packet);
}
}
private void spawn(){
int ind = 0;
for(String line : lines){
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(this.player!=null){
if(ind>0) finalLoc = getNmsLocation(NmsArmorLines.get(ind-1)); finalLoc.setY(finalLoc.getY()-linesdistance);
WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle();
EntityArmorStand stand = new EntityArmorStand(s);
NmsSpawn(stand, line, finalLoc);
NmsArmorLines.add(stand);
}
else{
if(ind>0) finalLoc = armor_lines.get(ind-1).getLocation(); finalLoc.setY(finalLoc.getY()-linesdistance);
ArmorStand Armorline = (ArmorStand) location.getWorld().spawnEntity(finalLoc, EntityType.ARMOR_STAND);
Armorline.setBasePlate(false);
Armorline.setCustomNameVisible(true);
Armorline.setGravity(false);
Armorline.setCanPickupItems(false);
Armorline.setCustomName(line);
Armorline.setSmall(true);
Armorline.setVisible(false);
armor_lines.add(Armorline);
if(line.equals("")) Armorline.remove();
}
ind++;
}
}
private void despawn(){
if(this.player!=null){
for(EntityArmorStand nmsStand : NmsArmorLines){
NmsDestroy(nmsStand);
}
NmsArmorLines.clear();
}
else{
for(ArmorStand line : armor_lines){
line.remove();
}
armor_lines.clear();
}
}
public void setDistanceBetweenLines(Double distance){
this.linesdistance = distance;
}
public void display(){
spawn();
}
public void update(ArrayList<String> lines){
if(this.player != null){
int ind = 0;
for(String newline : lines){
if(this.lines.size()>= ind){
String oldline = this.lines.get(ind);
if(!newline.equals(oldline)){
if(!newline.equals("")){
final EntityArmorStand oldstand = NmsArmorLines.get(ind);
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(ind>0) finalLoc = getNmsLocation(NmsArmorLines.get(ind-1)); finalLoc.setY(finalLoc.getY()-linesdistance);
WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle();
EntityArmorStand stand = new EntityArmorStand(s);
NmsSpawn(stand, newline, finalLoc);
this.NmsArmorLines.set(ind, stand);
this.lines.set(ind, newline);
NmsDestroy(oldstand);
}
else{
this.lines.set(ind, newline);
final EntityArmorStand oldstand = NmsArmorLines.get(ind);
NmsDestroy(oldstand);
}
}
ind++;
}
else{
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(ind>0) finalLoc = getNmsLocation(NmsArmorLines.get(ind-1)); finalLoc.setY(finalLoc.getY()-linesdistance);
WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle();
EntityArmorStand stand = new EntityArmorStand(s);
NmsSpawn(stand, newline, finalLoc);
this.NmsArmorLines.add(stand);
this.lines.add(newline);
}
}
if(lines.size() > this.lines.size()){
int dif = lines.size() - this.lines.size();
for(int in = 0; in <=dif; in++){
int arrayind = (this.lines.size()-1)-in;
this.lines.remove(arrayind);
NmsDestroy(this.NmsArmorLines.get(arrayind));
this.NmsArmorLines.remove(arrayind);
}
}
}
else{
int ind = 0;
for(String newline : lines){
if(this.lines.size()>= ind){
String oldline = this.lines.get(ind);
if(!newline.equals(oldline)){
if(newline != ""){
this.armor_lines.get(ind).setCustomName(newline);
}
else{
this.lines.set(ind, newline);
final ArmorStand oldstand = armor_lines.get(ind);
oldstand.remove();
}
}
ind++;
}
else{
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(ind>0) finalLoc = armor_lines.get(ind-1).getLocation(); finalLoc.setY(finalLoc.getY()-linesdistance);
ArmorStand Armorline = (ArmorStand) location.getWorld().spawnEntity(finalLoc, EntityType.ARMOR_STAND);
Armorline.setBasePlate(false);
Armorline.setCustomNameVisible(true);
Armorline.setGravity(false);
Armorline.setCanPickupItems(false);
Armorline.setCustomName(newline);
Armorline.setSmall(true);
Armorline.setVisible(false);
armor_lines.add(Armorline);
this.lines.add(newline);
}
}
if(lines.size() > this.lines.size()){
int dif = lines.size() - this.lines.size();
for(int in = 0; in <=dif; in++){
int arrayind = (this.lines.size()-1)-in;
this.lines.remove(arrayind);
this.armor_lines.get(arrayind).remove();
this.armor_lines.remove(arrayind);
}
}
}
}
public void updateLine(int index, String text){
if(this.lines.size() >= index){
int realindex = (this.lines.size()-1)-index;
String oldtext = this.lines.get(realindex);
if(!text.equals(oldtext)){
if(this.player != null){
if(text != ""){
final EntityArmorStand oldstand = NmsArmorLines.get(realindex);
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(realindex>0) finalLoc = getNmsLocation(NmsArmorLines.get(realindex-1)); finalLoc.setY(finalLoc.getY()-linesdistance);
WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle();
EntityArmorStand stand = new EntityArmorStand(s);
NmsSpawn(stand, text, finalLoc);
this.NmsArmorLines.set(realindex, stand);
NmsDestroy(oldstand);
}
else{
this.lines.set(realindex, text);
final EntityArmorStand oldstand = NmsArmorLines.get(realindex);
NmsDestroy(oldstand);
}
}
else{
if(text != ""){
this.armor_lines.get(realindex).setCustomName(text);
}
else{
final ArmorStand oldstand = armor_lines.get(realindex);
oldstand.remove();
}
}
this.lines.set(realindex, text);
}
}
}
public void removeLine(int index){
if(this.lines.size() >= index){
int realindex = (this.lines.size()-1)-index;
if(this.player != null){
final EntityArmorStand stand = NmsArmorLines.get(realindex);
this.NmsArmorLines.remove(stand);
NmsDestroy(stand);
}
else{
this.armor_lines.get(realindex).remove();
}
this.lines.remove(realindex);
}
}
public void delete(){
despawn();
this.player = null;
this.NmsArmorLines = new ArrayList<EntityArmorStand>();
this.armor_lines = new ArrayList<ArmorStand>();
this.lines = new ArrayList<String>();
this.location = null;
}
}

283
MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologram_v1_8_R3.java

@ -0,0 +1,283 @@
package cx.sfy.TheBridge.hologram;
import java.util.ArrayList;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import cx.sfy.TheBridge.hologram.TruenoHologram;
import net.minecraft.server.v1_8_R3.EntityArmorStand;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_8_R3.WorldServer;
public class TruenoHologram_v1_8_R3 implements TruenoHologram{
private Location location;
private ArrayList<String> lines;
private double linesdistance = 0.30;
private ArrayList<ArmorStand> armor_lines = new ArrayList<ArmorStand>();
private ArrayList<EntityArmorStand> NmsArmorLines = new ArrayList<EntityArmorStand>();
private Player player = null;
@Override
public void setupWorldHologram(Location loc, ArrayList<String> lines) {
this.location = loc.clone();
this.lines = lines;
}
@Override
public void setupPlayerHologram(Player player, Location loc, ArrayList<String> lines) {
this.player = player;
this.location = loc.clone();
this.lines = lines;
}
public Location getLocation(){
return this.location;
}
public Player getPlayer(){
return player;
}
private void NmsDestroy(EntityArmorStand hololine){
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(hololine.getId());
((CraftPlayer) this.player).getHandle().playerConnection.sendPacket(packet);
}
private Location getNmsLocation(EntityArmorStand hololine){
return new Location(hololine.getWorld().getWorld(), hololine.locX, hololine.locY, hololine.locZ);
}
private void NmsSpawn(EntityArmorStand stand, String line, Location loc){
stand.setLocation(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
stand.setCustomName(line);
stand.setCustomNameVisible(true);
stand.setGravity(false);
stand.setSmall(true);
stand.setInvisible(true);
stand.setBasePlate(false);
stand.setArms(false);
if(!line.equals("")){
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(stand);
((CraftPlayer) this.player).getHandle().playerConnection.sendPacket(packet);
}
}
private void spawn(){
int ind = 0;
for(String line : lines){
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(this.player!=null){
if(ind>0) finalLoc = getNmsLocation(NmsArmorLines.get(ind-1)); finalLoc.setY(finalLoc.getY()-linesdistance);
WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle();
EntityArmorStand stand = new EntityArmorStand(s);
NmsSpawn(stand, line, finalLoc);
NmsArmorLines.add(stand);
}
else{
if(ind>0) finalLoc = armor_lines.get(ind-1).getLocation(); finalLoc.setY(finalLoc.getY()-linesdistance);
ArmorStand Armorline = (ArmorStand) location.getWorld().spawnEntity(finalLoc, EntityType.ARMOR_STAND);
Armorline.setBasePlate(false);
Armorline.setCustomNameVisible(true);
Armorline.setGravity(false);
Armorline.setCanPickupItems(false);
Armorline.setCustomName(line);
Armorline.setSmall(true);
Armorline.setVisible(false);
armor_lines.add(Armorline);
if(line.equals("")) Armorline.remove();
}
ind++;
}
}
private void despawn(){
if(this.player!=null){
for(EntityArmorStand nmsStand : NmsArmorLines){
NmsDestroy(nmsStand);
}
NmsArmorLines.clear();
}
else{
for(ArmorStand line : armor_lines){
line.remove();
}
armor_lines.clear();
}
}
public void setDistanceBetweenLines(Double distance){
this.linesdistance = distance;
}
public void display(){
spawn();
}
public void update(ArrayList<String> lines){
if(this.player != null){
int ind = 0;
for(String newline : lines){
if(this.lines.size()>= ind){
String oldline = this.lines.get(ind);
if(!newline.equals(oldline)){
if(!newline.equals("")){
final EntityArmorStand oldstand = NmsArmorLines.get(ind);
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(ind>0) finalLoc = getNmsLocation(NmsArmorLines.get(ind-1)); finalLoc.setY(finalLoc.getY()-linesdistance);
WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle();
EntityArmorStand stand = new EntityArmorStand(s);
NmsSpawn(stand, newline, finalLoc);
this.NmsArmorLines.set(ind, stand);
this.lines.set(ind, newline);
NmsDestroy(oldstand);
}
else{
this.lines.set(ind, newline);
final EntityArmorStand oldstand = NmsArmorLines.get(ind);
NmsDestroy(oldstand);
}
}
ind++;
}
else{
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(ind>0) finalLoc = getNmsLocation(NmsArmorLines.get(ind-1)); finalLoc.setY(finalLoc.getY()-linesdistance);
WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle();
EntityArmorStand stand = new EntityArmorStand(s);
NmsSpawn(stand, newline, finalLoc);
this.NmsArmorLines.add(stand);
this.lines.add(newline);
}
}
if(lines.size() > this.lines.size()){
int dif = lines.size() - this.lines.size();
for(int in = 0; in <=dif; in++){
int arrayind = (this.lines.size()-1)-in;
this.lines.remove(arrayind);
NmsDestroy(this.NmsArmorLines.get(arrayind));
this.NmsArmorLines.remove(arrayind);
}
}
}
else{
int ind = 0;
for(String newline : lines){
if(this.lines.size()>= ind){
String oldline = this.lines.get(ind);
if(!newline.equals(oldline)){
if(newline != ""){
this.armor_lines.get(ind).setCustomName(newline);
}
else{
this.lines.set(ind, newline);
final ArmorStand oldstand = armor_lines.get(ind);
oldstand.remove();
}
}
ind++;
}
else{
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(ind>0) finalLoc = armor_lines.get(ind-1).getLocation(); finalLoc.setY(finalLoc.getY()-linesdistance);
ArmorStand Armorline = (ArmorStand) location.getWorld().spawnEntity(finalLoc, EntityType.ARMOR_STAND);
Armorline.setBasePlate(false);
Armorline.setCustomNameVisible(true);
Armorline.setGravity(false);
Armorline.setCanPickupItems(false);
Armorline.setCustomName(newline);
Armorline.setSmall(true);
Armorline.setVisible(false);
armor_lines.add(Armorline);
this.lines.add(newline);
}
}
if(lines.size() > this.lines.size()){
int dif = lines.size() - this.lines.size();
for(int in = 0; in <=dif; in++){
int arrayind = (this.lines.size()-1)-in;
this.lines.remove(arrayind);
this.armor_lines.get(arrayind).remove();
this.armor_lines.remove(arrayind);
}
}
}
}
public void updateLine(int index, String text){
if(this.lines.size() >= index){
int realindex = (this.lines.size()-1)-index;
String oldtext = this.lines.get(realindex);
if(!text.equals(oldtext)){
if(this.player != null){
if(text != ""){
final EntityArmorStand oldstand = NmsArmorLines.get(realindex);
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(realindex>0) finalLoc = getNmsLocation(NmsArmorLines.get(realindex-1)); finalLoc.setY(finalLoc.getY()-linesdistance);
WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle();
EntityArmorStand stand = new EntityArmorStand(s);
NmsSpawn(stand, text, finalLoc);
this.NmsArmorLines.set(realindex, stand);
NmsDestroy(oldstand);
}
else{
this.lines.set(realindex, text);
final EntityArmorStand oldstand = NmsArmorLines.get(realindex);
NmsDestroy(oldstand);
}
}
else{
if(text != ""){
this.armor_lines.get(realindex).setCustomName(text);
}
else{
final ArmorStand oldstand = armor_lines.get(realindex);
oldstand.remove();
}
}
this.lines.set(realindex, text);
}
}
}
public void removeLine(int index){
if(this.lines.size() >= index){
int realindex = (this.lines.size()-1)-index;
if(this.player != null){
final EntityArmorStand stand = NmsArmorLines.get(realindex);
this.NmsArmorLines.remove(stand);
NmsDestroy(stand);
}
else{
this.armor_lines.get(realindex).remove();
}
this.lines.remove(realindex);
}
}
public void delete(){
despawn();
this.player = null;
this.NmsArmorLines = new ArrayList<EntityArmorStand>();
this.armor_lines = new ArrayList<ArmorStand>();
this.lines = new ArrayList<String>();
this.location = null;
}
}

283
MultiArena-TheBridge/src/cx/sfy/TheBridge/hologram/TruenoHologram_v1_9_R2.java

@ -0,0 +1,283 @@
package cx.sfy.TheBridge.hologram;
import java.util.ArrayList;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_9_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import cx.sfy.TheBridge.hologram.TruenoHologram;
import net.minecraft.server.v1_9_R2.EntityArmorStand;
import net.minecraft.server.v1_9_R2.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_9_R2.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_9_R2.WorldServer;
public class TruenoHologram_v1_9_R2 implements TruenoHologram{
private Location location;
private ArrayList<String> lines;
private double linesdistance = 0.30;
private ArrayList<ArmorStand> armor_lines = new ArrayList<ArmorStand>();
private ArrayList<EntityArmorStand> NmsArmorLines = new ArrayList<EntityArmorStand>();
private Player player = null;
@Override
public void setupWorldHologram(Location loc, ArrayList<String> lines) {
this.location = loc.clone();
this.lines = lines;
}
@Override
public void setupPlayerHologram(Player player, Location loc, ArrayList<String> lines) {
this.player = player;
this.location = loc.clone();
this.lines = lines;
}
public Location getLocation(){
return this.location;
}
public Player getPlayer(){
return player;
}
private void NmsDestroy(EntityArmorStand hololine){
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(hololine.getId());
((CraftPlayer) this.player).getHandle().playerConnection.sendPacket(packet);
}
private Location getNmsLocation(EntityArmorStand hololine){
return new Location(hololine.getWorld().getWorld(), hololine.locX, hololine.locY, hololine.locZ);
}
private void NmsSpawn(EntityArmorStand stand, String line, Location loc){
stand.setLocation(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
stand.setCustomName(line);
stand.setCustomNameVisible(true);
stand.setGravity(false);
stand.setSmall(true);
stand.setInvisible(true);
stand.setBasePlate(false);
stand.setArms(false);
if(!line.equals("")){
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(stand);
((CraftPlayer) this.player).getHandle().playerConnection.sendPacket(packet);
}
}
private void spawn(){
int ind = 0;
for(String line : lines){
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(this.player!=null){
if(ind>0) finalLoc = getNmsLocation(NmsArmorLines.get(ind-1)); finalLoc.setY(finalLoc.getY()-linesdistance);
WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle();
EntityArmorStand stand = new EntityArmorStand(s);
NmsSpawn(stand, line, finalLoc);
NmsArmorLines.add(stand);
}
else{
if(ind>0) finalLoc = armor_lines.get(ind-1).getLocation(); finalLoc.setY(finalLoc.getY()-linesdistance);
ArmorStand Armorline = (ArmorStand) location.getWorld().spawnEntity(finalLoc, EntityType.ARMOR_STAND);
Armorline.setBasePlate(false);
Armorline.setCustomNameVisible(true);
Armorline.setGravity(false);
Armorline.setCanPickupItems(false);
Armorline.setCustomName(line);
Armorline.setSmall(true);
Armorline.setVisible(false);
armor_lines.add(Armorline);
if(line.equals("")) Armorline.remove();
}
ind++;
}
}
private void despawn(){
if(this.player!=null){
for(EntityArmorStand nmsStand : NmsArmorLines){
NmsDestroy(nmsStand);
}
NmsArmorLines.clear();
}
else{
for(ArmorStand line : armor_lines){
line.remove();
}
armor_lines.clear();
}
}
public void setDistanceBetweenLines(Double distance){
this.linesdistance = distance;
}
public void display(){
spawn();
}
public void update(ArrayList<String> lines){
if(this.player != null){
int ind = 0;
for(String newline : lines){
if(this.lines.size()>= ind){
String oldline = this.lines.get(ind);
if(!newline.equals(oldline)){
if(!newline.equals("")){
final EntityArmorStand oldstand = NmsArmorLines.get(ind);
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(ind>0) finalLoc = getNmsLocation(NmsArmorLines.get(ind-1)); finalLoc.setY(finalLoc.getY()-linesdistance);
WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle();
EntityArmorStand stand = new EntityArmorStand(s);
NmsSpawn(stand, newline, finalLoc);
this.NmsArmorLines.set(ind, stand);
this.lines.set(ind, newline);
NmsDestroy(oldstand);
}
else{
this.lines.set(ind, newline);
final EntityArmorStand oldstand = NmsArmorLines.get(ind);
NmsDestroy(oldstand);
}
}
ind++;
}
else{
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(ind>0) finalLoc = getNmsLocation(NmsArmorLines.get(ind-1)); finalLoc.setY(finalLoc.getY()-linesdistance);
WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle();
EntityArmorStand stand = new EntityArmorStand(s);
NmsSpawn(stand, newline, finalLoc);
this.NmsArmorLines.add(stand);
this.lines.add(newline);
}
}
if(lines.size() > this.lines.size()){
int dif = lines.size() - this.lines.size();
for(int in = 0; in <=dif; in++){
int arrayind = (this.lines.size()-1)-in;
this.lines.remove(arrayind);
NmsDestroy(this.NmsArmorLines.get(arrayind));
this.NmsArmorLines.remove(arrayind);
}
}
}
else{
int ind = 0;
for(String newline : lines){
if(this.lines.size()>= ind){
String oldline = this.lines.get(ind);
if(!newline.equals(oldline)){
if(newline != ""){
this.armor_lines.get(ind).setCustomName(newline);
}
else{
this.lines.set(ind, newline);
final ArmorStand oldstand = armor_lines.get(ind);
oldstand.remove();
}
}
ind++;
}
else{
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(ind>0) finalLoc = armor_lines.get(ind-1).getLocation(); finalLoc.setY(finalLoc.getY()-linesdistance);
ArmorStand Armorline = (ArmorStand) location.getWorld().spawnEntity(finalLoc, EntityType.ARMOR_STAND);
Armorline.setBasePlate(false);
Armorline.setCustomNameVisible(true);
Armorline.setGravity(false);
Armorline.setCanPickupItems(false);
Armorline.setCustomName(newline);
Armorline.setSmall(true);
Armorline.setVisible(false);
armor_lines.add(Armorline);
this.lines.add(newline);
}
}
if(lines.size() > this.lines.size()){
int dif = lines.size() - this.lines.size();
for(int in = 0; in <=dif; in++){
int arrayind = (this.lines.size()-1)-in;
this.lines.remove(arrayind);
this.armor_lines.get(arrayind).remove();
this.armor_lines.remove(arrayind);
}
}
}
}
public void updateLine(int index, String text){
if(this.lines.size() >= index){
int realindex = (this.lines.size()-1)-index;
String oldtext = this.lines.get(realindex);
if(!text.equals(oldtext)){
if(this.player != null){
if(text != ""){
final EntityArmorStand oldstand = NmsArmorLines.get(realindex);
Location finalLoc = location.clone();
finalLoc.setY(location.getY()+(linesdistance*lines.size()));
if(realindex>0) finalLoc = getNmsLocation(NmsArmorLines.get(realindex-1)); finalLoc.setY(finalLoc.getY()-linesdistance);
WorldServer s = ((CraftWorld)this.location.getWorld()).getHandle();
EntityArmorStand stand = new EntityArmorStand(s);
NmsSpawn(stand, text, finalLoc);
this.NmsArmorLines.set(realindex, stand);
NmsDestroy(oldstand);
}
else{
this.lines.set(realindex, text);
final EntityArmorStand oldstand = NmsArmorLines.get(realindex);
NmsDestroy(oldstand);
}
}
else{
if(text != ""){
this.armor_lines.get(realindex).setCustomName(text);
}
else{
final ArmorStand oldstand = armor_lines.get(realindex);
oldstand.remove();
}
}
this.lines.set(realindex, text);
}
}
}
public void removeLine(int index){
if(this.lines.size() >= index){
int realindex = (this.lines.size()-1)-index;
if(this.player != null){
final EntityArmorStand stand = NmsArmorLines.get(realindex);
this.NmsArmorLines.remove(stand);
NmsDestroy(stand);
}
else{
this.armor_lines.get(realindex).remove();
}
this.lines.remove(realindex);
}
}
public void delete(){
despawn();
this.player = null;
this.NmsArmorLines = new ArrayList<EntityArmorStand>();
this.armor_lines = new ArrayList<ArmorStand>();
this.lines = new ArrayList<String>();
this.location = null;
}
}

85
MultiArena-TheBridge/src/cx/sfy/TheBridge/hooks/PlaceholderHook.java

@ -0,0 +1,85 @@
package cx.sfy.TheBridge.hooks;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import cx.sfy.TheBridge.database.PlayerStat;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
public class PlaceholderHook extends PlaceholderExpansion {
private Plugin p;
public PlaceholderHook(Plugin p) {
this.p = p;
}
@Override
public String getAuthor() {
return "Stefatorus";
}
@Override
public String getIdentifier() {
return "bridges";
}
@Override
public String getPlugin() {
return p.getDescription().getName();
}
@Override
public String getVersion() {
return p.getDescription().getVersion();
}
@Override
public String onPlaceholderRequest(Player p, String id) {
if (p == null || !p.isOnline()){
return null;
}
PlayerStat ps = PlayerStat.getPlayerStat(p);
if (id.equals("normal_kills")) {
return String.valueOf(ps.getNormalKills());
}
if (id.equals("normal_wins")) {
return String.valueOf(ps.getNormalWins());
}
if (id.equals("normal_goals")) {
return String.valueOf(ps.getNormalGoals());
}
if (id.equals("four_kills")) {
return String.valueOf(ps.getFourKills());
}
if (id.equals("four_wins")) {
return String.valueOf(ps.getFourWins());
}
if (id.equals("four_goals")) {
return String.valueOf(ps.getFourGoals());
}
if (id.equals("global_kills")) {
return String.valueOf(ps.getFourKills() + ps.getNormalKills());
}
if (id.equals("global_wins")) {
return String.valueOf(ps.getFourWins() + ps.getNormalWins());
}
if (id.equals("global_goals")) {
return String.valueOf(ps.getFourGoals() + ps.getNormalGoals());
}
if (id.equals("coins")) {
return String.valueOf(ps.getCoins());
}
if (id.equals("xp")) {
return String.valueOf(ps.getXP());
}
if (id.equals("blocks_placed")) {
return String.valueOf(ps.getPlaced());
}
if (id.equals("blocks_broken")) {
return String.valueOf(ps.getBroken());
}
return null;
}
}

87
MultiArena-TheBridge/src/cx/sfy/TheBridge/kit/Hotbar.java

@ -0,0 +1,87 @@
package cx.sfy.TheBridge.kit;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.scheduler.BukkitRunnable;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.database.PlayerStat;
import cx.sfy.TheBridge.game.InventoryData;
import cx.sfy.TheBridge.utils.ItemBuilder;
public class Hotbar {
Main plugin;
public Hotbar(Main plugin) {
this.plugin = plugin;
}
public void createHotbarMenu(Player p) {
Inventory inv = Bukkit.getServer().createInventory(null, 54, plugin.getLang().get("menus.hotbar.title"));
ItemStack [] items = plugin.getGM().getKit().getContents();
ItemStack glass = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short)7);
ItemMeta glassM = glass.getItemMeta();
glassM.setDisplayName("§a↑ §eInventory");
List<String> lore = new ArrayList<String>();
lore.add("§a↓ §eHotbar");
glassM.setLore(lore);
glass.setItemMeta(glassM);
ItemStack save = ItemBuilder.item(Material.CHEST, 1, (short)0, plugin.getLang().get("menus.save.nameItem"), plugin.getLang().get("menus.save.loreItem"));
ItemStack close = ItemBuilder.item(Material.BARRIER, 1, (short)0, plugin.getLang().get("menus.close.nameItem"), plugin.getLang().get("menus.close.loreItem"));
for (int i = 0; i < 9; i++) {
if (items[i] != null) {
inv.setItem(i + 36, items[i]);
}
}
for (int i = 27; i < 36; i++) {
inv.setItem(i, glass);
}
inv.setItem(49, save);
inv.setItem(50, close);
new InventoryData(p);
new BukkitRunnable() {
@Override
public void run() {
if (!p.getOpenInventory().getTitle().equals(plugin.getLang().get("menus.hotbar.title"))) {
InventoryData itd = InventoryData.getInventoryData(p);
if (itd == null) {
return;
}
InventoryData.remove(p);
cancel();
}
}
}.runTaskTimer(plugin, 0, 0);
p.openInventory(inv);
}
public void saveLayout(Player p, Inventory inv) {
Inventory pinv = Bukkit.getServer().createInventory(null, 36);
for (int i = 0; i < 27; i++) {
if (inv.getItem(i) == null || inv.getItem(i).getType() == Material.AIR) {
pinv.setItem(i + 9, new ItemStack(Material.BARRIER));
} else {
pinv.setItem(i + 9, inv.getItem(i));
}
}
for (int i = 36; i < 45; i++) {
if (inv.getItem(i) == null || inv.getItem(i).getType() == Material.AIR) {
pinv.setItem(i - 36, new ItemStack(Material.BARRIER));
} else {
pinv.setItem(i - 36, inv.getItem(i));
}
}
PlayerStat ps = PlayerStat.getPlayerStat(p);
ps.setHotbar(pinv.getContents());
p.sendMessage(plugin.getLang().get("messages.hotbarSaved"));
}
}

82
MultiArena-TheBridge/src/cx/sfy/TheBridge/kit/Kit.java

@ -0,0 +1,82 @@
package cx.sfy.TheBridge.kit;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.bukkit.Bukkit;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.util.io.BukkitObjectInputStream;
import org.bukkit.util.io.BukkitObjectOutputStream;
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
public class Kit {
public String playerInventoryToBase64(PlayerInventory playerInventory) throws IllegalStateException {
String content = toBase64(playerInventory);
return content;
}
public String itemStackArrayToBase64(ItemStack[] items) throws IllegalStateException {
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
dataOutput.writeInt(items.length);
for (int i = 0; i < items.length; i++) {
dataOutput.writeObject(items[i]);
}
dataOutput.close();
return Base64Coder.encodeLines(outputStream.toByteArray());
} catch (Exception e) {
throw new IllegalStateException("Unable to save item stacks.", e);
}
}
public String toBase64(Inventory inventory) throws IllegalStateException {
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
dataOutput.writeInt(inventory.getSize());
for (int i = 0; i < inventory.getSize(); i++) {
dataOutput.writeObject(inventory.getItem(i));
}
dataOutput.close();
return Base64Coder.encodeLines(outputStream.toByteArray());
} catch (Exception e) {
throw new IllegalStateException("Unable to save item stacks.", e);
}
}
public Inventory fromBase64(String data) throws IOException {
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
Inventory inventory = Bukkit.getServer().createInventory(null, dataInput.readInt());
for (int i = 0; i < inventory.getSize(); i++) {
inventory.setItem(i, (ItemStack) dataInput.readObject());
}
dataInput.close();
return inventory;
} catch (ClassNotFoundException e) {
throw new IOException("Unable to decode class type.", e);
}
}
public ItemStack[] itemStackArrayFromBase64(String data) throws IOException {
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
ItemStack[] items = new ItemStack[dataInput.readInt()];
for (int i = 0; i < items.length; i++) {
items[i] = (ItemStack) dataInput.readObject();
}
dataInput.close();
return items;
} catch (ClassNotFoundException e) {
throw new IOException("Unable to decode class type.", e);
}
}
}

22
MultiArena-TheBridge/src/cx/sfy/TheBridge/leaderheads/TheBridgeFourGoals.java

@ -0,0 +1,22 @@
package cx.sfy.TheBridge.leaderheads;
import java.util.Arrays;
import org.bukkit.entity.Player;
import cx.sfy.TheBridge.database.PlayerStat;
import me.robin.leaderheads.datacollectors.OnlineDataCollector;
import me.robin.leaderheads.objects.BoardType;
public class TheBridgeFourGoals extends OnlineDataCollector {
public TheBridgeFourGoals() {
super("bridges-f-goals", "TheBridge", BoardType.DEFAULT, "&bBridges Four - Kills", "bridgesfgoals", Arrays.asList("&c----------", "&a{name}", "&e{amount} goals", "&c----------"));
}
@Override
public Double getScore(Player p) {
return (double)PlayerStat.getPlayerStat(p).getFourGoals();
}
}

22
MultiArena-TheBridge/src/cx/sfy/TheBridge/leaderheads/TheBridgeFourKills.java

@ -0,0 +1,22 @@
package cx.sfy.TheBridge.leaderheads;
import java.util.Arrays;
import org.bukkit.entity.Player;
import cx.sfy.TheBridge.database.PlayerStat;
import me.robin.leaderheads.datacollectors.OnlineDataCollector;
import me.robin.leaderheads.objects.BoardType;
public class TheBridgeFourKills extends OnlineDataCollector {
public TheBridgeFourKills() {
super("bridges-f-kills", "TheBridge", BoardType.DEFAULT, "&bBridges Four - Kills", "bridgesfkills", Arrays.asList("&c----------", "&a{name}", "&e{amount} kills", "&c----------"));
}
@Override
public Double getScore(Player p) {
return (double)PlayerStat.getPlayerStat(p).getFourKills();
}
}

22
MultiArena-TheBridge/src/cx/sfy/TheBridge/leaderheads/TheBridgeFourWins.java

@ -0,0 +1,22 @@
package cx.sfy.TheBridge.leaderheads;
import java.util.Arrays;
import org.bukkit.entity.Player;
import cx.sfy.TheBridge.database.PlayerStat;
import me.robin.leaderheads.datacollectors.OnlineDataCollector;
import me.robin.leaderheads.objects.BoardType;
public class TheBridgeFourWins extends OnlineDataCollector {
public TheBridgeFourWins() {
super("bridges-f-wins", "TheBridge", BoardType.DEFAULT, "&bBridges Four - Wins", "bridgesfwins", Arrays.asList("&c----------", "&a{name}", "&e{amount} wins", "&c----------"));
}
@Override
public Double getScore(Player p) {
return (double)PlayerStat.getPlayerStat(p).getFourWins();
}
}

22
MultiArena-TheBridge/src/cx/sfy/TheBridge/leaderheads/TheBridgeNormalGoals.java

@ -0,0 +1,22 @@
package cx.sfy.TheBridge.leaderheads;
import java.util.Arrays;
import org.bukkit.entity.Player;
import cx.sfy.TheBridge.database.PlayerStat;
import me.robin.leaderheads.datacollectors.OnlineDataCollector;
import me.robin.leaderheads.objects.BoardType;
public class TheBridgeNormalGoals extends OnlineDataCollector {
public TheBridgeNormalGoals() {
super("bridges-n-goals", "TheBridge", BoardType.DEFAULT, "&bBridges Normal - Goals", "bridgesngoals", Arrays.asList("&c----------", "&a{name}", "&e{amount} goals", "&c----------"));
}
@Override
public Double getScore(Player p) {
return (double)PlayerStat.getPlayerStat(p).getNormalKills();
}
}

22
MultiArena-TheBridge/src/cx/sfy/TheBridge/leaderheads/TheBridgeNormalKills.java

@ -0,0 +1,22 @@
package cx.sfy.TheBridge.leaderheads;
import java.util.Arrays;
import org.bukkit.entity.Player;
import cx.sfy.TheBridge.database.PlayerStat;
import me.robin.leaderheads.datacollectors.OnlineDataCollector;
import me.robin.leaderheads.objects.BoardType;
public class TheBridgeNormalKills extends OnlineDataCollector {
public TheBridgeNormalKills() {
super("bridges-n-kills", "TheBridge", BoardType.DEFAULT, "&bBridges Normal - Kills", "bridgesnkills", Arrays.asList("&c----------", "&a{name}", "&e{amount} kills", "&c----------"));
}
@Override
public Double getScore(Player p) {
return (double)PlayerStat.getPlayerStat(p).getNormalKills();
}
}

22
MultiArena-TheBridge/src/cx/sfy/TheBridge/leaderheads/TheBridgeNormalWins.java

@ -0,0 +1,22 @@
package cx.sfy.TheBridge.leaderheads;
import java.util.Arrays;
import org.bukkit.entity.Player;
import cx.sfy.TheBridge.database.PlayerStat;
import me.robin.leaderheads.datacollectors.OnlineDataCollector;
import me.robin.leaderheads.objects.BoardType;
public class TheBridgeNormalWins extends OnlineDataCollector {
public TheBridgeNormalWins() {
super("bridges-n-wins", "TheBridge", BoardType.DEFAULT, "&bBridges Normal - Wins", "bridgesnwins", Arrays.asList("&c----------", "&a{name}", "&e{amount} wins", "&c----------"));
}
@Override
public Double getScore(Player p) {
return (double)PlayerStat.getPlayerStat(p).getNormalWins();
}
}

1421
MultiArena-TheBridge/src/cx/sfy/TheBridge/listeners/PlayerListener.java

File diff suppressed because it is too large

159
MultiArena-TheBridge/src/cx/sfy/TheBridge/listeners/SetupListener.java

@ -0,0 +1,159 @@
package cx.sfy.TheBridge.listeners;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.game.Game;
import cx.sfy.TheBridge.game.GameFour;
import cx.sfy.TheBridge.game.Game.State;
import cx.sfy.TheBridge.game.GameFour.FState;;
public class SetupListener implements Listener {
Main plugin;
public SetupListener(Main plugin) {
this.plugin = plugin;
}
@SuppressWarnings("deprecation")
@EventHandler
public void onInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
if (p.getItemInHand() == null || p.getItemInHand().getType() == Material.AIR) {
return;
}
ItemStack item = p.getItemInHand();
if (item.getType() == Material.BLAZE_ROD && item.getItemMeta().getDisplayName().equalsIgnoreCase("§eSetup TheBridge")) {
if (e.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
plugin.getSM().setMax(p, e.getClickedBlock().getLocation());
e.setCancelled(true);
}
if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
plugin.getSM().setMin(p, e.getClickedBlock().getLocation());
e.setCancelled(true);
}
}
}
@EventHandler
public void onSignChange(SignChangeEvent e) {
Player p = e.getPlayer();
if (!p.hasPermission("bridges.admin")) {
return;
}
if (e.getLine(0).equals("[bridges]")) {
if (e.getLine(1).toLowerCase().equals("normal")) {
String game = e.getLine(2);
Sign sign = (Sign)e.getBlock().getState();
if (plugin.getGM().getGameByName(game) == null) {
p.sendMessage("§cThis Game not exits.");
return;
}
Game gname = plugin.getGM().getGameByName(game);
plugin.getSIM().createSign(e.getBlock().getLocation(), game, sign);
e.setLine(0, plugin.getLang().get("signs.normal.line-1").replaceAll("<state>", getState(gname.getState())).replaceAll("<name>", game).replaceAll("<players>", String.valueOf(gname.getPlayers())).replaceAll("<max>", String.valueOf(gname.getMax())));
e.setLine(1, plugin.getLang().get("signs.normal.line-2").replaceAll("<state>", getState(gname.getState())).replaceAll("<name>", game).replaceAll("<players>", String.valueOf(gname.getPlayers())).replaceAll("<max>", String.valueOf(gname.getMax())));
e.setLine(2, plugin.getLang().get("signs.normal.line-3").replaceAll("<state>", getState(gname.getState())).replaceAll("<name>", game).replaceAll("<players>", String.valueOf(gname.getPlayers())).replaceAll("<max>", String.valueOf(gname.getMax())));
e.setLine(3, plugin.getLang().get("signs.normal.line-4").replaceAll("<state>", getState(gname.getState())).replaceAll("<name>", game).replaceAll("<players>", String.valueOf(gname.getPlayers())).replaceAll("<max>", String.valueOf(gname.getMax())));
p.sendMessage("§aSign Normal added.");
} else if (e.getLine(1).toLowerCase().equals("four")) {
String game = e.getLine(2);
Sign sign = (Sign)e.getBlock().getState();
if (plugin.getGM().getGameFourByName(game) == null) {
p.sendMessage("§cThis Game not exits.");
return;
}
GameFour gname = plugin.getGM().getGameFourByName(game);
plugin.getSIM().createFourSign(e.getBlock().getLocation(), game, sign);
e.setLine(0, plugin.getLang().get("signs.four.line-1").replaceAll("<state>", getState(gname.getState())).replaceAll("<name>", game).replaceAll("<players>", String.valueOf(gname.getPlayers().size())).replaceAll("<max>", String.valueOf(gname.getMax())));
e.setLine(1, plugin.getLang().get("signs.four.line-2").replaceAll("<state>", getState(gname.getState())).replaceAll("<name>", game).replaceAll("<players>", String.valueOf(gname.getPlayers().size())).replaceAll("<max>", String.valueOf(gname.getMax())));
e.setLine(2, plugin.getLang().get("signs.four.line-3").replaceAll("<state>", getState(gname.getState())).replaceAll("<name>", game).replaceAll("<players>", String.valueOf(gname.getPlayers().size())).replaceAll("<max>", String.valueOf(gname.getMax())));
e.setLine(3, plugin.getLang().get("signs.four.line-4").replaceAll("<state>", getState(gname.getState())).replaceAll("<name>", game).replaceAll("<players>", String.valueOf(gname.getPlayers().size())).replaceAll("<max>", String.valueOf(gname.getMax())));
p.sendMessage("§aSign Four added.");
}
}
}
protected String getState(State state) {
if (state == State.WAITING) {
return plugin.getLang().get("states.waiting");
}
if (state == State.STARTING) {
return plugin.getLang().get("states.starting");
}
if (state == State.PREGAME) {
return plugin.getLang().get("states.pregame");
}
if (state == State.INGAME) {
return plugin.getLang().get("states.ingame");
}
if (state == State.FINISH) {
return plugin.getLang().get("states.finish");
}
if (state == State.RESTARTING) {
return plugin.getLang().get("states.restarting");
}
return "";
}
protected String getState(FState state) {
if (state == FState.WAITING) {
return plugin.getLang().get("states.waiting");
}
if (state == FState.STARTING) {
return plugin.getLang().get("states.starting");
}
if (state == FState.PREGAME) {
return plugin.getLang().get("states.pregame");
}
if (state == FState.INGAME) {
return plugin.getLang().get("states.ingame");
}
if (state == FState.FINISH) {
return plugin.getLang().get("states.finish");
}
if (state == FState.RESTARTING) {
return plugin.getLang().get("states.restarting");
}
return "";
}
@EventHandler
public void onBreak(BlockBreakEvent e) {
Player p = e.getPlayer();
if (!p.hasPermission("bridges.admin")) {
return;
}
if (plugin.getSIM().getSigns().keySet().contains(e.getBlock().getLocation())) {
plugin.getSigns().set("signs.normal." + plugin.getSIM().getSigns().get(e.getBlock().getLocation()).getGame(), null);
plugin.getSigns().save();
p.sendMessage("§cSign normal removed.");
} else if (plugin.getSIM().getFourSigns().keySet().contains(e.getBlock().getLocation())) {
plugin.getSigns().set("signs.four." + plugin.getSIM().getFourSigns().get(e.getBlock().getLocation()).getGame(), null);
plugin.getSigns().save();
p.sendMessage("§cSign four removed.");
}
}
public String getLocationString(Location loc){
String world = loc.getWorld().getName();
double x = loc.getX();
double y = loc.getY();
double z = loc.getZ();
float yaw = loc.getYaw();
float pitch = loc.getPitch();
return world + ";" + x + ";" + y + ";" + z + ";" + yaw + ";" + pitch;
}
}

393
MultiArena-TheBridge/src/cx/sfy/TheBridge/listeners/SpectatorListener.java

@ -0,0 +1,393 @@
package cx.sfy.TheBridge.listeners;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Egg;
import org.bukkit.entity.EnderPearl;
import org.bukkit.entity.Entity;
import org.bukkit.entity.ExperienceOrb;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.Snowball;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockCanBuildEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.PotionSplashEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.event.vehicle.VehicleEnterEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.game.GameFour;
public class SpectatorListener implements Listener {
public Main plugin;
public SpectatorListener(Main plugin) {
this.plugin = plugin;
}
@EventHandler
public void onBlockPlace(BlockPlaceEvent e) {
final GameFour game = plugin.getGM().getGameFourByPlayer(e.getPlayer());
if (game == null)
return;
if (game.getSpects().contains(e.getPlayer()))
e.setCancelled(true);
}
@EventHandler
public void onDrop(PlayerDropItemEvent e) {
final GameFour game = plugin.getGM().getGameFourByPlayer(e.getPlayer());
if (game == null)
return;
if (game.getSpects().contains(e.getPlayer()))
e.setCancelled(true);
}
@EventHandler
public void onChest(PlayerInteractEvent e) {
final GameFour game = plugin.getGM().getGameFourByPlayer(e.getPlayer());
if (game == null)
return;
if (game.getSpects().contains(e.getPlayer()))
if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK) && e.getClickedBlock().getType() == Material.CHEST || e.getAction().equals(Action.LEFT_CLICK_BLOCK) && e.getClickedBlock().getType() == Material.CHEST)
e.setCancelled(true);
}
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
final GameFour game = plugin.getGM().getGameFourByPlayer((Player)e.getWhoClicked());
if (game == null)
return;
if (game.getSpects().contains(e.getWhoClicked())) {
if (e.getClick().isShiftClick()) {
final Inventory clicked = e.getClickedInventory();
if (clicked == e.getWhoClicked().getInventory()) {
final ItemStack clickedOn = e.getCurrentItem();
if (clickedOn != null)
e.setCancelled(true);
}
}
final Inventory clicked = e.getClickedInventory();
if (clicked != e.getWhoClicked().getInventory()) {
final ItemStack onCursor = e.getCursor();
if (onCursor != null)
e.setCancelled(true);
}
}
}
@EventHandler
public void onDrag(InventoryDragEvent e) {
final GameFour game = plugin.getGM().getGameFourByPlayer((Player)e.getWhoClicked());
if (game == null)
return;
if (game.getSpects().contains(e.getWhoClicked()))
e.setCancelled(true);
}
@EventHandler
protected void onBlockCanBuild(BlockCanBuildEvent e) {
if (!e.isBuildable()) {
final Location blockL = e.getBlock().getLocation();
boolean allowed = false;
for (final Player target : Bukkit.getServer().getOnlinePlayers()) {
final GameFour game = plugin.getGM().getGameFourByPlayer(target);
if (game == null)
return;
if (target.getWorld().equals(e.getBlock().getWorld()) && game.getSpects().contains(target)) {
final Location playerL = target.getLocation();
if (playerL.getX() > blockL.getBlockX()-1 && playerL.getX() < blockL.getBlockX()+1)
if (playerL.getZ() > blockL.getBlockZ()-1 && playerL.getZ() < blockL.getBlockZ()+1)
if (playerL.getY() > blockL.getBlockY()-2 && playerL.getY() < blockL.getBlockY()+1)
if (game.getSpects().contains(target)) {
allowed = true;
target.teleport(e.getBlock().getLocation().add(0, 5, 0), TeleportCause.PLUGIN);
} else {
allowed = false;
break;
}
}
}
e.setBuildable(allowed);
}
}
@EventHandler
public void onPlayer(BlockPlaceEvent e) {
final Location location = e.getBlock().getLocation();
final GameFour game = plugin.getGM().getGameFourByPlayer(e.getPlayer());
if (game == null)
return;
for (final Player on : Bukkit.getOnlinePlayers())
if (game.getSpects().contains(on)) {
final Location location2 = on.getLocation();
if (location2.getX() > location.getBlockX() - 1 && location2.getX() < location.getBlockX() + 1 && location2.getZ() > location.getBlockZ() - 1 && location2.getZ() < location.getBlockZ() + 1 && location2.getY() > location.getBlockY() - 2 && location2.getY() < location.getBlockY() + 1)
on.teleport(on.getLocation().add(5, 5, 5));
}
}
@EventHandler
protected void onEntityDamageEvent(EntityDamageByEntityEvent e) {
if (e.getDamager() instanceof Player && e.getEntity() instanceof Player) {
final GameFour game = plugin.getGM().getGameFourByPlayer((Player)e.getDamager());
if (game == null)
return;
if ((!e.getDamager().hasMetadata("NPC") && game.getSpects().contains(e.getDamager())) || (!e.getEntity().hasMetadata("NPC") && game.getSpects().contains(e.getEntity())))
e.setCancelled(true);
} else if (!(e.getEntity() instanceof Player) && e.getDamager() instanceof Player) {
final GameFour game = plugin.getGM().getGameFourByPlayer((Player)e.getDamager());
if (game == null)
return;
if (!e.getDamager().hasMetadata("NPC") && game.getSpects().contains(e.getDamager()))
e.setCancelled(true);
} else if (e.getEntity() instanceof Player && !(e.getDamager() instanceof Player)) {
final GameFour game = plugin.getGM().getGameFourByPlayer((Player)e.getEntity());
if (game == null)
return;
if (!e.getEntity().hasMetadata("NPC") && game.getSpects().contains(e.getEntity()))
e.setCancelled(true);
}
GameFour game = null;
if (e.getEntity() instanceof Player)
game = plugin.getGM().getGameFourByPlayer((Player)e.getEntity());
if (game == null)
return;
if(e.getDamager() instanceof Projectile
&& !(e.getDamager() instanceof ThrownPotion)
&& !e.getEntity().hasMetadata("NPC")
&& game.getSpects().contains(e.getEntity())) {
e.setCancelled(true);
e.getDamager().remove();
final Player spectatorInvolved = (Player) e.getEntity();
final boolean wasFlying = spectatorInvolved.isFlying();
final Location initialSpectatorLocation = spectatorInvolved.getLocation();
final Vector initialProjectileVelocity = e.getDamager().getVelocity();
final Location initialProjectileLocation = e.getDamager().getLocation();
final Projectile proj = (Projectile) e.getDamager();
if (spectatorInvolved != proj.getShooter()) {
spectatorInvolved.setAllowFlight(true);
spectatorInvolved.setFlying(true);
spectatorInvolved.teleport(initialSpectatorLocation.clone().add(0, 6, 0), TeleportCause.PLUGIN);
Bukkit.getScheduler().runTaskLater(plugin, () -> {
if (proj instanceof Arrow) {
final Arrow arrow = initialProjectileLocation.getWorld().spawn(initialProjectileLocation, Arrow.class);
arrow.setBounce(false);
arrow.setVelocity(initialProjectileVelocity);
arrow.setShooter(proj.getShooter());
} else if (proj instanceof Snowball) {
final Snowball snowball = initialProjectileLocation.getWorld().spawn(initialProjectileLocation, Snowball.class);
snowball.setVelocity(initialProjectileVelocity);
snowball.setShooter(proj.getShooter());
} else if (proj instanceof Egg) {
final Egg egg = initialProjectileLocation.getWorld().spawn(initialProjectileLocation, Egg.class);
egg.setVelocity(initialProjectileVelocity);
egg.setShooter(proj.getShooter());
} else if (proj instanceof EnderPearl) {
final Player p = (Player) proj.getShooter();
p.launchProjectile(EnderPearl.class, initialProjectileVelocity);
}
}, 1L);
Bukkit.getScheduler().runTaskLater(plugin, () -> {
spectatorInvolved.teleport(new Location(initialSpectatorLocation.getWorld(), initialSpectatorLocation.getX(), initialSpectatorLocation.getY(), initialSpectatorLocation.getZ(), spectatorInvolved.getLocation().getYaw(), spectatorInvolved.getLocation().getPitch()), TeleportCause.PLUGIN);
spectatorInvolved.setAllowFlight(true);
spectatorInvolved.setFlying(wasFlying);
}, 5L);
}
}
}
@EventHandler(priority = EventPriority.HIGHEST)
protected void onPotionSplash(PotionSplashEvent e) {
final ArrayList<UUID> spectatorsAffected = new ArrayList<>();
GameFour game = null;
if (e.getEntity().getShooter() instanceof Player)
game = plugin.getGM().getGameFourByPlayer((Player)e.getEntity().getShooter());
for(final LivingEntity player : e.getAffectedEntities())
if(player instanceof Player && !player.hasMetadata("NPC") && game.getSpects().contains(player))
spectatorsAffected.add(player.getUniqueId());
if(!spectatorsAffected.isEmpty()) {
Boolean teleportationNeeded = false;
for(final Entity entity : e.getEntity().getNearbyEntities(2, 2, 2))
if(entity instanceof Player && !entity.hasMetadata("NPC") && game.getSpects().contains(entity))
teleportationNeeded = true;
final HashMap<UUID,Boolean> oldFlyMode = new HashMap<>();
for(final UUID spectatorUUID : spectatorsAffected) {
final Player spectator = Bukkit.getServer().getPlayer(spectatorUUID);
e.setIntensity(spectator, 0);
if(teleportationNeeded) {
oldFlyMode.put(spectator.getUniqueId(), spectator.isFlying());
spectator.setAllowFlight(true);
spectator.setFlying(true);
spectator.teleport(spectator.getLocation().add(0, 10, 0), TeleportCause.PLUGIN);
}
}
if(teleportationNeeded) {
final Location initialProjectileLocation = e.getEntity().getLocation();
final Vector initialProjectileVelocity = e.getEntity().getVelocity();
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> {
final ThrownPotion clonedEntity = (ThrownPotion) e.getEntity().getWorld().spawnEntity(initialProjectileLocation, e.getEntity().getType());
clonedEntity.setShooter(e.getEntity().getShooter());
clonedEntity.setTicksLived(e.getEntity().getTicksLived());
clonedEntity.setFallDistance(e.getEntity().getFallDistance());
clonedEntity.setBounce(e.getEntity().doesBounce());
if(e.getEntity().getPassenger() != null)
clonedEntity.setPassenger(e.getEntity().getPassenger());
clonedEntity.setItem(e.getEntity().getItem());
clonedEntity.setVelocity(initialProjectileVelocity);
e.getEntity().remove();
}, 1L);
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> {
for(final UUID spectatorUUID : spectatorsAffected) {
final Player spectator = Bukkit.getServer().getPlayer(spectatorUUID);
spectator.teleport(spectator.getLocation().add(0, -10, 0), TeleportCause.PLUGIN);
spectator.setAllowFlight(true);
spectator.setFlying(oldFlyMode.get(spectatorUUID));
}
}, 5L);
e.setCancelled(true);
}
}
}
@EventHandler
protected void onPlayerPickupItem(PlayerPickupItemEvent e) {
final GameFour game = plugin.getGM().getGameFourByPlayer(e.getPlayer());
if (game == null)
return;
if (game.getSpects().contains(e.getPlayer()))
e.setCancelled(true);
}
@EventHandler
protected void onEntityTarget(EntityTargetEvent e) {
GameFour game = null;
if (e.getTarget() instanceof Player)
game = plugin.getGM().getGameFourByPlayer((Player)e.getTarget());
if (game == null)
return;
if (e.getTarget() != null && e.getTarget() instanceof Player && !e.getTarget().hasMetadata("NPC") && game.getSpects().contains(e.getTarget()))
e.setCancelled(true);
if (e.getTarget() instanceof Player && e.getTarget() != null && game.getSpects().contains(e.getTarget()))
if (e.getEntity() instanceof ExperienceOrb) {
repellExpOrb((Player) e.getTarget(), (ExperienceOrb) e.getEntity());
e.setCancelled(true);
e.setTarget(null);
}
}
@EventHandler
protected void onBlockDamage(BlockDamageEvent e) {
final GameFour game = plugin.getGM().getGameFourByPlayer(e.getPlayer());
if (game == null)
return;
if (game.getSpects().contains(e.getPlayer()))
e.setCancelled(true);
}
@EventHandler
protected void onEntityDamage(EntityDamageEvent e) {
GameFour game = null;
if (e.getEntity() instanceof Player)
game = plugin.getGM().getGameFourByPlayer((Player)e.getEntity());
if (game == null)
return;
if (e.getEntity() instanceof Player && !e.getEntity().hasMetadata("NPC") && game.getSpects().contains(e.getEntity())) {
e.setCancelled(true);
e.getEntity().setFireTicks(0);
}
}
@EventHandler
protected void onFoodLevelChange(FoodLevelChangeEvent e) {
GameFour game = null;
if (e.getEntity() instanceof Player)
game = plugin.getGM().getGameFourByPlayer((Player)e.getEntity());
if (game == null)
return;
if (e.getEntity() instanceof Player && !e.getEntity().hasMetadata("NPC") && game.getSpects().contains(e.getEntity())) {
e.setCancelled(true);
((Player) e.getEntity()).setFoodLevel(20);
((Player) e.getEntity()).setSaturation(20);
}
}
@EventHandler
public void onInventoryDrag(InventoryDragEvent e) {
final GameFour game = plugin.getGM().getGameFourByPlayer((Player)e.getWhoClicked());
if (game == null)
return;
if (game.getSpects().contains(e.getWhoClicked()))
e.setCancelled(true);
}
@EventHandler
public void onVehicleEnter(VehicleEnterEvent e) {
GameFour game = null;
if (e.getEntered() instanceof Player)
game = plugin.getGM().getGameFourByPlayer((Player)e.getEntered());
if (game == null)
return;
if (e.getEntered() instanceof Player && game.getSpects().contains(e.getEntered()))
e.setCancelled(true);
}
void repellExpOrb(Player player, ExperienceOrb orb) {
final Location pLoc = player.getLocation();
final Location oLoc = orb.getLocation();
final Vector dir = oLoc.toVector().subtract(pLoc.toVector());
final double dx = Math.abs(dir.getX());
final double dz = Math.abs(dir.getZ());
if ( (dx == 0.0) && (dz == 0.0))
dir.setX(0.001);
if ((dx < 3.0) && (dz < 3.0)){
final Vector nDir = dir.normalize();
final Vector newV = nDir.clone().multiply(0.3);
newV.setY(0);
orb.setVelocity(newV);
if ((dx < 1.0) && (dz < 1.0))
orb.teleport(oLoc.clone().add(nDir.multiply(1.0)), TeleportCause.PLUGIN);
if ((dx < 0.5) && (dz < 0.5))
orb.remove();
}
}
}

82
MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/ArchiManager.java

@ -0,0 +1,82 @@
package cx.sfy.TheBridge.managers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.archievements.Archi;
import cx.sfy.TheBridge.archievements.ArchiType;
public class ArchiManager {
Main plugin;
private HashMap<ArchiType, ArrayList<Archi>> archiements = new HashMap<ArchiType, ArrayList<Archi>>();
private ItemStack unlocked = null;
private ItemStack locked = null;
public ArchiManager(Main plugin) {
this.plugin = plugin;
loadArchievements();
}
public void loadArchievements() {
ItemStack unlocked1 = new ItemStack(Material.valueOf(plugin.getAchievement().get("unlocked.item")), plugin.getAchievement().getInt("unlocked.amount"), (short)plugin.getAchievement().getInt("unlocked.data"));
ItemMeta unlockedM = unlocked1.getItemMeta();
unlockedM.setDisplayName(plugin.getAchievement().get("unlocked.name"));
List<String> un = new ArrayList<String>();
for (String u : plugin.getAchievement().getList("unlocked.lore")) {
un.add(u);
}
unlockedM.setLore(un);
unlocked1.setItemMeta(unlockedM);
unlocked = unlocked1;
ItemStack locked1 = new ItemStack(Material.valueOf(plugin.getAchievement().get("locked.item")), plugin.getAchievement().getInt("locked.amount"), (short)plugin.getAchievement().getInt("locked.data"));
ItemMeta lockedM = locked1.getItemMeta();
lockedM.setDisplayName(plugin.getAchievement().get("locked.name"));
List<String> lo = new ArrayList<String>();
for (String l : plugin.getAchievement().getList("locked.lore")) {
lo.add(l);
}
lockedM.setLore(lo);
locked1.setItemMeta(lockedM);
locked = locked1;
ConfigurationSection conf = plugin.getAchievement().getConfig().getConfigurationSection("archievements");
for (String msg : conf.getKeys(false)) {
ArchiType type = ArchiType.valueOf(plugin.getAchievement().get("archievements." + msg + ".type"));
if (!archiements.containsKey(type)) {
archiements.put(type, new ArrayList<Archi>());
archiements.get(type).add(new Archi(plugin, "archievements." + msg));
} else {
archiements.get(type).add(new Archi(plugin, "archievements." + msg));
}
}
}
public void check(Player p, int amount, ArchiType type) {
for (Archi archi : archiements.get(type)) {
if (archi.getMax() == amount) {
archi.execute(p);
}
}
}
public ItemStack getUnlocked() {
return unlocked;
}
public ItemStack getLocked() {
return locked;
}
public HashMap<ArchiType, ArrayList<Archi>> getArchiements() {
return archiements;
}
}

70
MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/CageManager.java

@ -0,0 +1,70 @@
package cx.sfy.TheBridge.managers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.configuration.ConfigurationSection;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.cosmetics.cages.Cage;
public class CageManager {
Main plugin;
private HashMap<String, Cage> cages = new HashMap<String, Cage>();
private List<String> unlocked = null;
private List<String> locked = null;
private List<String> noPerm = null;
public CageManager(Main plugin) {
this.plugin = plugin;
loadCages();
}
public void loadCages() {
List<String> un = new ArrayList<String>();
for (String u : plugin.getCages().getList("unlocked")) {
un.add(u);
}
unlocked = un;
List<String> lo = new ArrayList<String>();
for (String l : plugin.getCages().getList("locked")) {
lo.add(l);
}
locked = lo;
List<String> pe = new ArrayList<String>();
for (String p : plugin.getCages().getList("noPerm")) {
pe.add(p);
}
noPerm = pe;
ConfigurationSection conf = plugin.getCages().getConfig().getConfigurationSection("cages");
for (String cage : conf.getKeys(false)) {
cages.put(cage, new Cage(plugin, "cages." + cage, cage));
}
}
public Cage getCageByName(String name) {
if (cages.containsKey(name)) {
return cages.get(name);
}
return null;
}
public HashMap<String, Cage> getCages() {
return cages;
}
public List<String> getUnlocked() {
return unlocked;
}
public List<String> getLocked() {
return locked;
}
public List<String> getNoPerm() {
return noPerm;
}
}

44
MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/FileManager.java

@ -0,0 +1,44 @@
package cx.sfy.TheBridge.managers;
import java.io.File;
import java.io.IOException;
import org.bukkit.configuration.file.YamlConfiguration;
import cx.sfy.TheBridge.Main;
public class FileManager {
Main plugin;
public FileManager(Main plugin) {
this.plugin = plugin;
}
public void createNewFile(String file) {
File arenayml = new File(plugin.getDataFolder() + "/arenas", file + ".yml");
YamlConfiguration config = YamlConfiguration.loadConfiguration(arenayml);
try {
config.save(arenayml);
} catch (IOException e) {
e.printStackTrace();
}
}
public boolean arenaExists(String file) {
File folder = new File(plugin.getDataFolder() + "/arenas");
File[] listFiles = folder.listFiles();
String name = "";
for (int f = 0; f < listFiles.length; f++) {
if (listFiles[f].isFile()) {
File arena = listFiles[f];
name = arena.getName().replaceAll(".yml", "");
if (name.equals(file)) {
return true;
}
}
}
return false;
}
}

380
MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/GameManager.java

@ -0,0 +1,380 @@
package cx.sfy.TheBridge.managers;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.game.Game;
import cx.sfy.TheBridge.game.GameFour;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import net.md_5.bungee.api.ChatColor;
public class GameManager {
private ArrayList<Game> normalGames;
private ArrayList<GameFour> fourGames;
private HashMap<Player, Game> playerGame;
private HashMap<Player, GameFour> playerGameFour;
private Inventory kit;
Main plugin;
public GameManager(Main plugin) {
this.plugin = plugin;
this.normalGames = new ArrayList<>();
this.fourGames = new ArrayList<>();
this.playerGame = new HashMap<Player, Game>();
this.playerGameFour = new HashMap<Player, GameFour>();
this.kit = Bukkit.getServer().createInventory(null, InventoryType.PLAYER);
if (plugin.getConfig().getString("kit") == null) {
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "No hay un kit establecido. Usa " + ChatColor.YELLOW + "/bridges setkit");
} else {
try {
kit.setContents(plugin.getKit().fromBase64(plugin.getConfig().getString("kit")).getContents());
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
this.loadGames();
}
public void reloadKit() {
try {
kit.setContents(plugin.getKit().fromBase64(plugin.getConfig().getString("kit")).getContents());
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public Inventory getKit() {
return kit;
}
public void resetNormalGame(String file) {
Game prev = null;
for (Game game : normalGames) {
if (game.getName().equals(file)) {
prev = game;
}
}
normalGames.remove(prev);
File arena = new File(plugin.getDataFolder() + "/arenas/" + file + ".yml");
FileConfiguration yml = YamlConfiguration.loadConfiguration(arena);
String name = yml.getString("name");
if (yml.getString("locations.lobby") == null) {
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.RED + "El mapa " + ChatColor.YELLOW + name + " " + ChatColor.RED + "no tiene seteado el Lobby.");
}
if (yml.getString("locations.spect") == null) {
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.RED + "El mapa " + ChatColor.YELLOW + name + " " + ChatColor.RED + "no tiene seteado el Spectador.");
}
Location hRed = null;
Location hBlue = null;
if (yml.get("locations.holograms.red") != null) {
hRed = getStringLocation(yml.getString("locations.holograms.red"));
}
if (yml.get("locations.holograms.blue") != null) {
hBlue = getStringLocation(yml.getString("locations.holograms.blue"));
}
plugin.getWC().resetWorld(name);
int min = yml.getInt("minPlayers");
int teamSize = yml.getInt("teamSize");
int starting = yml.getInt("timers.starting");
int prestart = yml.getInt("timers.prestart");
int restart = yml.getInt("timers.restart");
String lobby = yml.getString("locations.lobby");
String spect = yml.getString("locations.spect");
String buildMin = yml.getString("locations.build.min");
String buildMax = yml.getString("locations.build.max");
String spawnsRed = yml.getString("locations.spawns.red");
String spawnsBlue = yml.getString("locations.spawns.blue");
String respawnsRed = yml.getString("locations.respawns.red");
String respawnsBlue = yml.getString("locations.respawns.blue");
ArrayList<Location> portalRed = new ArrayList<Location>();
for (String locRed : yml.getStringList("locations.portal.red")) {
portalRed.add(getStringLocation(locRed));
}
ArrayList<Location> portalBlue = new ArrayList<Location>();
for (String locBlue : yml.getStringList("locations.portal.blue")) {
portalBlue.add(getStringLocation(locBlue));
}
normalGames.add(new Game(plugin, name, min, 2 * teamSize, teamSize, starting, prestart, restart, getStringLocation(lobby), getStringLocation(spect), getStringLocation(buildMin), getStringLocation(buildMax), getStringLocation(spawnsRed), getStringLocation(spawnsBlue), portalRed, portalBlue, getStringLocation(respawnsRed), getStringLocation(respawnsBlue), hRed, hBlue));
}
public void resetFourGame(String file) {
GameFour prev = null;
for (GameFour game : fourGames) {
if (game.getName().equals(file)) {
prev = game;
}
}
fourGames.remove(prev);
File arena = new File(plugin.getDataFolder() + "/arenas/" + file + ".yml");
FileConfiguration yml = YamlConfiguration.loadConfiguration(arena);
String name = yml.getString("name");
plugin.getWC().resetWorld(name);
Location hRed = null;
Location hBlue = null;
Location hGreen = null;
Location hYellow = null;
if (yml.get("locations.holograms.red") != null) {
hRed = getStringLocation(yml.getString("locations.holograms.red"));
}
if (yml.get("locations.holograms.blue") != null) {
hBlue = getStringLocation(yml.getString("locations.holograms.blue"));
}
if (yml.get("locations.holograms.green") != null) {
hGreen = getStringLocation(yml.getString("locations.holograms.green"));
}
if (yml.get("locations.holograms.yellow") != null) {
hYellow = getStringLocation(yml.getString("locations.holograms.yellow"));
}
int min = yml.getInt("minPlayers");
int teamSize = yml.getInt("teamSize");
int starting = yml.getInt("timers.starting");
int prestart = yml.getInt("timers.prestart");
String lobby = yml.getString("locations.lobby");
String spect = yml.getString("locations.spect");
String buildMin = yml.getString("locations.build.min");
String buildMax = yml.getString("locations.build.max");
String spawnsRed = yml.getString("locations.spawns.red");
String spawnsBlue = yml.getString("locations.spawns.blue");
String spawnsGreen = yml.getString("locations.spawns.green");
String spawnsYellow = yml.getString("locations.spawns.yellow");
String respawnsRed = yml.getString("locations.respawns.red");
String respawnsBlue = yml.getString("locations.respawns.blue");
String respawnsGreen = yml.getString("locations.respawns.green");
String respawnsYellow = yml.getString("locations.respawns.yellow");
ArrayList<Location> portalRed = new ArrayList<Location>();
for (String locRed : yml.getStringList("locations.portal.red")) {
portalRed.add(getStringLocation(locRed));
}
ArrayList<Location> portalBlue = new ArrayList<Location>();
for (String locBlue : yml.getStringList("locations.portal.blue")) {
portalBlue.add(getStringLocation(locBlue));
}
ArrayList<Location> portalGreen = new ArrayList<Location>();
for (String locGreen : yml.getStringList("locations.portal.green")) {
portalGreen.add(getStringLocation(locGreen));
}
ArrayList<Location> portalYellow = new ArrayList<Location>();
for (String locYellow : yml.getStringList("locations.portal.yellow")) {
portalYellow.add(getStringLocation(locYellow));
}
fourGames.add(new GameFour(plugin, name, min, 4 * teamSize, teamSize, starting, prestart, getStringLocation(lobby), getStringLocation(spect), getStringLocation(buildMin), getStringLocation(buildMax), getStringLocation(spawnsRed), getStringLocation(spawnsBlue), getStringLocation(spawnsGreen), getStringLocation(spawnsYellow), getStringLocation(respawnsRed), getStringLocation(respawnsBlue), getStringLocation(respawnsGreen), getStringLocation(respawnsYellow), portalRed, portalBlue, portalGreen, portalYellow, hRed, hBlue, hGreen, hYellow));
}
public void loadGames() {
File folder = new File(plugin.getDataFolder() + "/arenas");
File[] listFiles = folder.listFiles();
for (int f = 0; f < listFiles.length; f++) {
if (listFiles[f].isFile()) {
File arena = listFiles[f];
FileConfiguration yml = YamlConfiguration.loadConfiguration(arena);
if (yml.getString("mode").toLowerCase().equals("normal")) {
String name = yml.getString("name");
if (yml.getString("locations.lobby") == null) {
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.RED + "El mapa " + ChatColor.YELLOW + name + " " + ChatColor.RED + "no tiene seteado el Lobby.");
continue;
}
if (yml.getString("locations.spect") == null) {
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.RED + "El mapa " + ChatColor.YELLOW + name + " " + ChatColor.RED + "no tiene seteado el Spectador.");
continue;
}
plugin.getWC().resetWorld(name);
Location hRed = null;
Location hBlue = null;
if (yml.get("locations.holograms.red") != null) {
hRed = getStringLocation(yml.getString("locations.holograms.red"));
}
if (yml.get("locations.holograms.blue") != null) {
hBlue = getStringLocation(yml.getString("locations.holograms.blue"));
}
int min = yml.getInt("minPlayers");
int teamSize = yml.getInt("teamSize");
int starting = yml.getInt("timers.starting");
int prestart = yml.getInt("timers.prestart");
int restart = yml.getInt("timers.restart");
String lobby = yml.getString("locations.lobby");
String spect = yml.getString("locations.spect");
String buildMin = yml.getString("locations.build.min");
String buildMax = yml.getString("locations.build.max");
String spawnsRed = yml.getString("locations.spawns.red");
String spawnsBlue = yml.getString("locations.spawns.blue");
String respawnsRed = yml.getString("locations.respawns.red");
String respawnsBlue = yml.getString("locations.respawns.blue");
ArrayList<Location> portalRed = new ArrayList<Location>();
for (String locRed : yml.getStringList("locations.portal.red")) {
portalRed.add(getStringLocation(locRed));
}
ArrayList<Location> portalBlue = new ArrayList<Location>();
for (String locBlue : yml.getStringList("locations.portal.blue")) {
portalBlue.add(getStringLocation(locBlue));
}
normalGames.add(new Game(plugin, name, min, 2 * teamSize, teamSize, starting, prestart, restart, getStringLocation(lobby), getStringLocation(spect), getStringLocation(buildMin), getStringLocation(buildMax), getStringLocation(spawnsRed), getStringLocation(spawnsBlue), portalRed, portalBlue, getStringLocation(respawnsRed), getStringLocation(respawnsBlue), hRed, hBlue));
}
if (yml.getString("mode").toLowerCase().equals("four")) {
String name = yml.getString("name");
plugin.getWC().resetWorld(name);
int min = yml.getInt("minPlayers");
Location hRed = null;
Location hBlue = null;
Location hGreen = null;
Location hYellow = null;
if (yml.get("locations.holograms.red") != null) {
hRed = getStringLocation(yml.getString("locations.holograms.red"));
}
if (yml.get("locations.holograms.blue") != null) {
hBlue = getStringLocation(yml.getString("locations.holograms.blue"));
}
if (yml.get("locations.holograms.green") != null) {
hGreen = getStringLocation(yml.getString("locations.holograms.green"));
}
if (yml.get("locations.holograms.yellow") != null) {
hYellow = getStringLocation(yml.getString("locations.holograms.yellow"));
}
int teamSize = yml.getInt("teamSize");
int starting = yml.getInt("timers.starting");
int prestart = yml.getInt("timers.prestart");
String lobby = yml.getString("locations.lobby");
String spect = yml.getString("locations.spect");
String buildMin = yml.getString("locations.build.min");
String buildMax = yml.getString("locations.build.max");
String spawnsRed = yml.getString("locations.spawns.red");
String spawnsBlue = yml.getString("locations.spawns.blue");
String spawnsGreen = yml.getString("locations.spawns.green");
String spawnsYellow = yml.getString("locations.spawns.yellow");
String respawnsRed = yml.getString("locations.respawns.red");
String respawnsBlue = yml.getString("locations.respawns.blue");
String respawnsGreen = yml.getString("locations.respawns.green");
String respawnsYellow = yml.getString("locations.respawns.yellow");
ArrayList<Location> portalRed = new ArrayList<Location>();
for (String locRed : yml.getStringList("locations.portal.red")) {
portalRed.add(getStringLocation(locRed));
}
ArrayList<Location> portalBlue = new ArrayList<Location>();
for (String locBlue : yml.getStringList("locations.portal.blue")) {
portalBlue.add(getStringLocation(locBlue));
}
ArrayList<Location> portalGreen = new ArrayList<Location>();
for (String locGreen : yml.getStringList("locations.portal.green")) {
portalGreen.add(getStringLocation(locGreen));
}
ArrayList<Location> portalYellow = new ArrayList<Location>();
for (String locYellow : yml.getStringList("locations.portal.yellow")) {
portalYellow.add(getStringLocation(locYellow));
}
fourGames.add(new GameFour(plugin, name, min, 4 * teamSize, teamSize, starting, prestart, getStringLocation(lobby), getStringLocation(spect), getStringLocation(buildMin), getStringLocation(buildMax), getStringLocation(spawnsRed), getStringLocation(spawnsBlue), getStringLocation(spawnsGreen), getStringLocation(spawnsYellow), getStringLocation(respawnsRed), getStringLocation(respawnsBlue), getStringLocation(respawnsGreen), getStringLocation(respawnsYellow), portalRed, portalBlue, portalGreen, portalYellow, hRed, hBlue, hGreen, hYellow));
}
}
}
}
public void addPlayerGame(Player p, Game game) {
playerGame.put(p, game);
game.addPlayer(p);
}
public void addPlayerGameFour(Player p, GameFour game) {
playerGameFour.put(p, game);
game.addPlayer(p);
}
public void removePlayerGame(Player p, Game game) {
game.removePlayer(p);
playerGame.remove(p);
plugin.getSB().update(p);
}
public void removePlayerGameFour(Player p, GameFour game) {
game.removePlayer(p);
playerGameFour.remove(p);
plugin.getSB().update(p);
}
public void removePlayerAllGames(Player p) {
for (Game game : normalGames) {
if (game.getGamePlayers().contains(p)) {
game.removePlayer(p);
playerGame.remove(p);
plugin.getSB().update(p);
}
}
}
public void removePlayerFourGames(Player p) {
for (GameFour game : fourGames) {
if (game.getPlayers().contains(p)) {
game.removePlayer(p);
playerGameFour.remove(p);
plugin.getSB().update(p);
}
}
}
public Game getGameByPlayer(Player p) {
if (playerGame.containsKey(p)) {
return playerGame.get(p);
}
return null;
}
public GameFour getGameFourByPlayer(Player p) {
if (playerGameFour.containsKey(p)) {
return playerGameFour.get(p);
}
return null;
}
public Game getGameByName(String name) {
for (Game game : normalGames) {
if (game.getName().equals(name)) {
return game;
}
}
return null;
}
public GameFour getGameFourByName(String name) {
for (GameFour game : fourGames) {
if (game.getName().equals(name)) {
return game;
}
}
return null;
}
public Location getStringLocation(String location) {
String[] l = location.split(";");
World world = Bukkit.getWorld(l[0]);
double x = Double.parseDouble(l[1]);
double y = Double.parseDouble(l[2]);
double z = Double.parseDouble(l[3]);
float yaw = Float.parseFloat(l[4]);
float pitch = Float.parseFloat(l[5]);
return new Location(world, x, y, z, yaw, pitch);
}
public ArrayList<Game> getGames(){
return normalGames;
}
public ArrayList<GameFour> getGamesFour(){
return fourGames;
}
}

252
MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/GlassManager.java

@ -0,0 +1,252 @@
package cx.sfy.TheBridge.managers;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
public class GlassManager {
@SuppressWarnings("deprecation")
public void createCage(Location loc, ChatColor team) {
World world = loc.getWorld();
int x = loc.getBlockX();
int y = loc.getBlockY();
int z = loc.getBlockZ();
world.getBlockAt(x, y, z).setType(Material.GLASS);
world.getBlockAt(x, y, z + 1).setType(Material.GLASS);
world.getBlockAt(x, y, z - 1).setType(Material.GLASS);
world.getBlockAt(x + 1, y, z).setType(Material.GLASS);
world.getBlockAt(x - 1, y, z).setType(Material.GLASS);
world.getBlockAt(x + 1, y, z + 1).setType(Material.GLASS);
world.getBlockAt(x + 1, y, z - 1).setType(Material.GLASS);
world.getBlockAt(x - 1, y, z + 1).setType(Material.GLASS);
world.getBlockAt(x - 1, y, z - 1).setType(Material.GLASS);
world.getBlockAt(x, y, z + 2).setType(Material.GLASS);
world.getBlockAt(x, y, z - 2).setType(Material.GLASS);
world.getBlockAt(x + 2, y, z).setType(Material.GLASS);
world.getBlockAt(x - 2, y, z).setType(Material.GLASS);
world.getBlockAt(x + 1, y, z + 2).setType(Material.GLASS);
world.getBlockAt(x + 1, y, z - 2).setType(Material.GLASS);
world.getBlockAt(x + 2, y, z + 1).setType(Material.GLASS);
world.getBlockAt(x - 2, y, z + 1).setType(Material.GLASS);
world.getBlockAt(x + 2, y, z + 2).setType(Material.GLASS);
world.getBlockAt(x + 2, y, z - 2).setType(Material.GLASS);
world.getBlockAt(x - 2, y, z - 2).setType(Material.GLASS);
world.getBlockAt(x - 2, y, z + 2).setType(Material.GLASS);
world.getBlockAt(x + 1, y, z + 2).setType(Material.GLASS);
world.getBlockAt(x + 1, y, z - 2).setType(Material.GLASS);
world.getBlockAt(x + 2, y, z + 1).setType(Material.GLASS);
world.getBlockAt(x - 2, y, z + 1).setType(Material.GLASS);
world.getBlockAt(x - 1, y, z - 2).setType(Material.GLASS);
world.getBlockAt(x - 1, y, z + 2).setType(Material.GLASS);
world.getBlockAt(x + 2, y, z - 1).setType(Material.GLASS);
world.getBlockAt(x - 2, y, z - 1).setType(Material.GLASS);
world.getBlockAt(x, y + 1, z - 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 1, y + 1, z - 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 2, y + 1, z - 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 2, y + 1, z - 1).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 2, y + 1, z).setType(Material.STAINED_GLASS);
world.getBlockAt(x - 1, y + 1, z - 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x - 2, y + 1, z - 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x - 2, y + 1, z - 1).setType(Material.STAINED_GLASS);
world.getBlockAt(x - 2, y + 1, z).setType(Material.STAINED_GLASS);
world.getBlockAt(x - 2, y + 1, z + 1).setType(Material.STAINED_GLASS);
world.getBlockAt(x - 2, y + 1, z + 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x - 1, y + 1, z + 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x, y + 1, z + 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 1, y + 1, z + 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 2, y + 1, z + 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 2, y + 1, z + 1).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 2, y + 1, z).setType(Material.STAINED_GLASS);
world.getBlockAt(x, y + 2, z - 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 1, y + 2, z - 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 2, y + 2, z - 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 2, y + 2, z - 1).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 2, y + 2, z).setType(Material.STAINED_GLASS);
world.getBlockAt(x - 1, y + 2, z - 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x - 2, y + 2, z - 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x - 2, y + 2, z - 1).setType(Material.STAINED_GLASS);
world.getBlockAt(x - 2, y + 2, z).setType(Material.STAINED_GLASS);
world.getBlockAt(x - 2, y + 2, z + 1).setType(Material.STAINED_GLASS);
world.getBlockAt(x - 2, y + 2, z + 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x - 1, y + 2, z + 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x, y + 2, z + 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 1, y + 2, z + 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 2, y + 2, z + 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 2, y + 2, z + 1).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 2, y + 2, z).setType(Material.STAINED_GLASS);
world.getBlockAt(x, y + 3, z - 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 1, y + 3, z - 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 2, y + 3, z - 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 2, y + 3, z - 1).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 2, y + 3, z).setType(Material.STAINED_GLASS);
world.getBlockAt(x - 1, y + 3, z - 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x - 2, y + 3, z - 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x - 2, y + 3, z - 1).setType(Material.STAINED_GLASS);
world.getBlockAt(x - 2, y + 3, z).setType(Material.STAINED_GLASS);
world.getBlockAt(x - 2, y + 3, z + 1).setType(Material.STAINED_GLASS);
world.getBlockAt(x - 2, y + 3, z + 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x - 1, y + 3, z + 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x, y + 3, z + 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 1, y + 3, z + 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 2, y + 3, z + 2).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 2, y + 3, z + 1).setType(Material.STAINED_GLASS);
world.getBlockAt(x + 2, y + 3, z).setType(Material.STAINED_GLASS);
world.getBlockAt(x, y + 1, z - 2).setData(getColor(team));
world.getBlockAt(x + 1, y + 1, z - 2).setData(getColor(team));
world.getBlockAt(x + 2, y + 1, z - 2).setData(getColor(team));
world.getBlockAt(x + 2, y + 1, z - 1).setData(getColor(team));
world.getBlockAt(x + 2, y + 1, z).setData(getColor(team));
world.getBlockAt(x - 1, y + 1, z - 2).setData(getColor(team));
world.getBlockAt(x - 2, y + 1, z - 2).setData(getColor(team));
world.getBlockAt(x - 2, y + 1, z - 1).setData(getColor(team));
world.getBlockAt(x - 2, y + 1, z).setData(getColor(team));
world.getBlockAt(x - 2, y + 1, z + 1).setData(getColor(team));
world.getBlockAt(x - 2, y + 1, z + 2).setData(getColor(team));
world.getBlockAt(x - 1, y + 1, z + 2).setData(getColor(team));
world.getBlockAt(x, y + 1, z + 2).setData(getColor(team));
world.getBlockAt(x + 1, y + 1, z + 2).setData(getColor(team));
world.getBlockAt(x + 2, y + 1, z + 2).setData(getColor(team));
world.getBlockAt(x + 2, y + 1, z + 1).setData(getColor(team));
world.getBlockAt(x + 2, y + 1, z).setData(getColor(team));
world.getBlockAt(x, y + 2, z - 2).setData(getColor(team));
world.getBlockAt(x + 1, y + 2, z - 2).setData(getColor(team));
world.getBlockAt(x + 2, y + 2, z - 2).setData(getColor(team));
world.getBlockAt(x + 2, y + 2, z - 1).setData(getColor(team));
world.getBlockAt(x + 2, y + 2, z).setData(getColor(team));
world.getBlockAt(x - 1, y + 2, z - 2).setData(getColor(team));
world.getBlockAt(x - 2, y + 2, z - 2).setData(getColor(team));
world.getBlockAt(x - 2, y + 2, z - 1).setData(getColor(team));
world.getBlockAt(x - 2, y + 2, z).setData(getColor(team));
world.getBlockAt(x - 2, y + 2, z + 1).setData(getColor(team));
world.getBlockAt(x - 2, y + 2, z + 2).setData(getColor(team));
world.getBlockAt(x - 1, y + 2, z + 2).setData(getColor(team));
world.getBlockAt(x, y + 2, z + 2).setData(getColor(team));
world.getBlockAt(x + 1, y + 2, z + 2).setData(getColor(team));
world.getBlockAt(x + 2, y + 2, z + 2).setData(getColor(team));
world.getBlockAt(x + 2, y + 2, z + 1).setData(getColor(team));
world.getBlockAt(x + 2, y + 2, z).setData(getColor(team));
world.getBlockAt(x, y + 3, z - 2).setData(getColor(team));
world.getBlockAt(x + 1, y + 3, z - 2).setData(getColor(team));
world.getBlockAt(x + 2, y + 3, z - 2).setData(getColor(team));
world.getBlockAt(x + 2, y + 3, z - 1).setData(getColor(team));
world.getBlockAt(x + 2, y + 3, z).setData(getColor(team));
world.getBlockAt(x - 1, y + 3, z - 2).setData(getColor(team));
world.getBlockAt(x - 2, y + 3, z - 2).setData(getColor(team));
world.getBlockAt(x - 2, y + 3, z - 1).setData(getColor(team));
world.getBlockAt(x - 2, y + 3, z).setData(getColor(team));
world.getBlockAt(x - 2, y + 3, z + 1).setData(getColor(team));
world.getBlockAt(x - 2, y + 3, z + 2).setData(getColor(team));
world.getBlockAt(x - 1, y + 3, z + 2).setData(getColor(team));
world.getBlockAt(x, y + 3, z + 2).setData(getColor(team));
world.getBlockAt(x + 1, y + 3, z + 2).setData(getColor(team));
world.getBlockAt(x + 2, y + 3, z + 2).setData(getColor(team));
world.getBlockAt(x + 2, y + 3, z + 1).setData(getColor(team));
world.getBlockAt(x + 2, y + 3, z).setData(getColor(team));
}
public void removeGlass(Location loc) {
World world = loc.getWorld();
int x = loc.getBlockX();
int y = loc.getBlockY();
int z = loc.getBlockZ();
world.getBlockAt(x, y, z).setType(Material.AIR);
world.getBlockAt(x, y, z + 1).setType(Material.AIR);
world.getBlockAt(x, y, z - 1).setType(Material.AIR);
world.getBlockAt(x + 1, y, z).setType(Material.AIR);
world.getBlockAt(x - 1, y, z).setType(Material.AIR);
world.getBlockAt(x + 1, y, z + 1).setType(Material.AIR);
world.getBlockAt(x + 1, y, z - 1).setType(Material.AIR);
world.getBlockAt(x - 1, y, z + 1).setType(Material.AIR);
world.getBlockAt(x - 1, y, z - 1).setType(Material.AIR);
world.getBlockAt(x, y, z + 2).setType(Material.AIR);
world.getBlockAt(x, y, z - 2).setType(Material.AIR);
world.getBlockAt(x + 2, y, z).setType(Material.AIR);
world.getBlockAt(x - 2, y, z).setType(Material.AIR);
world.getBlockAt(x + 1, y, z + 2).setType(Material.AIR);
world.getBlockAt(x + 1, y, z - 2).setType(Material.AIR);
world.getBlockAt(x + 2, y, z + 1).setType(Material.AIR);
world.getBlockAt(x - 2, y, z + 1).setType(Material.AIR);
world.getBlockAt(x + 2, y, z + 2).setType(Material.AIR);
world.getBlockAt(x + 2, y, z - 2).setType(Material.AIR);
world.getBlockAt(x - 2, y, z - 2).setType(Material.AIR);
world.getBlockAt(x - 2, y, z + 2).setType(Material.AIR);
world.getBlockAt(x + 1, y, z + 2).setType(Material.AIR);
world.getBlockAt(x + 1, y, z - 2).setType(Material.AIR);
world.getBlockAt(x + 2, y, z + 1).setType(Material.AIR);
world.getBlockAt(x - 2, y, z + 1).setType(Material.AIR);
world.getBlockAt(x - 1, y, z - 2).setType(Material.AIR);
world.getBlockAt(x - 1, y, z + 2).setType(Material.AIR);
world.getBlockAt(x + 2, y, z - 1).setType(Material.AIR);
world.getBlockAt(x - 2, y, z - 1).setType(Material.AIR);
world.getBlockAt(x, y + 1, z - 2).setType(Material.AIR);
world.getBlockAt(x + 1, y + 1, z - 2).setType(Material.AIR);
world.getBlockAt(x + 2, y + 1, z - 2).setType(Material.AIR);
world.getBlockAt(x + 2, y + 1, z - 1).setType(Material.AIR);
world.getBlockAt(x + 2, y + 1, z).setType(Material.AIR);
world.getBlockAt(x - 1, y + 1, z - 2).setType(Material.AIR);
world.getBlockAt(x - 2, y + 1, z - 2).setType(Material.AIR);
world.getBlockAt(x - 2, y + 1, z - 1).setType(Material.AIR);
world.getBlockAt(x - 2, y + 1, z).setType(Material.AIR);
world.getBlockAt(x - 2, y + 1, z + 1).setType(Material.AIR);
world.getBlockAt(x - 2, y + 1, z + 2).setType(Material.AIR);
world.getBlockAt(x - 1, y + 1, z + 2).setType(Material.AIR);
world.getBlockAt(x, y + 1, z + 2).setType(Material.AIR);
world.getBlockAt(x + 1, y + 1, z + 2).setType(Material.AIR);
world.getBlockAt(x + 2, y + 1, z + 2).setType(Material.AIR);
world.getBlockAt(x + 2, y + 1, z + 1).setType(Material.AIR);
world.getBlockAt(x + 2, y + 1, z).setType(Material.AIR);
world.getBlockAt(x, y + 2, z - 2).setType(Material.AIR);
world.getBlockAt(x + 1, y + 2, z - 2).setType(Material.AIR);
world.getBlockAt(x + 2, y + 2, z - 2).setType(Material.AIR);
world.getBlockAt(x + 2, y + 2, z - 1).setType(Material.AIR);
world.getBlockAt(x + 2, y + 2, z).setType(Material.AIR);
world.getBlockAt(x - 1, y + 2, z - 2).setType(Material.AIR);
world.getBlockAt(x - 2, y + 2, z - 2).setType(Material.AIR);
world.getBlockAt(x - 2, y + 2, z - 1).setType(Material.AIR);
world.getBlockAt(x - 2, y + 2, z).setType(Material.AIR);
world.getBlockAt(x - 2, y + 2, z + 1).setType(Material.AIR);
world.getBlockAt(x - 2, y + 2, z + 2).setType(Material.AIR);
world.getBlockAt(x - 1, y + 2, z + 2).setType(Material.AIR);
world.getBlockAt(x, y + 2, z + 2).setType(Material.AIR);
world.getBlockAt(x + 1, y + 2, z + 2).setType(Material.AIR);
world.getBlockAt(x + 2, y + 2, z + 2).setType(Material.AIR);
world.getBlockAt(x + 2, y + 2, z + 1).setType(Material.AIR);
world.getBlockAt(x + 2, y + 2, z).setType(Material.AIR);
world.getBlockAt(x, y + 3, z - 2).setType(Material.AIR);
world.getBlockAt(x + 1, y + 3, z - 2).setType(Material.AIR);
world.getBlockAt(x + 2, y + 3, z - 2).setType(Material.AIR);
world.getBlockAt(x + 2, y + 3, z - 1).setType(Material.AIR);
world.getBlockAt(x + 2, y + 3, z).setType(Material.AIR);
world.getBlockAt(x - 1, y + 3, z - 2).setType(Material.AIR);
world.getBlockAt(x - 2, y + 3, z - 2).setType(Material.AIR);
world.getBlockAt(x - 2, y + 3, z - 1).setType(Material.AIR);
world.getBlockAt(x - 2, y + 3, z).setType(Material.AIR);
world.getBlockAt(x - 2, y + 3, z + 1).setType(Material.AIR);
world.getBlockAt(x - 2, y + 3, z + 2).setType(Material.AIR);
world.getBlockAt(x - 1, y + 3, z + 2).setType(Material.AIR);
world.getBlockAt(x, y + 3, z + 2).setType(Material.AIR);
world.getBlockAt(x + 1, y + 3, z + 2).setType(Material.AIR);
world.getBlockAt(x + 2, y + 3, z + 2).setType(Material.AIR);
world.getBlockAt(x + 2, y + 3, z + 1).setType(Material.AIR);
world.getBlockAt(x + 2, y + 3, z).setType(Material.AIR);
}
public byte getColor(ChatColor team) {
if (team.equals(ChatColor.RED)) {
return 14;
}
if (team.equals(ChatColor.BLUE)) {
return 11;
}
if (team.equals(ChatColor.YELLOW)) {
return 4;
}
if (team.equals(ChatColor.GREEN)) {
return 5;
}
return 0;
}
}

5
MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/KillSoundManager.java

@ -0,0 +1,5 @@
package cx.sfy.TheBridge.managers;
public class KillSoundManager {
}

128
MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/LocationManager.java

@ -0,0 +1,128 @@
package cx.sfy.TheBridge.managers;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import cx.sfy.TheBridge.Main;
public class LocationManager {
private Location nkills;
private Location nwins;
private Location ngoals;
private Location fkills;
private Location fwins;
private Location fgoals;
private Location stats;
Main plugin;
public LocationManager(Main plugin) {
this.plugin = plugin;
}
public void setMainLobby(Player p) {
Location loc = p.getLocation();
String world = loc.getWorld().getName();
double x = loc.getX();
double y = loc.getY();
double z = loc.getZ();
float yaw = loc.getYaw();
float pitch = loc.getPitch();
plugin.getConfig().set("mainLobby", world + ";" + x + ";" + y + ";" + z + ";" + yaw + ";" + pitch);
plugin.saveConfig();
plugin.reloadMainLobby();
p.sendMessage("§aLobby has been setted.");
}
public void reloadLocations() {
if (plugin.getConfig().getString("stats") != null) {
stats = getStringLocation("stats");
} else {
stats = null;
}
if (plugin.getConfig().getString("tops.normal.kills") != null) {
nkills = getStringLocation("tops.normal.kills");
} else {
nkills = null;
}
if (plugin.getConfig().getString("tops.normal.wins") != null) {
nwins = getStringLocation("tops.normal.wins");
} else {
nwins = null;
}
if (plugin.getConfig().getString("tops.normal.goals") != null) {
ngoals = getStringLocation("tops.normal.goals");
} else {
ngoals = null;
}
if (plugin.getConfig().getString("tops.four.kills") != null) {
fkills = getStringLocation("tops.four.kills");
} else {
fkills = null;
}
if (plugin.getConfig().getString("tops.four.wins") != null) {
fwins = getStringLocation("tops.four.wins");
} else {
fwins = null;
}
if (plugin.getConfig().getString("tops.four.goals") != null) {
fgoals = getStringLocation("tops.four.goals");
} else {
fgoals = null;
}
}
public Location getMainLobby() {
String location = plugin.getConfig().getString("mainLobby");
String [] loca = location.split(";");
Location loc = new Location(Bukkit.getWorld(loca[0]), Double.valueOf(loca[1]), Double.valueOf(loca[2]), Double.valueOf(loca[3]), Float.valueOf(loca[4]), Float.valueOf(loca[5]));
return loc;
}
public Location getStringLocation(String l) {
String location = plugin.getConfig().getString(l);
String [] loca = location.split(";");
Location loc = new Location(Bukkit.getWorld(loca[0]), Double.valueOf(loca[1]), Double.valueOf(loca[2]), Double.valueOf(loca[3]), Float.valueOf(loca[4]), Float.valueOf(loca[5]));
return loc;
}
public String getLocationString(Location loc){
String world = loc.getWorld().getName();
double x = loc.getX();
double y = loc.getY();
double z = loc.getZ();
float yaw = loc.getYaw();
float pitch = loc.getPitch();
return world + ";" + x + ";" + y + ";" + z + ";" + yaw + ";" + pitch;
}
public Location getStats() {
return stats;
}
public Location getNormalKills() {
return nkills;
}
public Location getNormalWins() {
return nwins;
}
public Location getNormalGoals() {
return ngoals;
}
public Location getFourKills() {
return fkills;
}
public Location getFourWins() {
return fwins;
}
public Location getFourGoals() {
return fgoals;
}
}

288
MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/ScoreboardManager.java

@ -0,0 +1,288 @@
package cx.sfy.TheBridge.managers;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.game.Game;
import cx.sfy.TheBridge.game.GameFour;
import cx.sfy.TheBridge.game.Game.State;
import cx.sfy.TheBridge.game.GameFour.FState;
import cx.sfy.TheBridge.utils.ScoreboardUtil;
import me.clip.placeholderapi.PlaceholderAPI;
public class ScoreboardManager {
private HashMap<Player, String> sb = new HashMap<Player, String>();
private HashMap<Player, ScoreboardUtil> score = new HashMap<Player, ScoreboardUtil>();
Main plugin;
public ScoreboardManager(Main plugin) {
this.plugin = plugin;
}
public HashMap<Player, String> getSB(){
return sb;
}
public void createLobbyBoard(Player p) {
sb.put(p, "lobby");
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
ScoreboardUtil scoreboardUtil = new ScoreboardUtil("all", "starting", false);
scoreboardUtil.setName(plugin.getLang().get("scoreboards.main-title"));
String titulo = plugin.getLang().get(p, "scoreboards.main");
String [] title = titulo.split("\\n");
for (Integer n = 1, n2 = title.length - 1; n < title.length + 1; ++n, --n2) {
scoreboardUtil.lines(n, lobby(p, title[n2]));
}
scoreboardUtil.build(p);
score.put(p, scoreboardUtil);
}
public void createWaitingBoard(Player p) {
sb.put(p, "waiting");
Game game = plugin.getGM().getGameByPlayer(p);
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
ScoreboardUtil scoreboardUtil = new ScoreboardUtil("lobby", "starting", false);
scoreboardUtil.setName(plugin.getLang().get("scoreboards.lobby-title"));
String titulo = plugin.getLang().get(p, "scoreboards.lobby");
String [] title = titulo.split("\\n");
for (Integer n = 1, n2 = title.length - 1; n < title.length + 1; ++n, --n2) {
scoreboardUtil.lines(n, game(p, title[n2], game));
}
scoreboardUtil.build(p);
score.put(p, scoreboardUtil);
}
public void createStartingBoard(Player p) {
sb.put(p, "starting");
Game game = plugin.getGM().getGameByPlayer(p);
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
ScoreboardUtil scoreboardUtil = new ScoreboardUtil("starting", "starting", false);
scoreboardUtil.setName(plugin.getLang().get("scoreboards.starting-title"));
String titulo = plugin.getLang().get(p, "scoreboards.starting");
String [] title = titulo.split("\\n");
for (Integer n = 1, n2 = title.length - 1; n < title.length + 1; ++n, --n2) {
scoreboardUtil.lines(n, game(p, title[n2], game));
}
scoreboardUtil.build(p);
score.put(p, scoreboardUtil);
}
public void createGameBoard(Player p) {
sb.put(p, "game");
Game game = plugin.getGM().getGameByPlayer(p);
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
ScoreboardUtil scoreboardUtil = new ScoreboardUtil("game-normal", "starting", false);
scoreboardUtil.setName(plugin.getLang().get("scoreboards.game-normal-title"));
String titulo = plugin.getLang().get(p, "scoreboards.game-normal");
String [] title = titulo.split("\\n");
for (Integer n = 1, n2 = title.length - 1; n < title.length + 1; ++n, --n2) {
scoreboardUtil.lines(n, game(p, title[n2], game));
}
scoreboardUtil.build(p);
score.put(p, scoreboardUtil);
}
public void createWaitingFourBoard(Player p) {
sb.put(p, "waiting");
GameFour game = plugin.getGM().getGameFourByPlayer(p);
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
ScoreboardUtil scoreboardUtil = new ScoreboardUtil("lobby", "starting", false);
scoreboardUtil.setName(plugin.getLang().get("scoreboards.lobby-title"));
String titulo = plugin.getLang().get(p, "scoreboards.lobby");
String [] title = titulo.split("\\n");
for (Integer n = 1, n2 = title.length - 1; n < title.length + 1; ++n, --n2) {
scoreboardUtil.lines(n, gameFour(p, title[n2], game));
}
scoreboardUtil.build(p);
score.put(p, scoreboardUtil);
}
public void createStartingFourBoard(Player p) {
sb.put(p, "starting");
GameFour game = plugin.getGM().getGameFourByPlayer(p);
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
ScoreboardUtil scoreboardUtil = new ScoreboardUtil("starting", "starting", false);
scoreboardUtil.setName(plugin.getLang().get("scoreboards.starting-title"));
String titulo = plugin.getLang().get(p, "scoreboards.starting");
String [] title = titulo.split("\\n");
for (Integer n = 1, n2 = title.length - 1; n < title.length + 1; ++n, --n2) {
scoreboardUtil.lines(n, gameFour(p, title[n2], game));
}
scoreboardUtil.build(p);
score.put(p, scoreboardUtil);
}
public void createGameFourBoard(Player p) {
sb.put(p, "game");
GameFour game = plugin.getGM().getGameFourByPlayer(p);
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
ScoreboardUtil scoreboardUtil = new ScoreboardUtil("game-four", "starting", false);
scoreboardUtil.setName(plugin.getLang().get("scoreboards.game-four-title"));
String titulo = plugin.getLang().get(p, "scoreboards.game-four");
String [] title = titulo.split("\\n");
for (Integer n = 1, n2 = title.length - 1; n < title.length + 1; ++n, --n2) {
scoreboardUtil.lines(n, gameFour(p, title[n2], game));
}
scoreboardUtil.build(p);
score.put(p, scoreboardUtil);
}
public void update(Player p) {
if (p == null || !p.isOnline()) {
return;
}
ScoreboardUtil scoreboardUtil = score.get(p);
if (plugin.getGM().getGameByPlayer(p) == null && plugin.getGM().getGameFourByPlayer(p) == null) {
if (sb.get(p).equals("lobby")) {
scoreboardUtil.setName(plugin.getLang().get("scoreboards.main-title"));
String titulo = plugin.getLang().get(p, "scoreboards.main");
String [] title = titulo.split("\\n");
for (Integer n = 1, n2 = title.length - 1; n < title.length + 1; ++n, --n2) {
scoreboardUtil.lines(n, lobby(p, title[n2]));
}
} else {
createLobbyBoard(p);
}
} else {
if (plugin.getGM().getGameByPlayer(p) != null) {
Game game = plugin.getGM().getGameByPlayer(p);
if (game.isState(State.WAITING)) {
if (sb.get(p).equals("waiting")) {
scoreboardUtil.setName(plugin.getLang().get("scoreboards.lobby-title"));
String titulo = plugin.getLang().get(p, "scoreboards.lobby");
String [] title = titulo.split("\\n");
for (Integer n = 1, n2 = title.length - 1; n < title.length + 1; ++n, --n2) {
scoreboardUtil.lines(n, game(p, title[n2], game));
}
} else {
createWaitingBoard(p);
}
} else if (game.isState(State.STARTING)) {
if (sb.get(p).equals("starting")) {
scoreboardUtil.setName(plugin.getLang().get("scoreboards.starting-title"));
String titulo = plugin.getLang().get(p, "scoreboards.starting");
String [] title = titulo.split("\\n");
for (Integer n = 1, n2 = title.length - 1; n < title.length + 1; ++n, --n2) {
scoreboardUtil.lines(n, game(p, title[n2], game));
}
} else {
createStartingBoard(p);
}
} else if (game.isState(State.INGAME) || game.isState(State.PREGAME) || game.isState(State.FINISH) || game.isState(State.RESTARTING)) {
if (sb.get(p).equals("game")) {
scoreboardUtil.setName(plugin.getLang().get("scoreboards.game-normal-title"));
String titulo = plugin.getLang().get(p, "scoreboards.game-normal");
String [] title = titulo.split("\\n");
for (Integer n = 1, n2 = title.length - 1; n < title.length + 1; ++n, --n2) {
scoreboardUtil.lines(n, game(p, title[n2], game));
}
} else {
createGameBoard(p);
}
}
} else if (plugin.getGM().getGameFourByPlayer(p) != null) {
GameFour game = plugin.getGM().getGameFourByPlayer(p);
if (game.isState(FState.WAITING)) {
if (sb.get(p).equals("waiting")) {
scoreboardUtil.setName(plugin.getLang().get("scoreboards.lobby-title"));
String titulo = plugin.getLang().get(p, "scoreboards.lobby");
String [] title = titulo.split("\\n");
for (Integer n = 1, n2 = title.length - 1; n < title.length + 1; ++n, --n2) {
scoreboardUtil.lines(n, gameFour(p, title[n2], game));
}
} else {
createWaitingFourBoard(p);
}
} else if (game.isState(FState.STARTING)) {
if (sb.get(p).equals("starting")) {
scoreboardUtil.setName(plugin.getLang().get("scoreboards.starting-title"));
String titulo = plugin.getLang().get(p, "scoreboards.starting");
String [] title = titulo.split("\\n");
for (Integer n = 1, n2 = title.length - 1; n < title.length + 1; ++n, --n2) {
scoreboardUtil.lines(n, gameFour(p, title[n2], game));
}
} else {
createStartingFourBoard(p);
}
} else if (game.isState(FState.INGAME) || game.isState(FState.PREGAME) || game.isState(FState.FINISH) || game.isState(FState.RESTARTING)) {
if (sb.get(p).equals("game")) {
scoreboardUtil.setName(plugin.getLang().get("scoreboards.game-four-title"));
String titulo = plugin.getLang().get(p, "scoreboards.game-four");
String [] title = titulo.split("\\n");
for (Integer n = 1, n2 = title.length - 1; n < title.length + 1; ++n, --n2) {
scoreboardUtil.lines(n, gameFour(p, title[n2], game));
}
} else {
createGameFourBoard(p);
}
}
}
}
}
Date now = new Date();
SimpleDateFormat sm = new SimpleDateFormat("dd/MM/yy");
public String lobby(Player p, String c) {
if (plugin.getPlaceholder()) {
return PlaceholderAPI.setPlaceholders(p, c.replaceAll("<online>", String.valueOf(Bukkit.getOnlinePlayers().size())).replaceAll("<player>", p.getName()));
} else {
return c.replaceAll("<online>", String.valueOf(Bukkit.getOnlinePlayers().size())).replaceAll("<player>", p.getName());
}
}
public String game(Player p, String c, Game game) {
if (plugin.getPlaceholder()) {
return PlaceholderAPI.setPlaceholders(p, c
.replaceAll("<goals>", String.valueOf(game.getGoals(p)))
.replaceAll("<kills>", String.valueOf(game.getKills(p)))
.replaceAll("<date>", sm.format(now))
.replaceAll("<blueGoals>", String.valueOf(game.getTeams().get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(game.getTeams().get(ChatColor.RED).getGoals()))
.replaceAll("<time>", String.valueOf(game.getStarting())).replaceAll("<s>", (game.getStarting() > 1) ? "s" : "").replaceAll("<max>", String.valueOf(game.getMax())).replaceAll("<players>", String.valueOf(game.getPlayers())).replaceAll("<map>", game.getName()).replaceAll("<mode>", game.getMode()).replaceAll("<server>", plugin.getConfig().getString("server")));
} else {
return c.replaceAll("<goals>", String.valueOf(game.getGoals(p)))
.replaceAll("<kills>", String.valueOf(game.getKills(p)))
.replaceAll("<date>", sm.format(now))
.replaceAll("<blueGoals>", String.valueOf(game.getTeams().get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(game.getTeams().get(ChatColor.RED).getGoals()))
.replaceAll("<time>", String.valueOf(game.getStarting())).replaceAll("<max>", String.valueOf(game.getMax())).replaceAll("<players>", String.valueOf(game.getPlayers())).replaceAll("<map>", game.getName()).replaceAll("<mode>", game.getMode()).replaceAll("<server>", plugin.getConfig().getString("server"));
}
}
public String gameFour(Player p, String c, GameFour game) {
if (plugin.getPlaceholder()) {
return PlaceholderAPI.setPlaceholders(p, c.replaceAll("<red>", game.getTeams().get(ChatColor.RED).getAlly())
.replaceAll("<redLife>", game.getTeams().get(ChatColor.RED).getLifeString())
.replaceAll("<blue>", game.getTeams().get(ChatColor.BLUE).getAlly())
.replaceAll("<blueLife>", game.getTeams().get(ChatColor.BLUE).getLifeString())
.replaceAll("<yellow>", game.getTeams().get(ChatColor.YELLOW).getAlly())
.replaceAll("<yellowLife>", game.getTeams().get(ChatColor.YELLOW).getLifeString())
.replaceAll("<green>", game.getTeams().get(ChatColor.GREEN).getAlly())
.replaceAll("<greenLife>", game.getTeams().get(ChatColor.GREEN).getLifeString())
.replaceAll("<goals>", String.valueOf(game.getGoals(p))).replaceAll("<kills>", String.valueOf(game.getKills(p))).replaceAll("<date>", sm.format(now)).replaceAll("<server>", plugin.getConfig().getString("server")).replaceAll("<players>", String.valueOf(game.getPlayers().size())).replaceAll("<max>", String.valueOf(game.getMax())).replaceAll("<mode>", game.getMode()).replaceAll("<map>", game.getName()).replaceAll("<time>", String.valueOf(game.getStarting())).replaceAll("<s>", (game.getStarting() > 1) ? "s" : ""));
}
return c.replaceAll("<red>", game.getTeams().get(ChatColor.RED).getAlly())
.replaceAll("<redLife>", game.getTeams().get(ChatColor.RED).getLifeString())
.replaceAll("<blue>", game.getTeams().get(ChatColor.BLUE).getAlly())
.replaceAll("<blueLife>", game.getTeams().get(ChatColor.BLUE).getLifeString())
.replaceAll("<yellow>", game.getTeams().get(ChatColor.YELLOW).getAlly())
.replaceAll("<yellowLife>", game.getTeams().get(ChatColor.YELLOW).getLifeString())
.replaceAll("<green>", game.getTeams().get(ChatColor.GREEN).getAlly())
.replaceAll("<greenLife>", game.getTeams().get(ChatColor.GREEN).getLifeString())
.replaceAll("<goals>", String.valueOf(game.getGoals(p))).replaceAll("<kills>", String.valueOf(game.getKills(p))).replaceAll("<date>", sm.format(now)).replaceAll("<server>", plugin.getConfig().getString("server")).replaceAll("<players>", String.valueOf(game.getPlayers().size())).replaceAll("<max>", String.valueOf(game.getMax())).replaceAll("<mode>", game.getMode()).replaceAll("<map>", game.getName()).replaceAll("<time>", String.valueOf(game.getStarting())).replaceAll("<s>", (game.getStarting() > 1) ? "s" : "");
}
public void remove(Player p) {
sb.remove(p);
score.remove(p);
}
}

45
MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/SetupManager.java

@ -0,0 +1,45 @@
package cx.sfy.TheBridge.managers;
import java.util.HashMap;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import cx.sfy.TheBridge.Main;
public class SetupManager {
private HashMap<Player, HashMap<String, Location>> build = new HashMap<Player, HashMap<String, Location>>();
Main plugin;
public SetupManager(Main plugin) {
this.plugin = plugin;
}
public void setMin(Player p, Location loc) {
if (!build.containsKey(p)) {
build.put(p, new HashMap<String, Location>());
build.get(p).put("MIN", loc);
p.sendMessage(plugin.getLang().get("setup.minSet").replaceAll("<world>", loc.getWorld().getName()).replaceAll("<x>", String.valueOf(loc.getY())).replaceAll("<y>", String.valueOf(loc.getY())).replaceAll("<z>", String.valueOf(loc.getZ())).replaceAll("<yaw>", String.valueOf(loc.getYaw())).replaceAll("<pitch>", String.valueOf(loc.getPitch())));
} else {
build.get(p).put("MIN", loc);
p.sendMessage(plugin.getLang().get("setup.minSet").replaceAll("<world>", loc.getWorld().getName()).replaceAll("<x>", String.valueOf(loc.getY())).replaceAll("<y>", String.valueOf(loc.getY())).replaceAll("<z>", String.valueOf(loc.getZ())).replaceAll("<yaw>", String.valueOf(loc.getYaw())).replaceAll("<pitch>", String.valueOf(loc.getPitch())));
}
}
public void setMax(Player p, Location loc) {
if (!build.containsKey(p)) {
build.put(p, new HashMap<String, Location>());
build.get(p).put("MAX", loc);
p.sendMessage(plugin.getLang().get("setup.maxSet").replaceAll("<world>", loc.getWorld().getName()).replaceAll("<x>", String.valueOf(loc.getY())).replaceAll("<y>", String.valueOf(loc.getY())).replaceAll("<z>", String.valueOf(loc.getZ())).replaceAll("<yaw>", String.valueOf(loc.getYaw())).replaceAll("<pitch>", String.valueOf(loc.getPitch())));
} else {
build.get(p).put("MAX", loc);
p.sendMessage(plugin.getLang().get("setup.maxSet").replaceAll("<world>", loc.getWorld().getName()).replaceAll("<x>", String.valueOf(loc.getY())).replaceAll("<y>", String.valueOf(loc.getY())).replaceAll("<z>", String.valueOf(loc.getZ())).replaceAll("<yaw>", String.valueOf(loc.getYaw())).replaceAll("<pitch>", String.valueOf(loc.getPitch())));
}
}
public HashMap<Player, HashMap<String, Location>> getSelect(){
return build;
}
}

202
MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/SignManager.java

@ -0,0 +1,202 @@
package cx.sfy.TheBridge.managers;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign;
import org.bukkit.configuration.ConfigurationSection;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.game.Game;
import cx.sfy.TheBridge.game.Game.State;
import cx.sfy.TheBridge.game.GameFour;
import cx.sfy.TheBridge.game.GameFour.FState;
import cx.sfy.TheBridge.signs.GameFourSign;
import cx.sfy.TheBridge.signs.GameNormalSign;
public class SignManager {
private final HashMap<Location, GameNormalSign> gameSign = new HashMap<>();
private final HashMap<Location, GameFourSign> gameFourSign = new HashMap<>();
Main plugin;
public SignManager(Main plugin) {
this.plugin = plugin;
final ConfigurationSection conf = plugin.getSigns().getConfig().getConfigurationSection("signs.normal");
for (final String signN : conf.getKeys(false)) {
final Location loc = getStringLocation(plugin.getSigns().get("signs.normal." + signN + ".loc"));
if (!(loc.getBlock().getState() instanceof Sign))
continue;
final Block b = getBlockFaced(loc.getBlock());
gameSign.put(loc, new GameNormalSign(loc, signN, b));
}
final ConfigurationSection confF = plugin.getSigns().getConfig().getConfigurationSection("signs.four");
for (final String signF : confF.getKeys(false)) {
final Location loc = getStringLocation(plugin.getSigns().get("signs.four." + signF + ".loc"));
if (!(loc.getBlock().getState() instanceof Sign))
continue;
final Block b = getBlockFaced(loc.getBlock());
gameFourSign.put(loc, new GameFourSign(loc, signF, b));
}
}
public HashMap<Location, GameNormalSign> getSigns(){
return gameSign;
}
public HashMap<Location, GameFourSign> getFourSigns(){
return gameFourSign;
}
@SuppressWarnings("deprecation")
public Block getBlockFaced(Block b) {
switch (b.getData()) {
case 2:
return b.getRelative(BlockFace.SOUTH);
case 3:
return b.getRelative(BlockFace.NORTH);
case 4:
return b.getRelative(BlockFace.EAST);
case 5:
return b.getRelative(BlockFace.WEST);
default:
return b;
}
}
public void createSign(Location loc, String game, Sign sign) {
plugin.getSigns().set("signs.normal." + game + ".loc", getLocationString(loc));
plugin.getSigns().set("signs.normal." + game + ".game", game);
gameSign.put(loc, new GameNormalSign(loc, game, getBlockFaced(loc.getBlock())));
final Game gname = plugin.getGM().getGameByName(game);
sign.setLine(0, plugin.getLang().get("signs.normal.line-1").replaceAll("<state>", getState(gname.getState())).replaceAll("<name>", game).replaceAll("<players>", String.valueOf(gname.getPlayers())).replaceAll("<max>", String.valueOf(gname.getMax())));
sign.setLine(1, plugin.getLang().get("signs.normal.line-2").replaceAll("<state>", getState(gname.getState())).replaceAll("<name>", game).replaceAll("<players>", String.valueOf(gname.getPlayers())).replaceAll("<max>", String.valueOf(gname.getMax())));
sign.setLine(2, plugin.getLang().get("signs.normal.line-3").replaceAll("<state>", getState(gname.getState())).replaceAll("<name>", game).replaceAll("<players>", String.valueOf(gname.getPlayers())).replaceAll("<max>", String.valueOf(gname.getMax())));
sign.setLine(3, plugin.getLang().get("signs.normal.line-4").replaceAll("<state>", getState(gname.getState())).replaceAll("<name>", game).replaceAll("<players>", String.valueOf(gname.getPlayers())).replaceAll("<max>", String.valueOf(gname.getMax())));
sign.update(true);
plugin.getSigns().save();
}
public void createFourSign(Location loc, String game, Sign sign) {
plugin.getSigns().set("signs.four." + game + ".loc", getLocationString(loc));
plugin.getSigns().set("signs.four." + game + ".game", game);
gameFourSign.put(loc, new GameFourSign(loc, game, getBlockFaced(loc.getBlock())));
final GameFour gname = plugin.getGM().getGameFourByName(game);
sign.setLine(0, plugin.getLang().get("signs.four.line-1").replaceAll("<state>", getState(gname.getState())).replaceAll("<name>", game).replaceAll("<players>", String.valueOf(gname.getPlayers().size())).replaceAll("<max>", String.valueOf(gname.getMax())));
sign.setLine(1, plugin.getLang().get("signs.four.line-2").replaceAll("<state>", getState(gname.getState())).replaceAll("<name>", game).replaceAll("<players>", String.valueOf(gname.getPlayers().size())).replaceAll("<max>", String.valueOf(gname.getMax())));
sign.setLine(2, plugin.getLang().get("signs.four.line-3").replaceAll("<state>", getState(gname.getState())).replaceAll("<name>", game).replaceAll("<players>", String.valueOf(gname.getPlayers().size())).replaceAll("<max>", String.valueOf(gname.getMax())));
sign.setLine(3, plugin.getLang().get("signs.four.line-4").replaceAll("<state>", getState(gname.getState())).replaceAll("<name>", game).replaceAll("<players>", String.valueOf(gname.getPlayers().size())).replaceAll("<max>", String.valueOf(gname.getMax())));
sign.update(true);
plugin.getSigns().save();
}
public void updateGameSign(Game game) {
for (final GameNormalSign sig : gameSign.values())
if (sig.getGame().equals(game.getName())) {
final Sign sign = sig.getSign();
sign.setLine(0, plugin.getLang().get("signs.normal.line-1").replaceAll("<state>", getState(game.getState())).replaceAll("<name>", game.getName()).replaceAll("<players>", String.valueOf(game.getPlayers())).replaceAll("<max>", String.valueOf(game.getMax())));
sign.setLine(1, plugin.getLang().get("signs.normal.line-2").replaceAll("<state>", getState(game.getState())).replaceAll("<name>", game.getName()).replaceAll("<players>", String.valueOf(game.getPlayers())).replaceAll("<max>", String.valueOf(game.getMax())));
sign.setLine(2, plugin.getLang().get("signs.normal.line-3").replaceAll("<state>", getState(game.getState())).replaceAll("<name>", game.getName()).replaceAll("<players>", String.valueOf(game.getPlayers())).replaceAll("<max>", String.valueOf(game.getMax())));
sign.setLine(3, plugin.getLang().get("signs.normal.line-4").replaceAll("<state>", getState(game.getState())).replaceAll("<name>", game.getName()).replaceAll("<players>", String.valueOf(game.getPlayers())).replaceAll("<max>", String.valueOf(game.getMax())));
sign.update();
updateBlock(game, sig.getRetract());
}
}
public void updateGameFourSign(GameFour game) {
for (final GameFourSign sig : gameFourSign.values())
if (sig.getGame().equals(game.getName())) {
final Sign sign = sig.getSign();
sign.setLine(0, plugin.getLang().get("signs.four.line-1").replaceAll("<state>", getState(game.getState())).replaceAll("<name>", game.getName()).replaceAll("<players>", String.valueOf(game.getPlayers().size())).replaceAll("<max>", String.valueOf(game.getMax())));
sign.setLine(1, plugin.getLang().get("signs.four.line-2").replaceAll("<state>", getState(game.getState())).replaceAll("<name>", game.getName()).replaceAll("<players>", String.valueOf(game.getPlayers().size())).replaceAll("<max>", String.valueOf(game.getMax())));
sign.setLine(2, plugin.getLang().get("signs.four.line-3").replaceAll("<state>", getState(game.getState())).replaceAll("<name>", game.getName()).replaceAll("<players>", String.valueOf(game.getPlayers().size())).replaceAll("<max>", String.valueOf(game.getMax())));
sign.setLine(3, plugin.getLang().get("signs.four.line-4").replaceAll("<state>", getState(game.getState())).replaceAll("<name>", game.getName()).replaceAll("<players>", String.valueOf(game.getPlayers().size())).replaceAll("<max>", String.valueOf(game.getMax())));
sign.update();
updateBlock(game, sig.getRetract());
}
}
public Location getStringLocation(String location) {
final String [] loca = location.split(";");
final Location loc = new Location(Bukkit.getWorld(loca[0]), Double.valueOf(loca[1]), Double.valueOf(loca[2]), Double.valueOf(loca[3]), Float.valueOf(loca[4]), Float.valueOf(loca[5]));
return loc;
}
@SuppressWarnings("deprecation")
public void updateBlock(Game game, Block b) {
if (game.isState(State.WAITING))
b.setData((byte)plugin.getConfig().getInt("signs.waiting"));
if (game.isState(State.STARTING))
b.setData((byte)plugin.getConfig().getInt("signs.starting"));
if (game.isState(State.PREGAME))
b.setData((byte)plugin.getConfig().getInt("signs.ingame"));
if (game.isState(State.INGAME))
b.setData((byte)plugin.getConfig().getInt("signs.ingame"));
if (game.isState(State.FINISH))
b.setData((byte)plugin.getConfig().getInt("signs.full"));
if (game.isState(State.RESTARTING))
b.setData((byte)plugin.getConfig().getInt("signs.restart"));
}
@SuppressWarnings("deprecation")
public void updateBlock(GameFour game, Block b) {
if (game.isState(FState.WAITING))
b.setData((byte)plugin.getConfig().getInt("signs.waiting"));
if (game.isState(FState.STARTING))
b.setData((byte)plugin.getConfig().getInt("signs.starting"));
if (game.isState(FState.PREGAME))
b.setData((byte)plugin.getConfig().getInt("signs.ingame"));
if (game.isState(FState.INGAME))
b.setData((byte)plugin.getConfig().getInt("signs.ingame"));
if (game.isState(FState.FINISH))
b.setData((byte)plugin.getConfig().getInt("signs.full"));
if (game.isState(FState.RESTARTING))
b.setData((byte)plugin.getConfig().getInt("signs.restart"));
}
protected String getState(FState state) {
if (state == FState.WAITING)
return plugin.getLang().get("states.waiting");
if (state == FState.STARTING)
return plugin.getLang().get("states.starting");
if (state == FState.PREGAME)
return plugin.getLang().get("states.pregame");
if (state == FState.INGAME)
return plugin.getLang().get("states.ingame");
if (state == FState.FINISH)
return plugin.getLang().get("states.finish");
if (state == FState.RESTARTING)
return plugin.getLang().get("states.restarting");
return "";
}
protected String getState(State state) {
if (state == State.WAITING)
return plugin.getLang().get("states.waiting");
if (state == State.STARTING)
return plugin.getLang().get("states.starting");
if (state == State.PREGAME)
return plugin.getLang().get("states.pregame");
if (state == State.INGAME)
return plugin.getLang().get("states.ingame");
if (state == State.FINISH)
return plugin.getLang().get("states.finish");
if (state == State.RESTARTING)
return plugin.getLang().get("states.restarting");
return "";
}
public String getLocationString(Location loc){
final String world = loc.getWorld().getName();
final double x = loc.getX();
final double y = loc.getY();
final double z = loc.getZ();
final float yaw = loc.getYaw();
final float pitch = loc.getPitch();
return world + ";" + x + ";" + y + ";" + z + ";" + yaw + ";" + pitch;
}
}

73
MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/TitleManager.java

@ -0,0 +1,73 @@
package cx.sfy.TheBridge.managers;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import cx.sfy.TheBridge.Main;
public class TitleManager {
Main plugin;
private final String preTitle;
private final String preSubTitle;
private final String startTitle;
private final String startSubTitle;
private final String restartTitle;
private final String restartSubTitle;
private final int pfadein;
private final int pstayin;
private final int pfadeout;
private final int sfadein;
private final int sstayin;
private final int sfadeout;
private final int rfadein;
private final int rstayin;
private final int rfadeout;
public TitleManager(Main plugin) {
this.plugin = plugin;
this.preTitle = plugin.getLang().get("titles.prestart.title");
this.preSubTitle = plugin.getLang().get("titles.prestart.subtitle");
this.pfadein = plugin.getConfig().getInt("title.prestart.fadein");
this.pstayin = plugin.getConfig().getInt("title.prestart.stayin");
this.pfadeout = plugin.getConfig().getInt("title.prestart.fadeout");
this.startTitle = plugin.getLang().get("titles.start.title");
this.startSubTitle = plugin.getLang().get("titles.start.subtitle");
this.sfadein = plugin.getConfig().getInt("title.start.fadein");
this.sstayin = plugin.getConfig().getInt("title.start.stayin");
this.sfadeout = plugin.getConfig().getInt("title.start.fadeout");
this.restartTitle = plugin.getLang().get("titles.restart.title");
this.restartSubTitle = plugin.getLang().get("titles.restart.subtitle");
this.rfadein = plugin.getConfig().getInt("title.restart.fadein");
this.rstayin = plugin.getConfig().getInt("title.restart.stayin");
this.rfadeout = plugin.getConfig().getInt("title.restart.fadeout");
}
public void sendPreTitle(Player p, int time, boolean s) {
if (s)
plugin.getNMS().sendTitle(p, pfadein, pstayin, pfadeout, preTitle.replaceAll("<none>", "").replaceAll("<time>", String.valueOf(time)).replaceAll("<s>", "s"), preSubTitle.replaceAll("<none>", "").replaceAll("<time>", String.valueOf(time)).replaceAll("<s>", "s"));
else
plugin.getNMS().sendTitle(p, pfadein, pstayin, pfadeout, preTitle.replaceAll("<none>", "").replaceAll("<time>", String.valueOf(time)).replaceAll("<s>", ""), preSubTitle.replaceAll("<none>", "").replaceAll("<time>", String.valueOf(time)).replaceAll("<s>", ""));
}
public void sendStartTitle(Player p, int time, boolean s) {
if (s)
plugin.getNMS().sendTitle(p, sfadein, sstayin, sfadeout, startTitle.replaceAll("<none>", "").replaceAll("<time>", getColor(time) + String.valueOf(time)).replaceAll("<s>", "s"), startSubTitle.replaceAll("<none>", "").replaceAll("<time>", getColor(time) + String.valueOf(time)).replaceAll("<s>", "s"));
else
plugin.getNMS().sendTitle(p, sfadein, sstayin, sfadeout, startTitle.replaceAll("<none>", "").replaceAll("<time>", getColor(time) + String.valueOf(time)).replaceAll("<s>", ""), startSubTitle.replaceAll("<none>", "").replaceAll("<time>", getColor(time) + String.valueOf(time)).replaceAll("<s>", ""));
}
public void sendReStartTitle(final Player w, final Player p, final int time, final boolean s) {
if (s)
this.plugin.getNMS().sendTitle(p, this.rfadein, this.rstayin, this.rfadeout, this.restartTitle.replaceAll("<color>", new StringBuilder().append(this.plugin.getGM().getGameByPlayer(p).getTeamPlayer(w).getColor()).toString()).replaceAll("<player>", w.getName()).replaceAll("<none>", "").replaceAll("<time>", String.valueOf(time)).replaceAll("<s>", "s"), this.restartSubTitle.replaceAll("<color>", new StringBuilder().append(this.plugin.getGM().getGameByPlayer(p).getTeamPlayer(w).getColor()).toString()).replaceAll("<player>", w.getName()).replaceAll("<none>", "").replaceAll("<time>", String.valueOf(time)).replaceAll("<s>", "s"));
else
this.plugin.getNMS().sendTitle(p, this.rfadein, this.rstayin, this.rfadeout, this.restartTitle.replaceAll("<color>", new StringBuilder().append(this.plugin.getGM().getGameByPlayer(p).getTeamPlayer(w).getColor()).toString()).replaceAll("<player>", w.getName()).replaceAll("<none>", "").replaceAll("<time>", String.valueOf(time)).replaceAll("<s>", ""), this.restartSubTitle.replaceAll("<color>", new StringBuilder().append(this.plugin.getGM().getGameByPlayer(p).getTeamPlayer(w).getColor()).toString()).replaceAll("<player>", w.getName()).replaceAll("<none>", "").replaceAll("<time>", String.valueOf(time)).replaceAll("<s>", ""));
}
private ChatColor getColor(int time) {
if (time > 10)
return ChatColor.GREEN;
return ChatColor.RED;
}
}

251
MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/TopManager.java

@ -0,0 +1,251 @@
package cx.sfy.TheBridge.managers;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.hologram.TruenoHologram;
import cx.sfy.TheBridge.hologram.TruenoHologramAPI;
import cx.sfy.TheBridge.tops.BoardType;
import cx.sfy.TheBridge.tops.Top;
import me.clip.placeholderapi.PlaceholderAPI;
public class TopManager {
private HashMap<Integer, Top> nkills = new HashMap<Integer, Top>();
private HashMap<Integer, Top> nwins = new HashMap<Integer, Top>();
private HashMap<Integer, Top> ngoals = new HashMap<Integer, Top>();
private HashMap<Integer, Top> fkills = new HashMap<Integer, Top>();
private HashMap<Integer, Top> fwins = new HashMap<Integer, Top>();
private HashMap<Integer, Top> fgoals = new HashMap<Integer, Top>();
private ArrayList<String> nkillslines = new ArrayList<String>();
private ArrayList<String> nwinslines = new ArrayList<String>();
private ArrayList<String> ngoalslines = new ArrayList<String>();
private ArrayList<String> fkillslines = new ArrayList<String>();
private ArrayList<String> fwinslines = new ArrayList<String>();
private ArrayList<String> fgoalslines = new ArrayList<String>();
private HashMap<Player, ArrayList<TruenoHologram>> playerHolo = new HashMap<Player, ArrayList<TruenoHologram>>();
private HashMap<BoardType, TruenoHologram> holo = new HashMap<BoardType, TruenoHologram>();
Main plugin;
public TopManager(Main plugin) {
this.plugin = plugin;
}
public void updateTops() {
plugin.getLM().reloadLocations();
nkills.clear();
nwins.clear();
ngoals.clear();
fkills.clear();
fwins.clear();
fgoals.clear();
plugin.getDB().loadNormalKills();
plugin.getDB().loadNormalWins();
plugin.getDB().loadNormalGoals();
plugin.getDB().loadFourKills();
plugin.getDB().loadFourWins();
plugin.getDB().loadFourGoals();
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "Tops Updated");
}
public void createInfo(Player p) {
if (!playerHolo.containsKey(p)) {
playerHolo.put(p, new ArrayList<TruenoHologram>());
}
removeHolo(p);
if (plugin.getLM().getStats() != null) {
ArrayList<String> stats = new ArrayList<String>();
Bukkit.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
for (String msg2 : plugin.getLang().getList("stats")) {
stats.add(PlaceholderAPI.setPlaceholders(p, ChatColor.translateAlternateColorCodes('&', msg2)));
}
TruenoHologram hologram2 = TruenoHologramAPI.getNewHologram();
hologram2.setupPlayerHologram(p, plugin.getLM().getStats(), stats);
hologram2.display();
playerHolo.get(p).add(hologram2);
}
}, 20L);
}
}
public void removeHolo(Player p) {
for (TruenoHologram holo : playerHolo.get(p)) {
holo.delete();
}
}
public void removeHolo() {
for (TruenoHologram holo : holo.values()) {
holo.delete();
}
}
public void removeHolo(BoardType type) {
if (holo.containsKey(type)) {
holo.get(type).delete();
}
}
public void createTop(Location location, BoardType type) {
if (type.equals(BoardType.NORMAL_KILLS)) {
removeHolo(type);
nkillslines.clear();
for (String line : plugin.getLang().getList("tops.normal.kills")) {
if (line.contains("<top>")) {
for (Top top : nkills.values()) {
nkillslines.add(ChatColor.YELLOW + "" + ChatColor.BOLD + top.getTop() + ".- " + ChatColor.GRAY + top.getName() + " - " + ChatColor.GOLD + "" + top.getAmount());
}
} else {
nkillslines.add(ChatColor.translateAlternateColorCodes('&', line));
}
}
TruenoHologram hologram = TruenoHologramAPI.getNewHologram();
hologram.setDistanceBetweenLines(0.35);
hologram.setupWorldHologram(location, nkillslines);
hologram.display();
holo.put(type, hologram);
}
if (type.equals(BoardType.NORMAL_WINS)) {
removeHolo(type);
nwinslines.clear();
for (String line : plugin.getLang().getList("tops.normal.wins")) {
if (line.contains("<top>")) {
for (Top top : nwins.values()) {
nwinslines.add(ChatColor.YELLOW + "" + ChatColor.BOLD + top.getTop() + ".- " + ChatColor.GRAY + top.getName() + " - " + ChatColor.GOLD + "" + top.getAmount());
}
} else {
nwinslines.add(ChatColor.translateAlternateColorCodes('&', line));
}
}
TruenoHologram hologram = TruenoHologramAPI.getNewHologram();
hologram.setDistanceBetweenLines(0.35);
hologram.setupWorldHologram(location, nwinslines);
hologram.display();
holo.put(type, hologram);
}
if (type.equals(BoardType.NORMAL_GOALS)) {
removeHolo(type);
ngoalslines.clear();
for (String line : plugin.getLang().getList("tops.normal.goals")) {
if (line.contains("<top>")) {
for (Top top : ngoals.values()) {
ngoalslines.add(ChatColor.YELLOW + "" + ChatColor.BOLD + top.getTop() + ".- " + ChatColor.GRAY + top.getName() + " - " + ChatColor.GOLD + "" + top.getAmount());
}
} else {
ngoalslines.add(ChatColor.translateAlternateColorCodes('&', line));
}
}
TruenoHologram hologram = TruenoHologramAPI.getNewHologram();
hologram.setDistanceBetweenLines(0.35);
hologram.setupWorldHologram(location, ngoalslines);
hologram.display();
holo.put(type, hologram);
}
if (type.equals(BoardType.FOUR_KILLS)) {
removeHolo(type);
fkillslines.clear();
for (String line : plugin.getLang().getList("tops.four.kills")) {
if (line.contains("<top>")) {
for (Top top : fkills.values()) {
fkillslines.add(ChatColor.YELLOW + "" + ChatColor.BOLD + top.getTop() + ".- " + ChatColor.GRAY + top.getName() + " - " + ChatColor.GOLD + "" + top.getAmount());
}
} else {
fkillslines.add(ChatColor.translateAlternateColorCodes('&', line));
}
}
TruenoHologram hologram = TruenoHologramAPI.getNewHologram();
hologram.setDistanceBetweenLines(0.35);
hologram.setupWorldHologram(location, fkillslines);
hologram.display();
holo.put(type, hologram);
}
if (type.equals(BoardType.FOUR_WINS)) {
removeHolo(type);
fwinslines.clear();
for (String line : plugin.getLang().getList("tops.four.wins")) {
if (line.contains("<top>")) {
for (Top top : fwins.values()) {
fwinslines.add(ChatColor.YELLOW + "" + ChatColor.BOLD + top.getTop() + ".- " + ChatColor.GRAY + top.getName() + " - " + ChatColor.GOLD + "" + top.getAmount());
}
} else {
fwinslines.add(ChatColor.translateAlternateColorCodes('&', line));
}
}
TruenoHologram hologram = TruenoHologramAPI.getNewHologram();
hologram.setDistanceBetweenLines(0.35);
hologram.setupWorldHologram(location, fwinslines);
hologram.display();
holo.put(type, hologram);
}
if (type.equals(BoardType.FOUR_GOALS)) {
removeHolo(type);
fgoalslines.clear();
for (String line : plugin.getLang().getList("tops.four.goals")) {
if (line.contains("<top>")) {
for (Top top : fgoals.values()) {
fgoalslines.add(ChatColor.YELLOW + "" + ChatColor.BOLD + top.getTop() + ".- " + ChatColor.GRAY + top.getName() + " - " + ChatColor.GOLD + "" + top.getAmount());
}
} else {
fgoalslines.add(ChatColor.translateAlternateColorCodes('&', line));
}
}
TruenoHologram hologram = TruenoHologramAPI.getNewHologram();
hologram.setDistanceBetweenLines(0.35);
hologram.setupWorldHologram(location, fgoalslines);
hologram.display();
holo.put(type, hologram);
}
}
public void addTop(Top top) {
if (top.getType().equals(BoardType.NORMAL_KILLS)) {
nkills.put(getTopNumber(top), top);
} else if (top.getType().equals(BoardType.NORMAL_WINS)) {
nwins.put(getTopNumber(top), top);
} else if (top.getType().equals(BoardType.NORMAL_GOALS)) {
ngoals.put(getTopNumber(top), top);
} else if (top.getType().equals(BoardType.FOUR_KILLS)) {
fkills.put(getTopNumber(top), top);
} else if (top.getType().equals(BoardType.FOUR_WINS)) {
fwins.put(getTopNumber(top), top);
} else if (top.getType().equals(BoardType.FOUR_GOALS)) {
fgoals.put(getTopNumber(top), top);
}
}
public int getTopNumber(Top top) {
if (top.getType().equals(BoardType.NORMAL_KILLS)) {
return nkills.size() + 1;
}
if (top.getType().equals(BoardType.NORMAL_WINS)) {
return nwins.size() + 1;
}
if (top.getType().equals(BoardType.NORMAL_GOALS)) {
return ngoals.size() + 1;
}
if (top.getType().equals(BoardType.FOUR_KILLS)) {
return fkills.size() + 1;
}
if (top.getType().equals(BoardType.FOUR_WINS)) {
return fwins.size() + 1;
}
if (top.getType().equals(BoardType.FOUR_GOALS)) {
return fgoals.size() + 1;
}
return 0;
}
public HashMap<Player, ArrayList<TruenoHologram>> getHolograms(){
return playerHolo;
}
}

212
MultiArena-TheBridge/src/cx/sfy/TheBridge/menus/AchievementsMenu.java

@ -0,0 +1,212 @@
package cx.sfy.TheBridge.menus;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.SkullType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.archievements.Archi;
import cx.sfy.TheBridge.archievements.ArchiType;
import cx.sfy.TheBridge.database.PlayerStat;
import cx.sfy.TheBridge.listeners.PlayerListener;
import cx.sfy.TheBridge.utils.ItemBuilder;
public class AchievementsMenu {
Main plugin;
public AchievementsMenu(Main plugin) {
this.plugin = plugin;
}
public void createArchievementsMenu(Player p, int page) {
PlayerStat ps = PlayerStat.getPlayerStat(p);
Inventory inv = Bukkit.getServer().createInventory(null, 54, plugin.getAchievement().get("title").replaceAll("<player>", p.getName()));
ItemStack signKill = ItemBuilder.item(Material.valueOf(plugin.getAchievement().get("kills.item")), plugin.getAchievement().getInt("kills.amount"), (short)plugin.getAchievement().getInt("kills.data"), plugin.getAchievement().get("kills.name"), plugin.getAchievement().get("kills.lore"));
ItemStack signWin = ItemBuilder.item(Material.valueOf(plugin.getAchievement().get("wins.item")), plugin.getAchievement().getInt("wins.amount"), (short)plugin.getAchievement().getInt("wins.data"), plugin.getAchievement().get("wins.name"), plugin.getAchievement().get("wins.lore"));
ItemStack signGoals = ItemBuilder.item(Material.valueOf(plugin.getAchievement().get("goals.item")), plugin.getAchievement().getInt("goals.amount"), (short)plugin.getAchievement().getInt("goals.data"), plugin.getAchievement().get("goals.name"), plugin.getAchievement().get("goals.lore"));
ItemStack signPlaced = ItemBuilder.item(Material.valueOf(plugin.getAchievement().get("blocks_placed.item")), plugin.getAchievement().getInt("blocks_placed.amount"), (short)plugin.getAchievement().getInt("blocks_placed.data"), plugin.getAchievement().get("blocks_placed.name"), plugin.getAchievement().get("blocks_placed.lore"));
ItemStack signBroken = ItemBuilder.item(Material.valueOf(plugin.getAchievement().get("blocks_bloken.item")), plugin.getAchievement().getInt("blocks_bloken.amount"), (short)plugin.getAchievement().getInt("blocks_bloken.data"), plugin.getAchievement().get("blocks_bloken.name"), plugin.getAchievement().get("blocks_bloken.lore"));
ItemStack gLeft = ItemBuilder.item(Material.STAINED_GLASS_PANE, 1, (short)7, plugin.getAchievement().get("archivements").replaceAll("<arrow>", "→"), "");
ItemStack gRight = ItemBuilder.item(Material.STAINED_GLASS_PANE, 1, (short)7, plugin.getAchievement().get("archivements").replaceAll("<arrow>", "�"), "");
ItemStack next = ItemBuilder.createSkull(Material.SKULL_ITEM, 1, (short)SkullType.PLAYER.ordinal(), plugin.getAchievement().get("next").replaceAll("<next>", "→"), "", "creeyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjgyYWQxYjljYjRkZDIxMjU5YzBkNzVhYTMxNWZmMzg5YzNjZWY3NTJiZTM5NDkzMzgxNjRiYWM4NGE5NmUifX19");
ItemStack back = ItemBuilder.createSkull(Material.SKULL_ITEM, 1, (short)SkullType.PLAYER.ordinal(), plugin.getAchievement().get("back").replaceAll("<back>", "�"), "", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzdhZWU5YTc1YmYwZGY3ODk3MTgzMDE1Y2NhMGIyYTdkNzU1YzYzMzg4ZmYwMTc1MmQ1ZjQ0MTlmYzY0NSJ9fX0=");
ItemStack close = ItemBuilder.item(Material.valueOf(plugin.getAchievement().get("close.item")), plugin.getAchievement().getInt("close.amount"), (short)plugin.getAchievement().getInt("close.data"), plugin.getAchievement().get("close.name"), plugin.getAchievement().get("close.lore"));
inv.setItem(0, gLeft);
inv.setItem(9, gLeft);
inv.setItem(18, gLeft);
inv.setItem(27, gLeft);
inv.setItem(36, gLeft);
inv.setItem(8, gRight);
inv.setItem(17, gRight);
inv.setItem(26, gRight);
inv.setItem(35, gRight);
inv.setItem(44, gRight);
inv.setItem(2, signKill);
inv.setItem(3, signWin);
inv.setItem(4, signGoals);
inv.setItem(5, signPlaced);
inv.setItem(6, signBroken);
if (plugin.getAM().getArchiements().get(ArchiType.KILLS).size() >= (page + 1) * 4
&& plugin.getAM().getArchiements().get(ArchiType.WINS).size() >= (page + 1) * 4
&& plugin.getAM().getArchiements().get(ArchiType.GOALS).size() >= (page + 1) * 4
&& plugin.getAM().getArchiements().get(ArchiType.BLOCKS_PLACED).size() >= (page + 1) * 4
&& plugin.getAM().getArchiements().get(ArchiType.BLOCKS_BROKEN).size() >= (page + 1) * 4) {
inv.setItem(53, next);
}
if (PlayerListener.page.containsKey(p)) {
inv.setItem(45, back);
}
inv.setItem(49, close);
int min = (page - 1) * 4;
for (int i = 1; i < 5; i++) {
Archi archi = plugin.getAM().getArchiements().get(ArchiType.KILLS).get((i - 1) + min);
if (ps.getFourKills() + ps.getNormalKills() <= archi.getMax()) {
ItemStack locked = plugin.getAM().getLocked().clone();
ItemMeta lockedM = locked.getItemMeta();
List<String> loreNew = new ArrayList<String>();
for (String msg : lockedM.getLore()) {
loreNew.add(msg.replaceAll("&", "§").replaceAll("<money>", String.valueOf(archi.getMoney())).replaceAll("<xp>", String.valueOf(archi.getXp())).replaceAll("<max>", String.valueOf(archi.getMax())).replaceAll("<name>", archi.getName()).replaceAll("<description>", archi.getDescription()).replaceAll("<current>", String.valueOf(ps.getFourKills() + ps.getNormalKills())));
}
lockedM.setDisplayName("§c" + archi.getName());
lockedM.getLore().clear();
lockedM.setLore(loreNew);
locked.setItemMeta(lockedM);
inv.setItem(2 + (9 * (i)), locked);
} else {
ItemStack unlocked = plugin.getAM().getUnlocked().clone();
ItemMeta unlockedM = unlocked.getItemMeta();
List<String> loreNew = new ArrayList<String>();
for (String msg : unlockedM.getLore()) {
loreNew.add(msg.replaceAll("&", "§").replaceAll("<money>", String.valueOf(archi.getMoney())).replaceAll("<xp>", String.valueOf(archi.getXp())).replaceAll("<name>", archi.getName()).replaceAll("<description>", archi.getDescription()).replaceAll("<current>", String.valueOf(ps.getFourKills() + ps.getNormalKills())));
}
unlockedM.setDisplayName("§a" + archi.getName());
unlockedM.getLore().clear();
unlockedM.setLore(loreNew);
unlocked.setItemMeta(unlockedM);
inv.setItem(2 + (9 * (i)), unlocked);
}
}
for (int i = 1; i < 5; i++) {
Archi archi = plugin.getAM().getArchiements().get(ArchiType.WINS).get((i - 1) + min);
if (ps.getFourWins() + ps.getNormalWins() <= archi.getMax()) {
ItemStack locked = plugin.getAM().getLocked().clone();
ItemMeta lockedM = locked.getItemMeta();
List<String> loreNew = new ArrayList<String>();
for (String msg : lockedM.getLore()) {
loreNew.add(msg.replaceAll("&", "§").replaceAll("<money>", String.valueOf(archi.getMoney())).replaceAll("<xp>", String.valueOf(archi.getXp())).replaceAll("<max>", String.valueOf(archi.getMax())).replaceAll("<name>", archi.getName()).replaceAll("<description>", archi.getDescription()).replaceAll("<current>", String.valueOf(ps.getFourWins() + ps.getNormalWins())));
}
lockedM.setDisplayName("§c" + archi.getName());
lockedM.getLore().clear();
lockedM.setLore(loreNew);
locked.setItemMeta(lockedM);
inv.setItem(3 + (9 * (i)), locked);
} else {
ItemStack unlocked = plugin.getAM().getUnlocked().clone();
ItemMeta unlockedM = unlocked.getItemMeta();
List<String> loreNew = new ArrayList<String>();
for (String msg : unlockedM.getLore()) {
loreNew.add(msg.replaceAll("&", "§").replaceAll("<money>", String.valueOf(archi.getMoney())).replaceAll("<xp>", String.valueOf(archi.getXp())).replaceAll("<name>", archi.getName()).replaceAll("<description>", archi.getDescription()).replaceAll("<current>", String.valueOf(ps.getFourWins() + ps.getNormalWins())));
}
unlockedM.setDisplayName("§a" + archi.getName());
unlockedM.getLore().clear();
unlockedM.setLore(loreNew);
unlocked.setItemMeta(unlockedM);
inv.setItem(3 + (9 * (i)), unlocked);
}
}
for (int i = 1; i < 5; i++) {
Archi archi = plugin.getAM().getArchiements().get(ArchiType.GOALS).get((i - 1) + min);
if (ps.getFourGoals() + ps.getNormalGoals() <= archi.getMax()) {
ItemStack locked = plugin.getAM().getLocked().clone();
ItemMeta lockedM = locked.getItemMeta();
List<String> loreNew = new ArrayList<String>();
for (String msg : lockedM.getLore()) {
loreNew.add(msg.replaceAll("&", "§").replaceAll("<money>", String.valueOf(archi.getMoney())).replaceAll("<xp>", String.valueOf(archi.getXp())).replaceAll("<max>", String.valueOf(archi.getMax())).replaceAll("<name>", archi.getName()).replaceAll("<description>", archi.getDescription()).replaceAll("<current>", String.valueOf(ps.getFourGoals() + ps.getNormalGoals())));
}
lockedM.setDisplayName("§c" + archi.getName());
lockedM.getLore().clear();
lockedM.setLore(loreNew);
locked.setItemMeta(lockedM);
inv.setItem(4 + (9 * (i)), locked);
} else {
ItemStack unlocked = plugin.getAM().getUnlocked().clone();
ItemMeta unlockedM = unlocked.getItemMeta();
List<String> loreNew = new ArrayList<String>();
for (String msg : unlockedM.getLore()) {
loreNew.add(msg.replaceAll("&", "§").replaceAll("<money>", String.valueOf(archi.getMoney())).replaceAll("<xp>", String.valueOf(archi.getXp())).replaceAll("<name>", archi.getName()).replaceAll("<description>", archi.getDescription()).replaceAll("<current>", String.valueOf(ps.getFourGoals() + ps.getNormalGoals())));
}
unlockedM.setDisplayName("§a" + archi.getName());
unlockedM.getLore().clear();
unlockedM.setLore(loreNew);
unlocked.setItemMeta(unlockedM);
inv.setItem(4 + (9 * (i)), unlocked);
}
}
for (int i = 1; i < 5; i++) {
Archi archi = plugin.getAM().getArchiements().get(ArchiType.BLOCKS_PLACED).get((i - 1) + min);
if (ps.getPlaced() <= archi.getMax()) {
ItemStack locked = plugin.getAM().getLocked().clone();
ItemMeta lockedM = locked.getItemMeta();
List<String> loreNew = new ArrayList<String>();
for (String msg : lockedM.getLore()) {
loreNew.add(msg.replaceAll("&", "§").replaceAll("<money>", String.valueOf(archi.getMoney())).replaceAll("<xp>", String.valueOf(archi.getXp())).replaceAll("<max>", String.valueOf(archi.getMax())).replaceAll("<name>", archi.getName()).replaceAll("<description>", archi.getDescription()).replaceAll("<current>", String.valueOf(ps.getPlaced())));
}
lockedM.setDisplayName("§c" + archi.getName());
lockedM.getLore().clear();
lockedM.setLore(loreNew);
locked.setItemMeta(lockedM);
inv.setItem(5 + (9 * (i)), locked);
} else {
ItemStack unlocked = plugin.getAM().getUnlocked().clone();
ItemMeta unlockedM = unlocked.getItemMeta();
List<String> loreNew = new ArrayList<String>();
for (String msg : unlockedM.getLore()) {
loreNew.add(msg.replaceAll("&", "§").replaceAll("<money>", String.valueOf(archi.getMoney())).replaceAll("<xp>", String.valueOf(archi.getXp())).replaceAll("<name>", archi.getName()).replaceAll("<description>", archi.getDescription()).replaceAll("<current>", String.valueOf(ps.getPlaced())));
}
unlockedM.setDisplayName("§a" + archi.getName());
unlockedM.getLore().clear();
unlockedM.setLore(loreNew);
unlocked.setItemMeta(unlockedM);
inv.setItem(5 + (9 * (i)), unlocked);
}
}
for (int i = 1; i < 5; i++) {
Archi archi = plugin.getAM().getArchiements().get(ArchiType.BLOCKS_BROKEN).get((i - 1) + min);
if (ps.getBroken() <= archi.getMax()) {
ItemStack locked = plugin.getAM().getLocked().clone();
ItemMeta lockedM = locked.getItemMeta();
List<String> loreNew = new ArrayList<String>();
for (String msg : lockedM.getLore()) {
loreNew.add(msg.replaceAll("&", "§").replaceAll("<money>", String.valueOf(archi.getMoney())).replaceAll("<xp>", String.valueOf(archi.getXp())).replaceAll("<max>", String.valueOf(archi.getMax())).replaceAll("<name>", archi.getName()).replaceAll("<description>", archi.getDescription()).replaceAll("<current>", String.valueOf(ps.getBroken())));
}
lockedM.setDisplayName("§c" + archi.getName());
lockedM.getLore().clear();
lockedM.setLore(loreNew);
locked.setItemMeta(lockedM);
inv.setItem(6 + (9 * (i)), locked);
} else {
ItemStack unlocked = plugin.getAM().getUnlocked().clone();
ItemMeta unlockedM = unlocked.getItemMeta();
List<String> loreNew = new ArrayList<String>();
for (String msg : unlockedM.getLore()) {
loreNew.add(msg.replaceAll("&", "§").replaceAll("<money>", String.valueOf(archi.getMoney())).replaceAll("<xp>", String.valueOf(archi.getXp())).replaceAll("<name>", archi.getName()).replaceAll("<description>", archi.getDescription()).replaceAll("<current>", String.valueOf(ps.getBroken())));
}
unlockedM.setDisplayName("§a" + archi.getName());
unlockedM.getLore().clear();
unlockedM.setLore(loreNew);
unlocked.setItemMeta(unlockedM);
inv.setItem(6 + (9 * (i)), unlocked);
}
}
p.openInventory(inv);
}
}

121
MultiArena-TheBridge/src/cx/sfy/TheBridge/menus/GameMenu.java

@ -0,0 +1,121 @@
package cx.sfy.TheBridge.menus;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.game.Game;
import cx.sfy.TheBridge.game.Game.State;
import cx.sfy.TheBridge.game.GameFour;
import cx.sfy.TheBridge.game.GameFour.FState;
import cx.sfy.TheBridge.utils.ItemBuilder;
public class GameMenu {
Main plugin;
public GameMenu(Main plugin) {
this.plugin = plugin;
}
public void openSelectTypeMenu(Player p) {
final Inventory inv = Bukkit.getServer().createInventory(null, 27, plugin.getLang().get(p, "menus.type.title"));
final ItemStack normal = ItemBuilder.item(Material.STAINED_CLAY, 1, (short)11, plugin.getLang().get(p, "menus.type.normal.nameItem"), plugin.getLang().get(p, "menus.type.normal.loreItem"));
final ItemStack four = ItemBuilder.item(Material.STAINED_CLAY, 1, (short)14, plugin.getLang().get(p, "menus.type.four.nameItem"), plugin.getLang().get(p, "menus.type.four.loreItem"));
inv.setItem(11, normal);
inv.setItem(15, four);
p.openInventory(inv);
}
public void openGameMenu(Player p) {
final Inventory inv = Bukkit.getServer().createInventory(null, 27, plugin.getLang().get(p, "menus.game.title"));
for (final Game game : plugin.getGM().getGames())
inv.addItem(game(p, game));
p.openInventory(inv);
}
public void openGameFourMenu(Player p) {
final Inventory inv = Bukkit.getServer().createInventory(null, 27, plugin.getLang().get(p, "menus.gameFour.title"));
for (final GameFour game : plugin.getGM().getGamesFour())
inv.addItem(game(p, game));
p.openInventory(inv);
}
protected ItemStack game(Player p, Game game) {
final ItemStack item = ItemBuilder.item(Material.STAINED_CLAY, 1, getState(game), "§a" + game.getName(), plugin.getLang().get(p, "menus.game.generalDesc").replaceAll("<players>", String.valueOf(game.getPlayers())).replaceAll("<max>", String.valueOf(game.getMax())).replaceAll("<mode>", game.getMode()).replaceAll("<state>", getState(game.getState())));
return item;
}
protected ItemStack game(Player p, GameFour game) {
final ItemStack item = ItemBuilder.item(Material.STAINED_CLAY, 1, getState(game), "§a" + game.getName(), plugin.getLang().get(p, "menus.game.generalDesc").replaceAll("<players>", String.valueOf(game.getPlayers().size())).replaceAll("<max>", String.valueOf(game.getMax())).replaceAll("<mode>", game.getMode()).replaceAll("<state>", getState(game.getState())));
return item;
}
protected String getState(FState state) {
if (state == FState.WAITING)
return plugin.getLang().get("states.waiting");
if (state == FState.STARTING)
return plugin.getLang().get("states.starting");
if (state == FState.PREGAME)
return plugin.getLang().get("states.pregame");
if (state == FState.INGAME)
return plugin.getLang().get("states.ingame");
if (state == FState.FINISH)
return plugin.getLang().get("states.finish");
if (state == FState.RESTARTING)
return plugin.getLang().get("states.restarting");
return "";
}
protected String getState(State state) {
if (state == State.WAITING)
return plugin.getLang().get("states.waiting");
if (state == State.STARTING)
return plugin.getLang().get("states.starting");
if (state == State.PREGAME)
return plugin.getLang().get("states.pregame");
if (state == State.INGAME)
return plugin.getLang().get("states.ingame");
if (state == State.FINISH)
return plugin.getLang().get("states.finish");
if (state == State.RESTARTING)
return plugin.getLang().get("states.restarting");
return "";
}
protected short getState(Game game) {
if (game.isState(State.WAITING))
return (short)plugin.getConfig().getInt("signs.waiting");
if (game.isState(State.STARTING))
return (short)plugin.getConfig().getInt("signs.starting");
if (game.isState(State.PREGAME))
return (short)plugin.getConfig().getInt("signs.pregame");
if (game.isState(State.INGAME))
return (short)plugin.getConfig().getInt("signs.ingame");
if (game.isState(State.RESTARTING))
return (short)plugin.getConfig().getInt("signs.restart");
if (game.isState(State.FINISH))
return (short)plugin.getConfig().getInt("signs.finish");
return 5;
}
protected short getState(GameFour game) {
if (game.isState(FState.WAITING))
return (short)plugin.getConfig().getInt("signs.waiting");
if (game.isState(FState.STARTING))
return (short)plugin.getConfig().getInt("signs.starting");
if (game.isState(FState.PREGAME))
return (short)plugin.getConfig().getInt("signs.pregame");
if (game.isState(FState.INGAME))
return (short)plugin.getConfig().getInt("signs.ingame");
if (game.isState(FState.RESTARTING))
return (short)plugin.getConfig().getInt("signs.restart");
if (game.isState(FState.FINISH))
return (short)plugin.getConfig().getInt("signs.finish");
return 5;
}
}

33
MultiArena-TheBridge/src/cx/sfy/TheBridge/menus/GlassMenu.java

@ -0,0 +1,33 @@
package cx.sfy.TheBridge.menus;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.cosmetics.cages.Cage;
public class GlassMenu {
Main plugin;
public GlassMenu(Main plugin) {
this.plugin = plugin;
}
public void createGlassMenu(Player p) {
Inventory inv = Bukkit.getServer().createInventory(null, plugin.getCages().getInt("size"), plugin.getCages().get("title"));
for (Cage cage : plugin.getCM().getCages().values()) {
System.out.println(cage == null);
if (!cage.isBuy() && !p.hasPermission(cage.getPermission())) {
inv.setItem(cage.getSlot(), cage.getPermIcon());
} else if (cage.isBuy() && !p.hasPermission(cage.getPermission())) {
inv.setItem(cage.getSlot(), cage.getBuyIcon());
} else {
inv.setItem(cage.getSlot(), cage.getHasIcon());
}
}
p.openInventory(inv);
}
}

29
MultiArena-TheBridge/src/cx/sfy/TheBridge/menus/ShopMenu.java

@ -0,0 +1,29 @@
package cx.sfy.TheBridge.menus;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.utils.ItemBuilder;
public class ShopMenu {
Main plugin;
public ShopMenu(Main plugin) {
this.plugin = plugin;
}
public void openShopMenu(Player p) {
Inventory inv = Bukkit.getServer().createInventory(null, plugin.getConfig().getInt("shop.size"), plugin.getLang().get("shop.title"));
ItemStack glass = ItemBuilder.item(Material.valueOf(plugin.getConfig().getString("shop.glass.icon")), plugin.getConfig().getInt("shop.glass.amount"), (short)plugin.getConfig().getInt("shop.glass.data"), plugin.getLang().get("shop.glass.nameItem"), plugin.getLang().get("shop.glass.loreItem"));
ItemStack close = ItemBuilder.item(Material.valueOf(plugin.getConfig().getString("shop.close.icon")), plugin.getConfig().getInt("shop.close.amount"), (short)plugin.getConfig().getInt("shop.close.data"), plugin.getLang().get("shop.close.nameItem"), plugin.getLang().get("shop.close.loreItem"));
inv.setItem(plugin.getConfig().getInt("shop.glass.slot"), glass);
inv.setItem(plugin.getConfig().getInt("shop.close.slot"), close);
p.openInventory(inv);
}
}

49
MultiArena-TheBridge/src/cx/sfy/TheBridge/menus/SpectOptionsMenu.java

@ -0,0 +1,49 @@
package cx.sfy.TheBridge.menus;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.utils.ItemBuilder;
public class SpectOptionsMenu {
public HashMap<Player, Boolean> settings = new HashMap<Player, Boolean>();
public Main plugin;
public SpectOptionsMenu(Main plugin){
this.plugin = plugin;
}
public void openOptionsMenu(Player p) {
Inventory inv = Bukkit.createInventory(null, 36, plugin.getLang().get("menus.options.title"));
ItemStack velo1 = ItemBuilder.item(Material.LEATHER_BOOTS, 1, (short)0, plugin.getLang().get("menus.options.velocidad.nameItem").replaceAll("<#>", "I"), plugin.getLang().get("menus.options.velocidad.loreItem").replaceAll("<#>", "I"));
ItemStack velo2 = ItemBuilder.item(Material.GOLD_BOOTS, 1, (short)0, plugin.getLang().get("menus.options.velocidad.nameItem").replaceAll("<#>", "II"), plugin.getLang().get("menus.options.velocidad.loreItem").replaceAll("<#>", "II"));
ItemStack velo3 = ItemBuilder.item(Material.CHAINMAIL_BOOTS, 1, (short)0, plugin.getLang().get("menus.options.velocidad.nameItem").replaceAll("<#>", "III"), plugin.getLang().get("menus.options.velocidad.loreItem").replaceAll("<#>", "III"));
ItemStack velo4 = ItemBuilder.item(Material.IRON_BOOTS, 1, (short)0, plugin.getLang().get("menus.options.velocidad.nameItem").replaceAll("<#>", "IV"), plugin.getLang().get("menus.options.velocidad.loreItem").replaceAll("<#>", "IV"));
ItemStack velo5 = ItemBuilder.item(Material.DIAMOND_BOOTS, 1, (short)0, plugin.getLang().get("menus.options.velocidad.nameItem").replaceAll("<#>", "V"), plugin.getLang().get("menus.options.velocidad.loreItem").replaceAll("<#>", "V"));
ItemStack visNo = ItemBuilder.item(Material.EYE_OF_ENDER, 1, (short)0, plugin.getLang().get("menus.options.vision.nameItem").replaceAll("<type>", plugin.getLang().get("menus.options.enable")), plugin.getLang().get("menus.options.vision.loreItem").replaceAll("<type>", plugin.getLang().get("menus.options.enable")));
ItemStack visSi = ItemBuilder.item(Material.ENDER_PEARL, 1, (short)0, plugin.getLang().get("menus.options.vision.nameItem").replaceAll("<type>", plugin.getLang().get("menus.options.disable")), plugin.getLang().get("menus.options.vision.loreItem").replaceAll("<type>", plugin.getLang().get("menus.options.disable")));
inv.setItem(11, velo1);
inv.setItem(12, velo2);
inv.setItem(13, velo3);
inv.setItem(14, velo4);
inv.setItem(15, velo5);
if (settings.containsKey(p)) {
if (settings.get(p) == true) {
inv.setItem(22, visNo);
} else {
inv.setItem(22, visSi);
}
} else {
settings.put(p, false);
inv.setItem(22, visSi);
}
p.openInventory(inv);
}
}

81
MultiArena-TheBridge/src/cx/sfy/TheBridge/menus/SpectPlayerMenu.java

@ -0,0 +1,81 @@
package cx.sfy.TheBridge.menus;
import java.text.DecimalFormat;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.SkullType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.game.GameFour;
import cx.sfy.TheBridge.team.TeamFour;
import cx.sfy.TheBridge.utils.ItemBuilder;
public class SpectPlayerMenu {
Main plugin;
DecimalFormat df = new DecimalFormat("##.##");
public SpectPlayerMenu(Main plugin) {
this.plugin = plugin;
}
public void openSpectPlayerMenu(Player p) {
GameFour game = plugin.getGM().getGameFourByPlayer(p);
Inventory inv = Bukkit.getServer().createInventory(null, 54, plugin.getLang().get("menus.options.title"));
ItemStack wool1 = ItemBuilder.item(Material.STAINED_CLAY, 1, (short)11, plugin.getLang().get("menus.teleport.team.nameItem").replaceAll("<color>", "" + ChatColor.BLUE).replaceAll("<team>", game.getTeams().get(ChatColor.BLUE).getTeamName()), plugin.getLang().get("menus.teleport.team.loreItem"));
ItemStack wool2 = ItemBuilder.item(Material.STAINED_CLAY, 1, (short)14, plugin.getLang().get("menus.teleport.team.nameItem").replaceAll("<color>", "" + ChatColor.RED).replaceAll("<team>", game.getTeams().get(ChatColor.RED).getTeamName()), plugin.getLang().get("menus.teleport.team.loreItem"));
ItemStack wool3 = ItemBuilder.item(Material.STAINED_CLAY, 1, (short)4, plugin.getLang().get("menus.teleport.team.nameItem").replaceAll("<color>", "" + ChatColor.YELLOW).replaceAll("<team>", game.getTeams().get(ChatColor.YELLOW).getTeamName()), plugin.getLang().get("menus.teleport.team.loreItem"));
ItemStack wool4 = ItemBuilder.item(Material.STAINED_CLAY, 1, (short)5, plugin.getLang().get("menus.teleport.team.nameItem").replaceAll("<color>", "" + ChatColor.GREEN).replaceAll("<team>", game.getTeams().get(ChatColor.GREEN).getTeamName()), plugin.getLang().get("menus.teleport.team.loreItem"));
if (!game.getTeams().get(ChatColor.BLUE).getDeath()) {
TeamFour team = game.getTeams().get(ChatColor.BLUE);
for (int i = 0; i < team.getTeamPlayers().size(); i++) {
if (team.getTeamPlayers().get(i) != null) {
Player p1 = team.getTeamPlayers().get(i);
ItemStack ip1 = ItemBuilder.skull(Material.SKULL_ITEM, 1, (short)SkullType.PLAYER.ordinal(), plugin.getLang().get("menus.teleport.player.nameItem").replaceAll("<player>", "§7" + p1.getName()), plugin.getLang().get("menus.teleport.player.loreItem").replaceAll("<health>", df.format(p1.getHealth())), p1.getName());
inv.setItem(i + 10, ip1);
}
}
}
if (!game.getTeams().get(ChatColor.RED).getDeath()) {
TeamFour team = game.getTeams().get(ChatColor.RED);
for (int i = 0; i < team.getTeamPlayers().size(); i++) {
if (team.getTeamPlayers().get(i) != null) {
Player p1 = team.getTeamPlayers().get(i);
ItemStack ip1 = ItemBuilder.skull(Material.SKULL_ITEM, 1, (short)SkullType.PLAYER.ordinal(), plugin.getLang().get("menus.teleport.player.nameItem").replaceAll("<player>", "§7" + p1.getName()), plugin.getLang().get("menus.teleport.player.loreItem").replaceAll("<health>", df.format(p1.getHealth())), p1.getName());
inv.setItem(i + 19, ip1);
}
}
}
if (!game.getTeams().get(ChatColor.YELLOW).getDeath()) {
TeamFour team = game.getTeams().get(ChatColor.YELLOW);
for (int i = 0; i < team.getTeamPlayers().size(); i++) {
if (team.getTeamPlayers().get(i) != null) {
Player p1 = team.getTeamPlayers().get(i);
ItemStack ip1 = ItemBuilder.skull(Material.SKULL_ITEM, 1, (short)SkullType.PLAYER.ordinal(), plugin.getLang().get("menus.teleport.player.nameItem").replaceAll("<player>", "§7" + p1.getName()), plugin.getLang().get("menus.teleport.player.loreItem").replaceAll("<health>", df.format(p1.getHealth())), p1.getName());
inv.setItem(i + 28, ip1);
}
}
}
if (!game.getTeams().get(ChatColor.GREEN).getDeath()) {
TeamFour team = game.getTeams().get(ChatColor.GREEN);
for (int i = 0; i < team.getTeamPlayers().size(); i++) {
if (team.getTeamPlayers().get(i) != null) {
Player p1 = team.getTeamPlayers().get(i);
ItemStack ip1 = ItemBuilder.skull(Material.SKULL_ITEM, 1, (short)SkullType.PLAYER.ordinal(), plugin.getLang().get("menus.teleport.player.nameItem").replaceAll("<player>", "§7" + p1.getName()), plugin.getLang().get("menus.teleport.player.loreItem").replaceAll("<health>", df.format(p1.getHealth())), p1.getName());
inv.setItem(i + 36, ip1);
}
}
}
inv.setItem(9, wool1);
inv.setItem(18, wool2);
inv.setItem(27, wool3);
inv.setItem(36, wool4);
p.openInventory(inv);
}
}

97
MultiArena-TheBridge/src/cx/sfy/TheBridge/menus/TeamMenu.java

@ -0,0 +1,97 @@
package cx.sfy.TheBridge.menus;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.game.Game;
import cx.sfy.TheBridge.game.GameFour;
import cx.sfy.TheBridge.team.Team;
import cx.sfy.TheBridge.team.TeamFour;
import cx.sfy.TheBridge.utils.ItemBuilder;
public class TeamMenu {
Main plugin;
public TeamMenu(Main plugin) {
this.plugin = plugin;
}
public void openTeamFourMenu(Player p) {
GameFour game = plugin.getGM().getGameFourByPlayer(p);
Inventory inv = Bukkit.getServer().createInventory(null, 27, plugin.getLang().get("menus.teamFour.title"));
new BukkitRunnable() {
@Override
public void run() {
ItemStack blue = ItemBuilder.item(Material.STAINED_CLAY, (game.getTeams().get(ChatColor.BLUE).getTeamSize() == 0) ? 1 : game.getTeams().get(ChatColor.BLUE).getTeamSize(), (short)11, "§9" + plugin.getLang().get("menus.teamFour.team.nameItem").replaceAll("<#>", plugin.getConfig().getString("names.blue")), getLore(game.getTeams().get(ChatColor.BLUE)));
ItemStack red = ItemBuilder.item(Material.STAINED_CLAY, (game.getTeams().get(ChatColor.RED).getTeamSize() == 0) ? 1 : game.getTeams().get(ChatColor.RED).getTeamSize(), (short)14, "§c" + plugin.getLang().get("menus.teamFour.team.nameItem").replaceAll("<#>", plugin.getConfig().getString("names.red")), getLore(game.getTeams().get(ChatColor.RED)));
ItemStack yellow = ItemBuilder.item(Material.STAINED_CLAY, (game.getTeams().get(ChatColor.YELLOW).getTeamSize() == 0) ? 1 : game.getTeams().get(ChatColor.YELLOW).getTeamSize(), (short)4, "§e" + plugin.getLang().get("menus.teamFour.team.nameItem").replaceAll("<#>", plugin.getConfig().getString("names.yellow")), getLore(game.getTeams().get(ChatColor.YELLOW)));
ItemStack green = ItemBuilder.item(Material.STAINED_CLAY, (game.getTeams().get(ChatColor.GREEN).getTeamSize() == 0) ? 1 : game.getTeams().get(ChatColor.GREEN).getTeamSize(), (short)5, "§a" + plugin.getLang().get("menus.teamFour.team.nameItem").replaceAll("<#>", plugin.getConfig().getString("names.green")), getLore(game.getTeams().get(ChatColor.GREEN)));
inv.setItem(10, blue);
inv.setItem(12, red);
inv.setItem(14, yellow);
inv.setItem(16, green);
if (!p.getOpenInventory().getTitle().equals(plugin.getLang().get("menus.teamFour.title"))) {
cancel();
}
}
}.runTaskTimer(plugin, 0, 0);
p.openInventory(inv);
}
public void openTeamNormalMenu(Player p) {
Game game = plugin.getGM().getGameByPlayer(p);
Inventory inv = Bukkit.getServer().createInventory(null, 27, plugin.getLang().get("menus.team.title"));
new BukkitRunnable() {
@Override
public void run() {
ItemStack blue = ItemBuilder.item(Material.STAINED_CLAY, (game.getTeams().get(ChatColor.BLUE).getTeamSize() == 0) ? 1 : game.getTeams().get(ChatColor.BLUE).getTeamSize(), (short)11, "§9" + plugin.getLang().get("menus.team.team.nameItem").replaceAll("<#>", plugin.getConfig().getString("names.blue")), getLore(game.getTeams().get(ChatColor.BLUE)));
ItemStack red = ItemBuilder.item(Material.STAINED_CLAY, (game.getTeams().get(ChatColor.RED).getTeamSize() == 0) ? 1 : game.getTeams().get(ChatColor.RED).getTeamSize(), (short)14, "§c" + plugin.getLang().get("menus.team.team.nameItem").replaceAll("<#>", plugin.getConfig().getString("names.red")), getLore(game.getTeams().get(ChatColor.RED)));
inv.setItem(11, blue);
inv.setItem(15, red);
if (!p.getOpenInventory().getTitle().equals(plugin.getLang().get("menus.team.title"))) {
cancel();
}
}
}.runTaskTimer(plugin, 0, 0);
p.openInventory(inv);
}
public List<String> getLore(Team team){
List<String> lore = new ArrayList<String>();
for (String msg : plugin.getLang().getList("menus.team.team.loreItem")) {
if (msg.contains("<teamPlayers>")) {
for (Player p : team.getTeamPlayers()) {
lore.add("§7- " + team.getColor() + p.getName());
}
} else {
lore.add(msg.replaceAll("&", "§"));
}
}
return lore;
}
public List<String> getLore(TeamFour team){
List<String> lore = new ArrayList<String>();
for (String msg : plugin.getLang().getList("menus.teamFour.team.loreItem")) {
if (msg.contains("<teamPlayers>")) {
for (Player p : team.getTeamPlayers()) {
lore.add("§7- " + team.getColor() + p.getName());
}
} else {
lore.add(msg.replaceAll("&", "§"));
}
}
return lore;
}
}

54
MultiArena-TheBridge/src/cx/sfy/TheBridge/nms/GenericNMS.java

@ -0,0 +1,54 @@
package cx.sfy.TheBridge.nms;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import cx.sfy.TheBridge.packets.Reflection;
public class GenericNMS implements NMS {
@Override
public ChunkGenerator getChunkGenerator() {
return new ChunkGenerator() {
@Override
public List<BlockPopulator> getDefaultPopulators(World world) {
return Arrays.asList(new BlockPopulator[0]);
}
@Override
public boolean canSpawn(World world, int x, int z) {
return true;
}
@Override
public byte[] generate(World world, Random random, int x, int z) {
return new byte[32768];
}
@Override
public Location getFixedSpawnLocation(World world, Random random) {
return new Location(world, 0.0D, 64.0D, 0.0D);
}
};
}
@Override
public void sendTitle(Player player, int fadein, int stay, int fadeout, String title, String subtitle) {
Reflection.sendTitle(player, fadein, stay, fadeout, title, subtitle);
}
@Override
public void sendActionBar(Player player, String s) {
Reflection.sendAction(player, s);
}
}

12
MultiArena-TheBridge/src/cx/sfy/TheBridge/nms/NMS.java

@ -0,0 +1,12 @@
package cx.sfy.TheBridge.nms;
import org.bukkit.entity.Player;
import org.bukkit.generator.ChunkGenerator;
public interface NMS {
public ChunkGenerator getChunkGenerator();
public void sendTitle(Player player, int fadein, int stay, int fadeout, String title, String subtitle);
public void sendActionBar(Player player, String s);
}

31
MultiArena-TheBridge/src/cx/sfy/TheBridge/packets/PacketHandler.java

@ -0,0 +1,31 @@
package cx.sfy.TheBridge.packets;
import org.bukkit.entity.Player;
import cx.sfy.TheBridge.client.ClientPacket;
import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
public class PacketHandler extends ChannelDuplexHandler {
private Player p;
public PacketHandler(final Player p) {
this.p = p;
}
// OUTPUT MANGLER
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
if (ClientPacket.hidePacket(p, ctx, msg, promise)) {
return;
}
super.write(ctx, msg, promise);
}
// INPUT MANGLER
@Override
public void channelRead(ChannelHandlerContext c, Object msg) throws Exception {
super.channelRead(c, msg);
}
}

104
MultiArena-TheBridge/src/cx/sfy/TheBridge/packets/PacketInjector.java

@ -0,0 +1,104 @@
package cx.sfy.TheBridge.packets;
import java.lang.reflect.Field;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import io.netty.channel.Channel;
public class PacketInjector {
private static Field channel;
private static Field networkManager;
private static Field playerConnection;
public static void Enabler() {
try {
PacketInjector.playerConnection = Reflection.getClass("{nms}.EntityPlayer").getField("playerConnection");
PacketInjector.networkManager = Reflection.getClass("{nms}.PlayerConnection").getField("networkManager");
PacketInjector.channel = Reflection.getClass("{nms}.NetworkManager").getField("channel");
PacketInjector.refreshSessions();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void Disabler() {
for (Player p : Bukkit.getOnlinePlayers()) {
removePlayer(p);
}
}
public static void addPlayer(final Player p) {
if (p == null) {
return;
}
try {
final Channel channel = PacketInjector
.getChannel(PacketInjector.getNetworkManager(Reflection.getNmsPlayer(p)));
if (channel == null) {
return;
}
if (channel.pipeline().get("TheBridgePck") == null) {
final PacketHandler packetHandler = new PacketHandler(p);
channel.pipeline().addBefore("packet_handler", "TheBridgePck", packetHandler);
}
} catch (final Exception t) {
t.printStackTrace();
}
}
private static Channel getChannel(final Object networkManager) {
if (networkManager == null) {
return null;
}
Channel channel = null;
try {
channel = (Channel) PacketInjector.channel.get(networkManager);
} catch (final Exception e) {
e.printStackTrace();
}
return channel;
}
private static Object getNetworkManager(final Object entityPlayer) {
if (entityPlayer == null) {
return null;
}
Object networkManager = null;
try {
networkManager = PacketInjector.networkManager.get(PacketInjector.playerConnection.get(entityPlayer));
} catch (Exception e) {
e.printStackTrace();
}
return networkManager;
}
public static void refreshSessions() {
for (final Player player : Bukkit.getOnlinePlayers()) {
PacketInjector.removePlayer(player);
PacketInjector.addPlayer(player);
}
}
public static void removePlayer(final Player p) {
if (p == null) {
return;
}
try {
final Channel channel = PacketInjector
.getChannel(PacketInjector.getNetworkManager(Reflection.getNmsPlayer(p)));
if (channel == null) {
return;
}
if (channel.pipeline().get("LagAssistPck") != null) {
channel.pipeline().remove("LagAssistPck");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

33
MultiArena-TheBridge/src/cx/sfy/TheBridge/packets/PacketMain.java

@ -0,0 +1,33 @@
package cx.sfy.TheBridge.packets;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.Plugin;
public class PacketMain implements Listener {
public PacketMain(Plugin p) {
PacketInjector.Enabler();
Reflection.Enabler();
p.getServer().getPluginManager().registerEvents(this, p);
Bukkit.getLogger().info(" §e[§a✔§e] §fInjecting PacketListener.");
}
@EventHandler(priority = EventPriority.LOWEST)
public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
PacketInjector.addPlayer(p);
}
@EventHandler(priority = EventPriority.LOWEST)
public void onQuit(PlayerQuitEvent e) {
Player p = e.getPlayer();
PacketInjector.removePlayer(p);
}
}

332
MultiArena-TheBridge/src/cx/sfy/TheBridge/packets/Reflection.java

@ -0,0 +1,332 @@
package cx.sfy.TheBridge.packets;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.command.CommandMap;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.MapMeta;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.SimplePluginManager;
import org.bukkit.scoreboard.Scoreboard;
import org.json.simple.JSONObject;
import cx.sfy.TheBridge.utils.V1_8;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.ComponentBuilder;
public class Reflection {
static String version = ServerPackage.getServerVersion();
public enum Classes {
CraftWorld(), CraftBlock(), CraftPlayer(), Material(), MapMeta(), WorldServer(), PacketPlayOutTitle(), IChatBaseComponent();
private Class<?> type;
public Class<?> getType() {
return type;
}
}
public enum Methods {
setMapId(), getMapId(), getPlayerHandle(), getBlockType(), getChunkProviderServer(), getIChatBaseComponent();
private Method mthd;
public Method getMethod() {
return mthd;
}
}
public static void Enabler() {
// PUTTING CLASSES IN ENUM.
Classes.CraftWorld.type = getClass("{cb}.CraftWorld");
Classes.CraftBlock.type = getClass("{cb}.block.CraftBlock");
Classes.CraftPlayer.type = getClass("{cb}.entity.CraftPlayer");
Classes.Material.type = getClass("{b}.Material");
Classes.MapMeta.type = getClass("{b}.inventory.meta.MapMeta");
Classes.WorldServer.type = getClass("{nms}.WorldServer");
Classes.IChatBaseComponent.type = getClass("{nms}.IChatBaseComponent");
Classes.PacketPlayOutTitle.type = getClass("{nms}.PacketPlayOutTitle");
// PUTTING METHODS IN ENUM.
Methods.setMapId.mthd = getMethod(Classes.MapMeta.getType(), "setMapId", int.class);
Methods.getMapId.mthd = getMethod(Classes.MapMeta.getType(), "getMapId");
Methods.getPlayerHandle.mthd = getMethod(Classes.CraftPlayer.getType(), "getHandle");
Methods.getBlockType.mthd = getMethod(Classes.CraftBlock.getType(), "getType");
Methods.getChunkProviderServer.mthd = getMethod(Classes.WorldServer.getType(), "getChunkProviderServer");
Methods.getIChatBaseComponent.mthd = getMethod(Classes.IChatBaseComponent.getType().getDeclaredClasses()[0],
"a", String.class);
}
public static void sendAction(Player player, String s) {
if (Bukkit.getVersion().contains("1.8"))
V1_8.sendActionbar(player, s);
else
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new ComponentBuilder(s).create());
}
public static void sendTitle(Player p, int fadein, int stay, int fadeout, String title, String subtitle) {
try {
final Object enumTitle = Classes.PacketPlayOutTitle.getType().getDeclaredClasses()[0].getField("TITLE")
.get(null);
final Object enumSubtitle = Classes.PacketPlayOutTitle.getType().getDeclaredClasses()[0]
.getField("SUBTITLE")
.get(null);
final Object titlebase = runMethod(null, Methods.getIChatBaseComponent.getMethod(),
"{\"text\": \"" + title + "\"}");
final Object subtitlebase = runMethod(null, Methods.getIChatBaseComponent.getMethod(),
"{\"text\": \"" + subtitle + "\"}");
final Class<?> packetcls = Classes.PacketPlayOutTitle.getType();
final Constructor<?> constr = packetcls.getConstructor(
Classes.PacketPlayOutTitle.getType().getDeclaredClasses()[0], Classes.IChatBaseComponent.getType(),
int.class, int.class, int.class);
final Object packetTitle = constr.newInstance(enumTitle, titlebase, fadein, stay, fadeout);
final Object packetSubtitle = constr.newInstance(enumSubtitle, subtitlebase, fadein, stay, fadeout);
sendPlayerPacket(p, packetTitle);
sendPlayerPacket(p, packetSubtitle);
}
catch (final Exception e) {
e.printStackTrace();
}
}
@SuppressWarnings("unchecked")
static JSONObject convert(String text) {
final JSONObject json = new JSONObject();
json.put("text", text);
return json;
}
public static Class<?> getClass(String classname) {
try {
final String path = classname.replace("{nms}", "net.minecraft.server." + version)
.replace("{nm}", "net.minecraft." + version).replace("{cb}", "org.bukkit.craftbukkit." + version)
.replace("{b}", "org.bukkit");
return Class.forName(path);
} catch (final Exception e) {
e.printStackTrace();
return null;
}
}
public static Object getCraftWorld(World w) {
final Class<?> crwclass = Classes.CraftWorld.getType();
System.out.println(crwclass.getName());
final Object craftworld = crwclass.cast(w);
return craftworld;
}
public static Object getWorldServer(Object craftWorld) {
try {
return getFieldValue(craftWorld, "world");
} catch (final Exception e) {
e.printStackTrace();
}
return null;
}
public static Object getChunkProvider(Object worldServer) {
try {
return runMethod(worldServer, Methods.getChunkProviderServer.getMethod());
} catch (final Exception e) {
e.printStackTrace();
}
return null;
}
public static boolean isTile(Block b) {
return !b.getState().getClass().getSimpleName().toLowerCase().contains("craftblockstate");
}
public static Entity getEntity(Location l) {
final Collection<Entity> ents = l.getWorld().getNearbyEntities(l, 1, 1, 1);
for (final Entity ent : ents)
return ent;
return null;
}
public static void setmapId(ItemStack s, int id) {
final MapMeta mapm = (MapMeta) s.getItemMeta();
try {
runMethod(mapm, Methods.setMapId.getMethod(), id);
} catch (final Exception e) {
e.printStackTrace();
}
s.setItemMeta(mapm);
}
public static int getMapId(ItemStack s) {
final MapMeta mapm = (MapMeta) s.getItemMeta();
try {
return (int) runMethod(mapm, Methods.getMapId.getMethod());
} catch (final Exception e) {
e.printStackTrace();
}
return 0;
}
public static Object getNmsPlayer(Player p) {
if (p == null)
return null;
Method getHandle;
try {
getHandle = p.getClass().getMethod("getHandle");
return getHandle.invoke(p);
} catch (final Exception e) {
e.printStackTrace();
return null;
}
}
public static Object getNmsScoreboard(Scoreboard s) throws Exception {
final Method getHandle = s.getClass().getMethod("getHandle");
return getHandle.invoke(s);
}
public static Object getFieldValue(Object instance, String fieldName) throws Exception {
final Field field = instance.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
return field.get(instance);
}
@SuppressWarnings("unchecked")
public static <T> T getFieldValue(Field field, Object obj) {
try {
return (T) field.get(obj);
} catch (final Exception e) {
e.printStackTrace();
return null;
}
}
public static Field getField(Class<?> clazz, String fieldName) throws Exception {
final Field field = clazz.getDeclaredField(fieldName);
field.setAccessible(true);
return field;
}
public static Method getMethod(Class<?> clazz, String methodName, Class<?>... resl) {
Method method;
try {
method = clazz.getDeclaredMethod(methodName, resl);
method.setAccessible(true);
return method;
} catch (final Exception e) {
return null;
}
}
public static Object runMethod(Object obj, Method m, Object... resl) throws Exception {
return m.invoke(obj, resl);
}
public static Object runMethod(Object obj, String name, Object... resl) throws Exception {
final Class<?>[] classes = new Class<?>[resl.length];
for (int i = 0; i < resl.length; i++)
classes[i] = resl[i].getClass();
return getMethod(obj.getClass(), name, classes).invoke(obj, resl);
}
public static void setValue(Object instance, String field, Object value) {
try {
final Field f = instance.getClass().getDeclaredField(field);
f.setAccessible(true);
f.set(instance, value);
} catch (final Throwable t) {
t.printStackTrace();
}
}
public static void sendAllPacket(Object packet) throws Exception {
for (final Player p : Bukkit.getOnlinePlayers()) {
final Object nmsPlayer = getNmsPlayer(p);
final Object connection = nmsPlayer.getClass().getField("playerConnection").get(nmsPlayer);
connection.getClass().getMethod("sendPacket", getClass("{nms}.Packet")).invoke(connection, packet);
}
}
public static int getPing(Player p) {
try {
final Object entityPlayer = Methods.getPlayerHandle.getMethod().invoke(p);
return (int) getFieldValue(entityPlayer, "ping");
} catch (final Exception e) {
return -1;
}
}
public static void sendListPacket(List<String> players, Object packet) {
try {
for (final String name : players) {
final Object nmsPlayer = getNmsPlayer(Bukkit.getPlayer(name));
final Object connection = nmsPlayer.getClass().getField("playerConnection").get(nmsPlayer);
connection.getClass().getMethod("sendPacket", getClass("{nms}.Packet")).invoke(connection, packet);
}
} catch (final Exception e) {
e.printStackTrace();
}
}
public static void sendPlayerPacket(Player p, Object packet) throws Exception {
final Object nmsPlayer = getNmsPlayer(p);
final Object connection = nmsPlayer.getClass().getField("playerConnection").get(nmsPlayer);
connection.getClass().getMethod("sendPacket", getClass("{nms}.Packet")).invoke(connection, packet);
}
public static PluginCommand getCommand(String name, Plugin plugin) {
PluginCommand command = null;
try {
final Constructor<PluginCommand> c = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class);
c.setAccessible(true);
command = c.newInstance(name, plugin);
} catch (final Exception e) {
e.printStackTrace();
}
return command;
}
public static CommandMap getCommandMap() {
CommandMap commandMap = null;
try {
if (Bukkit.getPluginManager() instanceof SimplePluginManager) {
final Field f = SimplePluginManager.class.getDeclaredField("commandMap");
f.setAccessible(true);
commandMap = (CommandMap) f.get(Bukkit.getPluginManager());
}
} catch (final NoSuchFieldException e) {
e.printStackTrace();
} catch (final SecurityException e) {
e.printStackTrace();
} catch (final IllegalArgumentException e) {
e.printStackTrace();
} catch (final IllegalAccessException e) {
e.printStackTrace();
}
return commandMap;
}
}

29
MultiArena-TheBridge/src/cx/sfy/TheBridge/packets/ServerPackage.java

@ -0,0 +1,29 @@
package cx.sfy.TheBridge.packets;
import org.bukkit.Bukkit;
public enum ServerPackage {
MINECRAFTSERVER("net.minecraft.server." + getServerVersion()),
CRAFTBUKKIT("org.bukkit.craftbukkit." + getServerVersion()), MINECRAFT("net.minecraft." + getServerVersion());
private final String path;
ServerPackage(String path) {
this.path = path;
}
public static String getServerVersion() {
return Bukkit.getServer().getClass().getPackage().getName().substring(23);
}
@Override
public String toString() {
return path;
}
public Class<?> getClass(String className) throws ClassNotFoundException {
return Class.forName(this.toString() + "." + className);
}
}

43
MultiArena-TheBridge/src/cx/sfy/TheBridge/signs/GameFourSign.java

@ -0,0 +1,43 @@
package cx.sfy.TheBridge.signs;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
public class GameFourSign {
private Sign sign;
private String game;
private Block retract;
public GameFourSign(Location loc, String game, Block retract) {
setSign((Sign)loc.getBlock().getState());
setGame(game);
setRetract(retract);
}
public Sign getSign() {
return sign;
}
public void setSign(Sign sign) {
this.sign = sign;
}
public String getGame() {
return game;
}
public void setGame(String game) {
this.game = game;
}
public Block getRetract() {
return retract;
}
public void setRetract(Block retract) {
this.retract = retract;
}
}

43
MultiArena-TheBridge/src/cx/sfy/TheBridge/signs/GameNormalSign.java

@ -0,0 +1,43 @@
package cx.sfy.TheBridge.signs;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
public class GameNormalSign {
private Sign sign;
private String game;
private Block retract;
public GameNormalSign(Location loc, String game, Block retract) {
setSign((Sign)loc.getBlock().getState());
setGame(game);
setRetract(retract);
}
public Sign getSign() {
return sign;
}
public void setSign(Sign sign) {
this.sign = sign;
}
public String getGame() {
return game;
}
public void setGame(String game) {
this.game = game;
}
public Block getRetract() {
return retract;
}
public void setRetract(Block retract) {
this.retract = retract;
}
}

180
MultiArena-TheBridge/src/cx/sfy/TheBridge/team/Team.java

@ -0,0 +1,180 @@
package cx.sfy.TheBridge.team;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.math.transform.Transform;
import cx.sfy.TheBridge.cosmetics.cages.Cage;
import java.io.IOException;
import java.util.ArrayList;
public class Team {
private ArrayList<Player> players;
private ArrayList<Location> portal;
private Location hologram;
private Location spawn;
private Location respawn;
private String teamName;
private ChatColor color;
private Color fcolor;
private int goals;
private boolean cage;
private EditSession editSessionRed;
private EditSession editSessionBlue;
private Cage cages;
public Team(String teamName, ChatColor color, Color fcolor, Location respawn, Location spawn, ArrayList<Location> portal, Location hologram) {
this.color = color;
this.teamName = teamName;
this.players = new ArrayList<Player>();
this.goals = 0;
this.spawn = spawn;
this.respawn = respawn;
this.portal = portal;
this.fcolor = fcolor;
this.hologram = hologram;
this.cage = false;
}
public void createCage(Cage cage) {
cages = cage;
if (color.equals(ChatColor.RED)) {
Vector to = new Vector(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ());
BukkitWorld world = new BukkitWorld(spawn.getWorld());
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
try {
editSessionRed = ClipboardFormat.findByFile(cage.getFileRed()).load(cage.getFileRed()).paste(world, to, true, true, (Transform) null);
editSessionRed.flushQueue();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
if (color.equals(ChatColor.BLUE)) {
Vector to = new Vector(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ());
BukkitWorld world = new BukkitWorld(spawn.getWorld());
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
try {
editSessionBlue = ClipboardFormat.findByFile(cage.getFileBlue()).load(cage.getFileBlue()).paste(world, to, true, true, (Transform) null);
editSessionBlue.flushQueue();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
editSessionBlue.flushQueue();
}
});
}
}
public void removeCage() {
Vector to = new Vector(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ());
BukkitWorld world = new BukkitWorld(spawn.getWorld());
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
try {
editSessionBlue = ClipboardFormat.findByFile(cages.getClear()).load(cages.getClear()).paste(world, to, true, true, (Transform) null);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
editSessionBlue.flushQueue();
}
});
}
public boolean isCage() {
return cage;
}
public void setCage(boolean cage) {
this.cage = cage;
}
public Location getHologram() {
return hologram;
}
public String getTeamName() {
return teamName;
}
public ChatColor getColor() {
return color;
}
public Location getTeamSpawn() {
return spawn;
}
public Location getTeamRespawn() {
return respawn;
}
public Color getFColor() {
return fcolor;
}
public ArrayList<Location> getPortal() {
return portal;
}
public void createPortal() {
for (Location loc : portal) {
loc.getBlock().setType(Material.ENDER_PORTAL);
}
}
public void deletePortal() {
for (Location loc : portal) {
loc.getBlock().setType(Material.AIR);
}
}
public void addGoal() {
this.goals = this.goals + 1;
}
public int getGoals() {
return goals;
}
public void addPlayer(Player p) {
if (!players.contains(p)) {
players.add(p);
}
}
public void removePlayer(Player p) {
if (players.contains(p)) {
players.remove(p);
}
}
public ArrayList<Player> getTeamPlayers() {
return players;
}
public int getTeamSize() {
return players.size();
}
}

247
MultiArena-TheBridge/src/cx/sfy/TheBridge/team/TeamFour.java

@ -0,0 +1,247 @@
package cx.sfy.TheBridge.team;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.math.transform.Transform;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.cosmetics.cages.Cage;
import cx.sfy.TheBridge.game.GameFour;
import cx.sfy.TheBridge.game.GameFour.FState;
import java.io.IOException;
import java.util.ArrayList;
public class TeamFour {
private ArrayList<Player> players;
private ArrayList<Location> portal;
private Location hologram;
private Location teamSpawn;
private Location teamRespawn;
private int life;
private boolean death;
private GameFour game;
private ChatColor color;
private Color fcolor;
private String teamName;
private String ally;
private boolean cage;
private EditSession editSessionRed;
private EditSession editSessionBlue;
private EditSession editSessionYellow;
private EditSession editSessionGreen;
private Cage cages;
public TeamFour(GameFour game, ChatColor color, Color fcolor, String teamName, Location teamSpawn, Location teamRespawn, ArrayList<Location> portal, Location hologram) {
this.players = new ArrayList<Player>();
this.life = 2;
this.game = game;
this.fcolor = fcolor;
this.death = false;
this.teamSpawn = teamSpawn;
this.teamRespawn = teamRespawn;
this.portal = portal;
this.color = color;
this.teamName = teamName;
this.hologram = hologram;
this.ally = teamName.substring(0, 1);
this.cage = false;
}
public void createCage(Cage cage) {
cages = cage;
if (color.equals(ChatColor.RED)) {
Vector to = new Vector(teamSpawn.getBlockX(), teamSpawn.getBlockY(), teamSpawn.getBlockZ());
BukkitWorld world = new BukkitWorld(teamSpawn.getWorld());
try {
editSessionRed = ClipboardFormat.findByFile(cage.getFileRed()).load(cage.getFileRed()).paste(world, to, true, true, (Transform) null);
editSessionRed.flushQueue();
} catch (IOException e) {
e.printStackTrace();
}
}
if (color.equals(ChatColor.BLUE)) {
Vector to = new Vector(teamSpawn.getBlockX(), teamSpawn.getBlockY(), teamSpawn.getBlockZ());
BukkitWorld world = new BukkitWorld(teamSpawn.getWorld());
try {
editSessionBlue = ClipboardFormat.findByFile(cage.getFileBlue()).load(cage.getFileBlue()).paste(world, to, true, true, (Transform) null);
editSessionBlue.flushQueue();
} catch (IOException e) {
e.printStackTrace();
}
}
if (color.equals(ChatColor.YELLOW)) {
Vector to = new Vector(teamSpawn.getBlockX(), teamSpawn.getBlockY(), teamSpawn.getBlockZ());
BukkitWorld world = new BukkitWorld(teamSpawn.getWorld());
try {
editSessionYellow = ClipboardFormat.findByFile(cage.getFileYellow()).load(cage.getFileYellow()).paste(world, to, true, true, (Transform) null);
editSessionYellow.flushQueue();
} catch (IOException e) {
e.printStackTrace();
}
}
if (color.equals(ChatColor.GREEN)) {
Vector to = new Vector(teamSpawn.getBlockX(), teamSpawn.getBlockY(), teamSpawn.getBlockZ());
BukkitWorld world = new BukkitWorld(teamSpawn.getWorld());
try {
editSessionGreen = ClipboardFormat.findByFile(cage.getFileGreen()).load(cage.getFileGreen()).paste(world, to, true, true, (Transform) null);
editSessionGreen.flushQueue();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public void removeCage() {
Vector to = new Vector(teamSpawn.getBlockX(), teamSpawn.getBlockY(), teamSpawn.getBlockZ());
BukkitWorld world = new BukkitWorld(teamSpawn.getWorld());
try {
editSessionBlue = ClipboardFormat.findByFile(cages.getClear()).load(cages.getClear()).paste(world, to, true, true, (Transform) null);
editSessionBlue.flushQueue();
} catch (IOException e) {
e.printStackTrace();
}
}
public boolean isCage() {
return cage;
}
public void setCage(boolean cage) {
this.cage = cage;
}
public Location getHologram() {
return hologram;
}
public ArrayList<Location> getPortal() {
return portal;
}
public void setPortal(ArrayList<Location> portal) {
this.portal = portal;
}
public ChatColor getColor() {
return this.color;
}
public Color getFColor() {
return this.fcolor;
}
public String getTeamName() {
return color + this.teamName;
}
public String getAlly() {
return color + this.ally;
}
public void createPortal() {
for (Location loc : portal) {
loc.getBlock().setType(Material.ENDER_PORTAL);
}
}
public void deletePortal() {
for (Location loc : portal) {
loc.getBlock().setType(Material.AIR);
}
}
public void addPlayer(Player p) {
if (!players.contains(p)) {
players.add(p);
}
}
public void removePlayer(Player p) {
if (players.contains(p)) {
players.remove(p);
}
if (players.size() == 0 && game.isState(FState.INGAME) && game.isState(FState.PREGAME)) {
killTeam();
}
}
public void killTeam() {
setDeath(true);
ArrayList<Player> temp = new ArrayList<Player>();
for (Player p : players) {
p.playSound(p.getLocation(), Sound.valueOf(Main.get().getSounds().get("sounds.teamFour.death")), 1.0f, 1.0f);
for (Player on : game.getPlayers()) {
on.sendMessage(Main.get().getLang().get("messages.eliminated").replaceAll("<color>", "" + color).replaceAll("<player>", p.getName()));
}
temp.add(p);
}
players.clear();
for (Player p : temp) {
game.setSpect(p);
}
}
public void addLife(int life) {
this.life = this.life + life;
}
public void removeLife(int life) {
this.life = this.life - life;
}
public boolean getDeath() {
return this.death;
}
public void setDeath(boolean b) {
this.death = b;
}
public String getLifeString() {
if (getDeath()) {
return "§8❤❤❤❤❤❤❤❤";
}
String c = "";
String r = "";
for (int i = 0; i < life; i++) {
c = c + "❤";
}
for (int i = life; i < 8; i++) {
r = r + "❤";
}
String li = color + c + "§7" + r;
return li;
}
public int getLife() {
return this.life;
}
public ArrayList<Player> getTeamPlayers() {
return players;
}
public int getTeamSize() {
return players.size();
}
public Location getTeamSpawn() {
return teamSpawn;
}
public Location getTeamRespawn() {
return teamRespawn;
}
}

12
MultiArena-TheBridge/src/cx/sfy/TheBridge/tops/BoardType.java

@ -0,0 +1,12 @@
package cx.sfy.TheBridge.tops;
public enum BoardType {
NORMAL_KILLS,
NORMAL_WINS,
NORMAL_GOALS,
FOUR_KILLS,
FOUR_WINS,
FOUR_GOALS;
}

36
MultiArena-TheBridge/src/cx/sfy/TheBridge/tops/Top.java

@ -0,0 +1,36 @@
package cx.sfy.TheBridge.tops;
import cx.sfy.TheBridge.Main;
public class Top {
private BoardType type;
private int amount;
private int top;
private String name;
public Top(String name, int amount, BoardType type) {
this.type = type;
this.amount = amount;
this.name = name;
this.top = Main.get().getTOP().getTopNumber(this);
Main.get().getTOP().addTop(this);
}
public BoardType getType() {
return type;
}
public int getTop() {
return top;
}
public int getAmount() {
return amount;
}
public String getName() {
return name;
}
}

165
MultiArena-TheBridge/src/cx/sfy/TheBridge/utils/CenterMessage.java

@ -0,0 +1,165 @@
package cx.sfy.TheBridge.utils;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class CenterMessage {
public static void sendCenteredMessage(Player player, String string) {
Object object;
if (string == null || string.equals("")) {
player.sendMessage("");
}
string = ChatColor.translateAlternateColorCodes((char) '&', (String) string);
int n = 0;
boolean bl = false;
boolean bl2 = false;
for (int n2 : string.toCharArray()) {
if (n2 == 167) {
bl = true;
continue;
}
if (bl) {
bl = false;
if (n2 == 108 || n2 == 76) {
bl2 = true;
continue;
}
bl2 = false;
continue;
}
object = DefaultFontInfo.getDefaultFontInfo((char) n2);
n += bl2 ? ((DefaultFontInfo) object).getBoldLength() : ((DefaultFontInfo) object).getLength();
++n;
}
int n3 = n / 2;
int n4 = 154 - n3;
int n5 = DefaultFontInfo.SPACE.getLength() + 1;
object = new StringBuilder();
for (int n2 = 0; n2 < n4; n2 += n5) {
((StringBuilder) object).append(" ");
}
player.sendMessage(object.toString() + string);
}
public static void sendCenteredMessage(CommandSender commandSender, String string) {
Object object;
if (string == null || string.equals("")) {
commandSender.sendMessage("");
}
string = ChatColor.translateAlternateColorCodes((char) '&', (String) string);
int n = 0;
boolean bl = false;
boolean bl2 = false;
for (int n2 : string.toCharArray()) {
if (n2 == 167) {
bl = true;
continue;
}
if (bl) {
bl = false;
if (n2 == 108 || n2 == 76) {
bl2 = true;
continue;
}
bl2 = false;
continue;
}
object = DefaultFontInfo.getDefaultFontInfo((char) n2);
n += bl2 ? ((DefaultFontInfo) object).getBoldLength() : ((DefaultFontInfo) object).getLength();
++n;
}
int n3 = n / 2;
int n4 = 154 - n3;
int n5 = DefaultFontInfo.SPACE.getLength() + 1;
object = new StringBuilder();
for (int n2 = 0; n2 < n4; n2 += n5) {
((StringBuilder) object).append(" ");
}
commandSender.sendMessage(object.toString() + string);
}
public static String getCenteredMessage(String string) {
Object object;
if (string == null || string.equals("")) {
string = ChatColor.translateAlternateColorCodes((char) '&', (String) string);
}
int n = 0;
boolean bl = false;
boolean bl2 = false;
for (int n2 : string.toCharArray()) {
if (n2 == 167) {
bl = true;
continue;
}
if (bl) {
bl = false;
if (n2 == 108 || n2 == 76) {
bl2 = true;
continue;
}
bl2 = false;
continue;
}
object = DefaultFontInfo.getDefaultFontInfo((char) n2);
n += bl2 ? ((DefaultFontInfo) object).getBoldLength() : ((DefaultFontInfo) object).getLength();
++n;
}
int n3 = n / 2;
int n4 = 154 - n3;
int n5 = DefaultFontInfo.SPACE.getLength() + 1;
object = new StringBuilder();
for (int n2 = 0; n2 < n4; n2 += n5) {
((StringBuilder) object).append(" ");
}
return object.toString() + string;
}
public static enum DefaultFontInfo {
A('A', 5), a('a', 5), B('B', 5), b('b', 5), C('C', 5), c('c', 5), D('D', 5), d('d', 5), E('E', 5), e('e', 5),
F('F', 5), f('f', 4), G('G', 5), g('g', 5), H('H', 5), h('h', 5), I('I', 3), i('i', 1), J('J', 5), j('j', 5),
K('K', 5), k('k', 4), L('L', 5), l('l', 1), M('M', 5), m('m', 5), N('N', 5), n('n', 5), O('O', 5), o('o', 5),
P('P', 5), p('p', 5), Q('Q', 5), q('q', 5), R('R', 5), r('r', 5), S('S', 5), s('s', 5), T('T', 5), t('t', 4),
U('U', 5), u('u', 5), V('V', 5), v('v', 5), W('W', 5), w('w', 5), X('X', 5), x('x', 5), Y('Y', 5), y('y', 5),
Z('Z', 5), z('z', 5), NUM_1('1', 5), NUM_2('2', 5), NUM_3('3', 5), NUM_4('4', 5), NUM_5('5', 5), NUM_6('6', 5),
NUM_7('7', 5), NUM_8('8', 5), NUM_9('9', 5), NUM_0('0', 5), EXCLAMATION_POINT('!', 1), AT_SYMBOL('@', 6),
NUM_SIGN('#', 5), DOLLAR_SIGN('$', 5), PERCENT('%', 5), UP_ARROW('^', 5), AMPERSAND('&', 5), ASTERISK('*', 5),
LEFT_PARENTHESIS('(', 4), RIGHT_PERENTHESIS(')', 4), MINUS('-', 5), UNDERSCORE('_', 5), PLUS_SIGN('+', 5),
EQUALS_SIGN('=', 5), LEFT_CURL_BRACE('{', 4), RIGHT_CURL_BRACE('}', 4), LEFT_BRACKET('[', 3),
RIGHT_BRACKET(']', 3), COLON(':', 1), SEMI_COLON(';', 1), DOUBLE_QUOTE('\"', 3), SINGLE_QUOTE('\'', 1),
LEFT_ARROW('<', 4), RIGHT_ARROW('>', 4), QUESTION_MARK('?', 5), SLASH('/', 5), BACK_SLASH('\\', 5),
LINE('|', 1), TILDE('~', 5), TICK('`', 2), PERIOD('.', 1), COMMA(',', 1), SPACE(' ', 3), DEFAULT('a', 4);
private char character;
private int length;
private DefaultFontInfo(char c, int n2) {
this.character = c;
this.length = n2;
}
public char getCharacter() {
return this.character;
}
public int getLength() {
return this.length;
}
public int getBoldLength() {
if (this == SPACE) {
return this.getLength();
}
return this.length + 1;
}
public static DefaultFontInfo getDefaultFontInfo(char c) {
for (DefaultFontInfo defaultFontInfo : DefaultFontInfo.values()) {
if (defaultFontInfo.getCharacter() != c)
continue;
return defaultFontInfo;
}
return DEFAULT;
}
}
}

30
MultiArena-TheBridge/src/cx/sfy/TheBridge/utils/Chat.java

@ -0,0 +1,30 @@
package cx.sfy.TheBridge.utils;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
public class Chat {
public static TextComponent genHoverAndSuggestTextComponent(String show, String hover, String click) {
TextComponent msg = new TextComponent(show);
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(hover).create()));
msg.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + click));
return msg;
}
public static TextComponent genHoverAndRunCommandTextComponent(String show, String hover, String click) {
TextComponent msg = new TextComponent(show);
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(hover).create()));
msg.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + click));
return msg;
}
public static TextComponent genHoverTextComponent(String show, String hover) {
TextComponent msg = new TextComponent(show);
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(hover).create()));
return msg;
}
}

73
MultiArena-TheBridge/src/cx/sfy/TheBridge/utils/ConvertBase64.java

@ -0,0 +1,73 @@
package cx.sfy.TheBridge.utils;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.HashMap;
import org.bukkit.util.io.BukkitObjectInputStream;
import org.bukkit.util.io.BukkitObjectOutputStream;
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
public class ConvertBase64 {
private static HashMap<String, String> data = new HashMap<String, String>();
public static HashMap<String, String> getDataVoid() {
data.clear();
data.put("fly", "0");
data.put("jump", "0");
data.put("chat", "0");
data.put("visible", "0");
data.put("ride", "0");
data.put("speed", "0");
data.put("row", "0");
return data;
}
public static String convertToBase64(HashMap<String, String> data) throws IOException {
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(byteOut);
out.writeObject(data);
out.close();
return Base64Coder.encodeLines(byteOut.toByteArray());
}
public static HashMap<String, String> getDataFromBase64(String data) throws ClassNotFoundException, IOException{
ByteArrayInputStream byteIn = new ByteArrayInputStream(Base64Coder.decodeLines(data));
ObjectInputStream in = new ObjectInputStream(byteIn);
@SuppressWarnings("unchecked")
HashMap<String, String> data2 = (HashMap<String, String>) in.readObject();
in.close();
return data2;
}
public static String toBase64(Object object) throws IllegalStateException {
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
dataOutput.writeObject(object);
dataOutput.close();
return Base64Coder.encodeLines(outputStream.toByteArray());
} catch (Exception e) {
throw new IllegalStateException("Unable to save item stacks.", e);
}
}
public static Object fromBase64(String data) throws IOException {
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
Object object = dataInput.readObject();
dataInput.close();
return object;
} catch (ClassNotFoundException e) {
throw new IOException("Unable to decode class type.", e);
}
}
}

189
MultiArena-TheBridge/src/cx/sfy/TheBridge/utils/ItemBuilder.java

@ -0,0 +1,189 @@
package cx.sfy.TheBridge.utils;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import org.apache.commons.codec.binary.Base64;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
public class ItemBuilder {
public static ItemStack item(Material material, String displayName, String s) {
final ItemStack itemStack = new ItemStack(material);
final ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(displayName);
itemMeta.setLore(s.isEmpty() ? new ArrayList<String>() : Arrays.asList(s.split("\\n")));
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public static ItemStack item(Material material, int n, short n2, String displayName, String s) {
final ItemStack itemStack = new ItemStack(material, n, n2);
final ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(displayName);
itemMeta.setLore(s.isEmpty() ? new ArrayList<String>() : Arrays.asList(s.split("\\n")));
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public static ItemStack item(Material material, int n, short n2, String displayName, String s, Enchantment enchant, int level) {
final ItemStack itemStack = new ItemStack(material, n, n2);
final ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(displayName);
itemMeta.addEnchant(enchant, level, true);
itemMeta.setLore(s.isEmpty() ? new ArrayList<String>() : Arrays.asList(s.split("\\n")));
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public static ItemStack item(Material material, int n, short n2, String displayName, List<String> s) {
final ItemStack itemStack = new ItemStack(material, n, n2);
final ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(displayName);
itemMeta.setLore(s);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public static ItemStack item(Material material, int n, short n2, String displayName, List<String> s, Enchantment enchant, int level) {
final ItemStack itemStack = new ItemStack(material, n, n2);
final ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(displayName);
itemMeta.setLore(s);
itemMeta.addEnchant(enchant, level, true);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public static ItemStack skull(Material material, int n, short n2, String displayName, String s, String owner) {
final ItemStack itemStack = new ItemStack(material, n, n2);
final SkullMeta skullMeta = (SkullMeta)itemStack.getItemMeta();
skullMeta.setOwner(owner);
skullMeta.setDisplayName(displayName);
skullMeta.setLore(s.isEmpty() ? new ArrayList<String>() : Arrays.asList(s.split("\\n")));
itemStack.setItemMeta(skullMeta);
return itemStack;
}
public static ItemStack createSkull(Material material, int n, short n2, String displayName, String s, String uri){
if (!uri.startsWith("http://textures.minecraft.net/texture/"))
uri = "http://textures.minecraft.net/texture/" + uri;
final ItemStack head = new ItemStack(material, n, n2);
final SkullMeta skullMeta = (SkullMeta)head.getItemMeta();
skullMeta.setDisplayName(displayName);
skullMeta.setLore(s.isEmpty() ? new ArrayList<String>() : Arrays.asList(s.split("\\n")));
if (uri.isEmpty())
return head;
final GameProfile profile = new GameProfile(UUID.randomUUID(), null);
final byte[] encodedData = Base64.encodeBase64(String.format("{textures:{SKIN:{url:\"%s\"}}}", uri).getBytes());
profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
try {
final Field profileField = skullMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(skullMeta, profile);
}
catch (IllegalAccessException | IllegalArgumentException | NoSuchFieldException e1) {
e1.printStackTrace();
}
head.setItemMeta(skullMeta);
return head;
}
public static ItemStack lore(Material material, short n, int n2, List<String> lore) {
final ItemStack itemStack = new ItemStack(material, n2, n);
final ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setLore(lore);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public static ItemStack lore(ItemStack itemStack, List<String> lore) {
final ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setLore(lore);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public static ItemStack lore(Material material, short n, int n2, String s) {
final ItemStack itemStack = new ItemStack(material, n2, n);
final ItemMeta itemMeta = itemStack.getItemMeta();
final ArrayList<String> lore = new ArrayList<>();
lore.add(s);
itemMeta.setLore(lore);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public static ItemStack lore(ItemStack itemStack, String s) {
final ItemMeta itemMeta = itemStack.getItemMeta();
final List<String> lore = itemMeta.hasLore() ? itemMeta.getLore() : new ArrayList<>();
lore.add(s);
itemMeta.setLore(lore);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public static ItemStack name(Material material, short n, int n2, String displayName) {
final ItemStack itemStack = new ItemStack(material, n2, n);
final ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(displayName);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public static ItemStack name(ItemStack itemStack, String displayName) {
final ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(displayName);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public static ItemStack nameLore(Material material, short n, int n2, List<String> lore, String displayName) {
final ItemStack itemStack = new ItemStack(material, n2, n);
final ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(displayName);
itemMeta.setLore(lore);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public static ItemStack nameLore(ItemStack itemStack, List<String> lore, String displayName) {
final ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(displayName);
itemMeta.setLore(lore);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public static ItemStack nameLore(Material material, short n, int n2, String s, String displayName) {
final ItemStack itemStack = new ItemStack(material, n2, n);
final ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(displayName);
final ArrayList<String> lore = new ArrayList<>();
lore.add(s);
itemMeta.setLore(lore);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public static ItemStack nameLore(ItemStack itemStack, String s, String displayName) {
final ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(displayName);
final ArrayList<String> lore = new ArrayList<>();
lore.add(s);
itemMeta.setLore(lore);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
}

19
MultiArena-TheBridge/src/cx/sfy/TheBridge/utils/MathUtils.java

@ -0,0 +1,19 @@
package cx.sfy.TheBridge.utils;
public class MathUtils {
public static int toMegaByte(long bytes) {
return (int) (bytes / 1048576);
}
public static boolean isInt(String str) {
try {
int d = Integer.parseInt(str);
d = d + 1;
} catch (NumberFormatException nfe) {
return false;
}
return true;
}
}

7
MultiArena-TheBridge/src/cx/sfy/TheBridge/utils/PaperOnly.java

@ -0,0 +1,7 @@
package cx.sfy.TheBridge.utils;
public class PaperOnly {
}

179
MultiArena-TheBridge/src/cx/sfy/TheBridge/utils/ScoreboardUtil.java

@ -0,0 +1,179 @@
package cx.sfy.TheBridge.utils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
public class ScoreboardUtil {
private Scoreboard scoreboard;
private Objective objective;
private Objective objective2;
private boolean reset;
public String color(String s) {
return s.replaceAll("&", "§");
}
public ScoreboardUtil(String s, String s2, Boolean b) {
this.scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
(this.objective = this.scoreboard.registerNewObjective(s2, "dummy")).setDisplayName(s);
this.objective2 = this.scoreboard.registerNewObjective("h2", "health");
this.objective.setDisplaySlot(DisplaySlot.SIDEBAR);
this.objective2.setDisplayName((Object)ChatColor.RED + "❤");
this.objective2.setDisplaySlot(DisplaySlot.BELOW_NAME);
}
public void setName(String substring) {
if (substring.length() > 32) {
substring = substring.substring(0, 32);
}
this.objective.setDisplayName(color(substring));
}
public void lines(Integer n, String substring) {
Team team = this.scoreboard.getTeam("TEAM_" + n);
if (substring.length() > 32) {
substring = substring.substring(0, 32);
}
String[] splitStringLine = this.splitStringLine(substring);
if (team == null) {
Team registerNewTeam = this.scoreboard.registerNewTeam("TEAM_" + n);
registerNewTeam.addEntry(this.getEntry(n));
this.setPrefix(registerNewTeam, splitStringLine[0]);
this.setSuffix(registerNewTeam, splitStringLine[1]);
this.objective.getScore(this.getEntry(n)).setScore((int)n);
} else {
this.setPrefix(team, splitStringLine[0]);
this.setSuffix(team, splitStringLine[1]);
}
}
public int getArb(Player p) {
for (PotionEffect e : p.getActivePotionEffects()) {
if (e.getType().equals(PotionEffectType.ABSORPTION)) {
return e.getAmplifier();
}
}
return 0;
}
public void setPrefix(Team team, String prefix) {
if (prefix.length() > 16) {
team.setPrefix(prefix.substring(0, 16));
return;
}
team.setPrefix(prefix);
}
public void setSuffix(Team team, String s) {
if (s.length() > 16) {
team.setSuffix(this.maxChars(16, s));
}
else {
team.setSuffix(s.substring(0, s.length()));
}
}
public String maxChars(int n, String s) {
if (ChatColor.translateAlternateColorCodes('&', s).length() > n) {
return s.substring(0, n);
}
return ChatColor.translateAlternateColorCodes('&', s);
}
public String getEntry(Integer n) {
if (n == 0) {
return "§0";
}
if (n == 1) {
return "§1";
}
if (n == 2) {
return "§2";
}
if (n == 3) {
return "§3";
}
if (n == 4) {
return "§4";
}
if (n == 5) {
return "§5";
}
if (n == 6) {
return "§6";
}
if (n == 7) {
return "§7";
}
if (n == 8) {
return "§8";
}
if (n == 9) {
return "§9";
}
if (n == 10) {
return "§a";
}
if (n == 11) {
return "§b";
}
if (n == 12) {
return "§c";
}
if (n == 13) {
return "§d";
}
if (n == 14) {
return "§e";
}
if (n == 15) {
return "§f";
}
return "";
}
public Scoreboard getScoreboard() {
return this.scoreboard;
}
public void setReset(boolean reset) {
this.reset = reset;
}
public boolean isReset() {
return this.reset;
}
public void build(Player player) {
player.setScoreboard(this.scoreboard);
}
private String[] splitStringLine(String s) {
StringBuilder sb = new StringBuilder(s.substring(0, (s.length() >= 16) ? 16 : s.length()));
StringBuilder sb2 = new StringBuilder((s.length() > 16) ? s.substring(16) : "");
if (sb.toString().length() > 1 && sb.charAt(sb.length() - 1) == '§') {
sb.deleteCharAt(sb.length() - 1);
sb2.insert(0, '§');
}
String string = "";
for (int i = 0; i < sb.toString().length(); ++i) {
if (sb.toString().charAt(i) == '§' && i < sb.toString().length() - 1) {
string = String.valueOf(string) + "§" + sb.toString().charAt(i + 1);
}
}
String string2 = new StringBuilder().append((Object)sb2).toString();
if (sb.length() > 14) {
string2 = (string.isEmpty() ? ("§" + string2) : (String.valueOf(String.valueOf(string)) + string2));
}
return new String[] { (sb.toString().length() > 16) ? sb.toString().substring(0, 16) : sb.toString(), (string2.toString().length() > 16) ? string2.toString().substring(0, 16) : string2.toString() };
}
}

49
MultiArena-TheBridge/src/cx/sfy/TheBridge/utils/Tagged.java

@ -0,0 +1,49 @@
package cx.sfy.TheBridge.utils;
import java.util.HashMap;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import cx.sfy.TheBridge.Main;
public class Tagged {
private static HashMap<Player, Player> tag = new HashMap<Player, Player>();
private static HashMap<Player, BukkitTask> tagTask = new HashMap<Player, BukkitTask>();
public static void setTag(Player p, Player tagged) {
if (!tag.containsKey(p)) {
tag.put(p, tagged);
BukkitTask task = new BukkitRunnable() {
@Override
public void run() {
tag.remove(p);
cancel();
}
}.runTaskLater(Main.get(), 5 * 20);
tagTask.put(p, task);
} else {
tag.remove(p);
tagTask.get(p).cancel();
tag.put(p, tagged);
BukkitTask task = new BukkitRunnable() {
@Override
public void run() {
tag.remove(p);
cancel();
}
}.runTaskLater(Main.get(), 5 * 20);
tagTask.put(p, task);
}
}
public static Player getTag(Player p) {
if (tag.containsKey(p)) {
return tag.get(p);
}
return null;
}
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save