No longer use CorpseReborn and ActionBarAPI and get ProtocolLib via Maven
This commit is contained in:
parent
f414e18581
commit
7cfb06d589
23 changed files with 305 additions and 111 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,4 +3,3 @@
|
||||||
|
|
||||||
*.jar
|
*.jar
|
||||||
!gradle-wrapper.jar
|
!gradle-wrapper.jar
|
||||||
!/libs/*.jar
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
java
|
java
|
||||||
kotlin("jvm") version "1.3.71"
|
kotlin("jvm") version "1.3.72"
|
||||||
id("com.github.johnrengelman.shadow") version("5.2.0")
|
id("com.github.johnrengelman.shadow") version("5.2.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,16 +15,15 @@ repositories {
|
||||||
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
|
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
|
||||||
maven("https://oss.sonatype.org/content/repositories/snapshots")
|
maven("https://oss.sonatype.org/content/repositories/snapshots")
|
||||||
maven("https://oss.sonatype.org/content/repositories/central")
|
maven("https://oss.sonatype.org/content/repositories/central")
|
||||||
|
maven("https://repo.dmulloy2.net/nexus/repository/public/")
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(kotlin("stdlib-jdk8"))
|
implementation(kotlin("stdlib-jdk8"))
|
||||||
implementation(kotlin("reflect"))
|
implementation(kotlin("reflect"))
|
||||||
implementation("commons-codec:commons-codec:1.14")
|
implementation("commons-codec:commons-codec:1.14")
|
||||||
compileOnly(files("./libs/CorpseReborn.jar"))
|
compileOnly("com.comphenix.protocol", "ProtocolLib", "4.5.0")
|
||||||
compileOnly(files("./libs/ActionBarAPI.jar"))
|
compileOnly("org.spigotmc", "spigot-api", "1.15.2-R0.1-SNAPSHOT")
|
||||||
compileOnly(files("./libs/ProtocolLib.jar"))
|
|
||||||
compileOnly("org.spigotmc", "spigot-api", "1.14.4-R0.1-SNAPSHOT")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
configure<JavaPluginConvention> {
|
configure<JavaPluginConvention> {
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,131 @@
|
||||||
|
/*
|
||||||
|
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
|
||||||
|
* Copyright (C) dmulloy2 <http://dmulloy2.net>
|
||||||
|
* Copyright (C) Kristian S. Strangeland
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.comphenix.packetwrapper;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.wrappers.EnumWrappers.TitleAction;
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||||
|
|
||||||
|
public class WrapperPlayServerTitle extends AbstractPacket {
|
||||||
|
public static final PacketType TYPE = PacketType.Play.Server.TITLE;
|
||||||
|
|
||||||
|
public WrapperPlayServerTitle() {
|
||||||
|
super(new PacketContainer(TYPE), TYPE);
|
||||||
|
handle.getModifier().writeDefaults();
|
||||||
|
}
|
||||||
|
|
||||||
|
public WrapperPlayServerTitle(PacketContainer packet) {
|
||||||
|
super(packet, TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve Action.
|
||||||
|
*
|
||||||
|
* @return The current Action
|
||||||
|
*/
|
||||||
|
public TitleAction getAction() {
|
||||||
|
return handle.getTitleActions().read(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Action.
|
||||||
|
*
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setAction(TitleAction value) {
|
||||||
|
handle.getTitleActions().write(0, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve 0 (TITLE).
|
||||||
|
* <p>
|
||||||
|
* Notes: chat
|
||||||
|
*
|
||||||
|
* @return The current 0 (TITLE)
|
||||||
|
*/
|
||||||
|
public WrappedChatComponent getTitle() {
|
||||||
|
return handle.getChatComponents().read(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set 0 (TITLE).
|
||||||
|
*
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setTitle(WrappedChatComponent value) {
|
||||||
|
handle.getChatComponents().write(0, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve 2 (TIMES).
|
||||||
|
* <p>
|
||||||
|
* Notes: int
|
||||||
|
*
|
||||||
|
* @return The current 2 (TIMES)
|
||||||
|
*/
|
||||||
|
public int getFadeIn() {
|
||||||
|
return handle.getIntegers().read(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set 2 (TIMES).
|
||||||
|
*
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setFadeIn(int value) {
|
||||||
|
handle.getIntegers().write(0, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve Stay.
|
||||||
|
*
|
||||||
|
* @return The current Stay
|
||||||
|
*/
|
||||||
|
public int getStay() {
|
||||||
|
return handle.getIntegers().read(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Stay.
|
||||||
|
*
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setStay(int value) {
|
||||||
|
handle.getIntegers().write(1, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve Fade Out.
|
||||||
|
*
|
||||||
|
* @return The current Fade Out
|
||||||
|
*/
|
||||||
|
public int getFadeOut() {
|
||||||
|
return handle.getIntegers().read(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Fade Out.
|
||||||
|
*
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setFadeOut(int value) {
|
||||||
|
handle.getIntegers().write(2, value);
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ import de.moritzruth.spigot_ttt.game.players.PlayerManager
|
||||||
import de.moritzruth.spigot_ttt.game.players.Role
|
import de.moritzruth.spigot_ttt.game.players.Role
|
||||||
import de.moritzruth.spigot_ttt.plugin
|
import de.moritzruth.spigot_ttt.plugin
|
||||||
import de.moritzruth.spigot_ttt.utils.call
|
import de.moritzruth.spigot_ttt.utils.call
|
||||||
|
import de.moritzruth.spigot_ttt.utils.teleportToWorldSpawn
|
||||||
import org.bukkit.GameRule
|
import org.bukkit.GameRule
|
||||||
import org.bukkit.Location
|
import org.bukkit.Location
|
||||||
import org.bukkit.Material
|
import org.bukkit.Material
|
||||||
|
@ -129,7 +130,7 @@ object GameManager {
|
||||||
|
|
||||||
PlayerManager.tttPlayers.forEach {
|
PlayerManager.tttPlayers.forEach {
|
||||||
it.reset()
|
it.reset()
|
||||||
it.teleportToSpawn()
|
it.player.teleportToWorldSpawn()
|
||||||
it.activateStamina()
|
it.activateStamina()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package de.moritzruth.spigot_ttt.game.corpses
|
||||||
|
|
||||||
|
import de.moritzruth.spigot_ttt.game.players.TTTPlayer
|
||||||
|
import org.bukkit.event.Cancellable
|
||||||
|
import org.bukkit.event.Event
|
||||||
|
import org.bukkit.event.HandlerList
|
||||||
|
|
||||||
|
data class CorpseClickEvent(
|
||||||
|
val tttPlayer: TTTPlayer,
|
||||||
|
val tttCorpse: TTTCorpse
|
||||||
|
): Event(), Cancellable {
|
||||||
|
private var _cancelled = false
|
||||||
|
|
||||||
|
override fun getHandlers(): HandlerList {
|
||||||
|
@Suppress("RedundantCompanionReference") // false positive
|
||||||
|
return Companion.handlers
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val handlers = HandlerList()
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun getHandlerList() = handlers
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isCancelled(): Boolean = _cancelled
|
||||||
|
override fun setCancelled(cancel: Boolean) = run { _cancelled = cancel }
|
||||||
|
}
|
|
@ -7,8 +7,12 @@ import org.bukkit.entity.Player
|
||||||
import org.bukkit.event.EventHandler
|
import org.bukkit.event.EventHandler
|
||||||
import org.bukkit.event.EventPriority
|
import org.bukkit.event.EventPriority
|
||||||
import org.bukkit.event.Listener
|
import org.bukkit.event.Listener
|
||||||
|
import org.bukkit.event.entity.EntityCombustEvent
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent
|
||||||
|
import org.bukkit.event.entity.EntityTargetEvent
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent
|
import org.bukkit.event.inventory.InventoryClickEvent
|
||||||
import org.golde.bukkit.corpsereborn.CorpseAPI.events.CorpseClickEvent
|
import org.bukkit.event.player.PlayerInteractEntityEvent
|
||||||
|
import java.time.Duration
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
|
||||||
object CorpseListener: Listener {
|
object CorpseListener: Listener {
|
||||||
|
@ -26,21 +30,34 @@ object CorpseListener: Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
fun onPlayerInteractEntity(event: PlayerInteractEntityEvent) {
|
||||||
|
val tttPlayer = TTTPlayer.of(event.player) ?: return
|
||||||
|
val tttCorpse = CorpseManager.getTTTCorpse(event.rightClicked) ?: return
|
||||||
|
|
||||||
|
if (Duration.between(tttCorpse.timestamp, Instant.now()).toMillis() < 200) return
|
||||||
|
event.isCancelled = true
|
||||||
|
plugin.server.pluginManager.callEvent(CorpseClickEvent(tttPlayer, tttCorpse))
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
|
||||||
fun onCorpseClick(event: CorpseClickEvent) {
|
fun onCorpseClick(event: CorpseClickEvent) {
|
||||||
// bug: always ClickType.UNKNOWN
|
if (event.tttPlayer.alive) event.tttCorpse.identify(event.tttPlayer, event.tttPlayer.role == Role.DETECTIVE)
|
||||||
// if (event.clickType !== ClickType.RIGHT) return
|
event.tttPlayer.player.openInventory(event.tttCorpse.inventory)
|
||||||
|
}
|
||||||
|
|
||||||
val tttPlayer = TTTPlayer.of(event.clicker) ?: return
|
@EventHandler
|
||||||
val tttCorpse = CorpseManager.getTTTCorpse(event.corpse)
|
fun onEntityCombust(event: EntityCombustEvent) {
|
||||||
|
if (CorpseManager.getTTTCorpse(event.entity) != null) event.isCancelled = true
|
||||||
|
}
|
||||||
|
|
||||||
if (tttCorpse !== null) {
|
@EventHandler
|
||||||
if (Instant.now().toEpochMilli() - tttCorpse.timestamp.toEpochMilli() < 200) return
|
fun onEntityDamage(event: EntityDamageEvent) {
|
||||||
|
if (CorpseManager.getTTTCorpse(event.entity) != null) event.isCancelled = true
|
||||||
|
}
|
||||||
|
|
||||||
if (tttPlayer.alive) tttCorpse.identify(tttPlayer, tttPlayer.role == Role.DETECTIVE)
|
@EventHandler
|
||||||
event.clicker.openInventory(tttCorpse.inventory)
|
fun onEntityTarget(event: EntityTargetEvent) {
|
||||||
}
|
if (event.target != null && CorpseManager.getTTTCorpse(event.entity) != null) event.isCancelled = true
|
||||||
|
|
||||||
event.isCancelled = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package de.moritzruth.spigot_ttt.game.corpses
|
package de.moritzruth.spigot_ttt.game.corpses
|
||||||
|
|
||||||
|
import org.bukkit.entity.Entity
|
||||||
|
import org.bukkit.entity.Zombie
|
||||||
import org.bukkit.inventory.Inventory
|
import org.bukkit.inventory.Inventory
|
||||||
import org.golde.bukkit.corpsereborn.nms.Corpses
|
|
||||||
|
|
||||||
object CorpseManager {
|
object CorpseManager {
|
||||||
private val corpses = mutableListOf<TTTCorpse>()
|
private val corpses = mutableListOf<TTTCorpse>()
|
||||||
|
|
||||||
fun getTTTCorpse(corpse: Corpses.CorpseData): TTTCorpse? {
|
fun getTTTCorpse(entity: Entity): TTTCorpse? =
|
||||||
return corpses.find { it.corpse === corpse }
|
if (entity is Zombie) corpses.find { it.entity === entity } else null
|
||||||
}
|
|
||||||
|
|
||||||
fun add(corpse: TTTCorpse) {
|
fun add(corpse: TTTCorpse) {
|
||||||
corpses.add(corpse)
|
corpses.add(corpse)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package de.moritzruth.spigot_ttt.game.corpses
|
package de.moritzruth.spigot_ttt.game.corpses
|
||||||
|
|
||||||
import com.connorlinfoot.actionbarapi.ActionBarAPI
|
|
||||||
import de.moritzruth.spigot_ttt.Resourcepack
|
import de.moritzruth.spigot_ttt.Resourcepack
|
||||||
|
import de.moritzruth.spigot_ttt.game.GameManager
|
||||||
import de.moritzruth.spigot_ttt.game.GameMessenger
|
import de.moritzruth.spigot_ttt.game.GameMessenger
|
||||||
import de.moritzruth.spigot_ttt.game.items.impl.weapons.guns.Pistol
|
import de.moritzruth.spigot_ttt.game.items.impl.weapons.guns.Pistol
|
||||||
import de.moritzruth.spigot_ttt.game.players.DeathReason
|
import de.moritzruth.spigot_ttt.game.players.DeathReason
|
||||||
|
@ -10,13 +10,15 @@ import de.moritzruth.spigot_ttt.game.players.TTTPlayer
|
||||||
import de.moritzruth.spigot_ttt.plugin
|
import de.moritzruth.spigot_ttt.plugin
|
||||||
import de.moritzruth.spigot_ttt.utils.applyMeta
|
import de.moritzruth.spigot_ttt.utils.applyMeta
|
||||||
import de.moritzruth.spigot_ttt.utils.secondsToTicks
|
import de.moritzruth.spigot_ttt.utils.secondsToTicks
|
||||||
|
import de.moritzruth.spigot_ttt.utils.sendActionBarMessage
|
||||||
import org.bukkit.ChatColor
|
import org.bukkit.ChatColor
|
||||||
import org.bukkit.Location
|
import org.bukkit.Location
|
||||||
|
import org.bukkit.entity.EntityType
|
||||||
|
import org.bukkit.entity.Zombie
|
||||||
import org.bukkit.event.inventory.InventoryType
|
import org.bukkit.event.inventory.InventoryType
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.scheduler.BukkitTask
|
import org.bukkit.scheduler.BukkitTask
|
||||||
import org.golde.bukkit.corpsereborn.CorpseAPI.CorpseAPI
|
import org.bukkit.util.Vector
|
||||||
import org.golde.bukkit.corpsereborn.nms.Corpses
|
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
|
||||||
class TTTCorpse private constructor(
|
class TTTCorpse private constructor(
|
||||||
|
@ -24,16 +26,19 @@ class TTTCorpse private constructor(
|
||||||
location: Location,
|
location: Location,
|
||||||
private val role: Role,
|
private val role: Role,
|
||||||
private val reason: DeathReason,
|
private val reason: DeathReason,
|
||||||
private var credits: Int
|
private var credits: Int,
|
||||||
|
velocity: Vector = Vector()
|
||||||
) {
|
) {
|
||||||
var status = Status.UNIDENTIFIED; private set
|
var status = Status.UNIDENTIFIED; private set
|
||||||
|
val entity: Zombie
|
||||||
|
|
||||||
val corpse: Corpses.CorpseData
|
|
||||||
val inventory = tttPlayer.player.server.createInventory(null, InventoryType.HOPPER, "${role.chatColor}${tttPlayer.player.displayName}")
|
val inventory = tttPlayer.player.server.createInventory(null, InventoryType.HOPPER, "${role.chatColor}${tttPlayer.player.displayName}")
|
||||||
|
|
||||||
val timestamp: Instant = Instant.now()
|
val timestamp: Instant = Instant.now()
|
||||||
|
|
||||||
|
val location get() = entity.location
|
||||||
|
|
||||||
private var fullMinutesSinceDeath = 0
|
private var fullMinutesSinceDeath = 0
|
||||||
private var updateTimeListener: BukkitTask
|
private var updateTimeTask: BukkitTask
|
||||||
|
|
||||||
init {
|
init {
|
||||||
inventory.setItem(ROLE_SLOT, ItemStack(role.iconItemMaterial).applyMeta {
|
inventory.setItem(ROLE_SLOT, ItemStack(role.iconItemMaterial).applyMeta {
|
||||||
|
@ -43,9 +48,16 @@ class TTTCorpse private constructor(
|
||||||
|
|
||||||
setItems()
|
setItems()
|
||||||
|
|
||||||
corpse = CorpseAPI.spawnCorpse(tttPlayer.player, location)
|
entity = GameManager.world.spawnEntity(location, EntityType.ZOMBIE) as Zombie
|
||||||
|
entity.apply {
|
||||||
|
setAI(false)
|
||||||
|
isSilent = true
|
||||||
|
removeWhenFarAway = false
|
||||||
|
isBaby = false
|
||||||
|
isCollidable = false
|
||||||
|
}
|
||||||
|
|
||||||
updateTimeListener = plugin.server.scheduler.runTaskTimer(plugin, fun() {
|
updateTimeTask = plugin.server.scheduler.runTaskTimer(plugin, fun() {
|
||||||
fullMinutesSinceDeath += 1
|
fullMinutesSinceDeath += 1
|
||||||
setTimeItem()
|
setTimeItem()
|
||||||
}, secondsToTicks(60).toLong(), secondsToTicks(60).toLong())
|
}, secondsToTicks(60).toLong(), secondsToTicks(60).toLong())
|
||||||
|
@ -109,25 +121,24 @@ class TTTCorpse private constructor(
|
||||||
credits = 0
|
credits = 0
|
||||||
by.credits += c
|
by.credits += c
|
||||||
|
|
||||||
if (c > 1) {
|
by.player.sendActionBarMessage(
|
||||||
ActionBarAPI.sendActionBar(by.player, "${ChatColor.GREEN}Du hast $c Credits aufgesammelt")
|
if (c > 1) "${ChatColor.GREEN}Du hast $c Credits aufgesammelt"
|
||||||
} else {
|
else "${ChatColor.GREEN}Du hast 1 Credit aufgesammelt"
|
||||||
ActionBarAPI.sendActionBar(by.player, "${ChatColor.GREEN}Du hast 1 Credit aufgesammelt")
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun revive() {
|
fun revive() {
|
||||||
ensureNotDestroyed()
|
ensureNotDestroyed()
|
||||||
tttPlayer.revive(corpse.trueLocation, credits)
|
tttPlayer.revive(entity.location, credits)
|
||||||
destroy()
|
destroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun destroy() {
|
fun destroy() {
|
||||||
ensureNotDestroyed()
|
ensureNotDestroyed()
|
||||||
status = Status.DESTROYED
|
status = Status.DESTROYED
|
||||||
CorpseAPI.removeCorpse(corpse)
|
entity.remove()
|
||||||
updateTimeListener.cancel()
|
updateTimeTask.cancel()
|
||||||
inventory.viewers.toSet().forEach { it.closeInventory() }
|
inventory.viewers.toSet().forEach { it.closeInventory() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,13 +163,16 @@ class TTTCorpse private constructor(
|
||||||
tttPlayer.player.location,
|
tttPlayer.player.location,
|
||||||
tttPlayer.role,
|
tttPlayer.role,
|
||||||
reason,
|
reason,
|
||||||
tttPlayer.credits
|
tttPlayer.credits,
|
||||||
|
tttPlayer.player.velocity
|
||||||
).also { CorpseManager.add(it) }
|
).also { CorpseManager.add(it) }
|
||||||
|
|
||||||
fun spawnFake(role: Role, tttPlayer: TTTPlayer, location: Location) {
|
fun spawnFake(role: Role, tttPlayer: TTTPlayer, location: Location) {
|
||||||
|
val loc = location.clone()
|
||||||
|
loc.pitch = 0F
|
||||||
CorpseManager.add(TTTCorpse(
|
CorpseManager.add(TTTCorpse(
|
||||||
tttPlayer,
|
tttPlayer,
|
||||||
location,
|
loc,
|
||||||
role,
|
role,
|
||||||
DeathReason.Item(Pistol),
|
DeathReason.Item(Pistol),
|
||||||
0
|
0
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package de.moritzruth.spigot_ttt.game.items
|
package de.moritzruth.spigot_ttt.game.items
|
||||||
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary
|
import com.comphenix.protocol.ProtocolLibrary
|
||||||
import com.connorlinfoot.actionbarapi.ActionBarAPI
|
|
||||||
import de.moritzruth.spigot_ttt.game.GameManager
|
import de.moritzruth.spigot_ttt.game.GameManager
|
||||||
import de.moritzruth.spigot_ttt.game.items.impl.*
|
import de.moritzruth.spigot_ttt.game.items.impl.*
|
||||||
import de.moritzruth.spigot_ttt.game.items.impl.weapons.BaseballBat
|
import de.moritzruth.spigot_ttt.game.items.impl.weapons.BaseballBat
|
||||||
|
@ -11,6 +10,7 @@ import de.moritzruth.spigot_ttt.game.players.IState
|
||||||
import de.moritzruth.spigot_ttt.game.players.TTTPlayer
|
import de.moritzruth.spigot_ttt.game.players.TTTPlayer
|
||||||
import de.moritzruth.spigot_ttt.plugin
|
import de.moritzruth.spigot_ttt.plugin
|
||||||
import de.moritzruth.spigot_ttt.utils.nextTick
|
import de.moritzruth.spigot_ttt.utils.nextTick
|
||||||
|
import de.moritzruth.spigot_ttt.utils.sendActionBarMessage
|
||||||
import org.bukkit.ChatColor
|
import org.bukkit.ChatColor
|
||||||
import org.bukkit.Material
|
import org.bukkit.Material
|
||||||
import org.bukkit.entity.Item
|
import org.bukkit.entity.Item
|
||||||
|
@ -82,7 +82,7 @@ object ItemManager {
|
||||||
tttPlayer.updateItemInHand()
|
tttPlayer.updateItemInHand()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
ActionBarAPI.sendActionBar(event.player, "${ChatColor.RED}Du kannst dieses Item nicht droppen")
|
event.player.sendActionBarMessage("${ChatColor.RED}Du kannst dieses Item nicht droppen")
|
||||||
event.isCancelled = true
|
event.isCancelled = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
package de.moritzruth.spigot_ttt.game.items.impl
|
package de.moritzruth.spigot_ttt.game.items.impl
|
||||||
|
|
||||||
import com.connorlinfoot.actionbarapi.ActionBarAPI
|
|
||||||
import de.moritzruth.spigot_ttt.Resourcepack
|
import de.moritzruth.spigot_ttt.Resourcepack
|
||||||
import de.moritzruth.spigot_ttt.game.items.TTTItemListener
|
|
||||||
import de.moritzruth.spigot_ttt.game.GameEndEvent
|
import de.moritzruth.spigot_ttt.game.GameEndEvent
|
||||||
import de.moritzruth.spigot_ttt.game.GameManager
|
import de.moritzruth.spigot_ttt.game.GameManager
|
||||||
import de.moritzruth.spigot_ttt.game.corpses.CorpseManager
|
import de.moritzruth.spigot_ttt.game.corpses.CorpseClickEvent
|
||||||
import de.moritzruth.spigot_ttt.game.players.*
|
|
||||||
import de.moritzruth.spigot_ttt.game.items.Buyable
|
import de.moritzruth.spigot_ttt.game.items.Buyable
|
||||||
import de.moritzruth.spigot_ttt.game.items.TTTItem
|
import de.moritzruth.spigot_ttt.game.items.TTTItem
|
||||||
|
import de.moritzruth.spigot_ttt.game.items.TTTItemListener
|
||||||
|
import de.moritzruth.spigot_ttt.game.players.*
|
||||||
import de.moritzruth.spigot_ttt.plugin
|
import de.moritzruth.spigot_ttt.plugin
|
||||||
import de.moritzruth.spigot_ttt.utils.*
|
import de.moritzruth.spigot_ttt.utils.*
|
||||||
import org.bukkit.ChatColor
|
import org.bukkit.ChatColor
|
||||||
|
@ -18,7 +17,6 @@ import org.bukkit.boss.BarStyle
|
||||||
import org.bukkit.event.EventHandler
|
import org.bukkit.event.EventHandler
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.scheduler.BukkitTask
|
import org.bukkit.scheduler.BukkitTask
|
||||||
import org.golde.bukkit.corpsereborn.CorpseAPI.events.CorpseClickEvent
|
|
||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
|
||||||
|
@ -45,19 +43,16 @@ object Defibrillator: TTTItem, Buyable {
|
||||||
}
|
}
|
||||||
|
|
||||||
override val listener = object : TTTItemListener(this, true) {
|
override val listener = object : TTTItemListener(this, true) {
|
||||||
@EventHandler
|
@EventHandler(ignoreCancelled = true)
|
||||||
fun onCorpseClick(event: CorpseClickEvent) {
|
fun onCorpseClick(event: CorpseClickEvent) {
|
||||||
val tttPlayer = TTTPlayer.of(event.clicker) ?: return
|
if (event.tttPlayer.player.inventory.itemInMainHand.type != itemStack.type) return
|
||||||
if (tttPlayer.player.inventory.itemInMainHand.type != itemStack.type) return
|
|
||||||
|
|
||||||
val tttCorpse = CorpseManager.getTTTCorpse(event.corpse) ?: return
|
|
||||||
event.isCancelled = true
|
event.isCancelled = true
|
||||||
|
|
||||||
val state = isc.getOrCreate(tttPlayer)
|
val state = isc.getOrCreate(event.tttPlayer)
|
||||||
state.bossBar.addPlayer(tttPlayer.player)
|
state.bossBar.addPlayer(event.tttPlayer.player)
|
||||||
|
|
||||||
when(val action = state.action) {
|
when(val action = state.action) {
|
||||||
null -> state.action = Action.Reviving(tttPlayer, state)
|
null -> state.action = Action.Reviving(event.tttPlayer, state)
|
||||||
is Action.Reviving -> {
|
is Action.Reviving -> {
|
||||||
action.cancelTask.cancel()
|
action.cancelTask.cancel()
|
||||||
action.cancelTask = action.createCancelTask()
|
action.cancelTask = action.createCancelTask()
|
||||||
|
@ -66,18 +61,17 @@ object Defibrillator: TTTItem, Buyable {
|
||||||
|
|
||||||
if (progress >= 1) {
|
if (progress >= 1) {
|
||||||
try {
|
try {
|
||||||
tttCorpse.revive()
|
event.tttCorpse.revive()
|
||||||
|
|
||||||
ActionBarAPI.sendActionBar(
|
event.tttPlayer.player.sendActionBarMessage(
|
||||||
tttPlayer.player,
|
"${ChatColor.BOLD}${event.tttCorpse.tttPlayer.player.displayName} " +
|
||||||
"${ChatColor.BOLD}${tttCorpse.tttPlayer.player.displayName} " +
|
|
||||||
"${ChatColor.GREEN}wurde wiederbelebt"
|
"${ChatColor.GREEN}wurde wiederbelebt"
|
||||||
)
|
)
|
||||||
|
|
||||||
action.cancelTask.cancel()
|
action.cancelTask.cancel()
|
||||||
tttPlayer.player.inventory.removeTTTItemNextTick(Defibrillator)
|
event.tttPlayer.player.inventory.removeTTTItemNextTick(Defibrillator)
|
||||||
state.reset(tttPlayer)
|
state.reset(event.tttPlayer)
|
||||||
isc.remove(tttPlayer)
|
isc.remove(event.tttPlayer)
|
||||||
} catch(e: TTTPlayer.AlreadyLivingException) {
|
} catch(e: TTTPlayer.AlreadyLivingException) {
|
||||||
action.cancel()
|
action.cancel()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
package de.moritzruth.spigot_ttt.game.items.impl
|
package de.moritzruth.spigot_ttt.game.items.impl
|
||||||
|
|
||||||
import com.connorlinfoot.actionbarapi.ActionBarAPI
|
|
||||||
import de.moritzruth.spigot_ttt.Resourcepack
|
import de.moritzruth.spigot_ttt.Resourcepack
|
||||||
import de.moritzruth.spigot_ttt.game.items.TTTItemListener
|
|
||||||
import de.moritzruth.spigot_ttt.game.corpses.TTTCorpse
|
import de.moritzruth.spigot_ttt.game.corpses.TTTCorpse
|
||||||
import de.moritzruth.spigot_ttt.game.players.*
|
|
||||||
import de.moritzruth.spigot_ttt.game.items.Buyable
|
import de.moritzruth.spigot_ttt.game.items.Buyable
|
||||||
import de.moritzruth.spigot_ttt.game.items.TTTItem
|
import de.moritzruth.spigot_ttt.game.items.TTTItem
|
||||||
|
import de.moritzruth.spigot_ttt.game.items.TTTItemListener
|
||||||
|
import de.moritzruth.spigot_ttt.game.players.*
|
||||||
import de.moritzruth.spigot_ttt.plugin
|
import de.moritzruth.spigot_ttt.plugin
|
||||||
import de.moritzruth.spigot_ttt.utils.applyMeta
|
import de.moritzruth.spigot_ttt.utils.applyMeta
|
||||||
import de.moritzruth.spigot_ttt.utils.hideInfo
|
import de.moritzruth.spigot_ttt.utils.hideInfo
|
||||||
import de.moritzruth.spigot_ttt.utils.removeTTTItem
|
import de.moritzruth.spigot_ttt.utils.removeTTTItem
|
||||||
|
import de.moritzruth.spigot_ttt.utils.sendActionBarMessage
|
||||||
import org.bukkit.ChatColor
|
import org.bukkit.ChatColor
|
||||||
import org.bukkit.Material
|
import org.bukkit.Material
|
||||||
import org.bukkit.event.EventHandler
|
import org.bukkit.event.EventHandler
|
||||||
|
@ -101,7 +101,7 @@ object FakeCorpse: TTTItem, Buyable {
|
||||||
val corpseTTTPlayer = TTTPlayer.of(corpsePlayer)
|
val corpseTTTPlayer = TTTPlayer.of(corpsePlayer)
|
||||||
|
|
||||||
if (corpseTTTPlayer == null) {
|
if (corpseTTTPlayer == null) {
|
||||||
ActionBarAPI.sendActionBar(tttPlayer.player, "${ChatColor.RED}Das hat nicht funktioniert")
|
tttPlayer.player.sendActionBarMessage("${ChatColor.RED}Das hat nicht funktioniert")
|
||||||
} else {
|
} else {
|
||||||
TTTCorpse.spawnFake(state.chosenRole!!, corpseTTTPlayer, tttPlayer.player.location)
|
TTTCorpse.spawnFake(state.chosenRole!!, corpseTTTPlayer, tttPlayer.player.location)
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package de.moritzruth.spigot_ttt.game.items.impl
|
package de.moritzruth.spigot_ttt.game.items.impl
|
||||||
|
|
||||||
import de.moritzruth.spigot_ttt.Resourcepack
|
import de.moritzruth.spigot_ttt.Resourcepack
|
||||||
import de.moritzruth.spigot_ttt.game.items.TTTItemListener
|
|
||||||
import de.moritzruth.spigot_ttt.game.GameEndEvent
|
import de.moritzruth.spigot_ttt.game.GameEndEvent
|
||||||
import de.moritzruth.spigot_ttt.game.GameManager
|
import de.moritzruth.spigot_ttt.game.GameManager
|
||||||
import de.moritzruth.spigot_ttt.game.items.Buyable
|
import de.moritzruth.spigot_ttt.game.items.Buyable
|
||||||
import de.moritzruth.spigot_ttt.game.items.PASSIVE
|
import de.moritzruth.spigot_ttt.game.items.PASSIVE
|
||||||
import de.moritzruth.spigot_ttt.game.items.TTTItem
|
import de.moritzruth.spigot_ttt.game.items.TTTItem
|
||||||
|
import de.moritzruth.spigot_ttt.game.items.TTTItemListener
|
||||||
import de.moritzruth.spigot_ttt.game.players.*
|
import de.moritzruth.spigot_ttt.game.players.*
|
||||||
import de.moritzruth.spigot_ttt.plugin
|
import de.moritzruth.spigot_ttt.plugin
|
||||||
import de.moritzruth.spigot_ttt.utils.applyMeta
|
import de.moritzruth.spigot_ttt.utils.applyMeta
|
||||||
|
@ -81,7 +81,7 @@ object SecondChance: TTTItem, Buyable {
|
||||||
if (Random.nextBoolean()) {
|
if (Random.nextBoolean()) {
|
||||||
event.winnerRoleGroup = null
|
event.winnerRoleGroup = null
|
||||||
event.tttPlayer.player.openInventory(chooseSpawnInventory)
|
event.tttPlayer.player.openInventory(chooseSpawnInventory)
|
||||||
state.timeoutAction = TimeoutAction(event.tttPlayer, event.tttCorpse.corpse.trueLocation)
|
state.timeoutAction = TimeoutAction(event.tttPlayer, event.tttCorpse.location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package de.moritzruth.spigot_ttt.game.items.impl
|
package de.moritzruth.spigot_ttt.game.items.impl
|
||||||
|
|
||||||
import com.connorlinfoot.actionbarapi.ActionBarAPI
|
|
||||||
import de.moritzruth.spigot_ttt.Resourcepack
|
import de.moritzruth.spigot_ttt.Resourcepack
|
||||||
import de.moritzruth.spigot_ttt.game.items.TTTItemListener
|
|
||||||
import de.moritzruth.spigot_ttt.game.GameManager
|
import de.moritzruth.spigot_ttt.game.GameManager
|
||||||
import de.moritzruth.spigot_ttt.game.players.*
|
|
||||||
import de.moritzruth.spigot_ttt.game.items.Buyable
|
import de.moritzruth.spigot_ttt.game.items.Buyable
|
||||||
import de.moritzruth.spigot_ttt.game.items.TTTItem
|
import de.moritzruth.spigot_ttt.game.items.TTTItem
|
||||||
|
import de.moritzruth.spigot_ttt.game.items.TTTItemListener
|
||||||
|
import de.moritzruth.spigot_ttt.game.players.*
|
||||||
import de.moritzruth.spigot_ttt.utils.applyMeta
|
import de.moritzruth.spigot_ttt.utils.applyMeta
|
||||||
import de.moritzruth.spigot_ttt.utils.clearHeldItemSlot
|
import de.moritzruth.spigot_ttt.utils.clearHeldItemSlot
|
||||||
|
import de.moritzruth.spigot_ttt.utils.sendActionBarMessage
|
||||||
import org.bukkit.ChatColor
|
import org.bukkit.ChatColor
|
||||||
import org.bukkit.Sound
|
import org.bukkit.Sound
|
||||||
import org.bukkit.event.EventHandler
|
import org.bukkit.event.EventHandler
|
||||||
|
@ -48,11 +48,10 @@ object Teleporter: TTTItem, Buyable {
|
||||||
val state = isc.getOrCreate(tttPlayer)
|
val state = isc.getOrCreate(tttPlayer)
|
||||||
state.teleportSelf = !state.teleportSelf
|
state.teleportSelf = !state.teleportSelf
|
||||||
|
|
||||||
if (state.teleportSelf) {
|
tttPlayer.player.sendActionBarMessage(
|
||||||
ActionBarAPI.sendActionBar(tttPlayer.player, "${ChatColor.AQUA}Mode: Teleportiere dich selbst")
|
if (state.teleportSelf) "${ChatColor.AQUA}Mode: Teleportiere dich selbst"
|
||||||
} else {
|
else "${ChatColor.AQUA}Mode: Teleportiere jemand anderen"
|
||||||
ActionBarAPI.sendActionBar(tttPlayer.player, "${ChatColor.AQUA}Mode: Teleportiere jemand anderen")
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRightClick(data: ClickEventData) {
|
override fun onRightClick(data: ClickEventData) {
|
||||||
|
@ -61,10 +60,10 @@ object Teleporter: TTTItem, Buyable {
|
||||||
|
|
||||||
val firstPlayer = if (state.teleportSelf) {
|
val firstPlayer = if (state.teleportSelf) {
|
||||||
if (!tttPlayer.player.isOnGround) {
|
if (!tttPlayer.player.isOnGround) {
|
||||||
ActionBarAPI.sendActionBar(tttPlayer.player, "${ChatColor.RED}${ChatColor.BOLD}Du musst auf dem Boden stehen")
|
tttPlayer.player.sendActionBarMessage("${ChatColor.RED}${ChatColor.BOLD}Du musst auf dem Boden stehen")
|
||||||
null
|
null
|
||||||
} else if (tttPlayer.player.isSneaking) {
|
} else if (tttPlayer.player.isSneaking) {
|
||||||
ActionBarAPI.sendActionBar(tttPlayer.player, "${ChatColor.RED}${ChatColor.BOLD}Du darfst nicht sneaken")
|
tttPlayer.player.sendActionBarMessage("${ChatColor.RED}${ChatColor.BOLD}Du darfst nicht sneaken")
|
||||||
null
|
null
|
||||||
} else tttPlayer
|
} else tttPlayer
|
||||||
} else getRandomPlayerToTeleport(tttPlayer)
|
} else getRandomPlayerToTeleport(tttPlayer)
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package de.moritzruth.spigot_ttt.game.items.impl.weapons.guns
|
package de.moritzruth.spigot_ttt.game.items.impl.weapons.guns
|
||||||
|
|
||||||
import com.connorlinfoot.actionbarapi.ActionBarAPI
|
|
||||||
import de.moritzruth.spigot_ttt.Resourcepack
|
import de.moritzruth.spigot_ttt.Resourcepack
|
||||||
|
import de.moritzruth.spigot_ttt.game.items.Buyable
|
||||||
|
import de.moritzruth.spigot_ttt.game.items.TTTItem
|
||||||
import de.moritzruth.spigot_ttt.game.players.Role
|
import de.moritzruth.spigot_ttt.game.players.Role
|
||||||
import de.moritzruth.spigot_ttt.game.players.TTTPlayer
|
import de.moritzruth.spigot_ttt.game.players.TTTPlayer
|
||||||
import de.moritzruth.spigot_ttt.game.players.roles
|
import de.moritzruth.spigot_ttt.game.players.roles
|
||||||
import de.moritzruth.spigot_ttt.game.items.Buyable
|
|
||||||
import de.moritzruth.spigot_ttt.game.items.TTTItem
|
|
||||||
import de.moritzruth.spigot_ttt.utils.applyMeta
|
import de.moritzruth.spigot_ttt.utils.applyMeta
|
||||||
import de.moritzruth.spigot_ttt.utils.hideInfo
|
import de.moritzruth.spigot_ttt.utils.hideInfo
|
||||||
|
import de.moritzruth.spigot_ttt.utils.sendActionBarMessage
|
||||||
import org.bukkit.ChatColor
|
import org.bukkit.ChatColor
|
||||||
import org.bukkit.entity.Item
|
import org.bukkit.entity.Item
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
|
@ -41,7 +41,7 @@ object SidekickDeagle: Gun(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun reload(tttPlayer: TTTPlayer, itemStack: ItemStack, state: Gun.State) {
|
override fun reload(tttPlayer: TTTPlayer, itemStack: ItemStack, state: Gun.State) {
|
||||||
ActionBarAPI.sendActionBar(tttPlayer.player, "${ChatColor.RED}Du kannst diese Waffe nicht nachladen")
|
tttPlayer.player.sendActionBarMessage("${ChatColor.RED}Du kannst diese Waffe nicht nachladen")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onHit(tttPlayer: TTTPlayer, hitTTTPlayer: TTTPlayer) {
|
override fun onHit(tttPlayer: TTTPlayer, hitTTTPlayer: TTTPlayer) {
|
||||||
|
@ -61,7 +61,7 @@ object SidekickDeagle: Gun(
|
||||||
|
|
||||||
override fun onBeforeShoot(tttPlayer: TTTPlayer, item: ItemStack, state: Gun.State): Boolean {
|
override fun onBeforeShoot(tttPlayer: TTTPlayer, item: ItemStack, state: Gun.State): Boolean {
|
||||||
if (tttPlayer.role != Role.JACKAL) {
|
if (tttPlayer.role != Role.JACKAL) {
|
||||||
ActionBarAPI.sendActionBar(tttPlayer.player, "${ChatColor.RED}Diese Waffe kann nur der Jackal benutzen")
|
tttPlayer.player.sendActionBarMessage("${ChatColor.RED}Diese Waffe kann nur der Jackal benutzen")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package de.moritzruth.spigot_ttt.game.items.shop
|
package de.moritzruth.spigot_ttt.game.items.shop
|
||||||
|
|
||||||
import com.connorlinfoot.actionbarapi.ActionBarAPI
|
|
||||||
import de.moritzruth.spigot_ttt.Settings
|
import de.moritzruth.spigot_ttt.Settings
|
||||||
import de.moritzruth.spigot_ttt.game.items.Buyable
|
import de.moritzruth.spigot_ttt.game.items.Buyable
|
||||||
import de.moritzruth.spigot_ttt.game.items.ItemManager
|
import de.moritzruth.spigot_ttt.game.items.ItemManager
|
||||||
|
@ -8,6 +7,7 @@ import de.moritzruth.spigot_ttt.game.players.PlayerManager
|
||||||
import de.moritzruth.spigot_ttt.game.players.TTTPlayer
|
import de.moritzruth.spigot_ttt.game.players.TTTPlayer
|
||||||
import de.moritzruth.spigot_ttt.game.players.TTTPlayerDeathEvent
|
import de.moritzruth.spigot_ttt.game.players.TTTPlayerDeathEvent
|
||||||
import de.moritzruth.spigot_ttt.plugin
|
import de.moritzruth.spigot_ttt.plugin
|
||||||
|
import de.moritzruth.spigot_ttt.utils.sendActionBarMessage
|
||||||
import org.bukkit.ChatColor
|
import org.bukkit.ChatColor
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
import org.bukkit.event.EventHandler
|
import org.bukkit.event.EventHandler
|
||||||
|
@ -40,10 +40,10 @@ object ShopListener: Listener {
|
||||||
|
|
||||||
when {
|
when {
|
||||||
Shop.isOutOfStock(tttPlayer, tttItem) ->
|
Shop.isOutOfStock(tttPlayer, tttItem) ->
|
||||||
ActionBarAPI.sendActionBar(tttPlayer.player, "${ChatColor.RED}Dieses Item ist ausverkauft")
|
tttPlayer.player.sendActionBarMessage("${ChatColor.RED}Dieses Item ist ausverkauft")
|
||||||
|
|
||||||
tttPlayer.credits < tttItem.price ->
|
tttPlayer.credits < tttItem.price ->
|
||||||
ActionBarAPI.sendActionBar(tttPlayer.player, "${ChatColor.RED}Du hast nicht genug Credits")
|
tttPlayer.player.sendActionBarMessage("${ChatColor.RED}Du hast nicht genug Credits")
|
||||||
|
|
||||||
else -> try {
|
else -> try {
|
||||||
tttPlayer.addItem(tttItem)
|
tttPlayer.addItem(tttItem)
|
||||||
|
@ -54,9 +54,9 @@ object ShopListener: Listener {
|
||||||
|
|
||||||
Shop.setItems(tttPlayer)
|
Shop.setItems(tttPlayer)
|
||||||
} catch (e: TTTPlayer.AlreadyHasItemException) {
|
} catch (e: TTTPlayer.AlreadyHasItemException) {
|
||||||
ActionBarAPI.sendActionBar(tttPlayer.player, "${ChatColor.RED}Du hast dieses Item bereits")
|
tttPlayer.player.sendActionBarMessage("${ChatColor.RED}Du hast dieses Item bereits")
|
||||||
} catch (e: TTTPlayer.TooManyItemsOfTypeException) {
|
} catch (e: TTTPlayer.TooManyItemsOfTypeException) {
|
||||||
ActionBarAPI.sendActionBar(tttPlayer.player, "${ChatColor.RED}Du hast keinen Platz dafür")
|
tttPlayer.player.sendActionBarMessage("${ChatColor.RED}Du hast keinen Platz dafür")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ object ShopListener: Listener {
|
||||||
.filter { it.role.canOwnCredits && it.role.group == killer.role.group }
|
.filter { it.role.canOwnCredits && it.role.group == killer.role.group }
|
||||||
.forEach {
|
.forEach {
|
||||||
it.credits += Settings.creditsPerKill
|
it.credits += Settings.creditsPerKill
|
||||||
ActionBarAPI.sendActionBar(it.player, "${ChatColor.GREEN}Du hast ${Settings.creditsPerKill} Credit(s) erhalten")
|
it.player.sendActionBarMessage("${ChatColor.GREEN}Du hast ${Settings.creditsPerKill} Credit(s) erhalten")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import de.moritzruth.spigot_ttt.game.GamePhase
|
||||||
import de.moritzruth.spigot_ttt.plugin
|
import de.moritzruth.spigot_ttt.plugin
|
||||||
import de.moritzruth.spigot_ttt.utils.nextTick
|
import de.moritzruth.spigot_ttt.utils.nextTick
|
||||||
import de.moritzruth.spigot_ttt.utils.noop
|
import de.moritzruth.spigot_ttt.utils.noop
|
||||||
import de.moritzruth.spigot_ttt.utils.teleportPlayerToWorldSpawn
|
import de.moritzruth.spigot_ttt.utils.teleportToWorldSpawn
|
||||||
import org.bukkit.ChatColor
|
import org.bukkit.ChatColor
|
||||||
import org.bukkit.GameMode
|
import org.bukkit.GameMode
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
|
@ -29,8 +29,7 @@ object PlayerManager {
|
||||||
|
|
||||||
fun resetAfterGame() {
|
fun resetAfterGame() {
|
||||||
playersJoinedDuringRound.forEach {
|
playersJoinedDuringRound.forEach {
|
||||||
teleportPlayerToWorldSpawn(it)
|
it.teleportToWorldSpawn()
|
||||||
|
|
||||||
nextTick { it.gameMode = GameMode.SURVIVAL }
|
nextTick { it.gameMode = GameMode.SURVIVAL }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +53,7 @@ object PlayerManager {
|
||||||
|
|
||||||
if (tttPlayer == null) {
|
if (tttPlayer == null) {
|
||||||
if (GameManager.phase == null) {
|
if (GameManager.phase == null) {
|
||||||
teleportPlayerToWorldSpawn(player)
|
player.teleportToWorldSpawn()
|
||||||
player.gameMode = GameMode.SURVIVAL
|
player.gameMode = GameMode.SURVIVAL
|
||||||
} else {
|
} else {
|
||||||
player.gameMode = GameMode.SPECTATOR
|
player.gameMode = GameMode.SPECTATOR
|
||||||
|
@ -71,7 +70,7 @@ object PlayerManager {
|
||||||
player.gameMode = GameMode.SPECTATOR
|
player.gameMode = GameMode.SPECTATOR
|
||||||
}
|
}
|
||||||
GamePhase.OVER -> {
|
GamePhase.OVER -> {
|
||||||
tttPlayer.teleportToSpawn()
|
tttPlayer.player.teleportToWorldSpawn()
|
||||||
player.gameMode = GameMode.SURVIVAL
|
player.gameMode = GameMode.SURVIVAL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,6 @@ class TTTPlayer(player: Player, role: Role) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onDeath(reason: DeathReason, killer: TTTPlayer?, scream: Boolean = true) {
|
fun onDeath(reason: DeathReason, killer: TTTPlayer?, scream: Boolean = true) {
|
||||||
if (killer == this) throw IllegalArgumentException("You cannot be your own killer")
|
|
||||||
GameManager.ensurePhase(GamePhase.COMBAT)
|
GameManager.ensurePhase(GamePhase.COMBAT)
|
||||||
|
|
||||||
player.sendMessage(TTTPlugin.prefix +
|
player.sendMessage(TTTPlugin.prefix +
|
||||||
|
@ -181,7 +180,7 @@ class TTTPlayer(player: Player, role: Role) {
|
||||||
|
|
||||||
fun resetAfterGameEnd() {
|
fun resetAfterGameEnd() {
|
||||||
if (!alive) {
|
if (!alive) {
|
||||||
teleportToSpawn()
|
player.teleportToWorldSpawn()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Required to be delayed because of a Minecraft bug which sometimes turns players invisible
|
// Required to be delayed because of a Minecraft bug which sometimes turns players invisible
|
||||||
|
@ -215,8 +214,6 @@ class TTTPlayer(player: Player, role: Role) {
|
||||||
player.inventory.clear()
|
player.inventory.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun teleportToSpawn() = teleportPlayerToWorldSpawn(player)
|
|
||||||
|
|
||||||
fun updateItemInHand() {
|
fun updateItemInHand() {
|
||||||
val itemStack = player.inventory.itemInMainHand
|
val itemStack = player.inventory.itemInMainHand
|
||||||
this.itemInHand =
|
this.itemInHand =
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package de.moritzruth.spigot_ttt.utils
|
||||||
|
|
||||||
|
import com.comphenix.packetwrapper.WrapperPlayServerTitle
|
||||||
|
import com.comphenix.protocol.wrappers.EnumWrappers
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedChatComponent
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
|
||||||
|
fun Player.sendActionBarMessage(
|
||||||
|
message: String,
|
||||||
|
fadeIn: Int = secondsToTicks(0.2),
|
||||||
|
stay: Int = secondsToTicks(5),
|
||||||
|
fadeOut: Int = secondsToTicks(1)
|
||||||
|
) {
|
||||||
|
val wrapper = WrapperPlayServerTitle()
|
||||||
|
wrapper.action = EnumWrappers.TitleAction.ACTIONBAR
|
||||||
|
wrapper.title = WrappedChatComponent.fromText(message)
|
||||||
|
wrapper.fadeIn = fadeIn
|
||||||
|
wrapper.fadeOut = fadeOut
|
||||||
|
wrapper.stay = stay
|
||||||
|
|
||||||
|
wrapper.sendPacket(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Player.teleportToWorldSpawn() {
|
||||||
|
teleport(world.spawnLocation)
|
||||||
|
}
|
|
@ -1,7 +0,0 @@
|
||||||
package de.moritzruth.spigot_ttt.utils
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player
|
|
||||||
|
|
||||||
fun teleportPlayerToWorldSpawn(player: Player) {
|
|
||||||
player.teleport(player.world.spawnLocation)
|
|
||||||
}
|
|
|
@ -1,11 +1,8 @@
|
||||||
name: TTT
|
name: TTT
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
author: Moritz Ruth
|
author: Moritz Ruth
|
||||||
api-version: "1.14"
|
api-version: "1.15"
|
||||||
main: de.moritzruth.spigot_ttt.TTTPlugin
|
main: de.moritzruth.spigot_ttt.TTTPlugin
|
||||||
depend:
|
|
||||||
- CorpseReborn
|
|
||||||
- ActionBarAPI
|
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
start:
|
start:
|
||||||
|
|
Reference in a new issue