id
stringlengths
36
36
text
stringlengths
1
1.25M
4d6a1adf-f007-4e1a-9603-2b8ff3a9cd11
public PlaceBlock(AutoRefill plugin) { this.plugin = plugin; }
4450f5e6-354c-47e6-8e10-f1da2a373ce1
@EventHandler public void onBlockPlace(BlockPlaceEvent event) { final Player player = event.getPlayer(); if(player.hasPermission("autorefill.use")) { if(player.getGameMode() != GameMode.CREATIVE) { if(plugin.refillList.containsKey(player)) { RefillPlayer p = plugin.refillList.get(pl...
a55a4211-9a98-4e30-976a-1051a521ed74
public void run() { int index = -1; for(ItemStack i: playerInventory) { index += 1; if(i != null) { if(i.getDurability() == durability) { if(i.getType().equals(blockType)){ refill(player, index); return; } ...
52e2aeeb-abb2-4399-b4fd-00169216da94
public void refill(Player player, int index){ Inventory playerInventory = player.getInventory(); if(index != -1 && index <= 8){ player.getInventory().setHeldItemSlot(index); return; } else { if (index != -1 && player.getItemInHand().getType() == Material.AIR) { player.setItemInHand(playerInventory...
e8f0cce3-cf13-4925-a4a2-2527ebb913aa
private boolean isRefillable(Material block) { return plugin.configBlocks.contains(block); }
2747d441-013d-42b4-966d-1351405b9266
public RefillPlayer(Player player, boolean enabled) { this.player = player; this.enabled = enabled; }
3aaf7c75-829b-47f3-baa7-856ddf5e61df
public void setEnabled(boolean enabled) { this.enabled = enabled; }
2449bcda-c495-415e-a2bc-50a721a23810
public boolean isEnabled() { return this.enabled; }
ab692aaa-60b1-4fe9-9ee6-adb9e45d8b77
public Player getPlayer() { return this.player; }
634af58d-726c-4f95-88dd-03c3315abfe3
public void onEnable() { long start = System.currentTimeMillis(); load(); getLogger().info("AutoRefill has been Enabled!"); getServer().getPluginManager().registerEvents(new PlaceBlock(this), this); getCommand("refill").setExecutor(new Commands(this)); log.info("[AutoRefi...
c9808518-b1e8-413d-9c0a-4a4334ac1cc4
public void load(){ this.saveDefaultConfig(); this.enabled = this.getConfig().getBoolean("general.auto-enabled"); List<String> loadBlocks = AutoRefill.this.getConfig().getStringList("blocks"); for(String s: loadBlocks) { if(Material.getMaterial(s) != null){ configBlocks.add(Material.getMaterial(...
8ce12b72-69b1-43d0-bad4-79af1210a4fb
public void onDisable() { getLogger().info("AutoRefill has been Disabled."); }
459123e9-22d1-40fa-b141-97c52ec74b09
public Metrics(final Plugin plugin) throws IOException { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } this.plugin = plugin; // load the config configurationFile = getConfigFile(); configuration = YamlConfiguration.load...
f23625b8-2e3b-41ee-bc7d-ab667509624e
public Graph createGraph(final String name) { if (name == null) { throw new IllegalArgumentException("Graph name cannot be null"); } // Construct the graph object final Graph graph = new Graph(name); // Now we can add our graph graphs.add(graph); //...
91649c7c-d352-4612-8f5a-8b5353a01c69
public void addGraph(final Graph graph) { if (graph == null) { throw new IllegalArgumentException("Graph cannot be null"); } graphs.add(graph); }
d1391baa-c4ae-4954-88ff-4bc3ed501455
public boolean start() { synchronized (optOutLock) { // Did we opt out? if (isOptOut()) { return false; } // Is metrics already running? if (task != null) { return true; } // Begin hitting the s...
d61c9d44-7796-41f7-9ee7-e1553bb0f7d4
public void run() { try { // This has to be synchronized or it can collide with the disable method. synchronized (optOutLock) { // Disable Task, if it is running and the server owner decided to opt-out ...
42f4cb79-d5b2-4277-a011-db574fbc3e0f
public boolean isOptOut() { synchronized (optOutLock) { try { // Reload the metrics file configuration.load(getConfigFile()); } catch (IOException ex) { if (debug) { Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.g...
d8b46869-714a-470f-ac4e-f4afbeb266e4
public void enable() throws IOException { // This has to be synchronized or it can collide with the check in the task. synchronized (optOutLock) { // Check if the server owner has already set opt-out, if not, set it. if (isOptOut()) { configuration.set("opt-out", ...
5aa3aa1e-51f1-453b-9305-6ca30689a9ab
public void disable() throws IOException { // This has to be synchronized or it can collide with the check in the task. synchronized (optOutLock) { // Check if the server owner has already set opt-out, if not, set it. if (!isOptOut()) { configuration.set("opt-out"...
5bff634e-97a0-4b34-a9d2-d31aeabfc154
public File getConfigFile() { // I believe the easiest way to get the base folder (e.g craftbukkit set via -P) for plugins to use // is to abuse the plugin object we already have // plugin.getDataFolder() => base/plugins/PluginA/ // pluginsFolder => base/plugins/ // The base is n...
44eafea3-3ba0-4d43-8418-ede7802cf50a
private void postPlugin(final boolean isPing) throws IOException { // Server software specific section PluginDescriptionFile description = plugin.getDescription(); String pluginName = description.getName(); boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode i...
6b864ee1-81a0-4358-b6a0-8424aef2114b
public static byte[] gzip(String input) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); GZIPOutputStream gzos = null; try { gzos = new GZIPOutputStream(baos); gzos.write(input.getBytes("UTF-8")); } catch (IOException e) { e.printStackTrace...
71f4db05-e2d3-48a7-95da-3f48a5c1edfe
private boolean isMineshafterPresent() { try { Class.forName("mineshafter.MineServer"); return true; } catch (Exception e) { return false; } }
a9d1eb0f-46da-48b7-a20f-b44c7e09614a
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException { boolean isValueNumeric = false; try { if (value.equals("0") || !value.endsWith("0")) { Double.parseDouble(value); isValueNumeric = true; ...
d46fc915-77d3-4bc5-9dae-e70170cd47c9
private static String escapeJSON(String text) { StringBuilder builder = new StringBuilder(); builder.append('"'); for (int index = 0; index < text.length(); index++) { char chr = text.charAt(index); switch (chr) { case '"': case '\\': ...
8c120905-0a18-49e7-b3d7-357f29d053db
private static String urlEncode(final String text) throws UnsupportedEncodingException { return URLEncoder.encode(text, "UTF-8"); }
d2c506e0-418b-4b42-91b8-76fe84a1e9a5
private Graph(final String name) { this.name = name; }
15bd289c-8a73-4212-8f3b-37ae6b98c839
public String getName() { return name; }
ca8fd66e-ff61-4f2c-99be-d04d767d3224
public void addPlotter(final Plotter plotter) { plotters.add(plotter); }
17b98d3c-596b-4cba-bab0-de0fb518a2c1
public void removePlotter(final Plotter plotter) { plotters.remove(plotter); }
b5048161-f25e-44a1-9121-16e7aab1a4e3
public Set<Plotter> getPlotters() { return Collections.unmodifiableSet(plotters); }
063a9b75-437d-4dbd-83ce-2c69659fb7fb
@Override public int hashCode() { return name.hashCode(); }
a3e177e1-fe63-43a6-8872-a9cbd1d34894
@Override public boolean equals(final Object object) { if (!(object instanceof Graph)) { return false; } final Graph graph = (Graph) object; return graph.name.equals(name); }
cefc64ce-3741-43b7-b32a-8f48422773e9
protected void onOptOut() { }
549fdb47-3e64-4fa5-b56c-91cf47e4fa8f
public Plotter() { this("Default"); }
bbf08a7e-e3a8-4187-b071-f37045234329
public Plotter(final String name) { this.name = name; }
7742b185-37e9-4358-a359-0dfff49569e0
public abstract int getValue();
5f0944a7-a94a-45fd-8415-e81e1ebec683
public String getColumnName() { return name; }
cb924d95-a889-41fd-9a40-7d1feb3a2028
public void reset() { }
41393b60-7b84-4915-b1b2-858f06a3ef59
@Override public int hashCode() { return getColumnName().hashCode(); }
48efe06a-d791-4a68-94b9-260c6226996f
@Override public boolean equals(final Object object) { if (!(object instanceof Plotter)) { return false; } final Plotter plotter = (Plotter) object; return plotter.name.equals(name) && plotter.getValue() == getValue(); }
5e8e7779-ee0c-4377-9b57-84004d1232e1
public void activate() { try { buffer = MethodeUtileEnv.importerImage(getMadkitProperty("plan")); // picture's import } catch (IOException e) {e.printStackTrace();buffer = null;} System.out.println(getMadkitProperty("plan")); MethodeUtileEnv.adapterImage(buffer,couleurSalle,couleurMur,couleurLimite); s...
56a3c7ac-e386-402f-8548-c54db3471b1a
public boolean wallTop(int i, int j , int h) { if(j>h) return false; else if(getPatch(i,j).getColor().getRed() == 255) return true; return wallTop(i,j+1,h); }
917bfefc-a949-48b0-8061-4276ab65ac4b
public boolean wallRight(int i, int j , int w) { if(i>w) return false; else if(getPatch(i,j).getColor().getRed() == 255) return true; return wallTop(i+1,j,w); }
b194b70a-b43c-489c-a117-d84f31abbcbf
public boolean wallBot(int i, int j) { if(j<0) return false; else if(getPatch(i,j).getColor().getRed() == 255) return true; return wallBot(i,j-1); }
7e3c8f48-6090-4879-a9db-63a79277c257
public boolean wallLeft(int i, int j) { if(i<0) return false; else if( getPatch(i,j).getColor().getRed() == 255) return true; return wallBot(i-1,j); }
0c56791c-8e77-45a0-a0f4-61c0d3cbecad
public boolean betweenWalls(BufferedImage buffer, int i, int j){ return (wallTop(i,j,buffer.getWidth()) && wallBot(i,j) ) || wallLeft(i,j) && wallRight(i,j,buffer.getHeight() ); }
10229693-7cdf-498b-a28b-58a67cfdde20
public static int getEnvWidth(){ return buffer.getWidth()+arroundSize; }
349e112c-3b30-4430-9282-608886926933
public static int getEnvheight(){ return buffer.getHeight()+arroundSize; }
4b9857ee-35f3-48ce-825d-5d33f3cc1d48
public static BufferedImage importerImage(String fichier) throws IOException { try{ return ImageIO.read(MethodeUtileEnv.class.getResource("/Images/"+fichier)); } catch (IOException e) { e.printStackTrace(); return null; } }
ef6dead9-1203-4804-a95d-05d2dcc7a1d3
public static void adapterImage(BufferedImage buffer , int c1 , int c2, int limit) { for (int i = 0; i < buffer.getWidth(); i++) { for (int j = 0; j < buffer.getHeight(); j++) { Color pixelColor = new Color(buffer.getRGB(i,j)); //color creation from pixel'RGB components int r=pixelColor.getRed(); in...
11d28f98-71e6-4d15-93fd-e6855a544090
public Fenetre(){ // initialisation de la fenetre this.setTitle("Evacuation Incendie"); this.setSize(500, 300); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLocationRelativeTo(null); container.setBackground(Color.white); container.setLayout(new BorderLayout()); combo.setPreferredSize...
22102870-c4a2-467b-ae12-bf91529390a6
@SuppressWarnings("unchecked") public void initPlan() { String[] tab = {"plan.png", "plan2.jpg", "Option 3", "Option 4"}; combo = new JComboBox(tab); combo.setPreferredSize(new Dimension(100, 20)); combo.setForeground(Color.blue); top = new JPanel(); top.add(label); top.add(combo); }
f57f77d4-92b4-4ce8-9425-cd5379aab7e2
public void initFeu(){ // le nombre de feu PanbFeu = new JPanel(); PanbFeu.setBackground(Color.white); PanbFeu.setPreferredSize(new Dimension(220, 60)); nbFeu = new JTextField(); nbFeu.setPreferredSize(new Dimension(100, 25)); PanbFeu.add(label3); PanbFeu.add(nbFeu); }
8e21cc91-230d-4540-9ca0-c2a1d56cb64e
public void initAgent() { //Le nombre d'agent Panbagent = new JPanel(); Panbagent.setBackground(Color.white); Panbagent.setPreferredSize(new Dimension(220, 60)); nbAgent = new JTextField(); nbAgent.setPreferredSize(new Dimension(100, 25)); Panbagent.add(label2); Panbagent.add(nbAgent); }
ba64037d-59e6-4d7d-9d5d-ec6c5714f7a8
public String Getplan(){ return combo.getSelectedItem().toString(); }
f07db229-92ce-4ccb-a87f-fb8caee71ae1
public String GetNbAgent(){ return ","+nbAgent.getText(); }
2ba8babd-accf-4949-a2bf-f128a40b8f87
public String GetNbFeu(){ return ","+nbFeu.getText(); }
685eb080-83f1-4878-8204-4495cd2294c2
@Override public void mouseClicked(MouseEvent arg0) { }
8a8c8cfc-372e-4fc9-bb30-f3e61c25b87f
@Override public void actionPerformed(ActionEvent e) {; new TurtleKit( Option.turtles.toString(),Agent.class.getName()+GetNbAgent() + ";"+Feu.class.getName()+GetNbFeu() ,Option.viewers.toString(),MyViewer.class.getName() // ,Option.startSimu.toString() ,"--plan",Getplan() ,"--pheroName","feu" ...
cb11de1a-59eb-4a58-bf96-45f7dc3e90c9
@Override public void mouseEntered(MouseEvent arg0) {}
03fa555e-479f-414f-9d13-e74404ea4f3b
@Override public void mouseExited(MouseEvent arg0) {}
f786ad1b-d0e7-4e5d-ac31-8178791ee276
@Override public void mousePressed(MouseEvent arg0) {}
e222b000-036a-4905-8fde-20b72fc45e66
@Override public void mouseReleased(MouseEvent arg0) {}
6ff28d57-0142-4a8c-b6bc-e954ad14c009
public static void main(String[] args) { new Fenetre(); }
fdca4de9-bcc5-4584-b215-f734bfd53af1
public void paintPatch(final Graphics g, final Patch p, final int x, final int y, final int index) { super.paintPatch(g, p, x, y, index); if(p.getColor().getRed()== 255) { g.setColor(Color.WHITE); g.fillRect(x, y, cellSize, cellSize); } if(p.getColor() == Color.GREEN) { g.setColor(Color.GREEN); g.fi...
332af495-0e66-4be6-b620-c70af38f33d2
public void paintTurtle(final Graphics g, final Turtle t, final int i, final int j) { g.setColor(t.getColor()); g.fillRect(i , j ,PlanEvacuation.getEnvWidth()/60,PlanEvacuation.getEnvheight()/60 ); //g.drawImage(car,i,j, 4, 4, null); }
8de17d60-cb72-46b0-ae17-29bf042f0667
public static void main( String[] args ) { JFrame f = new JFrame( "Hello3" ); // Exit application when the window is closed f.addWindowListener( new WindowAdapter() { public void windowClosing( WindowEvent e ) { System.exit(0); } } ); f.setSize( FRAME_WIDTH, FRAME_HEIGHT ); f.getContentPane()...
5074af3d-80ed-40f3-8d4a-43798caf044d
public void windowClosing( WindowEvent e ) { System.exit(0); }
d381a752-f902-41c5-9ee1-63c1a521c09e
public void paintComponent( Graphics g ) { int xC = FRAME_WIDTH/2; int yC = FRAME_HEIGHT/2; g.drawString( "Hello, Java!", xC, yC ); g.drawLine( 0, 0, FRAME_WIDTH, FRAME_HEIGHT ); g.drawLine( 0, FRAME_HEIGHT, FRAME_WIDTH, 0 ); }
a0efaa54-3bb1-489d-b17b-329c73ffc372
public static void main( String[] args ) { JFrame f = new JFrame( "Hello1" ); f.setSize( 200, 200 ); f.getContentPane().add( new Hello1() ); f.setVisible( true ); }
71e3c674-04a5-428a-a3bb-7de1c14b0029
public void paintComponent( Graphics g ) { g.drawString( "Hello, Java!", 100, 100 ); }
fdf312c9-c380-41a0-9194-13cf414b182e
public static void main( String[] args ) { JFrame f = new JFrame( "Hello4" ); // Exit application when the window is closed f.addWindowListener( new WindowAdapter() { public void windowClosing( WindowEvent e ) { System.exit(0); } } ); f.setSize( frameWidth, frameHeight ); f.getContentPane().a...
efc6ef96-8735-482f-8737-5db709f9a466
public void windowClosing( WindowEvent e ) { System.exit(0); }
664987b4-9118-46a9-b5c3-5bea56e8a160
public void paintComponent( Graphics g ) { frameWidth = getWidth(); frameHeight = getHeight(); int xC = frameWidth/2; int yC = frameHeight/2; g.drawString( "Hello, Java!", xC, yC ); drawLines( g ); }
896eb9ad-844d-4c63-8dd6-1e09c9a44064
public void drawLines( Graphics g ) { g.setColor( lineColors[iColor] ); g.drawLine( 0, 0, frameWidth, frameHeight ); g.drawLine( 0, frameHeight, frameWidth, 0 ); if( ++iColor == lineColors.length ) iColor = 0; }
c247c81d-ba6c-444b-b0b1-97a8b6fb1271
public static void main( String[] args ) { JFrame f = new JFrame( "Hello2" ); // Exit application when the window is closed f.addWindowListener( new WindowAdapter() { public void windowClosing( WindowEvent e ) { System.exit(0); } } ); f.setSize( FRAME_WIDTH, FRAME_HEIGHT ); f.getContentPane()...
ef6c6c98-4d87-4d26-830f-3b37ad9f49c8
public void windowClosing( WindowEvent e ) { System.exit(0); }
5be00bdf-dc5c-408f-9f7f-5be5be5e4218
public void paintComponent( Graphics g ) { g.drawString( "Hello, Java!", 100, 100 ); }
f51a8c6c-df14-4e5f-9e81-99ec4cee034d
public static void main( String[] args) { InitGraphics(); }
267e89bc-1768-48b5-8c22-288e724bfce3
public void paintComponent( Graphics g) { // Create window one Window w1 = MyGraphicsAPI.SetWindow(-9,-15,9,15,-1,0,0,1); // Graph the line y = 2 / (0.5 - sin( x/2 )) Point p = MyGraphicsAPI.WindowToViewport( w1,-9 ,0 ); p = MyGraphicsAPI.ViewPortToFrameWindow(w1, p); MoveTo2D(p); double i; for( i = -9.0...
b6732708-630b-4a1f-891b-11d4dc9a4616
public static void PrintName(Point p, Graphics g) { Math.round(p.x); Math.round(p.y); int x = (int) p.x; int y = (int) p.y; g.drawString("Ian Westrope CS 384", x, y); }
8848d917-f7db-46d5-838e-78225985acd3
public static void MoveTo2D(Point p) { x = p.x; y = p.y; }
6286783d-f02b-4070-98bd-928c837c4524
public static void DrawTo2D(Point p, Graphics g) { Math.round(x); Math.round(y); Math.round(p.x); Math.round(p.y); int x1 = (int) x; int y1 = (int) y; int x2 = (int) p.x; int y2 = (int) p.y; g.drawLine(x1, y1, x2, y2); MoveTo2D(p); }
da344578-990f-442f-a7fc-4a784d8389d4
public static void InitGraphics() { JFrame f = new JFrame( "HW #2" ); // Exit application when the window is closed f.addWindowListener( new WindowAdapter() { public void windowClosing( WindowEvent e ) { System.exit(0); } } ); f.setSize( framewidth, fra...
2c389c03-7c10-4502-893b-bc340a962e18
public void windowClosing( WindowEvent e ) { System.exit(0); }
c781c921-b470-4a57-b646-1c81b04672cc
public static void InitGraphics() { JFrame f = new JFrame( "HW #2" ); // Exit application when the window is closed f.addWindowListener( new WindowAdapter() { public void windowClosing( WindowEvent e ) { System.exit(0); } } ); f.setSize( framewidth, fra...
601b73ad-f24a-43d8-8852-df4b31ec1a61
public void windowClosing( WindowEvent e ) { System.exit(0); }
1550b8ff-35bd-4f14-83d7-c46610db8262
public static void SetViewport( double width1, double height1, double width2, double height2 ) { viewportminx = width1; viewportminy = height1; viewportmaxx = width2; viewportmaxy = height2; }
7354cff0-0634-4923-af26-63a61053c4ad
public static Window SetWindow( double width1, double height1, double width2, double height2, double vpminx, double vpminy, double vpmaxx, double vpmaxy) { Window w = new Window(); w.vpminx = vpminx; w.vpminy = vpminy; w.vpmaxx = vpmaxx; w.vpmaxy = vpmaxy; w.windowminy = height1; w.windowminx = width1; w.wi...
287331b4-cf5d-4eb8-904c-41ad88d5ac6c
public static Point ViewPortToFrameWindow(Window w, Point p) { // bound checking if ( p.x > w.vpmaxx ) p.x = w.vpmaxx; if ( p.x < w.vpminx ) p.x = w.vpminx; if ( p.y > w.vpmaxy ) p.y = w.vpmaxy; if ( p.y < w.vpminy ) p.y = w.vpminy; Point p2 = new Point(); p2.x = framewidth * (( p.x - viewportminx ) / ( vie...
dc9f1733-3bb9-4f50-89c3-0e05277113cc
public static Point WindowToViewport(Window w, double xwin, double ywin) { // bound checking if ( xwin > w.windowmaxx ) xwin = w.windowmaxx; if ( xwin < w.windowminx ) xwin = w.windowminx; if ( ywin > w.windowmaxy ) ywin = w.windowmaxy; if ( ywin < w.windowminy ) ywin = w.windowminy; Point p = new Point(); ...
39704518-2b27-415e-a121-5ab796483df2
public MessageParser() {}
601249d4-3888-4d9c-bc24-3ec8c9d6559a
public int getMessageSender(final String message) { return Integer.parseInt(message.substring(0, indexOfBreak(1, message)-1)); }
61e48972-8329-41b6-a64c-232d48665de3
public String getMessageType(final String message) { return message.substring(indexOfBreak(1, message), indexOfBreak(2, message)-1); }
efc896d4-c33e-4dfa-9d15-71b9e0fc6094
public String getMessageContent(final String message) { return message.substring(indexOfBreak(2, message), indexOfBreak(3, message)-1); }
0c5e8409-928a-4130-a269-e8fc38c32605
public int getMessageLoad(final String message) { return Integer.parseInt(message.substring(indexOfBreak(3, message), indexOfBreak(4, message)-1)); }
80577da8-df77-4b38-a227-eff080824f55
public String getMessageClientIp(final String message) { if (!isClientRequest(message)) return message.substring(indexOfBreak(4, message), indexOfBreak(5, message)); else return message.substring(0, indexOfBreak(1, message)-1); }
74c8d096-d54f-404f-a851-e0eb5a057866
private boolean isClientRequest(final String message) { return getMessageType(message).equals(Messages.clientConnectionRequest) || getMessageType(message).equals(Messages.clientRequestLock) || getMessageType(message).equals(Messages.clientReleaseLock); }