How to use main method of common.Main class

Best Karate code snippet using common.Main.main

Source:RemotingSubsystemTransformersTestCase.java Github

copy

Full Screen

...89 // Add legacy subsystems90 ModelVersion version_1_1 = ModelVersion.create(1, 1);91 builder.createLegacyKernelServicesBuilder(null, controllerVersion, version_1_1)92 .addMavenResourceURL("org.jboss.as:jboss-as-remoting:" + controllerVersion.getMavenGavVersion());93 KernelServices mainServices = builder.build();94 assertTrue(mainServices.isSuccessfulBoot());95 KernelServices legacyServices = mainServices.getLegacyServices(version_1_1);96 assertNotNull(legacyServices);97 assertTrue(legacyServices.isSuccessfulBoot());98 PathAddress subsystemAddress = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME));99 ModelTestUtils.checkFailedTransformedBootOperations(mainServices, version_1_1, parse(subsystemXml),100 new FailedOperationTransformationConfig()101 .addFailedAttribute(subsystemAddress.append(RemotingEndpointResource.ENDPOINT_PATH), FailedOperationTransformationConfig.DISCARDED_RESOURCE)102 .addFailedAttribute(subsystemAddress,103 new FailedOperationTransformationConfig.RejectExpressionsConfig(104 RemotingSubsystemRootResource.WORKER_READ_THREADS,105 RemotingSubsystemRootResource.WORKER_TASK_CORE_THREADS,106 RemotingSubsystemRootResource.WORKER_TASK_KEEPALIVE,107 RemotingSubsystemRootResource.WORKER_TASK_LIMIT,108 RemotingSubsystemRootResource.WORKER_TASK_MAX_THREADS,109 RemotingSubsystemRootResource.WORKER_WRITE_THREADS))110 .addFailedAttribute(subsystemAddress.append(PathElement.pathElement(CommonAttributes.CONNECTOR)).append(PathElement.pathElement(CommonAttributes.PROPERTY)),111 new FailedOperationTransformationConfig.RejectExpressionsConfig(VALUE))112 .addFailedAttribute(subsystemAddress.append(PathElement.pathElement(CommonAttributes.CONNECTOR)).append(PathElement.pathElement(CommonAttributes.SECURITY, CommonAttributes.SASL)),113 new FailedOperationTransformationConfig.RejectExpressionsConfig(CommonAttributes.SERVER_AUTH, CommonAttributes.REUSE_SESSION))114 .addFailedAttribute(subsystemAddress.append(PathElement.pathElement(CommonAttributes.CONNECTOR))115 .append(PathElement.pathElement(CommonAttributes.SECURITY, CommonAttributes.SASL)).append(PathElement.pathElement(CommonAttributes.SASL_POLICY)),116 new FailedOperationTransformationConfig.RejectExpressionsConfig(117 CommonAttributes.FORWARD_SECRECY,118 CommonAttributes.NO_ACTIVE,119 CommonAttributes.NO_ANONYMOUS,120 CommonAttributes.NO_DICTIONARY,121 CommonAttributes.NO_PLAIN_TEXT,122 CommonAttributes.PASS_CREDENTIALS))123 .addFailedAttribute(subsystemAddress.append(PathElement.pathElement(CommonAttributes.CONNECTOR))124 .append(PathElement.pathElement(CommonAttributes.PROPERTY)),125 new FailedOperationTransformationConfig.RejectExpressionsConfig(126 CommonAttributes.VALUE))127 .addFailedAttribute(subsystemAddress.append(128 PathElement.pathElement(CommonAttributes.CONNECTOR))129 .append(PathElement.pathElement(CommonAttributes.SECURITY, CommonAttributes.SASL))130 .append(CommonAttributes.PROPERTY),131 new FailedOperationTransformationConfig.RejectExpressionsConfig(132 CommonAttributes.VALUE))133 .addFailedAttribute(subsystemAddress.append(134 PathElement.pathElement(CommonAttributes.OUTBOUND_CONNECTION))135 .append(CommonAttributes.PROPERTY),136 new FailedOperationTransformationConfig.RejectExpressionsConfig(137 CommonAttributes.VALUE))138 .addFailedAttribute(subsystemAddress.append(PathElement.pathElement(CommonAttributes.REMOTE_OUTBOUND_CONNECTION)),139 new FailedOperationTransformationConfig.ChainedConfig(140 toList(new FailedOperationTransformationConfig.RejectExpressionsConfig(CommonAttributes.USERNAME), new FixProtocolConfig(CommonAttributes.PROTOCOL)),141 CommonAttributes.USERNAME, CommonAttributes.PROTOCOL))142 .addFailedAttribute(subsystemAddress.append(143 PathElement.pathElement(CommonAttributes.REMOTE_OUTBOUND_CONNECTION))144 .append(PathElement.pathElement(CommonAttributes.PROPERTY)),145 new FailedOperationTransformationConfig.RejectExpressionsConfig(CommonAttributes.VALUE))146 .addFailedAttribute(subsystemAddress.append(147 PathElement.pathElement(CommonAttributes.LOCAL_OUTBOUND_CONNECTION))148 .append(PathElement.pathElement(CommonAttributes.PROPERTY)),149 new FailedOperationTransformationConfig.RejectExpressionsConfig(CommonAttributes.VALUE)));150 }151 @Test152 public void testNonRemotingProtocolRejectedAS720() throws Exception {153 testNonRemotingProtocolRejectedByVersion1_2(ModelTestControllerVersion.V7_2_0_FINAL);154 }155 @Test156 public void testNonRemotingProtocolRejectedEAP610() throws Exception {157 testNonRemotingProtocolRejectedByVersion1_2(ModelTestControllerVersion.EAP_6_1_0);158 }159 @Test160 public void testNonRemotingProtocolRejectedEAP611() throws Exception {161 testNonRemotingProtocolRejectedByVersion1_2(ModelTestControllerVersion.EAP_6_1_1);162 }163 private void testNonRemotingProtocolRejectedByVersion1_2(ModelTestControllerVersion controllerVersion) throws Exception {164 String subsystemXml = readResource("remoting-with-expressions.xml");165 KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.ADMIN_ONLY_HC);166 // Add legacy subsystems167 ModelVersion version_1_1 = ModelVersion.create(1, 2);168 builder.createLegacyKernelServicesBuilder(AdditionalInitialization.ADMIN_ONLY_HC, controllerVersion, version_1_1)169 .addMavenResourceURL("org.jboss.as:jboss-as-remoting:" + controllerVersion.getMavenGavVersion());170 KernelServices mainServices = builder.build();171 assertTrue(mainServices.isSuccessfulBoot());172 KernelServices legacyServices = mainServices.getLegacyServices(version_1_1);173 assertNotNull(legacyServices);174 assertTrue(legacyServices.isSuccessfulBoot());175 PathAddress rootAddr = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME));176 ModelTestUtils.checkFailedTransformedBootOperations(mainServices, version_1_1, parse(subsystemXml),177 new FailedOperationTransformationConfig()178 .addFailedAttribute(rootAddr.append(RemotingEndpointResource.ENDPOINT_PATH), FailedOperationTransformationConfig.DISCARDED_RESOURCE)179 .addFailedAttribute(rootAddr.append(PathElement.pathElement(CommonAttributes.REMOTE_OUTBOUND_CONNECTION)),180 new FixProtocolConfig(CommonAttributes.PROTOCOL)));181 }182 @Test183 public void testTransformersAS712() throws Exception {184 testTransformers_1_1(ModelTestControllerVersion.V7_1_2_FINAL);185 }186 @Test187 public void testTransformersAS713() throws Exception {188 testTransformers_1_1(ModelTestControllerVersion.V7_1_3_FINAL);189 }190 @Test191 public void testTransformersEAP600() throws Exception {192 testTransformers_1_1(ModelTestControllerVersion.EAP_6_0_0);193 }194 @Test195 public void testTransformersEAP601() throws Exception {196 testTransformers_1_1(ModelTestControllerVersion.EAP_6_0_1);197 }198 private void testTransformers_1_1(ModelTestControllerVersion controllerVersion) throws Exception {199 KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.ADMIN_ONLY_HC)200 .setSubsystemXmlResource("remoting-without-expressions.xml");201 ModelVersion oldVersion = ModelVersion.create(1, 1);202 // Add legacy subsystems203 builder.createLegacyKernelServicesBuilder(AdditionalInitialization.ADMIN_ONLY_HC, controllerVersion, oldVersion)204 .addMavenResourceURL("org.jboss.as:jboss-as-remoting:" + controllerVersion.getMavenGavVersion())205 .skipReverseControllerCheck();206 //.configureReverseControllerCheck(createAdditionalInitialization(), null);207 KernelServices mainServices = builder.build();208 assertTrue(mainServices.isSuccessfulBoot());209 KernelServices legacyServices = mainServices.getLegacyServices(oldVersion);210 assertNotNull(legacyServices);211 assertTrue(legacyServices.isSuccessfulBoot());212 checkSubsystemModelTransformation(mainServices, oldVersion, getAS7_6077Fixer(), false);213 checkRejectWorkerThreadAttributes(mainServices, oldVersion);214 checkRejectSASLAttribute(mainServices, oldVersion, CommonAttributes.REUSE_SESSION, "${reuse.session:true}");215 checkRejectSASLAttribute(mainServices, oldVersion, CommonAttributes.SERVER_AUTH, "${server.auth:true}");216 checkRejectSASLProperty(mainServices, oldVersion);217 checkRejectSASLPolicyAttributes(mainServices, oldVersion);218 checkRejectConnectorProperty(mainServices, oldVersion);219 checkRejectRemoteOutboundConnectionUsername(mainServices, oldVersion);220 checkRejectOutboundConnectionProperty(mainServices, oldVersion, CommonAttributes.REMOTE_OUTBOUND_CONNECTION, "remote-conn1");221 checkRejectOutboundConnectionProperty(mainServices, oldVersion, CommonAttributes.LOCAL_OUTBOUND_CONNECTION, "local-conn1");222 checkRejectOutboundConnectionProperty(mainServices, oldVersion, CommonAttributes.OUTBOUND_CONNECTION, "generic-conn1");223 checkRejectOutboundConnectionProtocolNotRemote(mainServices, oldVersion, CommonAttributes.REMOTE_OUTBOUND_CONNECTION, "remote-conn1");224 checkRejectHttpConnector(mainServices, oldVersion);225 checkRejectEndpointConfiguration(mainServices, oldVersion);226 }227 private ModelFixer getAS7_6077Fixer() {228 return new ModelFixer() {229 @Override230 public ModelNode fixModel(ModelNode modelNode) {231 for (AttributeDefinition ad : RemotingSubsystemRootResource.ATTRIBUTES) {232 if (modelNode.hasDefined(ad.getName())) {233 if (modelNode.get(ad.getName()).equals(ad.getDefaultValue())) {234 modelNode.get(ad.getName()).set(new ModelNode());235 }236 }237 }238 return modelNode;239 }240 };241 }242 @Test243 public void testTransformersAS720() throws Exception {244 testTransformers_1_2_0(ModelTestControllerVersion.V7_2_0_FINAL);245 }246 @Test247 public void testTransformersEAP610() throws Exception {248 testTransformers_1_2_0(ModelTestControllerVersion.EAP_6_1_0);249 }250 @Test251 public void testTransformersEAP611() throws Exception {252 testTransformers_1_2_0(ModelTestControllerVersion.EAP_6_1_1);253 }254 private void testTransformers_1_2_0(ModelTestControllerVersion controllerVersion) throws Exception {255 KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)256 .setSubsystemXmlResource("remoting-with-expressions-and-good-legacy-protocol.xml");257 ModelVersion oldVersion = ModelVersion.create(1, 2, 0);258 // Add legacy subsystems259 builder.createLegacyKernelServicesBuilder(null, controllerVersion, oldVersion)260 .addMavenResourceURL("org.jboss.as:jboss-as-remoting:" + controllerVersion.getMavenGavVersion())261 .skipReverseControllerCheck();262 //.configureReverseControllerCheck(createAdditionalInitialization(), null);263 KernelServices mainServices = builder.build();264 assertTrue(mainServices.isSuccessfulBoot());265 KernelServices legacyServices = mainServices.getLegacyServices(oldVersion);266 assertNotNull(legacyServices);267 assertTrue(legacyServices.isSuccessfulBoot());268 checkSubsystemModelTransformation(mainServices, oldVersion, null, false);269 checkRejectOutboundConnectionProtocolNotRemote(mainServices, oldVersion, CommonAttributes.REMOTE_OUTBOUND_CONNECTION, "remote-conn1");270 checkRejectHttpConnector(mainServices, oldVersion);271 checkRejectEndpointConfiguration(mainServices, oldVersion);272 }273 private void checkRejectOutboundConnectionProperty(KernelServices mainServices, ModelVersion version, String type, String name) throws OperationFailedException {274 ModelNode operation = new ModelNode();275 operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);276 ModelNode address = new ModelNode();277 address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);278 address.add(type, name);279 address.add(CommonAttributes.PROPERTY, "org.xnio.Options.SSL_ENABLED");280 operation.get(OP_ADDR).set(address);281 operation.get(NAME).set(CommonAttributes.VALUE);282 operation.get(VALUE).set("${myprop:true}");283 checkReject(operation, mainServices, version);284 }285 private void checkRejectOutboundConnectionProtocolNotRemote(KernelServices mainServices, ModelVersion version, String type, String name) throws OperationFailedException {286 ModelNode operation = new ModelNode();287 operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);288 ModelNode address = new ModelNode();289 address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);290 address.add(type, name);291 operation.get(OP_ADDR).set(address);292 operation.get(NAME).set(CommonAttributes.PROTOCOL);293 operation.get(VALUE).set(Protocol.HTTP_REMOTING.toString());294 checkReject(operation, mainServices, version);295 PathAddress addr = PathAddress.pathAddress(operation.get(OP_ADDR));296 PathElement element = addr.getLastElement();297 addr = addr.subAddress(0, addr.size() - 1);298 addr = addr.append(PathElement.pathElement(element.getKey(), "remoting-outbound2"));299 operation = Util.createAddOperation(addr);300 operation.get(CommonAttributes.OUTBOUND_SOCKET_BINDING_REF).set("dummy-outbound-socket");301 operation.get(CommonAttributes.USERNAME).set("myuser");302 operation.get(CommonAttributes.PROTOCOL).set(Protocol.HTTP_REMOTING.toString());303 checkReject(operation, mainServices, version);304 }305 private void checkRejectSASLAttribute(KernelServices mainServices, ModelVersion version, String name, String value) throws OperationFailedException {306 ModelNode operation = new ModelNode();307 operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);308 ModelNode address = new ModelNode();309 address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);310 address.add(CommonAttributes.CONNECTOR, "remoting-connector");311 address.add(CommonAttributes.SECURITY, CommonAttributes.SASL);312 operation.get(OP_ADDR).set(address);313 operation.get(NAME).set(name);314 operation.get(VALUE).set(value);315 checkReject(operation, mainServices, version);316 }317 private void checkRejectSASLProperty(KernelServices mainServices, ModelVersion version) throws OperationFailedException {318 ModelNode operation = new ModelNode();319 operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);320 ModelNode address = new ModelNode();321 address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);322 address.add(CommonAttributes.CONNECTOR, "remoting-connector");323 address.add(CommonAttributes.SECURITY, CommonAttributes.SASL);324 address.add(CommonAttributes.PROPERTY, "sasl1");325 operation.get(OP_ADDR).set(address);326 operation.get(NAME).set(CommonAttributes.VALUE);327 operation.get(VALUE).set("${sasl.prop:sasl one}");328 checkReject(operation, mainServices, version);329 }330 private void checkRejectSASLPolicyAttributes(KernelServices mainServices, ModelVersion version) throws OperationFailedException {331 for (AttributeDefinition attr: new AttributeDefinition[] {NO_ACTIVE, NO_ANONYMOUS, NO_DICTIONARY, FORWARD_SECRECY,332 NO_PLAIN_TEXT, PASS_CREDENTIALS}) {333 checkRejectSASLPolicyAttribute(mainServices, version, attr);334 }335 }336 private void checkRejectSASLPolicyAttribute(KernelServices mainServices, ModelVersion version, AttributeDefinition attr) throws OperationFailedException {337 ModelNode operation = new ModelNode();338 operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);339 ModelNode address = new ModelNode();340 address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);341 address.add(CommonAttributes.CONNECTOR, "remoting-connector");342 address.add(CommonAttributes.SECURITY, CommonAttributes.SASL);343 address.add(CommonAttributes.SASL_POLICY, CommonAttributes.POLICY);344 operation.get(OP_ADDR).set(address);345 operation.get(NAME).set(attr.getName());346 operation.get(VALUE).set("${mypolicy:false}");347 checkReject(operation, mainServices, version);348 }349 private void checkRejectConnectorProperty(KernelServices mainServices, ModelVersion version) throws OperationFailedException {350 ModelNode operation = new ModelNode();351 operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);352 ModelNode address = new ModelNode();353 address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);354 address.add(CommonAttributes.CONNECTOR, "remoting-connector");355 address.add(CommonAttributes.PROPERTY, "c1");356 operation.get(OP_ADDR).set(address);357 operation.get(NAME).set(CommonAttributes.VALUE);358 operation.get(VALUE).set("${connector.prop:connector one}");359 checkReject(operation, mainServices, version);360 }361 private void checkRejectRemoteOutboundConnectionUsername(KernelServices mainServices, ModelVersion version) throws OperationFailedException {362 ModelNode operation = new ModelNode();363 operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);364 ModelNode address = new ModelNode();365 address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);366 address.add(CommonAttributes.REMOTE_OUTBOUND_CONNECTION, "remote-conn1");367 operation.get(OP_ADDR).set(address);368 operation.get(NAME).set(CommonAttributes.USERNAME);369 operation.get(VALUE).set("${remoting.user:myuser}");370 checkReject(operation, mainServices, version);371 }372 private void checkRejectWorkerThreadAttributes(KernelServices mainServices, ModelVersion version) throws OperationFailedException {373 ModelNode operation = new ModelNode();374 operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);375 ModelNode address = new ModelNode();376 address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);377 operation.get(OP_ADDR).set(address);378 operation.get(NAME).set("worker-read-threads");379 operation.get(VALUE).set("${worker.read.threads:5}");380 checkReject(operation, mainServices, version);381 }382 private void checkRejectHttpConnector(KernelServices mainServices, ModelVersion version) throws OperationFailedException {383 ModelNode operation = new ModelNode();384 operation.get(OP).set(ADD);385 operation.get(CommonAttributes.CONNECTOR_REF).set("test");386 ModelNode address = new ModelNode();387 address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);388 address.add(HttpConnectorResource.PATH.getKey(), "test");389 operation.get(OP_ADDR).set(address);390 checkReject(operation, mainServices, version);391 }392 private void checkRejectEndpointConfiguration(KernelServices mainServices, ModelVersion version) throws OperationFailedException {393 // First clean out any worker-thread-pool stuff from earlier testing394 ModelNode operation = new ModelNode();395 operation.get(OP).set(UNDEFINE_ATTRIBUTE_OPERATION);396 ModelNode address = operation.get(OP_ADDR);397 address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);398 for (AttributeDefinition ad : RemotingSubsystemRootResource.ATTRIBUTES) {399 operation.get(NAME).set(ad.getName());400 ModelNode mainResult = mainServices.executeOperation(operation);401 assertEquals(mainResult.toJSONString(true), SUCCESS, mainResult.get(OUTCOME).asString());402 }403 operation = new ModelNode();404 operation.get(OP).set(ADD);405 address = new ModelNode();406 address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);407 address.add(RemotingEndpointResource.ENDPOINT_PATH.getKey(), RemotingEndpointResource.ENDPOINT_PATH.getValue());408 operation.get(OP_ADDR).set(address);409 for (AttributeDefinition ad : RemotingEndpointResource.ATTRIBUTES) {410 ModelNode dflt = ad.getDefaultValue();411 if (dflt != null) {412 operation.get(ad.getName()).set(dflt);413 }414 }415 checkReject(operation, mainServices, version);416 }417 private void checkReject(ModelNode operation, KernelServices mainServices, ModelVersion version) throws OperationFailedException {418 ModelNode mainResult = mainServices.executeOperation(operation);419 assertEquals(mainResult.toJSONString(true), SUCCESS, mainResult.get(OUTCOME).asString());420 final OperationTransformer.TransformedOperation op = mainServices.transformOperation(version, operation);421 final ModelNode result = mainServices.executeOperation(version, op);422 assertEquals("should reject the operation", FAILED, result.get(OUTCOME).asString());423 }424 private List<AttributesPathAddressConfig<?>> toList(AttributesPathAddressConfig<?>...configs){425 List<AttributesPathAddressConfig<?>> list = new ArrayList<AttributesPathAddressConfig<?>>();426 for (AttributesPathAddressConfig<?> config : configs) {427 list.add(config);428 }429 return list;430 }431 private static class FixProtocolConfig extends AttributesPathAddressConfig<FixProtocolConfig> {432 public FixProtocolConfig(String... attributes) {433 super(attributes);434 }435 @Override...

