Added Test plugin; resolves #66

This commit is contained in:
Daniel Saukel 2016-05-04 23:18:27 +02:00
parent 4f43db7390
commit 62afb6bcf0
23 changed files with 1311 additions and 1 deletions

View File

@ -1 +1 @@
mvn clean install
mvn clean package -DSkipTests

View File

@ -0,0 +1,71 @@
/*
* Copyright (C) 2016 Daniel Saukel
*
* 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;
import io.github.dre2n.dungeonsxl.command.CustomCommand;
import io.github.dre2n.dungeonsxl.game.CustomGameType;
import io.github.dre2n.dungeonsxl.global.ChestProtection;
import io.github.dre2n.dungeonsxl.listener.*;
import io.github.dre2n.dungeonsxl.requirement.RequirementTypeCustom;
import io.github.dre2n.dungeonsxl.reward.RewardTypeCustom;
import io.github.dre2n.dungeonsxl.sign.DSignTypeCustom;
import io.github.dre2n.dungeonsxl.trigger.TriggerTypeCustom;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
/**
* @author Daniel Saukel
*/
public class DXLTest extends JavaPlugin {
@Override
public void onEnable() {
// This is how you register /dxl subcommands.
DungeonsXL.getInstance().getCommands().addCommand(new CustomCommand());
// Register the DungeonsXL events just like any Bukkit event.
getServer().getPluginManager().registerEvents(new DGroupListener(), this);
getServer().getPluginManager().registerEvents(new DMobListener(), this);
getServer().getPluginManager().registerEvents(new DPlayerListener(), this);
getServer().getPluginManager().registerEvents(new DSignListener(), this);
getServer().getPluginManager().registerEvents(new EditWorldListener(), this);
getServer().getPluginManager().registerEvents(new GameWorldListener(), this);
getServer().getPluginManager().registerEvents(new RequirementListener(), this);
getServer().getPluginManager().registerEvents(new RewardListener(), this);
getServer().getPluginManager().registerEvents(new TriggerListener(), this);
// Register the custom game type
DungeonsXL.getInstance().getGameTypes().addGameType(CustomGameType.GHOST);
// There is currently no persistence API for loading the custom global protection :(
// New instances get added to the protections, anyways.
new ChestProtection(Bukkit.getWorlds().get(0).getBlockAt(0, 0, 0));
// Register the custom requirement type
DungeonsXL.getInstance().getRequirementTypes().addRequirement(RequirementTypeCustom.AWESOMENESS);
// Register the custom reward type
DungeonsXL.getInstance().getRewardTypes().addReward(RewardTypeCustom.HIGHWAY_TO_HELL);
// Register the custom edit Signs
DungeonsXL.getInstance().getDSigns().addDSign(DSignTypeCustom.CUSTOM);
// Register the custom trigger
DungeonsXL.getInstance().getTriggers().addTrigger(TriggerTypeCustom.CUSTOM);
}
}

View File

@ -0,0 +1,43 @@
/*
* Copyright (C) 2016 Daniel Saukel
*
* 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.command;
import io.github.dre2n.commons.command.BRCommand;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import org.bukkit.command.CommandSender;
/**
* @author Daniel Saukel
*/
public class CustomCommand extends BRCommand {
public CustomCommand() {
setCommand("custom");
setMinArgs(0);
setMaxArgs(0);
setHelp("help pages message");
setPermission("permission.node");
setPlayerCommand(true);
setConsoleCommand(true);
}
@Override
public void onExecute(String[] args, CommandSender sender) {
MessageUtil.sendMessage(sender, "This is a custom DXL command.");
}
}

View File

