Lots of stuff

This commit is contained in:
Sam 2017-01-30 23:28:55 +00:00
parent fb35f19c3d
commit c6bb850bc3
18 changed files with 145 additions and 237 deletions

View File

@ -3,28 +3,29 @@ package mineplex.core.sponsorbranding;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.concurrent.ConcurrentHashMap;
import javax.imageio.ImageIO;
import mineplex.core.MiniPlugin;
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
/**
*
* Manager for creating billboards with branding logos
*/
@ReflectivelyCreateMiniPlugin
public class BrandingManager extends MiniPlugin
{
private ConcurrentHashMap<Integer, BrandingPost> _posts = new ConcurrentHashMap<Integer, BrandingPost>();
private ConcurrentHashMap<String, BufferedImage> _imgCache = new ConcurrentHashMap<String, BufferedImage>();
public BrandingManager(JavaPlugin plugin)
private BrandingManager()
{
super("Branding Manager", plugin);
super("Branding Manager");
}
private BufferedImage getImage(String fileName)
@ -56,6 +57,28 @@ public class BrandingManager extends MiniPlugin
return image;
}
private BufferedImage getImage(URL url)
{
if (_imgCache.containsKey(url.toString()))
{
return _imgCache.get(url.toString());
}
BufferedImage image = null;
try
{
image = ImageIO.read(url);
_imgCache.put(url.toString(), image);
}
catch (IOException e)
{
e.printStackTrace();
}
return image;
}
/**
* Generates a billboard with a stored logo
* @param location The center of the billboard
@ -75,6 +98,22 @@ public class BrandingManager extends MiniPlugin
_posts.put(_posts.size(), bp);
}
public void createPost(Location location, BlockFace facing, URL url)
{
BufferedImage image = getImage(url);
if (image == null)
{
System.out.println("ERROR! Invalid image url!");
return;
}
BrandingPost brandingPost = new BrandingPost(location, facing, image);
brandingPost.spawn();
// Umm why not use a List?
_posts.put(_posts.size(), brandingPost);
}
/**
* Clears away all existing billboards
*/

View File

@ -68,6 +68,8 @@ public class BrandingPost
int width = (int) Math.ceil(_img.getWidth() / 128);
int height = (int) Math.ceil(_img.getHeight() / 128);
Bukkit.broadcastMessage("width=" + width + " height=" + height);
switch (_facing)
{
case EAST:
@ -160,6 +162,7 @@ public class BrandingPost
ItemStack item = getMapItem(x, y, _img);
i.setItem(item);
Bukkit.broadcastMessage(x + " <- X Y -> " + y);
_ents.add(i);
}
}

View File

@ -228,7 +228,7 @@ public class Hub extends JavaPlugin implements IRelation
//Updates
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
BrandingManager brandingManager = new BrandingManager(this);
BrandingManager brandingManager = require(BrandingManager.class);
new BillboardManager(this, brandingManager);
require(TrackManager.class);

View File

@ -4,9 +4,6 @@ import mineplex.core.MiniPlugin;
import mineplex.core.common.events.ServerShutdownEvent;
import mineplex.core.sponsorbranding.BrandingManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.ItemFrame;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent;

View File

@ -288,7 +288,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_conditionManager = new SkillConditionManager(plugin);
_brandingManager = new BrandingManager(plugin);
_brandingManager = require(BrandingManager.class);
_boosterManager = boosterManager;

View File

@ -49,6 +49,7 @@ import mineplex.core.teleport.Teleport;
import mineplex.core.updater.FileUpdater;
import mineplex.core.updater.Updater;
import mineplex.core.visibility.VisibilityManager;
import mineplex.gemhunters.bounties.BountyModule;
import mineplex.gemhunters.chat.ChatModule;
import mineplex.gemhunters.death.DeathModule;
import mineplex.gemhunters.economy.CashOutModule;
@ -208,6 +209,7 @@ public class GemHunters extends JavaPlugin
new HologramManager(this, packetHandler);
// Now we finally get to enable the Gem Hunters modules
require(BountyModule.class);
require(CashOutModule.class);
require(ChatModule.class);
require(DeathModule.class);

View File

