public void updateSources( @NotNull VcsRoot root, @NotNull CheckoutRules rules, @NotNull String toVersion, @NotNull File checkoutDirectory, @NotNull AgentRunningBuild build, boolean cleanCheckoutRequested) throws VcsException { AgentPluginConfig config = myConfigFactory.createConfig(build, root); GitFactory gitFactory = myGitMetaFactory.createFactory( mySshService, config, getLogger(build), build.getBuildTempDirectory()); Pair<CheckoutMode, File> targetDirAndMode = getTargetDirAndMode(config, root, rules, checkoutDirectory); CheckoutMode mode = targetDirAndMode.first; File targetDir = targetDirAndMode.second; Updater updater; AgentGitVcsRoot gitRoot = new AgentGitVcsRoot(myMirrorManager, targetDir, root); if (config.isUseAlternates(gitRoot)) { updater = new UpdaterWithAlternates( config, myMirrorManager, myDirectoryCleaner, gitFactory, build, root, toVersion, targetDir, rules, mode); } else if (config.isUseLocalMirrors(gitRoot)) { updater = new UpdaterWithMirror( config, myMirrorManager, myDirectoryCleaner, gitFactory, build, root, toVersion, targetDir, rules, mode); } else { updater = new UpdaterImpl( config, myMirrorManager, myDirectoryCleaner, gitFactory, build, root, toVersion, targetDir, rules, mode); } updater.update(); }
@SuppressWarnings("unused") @EventHandler public void onPlayerJoin(PlayerJoinEvent e) { BukkitTask task = new Expire(e, this).runTaskLater(this, 20); if (this.getConfig().getBoolean("update-check") || this.getConfig().getString("update-check").equals("true")) { if (e.getPlayer().hasPermission("donexpress.admin.update")) { String thisVersion = getDescription().getVersion(); Updater updater = new Updater( this, 59496, this.getFile(), Updater.UpdateType.NO_DOWNLOAD, false); // Start Updater but just do a version check update = updater.getResult() == Updater.UpdateResult .UPDATE_AVAILABLE; // Determine if there is an update ready for us name = updater.getLatestName(); // Get the latest version if (update) { e.getPlayer().sendMessage(ChatColor.YELLOW + "An update for DonatorExpress is available"); e.getPlayer().sendMessage(ChatColor.YELLOW + "New version: " + name); e.getPlayer().sendMessage(ChatColor.YELLOW + "Your version: " + thisVersion); e.getPlayer() .sendMessage( ChatColor.YELLOW + "Download it here: http://dev.bukkit.org/bukkit-plugins/donator-express"); } } } }
private Entity createMetadata( final String digestString, final String filename, final String contentType, final byte[] bytes) throws IOException { Updater<Entity> updater = new Updater<Entity>() { @Override protected Entity update() throws IOException { DS ds = DS.get(); Entity metadata = ds.getMetadata(digestString); log(metadata.toString()); if (metadata.getProperties().isEmpty()) { metadata.setProperty(LocationProperty, null); metadata.setUnindexedProperty(FilenameProperty, filename); metadata.setUnindexedProperty(ContentTypeProperty, contentType); metadata.setUnindexedProperty(TimestampProperty, new Date()); try { if (contentType.startsWith("image/jpeg")) { ExifParser exif = new ExifParser(bytes); Date timestamp = exif.getTimestamp(); if (timestamp != null) { exif.populate(metadata); } } } catch (Exception ex) { } ds.put(metadata); } return metadata; } }; return updater.start(); }
@Override public void onEnable() { PM = getServer().getPluginManager(); LOG = getLogger(); getCommand("obsidiandestroyer").setExecutor(cmdExecutor); getCommand("od").setExecutor(cmdExecutor); config.loadConfig(); entityListener.setObsidianDurability(config.loadDurabilityFromFile()); checkFactionsHook(); checkTownyHook(); checkWorldGuardGHook(); PM.registerEvents(entityListener, this); PM.registerEvents(joinListener, this); startMetrics(); if (config.getCheckUpdate()) { Updater updater = new Updater( this, "obsidiandestroyer", this.getFile(), Updater.UpdateType.NO_DOWNLOAD, false); UPDATE = updater.getResult() == Updater.UpdateResult.UPDATE_AVAILABLE; NAME = updater.getLatestVersionString(); } }
private Entity updateBlog( final String messageId, final MimeMessage message, final String htmlBody, final boolean publishImmediately, final Email senderEmail) throws IOException { Updater<Entity> updater = new Updater<Entity>() { @Override protected Entity update() throws IOException { try { String subject = (String) getHeader(message, SubjectProperty); if (subject.startsWith("//WL2K ")) { subject = subject.substring(7); } DS ds = DS.get(); Settings settings = ds.getSettings(); Entity blog = ds.getBlogEntity(messageId, subject); if (subject == null || subject.length() < 2 || htmlBody == null || ContentCounter.countChars(htmlBody) < 5) { ds.deleteWithChilds(blog.getKey()); return null; } int idx = subject.indexOf('{'); if (idx != -1) { Set<String> keywords = getKeywords(subject.substring(idx + 1)); subject = subject.substring(0, idx - 1).trim(); if (!keywords.isEmpty()) { blog.setProperty(KeywordsProperty, keywords); } } blog.setProperty(SubjectProperty, subject); blog.setProperty(PublishProperty, publishImmediately); blog.setProperty(SubjectProperty, subject); blog.setProperty(SenderProperty, senderEmail); setProperty(message, DateProperty, blog, true); blog.setUnindexedProperty(HtmlProperty, new Text(htmlBody)); blog.setProperty(TimestampProperty, new Date()); Entity placemark = ds.fetchLastPlacemark(settings); if (placemark != null) { GeoPt location = (GeoPt) placemark.getProperty(LocationProperty); if (location != null) { blog.setProperty(LocationProperty, location); } } ds.put(blog); return blog; } catch (MessagingException ex) { throw new IOException(ex); } } }; return updater.start(); }
@Test public void array_foreach_modone() throws Exception { UpdateExpression expr = EvalTestContext.updateExpressionFromJson( "{ '$foreach' : { 'field7' : { 'field':'elemf1','op':'=','rvalue':'elvalue0_1'} , '$update' : {'$set': { 'elemf1':'test'}} } }"); Updater updater = Updater.getInstance(JSON_NODE_FACTORY, md, expr); Assert.assertTrue(updater.update(jsonDoc, md.getFieldTreeRoot(), new Path())); Assert.assertEquals(4, jsonDoc.get(new Path("field7")).size()); Assert.assertEquals("test", jsonDoc.get(new Path("field7.0.elemf1")).asText()); }
@Test public void array_foreach_removeall() throws Exception { UpdateExpression expr = EvalTestContext.updateExpressionFromJson( "{ '$foreach' : { 'field7' : '$all', '$update' : '$remove' } }"); Updater updater = Updater.getInstance(JSON_NODE_FACTORY, md, expr); Assert.assertTrue(updater.update(jsonDoc, md.getFieldTreeRoot(), new Path())); Assert.assertEquals(0, jsonDoc.get(new Path("field7")).size()); Assert.assertEquals(0, jsonDoc.get(new Path("field7#")).asInt()); }
@Test public void setArrayFieldTest() throws Exception { UpdateExpression expr = EvalTestContext.updateExpressionFromJson( "{'$set' : { 'field6.nf5.0':'50', 'field6.nf6.1':'blah', 'field7.0.elemf1':'test'}} "); Updater updater = Updater.getInstance(JSON_NODE_FACTORY, md, expr); Assert.assertTrue(updater.update(jsonDoc, md.getFieldTreeRoot(), new Path())); Assert.assertEquals(50, jsonDoc.get(new Path("field6.nf5.0")).intValue()); Assert.assertEquals("blah", jsonDoc.get(new Path("field6.nf6.1")).asText()); Assert.assertEquals("test", jsonDoc.get(new Path("field7.0.elemf1")).asText()); }
@Test public void null_array_set() throws Exception { // Set field7 to null jsonDoc.modify(new Path("field7"), null, true); Assert.assertNull(jsonDoc.get(new Path("field7"))); UpdateExpression expr = EvalTestContext.updateExpressionFromJson("{ '$set' : { 'field7' : [] } }"); Updater updater = Updater.getInstance(JSON_NODE_FACTORY, md, expr); updater.update(jsonDoc, md.getFieldTreeRoot(), new Path()); Assert.assertEquals(0, jsonDoc.get(new Path("field7")).size()); }
@Test public void setSimpleFieldTest() throws Exception { UpdateExpression expr = EvalTestContext.updateExpressionFromJson( "[ {'$set' : { 'field1' : 'set1', 'field2':'set2', 'field5': 0, 'field6.nf1':'set6' } }, {'$add' : { 'field3':1 } } ] "); Updater updater = Updater.getInstance(JSON_NODE_FACTORY, md, expr); Assert.assertTrue(updater.update(jsonDoc, md.getFieldTreeRoot(), new Path())); Assert.assertEquals("set1", jsonDoc.get(new Path("field1")).asText()); Assert.assertEquals("set2", jsonDoc.get(new Path("field2")).asText()); Assert.assertEquals(4, jsonDoc.get(new Path("field3")).asInt()); Assert.assertFalse(jsonDoc.get(new Path("field5")).asBoolean()); Assert.assertEquals("set6", jsonDoc.get(new Path("field6.nf1")).asText()); }
@Test public void refSet() throws Exception { UpdateExpression expr = EvalTestContext.updateExpressionFromJson( "{'$set' : { 'field6.nf5.0': { '$valueof' : 'field3' }, 'field7.0' : {}}}"); Updater updater = Updater.getInstance(JSON_NODE_FACTORY, md, expr); Assert.assertTrue(updater.update(jsonDoc, md.getFieldTreeRoot(), new Path())); Assert.assertEquals( jsonDoc.get(new Path("field3")).intValue(), jsonDoc.get(new Path("field6.nf5.0")).intValue()); JsonNode node = jsonDoc.get(new Path("field7.0")); Assert.assertNotNull(node); Assert.assertEquals(0, node.size()); Assert.assertTrue(node instanceof ObjectNode); }
public NotificationsPanel(MainFrame owner) { this.owner = owner; this.setPreferredSize(new Dimension(0, 50)); this.setLayout(new GridLayout(1, 3, 5, 0)); this.updater = Updater.getInstance(); this.updater.registerObserver(this); JPanel pnlStocks = new JPanel(); pnlStocks.setLayout(new BorderLayout()); add(pnlStocks); lblStocks = new JLabel(""); pnlStocks.add(lblStocks); pnlStocks.add(Box.createRigidArea(new Dimension(5, 5)), BorderLayout.WEST); JPanel pnlExpiring = new JPanel(); pnlExpiring.setLayout(new BorderLayout()); add(pnlExpiring); lblExpiring = new JLabel(""); pnlExpiring.add(lblExpiring); JPanel pnlWasted = new JPanel(); pnlWasted.setLayout(new BorderLayout()); add(pnlWasted); lblWasted = new JLabel(""); pnlWasted.add(lblWasted); pnlWasted.add(Box.createRigidArea(new Dimension(5, 5)), BorderLayout.EAST); this.checkStatus(); }
/** * Reload RecipeManager's settings, messages, etc and re-parse recipes. * * @param sender To whom to send the messages to, null = console. * @param check Set to true to only check recipes, settings are unaffected. */ public void reload(CommandSender sender, boolean check, boolean firstTime) { Settings.getInstance().reload(sender); // (re)load settings Messages.getInstance().reload(sender); // (re)load messages from messages.yml Files.reload(sender); // (re)generate info files if they do not exist Updater.init(this, 32835, null); if (metrics == null) { if (Settings.getInstance().getMetrics()) { // start/stop metrics accordingly try { metrics = new Metrics(this); metrics.start(); } catch (IOException e) { e.printStackTrace(); } } } else { metrics.stop(); } if (!check) { if (Settings.getInstance().getClearRecipes() || !firstTime) { Vanilla.removeAllButSpecialRecipes(); Recipes.getInstance().clean(); } if (!firstTime && !Settings.getInstance().getClearRecipes()) { Vanilla.restoreAllButSpecialRecipes(); Recipes.getInstance().index.putAll(Vanilla.initialRecipes); } } RecipeProcessor.reload(sender, check); // (re)parse recipe files Events.reload(); // (re)register events }
public void removeUpdater(Updater _updater) { int index = _updater.getPriority().getIndex(); if (index < groups.size) { UpdateGroup group = groups.get(index); if (group != null) group.removeUpdater(_updater); } }
private <T extends ArtCollection> void updateArts( List<T> items, ArtSize artSize, Updater<T> updater) { for (T item : items) { if (item.getArtUrl(ArtSize.SMALL) == null) { try { ArtCollection arts = updater.getArts(item); if (arts != null) { String artUrl = arts.getArtUrl(artSize); updater.save(artUrl, artSize, item); } } catch (IOException e) { e.printStackTrace(); } } } }
@Override public boolean onPreferenceClick(Preference preference) { if (preference == update) { Updater.checkForUpdates(getActivity(), true); } else if (preference == storagePath) { Intent i = new Intent(context, FilePickerActivity.class); i.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false); i.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, true); i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_DIR); startActivityForResult(i, 69); return true; } else if (preference == facebook) { Utils.viewURL(context, FACEBOOK_URL); } else if (preference == googlePlus) { Utils.viewURL(context, GOOGLE_PLUS_URL); } else if (preference == privacy) { Utils.viewURL(context, PRIVACY_URL); } else if (preference == terms) { Utils.viewURL(context, TOS_URL); } else if (preference == about) { Utils.viewURL(context, ABOUT_URL); } else if (preference == madeWithLove) { Utils.viewURL(context, MADE_WITH_LOVE_URL); } return false; }
@Override public void perform(Run<?, ?> run, FilePath workspace, Launcher launcher, TaskListener listener) throws InterruptedException, IOException { // Don't do anything for individual matrix runs. if (run instanceof MatrixRun) { return; } else if (run instanceof AbstractBuild) { AbstractBuild<?, ?> abstractBuild = (AbstractBuild<?, ?>) run; Updater updater = new Updater(abstractBuild.getParent().getScm(), labels); updater.perform(run, listener, getIssueSelector()); } else if (scm != null) { Updater updater = new Updater(scm, labels); updater.perform(run, listener, getIssueSelector()); } else { throw new IllegalArgumentException("Unsupported run type " + run.getClass().getName()); } }
@Test public void unset() throws Exception { UpdateExpression expr = EvalTestContext.updateExpressionFromJson( "{'$unset' : [ 'field1', 'field6.nf2', 'field6.nf6.1','field7.1'] }"); Updater updater = Updater.getInstance(JSON_NODE_FACTORY, md, expr); Assert.assertTrue(updater.update(jsonDoc, md.getFieldTreeRoot(), new Path())); Assert.assertNull(jsonDoc.get(new Path("field1"))); Assert.assertNull(jsonDoc.get(new Path("field6.nf2"))); Assert.assertEquals("three", jsonDoc.get(new Path("field6.nf6.1")).asText()); Assert.assertEquals(3, jsonDoc.get(new Path("field6.nf6#")).asInt()); Assert.assertEquals(3, jsonDoc.get(new Path("field6.nf6")).size()); Assert.assertEquals("elvalue2_1", jsonDoc.get(new Path("field7.1.elemf1")).asText()); Assert.assertEquals(3, jsonDoc.get(new Path("field7#")).asInt()); Assert.assertEquals(3, jsonDoc.get(new Path("field7")).size()); }
public PipelineConfig updatePipeline( CaseInsensitiveString pipelineName, Updater<PipelineConfig> updater) { CruiseConfig cruiseConfig = loadForEdit(); PipelineConfig pipelineConfig = cruiseConfig.getPipelineConfigByName(pipelineName); updater.update(pipelineConfig); writeConfigFile(cruiseConfig); return pipelineConfig; }
@Test public void array_insert() throws Exception { UpdateExpression expr = EvalTestContext.updateExpressionFromJson( "{ '$insert' : { 'field6.nf6.2' : [ 'five','six',{'$valueof':'field2' }] } }"); Updater updater = Updater.getInstance(JSON_NODE_FACTORY, md, expr); Assert.assertTrue(updater.update(jsonDoc, md.getFieldTreeRoot(), new Path())); Assert.assertEquals("one", jsonDoc.get(new Path("field6.nf6.0")).asText()); Assert.assertEquals("two", jsonDoc.get(new Path("field6.nf6.1")).asText()); Assert.assertEquals("five", jsonDoc.get(new Path("field6.nf6.2")).asText()); Assert.assertEquals("six", jsonDoc.get(new Path("field6.nf6.3")).asText()); Assert.assertEquals("value2", jsonDoc.get(new Path("field6.nf6.4")).asText()); Assert.assertEquals("three", jsonDoc.get(new Path("field6.nf6.5")).asText()); Assert.assertEquals("four", jsonDoc.get(new Path("field6.nf6.6")).asText()); Assert.assertNull(jsonDoc.get(new Path("field6.ng6.7"))); Assert.assertEquals(7, jsonDoc.get(new Path("field6.nf6#")).asInt()); Assert.assertEquals(7, jsonDoc.get(new Path("field6.nf6")).size()); }
public void addUpdater(Updater _updater) { int index = _updater.getPriority().getIndex(); // We resize the array is the priority is too high for the array if (index >= groups.size) { int diff = index - (groups.size - 1); groups.ensureCapacity(diff); // A resize method would be good here :) for (int i = 0; i < diff; ++i) { groups.add(null); } } UpdateGroup group = groups.get(index); if (group == null) { group = new UpdateGroup(_updater.getPriority()); groups.set(index, group); } group.addUpdater(_updater); }
@Test public void array_foreach_append() throws Exception { jsonDoc = EvalTestContext.getDoc("./termsdata.json"); md = EvalTestContext.getMd("./termsmd.json"); UpdateExpression expr = EvalTestContext.updateExpressionFromJson( "{ '$foreach' : { 'termsVerbiage' : { 'field':'uid','op':'=','rvalue':1} ," + "'$update' : [ " + "{ '$insert': { 'termsVerbiageTranslation.0': {}}}," + "{ '$set': {'termsVerbiageTranslation.0.localeCode':'lg','termsVerbiageTranslation.0.localeText':'Lang' } }" + " ] }}"); Updater updater = Updater.getInstance(JSON_NODE_FACTORY, md, expr); System.out.println("before:" + JsonUtils.prettyPrint(jsonDoc.getRoot())); Assert.assertTrue(updater.update(jsonDoc, md.getFieldTreeRoot(), new Path())); System.out.println("After:" + JsonUtils.prettyPrint(jsonDoc.getRoot())); Assert.assertEquals( 4, jsonDoc.get(new Path("termsVerbiage.0.termsVerbiageTranslation")).size()); Assert.assertEquals( "lg", jsonDoc.get(new Path("termsVerbiage.0.termsVerbiageTranslation.0.localeCode")).asText()); }
public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("Quit")) { System.exit(0); } else if (e.getActionCommand().equals("Unbind name")) { tree.unbind(); } else if (e.getActionCommand().equals("Bind Object")) { ObjectDialog dialog = new ObjectDialog((Frame) frame); // dialog.pack(); // dialog.show(); if (dialog.isOk) { try { tree.bindObject(dialog.getName(), dialog.getIOR(), dialog.isRebind()); } catch (org.omg.CORBA.UserException ue) { JOptionPane.showMessageDialog( frame, ue.getClass().getName() + (ue.getMessage() != null ? (":" + ue.getMessage()) : ""), "Exception", JOptionPane.INFORMATION_MESSAGE); } } } else if (e.getActionCommand().equals("BindNewContext")) { try { String contextName = JOptionPane.showInputDialog( frame, "Name of the new context", "BindNewContext", JOptionPane.QUESTION_MESSAGE); // check if user input is okay or if CANCEL was hit if (contextName != null && contextName.length() > 0) tree.bind(contextName); } catch (org.omg.CORBA.UserException ue) { JOptionPane.showMessageDialog( frame, ue.getClass().getName() + (ue.getMessage() != null ? (":" + ue.getMessage()) : ""), "Exception", JOptionPane.INFORMATION_MESSAGE); } } else if (e.getActionCommand().equals("About...")) { JOptionPane.showMessageDialog( frame, "JacORB NameManager 1.2\n(C) 1998-2004 Gerald Brose, Wei-ju Wu & Volker Siegel\nFreie Universitaet Berlin", "About", JOptionPane.INFORMATION_MESSAGE); } else if (e.getActionCommand().equals("Options")) { NSPrefsDlg dlg = new NSPrefsDlg((Frame) frame, updateInterval); dlg.pack(); dlg.show(); if (dlg.isOk) updater.setSeconds(dlg.updateInterval); } else throw new RuntimeException("Should not happen"); }
/** * Constructs. * * @param display The VisAD display to use. * @throws DisplayException The VisAD display is <code>null</code>. * @throws VisADException VisAD failure. * @throws RemoteException Java RMI failure. */ public DisplayAdapter(DisplayImpl display) throws DisplayException, VisADException, RemoteException { if (display == null) { throw new DisplayException(getClass().getName() + ".<init>: " + "Display argument is null"); } this.display = display; updater = new Updater(); updater.setPriority(Thread.currentThread().getPriority() / 2); datumTable = new DatumTable(); scalarMapTable = new ScalarMapTable(); constantMapTable = new ConstantMapTable(); }
public boolean update() throws IOException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { ClassLoader newLoader = updater.update(); Class<?> cl = newLoader.loadClass(Main.class.getName()); if (Main.class.equals(cl)) return false; // Not a new class Object newMain; Method init = cl.getMethod("init", InputStream.class, PipeOutputStream.class, PipeInputStream.class), start = cl.getMethod("start"); try { newMain = cl.newInstance(); init.invoke(newMain, oldStdin, stdinPipe, stdoutPipe); stop(); start.invoke(newMain); return true; } catch (InstantiationException ignored) { } return false; }
public Handler(Component fr, NSTree tr) { frame = fr; tree = tr; popup = new JPopupMenu(); JMenuItem bindContext = new JMenuItem("BindNewContext"); JMenuItem bindObject = new JMenuItem("Bind Object"); JMenuItem unbind = new JMenuItem("Unbind name"); popup.add(bindContext); popup.add(bindObject); popup.add(unbind); bindContext.addActionListener(this); bindObject.addActionListener(this); unbind.addActionListener(this); updateInterval = 10; updater = new Updater(tree, updateInterval); updater.start(); }
private int executeUpdateInternal( final Updater updater, final StatementExecutorWrapper statementExecutorWrapper, final boolean isExceptionThrown, final Map<String, Object> dataMap) { int result; ExecutorExceptionHandler.setExceptionThrown(isExceptionThrown); ExecutorDataMap.setDataMap(dataMap); try { result = updater.executeUpdate( statementExecutorWrapper.getStatement(), statementExecutorWrapper.getSqlExecutionUnit().getSql()); } catch (final SQLException ex) { postExecutionEventsAfterExecution( statementExecutorWrapper, EventExecutionType.EXECUTE_FAILURE, Optional.of(ex)); ExecutorExceptionHandler.handleException(ex); return 0; } postExecutionEventsAfterExecution(statementExecutorWrapper); return result; }
public static void init() { users.clear(); fullInfoQuery.clear(); self = addUser(TL.newObject("userEmpty", 0)); contacts_hash = ""; // update typing updater = new Updater( 3 * 1000, new Runnable() { @Override public void run() { int time = Common.getUnixTime(); for (int i = 0; i < User.users.size(); i++) { User user = User.users.get(User.users.keyAt(i)); if (user.typing && user.typing_time < time) user.setTyping(user.typing_chat_id, false); } } }); updater.startUpdates(); }
private Updater start(View ix, byte[] key, byte[] value, boolean noGhost) throws Exception { Updater u = new Updater(ix, key, value, noGhost); u.start(); u.waitToSleep(); return u; }
@Override public boolean onCommand( CommandSender sender, Command command, String commandLabel, String[] args) { String commandName = command.getName().toLowerCase(); try { lastCommand = (sender instanceof Player ? "player:" : "console:") + commandName + " " + Str.argStr(args); // i don't like seeing these messages all the time.. // Log(((Player) sender).getName() + " used command " + command.getName()); if (BetterShop.iConomy == null && BetterShop.economy == null) { BSutils.sendMessage( sender, "\u00A74 BetterShop is missing a dependency. Check the console."); Log(Level.SEVERE, "Missing: iConomy or BOSEconomy", false); return true; } if (stock != null && config.useItemStock) { stock.checkStockRestock(); } if (commandName.equals("shop")) { if (args.length > 0) { if (args[0].equalsIgnoreCase("list")) { commandName = "shoplist"; } else if (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("?")) { commandName = "shophelp"; } else if (args[0].equalsIgnoreCase("buy")) { commandName = "shopbuy"; } else if (args[0].equalsIgnoreCase("sell")) { commandName = "shopsell"; } else if (args[0].equalsIgnoreCase("add")) { commandName = "shopadd"; } else if (args[0].equalsIgnoreCase("remove")) { commandName = "shopremove"; } else if (args[0].equalsIgnoreCase("load") || args[0].equalsIgnoreCase("reload")) { commandName = "shopload"; } else if (args[0].equalsIgnoreCase("check")) { commandName = "shopcheck"; } else if (args[0].equalsIgnoreCase("sellall")) { commandName = "shopsellall"; } else if (args[0].equalsIgnoreCase("sellstack")) { commandName = "shopsellstack"; } else if (args[0].equalsIgnoreCase("buystack")) { commandName = "shopbuystack"; } else if (args[0].equalsIgnoreCase("buyall")) { commandName = "shopbuyall"; } else if (args[0].equalsIgnoreCase("sellagain")) { commandName = "shopsellagain"; } else if (args[0].equalsIgnoreCase("buyagain")) { commandName = "shopbuyagain"; } else if (args[0].equalsIgnoreCase("listkits")) { commandName = "shoplistkits"; } else if (args[0].equalsIgnoreCase("restock")) { if (BSutils.hasPermission(sender, BSutils.BetterShopPermission.ADMIN_RESTOCK, true)) { stock.Restock(true); sender.sendMessage("Stock set to initial values"); } } else if (args[0].equalsIgnoreCase("backup")) { if (BSutils.hasPermission(sender, BSutils.BetterShopPermission.ADMIN_BACKUP, true)) { SimpleDateFormat formatter = new SimpleDateFormat("_yyyy_MM_dd_HH-mm-ss"); String backFname = BSConfig.pluginFolder.getPath() + File.separatorChar + config.tableName + formatter.format(new java.util.Date()) + ".csv"; try { if (pricelist.saveFile(new File(backFname))) { sender.sendMessage("Backup saved as " + backFname); } } catch (IOException ex) { Log(Level.SEVERE, "Failed to save backup file " + backFname, ex); sender.sendMessage("\u00A74Failed to save backup file " + backFname); } } return true; } else if (args[0].equalsIgnoreCase("import")) { return bscommand.importDB(sender, args); } else if (args[0].equalsIgnoreCase("restore")) { return bscommand.restoreDB(sender, args); } else if (args[0].equalsIgnoreCase("update")) { if (sender.isOp()) { Log("Downloading & Installing Update"); BSutils.sendMessage(sender, "Downloading & Installing Update"); ServerReload sreload = new ServerReload(getServer()); if (Updater.downloadUpdate()) { Log("Update Downloaded: Restarting Server.."); BSutils.sendMessage(sender, "Download Successful.. reloading server"); // this.setEnabled(false); // this.getServer().dispatchCommand((CommandSender) new CommanderSenderImpl(this), // "stop"); // this.getServer().dispatchCommand(new AdminCommandSender(this), "stop"); // this.getServer().reload(); sreload.start(500); } } else { BSutils.sendMessage(sender, "Only an OP can update the shop plugin"); } return true; } else if (args[0].equalsIgnoreCase("ver") || args[0].equalsIgnoreCase("version")) { // allow admin.info or developers access to plugin status (so if i find a bug i can see // if it's current) if (BSutils.hasPermission(sender, BSutils.BetterShopPermission.ADMIN_INFO, false) || (sender instanceof Player && (((Player) sender).getDisplayName().equals("jascotty2") || ((Player) sender).getDisplayName().equals("jjfs85")))) { BSutils.sendMessage(sender, "version " + pdfFile.getVersion()); if (Updater.isUpToDate()) { BSutils.sendMessage(sender, "Version is up-to-date"); } else { BSutils.sendMessage(sender, "Newer Version Avaliable"); } return true; } } else { return false; } // now remove [0] if (args.length > 1) { String newArgs[] = new String[args.length - 1]; for (int i = 1; i < args.length; ++i) { newArgs[i - 1] = args[i]; } args = newArgs; } else { args = new String[0]; } } else { return false; } } // check if using history if (commandName.equals("shopbuyagain") || commandName.equals("shopsellagain")) { if (args.length > 0 || BSutils.anonymousCheck(sender)) { return false; } if (commandName.equals("shopbuyagain")) { String action = bscommand.userbuyHistory.get(((Player) sender).getDisplayName()); if (action == null) { BSutils.sendMessage(sender, "You have no recent buying history"); return true; } else { // trim command & put into args String cm[] = action.split(" "); commandName = cm[0]; args = new String[cm.length - 1]; for (int i = 1; i < cm.length; ++i) { args[i - 1] = cm[i]; } } } else { // if (commandName.equals("shopsellagain")) { String action = bscommand.usersellHistory.get(((Player) sender).getDisplayName()); if (action == null) { BSutils.sendMessage(sender, "You have no recent sell history"); return true; } else { // trim command & put into args String cm[] = action.split(" "); commandName = cm[0]; args = new String[cm.length - 1]; for (int i = 1; i < cm.length; ++i) { args[i - 1] = cm[i]; } } } // System.out.println("new command: " + commandName); // System.out.println(BSCommand.argStr(args)); } if (!config.useGlobalCommandShop() && Str.isIn( commandName, new String[] { "shopbuy", "shopbuyall", "shopbuystack", "shopsell", "shopsellall", "shopsellstack", /*"shoplist", "shopitems", "shopcheck", "shoplistkits", "shopadd", "shopremove"*/ })) { BSutils.sendMessage(sender, "Shop is disabled from here"); return true; } if (commandName.equals("shoplist")) { return bscommand.list(sender, args); } else if (commandName.equals("shopitems")) { return bscommand.listitems(sender, args); } else if (commandName.equals("shophelp")) { return bscommand.help(sender, args); } else if (commandName.equals("shopbuy")) { return bscommand.buy(sender, args); } else if (commandName.equals("shopbuyall")) { ArrayList<String> arg = new ArrayList<String>(); arg.addAll(Arrays.asList(args)); arg.add("all"); return bscommand.buy(sender, arg.toArray(new String[0])); } else if (commandName.equals("shopbuystack")) { return bscommand.buystack(sender, args); } else if (commandName.equals("shopsell")) { return bscommand.sell(sender, args); } else if (commandName.equals("shopsellall")) { return bscommand.sellall(sender, args); } else if (commandName.equals("shopsellstack")) { return bscommand.sellstack(sender, args); } else if (commandName.equals("shopadd")) { return bscommand.add(sender, args); } else if (commandName.equals("shopremove")) { return bscommand.remove(sender, args); } else if (commandName.equals("shopload")) { return bscommand.load(sender); } else if (commandName.equals("shopcheck")) { return bscommand.check(sender, args); } else if (commandName.equals("shoplistkits")) { return bscommand.listkits(sender, args); } return false; } catch (Exception e) { BSutils.sendMessage(sender, "Unexpected Error!"); Log(Level.SEVERE, e); } return true; }