@ -0,0 +1,153 @@
/*
* Copyright (C) 2016 Daniel Saukel
*
* 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.game;
import io.github.dre2n.dungeonsxl.game.GameType;
import org.bukkit.GameMode;
/**
* @author Daniel Saukel
*/
public enum CustomGameType implements GameType {
GHOST("My awesome game type", "Identifier", false, false, false, false, false, false, GameMode.SPECTATOR, false);
private String displayName;
private String signName;
private boolean playerVersusPlayer;
private boolean friendlyFire;
private boolean mobWaves;
private boolean rewards;
private boolean showTime;
private boolean build;
private GameMode gameMode;
private boolean lives;
CustomGameType(String displayName, String signName, boolean playerVersusPlayer, boolean friendlyFire, boolean mobWaves, boolean rewards, boolean showTime, boolean build, GameMode gameMode, boolean lives) {
this.displayName = displayName;
this.signName = signName;
this.playerVersusPlayer = playerVersusPlayer;
this.friendlyFire = friendlyFire;
this.mobWaves = mobWaves;
this.rewards = rewards;
this.showTime = showTime;
this.build = build;
this.gameMode = gameMode;
this.lives = lives;
}
@Override
public String getDisplayName() {
return displayName;
}
@Override
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
@Override
public String getSignName() {
return signName;
}
@Override
public void setSignName(String signName) {
this.signName = signName;
}
@Override
public boolean isPlayerVersusPlayer() {
return playerVersusPlayer;
}
@Override
public void setPlayerVersusPlayer(boolean playerVersusPlayer) {
this.playerVersusPlayer = playerVersusPlayer;
}
@Override
public boolean isFriendlyFire() {
return friendlyFire;
}
@Override
public void setFriendlyFire(boolean friendlyFire) {
this.friendlyFire = friendlyFire;
}
@Override
public boolean hasMobWaves() {
return mobWaves;
}
@Override
public void setMobWaves(boolean mobWaves) {
this.mobWaves = mobWaves;
}
@Override
public boolean hasRewards() {
return rewards;
}
@Override
public void setRewards(boolean rewards) {
this.rewards = rewards;
}
@Override
public boolean getShowTime() {
return showTime;
}
@Override
public void setShowTime(boolean showTime) {
this.showTime = showTime;
}
@Override
public boolean canBuild() {
return build;
}
@Override
public void setBuild(boolean build) {
this.build = build;
}
@Override
public GameMode getGameMode() {
return gameMode;
}
@Override
public void setGameMode(GameMode gameMode) {
this.gameMode = gameMode;
}
@Override
public boolean hasLives() {
return lives;
}
@Override
public void setLives(boolean lives) {
this.lives = lives;
}
}

View File

@ -0,0 +1,51 @@
/*
* Copyright (C) 2016 Daniel Saukel
*
* 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.global;
import io.github.dre2n.dungeonsxl.global.GlobalProtection;
import java.util.Arrays;
import java.util.Collection;
import org.bukkit.block.Block;
import org.bukkit.configuration.file.FileConfiguration;
/**
* @author Daniel Saukel
*/
public class ChestProtection extends GlobalProtection {
private Block chest;
public ChestProtection(Block chest) {
super(chest.getWorld(), plugin.getGlobalProtections().generateId(ChestProtection.class, chest.getWorld()));
this.chest = chest;
}
@Override
public void save(FileConfiguration config) {
String preString = "protections.chests." + getWorld().getName() + "." + getId();
config.set(preString + ".x", chest.getX());
config.set(preString + ".y", chest.getY());
config.set(preString + ".z", chest.getZ());
}
@Override
public Collection<Block> getBlocks() {
return Arrays.asList(chest);
}
}

View File

@ -0,0 +1,71 @@
/*
* Copyright (C) 2016 Daniel Saukel
*
* 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.listener;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.event.dgroup.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/**
* @author Daniel Saukel
*/
public class DGroupListener implements Listener {
DungeonsXL plugin = DungeonsXL.getInstance();
@EventHandler
public void onCreate(DGroupCreateEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "Cause: " + event.getCause());
MessageUtil.log(plugin, "Creator: " + event.getCreator().getName());
}
@EventHandler
public void onDisband(DGroupDisbandEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "Cause: " + event.getCause());
MessageUtil.log(plugin, "Creator: " + event.getDisbander().getName());
}
@EventHandler
public void onFinishDungeon(DGroupFinishDungeonEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
}
@EventHandler
public void onStartFloor(DGroupStartFloorEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "GameWorld: " + event.getGameWorld().getMapName());
}
@EventHandler
public void onFinishFloor(DGroupFinishFloorEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "Finished: " + event.getFinished().getMapName());
MessageUtil.log(plugin, "Next: " + event.getNext());
}
@EventHandler
public void onReward(DGroupRewardEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "Rewards: " + event.getRewards());
MessageUtil.log(plugin, "Excluded players: " + event.getExcludedPlayers());
}
}

View File

@ -0,0 +1,44 @@
/*
* Copyright (C) 2016 Daniel Saukel
*
* 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.listener;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.event.dmob.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/**
* @author Daniel Saukel
*/
public class DMobListener implements Listener {
DungeonsXL plugin = DungeonsXL.getInstance();
@EventHandler
public void onDeath(DMobDeathEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "DMob: " + event.getDMob());
}
@EventHandler
public void onSpawn(DMobSpawnEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "DMob: " + event.getDMob());
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (C) 2016 Daniel Saukel
*
* 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.listener;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.event.dplayer.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/**
* @author Daniel Saukel
*/
public class DPlayerListener implements Listener {
DungeonsXL plugin = DungeonsXL.getInstance();
@EventHandler
public void onDeath(DPlayerDeathEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "DPlayer: " + event.getDPlayer().getPlayer().getName());
MessageUtil.log(plugin, "Lost lives: " + event.getLostLives());
}
@EventHandler
public void onEscape(DPlayerEscapeEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "DPlayer: " + event.getDPlayer().getPlayer().getName());
}
@EventHandler
public void onFinish(DPlayerFinishEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "DPlayer: " + event.getDPlayer().getPlayer().getName());
MessageUtil.log(plugin, "Player has to wait: " + event.getHasToWait());
}
@EventHandler
public void onJoinDGroup(DPlayerJoinDGroupEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "DPlayer: " + event.getDPlayer().getPlayer().getName());
MessageUtil.log(plugin, "DGroup: " + event.getDGroup().getName());
}
@EventHandler
public void onKick(DPlayerKickEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "DPlayer: " + event.getDPlayer().getPlayer().getName());
}
@EventHandler
public void onLeaveDGroup(DPlayerLeaveDGroupEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "DPlayer: " + event.getDPlayer().getPlayer().getName());
MessageUtil.log(plugin, "DGroup: " + event.getDGroup().getName());
}
/*This would cause waaay too much console spam...
@EventHandler
public void onUpdate(DPlayerUpdateEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "DPlayer: " + event.getDPlayer().getPlayer().getName());
}*/
}

View File

@ -0,0 +1,39 @@
/*
* Copyright (C) 2016 Daniel Saukel
*
* 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.listener;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.event.dsign.DSignRegistrationEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/**
* @author Daniel Saukel
*/
public class DSignListener implements Listener {
DungeonsXL plugin = DungeonsXL.getInstance();
@EventHandler
public void onRegistration(DSignRegistrationEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "GameWorld (ID): " + event.getGameWorld().getId());
MessageUtil.log(plugin, "DSign: " + event.getDSign().getType());
}
}

View File

@ -0,0 +1,57 @@
/*
* Copyright (C) 2016 Daniel Saukel
*
* 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.listener;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.event.editworld.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/**
* @author Daniel Saukel
*/
public class EditWorldListener implements Listener {
DungeonsXL plugin = DungeonsXL.getInstance();
@EventHandler
public void onGenerate(EditWorldGenerateEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "EditWorld (ID): " + event.getEditWorld().getId());
}
@EventHandler
public void onLoad(EditWorldLoadEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "EditWorld (name): " + event.getName());
}
@EventHandler
public void onSave(EditWorldGenerateEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "EditWorld (ID): " + event.getEditWorld().getId());
}
@EventHandler
public void onUnload(EditWorldUnloadEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "EditWorld (ID): " + event.getEditWorld().getId());
MessageUtil.log(plugin, "Save?: " + event.getSave());
}
}

View File

@ -0,0 +1,51 @@
/*
* Copyright (C) 2016 Daniel Saukel
*
* 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.listener;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.event.gameworld.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/**
* @author Daniel Saukel
*/
public class GameWorldListener implements Listener {
DungeonsXL plugin = DungeonsXL.getInstance();
@EventHandler
public void onLoad(GameWorldLoadEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "GameWorld (name): " + event.getName());
}
@EventHandler
public void onGenerate(GameWorldStartGameEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "GameWorld (ID): " + event.getGameWorld().getId());
MessageUtil.log(plugin, "Game: " + event.getGame());
}
@EventHandler
public void onUnload(GameWorldUnloadEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "GameWorld (ID): " + event.getGameWorld().getId());
}
}

View File

@ -0,0 +1,50 @@
/*
* Copyright (C) 2016 Daniel Saukel
*
* 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.listener;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.event.requirement.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/**
* @author Daniel Saukel
*/
public class RequirementListener implements Listener {
DungeonsXL plugin = DungeonsXL.getInstance();
@EventHandler
public void onCheck(RequirementCheckEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "Requirement: " + event.getRequirement().getType());
}
@EventHandler
public void onDemand(RequirementDemandEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "Requirement: " + event.getRequirement().getType());
}
@EventHandler
public void onRegistration(RequirementRegistrationEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "Requirement: " + event.getRequirement().getType());
}
}

View File

@ -0,0 +1,45 @@
/*
* Copyright (C) 2016 Daniel Saukel
*
* 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.listener;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.event.reward.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/**
* @author Daniel Saukel
*/
public class RewardListener implements Listener {
DungeonsXL plugin = DungeonsXL.getInstance();
@EventHandler
public void onAddition(RewardAdditionEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "Reward: " + event.getReward().getType());
MessageUtil.log(plugin, "DGroup: " + event.getDGroup().getName());
}
@EventHandler
public void onRegistration(RewardRegistrationEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "Reward: " + event.getReward().getType());
}
}

View File

@ -0,0 +1,45 @@
/*
* Copyright (C) 2016 Daniel Saukel
*
* 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.listener;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.DungeonsXL;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerRegistrationEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/**
* @author Daniel Saukel
*/
public class TriggerListener implements Listener {
DungeonsXL plugin = DungeonsXL.getInstance();
@EventHandler
public void onAction(TriggerActionEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "Trigger: " + event.getTrigger().getType());
}
@EventHandler
public void onRegisration(TriggerRegistrationEvent event) {
MessageUtil.log(plugin, "&b== " + event.getEventName() + "==");
MessageUtil.log(plugin, "Trigger: " + event.getTrigger().getType());
}
}

View File

@ -0,0 +1,65 @@
/*
* Copyright (C) 2016 Daniel Saukel
*
* 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.requirement;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.requirement.Requirement;
import io.github.dre2n.dungeonsxl.requirement.RequirementType;
import org.bukkit.entity.Player;
/**
* @author Daniel Saukel
*/
public class AwesomenessRequirement extends Requirement {
private RequirementType type = RequirementTypeCustom.AWESOMENESS;
private int level;
/**
* @return the awesomeness level
*/
public int getAwesomenessLevel() {
return level;
}
/**
* @param level
* the awesomeness level to set
*/
public void setAwesomenessLevel(int level) {
this.level = level;
}
@Override
public boolean check(Player player) {
// Code that checks if the player has the requirement
MessageUtil.sendTitleMessage(player, "&6Are you AWESOME?");
return true;
}
@Override
public void demand(Player player) {
// Code that removes the requirement if it is a fee
}
@Override
public RequirementType getType() {
return type;
}
}

View File

@ -0,0 +1,47 @@
/*
* Copyright (C) 2016 Daniel Saukel
*
* 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.requirement;
import io.github.dre2n.dungeonsxl.requirement.Requirement;
import io.github.dre2n.dungeonsxl.requirement.RequirementType;
/**
* @author Daniel Saukel
*/
public enum RequirementTypeCustom implements RequirementType {
AWESOMENESS("awesomeness", AwesomenessRequirement.class);
private String identifier;
private Class<? extends Requirement> handler;
RequirementTypeCustom(String identifier, Class<? extends Requirement> handler) {
this.identifier = identifier;
this.handler = handler;
}
@Override
public String getIdentifier() {
return identifier;
}
@Override
public Class<? extends Requirement> getHandler() {
return handler;
}
}

View File

@ -0,0 +1,71 @@
/*
* Copyright (C) 2016 Daniel Saukel
*
* 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.reward;
import io.github.dre2n.commons.util.messageutil.MessageUtil;
import io.github.dre2n.dungeonsxl.config.DMessages;
import io.github.dre2n.dungeonsxl.reward.Reward;
import io.github.dre2n.dungeonsxl.reward.RewardType;
import java.util.Arrays;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
/**
* @author Daniel Saukel
*/
public class HighwayToHellReward extends Reward {
private RewardType type = RewardTypeCustom.HIGHWAY_TO_HELL;
public static final ItemStack RECORD;
static {
RECORD = new ItemStack(Material.GOLD_RECORD);
ItemMeta meta = RECORD.getItemMeta();
meta.setDisplayName(ChatColor.DARK_RED + "Highway To Hell");
meta.setLore(Arrays.asList(
ChatColor.GOLD + "1. Highway To Hell 3:28",
ChatColor.GOLD + "2. Girls Got Rhythm 3:24",
ChatColor.GOLD + "3. Walk All Over You 5:09",
ChatColor.GOLD + "4. Touch Too Much 4:26",
ChatColor.GOLD + "5. Beating Around The Bush 3:56",
ChatColor.GOLD + "6. Shot Down In Flames 3:23",
ChatColor.GOLD + "7. Get It Hot 2:34",
ChatColor.GOLD + "8. If You Want Blood (You've Got It) 4:37",
ChatColor.GOLD + "9. Love Hungry Man 4:17",
ChatColor.GOLD + "10. Night Prowler 6:16",
ChatColor.DARK_RED + "All titles A. Young - M. Young - B. Scott"
));
RECORD.setItemMeta(meta);
}
@Override
public void giveTo(Player player) {
// This is called when all rewards are given to the players. Each group member gets one item.
player.getInventory().addItem(RECORD);
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.REWARD_GENERAL, "1 Highway To Hell album"));
}
@Override
public RewardType getType() {
return type;
}
}

View File

@ -0,0 +1,46 @@
/*
* Copyright (C) 2016 Daniel Saukel
*
* 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.reward;
import io.github.dre2n.dungeonsxl.reward.Reward;
import io.github.dre2n.dungeonsxl.reward.RewardType;
/**
* @author Daniel Saukel
*/
public enum RewardTypeCustom implements RewardType {
HIGHWAY_TO_HELL("highwayToHell", HighwayToHellReward.class);
private String identifier;
private Class<? extends Reward> handler;
RewardTypeCustom(String identifier, Class<? extends Reward> handler) {
this.identifier = identifier;
this.handler = handler;
}
@Override
public String getIdentifier() {
return identifier;
}
@Override
public Class<? extends Reward> getHandler() {
return handler;
}
}

View File

@ -0,0 +1,69 @@
/*
* Copyright (C) 2016 Daniel Saukel
*
* 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.sign.DSign;
import io.github.dre2n.dungeonsxl.sign.DSignType;
import io.github.dre2n.dungeonsxl.world.GameWorld;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
/**
* @author Daniel Saukel
*/
public class CustomSign extends DSign {
private DSignType type = DSignTypeCustom.CUSTOM;
public CustomSign(Sign sign, GameWorld gameWorld) {
super(sign, gameWorld);
}
@Override
public boolean check() {
// Check if the sign has the correct format
if (getSign().getLine(1).isEmpty()) {
return false;
} else {
return true;
}
}
@Override
public void onInit() {
// Stuff that happens when the sign is transformed
}
@Override
public boolean onPlayerTrigger(Player player) {
// Stuff that happens when one player triggers the sign
return true;
}
@Override
public void onTrigger() {
// Stuff that happens when the sign is triggered
remove();
}
@Override
public DSignType getType() {
return type;
}
}

