mirror of
https://github.com/garbagemule/MobArena.git
synced 2025-02-16 20:41:56 +01:00
Added Spout class selection option
This commit is contained in:
parent
ace0475530
commit
6291a0fbfb
BIN
MobArena.jar
BIN
MobArena.jar
Binary file not shown.
@ -47,6 +47,7 @@ import com.garbagemule.MobArena.MAMessages.Msg;
|
||||
import com.garbagemule.MobArena.repairable.Repairable;
|
||||
import com.garbagemule.MobArena.repairable.RepairableComparator;
|
||||
import com.garbagemule.MobArena.repairable.RepairableContainer;
|
||||
import com.garbagemule.MobArena.spout.Spouty;
|
||||
import com.garbagemule.MobArena.util.InventoryItem;
|
||||
import com.garbagemule.MobArena.util.WaveUtils;
|
||||
import com.garbagemule.MobArena.waves.BossWave;
|
||||
@ -64,7 +65,7 @@ public class Arena
|
||||
protected World world;
|
||||
protected boolean enabled, protect, running, setup, lobbySetup, autoEquip, forceRestore, softRestore, softRestoreDrops, emptyInvJoin, emptyInvSpec, pvp, monsterInfight, allowWarp;
|
||||
|
||||
protected boolean edit, waveClear, detCreepers, detDamage, lightning, hellhounds, specOnDeath, shareInArena;
|
||||
protected boolean edit, waveClear, detCreepers, detDamage, lightning, hellhounds, specOnDeath, shareInArena, spoutSelect;
|
||||
protected Location p1, p2, l1, l2, arenaLoc, lobbyLoc, spectatorLoc;
|
||||
protected Map<String,Location> spawnpoints, spawnpointsBoss, containers;
|
||||
protected String logging;
|
||||
@ -327,6 +328,9 @@ public class Arena
|
||||
// Notify listeners.
|
||||
for (MobArenaListener listener : plugin.getAM().listeners)
|
||||
listener.onPlayerJoin(this, p);
|
||||
|
||||
if (MobArena.hasSpout && spoutSelect)
|
||||
Spouty.classSelectionScreen(plugin, this, p);
|
||||
}
|
||||
|
||||
public void playerReady(Player p)
|
||||
@ -852,6 +856,7 @@ public class Arena
|
||||
allowWarp = config.getBoolean(arenaPath + "allow-teleporting", false);
|
||||
specOnDeath = config.getBoolean(arenaPath + "spectate-on-death", true);
|
||||
shareInArena = config.getBoolean(arenaPath + "share-items-in-arena", true);
|
||||
spoutSelect = config.getBoolean(arenaPath + "spout-class-select", true);
|
||||
joinDistance = config.getInt(arenaPath + "max-join-distance", 0);
|
||||
minPlayers = config.getInt(arenaPath + "min-players", 0);
|
||||
maxPlayers = config.getInt(arenaPath + "max-players", 0);
|
||||
|
@ -17,6 +17,7 @@ import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
import com.garbagemule.MobArena.listeners.MagicSpellsListener;
|
||||
import com.garbagemule.MobArena.spout.Spouty;
|
||||
import com.garbagemule.MobArena.util.FileUtils;
|
||||
import com.garbagemule.register.payment.Method;
|
||||
import com.garbagemule.register.payment.Methods;
|
||||
@ -171,11 +172,13 @@ public class MobArena extends JavaPlugin
|
||||
|
||||
private void setupSpout()
|
||||
{
|
||||
if (hasSpout)
|
||||
return;
|
||||
if (hasSpout) return;
|
||||
|
||||
Plugin spoutPlugin = this.getServer().getPluginManager().getPlugin("Spout");
|
||||
hasSpout = spoutPlugin != null;
|
||||
if (!hasSpout) return;
|
||||
|
||||
Spouty.registerEvents(this);
|
||||
}
|
||||
|
||||
private void setupHeroes()
|
||||
|
@ -0,0 +1,33 @@
|
||||
package com.garbagemule.MobArena.listeners;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
|
||||
import org.getspout.spoutapi.event.screen.ScreenListener;
|
||||
import org.getspout.spoutapi.gui.Button;
|
||||
|
||||
import com.garbagemule.MobArena.Arena;
|
||||
import com.garbagemule.MobArena.MobArena;
|
||||
import com.garbagemule.MobArena.spout.ClassButton;
|
||||
|
||||
public class MASpoutScreenListener extends ScreenListener
|
||||
{
|
||||
private MobArena plugin;
|
||||
|
||||
public MASpoutScreenListener(MobArena plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void onButtonClick(ButtonClickEvent event)
|
||||
{
|
||||
Button b = event.getButton();
|
||||
if (!(b instanceof ClassButton)) return;
|
||||
|
||||
Player p = event.getPlayer();
|
||||
Arena arena = plugin.getAM().getArenaWithPlayer(p);
|
||||
if (arena == null) return;
|
||||
|
||||
arena.assignClass(p, b.getText());
|
||||
event.getPlayer().getMainScreen().closePopup();
|
||||
}
|
||||
}
|
12
src/com/garbagemule/MobArena/spout/ClassButton.java
Normal file
12
src/com/garbagemule/MobArena/spout/ClassButton.java
Normal file
@ -0,0 +1,12 @@
|
||||
package com.garbagemule.MobArena.spout;
|
||||
|
||||
import org.getspout.spoutapi.gui.GenericButton;
|
||||
|
||||
public class ClassButton extends GenericButton
|
||||
{
|
||||
public ClassButton(String className)
|
||||
{
|
||||
this.setText(className);
|
||||
this.setWidth(100).setHeight(20);
|
||||
}
|
||||
}
|
38
src/com/garbagemule/MobArena/spout/ClassPopup.java
Normal file
38
src/com/garbagemule/MobArena/spout/ClassPopup.java
Normal file
@ -0,0 +1,38 @@
|
||||
package com.garbagemule.MobArena.spout;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.getspout.spoutapi.gui.GenericLabel;
|
||||
import org.getspout.spoutapi.gui.GenericPopup;
|
||||
import org.getspout.spoutapi.gui.WidgetAnchor;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.garbagemule.MobArena.MobArena;
|
||||
|
||||
public class ClassPopup extends GenericPopup
|
||||
{
|
||||
private GenericLabel arenaTitle = new GenericLabel();
|
||||
|
||||
public ClassPopup(MobArena plugin, SpoutPlayer sp, List<ClassButton> buttons)
|
||||
{
|
||||
int screenWidth = sp.getMainScreen().getWidth();
|
||||
int screenHeight = sp.getMainScreen().getHeight();
|
||||
|
||||
int buttonAmount = buttons.size();
|
||||
int buttonsHeight = buttonAmount * 20;
|
||||
int buttonsX = (screenWidth - 100) / 2;
|
||||
int buttonsY = (screenHeight - buttonsHeight) / 2 + 20;
|
||||
|
||||
arenaTitle.setText("Choose your class!");
|
||||
arenaTitle.setAlign(WidgetAnchor.CENTER_CENTER);
|
||||
arenaTitle.setX((screenWidth - arenaTitle.getWidth()) / 2).setY(buttonsY - 20);
|
||||
this.attachWidget(plugin, arenaTitle);
|
||||
|
||||
for (int i = 0; i < buttons.size(); i++)
|
||||
{
|
||||
ClassButton b = buttons.get(i);
|
||||
b.setX(buttonsX).setY(buttonsY + i*20);
|
||||
this.attachWidget(plugin, b);
|
||||
}
|
||||
}
|
||||
}
|
38
src/com/garbagemule/MobArena/spout/Spouty.java
Normal file
38
src/com/garbagemule/MobArena/spout/Spouty.java
Normal file
@ -0,0 +1,38 @@
|
||||
package com.garbagemule.MobArena.spout;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.garbagemule.MobArena.Arena;
|
||||
import com.garbagemule.MobArena.MobArena;
|
||||
import com.garbagemule.MobArena.listeners.MASpoutScreenListener;
|
||||
|
||||
public class Spouty
|
||||
{
|
||||
public static void registerEvents(MobArena plugin)
|
||||
{
|
||||
PluginManager pm = Bukkit.getServer().getPluginManager();
|
||||
pm.registerEvent(Event.Type.CUSTOM_EVENT, new MASpoutScreenListener(plugin), Priority.Normal, plugin);
|
||||
}
|
||||
|
||||
public static void classSelectionScreen(MobArena plugin, Arena arena, Player p)
|
||||
{
|
||||
SpoutPlayer sp = SpoutManager.getPlayer(p);
|
||||
if (sp == null) return;
|
||||
|
||||
List<ClassButton> buttons = new LinkedList<ClassButton>();
|
||||
for (String s : arena.getClasses())
|
||||
buttons.add(new ClassButton(s));
|
||||
|
||||
ClassPopup popup = new ClassPopup(plugin, sp, buttons);
|
||||
sp.getMainScreen().attachPopupScreen(popup);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user