Full Screen

Full Screen

Source:Boot.java Github

copy

Full Screen

...10 import org.newdawn.slick.Color;11 import org.newdawn.slick.TrueTypeFont;12 //keyboard control:13 import org.lwjgl.input.Keyboard;14//substitute main:15 import animals.*;16 import java.awt.*;17 import java.io.ByteArrayOutputStream;18 import java.io.PrintStream;19 import java.util.*;20/**21 * The main part of program22 */23public class Boot {24 public static ArrayList<Object> objectList = new ArrayList<Object>();25 public static TileGrid grid;26 public static Player mainPlayer = new Player(4,3);27 public static Common com;28 public static int tick;29 public static String playerPic = "playerM";30 public static String playerName = "MoonBoy";31 //STDOUT CHECK:32 private final static ByteArrayOutputStream outContent = new ByteArrayOutputStream();33// private final static ByteArrayOutputStream errContent = new ByteArrayOutputStream();34 private final static PrintStream originalOut = System.out;35// private final static PrintStream originalErr = System.err;36 public Boot() {37 tick = 0;38 //call helpers: Artist to load screen:39 beginSession();40 /**41 * Load and draw the map42 */43 //loadmap:44 grid = new TileGrid();45 //drawmap:46 grid.draw();47 //handle objects:48 grid.handleOccupiedTiles();49 //draw objects:50 for(int i =0; i<objectList.size(); ++i){51 objectList.get(i).draw();52 }53 /**54 * Initialize string writer for GUI55 */56 TrueTypeFont font = null;57 Font awtFont = new Font("Times New Roman", Font.BOLD, 20);58 Font awtFont2 = new Font("Times New Roman", Font.BOLD, 14);59 Font awtFont3 = new Font("Calibri", Font.BOLD, 34);60 font = new TrueTypeFont(awtFont, false);61 TrueTypeFont font2 = new TrueTypeFont(awtFont2, false);62 TrueTypeFont font3 = new TrueTypeFont(awtFont3, false);63 String[] inventory_content;64 int pass = 0;65 /**66 * GUI Loop67 */68 while(!Display.isCloseRequested()){ //while not prompted to close69 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);70 font3.drawString(47, 690, "CONTROLS", Color.yellow);71 font2.drawString(50, 730, "Move = w/a/s/d", Color.orange);72 font2.drawString(50, 755, "Grow = g", Color.orange );73 font2.drawString(50, 780, "Talk = t + <arrow_key>",Color.orange);74 font2.drawString(50, 805, "Kill = k + <arrow_key>",Color.orange);75 font2.drawString(50, 830, "Interact = i + <arrow_key>",Color.orange);76 font2.drawString(50, 855, "Mix = m + <arrow_key> + <recipe_code>",Color.orange);77 font2.drawString(50, 880, "Exit = ESC_KEY",Color.orange);78 font3.drawString(345, 690, "RECIPE CODE", Color.green);79 font2.drawString(350, 730, "Mixed Cheese = 0", Color.cyan);80 font2.drawString(350, 755, "(Cow Milk + Goat Milk)", Color.cyan);81 font2.drawString(350, 785, "Horse Rolade = 1", Color.cyan);82 font2.drawString(350, 810, "(Horse Meat + Duck Egg)", Color.cyan);83 font2.drawString(350, 840, "Bacon Omelette = 2", Color.cyan);84 font2.drawString(350, 865, "(Pig Meat + Chicken Egg)", Color.cyan);85 inventory_content = mainPlayer.printBackpack();86 int ystep = 25;87 font3.drawString(560, 690, "INVENTORY:");88 for(int i=0; i<6; ++i){89 font2.drawString(560, 730+(ystep*i), (i+1)+". " + inventory_content[i]);90 if(inventory_content[i] != "") {91 if (inventory_content[i] == "MixedCheese")92 drawQuadTexture(quickLoad("mixedcheese"), 700, 730+(ystep*i), 30, 25);93 else if (inventory_content[i] == "BaconOmelette")94 drawQuadTexture(quickLoad("baconomelette"), 700, 730+(ystep*i), 30, 25);95 else if (inventory_content[i] == "HorseRolade")96 drawQuadTexture(quickLoad("horserolade"), 700, 730+(ystep*i), 30, 25);97 }98 }99 /*100 if (inventory_content[0] != ""){101 drawQuadTexture(quickLoad("MixedCheese"), 600, 730, 50, 50);102 }*/103 font.drawString(900, 700, "OUTPUT:");104 if(outContent.toString().contains("Animal's killed")){105 String[] str_piece = outContent.toString().split("A", 2);106 font.drawString(900, 730, "It cries : " + str_piece[0]);107 font.drawString(900, 755, "A" + str_piece[1]);108 if(Common.animalList.size() == 0){109 font.drawString(900, 780, "---------------");110 font.drawString(900, 805, "Game Over");111 font.drawString(900, 830, "Final Score: " + mainPlayer.getScore());112 }113 } else if(Common.animalList.size() == 0){114 font.drawString(900, 730, "Game Over");115 font.drawString(900, 755, "Final Score: " + mainPlayer.getScore());116 } else{117 font.drawString(900, 730, outContent.toString());118 }119 font.drawString(1150, 700, "TICK = " + tick);120 font.drawString(1150, 730, "MONEY = " + mainPlayer.getScore(), Color.yellow);121 font.drawString(1150, 760, "WATER = " + mainPlayer.getPouch(), Color.blue);122 font.drawString(1150, 900, "");123 drawQuadTexture(quickLoad(playerPic), 1150, 790, 150, 150);124 font.drawString(1150, 900, playerName);125 if((tick % 20) > 10){126 font.drawString(1150, 760, "", Color.blue); // set to malam127 }128 if (Keyboard.next() && Keyboard.getEventKeyState()) {129 outContent.reset();130 setUpStreams();131 //CHANGE PLAYER PIC:132 if (Keyboard.isKeyDown(Keyboard.KEY_P)) {133 if (playerPic == "playerM") {134 playerPic = "playerF";135 playerName = "MoonGurl";136 }137 else{138 playerPic = "playerM";139 playerName = "MoonBoy";140 }141 }142 143 //MIX KEY:144 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_0) && Keyboard.isKeyDown(Keyboard.KEY_UP)) {145 mainPlayer.mix('w', "MixedCheese");146 updateMap();147 }148 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_1) && Keyboard.isKeyDown(Keyboard.KEY_UP)) {149 mainPlayer.mix('w', "HorseRolade");150 updateMap();151 }152 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_2) && Keyboard.isKeyDown(Keyboard.KEY_UP)) {153 mainPlayer.mix('w', "BaconOmelette");154 updateMap();155 }156 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_0) && Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {157 mainPlayer.mix('d', "MixedCheese");158 updateMap();159 }160 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_1) && Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {161 mainPlayer.mix('d', "HorseRolade");162 updateMap();163 }164 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_2) && Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {165 mainPlayer.mix('d', "BaconOmelette");166 updateMap();167 }168 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_0) && Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {169 mainPlayer.mix('s', "MixedCheese");170 updateMap();171 }172 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_1) && Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {173 mainPlayer.mix('s', "HorseRolade");174 updateMap();175 }176 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_2) && Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {177 mainPlayer.mix('s', "BaconOmelette");178 updateMap();179 }180 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_0) && Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {181 mainPlayer.mix('a', "MixedCheese");182 updateMap();183 }184 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_1) && Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {185 mainPlayer.mix('a', "HorseRolade");186 updateMap();187 }188 if (Keyboard.isKeyDown(Keyboard.KEY_M) && Keyboard.isKeyDown(Keyboard.KEY_2) && Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {189 mainPlayer.mix('a', "BaconOmelette");190 updateMap();191 }192 //INTERACT KEY:193 if(Keyboard.isKeyDown(Keyboard.KEY_I) && Keyboard.isKeyDown(Keyboard.KEY_UP) ){194 mainPlayer.interact('w');195 updateMap();196 }197 if(Keyboard.isKeyDown(Keyboard.KEY_I) && Keyboard.isKeyDown(Keyboard.KEY_RIGHT) ){198 mainPlayer.interact('d');199 updateMap();200 }201 if(Keyboard.isKeyDown(Keyboard.KEY_I) && Keyboard.isKeyDown(Keyboard.KEY_DOWN) ){202 mainPlayer.interact('s');203 updateMap();204 }205 if(Keyboard.isKeyDown(Keyboard.KEY_I) && Keyboard.isKeyDown(Keyboard.KEY_LEFT) ) {206 mainPlayer.interact('a');207 updateMap();208 }209 //TALK KEY:210 if (Keyboard.isKeyDown(Keyboard.KEY_T) && Keyboard.isKeyDown(Keyboard.KEY_UP)) {211 mainPlayer.talk('w');212 updateMap();213 }214 if (Keyboard.isKeyDown(Keyboard.KEY_T) && Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {215 mainPlayer.talk('d');216 updateMap();217 }218 if (Keyboard.isKeyDown(Keyboard.KEY_T) && Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {219 mainPlayer.talk('s');220 updateMap();221 }222 if (Keyboard.isKeyDown(Keyboard.KEY_T) && Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {223 mainPlayer.talk('a');224 updateMap();225 }226 //KILL KEY:227 if (Keyboard.isKeyDown(Keyboard.KEY_K) && Keyboard.isKeyDown(Keyboard.KEY_UP)) {228 mainPlayer.kill('w');229 updateMap();230 }231 if (Keyboard.isKeyDown(Keyboard.KEY_K) && Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {232 mainPlayer.kill('d');233 updateMap();234 }235 if (Keyboard.isKeyDown(Keyboard.KEY_K) && Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {236 mainPlayer.kill('s');237 updateMap();238 }239 if (Keyboard.isKeyDown(Keyboard.KEY_K) && Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {240 mainPlayer.kill('a');241 updateMap();242 }243 //GROW KEY:244 if (Keyboard.isKeyDown(Keyboard.KEY_G)) {245 mainPlayer.grow();246 updateMap();247 }248 //EXIT KEY:249 if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {250 break;251 }252 //MOVE KEY:253 if (Keyboard.isKeyDown(Keyboard.KEY_W)) {254 Common.gamemap.get(mainPlayer.getRow()).get(mainPlayer.getCol()).makeUnoccupied();255 mainPlayer.move('w');256 Common.gamemap.get(mainPlayer.getRow()).get(mainPlayer.getCol()).playerOccupy();257 updateMap();258 }259 if (Keyboard.isKeyDown(Keyboard.KEY_A)) {260 Common.gamemap.get(mainPlayer.getRow()).get(mainPlayer.getCol()).makeUnoccupied();261 mainPlayer.move('a');262 Common.gamemap.get(mainPlayer.getRow()).get(mainPlayer.getCol()).playerOccupy();263 updateMap();264 }265 if (Keyboard.isKeyDown(Keyboard.KEY_S)) {266 Common.gamemap.get(mainPlayer.getRow()).get(mainPlayer.getCol()).makeUnoccupied();267 mainPlayer.move('s');268 Common.gamemap.get(mainPlayer.getRow()).get(mainPlayer.getCol()).playerOccupy();269 updateMap();270 }271 if (Keyboard.isKeyDown(Keyboard.KEY_D)) {272 Common.gamemap.get(mainPlayer.getRow()).get(mainPlayer.getCol()).makeUnoccupied();273 mainPlayer.move('d');274 Common.gamemap.get(mainPlayer.getRow()).get(mainPlayer.getCol()).playerOccupy();275 updateMap();276 }277 restoreStreams();278 }279 //drawmap:280 grid.draw();281 //handle objects:282 grid.handleOccupiedTiles();283 //draw objects:284 for(int i =0; i<objectList.size(); ++i){285 objectList.get(i).draw();286 }287 Display.update();288 Display.sync(60);289 if(Common.animalList.size() == 0){290 pass++;291 if(pass > 5){292 try{Thread.sleep(3000);}catch(InterruptedException e){break;}293 break;294 }295 }296 }297 /**298 * Close the GUI Window after Game Over or ESC KEY pressed299 */300 Display.destroy();301 }302 public static void updateMap(){303 tick++;304 for(int i = 0; i < Common.animalList.size(); i++){305 Common.animalList.get(i).minThreshold();306 }307 //Move all animal every 2 ticks308 if(tick != 0 && tick % 2 == 0){309 com.moveAllAnimals();310 }311 //Erase dead animal and eat if hungry312 for(int i = 0; i < Common.animalList.size(); i++){313 Common.gamemap.get(Common.animalList.get(i).getX()).get(Common.animalList.get(i).getY()).makeUnoccupied();314 Common.animalList.get(i).eat();315 Common.gamemap.get(Common.animalList.get(i).getX()).get(Common.animalList.get(i).getY()).animalOccupy(Common.animalList.get(i));316 if(Common.animalList.get(i).getThreshold() <= -5){317 Common.gamemap.get(Common.animalList.get(i).getX()).get(Common.animalList.get(i).getY()).makeUnoccupied();318 //animalList.erase(animalList.begin() + i);319 Common.animalList.remove(i);320 }321 }322 //Update all facilities:323 com.updateAllFacilities();324 objectList.clear();325 //loadmap:326 grid = new TileGrid();327 }328 /**329 * Method to catch STDOUT330 */331 public static void setUpStreams() {332 System.setOut(new PrintStream(outContent));333 //System.setErr(new PrintStream(errContent));334 }335 /**336 * Method to clear the setOut337 */338 public static void restoreStreams() {339 System.setOut(originalOut);340 //System.setErr(originalErr);341 }342 /**343 * Entry point of program.344 * Initialize map reader, spawn animals, and create GUI window345 * @param args346 */347 public static void main(String[] args){348 com = new Common();349 Common.gamemap.get(mainPlayer.getRow()).get(mainPlayer.getCol()).playerOccupy();350 //Bagian Spawn Animal secara random351 //Spawn 3 Chickens352 Random rand = new Random();353 for(int i = 0; i < 3; i++){354 int x = 0;355 int y = 0;356 //Loop until correct position is found357 do{358 x = rand.nextInt(Common.gamemap.size());359 y = rand.nextInt(Common.getGamemap().get(0).size());360 } while(Common.gamemap.get(x).get(y).showSymbol() != 'o' || (Common.gamemap.get(x).get(y).getOverrideSymbol() != '\0'));361 FarmAnimal a = new Chicken(x, y, false);362 //add animal into list of animal363 Common.animalList.add(a);364 //update gamemap365 Common.gamemap.get(x).get(y).animalOccupy(a);366 }367 //Spawn 4 Ducks368 for(int i = 0; i < 4; i++){369 int x = 0;370 int y = 0;371 //Loop until correct position is found372 do{373 x = rand.nextInt(Common.gamemap.size());374 y = rand.nextInt(Common.getGamemap().get(0).size());375 } while(Common.gamemap.get(x).get(y).showSymbol() != 'o' || (Common.gamemap.get(x).get(y).getOverrideSymbol() != '\0'));376 FarmAnimal a = new Duck(x, y, false);377 //add animal into list of animal378 Common.animalList.add(a);379 //update gamemap380 Common.gamemap.get(x).get(y).animalOccupy(a);381 }382 //Spawn 8 Cows383 for(int i = 0; i < 8; i++){384 int x = 0;385 int y = 0;386 //Loop until correct position is found387 do{388 x = rand.nextInt(Common.gamemap.size());389 y = rand.nextInt(Common.getGamemap().get(0).size());390 } while(Common.gamemap.get(x).get(y).showSymbol() != '.' || (Common.gamemap.get(x).get(y).getOverrideSymbol() != '\0'));391 FarmAnimal a = new Cow(x, y, false);392 //add animal into list of animal393 Common.animalList.add(a);394 //update gamemap395 Common.gamemap.get(x).get(y).animalOccupy(a);396 }397 //Spawn 7 Goats398 for(int i = 0; i < 7; i++){399 int x = 0;400 int y = 0;401 //Loop until correct position is found402 do{403 x = rand.nextInt(Common.gamemap.size());404 y = rand.nextInt(Common.getGamemap().get(0).size());405 } while(Common.gamemap.get(x).get(y).showSymbol() != '.' || (Common.gamemap.get(x).get(y).getOverrideSymbol() != '\0'));406 FarmAnimal a = new Goat(x, y, false);407 //add animal into list of animal408 Common.animalList.add(a);409 //update gamemap410 Common.gamemap.get(x).get(y).animalOccupy(a);411 }412 //Spawn 5 Pigs413 for(int i = 0; i < 5; i++){414 int x = 0;415 int y = 0;416 //Loop until correct position is found417 do{418 x = rand.nextInt(Common.gamemap.size());419 y = rand.nextInt(Common.getGamemap().get(0).size());420 } while(Common.gamemap.get(x).get(y).showSymbol() != 'x' || (Common.gamemap.get(x).get(y).getOverrideSymbol() != '\0'));421 FarmAnimal a = new Pig(x, y, false);422 //add animal into list of animal423 Common.animalList.add(a);424 //update gamemap425 Common.gamemap.get(x).get(y).animalOccupy(a);426 }427 //Spawn 4 Horses428 for(int i = 0; i < 4; i++){429 int x = 0;430 int y = 0;431 //Loop until correct position is found432 do{433 x = rand.nextInt(Common.gamemap.size());434 y = rand.nextInt(Common.getGamemap().get(0).size());435 } while(Common.gamemap.get(x).get(y).showSymbol() != 'x' || (Common.gamemap.get(x).get(y).getOverrideSymbol() != '\0'));436 FarmAnimal a = new Horse(x, y, false);437 //add animal into list of animal438 Common.animalList.add(a);439 //update gamemap440 Common.gamemap.get(x).get(y).animalOccupy(a);441 }442 /*443 System.out.println(" GAME OVER");444 System.out.println("---------------------------------------------");445 System.out.println("Final score: " + mainPlayer.getScore());446 */447 //boot the GUI:448 new Boot();449 }450}...