@ -0,0 +1,46 @@
package mineplex.gemhunters.bounties;
import java.net.MalformedURLException;
import java.net.URL;
import org.bukkit.block.BlockFace;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.sponsorbranding.BrandingManager;
@ReflectivelyCreateMiniPlugin
public class BountyModule extends MiniPlugin
{
private final BrandingManager _brandingManager;
private BountyModule()
{
super("Bounty");
_brandingManager = require(BrandingManager.class);
}
@EventHandler
public void test(PlayerCommandPreprocessEvent event)
{
if (!event.getMessage().startsWith("/want"))
{
return;
}
try
{
event.setCancelled(true);
_brandingManager.createPost(event.getPlayer().getLocation(), BlockFace.SOUTH, new URL("http://minotar.net/helm/Moppletop.png"));
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
}
}

View File

@ -165,8 +165,8 @@ public class CashOutModule extends MiniPlugin
session.endSession();
iterator.remove();
player.sendMessage(C.cGreen + "Imagine you are being sent to the Lobby.");
// Portal.getInstance().sendToHub(player, "You cashed out!");
player.kickPlayer(C.cGreen + "Imagine you are being sent to the Lobby.");
// Portal.getInstance().sendToHub(player, null);
}
}
}

View File

@ -18,7 +18,6 @@ public class CashOutSession
_max = max;
_stand = player.getWorld().spawn(player.getLocation().add(0, 0.5, 0), ArmorStand.class);
_stand.setCustomName("Cashing Out");
_stand.setCustomNameVisible(true);
_stand.setVisible(false);
_stand.setGravity(false);

View File

@ -54,5 +54,9 @@ public class GemHuntersScoreboard extends WritableMineplexScoreboard
{
return C.cGray + " " + perspective.getName();
}
public int getUndernameScore(Player player)
{
return _economy.getGems(player);
}
}

View File

@ -8,6 +8,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
@ -97,15 +99,19 @@ public class ScoreboardModule extends MiniPlugin
{
Player otherPlayer = other.getOwner();
Team team = handle.registerNewTeam(otherPlayer.getName());
team.setPrefix(_clientManager.Get(otherPlayer).GetRank().getTag(true, true) + C.Reset + " ");
team.setSuffix(scoreboard.getSuffix(player, otherPlayer));
team.addEntry(otherPlayer.getName());
if (player.equals(otherPlayer))
{
continue;
}
Objective gemCounter = handle.registerNewObjective("gems", "Gems");
gemCounter.setDisplaySlot(DisplaySlot.BELOW_NAME);
gemCounter.getScore(otherPlayer.getName()).setScore(scoreboard.getUndernameScore(otherPlayer));
Scoreboard otherHandle = other.getHandle();
Team otherTeam = otherHandle.registerNewTeam(player.getName());

View File

@ -52,7 +52,7 @@ public class ShopModule extends MiniPlugin
private static final int MAX_SEARCH_ATTEMPTS = 40;
private static final String[] NAMES = {
"Andrew", "Jon", "Bob", "Sam", "Ronan", "Alex", "Joe", "Emma", "Giovani", "Dean", "Josh", "Geoffrey", "Parker", "Spencer", "Luke"
};
private final GoogleSheetsManager _sheets;

View File

@ -1,12 +1,5 @@
package mineplex.gemhunters.util;
import java.net.MalformedURLException;
import java.net.URL;
import mineplex.core.slack.SlackAPI;
import mineplex.core.slack.SlackMessage;
import mineplex.core.slack.SlackTeam;
public class SlackSheetsBot
{
@ -16,15 +9,15 @@ public class SlackSheetsBot
public static final void reportParsingError(Exception exception, String spreadsheetName, String sheetName, int row)
{
try
{
SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, SLACK_CHANNEL_NAME, new SlackMessage(SLACK_USERNAME, new URL(SLACK_ICON), "A parsing error has occured on spreadsheet *" + spreadsheetName + "* sheet *" + sheetName + "* at row *" + row + "*.\n Details: " + exception.getMessage()),
true);
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
// try
// {
// SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, SLACK_CHANNEL_NAME, new SlackMessage(SLACK_USERNAME, new URL(SLACK_ICON), "A parsing error has occured on spreadsheet *" + spreadsheetName + "* sheet *" + sheetName + "* at row *" + row + "*.\n Details: " + exception.getMessage()),
// true);
// }
// catch (MalformedURLException e)
// {
// e.printStackTrace();
// }
}
}

View File

@ -6,6 +6,8 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class WorldListeners implements Listener
@ -15,7 +17,7 @@ public class WorldListeners implements Listener
{
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void blockBreak(BlockBreakEvent event)
{
@ -24,7 +26,7 @@ public class WorldListeners implements Listener
event.setCancelled(true);
}
}
@EventHandler
public void blockPlace(BlockPlaceEvent event)
{
@ -33,10 +35,28 @@ public class WorldListeners implements Listener
event.setCancelled(true);
}
}
@EventHandler
public void armorStandEdit(PlayerArmorStandManipulateEvent event)
{
if (shouldBlock(event.getPlayer()))
{
event.setCancelled(true);
}
}
@EventHandler
public void armorStandDestory(PlayerInteractAtEntityEvent event)
{
if (shouldBlock(event.getPlayer()))
{
event.setCancelled(true);
}
}
public boolean shouldBlock(Player player)
{
return player.getGameMode() != GameMode.CREATIVE;
}
}

