mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-02 17:00:19 +01:00
Add group tags
This commit is contained in:
parent
da049b4618
commit
9c311c3108
@ -24,6 +24,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -87,6 +88,7 @@ public class GameRules {
|
||||
/* Misc */
|
||||
DEFAULT_VALUES.msgs = new HashMap<>();
|
||||
DEFAULT_VALUES.secureObjects = new ArrayList<>();
|
||||
DEFAULT_VALUES.groupTagEnabled = false;
|
||||
}
|
||||
|
||||
/* keepInventory */
|
||||
@ -142,6 +144,7 @@ public class GameRules {
|
||||
/* Misc */
|
||||
protected Map<Integer, String> msgs;
|
||||
protected List<ItemStack> secureObjects;
|
||||
protected Boolean groupTagEnabled;
|
||||
|
||||
/* Getters and setters */
|
||||
// keepInventory
|
||||
@ -527,6 +530,18 @@ public class GameRules {
|
||||
return secureObjects;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* if the group tag is enabled.
|
||||
* Returns false if HolographicDisplays isn't loaded
|
||||
*/
|
||||
public boolean isGroupTagEnabled() {
|
||||
if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
|
||||
return false;
|
||||
}
|
||||
return groupTagEnabled;
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
/**
|
||||
* @param defaultValues
|
||||
@ -740,6 +755,10 @@ public class GameRules {
|
||||
} else if (defaultValues.secureObjects != null) {
|
||||
secureObjects.addAll(defaultValues.secureObjects);
|
||||
}
|
||||
|
||||
if (groupTagEnabled == null) {
|
||||
groupTagEnabled = defaultValues.groupTagEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -78,6 +78,8 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
private ItemStack oldHelmet;
|
||||
private DGroup stealing;
|
||||
|
||||
private DGroupTag groupTag;
|
||||
|
||||
public DGamePlayer(Player player, DGameWorld world) {
|
||||
super(player, world.getWorld());
|
||||
|
||||
@ -410,6 +412,22 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
stealing = dGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* the player's group tag
|
||||
*/
|
||||
public DGroupTag getDGroupTag() {
|
||||
return groupTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* the player's group tag
|
||||
*/
|
||||
public void initDGroupTag() {
|
||||
groupTag = new DGroupTag(this);
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
public void captureFlag() {
|
||||
if (stealing == null) {
|
||||
|
@ -778,7 +778,9 @@ public class DGroup {
|
||||
if (dPlayer == null) {
|
||||
dPlayer = new DGamePlayer(player, gameWorld);
|
||||
}
|
||||
|
||||
if (rules.isGroupTagEnabled()) {
|
||||
dPlayer.initDGroupTag();
|
||||
}
|
||||
if (!dPlayer.isReady()) {
|
||||
ready = false;
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 Frank Baumann
|
||||
*
|
||||
* 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 io.github.dre2n.dungeonsxl.player;
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.Hologram;
|
||||
import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
|
||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public class DGroupTag {
|
||||
|
||||
private DGamePlayer player;
|
||||
private Hologram hologram;
|
||||
|
||||
public DGroupTag(DGamePlayer player) {
|
||||
this.player = player;
|
||||
DGroup group = player.getDGroup();
|
||||
if (group != null) {
|
||||
hologram = HologramsAPI.createHologram(DungeonsXL.getInstance(), player.getPlayer().getLocation().clone().add(0, 3.5, 0));
|
||||
hologram.appendItemLine(new ItemStack(Material.WOOL, 1, group.getDColor().getWoolData()));
|
||||
hologram.appendTextLine(group.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void update() {
|
||||
hologram.teleport(player.getPlayer().getLocation().clone().add(0, 3.5, 0));
|
||||
}
|
||||
|
||||
}
|
@ -417,12 +417,17 @@ public class DPlayerListener implements Listener {
|
||||
}
|
||||
DGameWorld gameWorld = DGameWorld.getByWorld(player.getWorld());
|
||||
DGamePlayer gamePlayer = DGamePlayer.getByPlayer(player);
|
||||
if (gameWorld != null && gamePlayer != null && gamePlayer.isStealing()) {
|
||||
DGroup group = gamePlayer.getDGroup();
|
||||
Location startLocation = gameWorld.getStartLocation(group);
|
||||
if (gameWorld != null && gamePlayer != null) {
|
||||
if (gamePlayer.getDGroupTag() != null) {
|
||||
gamePlayer.getDGroupTag().update();
|
||||
}
|
||||
if (gamePlayer.isStealing()) {
|
||||
DGroup group = gamePlayer.getDGroup();
|
||||
Location startLocation = gameWorld.getStartLocation(group);
|
||||
|
||||
if (startLocation.distance(player.getLocation()) < 3) {
|
||||
gamePlayer.captureFlag();
|
||||
if (startLocation.distance(player.getLocation()) < 3) {
|
||||
gamePlayer.captureFlag();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -292,6 +292,10 @@ public class WorldConfig extends GameRules {
|
||||
if (configFile.contains("title.show")) {
|
||||
titleShow = (int) configFile.getDouble("title.show") * 20;
|
||||
}
|
||||
|
||||
if (configFile.contains("groupTagEnabled")) {
|
||||
groupTagEnabled = configFile.getBoolean("groupTagEnabled");
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
|
Loading…
Reference in New Issue
Block a user