Full Screen

Full Screen

Source:Setup.java Github

copy

Full Screen

1package me.SSP.CommandExecutor;23import java.io.File;4import java.io.FileNotFoundException;5import java.io.IOException;67import org.bukkit.Bukkit;8import org.bukkit.Sound;9import org.bukkit.command.Command;10import org.bukkit.command.CommandExecutor;11import org.bukkit.command.CommandSender;12import org.bukkit.configuration.InvalidConfigurationException;13import org.bukkit.configuration.file.FileConfiguration;14import org.bukkit.configuration.file.YamlConfiguration;15import org.bukkit.entity.ArmorStand;16import org.bukkit.entity.EnderCrystal;17import org.bukkit.entity.EntityType;18import org.bukkit.entity.Player;19import org.bukkit.scheduler.BukkitRunnable;20import org.bukkit.util.EulerAngle;2122import me.SSP.Main;23import me.SSP.Utils.Data;24import me.SSP.Utils.Lists;25import me.SSP.Utils.TitlesAPI;2627public class Setup implements CommandExecutor{28 29 public static File dataYML = new File("plugins/SSP/DATA", "Locations.yml");30 public static FileConfiguration dataCFG = YamlConfiguration.loadConfiguration(dataYML);3132 @Override33 public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {34 35 if(cmd.getName().equalsIgnoreCase("ssp")){36 Player p = (Player)sender;37 if(p.hasPermission("ssp.admin")){38 if(args.length == 1){39 if(args[0].equalsIgnoreCase("remove")){40 if(Lists.removeMode.contains(p)){41 Lists.removeMode.remove(p);42 p.sendMessage(Main.C("&e▸ &fYou &cget out &fof removeLoot mode"));43 44 } else {45 Lists.removeMode.add(p);46 p.sendMessage(Main.C("&e▸ &fYou've &aentered &fremoveLoot mode"));47 }48 }49 50 if(args[0].equalsIgnoreCase("reload")){51 try {52 dataCFG.load(dataYML);53 Data.cfg.load(Data.file);54 Data.cfg.save(Data.file);55 dataCFG.save(dataYML);56 p.sendMessage(Main.C("&e▸ &aSuccessfully &freloading."));57 } catch (FileNotFoundException e) {58 p.sendMessage(Main.C("&e&l(!) &fError while loading &eDataYML"));59 e.printStackTrace();60 } catch (IOException e) {61 p.sendMessage(Main.C("&e&l(!) &fError while loading &eDataYML"));62 e.printStackTrace();63 } catch (InvalidConfigurationException e) {64 p.sendMessage(Main.C("&e&l(!) &fError while loading &eDataYML"));65 e.printStackTrace();66 }67 }68 69 if(args[0].equalsIgnoreCase("set")){70 p.sendMessage(Main.C("&8&m&l------------------------"));71 p.sendMessage(Main.C("&8&l» &f/ssp &cremove"));72 p.sendMessage(Main.C("&8&l» &f/ssp reload"));73 p.sendMessage(Main.C("&8&l» &f/ssp &fset &7Common"));74 p.sendMessage(Main.C("&8&l» &f/ssp &fset &eRare"));75 p.sendMessage(Main.C("&8&l» &f/ssp &fset &cEpic"));76 p.sendMessage(Main.C("&8&l» &f/ssp &fset &5EnderChest"));77 p.sendMessage(Main.C("&8&l» &f/ssp &fset &bTrash"));78 p.sendMessage(Main.C("&8&l» &f/ssp &fset &bShop"));79 p.sendMessage(Main.C("&8&l» &f/ssp &fset &bXPDrop"));80 p.sendMessage(Main.C("&8&l» &f/ssp &fset &bItemsDrop"));81 p.sendMessage(Main.C("&8&m&l------------------------"));82 }83 84 } else if(args.length == 2){85 if(args[0].equalsIgnoreCase("set")){86 if(args[1].equalsIgnoreCase("common")){87 ArmorStand common = (ArmorStand)p.getLocation().getWorld().spawn(p.getLocation(), ArmorStand.class);88 common.setBasePlate(false);89 common.setArms(false);90 common.setVisible(false);91 common.setGravity(false);92 common.setCanPickupItems(false);93 common.setSmall(true);94 common.setHelmet(Main.getHead("common"));95 common.setCustomName("1");96 common.setCustomNameVisible(false);97 p.sendMessage(Main.C("&e▸ &fYou've spawned &7Common &fcrate"));98 p.playSound(p.getLocation(), Sound.LEVEL_UP, 10, 10);99 new BukkitRunnable() {100 101 @Override102 public void run() {103104 common.setHeadPose(new EulerAngle(common.getHeadPose().getX(), common.getHeadPose().getY() + 0.1 , common.getHeadPose().getZ()));105 106 }107 }.runTaskTimerAsynchronously(Main.getPlugin(Main.class), 1L, 1L);108 }109 110 if(args[1].equalsIgnoreCase("rare")){111 ArmorStand rare = (ArmorStand)p.getLocation().getWorld().spawn(p.getLocation(), ArmorStand.class);112 rare.setBasePlate(false);113 rare.setArms(false);114 rare.setVisible(false);115 rare.setGravity(false);116 rare.setCanPickupItems(false);117 rare.setSmall(true);118 rare.setHelmet(Main.getHead("rare"));119 rare.setCustomName("2");120 rare.setCustomNameVisible(false);121 p.sendMessage(Main.C("&e▸ &fYou've spawned &eRare &fcrate"));122 p.playSound(p.getLocation(), Sound.LEVEL_UP, 10, 10);123 new BukkitRunnable() {124 125 @Override126 public void run() {127128 rare.setHeadPose(new EulerAngle(rare.getHeadPose().getX(), rare.getHeadPose().getY() + 0.1 , rare.getHeadPose().getZ()));129 130 }131 }.runTaskTimerAsynchronously(Main.getPlugin(Main.class), 1L, 1L);132 }133 134 if(args[1].equalsIgnoreCase("epic")){135 ArmorStand epic = (ArmorStand)p.getLocation().getWorld().spawn(p.getLocation(), ArmorStand.class);136 epic.setBasePlate(false);137 epic.setArms(false);138 epic.setVisible(false);139 epic.setGravity(false);140 epic.setCanPickupItems(false);141 epic.setSmall(true);142 epic.setHelmet(Main.getHead("epic"));143 epic.setCustomName("3");144 epic.setCustomNameVisible(false);145 p.sendMessage(Main.C("&e▸ &fYou've spawned &cEpic &fcrate"));146 p.playSound(p.getLocation(), Sound.LEVEL_UP, 10, 10);147 new BukkitRunnable() {148 149 @Override150 public void run() {151152 epic.setHeadPose(new EulerAngle(epic.getHeadPose().getX(), epic.getHeadPose().getY() + 0.1 , epic.getHeadPose().getZ()));153 154 }155 }.runTaskTimerAsynchronously(Main.getPlugin(Main.class), 1L, 1L);156 }157 158 if(args[1].equalsIgnoreCase("trash")){159 ArmorStand trash = (ArmorStand)p.getLocation().getWorld().spawn(p.getLocation(), ArmorStand.class);160 trash.setBasePlate(false);161 trash.setArms(false);162 trash.setVisible(false);163 trash.setGravity(false);164 trash.setCanPickupItems(false);165 trash.setSmall(true);166 trash.setHelmet(Main.getHead("trash"));167 trash.setCustomName("4");168 trash.setCustomNameVisible(false);169 p.sendMessage(Main.C("&e▸ &fYou've spawned &bRecycling Bin"));170 p.playSound(p.getLocation(), Sound.LEVEL_UP, 10, 10);171 }172 173 if(args[1].equalsIgnoreCase("enderchest")){174 ArmorStand enderchest = (ArmorStand)p.getLocation().getWorld().spawn(p.getLocation(), ArmorStand.class);175 enderchest.setBasePlate(false);176 enderchest.setArms(false);177 enderchest.setVisible(false);178 enderchest.setGravity(false);179 enderchest.setCanPickupItems(false);180 enderchest.setSmall(true);181 enderchest.setHelmet(Main.getHead("enderchest"));182 enderchest.setCustomName("5");183 enderchest.setCustomNameVisible(false);184 p.sendMessage(Main.C("&e▸ &fYou've spawned &5EnderChest"));185 p.playSound(p.getLocation(), Sound.LEVEL_UP, 10, 10);186 }187 188 if(args[1].equalsIgnoreCase("shop")){189 EnderCrystal shop = (EnderCrystal) Bukkit.getWorld(p.getWorld().getName()).spawnEntity(p.getLocation(), EntityType.ENDER_CRYSTAL);190 shop.setCustomName(Main.C("&7▸ &e&lSky&6&lPvp"));191 shop.setCustomNameVisible(true);192 p.sendMessage(Main.C("&e▸ &fYou've spawned the &eShop&f."));193 p.playSound(p.getLocation(), Sound.LEVEL_UP, 10, 10);194 }195 196 if(args[1].equalsIgnoreCase("xpdrop")){197 dataCFG.set("XPDROP.x", p.getLocation().getX());198 dataCFG.set("XPDROP.y", p.getLocation().getY());199 dataCFG.set("XPDROP.z", p.getLocation().getZ());200 dataCFG.set("XPDROP.world", p.getLocation().getWorld().getName());201 p.sendMessage(Main.C("&e▸ &fYou've set &aXPDrop &flocation!"));202 p.playSound(p.getLocation(), Sound.LEVEL_UP, 10, 10);203 p.sendMessage(Main.C("&e&l(!) &rSaved to &f(&eplugins/SSP/Locations/DATA.yml&f)"));204 try {205 dataCFG.save(dataYML);206 } catch (IOException e) {207 e.printStackTrace();208 }209 }210 }211 } else {212 p.sendMessage(Main.C("&8&m&l------------------------"));213 p.sendMessage(Main.C("&8&l» &f/ssp &cremove"));214 p.sendMessage(Main.C("&8&l» &f/ssp reload"));215 p.sendMessage(Main.C("&8&l» &f/ssp &fset &7Common"));216 p.sendMessage(Main.C("&8&l» &f/ssp &fset &eRare"));217 p.sendMessage(Main.C("&8&l» &f/ssp &fset &cEpic"));218 p.sendMessage(Main.C("&8&l» &f/ssp &fset &5EnderChest"));219 p.sendMessage(Main.C("&8&l» &f/ssp &fset &bTrash"));220 p.sendMessage(Main.C("&8&l» &f/ssp &fset &bShop"));221 p.sendMessage(Main.C("&8&l» &f/ssp &fset &bXPDrop"));222 p.sendMessage(Main.C("&8&l» &f/ssp &fset &bItemsDrop"));223 p.sendMessage(Main.C("&8&m&l------------------------"));224 }225 226 } else {TitlesAPI.sendActionBar(p, Main.C("&4&l» &cPermission (SSP.Admin) Required &4&l«")); p.playSound(p.getLocation(), Sound.NOTE_BASS, 10, 10);}227228 }229 230 return false;231 }232233} ...