View File

@ -0,0 +1,62 @@
/*
* Copyright (C) 2016 Daniel Saukel
*
* 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.player.DPermissions;
import io.github.dre2n.dungeonsxl.sign.DSign;
import io.github.dre2n.dungeonsxl.sign.DSignType;
/**
* @author Daniel Saukel
*/
public enum DSignTypeCustom implements DSignType {
CUSTOM("Custom", "custom", false, CustomSign.class);
private String name;
private String buildPermission;
private boolean onDungeonInit;
private Class<? extends DSign> handler;
DSignTypeCustom(String name, String buildPermission, boolean onDungeonInit, Class<? extends DSign> handler) {
this.name = name;
this.buildPermission = buildPermission;
this.onDungeonInit = onDungeonInit;
this.handler = handler;
}
@Override
public String getName() {
return name;
}
@Override
public String getBuildPermission() {
return DPermissions.SIGN.getNode() + "." + buildPermission;
}
@Override
public boolean isOnDungeonInit() {
return onDungeonInit;
}
@Override
public Class<? extends DSign> getHandler() {
return handler;
}
}

View File

@ -0,0 +1,99 @@
/*
* Copyright (C) 2016 Daniel Saukel
*
* 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.trigger;
import io.github.dre2n.dungeonsxl.event.trigger.TriggerActionEvent;
import io.github.dre2n.dungeonsxl.trigger.Trigger;
import io.github.dre2n.dungeonsxl.trigger.TriggerType;
import io.github.dre2n.dungeonsxl.world.GameWorld;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.entity.Player;
/**
* @author Daniel Saukel
*/
public class CustomTrigger extends Trigger {
private static Map<GameWorld, ArrayList<CustomTrigger>> triggers = new HashMap<>();
private TriggerType type = TriggerTypeCustom.CUSTOM;
private String value;
public CustomTrigger(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public void onTrigger(Player player) {
TriggerActionEvent event = new TriggerActionEvent(this);
if (event.isCancelled()) {
return;
}
setTriggered(true);
this.setPlayer(player);
updateDSigns();
}
@Override
public void register(GameWorld gameWorld) {
if (!hasTriggers(gameWorld)) {
ArrayList<CustomTrigger> list = new ArrayList<>();
list.add(this);
triggers.put(gameWorld, list);
} else {
triggers.get(gameWorld).add(this);
}
}
@Override
public void unregister(GameWorld gameWorld) {
if (hasTriggers(gameWorld)) {
triggers.get(gameWorld).remove(this);
}
}
@Override
public TriggerType getType() {
return type;
}
public static CustomTrigger getOrCreate(String value, GameWorld gameWorld) {
if (triggers.containsKey(gameWorld)) {
for (CustomTrigger trigger : triggers.get(gameWorld)) {
if (trigger.value.equals(value)) {
return trigger;
}
}
}
return new CustomTrigger(value);
}
public static boolean hasTriggers(GameWorld gameWorld) {
return !triggers.isEmpty() && triggers.containsKey(gameWorld);
}
}

View File

@ -0,0 +1,47 @@
/*
* Copyright (C) 2016 Daniel Saukel
*
* 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.trigger;
import io.github.dre2n.dungeonsxl.trigger.Trigger;
import io.github.dre2n.dungeonsxl.trigger.TriggerType;
/**
* @author Daniel Saukel
*/
public enum TriggerTypeCustom implements TriggerType {
CUSTOM("C", CustomTrigger.class);
private String identifier;
private Class<? extends Trigger> handler;
TriggerTypeCustom(String identifier, Class<? extends Trigger> handler) {
this.identifier = identifier;
this.handler = handler;
}
@Override
public String getIdentifier() {
return identifier;
}
@Override
public Class<? extends Trigger> getHandler() {
return handler;
}
}

View File

@ -0,0 +1,6 @@
name: DXLTest
main: io.github.dre2n.dungeonsxl.DXLTest
version: TEST
author: Daniel Saukel
description: Test
depend: [DungeonsXL]