View File

@ -1,13 +1,11 @@
package mineplex.gemhunters.worldevent;
import mineplex.gemhunters.worldevent.giant.GiantWorldEvent;
import mineplex.gemhunters.worldevent.pumpkinking.PumpkinKingWorldEvent;
public enum WorldEventType
{
GIANT("Zombie Awakening", GiantWorldEvent.class, WorldEventPriority.GLOBAL),
PUMPKIN_KING("Pumpkin King", PumpkinKingWorldEvent.class, WorldEventPriority.ISOLATED)
;
private String _name;

View File

@ -1,85 +0,0 @@
package mineplex.gemhunters.worldevent.pumpkinking;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class PhaseOne implements Listener
{
private static final int SHIELD_RADIUS = 4;
private final PumpkingKing _pumpkingKing;
private final Set<Block> _sheildBlocks;
private boolean _shieldActive;
public PhaseOne(PumpkingKing pumpkingKing)
{
_pumpkingKing = pumpkingKing;
_sheildBlocks = new HashSet<>();
}
@EventHandler
public void shieldActive(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTER)
{
return;
}
if (!_shieldActive)
{
_shieldActive = true;
createShield();
}
}
public void createShield()
{
Map<Block, Double> blocks = UtilBlock.getInRadius(_pumpkingKing.getSpawn().getBlock(), SHIELD_RADIUS);
new BukkitRunnable()
{
int y = _pumpkingKing.getSpawn().clone().subtract(0, SHIELD_RADIUS, 0).getBlockY();
int yGoal = y + SHIELD_RADIUS * 2;
@Override
public void run()
{
if (y > yGoal)
{
cancel();
return;
}
for (Block block : blocks.keySet())
{
if (blocks.get(block) > 0.3 || block.getLocation().getY() > y)
{
continue;
}
_sheildBlocks.add(block);
MapUtil.QuickChangeBlockAt(block.getLocation(), Material.STAINED_GLASS, (byte) 10);
}
y += 1;
}
}.runTaskTimer(UtilServer.getPlugin(), 0, 10);
}
}

View File

@ -1,32 +0,0 @@
package mineplex.gemhunters.worldevent.pumpkinking;
import mineplex.gemhunters.worldevent.WorldEvent;
import mineplex.gemhunters.worldevent.WorldEventType;
public class PumpkinKingWorldEvent extends WorldEvent
{
public PumpkinKingWorldEvent(WorldEventType eventType)
{
super(eventType);
}
@Override
public void onStart()
{
new PumpkingKing();
}
@Override
public boolean checkToEnd()
{
return false;
}
@Override
public void onEnd()
{
}
}

View File

@ -1,82 +0,0 @@
package mineplex.gemhunters.worldevent.pumpkinking;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Skeleton;
import org.bukkit.event.Listener;
import mineplex.core.Managers;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilServer;
import mineplex.core.utils.UtilVariant;
import mineplex.gemhunters.world.WorldDataModule;
public class PumpkingKing
{
private final WorldDataModule _worldData;
private final World _world;
private final Skeleton _entity;
private final Object[] _phases;
private int _phase;
public PumpkingKing()
{
_worldData = Managers.require(WorldDataModule.class);
_world = _worldData.World;
_entity = UtilVariant.spawnWitherSkeleton(getSpawn());
_entity.setRemoveWhenFarAway(false);
_entity.setCustomName(C.cDRedB + "Pumpking King");
_entity.setCustomNameVisible(true);
UtilEnt.vegetate(_entity, true);
UtilEnt.ghost(_entity, true, false);
UtilEnt.setFakeHead(_entity, true);
_phases = new Object[] { new PhaseOne(this) };
_phase = -1;
nextPhase();
//plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
public void nextPhase()
{
if (_phase != -1)
{
UtilServer.Unregister((Listener) _phases[_phase]);
}
_phase++;
UtilServer.RegisterEvents((Listener) _phases[_phase]);
}
public Location getSpawn()
{
return getLocation("Spawn");
}
public Location getLocation(String id)
{
return _worldData.getCustomLocation("PK " + id).get(0);
}
public List<Location> getLocations(String id)
{
return _worldData.getCustomLocation("PK " + id);
}
public Skeleton getEntity()
{
return _entity;
}
}