Full Screen

Full Screen

main

Using AI Code Generation

copy

Full Screen

1import common.Main;2public class 4 extends Main {3 public static void main(String[] args) {4 Main.main(args);5 }6}7public class Main {8 public static void main(String[] args) {9 System.out.println("Hello World");10 }11}

Full Screen

Full Screen

main

Using AI Code Generation

copy

Full Screen

1import common.Main;2public class 4 extends Main {3 public static void main(String[] args) {4 Main.main(args);5 }6}7public class Main {8 public static void main(String[] args) {9 System.out.println("Hello World");10 }11}

Full Screen

Full Screen

main

Using AI Code Generation

copy

Full Screen

1import common.Main;2public class 4 extends Main {3 public static void main(String[] args) {4 Main.main(args);5 }6}7public class Main {8 public static void main(String[] args) {9 System.out.println("Hello World!");10 }11}

Full Screen

Full Screen

main

Using AI Code Generation

copy

Full Screen

1import common.Main;2{3 public static void main(String[] args)4 {5 Main.main(args);6 }7}8{9 public static void main(String[] args)10 {11 System.out.println("Hello World");12 }13}

Full Screen

Full Screen

main

Using AI Code Generation

copy

Full Screen

1import common.Main;2public class 4 extends Main{3 public static void main(String args[]){4 Main.main(args);5 }6}7public class Main{8 public static void main(String args[]){9 System.out.println("Hello");10 }11}12I have a class 4 which is extending a class Main. I have a main method in class 4 which is calling main method of class Main. I am getting an error saying that the method main(String[]) is undefined for the type Main. How can I fix this?13import java.util.Scanner;14public class PrimeNumbers {15 public static void main(String[] args) {16 Scanner input = new Scanner(System.in);17 int[] primeNumbers = new int[100];18 int count = 0;19 int number = 2;20 while (count < 100) {21 boolean isPrime = true;22 for (int divisor = 2; divisor < number; divisor++) {23 if (number % divisor == 0) {24 isPrime = false;25 break;26 }27 }28 if (isPrime) {29 primeNumbers[count] = number;30 count++;31 }32 number++;33 }34 for (int i = 0; i < 100; i++) {35 System.out.printf("%5d", primeNumbers[i]);36 if ((i + 1) % 10 == 0) {37 System.out.println();38 }39 }40 }41}42import java.util.Scanner;43public class PrimeNumbers {44 public static void main(String[] args) {

Full Screen

Full Screen

main

Using AI Code Generation

copy

Full Screen

1import common.Main;2class MainClass {3 public static void main(String[] args) {4 Main.main(args);5 }6}7import common.Main;8class MainClass {9 public static void main(String[] args) {10 Main.main(args);11 }12}13import common.Main;14class MainClass {15 public static void main(String[] args) {16 Main.main(args);17 }18}19import common.Main;20class MainClass {21 public static void main(String[] args) {22 Main.main(args);23 }24}25import common.Main;26class MainClass {27 public static void main(String[] args) {28 Main.main(args);29 }30}31import common.Main;32class MainClass {33 public static void main(String[] args) {34 Main.main(args);35 }36}37import common.Main;38class MainClass {39 public static void main(String[] args) {40 Main.main(args);41 }42}43import common.Main;44class MainClass {45 public static void main(String[] args) {46 Main.main(args);47 }48}49import common.Main;50class MainClass {51 public static void main(String[] args) {52 Main.main(args);53 }54}55import common.Main;56class MainClass {57 public static void main(String[] args) {58 Main.main(args);59 }60}61import common.Main;62class MainClass {63 public static void main(String[] args) {64 Main.main(args);65 }66}67import common.Main;68class MainClass {69 public static void main(String

Full Screen

Full Screen

main

Using AI Code Generation

copy

Full Screen

1import common.Main;2public class 4 {3 public static void main(String[] args) {4 Main.main(args);5 }6}7public class Main {8 public static void main(String[] args) {9 System.out.println("Hello World");10 }11}

Full Screen

Full Screen

main

Using AI Code Generation

copy

Full Screen

1import common.Main;2public class 4 {3 public static void main(String[] args) {4 Main.main(args);5 }6}7public class Main {8 public static void main(String[] args) {9 System.out.println("Hello World!");10 }11}12import common.Main;13public class 5 implements Main {14 public static void main(String[] args) {15 Main.main(args);16 }17}18public interface Main {19 public static void main(String[] args) {20 System.out.println("Hello World!");21 }22}23import common.Main;24public class 6 implements Main {25 public static void main(String[] args) {26 Main.main(args);27 }28}29public interface Main {30 public static void main(String[] args) {31 Main m = new Main() {};32 m.main();33 }34 private void main() {35 System.out.println("Hello World!");36 }37}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Karate automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in Main

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful