Added action bar and title sign

This commit is contained in:
Daniel Saukel 2016-12-26 03:20:03 +01:00
parent 2c11cfe9ba
commit a3a376e8af
12 changed files with 244 additions and 9 deletions

View File

@ -8,6 +8,6 @@
<parent>
<groupId>io.github.dre2n</groupId>
<artifactId>dungeonsxl</artifactId>
<version>0.15.3</version>
<version>0.15.4</version>
</parent>
</project>

View File

@ -8,7 +8,7 @@
<parent>
<groupId>io.github.dre2n</groupId>
<artifactId>dungeonsxl</artifactId>
<version>0.15.3</version>
<version>0.15.4</version>
</parent>
<build>
<resources>

View File

@ -0,0 +1,82 @@
/*
* Copyright (C) 2012-2016 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.sign;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
/**
* @author Daniel Saukel
*/
public class ActionBarSign extends PerPlayerSign {
private DSignType type = DSignTypeDefault.ACTION_BAR;
private String text;
public ActionBarSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
/* Getters and setters*/
/**
* @return
* the text
*/
public String getText() {
return text;
}
/**
* @param text
* the text to set
*/
public void setText(String text) {
this.text = text;
}
/* Actions */
@Override
public boolean check() {
return true;
}
@Override
public void onInit() {
text = lines[1];
text += lines[2];
getSign().getBlock().setType(Material.AIR);
}
@Override
public boolean onPlayerTrigger(Player player) {
if (!super.onPlayerTrigger(player)) {
return false;
}
MessageUtil.sendActionBarMessage(player, text);
return true;
}
@Override
public DSignType getType() {
return type;
}
}

View File

@ -25,6 +25,7 @@ import io.github.dre2n.dungeonsxl.player.DPermissions;
*/
public enum DSignTypeDefault implements DSignType {
ACTION_BAR("ActionBar", "actionbar", true, false, ActionBarSign.class),
BED("Bed", "bed", false, false, BedSign.class),
BLOCK("Block", "block", false, true, BlockSign.class),
BOSS_SHOP("BossShop", "bossshop", false, true, BossShopSign.class),
@ -57,6 +58,7 @@ public enum DSignTypeDefault implements DSignType {
SOUND_MESSAGE("SoundMSG", "soundmsg", false, false, SoundMessageSign.class),
START("Start", "start", true, false, StartSign.class),
TELEPORT("Teleport", "teleport", false, false, TeleportSign.class),
TITLE("Title", "title", true, false, TitleSign.class),
TRIGGER("Trigger", "trigger", true, false, TriggerSign.class),
WAVE("Wave", "wave", false, false, WaveSign.class);

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2012-2016 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.sign;
import io.github.dre2n.dungeonsxl.world.DGameWorld;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
/**
* @author Daniel Saukel
*/
public abstract class PerPlayerSign extends DSign {
private Set<UUID> triggered = new HashSet<>();
public PerPlayerSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
@Override
public boolean onPlayerTrigger(Player player) {
return triggered.add(player.getUniqueId());
}
/**
* @param player
* the player to check
* @return
* true if the player already triggered the sign
*/
public boolean isTriggeredByPlayer(Player player) {
return triggered.contains(player.getUniqueId());
}
}

View File

@ -0,0 +1,99 @@
/*
* Copyright (C) 2012-2016 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.sign;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.world.DGameWorld;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
/**
* @author Daniel Saukel
*/
public class TitleSign extends PerPlayerSign {
private DSignType type = DSignTypeDefault.TITLE;
private String title;
private String subtitle;
public TitleSign(Sign sign, String[] lines, DGameWorld gameWorld) {
super(sign, lines, gameWorld);
}
/* Getters and setters*/
/**
* @return
* the title
*/
public String getTitle() {
return title;
}
/**
* @param text
* the text to set
*/
public void setTitle(String text) {
title = text;
}
/**
* @return
* the subtitle
*/
public String getSubtitle() {
return subtitle;
}
/**
* @param text
* the text to set
*/
public void setSubtitle(String text) {
subtitle = text;
}
/* Actions */
@Override
public boolean check() {
return true;
}
@Override
public void onInit() {
title = lines[1];
subtitle = lines[2];
getSign().getBlock().setType(Material.AIR);
}
@Override
public boolean onPlayerTrigger(Player player) {
if (!super.onPlayerTrigger(player)) {
return false;
}
MessageUtil.sendTitleMessage(player, title, subtitle);
return true;
}
@Override
public DSignType getType() {
return type;
}
}

View File

@ -8,7 +8,7 @@
<parent>
<groupId>io.github.dre2n</groupId>
<artifactId>dungeonsxl</artifactId>
<version>0.15.3</version>
<version>0.15.4</version>
</parent>
<build>
<plugins>

View File

@ -8,7 +8,7 @@
<parent>
<groupId>io.github.dre2n</groupId>
<artifactId>dungeonsxl</artifactId>
<version>0.15.3</version>
<version>0.15.4</version>
</parent>
<build>
<plugins>

View File

@ -8,7 +8,7 @@
<parent>
<groupId>io.github.dre2n</groupId>
<artifactId>dungeonsxl</artifactId>
<version>0.15.3</version>
<version>0.15.4</version>
</parent>
<build>
<plugins>

View File

@ -8,7 +8,7 @@
<parent>
<groupId>io.github.dre2n</groupId>
<artifactId>dungeonsxl</artifactId>
<version>0.15.3</version>
<version>0.15.4</version>
</parent>
<build>
<plugins>

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.dre2n</groupId>
<artifactId>dungeonsxl</artifactId>
<version>0.15.3</version>
<version>0.15.4</version>
<packaging>pom</packaging>
<name>DungeonsXL</name>
<url>https://dre2n.github.io</url>
@ -24,7 +24,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.11-R0.1-SNAPSHOT</version>
<version>1.11.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -8,7 +8,7 @@
<parent>
<groupId>io.github.dre2n</groupId>
<artifactId>dungeonsxl</artifactId>
<version>0.15.3</version>
<version>0.15.4</version>
</parent>
<build>
<finalName>dungeonsxl-${project.version}${buildNo}</finalName>